35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTDMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATTDMATMULTEXPR_H_
102 template<
typename MT1
104 class SMatTDMatMultExpr :
public DenseMatrix< SMatTDMatMultExpr<MT1,MT2>, false >
105 ,
private MatMatMultExpr
106 ,
private Computation
141 enum { vectorizable = 0 };
174 if(
lhs_.columns() == 0UL )
183 const ConstIterator end( A.end(i) );
184 ConstIterator element( A.begin(i) );
191 tmp = element->value() *
rhs_(element->index(),j);
193 for( ; element!=end; ++element )
194 tmp += element->value() *
rhs_(element->index(),j);
200 for(
size_t k=1UL; k<
lhs_.columns(); ++k ) {
225 return rhs_.columns();
255 template<
typename T >
257 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
267 template<
typename T >
269 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
291 template<
typename MT
312 const size_t block( 256UL );
315 const size_t jend( B.columns() &
size_t(-4) );
317 for(
size_t ii=0UL; ii<A.rows(); ii+=block ) {
318 const size_t iend( ( ii+block > A.rows() )?( A.rows() ):( ii+block ) );
319 for(
size_t j=0UL; j<jend; j+=4UL ) {
320 for(
size_t i=ii; i<iend; ++i ) {
321 const ConstIterator end( A.end(i) );
322 ConstIterator element( A.begin(i) );
324 (~lhs)(i,j ) = element->value() * B(element->index(),j );
325 (~lhs)(i,j+1UL) = element->value() * B(element->index(),j+1UL);
326 (~lhs)(i,j+2UL) = element->value() * B(element->index(),j+2UL);
327 (~lhs)(i,j+3UL) = element->value() * B(element->index(),j+3UL);
329 for( ; element!=end; ++element ) {
330 (~lhs)(i,j ) += element->value() * B(element->index(),j );
331 (~lhs)(i,j+1UL) += element->value() * B(element->index(),j+1UL);
332 (~lhs)(i,j+2UL) += element->value() * B(element->index(),j+2UL);
333 (~lhs)(i,j+3UL) += element->value() * B(element->index(),j+3UL);
337 reset( (~lhs)(i,j ) );
338 reset( (~lhs)(i,j+1UL) );
339 reset( (~lhs)(i,j+2UL) );
340 reset( (~lhs)(i,j+3UL) );
344 for(
size_t j=jend; j<B.columns(); ++j ) {
345 for(
size_t i=ii; i<iend; ++i ) {
346 const ConstIterator end( A.end(i) );
347 ConstIterator element( A.begin(i) );
349 (~lhs)(i,j) = element->value() * B(element->index(),j);
351 for( ; element!=end; ++element ) {
352 (~lhs)(i,j) += element->value() * B(element->index(),j);
356 reset( (~lhs)(i,j) );
377 template<
typename MT
395 const TmpType tmp( rhs );
414 template<
typename MT
435 const size_t block( 256UL );
436 BLAZE_INTERNAL_ASSERT( ( B.columns() - ( B.columns() % 4UL ) ) == ( B.columns() & size_t(-4) ),
"Invalid end calculation" );
437 const size_t jend( B.columns() & size_t(-4) );
439 for(
size_t ii=0UL; ii<A.rows(); ii+=block ) {
440 const size_t iend( ( ii+block > A.rows() )?( A.rows() ):( ii+block ) );
441 for(
size_t j=0UL; j<jend; j+=4UL ) {
442 for(
size_t i=ii; i<iend; ++i ) {
443 const ConstIterator end( A.end(i) );
444 ConstIterator element( A.begin(i) );
445 for( ; element!=end; ++element ) {
446 (~lhs)(i,j ) += element->value() * B(element->index(),j );
447 (~lhs)(i,j+1UL) += element->value() * B(element->index(),j+1UL);
448 (~lhs)(i,j+2UL) += element->value() * B(element->index(),j+2UL);
449 (~lhs)(i,j+3UL) += element->value() * B(element->index(),j+3UL);
453 for(
size_t j=jend; j<B.columns(); ++j ) {
454 for(
size_t i=ii; i<iend; ++i ) {
455 const ConstIterator end( A.end(i) );
456 ConstIterator element( A.begin(i) );
457 for( ; element!=end; ++element ) {
458 (~lhs)(i,j) += element->value() * B(element->index(),j);
484 template<
typename MT
505 const size_t block( 256UL );
506 BLAZE_INTERNAL_ASSERT( ( B.columns() - ( B.columns() % 4UL ) ) == ( B.columns() & size_t(-4) ),
"Invalid end calculation" );
507 const size_t jend( B.columns() & size_t(-4) );
509 for(
size_t ii=0UL; ii<A.rows(); ii+=block ) {
510 const size_t iend( ( ii+block > A.rows() )?( A.rows() ):( ii+block ) );
511 for(
size_t j=0UL; j<jend; j+=4UL ) {
512 for(
size_t i=ii; i<iend; ++i ) {
513 const ConstIterator end( A.end(i) );
514 ConstIterator element( A.begin(i) );
515 for( ; element!=end; ++element ) {
516 (~lhs)(i,j ) -= element->value() * B(element->index(),j );
517 (~lhs)(i,j+1UL) -= element->value() * B(element->index(),j+1UL);
518 (~lhs)(i,j+2UL) -= element->value() * B(element->index(),j+2UL);
519 (~lhs)(i,j+3UL) -= element->value() * B(element->index(),j+3UL);
523 for(
size_t j=jend; j<B.columns(); ++j ) {
524 for(
size_t i=ii; i<iend; ++i ) {
525 const ConstIterator end( A.end(i) );
526 ConstIterator element( A.begin(i) );
527 for( ; element!=end; ++element ) {
528 (~lhs)(i,j) -= element->value() * B(element->index(),j);
600 template<
typename T1
602 inline const SMatTDMatMultExpr<T1,T2>
608 throw std::invalid_argument(
"Matrix sizes do not match" );
625 template<
typename MT1,
typename MT2,
typename VT >
626 struct DMatDVecMultExprTrait< SMatTDMatMultExpr<MT1,MT2>, VT >
630 typedef typename SelectType< IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
631 IsDenseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
632 IsDenseVector<VT>::value && IsColumnVector<VT>::value
633 ,
typename SMatDVecMultExprTrait< MT1, typename TDMatDVecMultExprTrait<MT2,VT>::Type >::Type
634 , INVALID_TYPE >::Type Type;
643 template<
typename MT1,
typename MT2,
typename VT >
644 struct DMatSVecMultExprTrait< SMatTDMatMultExpr<MT1,MT2>, VT >
648 typedef typename SelectType< IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
649 IsDenseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
650 IsSparseVector<VT>::value && IsColumnVector<VT>::value
651 ,
typename SMatDVecMultExprTrait< MT1, typename TDMatSVecMultExprTrait<MT2,VT>::Type >::Type
652 , INVALID_TYPE >::Type Type;
661 template<
typename VT,
typename MT1,
typename MT2 >
662 struct TDVecDMatMultExprTrait< VT, SMatTDMatMultExpr<MT1,MT2> >
666 typedef typename SelectType< IsDenseVector<VT>::value && IsRowVector<VT>::value &&
667 IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
668 IsDenseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value
669 ,
typename TDVecTDMatMultExprTrait< typename TDVecSMatMultExprTrait<VT,MT1>::Type, MT2 >::Type
670 , INVALID_TYPE >::Type Type;
679 template<
typename VT,
typename MT1,
typename MT2 >
680 struct TSVecDMatMultExprTrait< VT, SMatTDMatMultExpr<MT1,MT2> >
684 typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
685 IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
686 IsDenseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value
687 ,
typename TSVecTDMatMultExprTrait< typename TSVecSMatMultExprTrait<VT,MT1>::Type, MT2 >::Type
688 , INVALID_TYPE >::Type Type;
697 template<
typename MT1,
typename MT2 >
698 struct SubmatrixExprTrait< SMatTDMatMultExpr<MT1,MT2> >
702 typedef typename MultExprTrait< typename SubmatrixExprTrait<const MT1>::Type
703 ,
typename SubmatrixExprTrait<const MT2>::Type >::Type Type;
712 template<
typename MT1,
typename MT2 >
713 struct RowExprTrait< SMatTDMatMultExpr<MT1,MT2> >
717 typedef typename MultExprTrait< typename RowExprTrait<const MT1>::Type, MT2 >::Type Type;
726 template<
typename MT1,
typename MT2 >
727 struct ColumnExprTrait< SMatTDMatMultExpr<MT1,MT2> >
731 typedef typename MultExprTrait< MT1, typename ColumnExprTrait<const MT2>::Type >::Type Type;
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTDMatMultExpr.h:127
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatTDMatMultExpr.h:123
Header file for the SMatDVecMultExprTrait class template.
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:3703
MT1::CompositeType CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTDMatMultExpr.h:112
Header file for the IsSparseMatrix type trait.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatTDMatMultExpr.h:256
MultTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: SMatTDMatMultExpr.h:119
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
Header file for the ColumnExprTrait class template.
Header file for the IsColumnMajorMatrix type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2375
Header file for the IsRowVector type trait.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:248
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatTDMatMultExpr.h:124
Header file for the TDVecSMatMultExprTrait class template.
SelectType< IsComputation< MT1 >::value, const RT1, CT1 >::Type LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: SMatTDMatMultExpr.h:133
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatTDMatMultExpr.h:275
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
MT1::ResultType RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatTDMatMultExpr.h:110
SMatTDMatMultExpr< MT1, MT2 > This
Type of this SMatTDMatMultExpr instance.
Definition: SMatTDMatMultExpr.h:118
Header file for the RequiresEvaluation type trait.
MT2::ResultType RT2
Result type of the right-hand side dense matrix expression.
Definition: SMatTDMatMultExpr.h:111
Header file for the TSVecSMatMultExprTrait class template.
RightOperand rightOperand() const
Returns the right-hand side transpose dense matrix operand.
Definition: SMatTDMatMultExpr.h:244
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatTDMatMultExpr.h:224
SMatTDMatMultExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the SMatTDMatMultExpr class.
Definition: SMatTDMatMultExpr.h:150
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:104
Constraint on the data type.
Constraint on the data type.
Header file for the MultExprTrait class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
SelectType< IsComputation< MT2 >::value, const RT2, CT2 >::Type RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: SMatTDMatMultExpr.h:136
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the multiplication trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: StorageOrder.h:161
Header file for the TSVecTDMatMultExprTrait class template.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
Header file for the TDMatSVecMultExprTrait class template.
Header file for the DenseMatrix base class.
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:179
Header file for the DMatDVecMultExprTrait class template.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatTDMatMultExpr.h:214
Expression object for sparse matrix-transpose dense matrix multiplications.The SMatTDMatMultExpr clas...
Definition: Forward.h:97
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:78
Constraints on the storage order of matrix types.
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Header file for the IsDenseMatrix type trait.
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatTDMatMultExpr.h:121
Header file for the IsSparseVector type trait.
Header file for the SubmatrixExprTrait class template.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Header file for run time assertion macros.
Utility type for generic codes.
Base template for the MultTrait class.
Definition: MultTrait.h:141
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: SMatTDMatMultExpr.h:130
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:209
LeftOperand leftOperand() const
Returns the left-hand side sparse matrix operand.
Definition: SMatTDMatMultExpr.h:234
Header file for the reset shim.
MT2::CompositeType CT2
Composite type of the right-hand side dense matrix expression.
Definition: SMatTDMatMultExpr.h:113
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
ResultType::ElementType ElementType
Resulting element type.
Definition: SMatTDMatMultExpr.h:122
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTDMatMultExpr.h:120
Header file for the RemoveReference type trait.
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.In case either of the two given data types T1 or T2 is not a matrix type ...
Definition: StorageOrder.h:283
Header file for the IsDenseVector type trait.
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComputation type trait class.
RightOperand rhs_
Right-hand side dense matrix of the multiplication expression.
Definition: SMatTDMatMultExpr.h:276
Header file for the TDVecDMatMultExprTrait class template.
Header file for the TDMatDVecMultExprTrait class template.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
Header file for basic type definitions.
Header file for the TSVecDMatMultExprTrait class template.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTDMatMultExpr.h:165
Header file for the DMatSVecMultExprTrait class template.
Header file for the IsColumnVector type trait.
Size type of the Blaze library.
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:138
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the TDVecTDMatMultExprTrait class template.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:79
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatTDMatMultExpr.h:268
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.