35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTSMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATTSMATMULTEXPR_H_
117 template<
typename MT1
119 class SMatTSMatMultExpr :
public SparseMatrix< SMatTSMatMultExpr<MT1,MT2>, false >
120 ,
private MatMatMultExpr
121 ,
private Computation
140 template<
typename T1,
typename T2,
typename T3 >
141 struct CanExploitSymmetry {
167 enum { smpAssignable = 0 };
201 if(
lhs_.columns() == 0UL )
211 const LeftIterator lend( A.end(i) );
212 LeftIterator lelem( A.begin(i) );
217 const RightIterator rend( B.end(j) );
218 RightIterator relem( B.begin(j) );
221 if( lelem == lend || relem == rend )
226 if( lelem->index() < relem->index() ) {
228 if( lelem == lend )
break;
230 else if( relem->index() < lelem->index() ) {
232 if( relem == rend )
break;
235 tmp = lelem->value() * relem->value();
242 if( lelem != lend && relem != rend )
245 if( lelem->index() < relem->index() ) {
247 if( lelem == lend )
break;
249 else if( relem->index() < lelem->index() ) {
251 if( relem == rend )
break;
254 tmp += lelem->value() * relem->value();
256 if( lelem == lend )
break;
258 if( relem == rend )
break;
278 tmp = element->value() *
rhs_(element->index(),j);
280 for( ; element!=
end; ++element ) {
281 tmp += element->value() *
rhs_(element->index(),j);
299 tmp =
lhs_(i,element->index()) * element->value();
301 for( ; element!=
end; ++element ) {
302 tmp +=
lhs_(i,element->index()) * element->value();
313 tmp =
lhs_(i,kbegin) *
rhs_(kbegin,j);
314 for(
size_t k=kbegin+1UL; k<kend; ++k ) {
331 inline ReturnType
at(
size_t i,
size_t j )
const {
332 if( i >=
lhs_.rows() ) {
335 if( j >=
rhs_.columns() ) {
358 return rhs_.columns();
410 template<
typename T >
412 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
422 template<
typename T >
424 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
434 return (
rows() > SMP_SMATTSMATMULT_THRESHOLD );
457 template<
typename MT >
469 assign( ~lhs, rhs.lhs_ * tmp );
489 template<
typename MT >
498 assign( ~lhs, rhs.lhs_ *
trans( rhs.rhs_ ) );
516 template<
typename MT >
517 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
530 assign( ~lhs, tmp * rhs.rhs_ );
550 template<
typename MT >
551 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
561 assign( ~lhs,
trans( rhs.lhs_ ) * rhs.rhs_ );
579 template<
typename MT >
580 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
591 addAssign( ~lhs, rhs.lhs_ * tmp );
611 template<
typename MT >
612 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
620 addAssign( ~lhs, rhs.lhs_ *
trans( rhs.rhs_ ) );
638 template<
typename MT >
639 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
652 addAssign( ~lhs, tmp * rhs.rhs_ );
672 template<
typename MT >
673 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
683 addAssign( ~lhs,
trans( rhs.lhs_ ) * rhs.rhs_ );
705 template<
typename MT >
706 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
717 subAssign( ~lhs, rhs.lhs_ * tmp );
737 template<
typename MT >
738 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
746 subAssign( ~lhs, rhs.lhs_ *
trans( rhs.rhs_ ) );
764 template<
typename MT >
765 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
778 subAssign( ~lhs, tmp * rhs.rhs_ );
798 template<
typename MT >
799 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
809 subAssign( ~lhs,
trans( rhs.lhs_ ) * rhs.rhs_ );
841 template<
typename MT >
842 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
873 template<
typename MT >
874 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
902 template<
typename MT >
903 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
936 template<
typename MT >
937 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
967 template<
typename MT >
968 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
999 template<
typename MT >
1000 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1033 template<
typename MT >
1034 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1062 template<
typename MT >
1063 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1097 template<
typename MT >
1098 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1129 template<
typename MT >
1130 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1163 template<
typename MT >
1164 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1192 template<
typename MT >
1193 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1271 template<
typename T1
1273 inline const SMatTSMatMultExpr<T1,T2>
1297 template<
typename MT1,
typename MT2 >
1298 struct Rows< SMatTSMatMultExpr<MT1,MT2> > :
public Rows<MT1>
1314 template<
typename MT1,
typename MT2 >
1315 struct Columns< SMatTSMatMultExpr<MT1,MT2> > :
public Columns<MT2>
1331 template<
typename MT1,
typename MT2 >
1332 struct IsLower< SMatTSMatMultExpr<MT1,MT2> >
1333 :
public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
1349 template<
typename MT1,
typename MT2 >
1350 struct IsUniLower< SMatTSMatMultExpr<MT1,MT2> >
1351 :
public IsTrue< And< IsUniLower<MT1>, IsUniLower<MT2> >::value >
1367 template<
typename MT1,
typename MT2 >
1368 struct IsStrictlyLower< SMatTSMatMultExpr<MT1,MT2> >
1369 :
public IsTrue< Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
1370 , And< IsStrictlyLower<MT2>, IsLower<MT1> > >::value >
1386 template<
typename MT1,
typename MT2 >
1387 struct IsUpper< SMatTSMatMultExpr<MT1,MT2> >
1388 :
public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
1404 template<
typename MT1,
typename MT2 >
1405 struct IsUniUpper< SMatTSMatMultExpr<MT1,MT2> >
1406 :
public IsTrue< And< IsUniUpper<MT1>, IsUniUpper<MT2> >::value >
1422 template<
typename MT1,
typename MT2 >
1423 struct IsStrictlyUpper< SMatTSMatMultExpr<MT1,MT2> >
1424 :
public IsTrue< Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
1425 , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > >::value >
1441 template<
typename MT1,
typename MT2,
typename VT >
1442 struct SMatDVecMultExprTrait< SMatTSMatMultExpr<MT1,MT2>, VT >
1446 typedef typename SelectType< IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1447 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
1448 IsDenseVector<VT>::value && IsColumnVector<VT>::value
1449 ,
typename SMatDVecMultExprTrait< MT1, typename TSMatDVecMultExprTrait<MT2,VT>::Type >::Type
1450 , INVALID_TYPE >::Type Type;
1459 template<
typename MT1,
typename MT2,
typename VT >
1460 struct SMatSVecMultExprTrait< SMatTSMatMultExpr<MT1,MT2>, VT >
1464 typedef typename SelectType< IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1465 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
1466 IsSparseVector<VT>::value && IsColumnVector<VT>::value
1467 ,
typename SMatSVecMultExprTrait< MT1, typename TSMatSVecMultExprTrait<MT2,VT>::Type >::Type
1468 , INVALID_TYPE >::Type Type;
1477 template<
typename VT,
typename MT1,
typename MT2 >
1478 struct TDVecSMatMultExprTrait< VT, SMatTSMatMultExpr<MT1,MT2> >
1482 typedef typename SelectType< IsDenseVector<VT>::value && IsRowVector<VT>::value &&
1483 IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1484 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value
1485 ,
typename TDVecTSMatMultExprTrait< typename TDVecSMatMultExprTrait<VT,MT1>::Type, MT2 >::Type
1486 , INVALID_TYPE >::Type Type;
1495 template<
typename VT,
typename MT1,
typename MT2 >
1496 struct TSVecSMatMultExprTrait< VT, SMatTSMatMultExpr<MT1,MT2> >
1500 typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1501 IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1502 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value
1503 ,
typename TDVecTSMatMultExprTrait< typename TDVecSMatMultExprTrait<VT,MT1>::Type, MT2 >::Type
1504 , INVALID_TYPE >::Type Type;
1513 template<
typename MT1,
typename MT2,
bool AF >
1514 struct SubmatrixExprTrait< SMatTSMatMultExpr<MT1,MT2>, AF >
1518 typedef typename MultExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1519 ,
typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1528 template<
typename MT1,
typename MT2 >
1529 struct RowExprTrait< SMatTSMatMultExpr<MT1,MT2> >
1533 typedef typename MultExprTrait< typename RowExprTrait<const MT1>::Type, MT2 >::Type Type;
1542 template<
typename MT1,
typename MT2 >
1543 struct ColumnExprTrait< SMatTSMatMultExpr<MT1,MT2> >
1547 typedef typename MultExprTrait< MT1, typename ColumnExprTrait<const MT2>::Type >::Type Type;
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
MultTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:151
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
Header file for mathematical functions.
Header file for the SMatDVecMultExprTrait class template.
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
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:7820
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:250
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:159
Header file for the IsSparseMatrix type trait.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatTSMatMultExpr.h:367
Header file for the ColumnExprTrait class template.
Header file for the IsColumnMajorMatrix type trait.
Header file for the TSVecTSMatMultExprTrait class template.
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:162
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Header file for the IsRowVector type trait.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the And class template.
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:90
Header file for the TDVecSMatMultExprTrait class template.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
Header file for the TSVecSMatMultExprTrait class template.
Header file for the IsUniLower type trait.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatTSMatMultExpr.h:357
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:117
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: SMatTSMatMultExpr.h:433
Header file for the SparseMatrix base class.
SMatTSMatMultExpr< MT1, MT2 > This
Type of this SMatTSMatMultExpr instance.
Definition: SMatTSMatMultExpr.h:150
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:155
Constraint on the data type.
Expression object for sparse matrix-transpose sparse matrix multiplications.The SMatTSMatMultExpr cla...
Definition: Forward.h:115
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
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 DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
MT1::CompositeType CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:127
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:110
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:153
#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: ColumnMajorMatrix.h:79
Header file for the Or class template.
Header file for the TDVecTSMatMultExprTrait class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
MT1::ResultType RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:125
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
Header file for the Columns type trait.
Header file for the TSMatDVecMultExprTrait class template.
Header file for the IsLower type trait.
Header file for the SMatSVecMultExprTrait class template.
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatTSMatMultExpr.h:423
RightOperand rightOperand() const
Returns the right-hand side transpose sparse matrix operand.
Definition: SMatTSMatMultExpr.h:399
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatTSMatMultExpr.h:331
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the serial shim.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatMultExpr.h:165
ResultType::ElementType ElementType
Resulting element type.
Definition: SMatTSMatMultExpr.h:154
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatTSMatMultExpr.h:156
Header file for the IsSparseVector type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
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: RowMajorMatrix.h:79
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
SMatTSMatMultExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the SMatTSMatMultExpr class.
Definition: SMatTSMatMultExpr.h:176
Header file for run time assertion macros.
Compile time check for column-major matrix types.This type trait tests whether or not the given templ...
Definition: IsColumnMajorMatrix.h:110
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
Utility type for generic codes.
Base template for the MultTrait class.
Definition: MultTrait.h:138
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:94
Constraint on the data type.
Constraints on the storage order of matrix types.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTSMatMultExpr.h:191
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTSMatMultExpr.h:152
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatTSMatMultExpr.h:440
Header file for the RemoveReference type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Header file for the IsDenseVector type trait.
MT2::CompositeType CT2
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:128
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatTSMatMultExpr.h:347
Header file for the IsRowMajorMatrix type trait.
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
Header file for the IsComputation type trait class.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
#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:2583
Header file for the IsTrue value trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatTSMatMultExpr.h:411
RightOperand rhs_
Right-hand side sparse matrix of the multiplication expression.
Definition: SMatTSMatMultExpr.h:441
Header file for the IsUpper type trait.
Header file for exception macros.
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:126
Header file for the IsColumnVector type trait.
Constraint on the data type.
LeftOperand leftOperand() const
Returns the left-hand side sparse matrix operand.
Definition: SMatTSMatMultExpr.h:389
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#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
#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
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatTSMatMultExpr.h:378
Header file for the IsExpression type trait class.
Header file for the TSMatSVecMultExprTrait class template.
Header file for the FunctionTrace class.