So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
bogus::BlockMatrixBase< Derived > Class Template Reference

Base class for dense and sparse block matrices, thought dense don't exist yet. More...

#include <BlockMatrixBase.hpp>

Inheritance diagram for bogus::BlockMatrixBase< Derived >:
bogus::IterableBlockObject< Derived > bogus::BlockObjectBase< Derived > bogus::SparseBlockMatrixBase< Derived > bogus::SparseBlockMatrixBase< MappedSparseBlockMatrix< BlockT, Flags, Index_ > > bogus::SparseBlockMatrixBase< SparseBlockMatrix< BlockT, Flags > > bogus::SparseBlockMatrix< Eigen::Matrix< double, Dimension, Dimension > > bogus::SparseBlockMatrix< Eigen::Matrix< double, Dimension, Dimension, Eigen::RowMajor >, SYMMETRIC > bogus::SparseBlockMatrix< Eigen::MatrixXd > bogus::SparseBlockMatrix< HBlock, UNCOMPRESSED > bogus::SparseBlockMatrix< LU< Eigen::MatrixBase< Eigen::MatrixXd > > > bogus::MappedSparseBlockMatrix< BlockT, Flags, Index_ > bogus::SparseBlockMatrix< BlockT, Flags >

Public Types

enum  CompileTimeProperties {
  RowsPerBlock = Traits::RowsPerBlock, ColsPerBlock = Traits::ColsPerBlock, has_row_major_blocks = BlockTraits< BlockType >::is_row_major, has_square_or_dynamic_blocks = ColsPerBlock == RowsPerBlock,
  has_fixed_rows_blocks = ((int) RowsPerBlock != internal::DYNAMIC ), has_fixed_cols_blocks = ((int) ColsPerBlock != internal::DYNAMIC ), has_fixed_size_blocks = has_fixed_cols_blocks && has_fixed_rows_blocks
}
 Compile-time block properties.
 
typedef BlockMatrixTraits
< Derived > 
Traits
 
typedef Traits::Index Index
 
typedef Traits::Scalar Scalar
 
typedef Traits::BlockType BlockType
 
typedef Traits::BlockPtr BlockPtr
 
typedef Traits::BlocksArrayType BlocksArrayType
 
typedef IterableBlockObject
< Derived > 
Base
 
enum  { is_transposed = Traits::is_transposed }
 
enum  { RowsAtCompileTime = internal::DYNAMIC, ColsAtCompileTime = internal::DYNAMIC, is_self_transpose = Traits::is_symmetric }
 
typedef
Traits::ConstTransposeReturnType 
ConstTransposeReturnType
 
typedef Traits::TransposeObjectType TransposeObjectType
 
typedef Traits::PlainObjectType PlainObjectType
 

Public Member Functions

template<typename RhsT , typename ResT >
void splitRowMultiply (const Index row, const RhsT &rhs, ResT &res) const
 Multiplies a given block-row of the matrix with rhs, omitting the diagonal block. More...
 
BlockPtr blockPtr (Index row, Index col) const
 Return a BlockPtr to the block a (row, col) or InvalidBlockPtr if it does not exist.
 
BlockPtr diagonalBlockPtr (Index row) const
 Return a BlockPtr to the block a (row, row) or InvalidBlockPtr if it does not exist.
 
const BlockType & block (BlockPtr ptr) const
 Returns a reference to a block using the result from blockPtr() or diagonalBlockPtr()
 
BlockType & block (BlockPtr ptr)
 Returns a reference to a block using the result from blockPtr() or diagonalBlockPtr()
 
Index rows () const
 Returns the total number of rows of the matrix ( expanding blocks )
 
Index cols () const
 Returns the total number of columns of the matrix ( expanding blocks )
 
Index size () const
 Returns the total number of blocks of the matrix.
 
const Traits::BlocksArrayType & blocks () const
 Access to blocks data.
 
const BlockType * data () const
 Access to blocks data as a raw pointer.
 
BlockType * data ()
 Access to blocks data as a raw pointer.
 
BlockType & diagonal (const Index row)
 
const BlockType & diagonal (const Index row) const
 
BlockType & block (Index row, Index col)
 
const BlockType & block (Index row, Index col) const
 
template<typename Func >
void eachBlockOfRow (const Index row, Func func) const
 Iterates over each block of a given row. Calls func( col, block )
 
template<typename Func >
void eachBlockOfCol (const Index col, Func func) const
 Iterates over each block of a given col. Calls func( row, block )
 
template<bool DoTranspose, typename RhsT , typename ResT >
void rowMultiply (const Index row, const RhsT &rhs, ResT &res) const
 Multiplication with a single row.
 
template<bool DoTranspose, typename RhsT , typename ResT , typename PreOp >
void rowMultiplyPrecompose (const Index row, const RhsT &rhs, ResT &res, const PreOp &op) const
 
template<bool DoTranspose, typename RhsT , typename ResT >
void colMultiply (const Index col, const RhsT &rhs, ResT &res) const
 Multiplication with a single column.
 
template<bool DoTranspose, typename RhsT , typename ResT , typename PostOp >
void colMultiplyPostcompose (const Index col, const RhsT &rhs, ResT &res, const PostOp &op) const
 
const Derived & derived () const
 Returns a const reference to the implementation.
 
Derived & derived ()
 Returns a reference to the implementation.
 
Index blockRows (Index row) const
 Returns the number of rows of a given block row.
 
Index blockCols (Index col) const
 Returns the number of columns of a given block columns.
 
Index rowsOfBlocks () const
 Returns the number of block rows of the matrix.
 
Index colsOfBlocks () const
 Returns the number of block columns of the matrix.
 
const Index * rowOffsets () const
 Returns an array containing the first index of each row.
 
const Index * colOffsets () const
 Returns an array containing the first index of each column.
 
Index rowOffset (Index row) const
 Returns an array containing the first index of a given row.
 
Index colOffset (Index col) const
 Returns an array containing the first index of a given columns.
 
ConstTransposeReturnType transpose () const
 Return a const transposed view of this object.
 
template<bool DoTranspose, typename RhsT , typename ResT >
void multiply (const RhsT &rhs, ResT &res, Scalar alpha=1, Scalar beta=0) const
 Performs a matrix vector multiplication. More...
 

Static Public Attributes

static const BlockPtr InvalidBlockPtr
 Return value of blockPtr( Index, Index ) for non-existing block.
 

Protected Attributes

Index m_rows
 
Index m_cols
 
BlocksArrayType m_blocks
 

Detailed Description

template<typename Derived>
class bogus::BlockMatrixBase< Derived >

Base class for dense and sparse block matrices, thought dense don't exist yet.

Member Function Documentation

template<typename Derived>
BlockType& bogus::BlockMatrixBase< Derived >::block ( Index  row,
Index  col 
)
Warning
block has to exist
template<typename Derived>
const BlockType& bogus::BlockMatrixBase< Derived >::block ( Index  row,
Index  col 
) const
Warning
block has to exist
template<typename Derived>
BlockType& bogus::BlockMatrixBase< Derived >::diagonal ( const Index  row)
Warning
block has to exist
template<typename Derived>
const BlockType& bogus::BlockMatrixBase< Derived >::diagonal ( const Index  row) const
Warning
block has to exist
template<typename Derived>
template<bool DoTranspose, typename RhsT , typename ResT >
void bogus::BlockObjectBase< Derived >::multiply ( const RhsT &  rhs,
ResT &  res,
Scalar  alpha = 1,
Scalar  beta = 0 
) const
inherited

Performs a matrix vector multiplication.

Template Parameters
DoTransposeIf true, performs res = alpha * M' * rhs + beta * res, otherwise res = alpha * M * rhs + beta * res
template<typename Derived>
template<typename RhsT , typename ResT >
void bogus::BlockMatrixBase< Derived >::splitRowMultiply ( const Index  row,
const RhsT &  rhs,
ResT &  res 
) const

Multiplies a given block-row of the matrix with rhs, omitting the diagonal block.

I.e. res = [ M( row, 0 ) ... M( row, row-1 ) 0 M( row, row+1 ) ... M( row, colsOfBlocks()-1 ) ] * rhs

Especially useful inside a Gauss-Seidel algorithm.

Warning
Does not work on sparse, non-symmetric column major matrices

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