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 |
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).
template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
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()
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()
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