12 #ifndef BOGUS_BLOCK_EXPRESSIONS_HPP
13 #define BOGUS_BLOCK_EXPRESSIONS_HPP
15 #include "BlockObjectBase.hpp"
21 template <
typename MatrixT>
26 typedef typename Traits::PlainObjectType PlainObjectType ;
27 typedef typename Traits::Index Index ;
28 typedef typename Base::Scalar Scalar ;
30 const PlainObjectType &matrix ;
32 Transpose(
const PlainObjectType &m ) : matrix( m.derived() ) {}
34 typename Base::ConstTransposeReturnType transpose()
const {
return matrix ; }
36 template <
bool DoTranspose,
typename RhsT,
typename ResT >
37 void multiply(
const RhsT& rhs, ResT& res, Scalar alpha = 1, Scalar beta = 0 )
const
39 matrix.template multiply< !DoTranspose >( rhs, res, alpha, beta ) ;
42 Index rows()
const {
return matrix.cols() ; }
43 Index cols()
const {
return matrix.rows() ; }
45 Index rowsOfBlocks()
const {
return matrix.colsOfBlocks() ; }
46 Index colsOfBlocks()
const {
return matrix.rowsOfBlocks() ; }
47 Index blockRows( Index row )
const {
return matrix.blockCols( row ) ; }
48 Index blockCols( Index col )
const {
return matrix.blockRows( col ) ; }
49 const Index *rowOffsets( )
const {
return matrix.colOffsets( ) ; }
50 const Index *colOffsets( )
const {
return matrix.rowOffsets( ) ; }
54 template <
typename MatrixT>
58 typedef typename OrigTraits::Index Index ;
59 typedef typename OrigTraits::Scalar Scalar ;
64 is_symmetric = OrigTraits::is_symmetric
67 RowsPerBlock = OrigTraits::ColsPerBlock,
68 ColsPerBlock = OrigTraits::RowsPerBlock
71 typedef typename OrigTraits::PlainObjectType PlainObjectType ;
72 typedef const PlainObjectType& ConstTransposeReturnType ;
73 typedef PlainObjectType TransposeObjectType ;
77 template <
typename ObjectT,
bool IsTemporary >
80 typedef const ObjectT& ConstValue ;
82 template <
typename ObjectT >
85 typedef const ObjectT ConstValue ;
89 template <
typename ObjectT >
92 typedef ObjectT ObjectType ;
93 typedef typename ObjectT::PlainObjectType PlainObjectType ;
96 enum { do_transpose = Traits::is_transposed } ;
97 typedef typename Traits::Scalar Scalar ;
99 typename BlockStorage< ObjectT, Traits::is_temporary >::ConstValue object ;
103 : object(o), scaling(s)
107 template <
template <
typename,
typename >
class BlockOp,
typename LhsMatrixT,
typename RhsMatrixT>
112 typedef typename Base::PlainObjectType PlainObjectType ;
117 typedef typename Lhs::PlainObjectType PlainLhsMatrixType ;
118 typedef typename Rhs::PlainObjectType PlainRhsMatrixType ;
122 enum { transposeLhs = Lhs::do_transpose,
123 transposeRhs = Rhs::do_transpose };
126 typename Lhs::Scalar lscaling = 1,
typename Lhs::Scalar rscaling = 1 )
127 : lhs( l, lscaling ), rhs ( r, rscaling )
133 template <
typename LhsMatrixT,
typename RhsMatrixT>
137 typedef typename Base::Scalar Scalar ;
138 typedef typename Base::Index Index ;
140 Product(
const LhsMatrixT& l,
const RhsMatrixT &r,
141 typename Base::Lhs::Scalar lscaling = 1,
typename Base::Lhs::Scalar rscaling = 1 )
142 :
Base( l, r, lscaling, rscaling )
145 typename Base::ConstTransposeReturnType transpose()
const
147 return typename Base::ConstTransposeReturnType (
148 Base::rhs.
object.transpose(), Base::lhs.
object.transpose(),
149 Base::rhs.scaling, Base::lhs.scaling ) ;
152 template <
bool DoTranspose,
typename RhsT,
typename ResT >
153 void multiply(
const RhsT& rhs, ResT& res, Scalar alpha = 1, Scalar beta = 0 )
const ;
155 Index rows()
const {
return Base::lhs.object.rows() ; }
156 Index cols()
const {
return Base::rhs.object.cols() ; }
158 Index rowsOfBlocks()
const {
return Base::lhs.object.rowsOfBlocks() ; }
159 Index colsOfBlocks()
const {
return Base::rhs.object.colsOfBlocks() ; }
160 Index blockRows( Index row )
const {
return Base::lhs.object.blockRows( row ) ; }
161 Index blockCols( Index col )
const {
return Base::rhs.object.blockCols( col ) ; }
162 const Index *rowOffsets( )
const {
return Base::lhs.object.rowOffsets( ) ; }
163 const Index *colOffsets( )
const {
return Base::rhs.object.colOffsets( ) ; }
166 template <
typename LhsMatrixT,
typename RhsMatrixT>
172 typedef typename LhsTraits::Index Index ;
173 typedef typename LhsTraits::Scalar Scalar ;
175 enum { is_transposed = 0,
181 typedef typename LhsTraits::PlainObjectType::BlockType LhsBlockType ;
182 typedef typename RhsTraits::PlainObjectType::BlockType RhsBlockType ;
185 LhsTraits::is_transposed, RhsTraits::is_transposed >::ReturnType ResBlockType ;
187 typedef typename LhsTraits::PlainObjectType
188 ::template MutableImpl< ResBlockType, false >::Type PlainObjectType ;
191 RowsPerBlock = LhsTraits::RowsPerBlock,
192 ColsPerBlock = RhsTraits::ColsPerBlock
201 template <
typename LhsMatrixT,
typename RhsMatrixT>
205 typedef typename Base::Scalar Scalar ;
206 typedef typename Base::Index Index ;
208 Addition(
const LhsMatrixT& l,
const RhsMatrixT &r,
209 typename Base::Lhs::Scalar lscaling = 1,
typename Base::Lhs::Scalar rscaling = 1 )
210 :
Base( l, r, lscaling, rscaling )
213 typename Base::ConstTransposeReturnType transpose()
const
215 return typename Base::ConstTransposeReturnType (
216 Base::lhs.
object.transpose(), Base::rhs.
object.transpose(),
217 Base::lhs.scaling, Base::rhs.scaling ) ;
220 template <
bool DoTranspose,
typename RhsT,
typename ResT >
221 void multiply(
const RhsT& rhs, ResT& res, Scalar alpha = 1, Scalar beta = 0 )
const
223 Base::lhs.object.template multiply< DoTranspose >( rhs, res, alpha*Base::lhs.scaling, beta ) ;
224 Base::rhs.object.template multiply< DoTranspose >( rhs, res, alpha*Base::rhs.scaling, 1 ) ;
227 Index rows()
const {
return Base::lhs.object.rows() ; }
228 Index cols()
const {
return Base::lhs.object.cols() ; }
230 Index rowsOfBlocks()
const {
return Base::lhs.object.rowsOfBlocks() ; }
231 Index colsOfBlocks()
const {
return Base::lhs.object.colsOfBlocks() ; }
232 Index blockRows( Index row )
const {
return Base::lhs.object.blockRows( row ) ; }
233 Index blockCols( Index col )
const {
return Base::lhs.object.blockCols( col ) ; }
234 const Index *rowOffsets( )
const {
return Base::lhs.object.rowOffsets( ) ; }
235 const Index *colOffsets( )
const {
return Base::lhs.object.colOffsets( ) ; }
238 template <
typename LhsMatrixT,
typename RhsMatrixT>
243 typedef typename OrigTraits::Index Index ;
244 typedef typename OrigTraits::Scalar Scalar ;
246 typedef typename OrigTraits::PlainObjectType::BlockType ResBlockType ;
248 typedef typename OrigTraits::PlainObjectType
249 ::template MutableImpl< ResBlockType, false >::Type PlainObjectType ;
251 enum { is_transposed = 0,
257 RowsPerBlock = OrigTraits::RowsPerBlock,
258 ColsPerBlock = OrigTraits::ColsPerBlock
267 template <
typename MatrixT>
271 typedef typename Operand::PlainObjectType PlainOperandMatrixType ;
274 enum { transposeOperand = Operand::do_transpose };
278 typedef typename Base::Scalar Scalar ;
279 typedef typename Base::Index Index ;
281 Scaling(
const MatrixT &
object,
const typename MatrixT::Scalar scaling )
282 : operand(
object, scaling )
285 typename Base::ConstTransposeReturnType transpose()
const
287 return typename Base::ConstTransposeReturnType (
288 operand.object.transpose(), operand.scaling ) ;
291 template <
bool DoTranspose,
typename RhsT,
typename ResT >
292 void multiply(
const RhsT& rhs, ResT& res, Scalar alpha = 1, Scalar beta = 0 )
const
294 operand.object.template multiply< DoTranspose >( rhs, res, alpha*operand.scaling, beta ) ;
297 typename Base::Index rows()
const {
return operand.object.rows() ; }
298 typename Base::Index cols()
const {
return operand.object.cols() ; }
300 Index rowsOfBlocks()
const {
return operand.object.rowsOfBlocks() ; }
301 Index colsOfBlocks()
const {
return operand.object.colsOfBlocks() ; }
302 Index blockRows( Index row )
const {
return operand.object.blockRows( row ) ; }
303 Index blockCols( Index col )
const {
return operand.object.blockCols( col ) ; }
304 const Index *rowOffsets( )
const {
return operand.object.rowOffsets( ) ; }
305 const Index *colOffsets( )
const {
return operand.object.colOffsets( ) ; }
308 template <
typename MatrixT>
313 typedef typename OrigTraits::Index Index ;
314 typedef typename OrigTraits::Scalar Scalar ;
316 enum { is_symmetric = OrigTraits::is_symmetric,
320 RowsPerBlock = OrigTraits::RowsPerBlock,
321 ColsPerBlock = OrigTraits::ColsPerBlock
324 typedef typename OrigTraits::PlainObjectType PlainObjectType ;
331 template <
typename ObjectT >
337 :
Base(o.operand.object, s*o.operand.scaling)
339 BlockOperand(
const typename Base::ObjectType & o,
typename Base::Scalar s = 1 )
347 #endif // EXPRESSIONS_HPP
Definition: Traits.hpp:19
Base class for Transpose views of a BlockObjectBase.
Definition: Expressions.hpp:22
Definition: Expressions.hpp:202
Definition: Expressions.hpp:268
Defines the return type of the product of two blocks potentially transposed.
Definition: Traits.hpp:64
Definition: Expressions.hpp:134
Definition: Expressions.hpp:55
Base class for anything block.
Definition: BlockObjectBase.hpp:22
Definition: Expressions.hpp:108
Definition: Expressions.hpp:78
Definition: Expressions.hpp:90