11 #ifndef BOGUS_COMPOUND_BLOCK_MATRIX_HPP
12 #define BOGUS_COMPOUND_BLOCK_MATRIX_HPP
14 #include "IterableBlockObject.hpp"
29 template<
bool ColWise,
typename MatrixT1,
typename MatrixT2 >
35 typedef typename Base::Index Index ;
36 typedef typename Base::Scalar Scalar ;
37 typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType ;
43 Index rows()
const {
return m_first.
rows() ; }
44 Index cols()
const {
return m_first.
cols()+m_second.
cols() ; }
46 Index blockRows( Index row )
const {
return m_first.
blockRows( row ) ; }
47 Index blockCols( Index col )
const {
48 const Index off = col - secondBegin() ;
52 Index rowsOfBlocks()
const {
return m_first.
rowsOfBlocks() ; }
55 const Index *rowOffsets( )
const {
return m_first.
rowOffsets() ; }
56 const Index *colOffsets( )
const {
return data_pointer(m_offsets) ; }
60 template <
bool DoTranspose,
typename RhsT,
typename ResT >
61 void multiply(
const RhsT& rhs, ResT& res, Scalar alpha = 1, Scalar beta = 0 )
const ;
65 Index size()
const {
return m_first.
size() + m_second.
size() ; }
67 template <
typename Func>
68 void eachBlockOfRow(
const Index row, Func func )
const {
69 m_first .
derived().eachBlockOfRow( row, func ) ;
70 m_second.
derived().eachBlockOfRow( row, func ) ;
72 template <
typename Func>
73 void eachBlockOfCol(
const Index col, Func func )
const {
74 const Index off = col - secondBegin() ;
76 m_first .
derived().eachBlockOfCol( col, func ) ;
78 m_second.
derived().eachBlockOfCol( off, func ) ;
81 template <
bool DoTranspose,
typename RhsT,
typename ResT,
typename PreOp >
82 void rowMultiplyPrecompose(
const Index row,
const RhsT& rhs, ResT& res,
const PreOp &op )
const ;
84 template <
bool DoTranspose,
typename RhsT,
typename ResT,
typename PostOp >
85 void colMultiplyPostcompose(
const Index col,
const RhsT& rhs, ResT& res,
const PostOp &op )
const ;
92 const Index* compoundOffsets()
const {
return m_compoundOffsets ; }
93 Index secondBegin()
const {
return m_first.
colsOfBlocks() ; }
98 Index m_compoundOffsets[3] ;
99 std::vector< Index > m_offsets ;
103 template<
bool ColWise,
typename MatrixT1,
typename MatrixT2 >
105 :
public BlockMatrixTraits< BlockObjectBase< CompoundBlockMatrix< ColWise, MatrixT1, MatrixT2 > > >
110 typedef typename OrigTraits::Scalar Scalar;
111 typedef typename OrigTraits::Index Index;
115 ColWise || ((int)OrigTraits::RowsPerBlock) == (int)OtherTraits::RowsPerBlock,
116 internal::DYNAMIC, OrigTraits::RowsPerBlock >::First,
118 !ColWise || ((
int)OrigTraits::ColsPerBlock) == (
int)OtherTraits::ColsPerBlock,
119 internal::DYNAMIC, OrigTraits::ColsPerBlock >::First
123 template<
typename MatrixT1,
typename MatrixT2 >
130 typedef typename Base::Index Index ;
131 typedef typename Base::Scalar Scalar ;
132 typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType ;
138 Index cols()
const {
return m_first.
cols() ; }
139 Index rows()
const {
return m_first.
rows()+m_second.
rows() ; }
141 Index blockCols( Index col )
const {
return m_first.
blockCols( col ) ; }
142 Index blockRows( Index row )
const {
143 const Index off = row - secondBegin() ;
147 Index colsOfBlocks()
const {
return m_first.
colsOfBlocks() ; }
150 const Index *colOffsets( )
const {
return m_first.
colOffsets() ; }
151 const Index *rowOffsets( )
const {
return data_pointer(m_offsets) ; }
155 template <
bool DoTranspose,
typename RhsT,
typename ResT >
156 void multiply(
const RhsT& rhs, ResT& res, Scalar alpha = 1, Scalar beta = 0 )
const ;
160 Index size()
const {
return m_first.
size() + m_second.
size() ; }
162 template <
typename Func>
163 void eachBlockOfCol(
const Index col, Func func )
const {
164 m_first .
derived().eachBlockOfRow( col, func ) ;
165 m_second.
derived().eachBlockOfRow( col, func ) ;
167 template <
typename Func>
168 void eachBlockOfRow(
const Index row, Func func )
const {
169 const Index off = row - secondBegin() ;
171 m_first .
derived().eachBlockOfCol( row, func ) ;
173 m_second.
derived().eachBlockOfCol( off, func ) ;
176 template <
bool DoTranspose,
typename RhsT,
typename ResT,
typename PreOp >
177 void rowMultiplyPrecompose(
const Index row,
const RhsT& rhs, ResT& res,
const PreOp &op )
const ;
179 template <
bool DoTranspose,
typename RhsT,
typename ResT,
typename PostOp >
180 void colMultiplyPostcompose(
const Index col,
const RhsT& rhs, ResT& res,
const PostOp &op )
const ;
187 const Index* compoundOffsets()
const {
return m_compoundOffsets ; }
188 Index secondBegin()
const {
return m_first.
rowsOfBlocks() ; }
193 Index m_compoundOffsets[3] ;
194 std::vector< Index > m_offsets ;
Index blockRows(Index row) const
Returns the number of rows of a given block row.
Definition: BlockObjectBase.hpp:51
Index rowsOfBlocks() const
Returns the number of block rows of the matrix.
Definition: BlockObjectBase.hpp:56
Definition: Traits.hpp:19
Index cols() const
Returns the total number of columns of the matrix ( expanding blocks )
Definition: BlockObjectBase.hpp:48
const Derived & derived() const
Returns a const reference to the implementation.
Definition: BlockObjectBase.hpp:25
Index colsOfBlocks() const
Returns the number of block columns of the matrix.
Definition: BlockObjectBase.hpp:58
const Index * colOffsets() const
Returns an array containing the first index of each column.
Definition: BlockObjectBase.hpp:63
Base class for matrix-like objects that define a block structure, but not a block type...
Definition: IterableBlockObject.hpp:22
Base class for Transpose views of a BlockObjectBase.
Definition: Expressions.hpp:22
const Index * rowOffsets() const
Returns an array containing the first index of each row.
Definition: BlockObjectBase.hpp:61
Index rows() const
Returns the total number of rows of the matrix ( expanding blocks )
Definition: BlockObjectBase.hpp:46
Definition: CppTools.hpp:49
Index blockCols(Index col) const
Returns the number of columns of a given block columns.
Definition: BlockObjectBase.hpp:53
Index size() const
Returns the total number of blocks of the matrix.
Definition: IterableBlockObject.hpp:33
A matrix made by concatenating two other matrices of possibly different types.
Definition: CompoundMatrix.hpp:30