From 14c7b6bcfc4da0f91d9ab4a8fae93f7702ef24a1 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Tue, 16 Jul 2013 20:22:00 +0000 Subject: [PATCH] Added VerticalBlockMatrix from Matrix constructor --- gtsam/base/VerticalBlockMatrix.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gtsam/base/VerticalBlockMatrix.h b/gtsam/base/VerticalBlockMatrix.h index aaf65ac4b..8772487df 100644 --- a/gtsam/base/VerticalBlockMatrix.h +++ b/gtsam/base/VerticalBlockMatrix.h @@ -66,9 +66,8 @@ namespace gtsam { variableColOffsets_.push_back(0); } - /** - * Construct from a container of the sizes of each vertical block, resize the matrix so that its - * height is matrixNewHeight and its width fits the given block dimensions. */ + /** Construct from a container of the sizes of each vertical block, resize the matrix so that + * its height is matrixNewHeight and its width fits the given block dimensions. */ template VerticalBlockMatrix(const CONTAINER dimensions, DenseIndex height) : rowStart_(0), rowEnd_(height), blockStart_(0) @@ -78,6 +77,17 @@ namespace gtsam { assertInvariants(); } + /** Construct from a container of the sizes of each vertical block and a pre-prepared matrix. */ + template + VerticalBlockMatrix(const CONTAINER dimensions, const Matrix& matrix) : + matrix_(matrix), rowStart_(0), rowEnd_(matrix.rows()), blockStart_(0) + { + fillOffsets(dimensions.begin(), dimensions.end()); + if(variableColOffsets_.back() != matrix_.cols()) + throw std::invalid_argument("Requested to create a VerticalBlockMatrix with dimensions that do not sum to the total columns of the provided matrix."); + assertInvariants(); + } + /** * Construct from iterator over the sizes of each vertical block, resize the matrix so that its * height is matrixNewHeight and its width fits the given block dimensions. */