27 class VerticalBlockMatrix;
58 variableColOffsets_.push_back(0);
63 template<
typename CONTAINER>
67 fillOffsets(dimensions.begin(), dimensions.end(), appendOneDimension);
68 matrix_.resize(variableColOffsets_.back(), variableColOffsets_.back());
73 template<
typename ITERATOR>
77 fillOffsets(firstBlockDim, lastBlockDim, appendOneDimension);
78 matrix_.resize(variableColOffsets_.back(), variableColOffsets_.back());
83 template<
typename CONTAINER>
87 matrix_.resize(matrix.rows(), matrix.cols());
88 matrix_.triangularView<Eigen::Upper>() = matrix.triangularView<Eigen::Upper>();
89 fillOffsets(dimensions.begin(), dimensions.end(), appendOneDimension);
90 if(matrix_.rows() != matrix_.cols())
91 throw std::invalid_argument(
"Requested to create a SymmetricBlockMatrix from a non-square matrix.");
92 if(variableColOffsets_.back() != matrix_.cols())
93 throw std::invalid_argument(
"Requested to create a SymmetricBlockMatrix with dimensions that do not sum to the total size of the provided matrix.");
108 DenseIndex rows()
const { assertInvariants();
return variableColOffsets_.back() - variableColOffsets_[blockStart_]; }
114 DenseIndex nBlocks()
const { assertInvariants();
return variableColOffsets_.size() - 1 - blockStart_; }
119 return Block(*
this, i_block, j_block);
134 return Block(*
this, i_startBlock, j_startBlock, i_endBlock - i_startBlock, j_endBlock - j_startBlock);
143 return constBlock(*
this, i_startBlock, j_startBlock, i_endBlock - i_startBlock, j_endBlock - j_startBlock);
149 return Block(*
this, 0, nBlocks(), 0);
159 Eigen::SelfAdjointView<const Matrix, Eigen::Upper>
matrix()
const
165 Eigen::SelfAdjointView<Matrix, Eigen::Upper>
matrix()
175 checkBlock(actualBlock);
176 return variableColOffsets_[actualBlock];
193 void assertInvariants()
const
195 assert(matrix_.rows() == matrix_.cols());
196 assert(matrix_.cols() == variableColOffsets_.back());
197 assert(blockStart_ < (
DenseIndex)variableColOffsets_.size());
202 assert(matrix_.rows() == matrix_.cols());
203 assert(matrix_.cols() == variableColOffsets_.back());
205 assert(block < (
DenseIndex)variableColOffsets_.size()-1);
206 assert(variableColOffsets_[block] < matrix_.cols() && variableColOffsets_[block+1] <= matrix_.cols());
211 return variableColOffsets_[block + blockStart_];
214 template<
typename ITERATOR>
215 void fillOffsets(ITERATOR firstBlockDim, ITERATOR lastBlockDim,
bool appendOneDimension)
217 variableColOffsets_.resize((lastBlockDim-firstBlockDim) + 1 + (appendOneDimension ? 1 : 0));
218 variableColOffsets_[0] = 0;
220 for(ITERATOR
dim=firstBlockDim;
dim!=lastBlockDim; ++
dim) {
221 variableColOffsets_[j+1] = variableColOffsets_[j] + *
dim;
224 if(appendOneDimension)
226 variableColOffsets_[j+1] = variableColOffsets_[j] + 1;
231 friend class VerticalBlockMatrix;
232 template<
typename SymmetricBlockMatrixType>
friend class SymmetricBlockMatrixBlockExpr;
236 friend class boost::serialization::access;
237 template<
class ARCHIVE>
238 void serialize(ARCHIVE & ar,
const unsigned int version) {
242 matrix_.triangularView<Eigen::Lower>() = matrix_.triangularView<Eigen::Upper>().transpose();
243 ar & BOOST_SERIALIZATION_NVP(matrix_);
244 ar & BOOST_SERIALIZATION_NVP(variableColOffsets_);
245 ar & BOOST_SERIALIZATION_NVP(blockStart_);
constBlock operator()(DenseIndex i_block, DenseIndex j_block) const
Access the block with vertical block index i_block and horizontal block index j_block.
Definition: SymmetricBlockMatrix.h:124
DenseIndex cols() const
Column size.
Definition: SymmetricBlockMatrix.h:111
Eigen::SelfAdjointView< const Matrix, Eigen::Upper > matrix() const
Access to full matrix, including any portions excluded by firstBlock() to other operations.
Definition: SymmetricBlockMatrix.h:159
SymmetricBlockMatrix(ITERATOR firstBlockDim, ITERATOR lastBlockDim, bool appendOneDimension=false)
Construct from iterator over the sizes of each vertical block.
Definition: SymmetricBlockMatrix.h:74
bool choleskyPartial(Matrix &ABC, size_t nFrontal)
Partial Cholesky computes a factor [R S such that [R' 0 [R S = [A B 0 L] S' I] 0 L] B' C]...
Definition: cholesky.cpp:121
Base exception type that uses tbb_exception if GTSAM is compiled with TBB.
Definition: types.h:154
Block operator()(DenseIndex i_block, DenseIndex j_block)
Access the block with vertical block index i_block and horizontal block index j_block.
Definition: SymmetricBlockMatrix.h:118
Definition: VerticalBlockMatrix.h:41
FastVector< DenseIndex > variableColOffsets_
the starting columns of each block (0-based)
Definition: SymmetricBlockMatrix.h:49
Eigen::SelfAdjointView< Matrix, Eigen::Upper > matrix()
Access to full matrix, including any portions excluded by firstBlock() to other operations.
Definition: SymmetricBlockMatrix.h:165
size_t dim(const Vector &v)
dimensionality == size
Definition: Vector.h:90
DenseIndex rows() const
Row size.
Definition: SymmetricBlockMatrix.h:108
SymmetricBlockMatrix(const CONTAINER &dimensions, bool appendOneDimension=false)
Construct from a container of the sizes of each block.
Definition: SymmetricBlockMatrix.h:64
SymmetricBlockMatrix(const CONTAINER &dimensions, const Matrix &matrix, bool appendOneDimension=false)
Construct from a container of the sizes of each vertical block and a pre-prepared matrix...
Definition: SymmetricBlockMatrix.h:84
DenseIndex blockStart() const
Retrieve the first logical block, i.e.
Definition: SymmetricBlockMatrix.h:186
constBlock full() const
Return the full matrix, not including any portions excluded by firstBlock().
Definition: SymmetricBlockMatrix.h:153
A matrix expression that references a single block of a SymmetricBlockMatrix.
Definition: SymmetricBlockMatrixBlockExpr.h:22
Definition: SymmetricBlockMatrix.h:250
constBlock range(DenseIndex i_startBlock, DenseIndex i_endBlock, DenseIndex j_startBlock, DenseIndex j_endBlock) const
Access the range of blocks starting with vertical block index i_startBlock, ending with vertical bloc...
Definition: SymmetricBlockMatrix.h:141
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition: types.h:74
typedef and functions to augment Eigen's MatrixXd
Matrix matrix_
The full matrix.
Definition: SymmetricBlockMatrix.h:48
Block range(DenseIndex i_startBlock, DenseIndex i_endBlock, DenseIndex j_startBlock, DenseIndex j_endBlock)
Access the range of blocks starting with vertical block index i_startBlock, ending with vertical bloc...
Definition: SymmetricBlockMatrix.h:132
Definition: SymmetricBlockMatrix.h:40
DenseIndex & blockStart()
Retrieve or modify the first logical block, i.e.
Definition: SymmetricBlockMatrix.h:182
SymmetricBlockMatrix()
Construct from an empty matrix (asserts that the matrix is empty)
Definition: SymmetricBlockMatrix.h:55
Block full()
Return the full matrix, not including any portions excluded by firstBlock().
Definition: SymmetricBlockMatrix.h:147
DenseIndex blockStart_
Changes apparent matrix view, see main class comment.
Definition: SymmetricBlockMatrix.h:51
DenseIndex offset(DenseIndex block) const
Return the absolute offset in the underlying matrix of the start of the specified block...
Definition: SymmetricBlockMatrix.h:171
DenseIndex nBlocks() const
Block count.
Definition: SymmetricBlockMatrix.h:114
Matrix expression for a block of a SymmetricBlockMatrix.
A thin wrapper around std::vector that uses boost's pool_allocator.