35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTSMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATTSMATMULTEXPR_H_
109 template<
typename MT1
111 class SMatTSMatMultExpr :
public SparseMatrix< SMatTSMatMultExpr<MT1,MT2>, false >
112 ,
private MatMatMultExpr
113 ,
private Computation
132 template<
typename T1,
typename T2,
typename T3 >
133 struct CanExploitSymmetry {
159 enum { smpAssignable = 0 };
193 if(
lhs_.columns() == 0UL )
203 const LeftIterator lend( A.end(i) );
204 LeftIterator lelem( A.begin(i) );
209 const RightIterator rend( B.end(j) );
210 RightIterator relem( B.begin(j) );
213 if( lelem == lend || relem == rend )
218 if( lelem->index() < relem->index() ) {
220 if( lelem == lend )
break;
222 else if( relem->index() < lelem->index() ) {
224 if( relem == rend )
break;
227 tmp = lelem->value() * relem->value();
234 if( lelem != lend && relem != rend )
237 if( lelem->index() < relem->index() ) {
239 if( lelem == lend )
break;
241 else if( relem->index() < lelem->index() ) {
243 if( relem == rend )
break;
246 tmp += lelem->value() * relem->value();
248 if( lelem == lend )
break;
250 if( relem == rend )
break;
262 const LeftIterator
end( A.end(i) );
263 LeftIterator element( A.begin(i) );
270 tmp = element->value() *
rhs_(element->index(),j);
272 for( ; element!=
end; ++element )
273 tmp += element->value() *
rhs_(element->index(),j);
282 const RightIterator
end( B.end(j) );
283 RightIterator element( B.begin(j) );
290 tmp =
lhs_(i,element->index()) * element->value();
292 for( ; element!=
end; ++element )
293 tmp +=
lhs_(i,element->index()) * element->value();
299 for(
size_t k=1UL; k<
lhs_.columns(); ++k ) {
324 return rhs_.columns();
376 template<
typename T >
378 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
388 template<
typename T >
390 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
423 template<
typename MT >
435 assign( ~lhs, rhs.lhs_ * tmp );
455 template<
typename MT >
482 template<
typename MT >
483 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
496 assign( ~lhs, tmp * rhs.rhs_ );
516 template<
typename MT >
517 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
545 template<
typename MT >
546 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
577 template<
typename MT >
578 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
604 template<
typename MT >
605 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
638 template<
typename MT >
639 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
671 template<
typename MT >
672 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
703 template<
typename MT >
704 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
730 template<
typename MT >
731 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
764 template<
typename MT >
765 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
807 template<
typename MT >
808 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
839 template<
typename MT >
840 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
868 template<
typename MT >
869 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
902 template<
typename MT >
903 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
933 template<
typename MT >
934 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
965 template<
typename MT >
966 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
999 template<
typename MT >
1000 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1028 template<
typename MT >
1029 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1063 template<
typename MT >
1064 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1095 template<
typename MT >
1096 friend inline typename DisableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1129 template<
typename MT >
1130 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1158 template<
typename MT >
1159 friend inline typename EnableIf< CanExploitSymmetry<MT,MT1,MT2> >::Type
1237 template<
typename T1
1239 inline const SMatTSMatMultExpr<T1,T2>
1245 throw std::invalid_argument(
"Matrix sizes do not match" );
1262 template<
typename MT1,
typename MT2 >
1263 struct Rows< SMatTSMatMultExpr<MT1,MT2> >
1280 template<
typename MT1,
typename MT2 >
1281 struct Columns< SMatTSMatMultExpr<MT1,MT2> >
1282 :
public Columns<MT2>
1298 template<
typename MT1,
typename MT2 >
1299 struct IsLower< SMatTSMatMultExpr<MT1,MT2> >
1300 :
public IsTrue< IsLower<MT1>::value && IsLower<MT2>::value >
1316 template<
typename MT1,
typename MT2 >
1317 struct IsUpper< SMatTSMatMultExpr<MT1,MT2> >
1318 :
public IsTrue< IsUpper<MT1>::value && IsUpper<MT2>::value >
1334 template<
typename MT1,
typename MT2,
typename VT >
1335 struct SMatDVecMultExprTrait< SMatTSMatMultExpr<MT1,MT2>, VT >
1339 typedef typename SelectType< IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1340 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
1341 IsDenseVector<VT>::value && IsColumnVector<VT>::value
1342 ,
typename SMatDVecMultExprTrait< MT1, typename TSMatDVecMultExprTrait<MT2,VT>::Type >::Type
1343 , INVALID_TYPE >::Type Type;
1352 template<
typename MT1,
typename MT2,
typename VT >
1353 struct SMatSVecMultExprTrait< SMatTSMatMultExpr<MT1,MT2>, VT >
1357 typedef typename SelectType< IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1358 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
1359 IsSparseVector<VT>::value && IsColumnVector<VT>::value
1360 ,
typename SMatSVecMultExprTrait< MT1, typename TSMatSVecMultExprTrait<MT2,VT>::Type >::Type
1361 , INVALID_TYPE >::Type Type;
1370 template<
typename VT,
typename MT1,
typename MT2 >
1371 struct TDVecSMatMultExprTrait< VT, SMatTSMatMultExpr<MT1,MT2> >
1375 typedef typename SelectType< IsDenseVector<VT>::value && IsRowVector<VT>::value &&
1376 IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1377 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value
1378 ,
typename TDVecTSMatMultExprTrait< typename TDVecSMatMultExprTrait<VT,MT1>::Type, MT2 >::Type
1379 , INVALID_TYPE >::Type Type;
1388 template<
typename VT,
typename MT1,
typename MT2 >
1389 struct TSVecSMatMultExprTrait< VT, SMatTSMatMultExpr<MT1,MT2> >
1393 typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1394 IsSparseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1395 IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value
1396 ,
typename TDVecTSMatMultExprTrait< typename TDVecSMatMultExprTrait<VT,MT1>::Type, MT2 >::Type
1397 , INVALID_TYPE >::Type Type;
1406 template<
typename MT1,
typename MT2,
bool AF >
1407 struct SubmatrixExprTrait< SMatTSMatMultExpr<MT1,MT2>, AF >
1411 typedef typename MultExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1412 ,
typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1421 template<
typename MT1,
typename MT2 >
1422 struct RowExprTrait< SMatTSMatMultExpr<MT1,MT2> >
1426 typedef typename MultExprTrait< typename RowExprTrait<const MT1>::Type, MT2 >::Type Type;
1435 template<
typename MT1,
typename MT2 >
1436 struct ColumnExprTrait< SMatTSMatMultExpr<MT1,MT2> >
1440 typedef typename MultExprTrait< MT1, typename ColumnExprTrait<const MT2>::Type >::Type Type;
Header file for the SMatDVecMultExprTrait class template.
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
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:4838
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatTSMatMultExpr.h:344
MT1::CompositeType CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:119
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:258
Header file for the IsSparseMatrix type trait.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
Header file for the ColumnExprTrait class template.
Header file for the IsColumnMajorMatrix type trait.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatTSMatMultExpr.h:377
Header file for the TSVecTSMatMultExprTrait class template.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
Header file for the IsRowVector type trait.
SMatTSMatMultExpr< MT1, MT2 > This
Type of this SMatTSMatMultExpr instance.
Definition: SMatTSMatMultExpr.h:142
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:257
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
MT1::ResultType RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:117
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:154
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
MT2::CompositeType CT2
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:120
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:695
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: SMatTSMatMultExpr.h:399
Header file for the RequiresEvaluation type trait.
Header file for the TSVecSMatMultExprTrait class template.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2474
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatTSMatMultExpr.h:148
Header file for the SparseMatrix base class.
Constraint on the data type.
Expression object for sparse matrix-transpose sparse matrix multiplications.The SMatTSMatMultExpr cla...
Definition: Forward.h:105
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
ResultType::ElementType ElementType
Resulting element type.
Definition: SMatTSMatMultExpr.h:146
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 IsSymmetric type trait.
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:104
#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 TDVecTSMatMultExprTrait class template.
BLAZE_ALWAYS_INLINE 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:635
Header file for the Columns type trait.
Header file for the TSMatDVecMultExprTrait class template.
Header file for the IsLower type trait.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatTSMatMultExpr.h:389
Header file for the SMatSVecMultExprTrait class template.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatTSMatMultExpr.h:323
Constraints on the storage order of matrix types.
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
RightOperand rightOperand() const
Returns the right-hand side transpose sparse matrix operand.
Definition: SMatTSMatMultExpr.h:365
RightOperand rhs_
Right-hand side sparse matrix of the multiplication expression.
Definition: SMatTSMatMultExpr.h:407
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 EnableIf class template.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatTSMatMultExpr.h:333
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
const size_t SMP_SMATTSMATMULT_THRESHOLD
SMP row-major sparse matrix/column-major sparse matrix multiplication threshold.This threshold specif...
Definition: Thresholds.h:1133
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTSMatMultExpr.h:183
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
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: 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.
Compile time check for column-major matrix types.This type trait tests whether or not the given templ...
Definition: IsColumnMajorMatrix.h:104
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:142
BLAZE_ALWAYS_INLINE 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:742
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:151
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:87
Constraint on the data type.
MultTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:143
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatTSMatMultExpr.h:313
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.
SMatTSMatMultExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the SMatTSMatMultExpr class.
Definition: SMatTSMatMultExpr.h:168
LeftOperand leftOperand() const
Returns the left-hand side sparse matrix operand.
Definition: SMatTSMatMultExpr.h:355
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatTSMatMultExpr.h:406
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:932
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:2473
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:332
Header file for basic type definitions.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTSMatMultExpr.h:144
Header file for the IsUpper type trait.
Header file for the IsColumnVector type trait.
Constraint on the data type.
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
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:118
Header file for the IsExpression type trait class.
Header file for the TSMatSVecMultExprTrait class template.
Header file for the FunctionTrace class.
BLAZE_ALWAYS_INLINE 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:849
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:145
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:147