22 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATTSMATMULTEXPR_H_
23 #define _BLAZE_MATH_EXPRESSIONS_DMATTSMATMULTEXPR_H_
31 #include <boost/type_traits/remove_reference.hpp>
84 template<
typename MT1
92 typedef typename MT1::ResultType
RT1;
93 typedef typename MT2::ResultType
RT2;
94 typedef typename MT1::CompositeType
CT1;
95 typedef typename MT2::CompositeType
CT2;
123 enum { vectorizable = 0 };
151 typedef typename boost::remove_reference<CT2>::type::ConstIterator ConstIterator;
156 if(
lhs_.columns() == 0UL )
164 const ConstIterator end( B.end(j) );
165 ConstIterator element( B.begin(j) );
172 tmp =
lhs_(i,element->index()) * element->value();
174 for( ; element!=end; ++element )
175 tmp +=
lhs_(i,element->index()) * element->value();
181 for(
size_t k=1UL; k<
lhs_.columns(); ++k ) {
206 return rhs_.columns();
236 template<
typename T >
238 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
248 template<
typename T >
250 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
272 template<
typename MT
281 typedef typename boost::remove_reference<RT>::type::ConstIterator ConstIterator;
290 for(
size_t i=0UL; i<(~lhs).
rows(); ++i ) {
291 for(
size_t j=0UL; j<(~lhs).
columns(); ++j )
293 ConstIterator element( B.begin(j) );
294 const ConstIterator end( B.end(j) );
296 if( element == end ) {
297 reset( (~lhs)(i,j) );
301 (~lhs)(i,j) = A(i,element->index()) * element->value();
303 for( ; element!=end; ++element )
304 (~lhs)(i,j) += A(i,element->index()) * element->value();
324 template<
typename MT
342 const TmpType tmp( rhs );
361 template<
typename MT
370 typedef typename boost::remove_reference<RT>::type::ConstIterator ConstIterator;
379 for(
size_t i=0UL; i<(~lhs).
rows(); ++i ) {
380 for(
size_t j=0UL; j<(~lhs).
columns(); ++j )
382 ConstIterator element( B.begin(j) );
383 const ConstIterator end( B.end(j) );
385 for( ; element!=end; ++element )
386 (~lhs)(i,j) += A(i,element->index()) * element->value();
410 template<
typename MT
419 typedef typename boost::remove_reference<RT>::type::ConstIterator ConstIterator;
428 for(
size_t i=0UL; i<(~lhs).
rows(); ++i ) {
429 for(
size_t j=0UL; j<(~lhs).
columns(); ++j )
431 ConstIterator element( B.begin(j) );
432 const ConstIterator end( B.end(j) );
434 for( ; element!=end; ++element )
435 (~lhs)(i,j) -= A(i,element->index()) * element->value();
504 template<
typename T1
506 inline const DMatTSMatMultExpr<T1,T2>
512 throw std::invalid_argument(
"Matrix sizes do not match" );
540 template<
typename MT1
542 inline typename RowExprTrait< DMatTSMatMultExpr<MT1,MT2> >::Type
543 row(
const DMatTSMatMultExpr<MT1,MT2>& dm,
size_t index )
547 return row( dm.leftOperand(), index ) * dm.rightOperand();
566 template<
typename MT1
568 inline typename ColumnExprTrait< DMatTSMatMultExpr<MT1,MT2> >::Type
569 column(
const DMatTSMatMultExpr<MT1,MT2>& dm,
size_t index )
573 return dm.leftOperand() *
column( dm.rightOperand(), index );
589 template<
typename MT1,
typename MT2,
typename VT >
590 struct DMatDVecMultExprTrait< DMatTSMatMultExpr<MT1,MT2>, VT >
594 typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
595 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
596 IsDenseVector<VT>::value && !IsTransposeVector<VT>::value
597 ,
typename DMatDVecMultExprTrait< MT1, typename TSMatDVecMultExprTrait<MT2,VT>::Type >::Type
598 , INVALID_TYPE >::Type Type;
607 template<
typename MT1,
typename MT2,
typename VT >
608 struct DMatSVecMultExprTrait< DMatTSMatMultExpr<MT1,MT2>, VT >
612 typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
613 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
614 IsSparseVector<VT>::value && !IsTransposeVector<VT>::value
615 ,
typename DMatSVecMultExprTrait< MT1, typename TSMatSVecMultExprTrait<MT2,VT>::Type >::Type
616 , INVALID_TYPE >::Type Type;
625 template<
typename VT,
typename MT1,
typename MT2 >
626 struct TDVecDMatMultExprTrait< VT, DMatTSMatMultExpr<MT1,MT2> >
630 typedef typename SelectType< IsDenseVector<VT>::value && IsTransposeVector<VT>::value &&
631 IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
632 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value
633 ,
typename TDVecTSMatMultExprTrait< typename TDVecDMatMultExprTrait<VT,MT1>::Type, MT2 >::Type
634 , INVALID_TYPE >::Type Type;
643 template<
typename VT,
typename MT1,
typename MT2 >
644 struct TSVecDMatMultExprTrait< VT, DMatTSMatMultExpr<MT1,MT2> >
648 typedef typename SelectType< IsSparseVector<VT>::value && IsTransposeVector<VT>::value &&
649 IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
650 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value
651 ,
typename TDVecTSMatMultExprTrait< typename TSVecDMatMultExprTrait<VT,MT1>::Type, MT2 >::Type
652 , INVALID_TYPE >::Type Type;
661 template<
typename MT1,
typename MT2 >
662 struct RowExprTrait< DMatTSMatMultExpr<MT1,MT2> >
666 typedef typename MultExprTrait< typename RowExprTrait<const MT1>::Type, MT2 >::Type Type;
675 template<
typename MT1,
typename MT2 >
676 struct ColumnExprTrait< DMatTSMatMultExpr<MT1,MT2> >
680 typedef typename MultExprTrait< MT1, typename ColumnExprTrait<const MT2>::Type >::Type Type;