Eigen::BlockSparseMatrix
template<typename _Scalar, int _BlockAtCompileTime, int _Options, typename _StorageIndex>
class Eigen::BlockSparseMatrix< _Scalar, _BlockAtCompileTime, _Options, _StorageIndex >
A versatile sparse matrix representation where each element is a block.
This class provides routines to manipulate block sparse matrices stored in a BSR-like representation. There are two main types :
- All blocks have the same number of rows and columns, called block size in the following. In this case, if this block size is known at compile time, it can be given as a template parameter like
BlockSparseMatrix<Scalar, 3, ColMajor> bmat(b_rows, b_cols);
Here, bmat is a b_rows x b_cols block sparse matrix where each coefficient is a 3x3 dense matrix. If the block size is fixed but will be given at runtime, BlockSparseMatrix<Scalar, Dynamic, ColMajor> bmat(b_rows, b_cols);
bmat.setBlockSize(block_size);
- The second case is for variable-block sparse matrices. Here each block has its own dimensions. The only restriction is that all the blocks in a row (resp. a column) should have the same number of rows (resp. of columns). It is thus required in this case to describe the layout of the matrix by calling setBlockLayout(rowBlocks, colBlocks).
In any of the previous case, the matrix can be filled by calling setFromTriplets(). A regular sparse matrix can be converted to a block sparse matrix and vice versa. It is obviously required to describe the block layout beforehand by calling either setBlockSize() for fixed-size blocks or setBlockLayout for variable-size blocks.
- Template Parameters
-
_Scalar |
The Scalar type |
_BlockAtCompileTime |
The block layout option. It takes the following values Dynamic : block size known at runtime a numeric number : fixed-size block known at compile time |
blockCols()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the number of columns grouped by blocks
blockColsIndex()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the starting index of the bj col block
blockPtr()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the starting position of the block
id
in the array of values
blockRows()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the number of rows grouped by blocks
blockRowsIndex()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the starting index of the bi row block
coeff()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
coeffRef()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
cols()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the number of cols
innerToBlock()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the block index where inner belongs to
nonZeros()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the total number of nonzero elements, including eventual explicit zeros in blocks
nonZerosBlocks()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the number of nonzero blocks
operator=()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
template<typename MatrixType >
Assignment from a sparse matrix with the same storage order.
Convert from a sparse matrix to block sparse matrix.
- Warning
- Before calling this function, tt is necessary to call either setBlockLayout() (matrices with variable-size blocks) or setBlockSize() (for fixed-size blocks).
outerToBlock()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the block index where outer belongs to
reserve()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
Allocate the internal array of pointers to blocks and their inner indices.
- Note
- For fixed-size blocks, call setBlockSize() to set the block. And For variable-size blocks, call setBlockLayout() before using this function
- Parameters
-
nonzerosblocks |
Number of nonzero blocks. The total number of nonzeros is is computed in setBlockLayout() for variable-size blocks |
- See also
-
setBlockSize()
rows()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
- Returns
- the number of rows
setBlockLayout()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
void Eigen::BlockSparseMatrix< _Scalar, _BlockAtCompileTime, _Options, _StorageIndex >::setBlockLayout | ( | const VectorXi & |
rowBlocks, | | | const VectorXi & |
colBlocks | | ) | |
| | inline |
Set the row and column block layouts,.
This function set the size of each row and column block. So this function should be used only for blocks with variable size.
- Parameters
-
rowBlocks |
: Number of rows per row block |
colBlocks |
: Number of columns per column block |
- See also
-
resize(), setBlockSize()
setBlockSize()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
set the block size at runtime for fixed-size block layout
Call this only for fixed-size blocks
setBlockStructure()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
template<typename MatrixType >
void Eigen::BlockSparseMatrix< _Scalar, _BlockAtCompileTime, _Options, _StorageIndex >::setBlockStructure | ( | const MatrixType & | blockPattern |
) | | | inline |
Set the nonzero block pattern of the matrix.
Given a sparse matrix describing the nonzero block pattern, this function prepares the internal pointers for values. After calling this function, any nonzero block (bi, bj) can be set with a simple call to coeffRef(bi,bj).
- Warning
- Before calling this function, tt is necessary to call either setBlockLayout() (matrices with variable-size blocks) or setBlockSize() (for fixed-size blocks).
- Parameters
-
blockPattern |
Sparse matrix of boolean elements describing the block structure |
- See also
-
setBlockLayout()
- setBlockSize()
setFromTriplets()
template<typename _Scalar , int _BlockAtCompileTime, int _Options, typename _StorageIndex >
template<typename InputIterator >
void Eigen::BlockSparseMatrix< _Scalar, _BlockAtCompileTime, _Options, _StorageIndex >::setFromTriplets | ( | const InputIterator & |
begin, | | | const InputIterator & |
end | | ) | |
| | inline |
Fill values in a matrix from a triplet list.
Each triplet item has a block stored in an Eigen dense matrix. The InputIterator class should provide the functions row(), col() and value()
- Note
- For fixed-size blocks, call setBlockSize() before this function.
FIXME Do not accept duplicates
The documentation for this class was generated from the following file: