Eigen-unsupported  3.4.90 (git rev a4098ac676528a83cfb73d4d26ce1b42ec05f47c)
Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ > Class Template Reference

Detailed Description

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 :

  1. 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);
  2. 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
_BlockAtCompileTimeThe block layout option. It takes the following values Dynamic : block size known at runtime a numeric number : fixed-size block known at compile time
+ Inheritance diagram for Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >:

Public Member Functions

Index blockCols () const
 
Index blockColsIndex (Index bj) const
 
Index blockPtr (Index id) const
 
Index blockRows () const
 
Index blockRowsIndex (Index bi) const
 
 BlockSparseMatrix (const BlockSparseMatrix &other)
 Copy-constructor.
 
template<typename MatrixType >
 BlockSparseMatrix (const MatrixType &spmat)
 Constructor from a sparse matrix.
 
 BlockSparseMatrix (Index brow, Index bcol)
 Construct and resize.
 
Map< const BlockScalarcoeff (Index brow, Index bcol) const
 
Ref< BlockScalarcoeffRef (Index brow, Index bcol)
 
Index cols () const
 
Index innerToBlock (Index inner) const
 
bool isCompressed () const
 for compatibility purposes with the SparseMatrix class
 
Index nonZeros () const
 
Index nonZerosBlocks () const
 
template<typename MatrixType >
BlockSparseMatrixoperator= (const MatrixType &spmat)
 Assignment from a sparse matrix with the same storage order. More...
 
Index outerToBlock (Index outer) const
 
void reserve (const Index nonzerosblocks)
 Allocate the internal array of pointers to blocks and their inner indices. More...
 
void resize (Index brow, Index bcol)
 Set the number of rows and columns blocks.
 
Index rows () const
 
void setBlockLayout (const VectorXi &rowBlocks, const VectorXi &colBlocks)
 Set the row and column block layouts,. More...
 
void setBlockSize (Index blockSize)
 set the block size at runtime for fixed-size block layout More...
 
template<typename MatrixType >
void setBlockStructure (const MatrixType &blockPattern)
 Set the nonzero block pattern of the matrix. More...
 
template<typename InputIterator >
void setFromTriplets (const InputIterator &begin, const InputIterator &end)
 Fill values in a matrix from a triplet list. More...
 

Member Function Documentation

◆ blockCols()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::blockCols ( ) const
inline
Returns
the number of columns grouped by blocks

◆ blockColsIndex()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::blockColsIndex ( Index  bj) const
inline
Returns
the starting index of the bj col block

◆ blockPtr()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::blockPtr ( Index  id) const
inline
Returns
the starting position of the block id in the array of values

◆ blockRows()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::blockRows ( ) const
inline
Returns
the number of rows grouped by blocks

◆ blockRowsIndex()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::blockRowsIndex ( Index  bi) const
inline
Returns
the starting index of the bi row block

◆ coeff()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Map< const BlockScalar > Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::coeff ( Index  brow,
Index  bcol 
) const
inline
Returns
the value of the (i,j) block as an Eigen Dense Matrix

◆ coeffRef()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Ref< BlockScalar > Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::coeffRef ( Index  brow,
Index  bcol 
)
inline
Returns
a reference to the (i,j) block as an Eigen Dense Matrix

◆ cols()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::cols ( ) const
inline
Returns
the number of cols

◆ innerToBlock()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::innerToBlock ( Index  inner) const
inline
Returns
the block index where inner belongs to

◆ nonZeros()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::nonZeros ( ) const
inline
Returns
the total number of nonzero elements, including eventual explicit zeros in blocks

◆ nonZerosBlocks()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::nonZerosBlocks ( ) const
inline
Returns
the number of nonzero blocks

◆ operator=()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
template<typename MatrixType >
BlockSparseMatrix & Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::operator= ( const MatrixType &  spmat)
inline

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_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::outerToBlock ( Index  outer) const
inline
Returns
the block index where outer belongs to

◆ reserve()

template<typename Scalar_ , int _BlockAtCompileTime, int Options_, typename StorageIndex_ >
void Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::reserve ( const Index  nonzerosblocks)
inline

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
nonzerosblocksNumber 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_ >
Index Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::rows ( ) const
inline
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_ >
void Eigen::BlockSparseMatrix< Scalar_, _BlockAtCompileTime, Options_, StorageIndex_ >::setBlockSize ( Index  blockSize)
inline

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
blockPatternSparse 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: