From 941cd93bf6ba2357ee19996ac626c6a267c6835f Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Fri, 12 Jul 2013 22:27:44 +0000 Subject: [PATCH] Returning empty noise model from QR and fix for backwards-compatibility in old code --- gtsam/linear/JacobianFactor.cpp | 5 +++++ gtsam/linear/NoiseModel.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gtsam/linear/JacobianFactor.cpp b/gtsam/linear/JacobianFactor.cpp index 5de446d25..4493d2b00 100644 --- a/gtsam/linear/JacobianFactor.cpp +++ b/gtsam/linear/JacobianFactor.cpp @@ -476,6 +476,11 @@ namespace gtsam { // Use in-place QR dense Ab appropriate to NoiseModel gttic(QR); SharedDiagonal noiseModel = model_->QR(matrix_); + // In the new unordered code, empty noise model indicates unit noise model, and I already + // modified QR to return an empty noise model. This just creates a unit noise model in that + // case because this old code does not handle empty noise models. + if(!noiseModel) + noiseModel = noiseModel::Unit::Create(std::min(matrix_.rows(), matrix_.cols() - 1)); gttoc(QR); // Zero the lower-left triangle. todo: not all of these entries actually diff --git a/gtsam/linear/NoiseModel.cpp b/gtsam/linear/NoiseModel.cpp index 473d1b839..b72843b83 100644 --- a/gtsam/linear/NoiseModel.cpp +++ b/gtsam/linear/NoiseModel.cpp @@ -131,7 +131,7 @@ SharedDiagonal Gaussian::QR(Matrix& Ab) const { // TODO: necessary to isolate last column? // householder(Ab, maxRank); - return Unit::Create(maxRank); + return SharedDiagonal(); } void Gaussian::WhitenSystem(vector& A, Vector& b) const {