35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATDMATMULTEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_TSMATDMATMULTEXPR_H_ 121 template<
typename MT1
127 class TSMatDMatMultExpr
128 :
public MatMatMultExpr< DenseMatrix< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, false > >
129 ,
private Computation
143 static constexpr
bool evaluateLeft = ( IsComputation_v<MT1> || RequiresEvaluation_v<MT1> );
148 static constexpr
bool evaluateRight = ( IsComputation_v<MT2> || RequiresEvaluation_v<MT2> );
152 static constexpr
bool SYM = ( SF && !( HF || LF || UF ) );
153 static constexpr
bool HERM = ( HF && !( LF || UF ) );
154 static constexpr
bool LOW = ( LF || ( ( SF || HF ) && UF ) );
155 static constexpr
bool UPP = ( UF || ( ( SF || HF ) && LF ) );
165 template<
typename T1,
typename T2,
typename T3 >
166 static constexpr
bool CanExploitSymmetry_v = IsSymmetric_v<T2>;
176 template<
typename T1,
typename T2,
typename T3 >
177 static constexpr
bool IsEvaluationRequired_v =
187 template<
typename T1,
typename T2,
typename T3 >
188 static constexpr
bool UseOptimizedKernel_v =
189 ( useOptimizedKernels &&
191 !IsResizable_v< ElementType_t<T1> > &&
192 !IsResizable_v<ET1> );
201 template<
typename T1,
typename T2,
typename T3 >
202 static constexpr
bool UseDefaultKernel_v = !UseOptimizedKernel_v<T1,T2,T3>;
299 if( IsDiagonal_v<MT1> ) {
302 else if( IsDiagonal_v<MT2> ) {
305 else if( IsTriangular_v<MT1> || IsTriangular_v<MT2> ) {
306 const size_t begin( ( IsUpper_v<MT1> )
307 ?( ( IsLower_v<MT2> )
308 ?(
max( ( IsStrictlyUpper_v<MT1> ? i+1UL : i )
309 , ( IsStrictlyLower_v<MT2> ? j+1UL : j ) ) )
310 :( IsStrictlyUpper_v<MT1> ? i+1UL : i ) )
311 :( ( IsLower_v<MT2> )
312 ?( IsStrictlyLower_v<MT2> ? j+1UL : j )
314 const size_t end( ( IsLower_v<MT1> )
315 ?( ( IsUpper_v<MT2> )
316 ?(
min( ( IsStrictlyLower_v<MT1> ? i : i+1UL )
317 , ( IsStrictlyUpper_v<MT2> ? j : j+1UL ) ) )
318 :( IsStrictlyLower_v<MT1> ? i : i+1UL ) )
319 :( ( IsUpper_v<MT2> )
320 ?( IsStrictlyUpper_v<MT2> ? j : j+1UL )
321 :(
lhs_.columns() ) ) );
345 if( i >=
lhs_.rows() ) {
348 if( j >=
rhs_.columns() ) {
360 inline size_t rows() const noexcept {
371 return rhs_.columns();
401 template<
typename T >
402 inline bool canAlias(
const T* alias )
const noexcept {
403 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
413 template<
typename T >
414 inline bool isAliased(
const T* alias )
const noexcept {
415 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
425 return rhs_.isAligned();
435 return (
rows() *
columns() >= SMP_TSMATDMATMULT_THRESHOLD ) && !IsDiagonal_v<MT2>;
458 template<
typename MT
478 TSMatDMatMultExpr::selectAssignKernel( ~lhs, A, B );
494 template<
typename MT3
497 static inline void selectAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
499 const size_t size( C.rows() * C.columns() );
501 if( ( IsRowMajorMatrix_v<MT3> &&
size < TSMATDMATMULT_THRESHOLD ) ||
502 ( IsColumnMajorMatrix_v<MT3> &&
size < 625UL ) )
503 selectSmallAssignKernel( C, A, B );
505 selectLargeAssignKernel( C, A, B );
525 template<
typename MT3
528 static inline void selectDefaultAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
532 if( IsDiagonal_v<MT5> )
534 for(
size_t i=0UL; i<A.columns(); ++i )
536 const auto end( A.end(i) );
537 auto element( A.begin(i) );
539 for( ; element!=
end; ++element ) {
540 C(element->index(),i) = element->value() * B(i,i);
546 const size_t block( IsRowMajorMatrix_v<MT3> ? 256UL : 8UL );
548 for(
size_t jj=0UL; jj<B.columns(); jj+=block )
550 const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
552 for(
size_t i=0UL; i<A.columns(); ++i )
554 const auto end( A.end(i) );
555 auto element( A.begin(i) );
557 for( ; element!=
end; ++element )
559 const size_t i1( element->index() );
561 const size_t jbegin( ( IsUpper_v<MT5> )
563 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
564 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
566 const size_t jend( ( IsLower_v<MT5> )
568 ?(
min( i1+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
569 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
570 :(
LOW ?
min(i1+1UL,jpos) : jpos ) );
575 for(
size_t j=jbegin; j<jend; ++j ) {
577 C(i1,j) = element->value() * B(i,j);
579 C(i1,j) += element->value() * B(i,j);
587 for(
size_t j=0UL; j<B.columns(); ++j ) {
588 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
589 C(i,j) =
HERM ?
conj( C(j,i) ) : C(j,i);
611 template<
typename MT3
614 static inline auto selectSmallAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
615 -> EnableIf_t< UseDefaultKernel_v<MT3,MT4,MT5> >
617 selectDefaultAssignKernel( C, A, B );
637 template<
typename MT3
640 static inline auto selectSmallAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
641 -> EnableIf_t< UseOptimizedKernel_v<MT3,MT4,MT5> >
643 const size_t block( ( IsRowMajorMatrix_v<MT3> )?( 256UL ):( 8UL ) );
647 for(
size_t jj=0UL; jj<B.columns(); jj+=block )
649 const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
651 for(
size_t i=0UL; i<A.columns(); ++i )
653 const auto end( A.end(i) );
654 auto element( A.begin(i) );
656 const size_t nonzeros( A.nonZeros(i) );
657 const size_t kpos( nonzeros &
size_t(-4) );
660 for(
size_t k=0UL; k<kpos; k+=4UL )
662 const size_t i1( element->index() );
663 const ET1 v1( element->value() );
665 const size_t i2( element->index() );
666 const ET1 v2( element->value() );
668 const size_t i3( element->index() );
669 const ET1 v3( element->value() );
671 const size_t i4( element->index() );
672 const ET1 v4( element->value() );
677 const size_t jbegin( ( IsUpper_v<MT5> )
679 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
680 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
682 const size_t jend( ( IsLower_v<MT5> )
684 ?(
min( i4+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
685 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
686 :(
LOW ?
min(i4+1UL,jpos) : jpos ) );
691 for(
size_t j=jbegin; j<jend; ++j ) {
692 C(i1,j) += v1 * B(i,j);
693 C(i2,j) += v2 * B(i,j);
694 C(i3,j) += v3 * B(i,j);
695 C(i4,j) += v4 * B(i,j);
699 for( ; element!=
end; ++element )
701 const size_t i1( element->index() );
703 const size_t jbegin( ( IsUpper_v<MT5> )
705 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
706 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
708 const size_t jend( ( IsLower_v<MT5> )
710 ?(
min( i1+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
711 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
712 :(
LOW ?
min(i1+1UL,jpos) : jpos ) );
717 for(
size_t j=jbegin; j<jend; ++j ) {
718 C(i1,j) += element->value() * B(i,j);
725 for(
size_t j=0UL; j<B.columns(); ++j ) {
726 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
727 C(i,j) =
HERM ?
conj( C(j,i) ) : C(j,i);
749 template<
typename MT3
752 static inline auto selectLargeAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
753 -> EnableIf_t< UseDefaultKernel_v<MT3,MT4,MT5> >
755 selectDefaultAssignKernel( C, A, B );
775 template<
typename MT3
778 static inline auto selectLargeAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
779 -> EnableIf_t< UseOptimizedKernel_v<MT3,MT4,MT5> >
783 const ForwardFunctor fwd;
785 const OppositeType_t<MT4> tmp(
serial( A ) );
786 assign( C, fwd( tmp * B ) );
804 template<
typename MT
806 friend inline auto assign( SparseMatrix<MT,SO>& lhs,
const TSMatDMatMultExpr& rhs )
807 -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
811 using TmpType = If_t< SO, OppositeType, ResultType >;
823 const ForwardFunctor fwd;
825 const TmpType tmp(
serial( rhs ) );
826 assign( ~lhs, fwd( tmp ) );
846 template<
typename MT
849 -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
858 const ForwardFunctor fwd;
860 assign( ~lhs, fwd(
trans( rhs.lhs_ ) * rhs.rhs_ ) );
878 template<
typename MT
880 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs,
const TSMatDMatMultExpr& rhs )
881 -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
898 TSMatDMatMultExpr::selectAddAssignKernel( ~lhs, A, B );
914 template<
typename MT3
917 static inline void selectAddAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
919 const size_t size( C.rows() * C.columns() );
921 if( ( IsRowMajorMatrix_v<MT3> &&
size < TSMATDMATMULT_THRESHOLD ) ||
922 ( IsColumnMajorMatrix_v<MT3> &&
size < 625UL ) )
923 selectSmallAddAssignKernel( C, A, B );
925 selectLargeAddAssignKernel( C, A, B );
945 template<
typename MT3
948 static inline void selectDefaultAddAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
950 if( IsDiagonal_v<MT5> )
952 for(
size_t i=0UL; i<A.columns(); ++i )
954 const auto end( A.end(i) );
955 auto element( A.begin(i) );
957 for( ; element!=
end; ++element ) {
958 C(element->index(),i) += element->value() * B(i,i);
964 const size_t block( IsRowMajorMatrix_v<MT3> ? 256UL : 8UL );
966 for(
size_t jj=0UL; jj<B.columns(); jj+=block )
968 const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
970 for(
size_t i=0UL; i<A.columns(); ++i )
972 const auto end( A.end(i) );
973 auto element( A.begin(i) );
975 for( ; element!=
end; ++element )
977 const size_t i1( element->index() );
979 const size_t jbegin( ( IsUpper_v<MT5> )
981 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
982 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
983 :(
UPP ?
max(i1,jj) : jj ) );
984 const size_t jend( ( IsLower_v<MT5> )
986 ?(
min( i1+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
987 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
988 :(
LOW ?
min(i1+1UL,jpos) : jpos ) );
993 for(
size_t j=jbegin; j<jend; ++j ) {
994 C(i1,j) += element->value() * B(i,j);
1018 template<
typename MT3
1021 static inline auto selectSmallAddAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1022 -> EnableIf_t< UseDefaultKernel_v<MT3,MT4,MT5> >
1024 selectDefaultAddAssignKernel( C, A, B );
1044 template<
typename MT3
1047 static inline auto selectSmallAddAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1048 -> EnableIf_t< UseOptimizedKernel_v<MT3,MT4,MT5> >
1050 const size_t block( ( IsRowMajorMatrix_v<MT3> )?( 256UL ):( 8UL ) );
1052 for(
size_t jj=0UL; jj<B.columns(); jj+=block )
1054 const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1056 for(
size_t i=0UL; i<A.columns(); ++i )
1058 const auto end( A.end(i) );
1059 auto element( A.begin(i) );
1061 const size_t nonzeros( A.nonZeros(i) );
1062 const size_t kpos( nonzeros &
size_t(-4) );
1065 for(
size_t k=0UL; k<kpos; k+=4UL )
1067 const size_t i1( element->index() );
1068 const ET1 v1( element->value() );
1070 const size_t i2( element->index() );
1071 const ET1 v2( element->value() );
1073 const size_t i3( element->index() );
1074 const ET1 v3( element->value() );
1076 const size_t i4( element->index() );
1077 const ET1 v4( element->value() );
1082 const size_t jbegin( ( IsUpper_v<MT5> )
1084 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
1085 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
1086 :(
UPP ?
max(i1,jj) : jj ) );
1087 const size_t jend( ( IsLower_v<MT5> )
1089 ?(
min( i4+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
1090 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
1091 :(
LOW ?
min(i4+1UL,jpos) : jpos ) );
1093 if( jbegin >= jend )
1096 for(
size_t j=jbegin; j<jend; ++j ) {
1097 C(i1,j) += v1 * B(i,j);
1098 C(i2,j) += v2 * B(i,j);
1099 C(i3,j) += v3 * B(i,j);
1100 C(i4,j) += v4 * B(i,j);
1104 for( ; element!=
end; ++element )
1106 const size_t i1( element->index() );
1108 const size_t jbegin( ( IsUpper_v<MT5> )
1110 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
1111 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
1112 :(
UPP ?
max(i1,jj) : jj ) );
1113 const size_t jend( ( IsLower_v<MT5> )
1115 ?(
min( i1+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
1116 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
1117 :(
LOW ?
min(i1+1UL,jpos) : jpos ) );
1119 if( jbegin >= jend )
1122 for(
size_t j=jbegin; j<jend; ++j ) {
1123 C(i1,j) += element->value() * B(i,j);
1146 template<
typename MT3
1149 static inline auto selectLargeAddAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1150 -> EnableIf_t< UseDefaultKernel_v<MT3,MT4,MT5> >
1152 selectDefaultAddAssignKernel( C, A, B );
1172 template<
typename MT3
1175 static inline auto selectLargeAddAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1176 -> EnableIf_t< UseOptimizedKernel_v<MT3,MT4,MT5> >
1180 const ForwardFunctor fwd;
1182 const OppositeType_t<MT4> tmp(
serial( A ) );
1183 addAssign( C, fwd( tmp * B ) );
1203 template<
typename MT
1205 friend inline auto addAssign( Matrix<MT,SO>& lhs,
const TSMatDMatMultExpr& rhs )
1206 -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1215 const ForwardFunctor fwd;
1217 addAssign( ~lhs, fwd(
trans( rhs.lhs_ ) * rhs.rhs_ ) );
1239 template<
typename MT
1241 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs,
const TSMatDMatMultExpr& rhs )
1242 -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1259 TSMatDMatMultExpr::selectSubAssignKernel( ~lhs, A, B );
1275 template<
typename MT3
1278 static inline void selectSubAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1280 const size_t size( C.rows() * C.columns() );
1282 if( ( IsRowMajorMatrix_v<MT3> &&
size < TSMATDMATMULT_THRESHOLD ) ||
1283 ( IsColumnMajorMatrix_v<MT3> &&
size < 625UL ) )
1284 selectSmallSubAssignKernel( C, A, B );
1286 selectLargeSubAssignKernel( C, A, B );
1306 template<
typename MT3
1309 static inline void selectDefaultSubAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1311 if( IsDiagonal_v<MT5> )
1313 for(
size_t i=0UL; i<A.columns(); ++i )
1315 const auto end( A.end(i) );
1316 auto element( A.begin(i) );
1318 for( ; element!=
end; ++element ) {
1319 C(element->index(),i) -= element->value() * B(i,i);
1325 const size_t block( IsRowMajorMatrix_v<MT3> ? 256UL : 8UL );
1327 for(
size_t jj=0UL; jj<B.columns(); jj+=block )
1329 const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1331 for(
size_t i=0UL; i<A.columns(); ++i )
1333 const auto end( A.end(i) );
1334 auto element( A.begin(i) );
1336 for( ; element!=
end; ++element )
1338 const size_t i1( element->index() );
1340 const size_t jbegin( ( IsUpper_v<MT5> )
1342 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
1343 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
1344 :(
UPP ?
max(i1,jj) : jj ) );
1345 const size_t jend( ( IsLower_v<MT5> )
1347 ?(
min( i1+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
1348 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
1349 :(
LOW ?
min(i1+1UL,jpos) : jpos ) );
1351 if( jbegin >= jend )
1354 for(
size_t j=jbegin; j<jend; ++j ) {
1355 C(i1,j) -= element->value() * B(i,j);
1379 template<
typename MT3
1382 static inline auto selectSmallSubAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1383 -> EnableIf_t< UseDefaultKernel_v<MT3,MT4,MT5> >
1385 selectDefaultSubAssignKernel( C, A, B );
1405 template<
typename MT3
1408 static inline auto selectSmallSubAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1409 -> EnableIf_t< UseOptimizedKernel_v<MT3,MT4,MT5> >
1411 const size_t block( ( IsRowMajorMatrix_v<MT3> )?( 256UL ):( 8UL ) );
1413 for(
size_t jj=0UL; jj<B.columns(); jj+=block )
1415 const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1417 for(
size_t i=0UL; i<A.columns(); ++i )
1419 const auto end( A.end(i) );
1420 auto element( A.begin(i) );
1422 const size_t nonzeros( A.nonZeros(i) );
1423 const size_t kpos( nonzeros &
size_t(-4) );
1426 for(
size_t k=0UL; k<kpos; k+=4UL )
1428 const size_t i1( element->index() );
1429 const ET1 v1( element->value() );
1431 const size_t i2( element->index() );
1432 const ET1 v2( element->value() );
1434 const size_t i3( element->index() );
1435 const ET1 v3( element->value() );
1437 const size_t i4( element->index() );
1438 const ET1 v4( element->value() );
1443 const size_t jbegin( ( IsUpper_v<MT5> )
1445 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
1446 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
1447 :(
UPP ?
max(i1,jj) : jj ) );
1448 const size_t jend( ( IsLower_v<MT5> )
1450 ?(
min( i4+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
1451 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
1452 :(
LOW ?
min(i4+1UL,jpos) : jpos ) );
1454 if( jbegin >= jend )
1457 for(
size_t j=jbegin; j<jend; ++j ) {
1458 C(i1,j) -= v1 * B(i,j);
1459 C(i2,j) -= v2 * B(i,j);
1460 C(i3,j) -= v3 * B(i,j);
1461 C(i4,j) -= v4 * B(i,j);
1465 for( ; element!=
end; ++element )
1467 const size_t i1( element->index() );
1469 const size_t jbegin( ( IsUpper_v<MT5> )
1471 ?(
max( i1, IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) )
1472 :(
max( IsStrictlyUpper_v<MT5> ? i+1UL : i, jj ) ) )
1473 :(
UPP ?
max(i1,jj) : jj ) );
1474 const size_t jend( ( IsLower_v<MT5> )
1476 ?(
min( i1+1UL, IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) )
1477 :(
min( IsStrictlyLower_v<MT5> ? i : i+1UL, jpos ) ) )
1478 :(
LOW ?
min(i1+1UL,jpos) : jpos ) );
1480 if( jbegin >= jend )
1483 for(
size_t j=jbegin; j<jend; ++j ) {
1484 C(i1,j) -= element->value() * B(i,j);
1507 template<
typename MT3
1510 static inline auto selectLargeSubAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1511 -> EnableIf_t< UseDefaultKernel_v<MT3,MT4,MT5> >
1513 selectDefaultSubAssignKernel( C, A, B );
1533 template<
typename MT3
1536 static inline auto selectLargeSubAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1537 -> EnableIf_t< UseOptimizedKernel_v<MT3,MT4,MT5> >
1541 const ForwardFunctor fwd;
1543 const OppositeType_t<MT4> tmp(
serial( A ) );
1544 subAssign( C, fwd( tmp * B ) );
1564 template<
typename MT
1566 friend inline auto subAssign( Matrix<MT,SO>& lhs,
const TSMatDMatMultExpr& rhs )
1567 -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1576 const ForwardFunctor fwd;
1578 subAssign( ~lhs, fwd(
trans( rhs.lhs_ ) * rhs.rhs_ ) );
1600 template<
typename MT
1602 friend inline void schurAssign( DenseMatrix<MT,SO>& lhs,
const TSMatDMatMultExpr& rhs )
1614 schurAssign( ~lhs, tmp );
1647 template<
typename MT
1650 -> EnableIf_t< IsEvaluationRequired_v<MT,MT1,MT2> >
1688 template<
typename MT
1691 -> EnableIf_t< IsEvaluationRequired_v<MT,MT1,MT2> >
1695 using TmpType = If_t< SO, OppositeType, ResultType >;
1707 const ForwardFunctor fwd;
1709 const TmpType tmp( rhs );
1730 template<
typename MT
1733 -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1740 const ForwardFunctor fwd;
1763 template<
typename MT
1766 -> EnableIf_t< IsEvaluationRequired_v<MT,MT1,MT2> >
1803 template<
typename MT
1806 -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1813 const ForwardFunctor fwd;
1840 template<
typename MT
1843 -> EnableIf_t< IsEvaluationRequired_v<MT,MT1,MT2> >
1880 template<
typename MT
1883 -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1890 const ForwardFunctor fwd;
1914 template<
typename MT
1980 template<
typename MT1
1982 , DisableIf_t< ( IsIdentity_v<MT1> &&
1983 IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > ) ||
1984 IsZero_v<MT1> >* =
nullptr >
1985 inline const TSMatDMatMultExpr<MT1,MT2,false,false,false,false>
1986 tsmatdmatmult(
const SparseMatrix<MT1,true>& lhs,
const DenseMatrix<MT2,false>& rhs )
1992 return TSMatDMatMultExpr<MT1,MT2,false,false,false,false>( ~lhs, ~rhs );
2012 template<
typename MT1
2014 , EnableIf_t< IsIdentity_v<MT1> &&
2015 IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > >* =
nullptr >
2017 tsmatdmatmult(
const SparseMatrix<MT1,true>& lhs,
const DenseMatrix<MT2,false>& rhs )
2044 template<
typename MT1
2046 , EnableIf_t< IsZero_v<MT1> >* =
nullptr >
2047 inline decltype(
auto)
2048 tsmatdmatmult( const SparseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
2054 using ReturnType =
const MultTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
2096 template<
typename MT1
2098 inline decltype(
auto)
2107 return tsmatdmatmult( ~lhs, ~rhs );
2146 template<
typename MT1
2152 inline decltype(
auto)
declsym( const TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2160 using ReturnType =
const TSMatDMatMultExpr<MT1,MT2,true,HF,LF,UF>;
2161 return ReturnType( dm.leftOperand(), dm.rightOperand() );
2193 template<
typename MT1
2199 inline decltype(
auto)
declherm( const TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2207 using ReturnType =
const TSMatDMatMultExpr<MT1,MT2,SF,true,LF,UF>;
2208 return ReturnType( dm.leftOperand(), dm.rightOperand() );
2240 template<
typename MT1
2246 inline decltype(
auto)
decllow( const TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2254 using ReturnType =
const TSMatDMatMultExpr<MT1,MT2,SF,HF,true,UF>;
2255 return ReturnType( dm.leftOperand(), dm.rightOperand() );
2287 template<
typename MT1
2293 inline decltype(
auto)
declupp( const TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2301 using ReturnType =
const TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,true>;
2302 return ReturnType( dm.leftOperand(), dm.rightOperand() );
2334 template<
typename MT1
2340 inline decltype(
auto)
decldiag( const TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2348 using ReturnType =
const TSMatDMatMultExpr<MT1,MT2,SF,HF,true,true>;
2349 return ReturnType( dm.leftOperand(), dm.rightOperand() );
2365 template<
typename MT1,
typename MT2,
bool SF,
bool HF,
bool LF,
bool UF >
2366 struct Size< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, 0UL >
2367 :
public Size<MT1,0UL>
2370 template<
typename MT1,
typename MT2,
bool SF,
bool HF,
bool LF,
bool UF >
2371 struct Size< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, 1UL >
2372 :
public Size<MT2,1UL>
2388 template<
typename MT1,
typename MT2,
bool SF,
bool HF,
bool LF,
bool UF >
2389 struct IsAligned< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2390 :
public IsAligned<MT2>
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:329
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TSMatDMatMultExpr.h:246
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the decldiag trait.
decltype(auto) decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:975
If_t< IsExpression_v< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:256
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: TSMatDMatMultExpr.h:424
Header file for basic type definitions.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
Header file for the declherm trait.
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TSMatDMatMultExpr.h:295
Header file for the serial shim.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: TSMatDMatMultExpr.h:370
Header file for the IsDiagonal type trait.
Base template for the DeclUppTrait class.
Definition: DeclUppTrait.h:134
#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:61
Header file for the DeclUpp functor.
ResultType_t< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:133
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatDMatMultExpr.h:441
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
Constraint on the data type.
Header file for the IsIdentity type trait.
If_t< evaluateLeft, const RT1, CT1 > LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: TSMatDMatMultExpr.h:259
static constexpr bool SYM
Flag for symmetric matrices.
Definition: TSMatDMatMultExpr.h:152
decltype(auto) declupp(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as upper.
Definition: DMatDeclUppExpr.h:1002
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:138
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: TSMatDMatMultExpr.h:267
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatDMatMultExpr.h:380
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
Header file for the reset shim.
static constexpr bool evaluateRight
Compilation switch for the composite type of the right-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:148
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
System settings for performance optimizations.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
If_t< IsExpression_v< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:253
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: TSMatDMatMultExpr.h:360
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatDMatMultExpr.h:250
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:137
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
static constexpr bool UPP
Flag for upper matrices.
Definition: TSMatDMatMultExpr.h:155
static constexpr bool LOW
Flag for lower matrices.
Definition: TSMatDMatMultExpr.h:154
RightOperand rhs_
Right-hand side dense matrix of the multiplication expression.
Definition: TSMatDMatMultExpr.h:442
Constraint on the data type.
Constraint on the data type.
typename If_t< HERM, DeclHermTrait< MultTrait_t< RT1, RT2 > >, If_t< SYM, DeclSymTrait< MultTrait_t< RT1, RT2 > >, If_t< LOW, If_t< UPP, DeclDiagTrait< MultTrait_t< RT1, RT2 > >, DeclLowTrait< MultTrait_t< RT1, RT2 > > >, If_t< UPP, DeclUppTrait< MultTrait_t< RT1, RT2 > >, MultTrait< RT1, RT2 > > > > >::Type ResultType
Result type for expression template evaluations.
Definition: TSMatDMatMultExpr.h:244
Headerfile for the generic max algorithm.
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.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the DeclLow functor.
Header file for the If class template.
#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:61
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: TSMatDMatMultExpr.h:270
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is not a zero vector or matrix type...
Definition: Zero.h:61
ElementType_t< RT2 > ET2
Element type of the right-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:136
Generic wrapper for the decllow() function.
Definition: DeclLow.h:58
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
Header file for the decllow trait.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
decltype(auto) decllow(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as lower.
Definition: DMatDeclLowExpr.h:1002
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
If_t< evaluateRight, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: TSMatDMatMultExpr.h:262
Generic wrapper for the null function.
Definition: Noop.h:59
Header file for the IsTriangular type trait.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: TSMatDMatMultExpr.h:344
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: TSMatDMatMultExpr.h:434
Base template for the DeclSymTrait class.
Definition: DeclSymTrait.h:134
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
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:438
Header file for the DeclDiag functor.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
CompositeType_t< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:137
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
#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:103
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: TSMatDMatMultExpr.h:390
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: TSMatDMatMultExpr.h:248
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
Header file for the conjugate shim.
Header file for the declupp trait.
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:134
#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:79
#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:61
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
Base template for the DeclHermTrait class.
Definition: DeclHermTrait.h:134
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: TSMatDMatMultExpr.h:247
Base template for the MultTrait class.
Definition: MultTrait.h:146
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
TSMatDMatMultExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the TSMatDMatMultExpr class.
Definition: TSMatDMatMultExpr.h:280
Header file for the IsZero type trait.
ElementType_t< RT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:135
Header file for the declsym trait.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
decltype(auto) declsym(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as symmetric.
Definition: DMatDeclSymExpr.h:1002
Header file for the isDefault shim.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
Constraint on the data type.
Constraints on the storage order of matrix types.
Generic wrapper for the declherm() function.
Definition: DeclHerm.h:58
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Header file for the Noop functor.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
#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:84
Generic wrapper for the declupp() function.
Definition: DeclUpp.h:58
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatDMatMultExpr.h:249
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: TSMatDMatMultExpr.h:414
Base template for the DeclLowTrait class.
Definition: DeclLowTrait.h:134
decltype(auto) declherm(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as Hermitian.
Definition: DMatDeclHermExpr.h:1002
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
Expression object for transpose sparse matrix-dense matrix multiplications.The TSMatDMatMultExpr clas...
Definition: Forward.h:169
static constexpr bool evaluateLeft
Compilation switch for the composite type of the left-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:143
Header file for the IntegralConstant class template.
Generic wrapper for the decldiag() function.
Definition: DeclDiag.h:58
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: TSMatDMatMultExpr.h:402
Header file for the DeclHerm functor.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
Header file for the IsUpper type trait.
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1326
Constraint on the data type.
Generic wrapper for the declsym() function.
Definition: DeclSym.h:58
Base template for the DeclDiagTrait class.
Definition: DeclDiagTrait.h:134
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
static constexpr bool HERM
Flag for Hermitian matrices.
Definition: TSMatDMatMultExpr.h:153
Header file for the IsResizable type trait.
Header file for the Size type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is a zero vector or matrix type...
Definition: Zero.h:81
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
Header file for the DeclSym functor.
#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:61
Header file for the IsExpression type trait class.
Header file for the function trace functionality.