Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Eigen::BlockSparseMatrix Class Reference

A versatile sparse matrix representation where each element is a block. More...

#include <BlockSparseMatrix.h>

Classes

class  BlockInnerIterator
 
class  InnerIterator
 

Public Types

enum  {
  Options = _Options, Flags = Options, BlockSize =_BlockAtCompileTime, RowsAtCompileTime = Dynamic,
  ColsAtCompileTime = Dynamic, MaxRowsAtCompileTime = Dynamic, MaxColsAtCompileTime = Dynamic, IsVectorAtCompileTime = 0,
  IsColMajor = Flags&RowMajorBit ? 0 : 1
}
 
typedef Matrix< RealScalar, _BlockAtCompileTime, _BlockAtCompileTime, IsColMajor ? ColMajor :RowMajorBlockRealScalar
 
typedef Matrix< Scalar, _BlockAtCompileTime, _BlockAtCompileTime, IsColMajor ? ColMajor :RowMajorBlockScalar
 
typedef internal::conditional< _BlockAtCompileTime==Dynamic, Scalar, BlockScalar >::type BlockScalarReturnType
 
typedef internal::ref_selector< BlockSparseMatrix< _Scalar, _BlockAtCompileTime, _Options, _StorageIndex > >::type Nested
 
typedef BlockSparseMatrix< Scalar, BlockSize, IsColMajor ? ColMajor :RowMajor, StorageIndexPlainObject
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef _Scalar Scalar
 
typedef _StorageIndex StorageIndex
 

Public Member Functions

Index blockCols () const
 
Index blockColsIndex (Index bj) const
 
Index blockInnerIndex (Index bi) const
 
Index blockInnerSize (Index bi) const
 
Index blockOuterIndex (Index bj) const
 
Index blockOuterSize (Index bj) const
 
Index blockPtr (Index id) const
 
Index blockRows () const
 
Index blockRowsIndex (Index bi) const
 
 BlockSparseMatrix ()
 
 BlockSparseMatrix (const BlockSparseMatrix &other)
 Copy-constructor. More...
 
template<typename MatrixType >
 BlockSparseMatrix (const MatrixType &spmat)
 Constructor from a sparse matrix. More...
 
 BlockSparseMatrix (Index brow, Index bcol)
 Construct and resize. More...
 
Map< const BlockScalarcoeff (Index brow, Index bcol) const
 
Ref< BlockScalarcoeffRef (Index brow, Index bcol)
 
Index cols () const
 
Index innerBlocks () const
 
StorageIndexinnerIndexPtr ()
 
const StorageIndexinnerIndexPtr () const
 
Index innerSize () const
 
Index innerToBlock (Index inner) const
 
bool isCompressed () const
 for compatibility purposes with the SparseMatrix class More...
 
Index nonZeros () const
 
Index nonZerosBlocks () const
 
template<typename VecType >
BlockSparseTimeDenseProduct< BlockSparseMatrix, VecType > operator* (const VecType &lhs) const
 
BlockSparseMatrixoperator= (BlockSparseMatrix other)
 
template<typename MatrixType >
BlockSparseMatrixoperator= (const MatrixType &spmat)
 Assignment from a sparse matrix with the same storage order. More...
 
Index outerBlocks () const
 
StorageIndexouterIndexPtr ()
 
const StorageIndexouterIndexPtr () const
 
Index outerSize () const
 
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. More...
 
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...
 
BlockScalarReturnTypevaluePtr ()
 
 ~BlockSparseMatrix ()
 

Protected Member Functions

Map< BlockScalarinsert (Index brow, Index bcol)
 

Protected Attributes

StorageIndexm_blockPtr
 
Index m_blockSize
 
StorageIndexm_indices
 
Index m_innerBSize
 
StorageIndexm_innerOffset
 
Index m_nonzeros
 
Index m_nonzerosblocks
 
Index m_outerBSize
 
StorageIndexm_outerIndex
 
StorageIndexm_outerOffset
 
Scalarm_values
 

Friends

std::ostream & operator<< (std::ostream &s, const BlockSparseMatrix &m)
 
void swap (BlockSparseMatrix &first, BlockSparseMatrix &second)
 

Detailed Description

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
_ScalarThe 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

Definition at line 54 of file BlockSparseMatrix.h.

Member Typedef Documentation

◆ BlockRealScalar

typedef Matrix<RealScalar, _BlockAtCompileTime, _BlockAtCompileTime,IsColMajor ? ColMajor : RowMajor> Eigen::BlockSparseMatrix::BlockRealScalar

Definition at line 304 of file BlockSparseMatrix.h.

◆ BlockScalar

typedef Matrix<Scalar, _BlockAtCompileTime, _BlockAtCompileTime,IsColMajor ? ColMajor : RowMajor> Eigen::BlockSparseMatrix::BlockScalar

Definition at line 303 of file BlockSparseMatrix.h.

◆ BlockScalarReturnType

Definition at line 305 of file BlockSparseMatrix.h.

◆ Nested

typedef internal::ref_selector<BlockSparseMatrix<_Scalar, _BlockAtCompileTime, _Options, _StorageIndex> >::type Eigen::BlockSparseMatrix::Nested

Definition at line 290 of file BlockSparseMatrix.h.

◆ PlainObject

Definition at line 306 of file BlockSparseMatrix.h.

◆ RealScalar

Definition at line 288 of file BlockSparseMatrix.h.

◆ Scalar

Definition at line 287 of file BlockSparseMatrix.h.

◆ StorageIndex

Definition at line 289 of file BlockSparseMatrix.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Options 
Flags 
BlockSize 
RowsAtCompileTime 
ColsAtCompileTime 
MaxRowsAtCompileTime 
MaxColsAtCompileTime 
IsVectorAtCompileTime 
IsColMajor 

Definition at line 292 of file BlockSparseMatrix.h.

Constructor & Destructor Documentation

◆ BlockSparseMatrix() [1/4]

Eigen::BlockSparseMatrix::BlockSparseMatrix ( )
inline

Definition at line 309 of file BlockSparseMatrix.h.

◆ BlockSparseMatrix() [2/4]

Eigen::BlockSparseMatrix::BlockSparseMatrix ( Index  brow,
Index  bcol 
)
inline

Construct and resize.

Definition at line 320 of file BlockSparseMatrix.h.

◆ BlockSparseMatrix() [3/4]

Eigen::BlockSparseMatrix::BlockSparseMatrix ( const BlockSparseMatrix other)
inline

Copy-constructor.

Definition at line 331 of file BlockSparseMatrix.h.

◆ ~BlockSparseMatrix()

Eigen::BlockSparseMatrix::~BlockSparseMatrix ( )
inline

Definition at line 373 of file BlockSparseMatrix.h.

◆ BlockSparseMatrix() [4/4]

template<typename MatrixType >
Eigen::BlockSparseMatrix::BlockSparseMatrix ( const MatrixType spmat)
inline

Constructor from a sparse matrix.

Definition at line 389 of file BlockSparseMatrix.h.

Member Function Documentation

◆ blockCols()

Index Eigen::BlockSparseMatrix::blockCols ( ) const
inline
Returns
the number of columns grouped by blocks

Definition at line 770 of file BlockSparseMatrix.h.

◆ blockColsIndex()

Index Eigen::BlockSparseMatrix::blockColsIndex ( Index  bj) const
inline
Returns
the starting index of the bj col block

Definition at line 884 of file BlockSparseMatrix.h.

◆ blockInnerIndex()

Index Eigen::BlockSparseMatrix::blockInnerIndex ( Index  bi) const
inline

Definition at line 893 of file BlockSparseMatrix.h.

◆ blockInnerSize()

Index Eigen::BlockSparseMatrix::blockInnerSize ( Index  bi) const
inline

Definition at line 899 of file BlockSparseMatrix.h.

◆ blockOuterIndex()

Index Eigen::BlockSparseMatrix::blockOuterIndex ( Index  bj) const
inline

Definition at line 889 of file BlockSparseMatrix.h.

◆ blockOuterSize()

Index Eigen::BlockSparseMatrix::blockOuterSize ( Index  bj) const
inline

Definition at line 903 of file BlockSparseMatrix.h.

◆ blockPtr()

Index Eigen::BlockSparseMatrix::blockPtr ( Index  id) const
inline
Returns
the starting position of the block id in the array of values

Definition at line 936 of file BlockSparseMatrix.h.

◆ blockRows()

Index Eigen::BlockSparseMatrix::blockRows ( ) const
inline
Returns
the number of rows grouped by blocks

Definition at line 765 of file BlockSparseMatrix.h.

◆ blockRowsIndex()

Index Eigen::BlockSparseMatrix::blockRowsIndex ( Index  bi) const
inline
Returns
the starting index of the bi row block

Definition at line 876 of file BlockSparseMatrix.h.

◆ coeff()

Map<const BlockScalar> Eigen::BlockSparseMatrix::coeff ( Index  brow,
Index  bcol 
) const
inline
Returns
the value of the (i,j) block as an Eigen Dense Matrix

Definition at line 832 of file BlockSparseMatrix.h.

◆ coeffRef()

Ref<BlockScalar> Eigen::BlockSparseMatrix::coeffRef ( Index  brow,
Index  bcol 
)
inline
Returns
a reference to the (i,j) block as an Eigen Dense Matrix

Definition at line 806 of file BlockSparseMatrix.h.

◆ cols()

Index Eigen::BlockSparseMatrix::cols ( ) const
inline
Returns
the number of cols

Definition at line 747 of file BlockSparseMatrix.h.

◆ innerBlocks()

Index Eigen::BlockSparseMatrix::innerBlocks ( ) const
inline

Definition at line 776 of file BlockSparseMatrix.h.

◆ innerIndexPtr() [1/2]

StorageIndex* Eigen::BlockSparseMatrix::innerIndexPtr ( )
inline

Definition at line 866 of file BlockSparseMatrix.h.

◆ innerIndexPtr() [2/2]

const StorageIndex* Eigen::BlockSparseMatrix::innerIndexPtr ( ) const
inline

Definition at line 867 of file BlockSparseMatrix.h.

◆ innerSize()

Index Eigen::BlockSparseMatrix::innerSize ( ) const
inline

Definition at line 753 of file BlockSparseMatrix.h.

◆ innerToBlock()

Index Eigen::BlockSparseMatrix::innerToBlock ( Index  inner) const
inline
Returns
the block index where inner belongs to

Definition at line 791 of file BlockSparseMatrix.h.

◆ insert()

Map<BlockScalar> Eigen::BlockSparseMatrix::insert ( Index  brow,
Index  bcol 
)
protected

◆ isCompressed()

bool Eigen::BlockSparseMatrix::isCompressed ( ) const
inline

for compatibility purposes with the SparseMatrix class

Definition at line 872 of file BlockSparseMatrix.h.

◆ nonZeros()

Index Eigen::BlockSparseMatrix::nonZeros ( ) const
inline
Returns
the total number of nonzero elements, including eventual explicit zeros in blocks

Definition at line 862 of file BlockSparseMatrix.h.

◆ nonZerosBlocks()

Index Eigen::BlockSparseMatrix::nonZerosBlocks ( ) const
inline
Returns
the number of nonzero blocks

Definition at line 860 of file BlockSparseMatrix.h.

◆ operator*()

template<typename VecType >
BlockSparseTimeDenseProduct<BlockSparseMatrix, VecType> Eigen::BlockSparseMatrix::operator* ( const VecType &  lhs) const
inline

Definition at line 854 of file BlockSparseMatrix.h.

◆ operator=() [1/2]

BlockSparseMatrix& Eigen::BlockSparseMatrix::operator= ( BlockSparseMatrix  other)
inline

Definition at line 365 of file BlockSparseMatrix.h.

◆ operator=() [2/2]

template<typename MatrixType >
BlockSparseMatrix& Eigen::BlockSparseMatrix::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).

Definition at line 405 of file BlockSparseMatrix.h.

◆ outerBlocks()

Index Eigen::BlockSparseMatrix::outerBlocks ( ) const
inline

Definition at line 775 of file BlockSparseMatrix.h.

◆ outerIndexPtr() [1/2]

StorageIndex* Eigen::BlockSparseMatrix::outerIndexPtr ( )
inline

Definition at line 868 of file BlockSparseMatrix.h.

◆ outerIndexPtr() [2/2]

const StorageIndex* Eigen::BlockSparseMatrix::outerIndexPtr ( ) const
inline

Definition at line 869 of file BlockSparseMatrix.h.

◆ outerSize()

Index Eigen::BlockSparseMatrix::outerSize ( ) const
inline

Definition at line 759 of file BlockSparseMatrix.h.

◆ outerToBlock()

Index Eigen::BlockSparseMatrix::outerToBlock ( Index  outer) const
inline
Returns
the block index where outer belongs to

Definition at line 779 of file BlockSparseMatrix.h.

◆ reserve()

void Eigen::BlockSparseMatrix::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()

Definition at line 596 of file BlockSparseMatrix.h.

◆ resize()

void Eigen::BlockSparseMatrix::resize ( Index  brow,
Index  bcol 
)
inline

Set the number of rows and columns blocks.

Definition at line 538 of file BlockSparseMatrix.h.

◆ rows()

Index Eigen::BlockSparseMatrix::rows ( ) const
inline
Returns
the number of rows

Definition at line 738 of file BlockSparseMatrix.h.

◆ setBlockLayout()

void Eigen::BlockSparseMatrix::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()

Definition at line 563 of file BlockSparseMatrix.h.

◆ setBlockSize()

void Eigen::BlockSparseMatrix::setBlockSize ( Index  blockSize)
inline

set the block size at runtime for fixed-size block layout

Call this only for fixed-size blocks

Definition at line 549 of file BlockSparseMatrix.h.

◆ setBlockStructure()

template<typename MatrixType >
void Eigen::BlockSparseMatrix::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()

Definition at line 498 of file BlockSparseMatrix.h.

◆ setFromTriplets()

template<typename InputIterator >
void Eigen::BlockSparseMatrix::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

Definition at line 631 of file BlockSparseMatrix.h.

◆ valuePtr()

BlockScalarReturnType* Eigen::BlockSparseMatrix::valuePtr ( )
inline

Definition at line 864 of file BlockSparseMatrix.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  s,
const BlockSparseMatrix m 
)
friend

Definition at line 918 of file BlockSparseMatrix.h.

◆ swap

void swap ( BlockSparseMatrix first,
BlockSparseMatrix second 
)
friend

Definition at line 350 of file BlockSparseMatrix.h.

Member Data Documentation

◆ m_blockPtr

StorageIndex* Eigen::BlockSparseMatrix::m_blockPtr
protected

Definition at line 965 of file BlockSparseMatrix.h.

◆ m_blockSize

Index Eigen::BlockSparseMatrix::m_blockSize
protected

Definition at line 968 of file BlockSparseMatrix.h.

◆ m_indices

StorageIndex* Eigen::BlockSparseMatrix::m_indices
protected

Definition at line 966 of file BlockSparseMatrix.h.

◆ m_innerBSize

Index Eigen::BlockSparseMatrix::m_innerBSize
protected

Definition at line 958 of file BlockSparseMatrix.h.

◆ m_innerOffset

StorageIndex* Eigen::BlockSparseMatrix::m_innerOffset
protected

Definition at line 960 of file BlockSparseMatrix.h.

◆ m_nonzeros

Index Eigen::BlockSparseMatrix::m_nonzeros
protected

Definition at line 963 of file BlockSparseMatrix.h.

◆ m_nonzerosblocks

Index Eigen::BlockSparseMatrix::m_nonzerosblocks
protected

Definition at line 962 of file BlockSparseMatrix.h.

◆ m_outerBSize

Index Eigen::BlockSparseMatrix::m_outerBSize
protected

Definition at line 959 of file BlockSparseMatrix.h.

◆ m_outerIndex

StorageIndex* Eigen::BlockSparseMatrix::m_outerIndex
protected

Definition at line 967 of file BlockSparseMatrix.h.

◆ m_outerOffset

StorageIndex* Eigen::BlockSparseMatrix::m_outerOffset
protected

Definition at line 961 of file BlockSparseMatrix.h.

◆ m_values

Scalar* Eigen::BlockSparseMatrix::m_values
protected

Definition at line 964 of file BlockSparseMatrix.h.


The documentation for this class was generated from the following file:


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:09:28