35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTDMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATTDMATMULTEXPR_H_
126 template<
typename MT1
128 class SMatTDMatMultExpr :
public DenseMatrix< SMatTDMatMultExpr<MT1,MT2>, false >
129 ,
private MatMatMultExpr
130 ,
private Computation
159 template<
typename T1,
typename T2,
typename T3 >
160 struct CanExploitSymmetry {
161 enum :
bool { value = IsSymmetric<T3>::value };
172 template<
typename T1,
typename T2,
typename T3 >
173 struct IsEvaluationRequired {
174 enum :
bool { value = ( evaluateLeft || evaluateRight ) &&
175 CanExploitSymmetry<T1,T2,T3>::value };
185 template<
typename T1,
typename T2,
typename T3 >
186 struct UseOptimizedKernel {
188 !IsDiagonal<T3>::value &&
189 !IsResizable< ElementType_<T1> >::value &&
190 !IsResizable<ET1>::value };
220 enum :
bool { simdEnabled =
false };
223 enum :
bool { smpAssignable = !evaluateLeft && MT1::smpAssignable &&
224 !evaluateRight && MT2::smpAssignable };
274 :(
lhs_.columns() ) ) );
278 const size_t n(
end - begin );
296 inline ReturnType
at(
size_t i,
size_t j )
const {
297 if( i >=
lhs_.rows() ) {
300 if( j >=
rhs_.columns() ) {
312 inline size_t rows() const noexcept {
323 return rhs_.columns();
353 template<
typename T >
354 inline bool canAlias(
const T* alias )
const noexcept {
355 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
365 template<
typename T >
366 inline bool isAliased(
const T* alias )
const noexcept {
367 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
377 return rhs_.isAligned();
387 return (
rows() *
columns() >= SMP_SMATTDMATMULT_THRESHOLD );
410 template<
typename MT
420 LT A(
serial( rhs.lhs_ ) );
421 RT B(
serial( rhs.rhs_ ) );
430 SMatTDMatMultExpr::selectAssignKernel( ~lhs, A, B );
449 template<
typename MT3
453 selectAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
459 for(
size_t ii=0UL; ii<A.rows(); ii+=block )
461 const size_t iend(
min( ii+block, A.rows() ) );
465 for( ; (j+4UL) <= B.columns(); j+=4UL ) {
466 for(
size_t i=ii; i<iend; ++i )
475 if( element ==
end ) {
483 C(i,j ) = element->value() * B(element->index(),j );
484 C(i,j+1UL) = element->value() * B(element->index(),j+1UL);
485 C(i,j+2UL) = element->value() * B(element->index(),j+2UL);
486 C(i,j+3UL) = element->value() * B(element->index(),j+3UL);
488 for( ; element!=
end; ++element ) {
489 C(i,j ) += element->value() * B(element->index(),j );
490 C(i,j+1UL) += element->value() * B(element->index(),j+1UL);
491 C(i,j+2UL) += element->value() * B(element->index(),j+2UL);
492 C(i,j+3UL) += element->value() * B(element->index(),j+3UL);
497 for( ; (j+2UL) <= B.columns(); j+=2UL ) {
498 for(
size_t i=ii; i<iend; ++i )
500 const ConstIterator
end( ( IsUpper<MT5>::value )
501 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+2UL) : A.upperBound(i,j+2UL) )
503 ConstIterator element( ( IsLower<MT5>::value )
504 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
507 if( element ==
end ) {
513 C(i,j ) = element->value() * B(element->index(),j );
514 C(i,j+1UL) = element->value() * B(element->index(),j+1UL);
516 for( ; element!=
end; ++element ) {
517 C(i,j ) += element->value() * B(element->index(),j );
518 C(i,j+1UL) += element->value() * B(element->index(),j+1UL);
523 for( ; j<B.columns(); ++j ) {
524 for(
size_t i=ii; i<iend; ++i )
526 const ConstIterator
end( ( IsUpper<MT5>::value )
527 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j) : A.upperBound(i,j) )
529 ConstIterator element( ( IsLower<MT5>::value )
530 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
533 if( element ==
end ) {
538 C(i,j) = element->value() * B(element->index(),j);
540 for( ; element!=
end; ++element ) {
541 C(i,j) += element->value() * B(element->index(),j);
564 template<
typename MT3
567 static inline EnableIf_< UseOptimizedKernel<MT3,MT4,MT5> >
568 selectAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
572 const size_t block( IsColumnMajorMatrix<MT3>::value ? A.rows() : 256UL );
576 for(
size_t ii=0UL; ii<A.rows(); ii+=block )
578 const size_t iend(
min( ii+block, A.rows() ) );
582 for( ; (j+4UL) <= B.columns(); j+=4UL ) {
583 for(
size_t i=ii; i<iend; ++i )
585 const ConstIterator
end( ( IsUpper<MT5>::value )
586 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+4UL) : A.upperBound(i,j+4UL) )
588 ConstIterator element( ( IsLower<MT5>::value )
589 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
592 const size_t nonzeros(
end - element );
593 const size_t kpos( nonzeros &
size_t(-4) );
596 for(
size_t k=0UL; k<kpos; k+=4UL )
598 const size_t i1( element->index() );
599 const ET1 v1( element->value() );
601 const size_t i2( element->index() );
602 const ET1 v2( element->value() );
604 const size_t i3( element->index() );
605 const ET1 v3( element->value() );
607 const size_t i4( element->index() );
608 const ET1 v4( element->value() );
613 C(i,j ) += v1 * B(i1,j ) + v2 * B(i2,j ) + v3 * B(i3,j ) + v4 * B(i4,j );
614 C(i,j+1UL) += v1 * B(i1,j+1UL) + v2 * B(i2,j+1UL) + v3 * B(i3,j+1UL) + v4 * B(i4,j+1UL);
615 C(i,j+2UL) += v1 * B(i1,j+2UL) + v2 * B(i2,j+2UL) + v3 * B(i3,j+2UL) + v4 * B(i4,j+2UL);
616 C(i,j+3UL) += v1 * B(i1,j+3UL) + v2 * B(i2,j+3UL) + v3 * B(i3,j+3UL) + v4 * B(i4,j+3UL);
619 for( ; element!=
end; ++element )
621 const size_t i1( element->index() );
622 const ET1 v1( element->value() );
624 C(i,j ) += v1 * B(i1,j );
625 C(i,j+1UL) += v1 * B(i1,j+1UL);
626 C(i,j+2UL) += v1 * B(i1,j+2UL);
627 C(i,j+3UL) += v1 * B(i1,j+3UL);
632 for( ; (j+2UL) <= B.columns(); j+=2UL ) {
633 for(
size_t i=ii; i<iend; ++i )
635 const ConstIterator
end( ( IsUpper<MT5>::value )
636 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+2UL) : A.upperBound(i,j+2UL) )
638 ConstIterator element( ( IsLower<MT5>::value )
639 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
642 const size_t nonzeros(
end - element );
643 const size_t kpos( nonzeros &
size_t(-4) );
646 for(
size_t k=0UL; k<kpos; k+=4UL )
648 const size_t i1( element->index() );
649 const ET1 v1( element->value() );
651 const size_t i2( element->index() );
652 const ET1 v2( element->value() );
654 const size_t i3( element->index() );
655 const ET1 v3( element->value() );
657 const size_t i4( element->index() );
658 const ET1 v4( element->value() );
663 C(i,j ) += v1 * B(i1,j ) + v2 * B(i2,j ) + v3 * B(i3,j ) + v4 * B(i4,j );
664 C(i,j+1UL) += v1 * B(i1,j+1UL) + v2 * B(i2,j+1UL) + v3 * B(i3,j+1UL) + v4 * B(i4,j+1UL);
667 for( ; element!=
end; ++element )
669 const size_t i1( element->index() );
670 const ET1 v1( element->value() );
672 C(i,j ) += v1 * B(i1,j );
673 C(i,j+1UL) += v1 * B(i1,j+1UL);
678 for( ; j<B.columns(); ++j ) {
679 for(
size_t i=ii; i<iend; ++i )
681 const ConstIterator
end( ( IsUpper<MT5>::value )
682 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j) : A.upperBound(i,j) )
684 ConstIterator element( ( IsLower<MT5>::value )
685 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
688 const size_t nonzeros(
end - element );
689 const size_t kpos( nonzeros &
size_t(-4) );
692 for(
size_t k=0UL; k<kpos; k+=4UL )
694 const size_t i1( element->index() );
695 const ET1 v1( element->value() );
697 const size_t i2( element->index() );
698 const ET1 v2( element->value() );
700 const size_t i3( element->index() );
701 const ET1 v3( element->value() );
703 const size_t i4( element->index() );
704 const ET1 v4( element->value() );
709 C(i,j) += v1 * B(i1,j) + v2 * B(i2,j) + v3 * B(i3,j) + v4 * B(i4,j);
712 for( ; element!=
end; ++element )
714 const size_t i1( element->index() );
715 const ET1 v1( element->value() );
717 C(i,j) += v1 * B(i1,j);
739 template<
typename MT
741 friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> >
746 typedef IfTrue_< SO, OppositeType, ResultType > TmpType;
758 const TmpType tmp(
serial( rhs ) );
779 template<
typename MT
781 friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
789 assign( ~lhs, rhs.lhs_ *
trans( rhs.rhs_ ) );
807 template<
typename MT
809 friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> >
817 LT A(
serial( rhs.lhs_ ) );
818 RT B(
serial( rhs.rhs_ ) );
827 SMatTDMatMultExpr::selectAddAssignKernel( ~lhs, A, B );
846 template<
typename MT3
849 static inline DisableIf_< UseOptimizedKernel<MT3,MT4,MT5> >
850 selectAddAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
854 const size_t block( IsColumnMajorMatrix<MT3>::value ? A.rows() : 256UL );
856 for(
size_t ii=0UL; ii<A.rows(); ii+=block )
858 const size_t iend(
min( ii+block, A.rows() ) );
862 for( ; (j+4UL) <= B.columns(); j+=4UL ) {
863 for(
size_t i=ii; i<iend; ++i )
865 const ConstIterator
end( ( IsUpper<MT5>::value )
866 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+4UL) : A.upperBound(i,j+4UL) )
868 ConstIterator element( ( IsLower<MT5>::value )
869 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
872 for( ; element!=
end; ++element ) {
873 C(i,j ) += element->value() * B(element->index(),j );
874 C(i,j+1UL) += element->value() * B(element->index(),j+1UL);
875 C(i,j+2UL) += element->value() * B(element->index(),j+2UL);
876 C(i,j+3UL) += element->value() * B(element->index(),j+3UL);
881 for( ; (j+2UL) <= B.columns(); j+=2UL ) {
882 for(
size_t i=ii; i<iend; ++i )
884 const ConstIterator
end( ( IsUpper<MT5>::value )
885 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+2UL) : A.upperBound(i,j+2UL) )
887 ConstIterator element( ( IsLower<MT5>::value )
888 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
891 for( ; element!=
end; ++element ) {
892 C(i,j ) += element->value() * B(element->index(),j );
893 C(i,j+1UL) += element->value() * B(element->index(),j+1UL);
898 for( ; j<B.columns(); ++j ) {
899 for(
size_t i=ii; i<iend; ++i )
901 const ConstIterator
end( ( IsUpper<MT5>::value )
902 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j) : A.upperBound(i,j) )
904 ConstIterator element( ( IsLower<MT5>::value )
905 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
908 for( ; element!=
end; ++element ) {
909 C(i,j) += element->value() * B(element->index(),j);
932 template<
typename MT3
935 static inline EnableIf_< UseOptimizedKernel<MT3,MT4,MT5> >
936 selectAddAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
940 const size_t block( IsColumnMajorMatrix<MT3>::value ? A.rows() : 256UL );
942 for(
size_t ii=0UL; ii<A.rows(); ii+=block )
944 const size_t iend(
min( ii+block, A.rows() ) );
948 for( ; (j+4UL) <= B.columns(); j+=4UL ) {
949 for(
size_t i=ii; i<iend; ++i )
951 const ConstIterator
end( ( IsUpper<MT5>::value )
952 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+4UL) : A.upperBound(i,j+4UL) )
954 ConstIterator element( ( IsLower<MT5>::value )
955 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
958 const size_t nonzeros(
end - element );
959 const size_t kpos( nonzeros &
size_t(-4) );
962 for(
size_t k=0UL; k<kpos; k+=4UL )
964 const size_t i1( element->index() );
965 const ET1 v1( element->value() );
967 const size_t i2( element->index() );
968 const ET1 v2( element->value() );
970 const size_t i3( element->index() );
971 const ET1 v3( element->value() );
973 const size_t i4( element->index() );
974 const ET1 v4( element->value() );
979 C(i,j ) += v1 * B(i1,j ) + v2 * B(i2,j ) + v3 * B(i3,j ) + v4 * B(i4,j );
980 C(i,j+1UL) += v1 * B(i1,j+1UL) + v2 * B(i2,j+1UL) + v3 * B(i3,j+1UL) + v4 * B(i4,j+1UL);
981 C(i,j+2UL) += v1 * B(i1,j+2UL) + v2 * B(i2,j+2UL) + v3 * B(i3,j+2UL) + v4 * B(i4,j+2UL);
982 C(i,j+3UL) += v1 * B(i1,j+3UL) + v2 * B(i2,j+3UL) + v3 * B(i3,j+3UL) + v4 * B(i4,j+3UL);
985 for( ; element!=
end; ++element )
987 const size_t i1( element->index() );
988 const ET1 v1( element->value() );
990 C(i,j ) += v1 * B(i1,j );
991 C(i,j+1UL) += v1 * B(i1,j+1UL);
992 C(i,j+2UL) += v1 * B(i1,j+2UL);
993 C(i,j+3UL) += v1 * B(i1,j+3UL);
998 for( ; (j+2UL) <= B.columns(); j+=2UL ) {
999 for(
size_t i=ii; i<iend; ++i )
1001 const ConstIterator
end( ( IsUpper<MT5>::value )
1002 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+2UL) : A.upperBound(i,j+2UL) )
1004 ConstIterator element( ( IsLower<MT5>::value )
1005 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
1008 const size_t nonzeros(
end - element );
1009 const size_t kpos( nonzeros &
size_t(-4) );
1012 for(
size_t k=0UL; k<kpos; k+=4UL )
1014 const size_t i1( element->index() );
1015 const ET1 v1( element->value() );
1017 const size_t i2( element->index() );
1018 const ET1 v2( element->value() );
1020 const size_t i3( element->index() );
1021 const ET1 v3( element->value() );
1023 const size_t i4( element->index() );
1024 const ET1 v4( element->value() );
1029 C(i,j ) += v1 * B(i1,j ) + v2 * B(i2,j ) + v3 * B(i3,j ) + v4 * B(i4,j );
1030 C(i,j+1UL) += v1 * B(i1,j+1UL) + v2 * B(i2,j+1UL) + v3 * B(i3,j+1UL) + v4 * B(i4,j+1UL);
1033 for( ; element!=
end; ++element )
1035 const size_t i1( element->index() );
1036 const ET1 v1( element->value() );
1038 C(i,j ) += v1 * B(i1,j );
1039 C(i,j+1UL) += v1 * B(i1,j+1UL);
1044 for( ; j<B.columns(); ++j ) {
1045 for(
size_t i=ii; i<iend; ++i )
1047 const ConstIterator
end( ( IsUpper<MT5>::value )
1048 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j) : A.upperBound(i,j) )
1050 ConstIterator element( ( IsLower<MT5>::value )
1051 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
1054 const size_t nonzeros(
end - element );
1055 const size_t kpos( nonzeros &
size_t(-4) );
1058 for(
size_t k=0UL; k<kpos; k+=4UL )
1060 const size_t i1( element->index() );
1061 const ET1 v1( element->value() );
1063 const size_t i2( element->index() );
1064 const ET1 v2( element->value() );
1066 const size_t i3( element->index() );
1067 const ET1 v3( element->value() );
1069 const size_t i4( element->index() );
1070 const ET1 v4( element->value() );
1075 C(i,j) += v1 * B(i1,j) + v2 * B(i2,j) + v3 * B(i3,j) + v4 * B(i4,j);
1078 for( ; element!=
end; ++element )
1080 const size_t i1( element->index() );
1081 const ET1 v1( element->value() );
1083 C(i,j) += v1 * B(i1,j);
1107 template<
typename MT
1109 friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
1117 addAssign( ~lhs, rhs.lhs_ *
trans( rhs.rhs_ ) );
1139 template<
typename MT
1141 friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> >
1149 LT A(
serial( rhs.lhs_ ) );
1150 RT B(
serial( rhs.rhs_ ) );
1159 SMatTDMatMultExpr::selectSubAssignKernel( ~lhs, A, B );
1178 template<
typename MT3
1181 static inline DisableIf_< UseOptimizedKernel<MT3,MT4,MT5> >
1182 selectSubAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1186 const size_t block( IsColumnMajorMatrix<MT3>::value ? A.rows() : 256UL );
1188 for(
size_t ii=0UL; ii<A.rows(); ii+=block )
1190 const size_t iend(
min( ii+block, A.rows() ) );
1194 for( ; (j+4UL) <= B.columns(); j+=4UL ) {
1195 for(
size_t i=ii; i<iend; ++i )
1197 const ConstIterator
end( ( IsUpper<MT5>::value )
1198 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+4UL) : A.upperBound(i,j+4UL) )
1200 ConstIterator element( ( IsLower<MT5>::value )
1201 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
1204 for( ; element!=
end; ++element ) {
1205 C(i,j ) -= element->value() * B(element->index(),j );
1206 C(i,j+1UL) -= element->value() * B(element->index(),j+1UL);
1207 C(i,j+2UL) -= element->value() * B(element->index(),j+2UL);
1208 C(i,j+3UL) -= element->value() * B(element->index(),j+3UL);
1213 for( ; (j+2UL) <= B.columns(); j+=2UL ) {
1214 for(
size_t i=ii; i<iend; ++i )
1216 const ConstIterator
end( ( IsUpper<MT5>::value )
1217 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+2UL) : A.upperBound(i,j+2UL) )
1219 ConstIterator element( ( IsLower<MT5>::value )
1220 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
1223 for( ; element!=
end; ++element ) {
1224 C(i,j ) -= element->value() * B(element->index(),j );
1225 C(i,j+1UL) -= element->value() * B(element->index(),j+1UL);
1230 for( ; j<B.columns(); ++j ) {
1231 for(
size_t i=ii; i<iend; ++i )
1233 const ConstIterator
end( ( IsUpper<MT5>::value )
1234 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j) : A.upperBound(i,j) )
1236 ConstIterator element( ( IsLower<MT5>::value )
1237 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
1240 for( ; element!=
end; ++element ) {
1241 C(i,j) -= element->value() * B(element->index(),j);
1264 template<
typename MT3
1267 static inline EnableIf_< UseOptimizedKernel<MT3,MT4,MT5> >
1268 selectSubAssignKernel( MT3& C,
const MT4& A,
const MT5& B )
1272 const size_t block( IsColumnMajorMatrix<MT3>::value ? A.rows() : 256UL );
1274 for(
size_t ii=0UL; ii<A.rows(); ii+=block )
1276 const size_t iend(
min( ii+block, A.rows() ) );
1280 for( ; (j+4UL) <= B.columns(); j+=4UL ) {
1281 for(
size_t i=ii; i<iend; ++i )
1283 const ConstIterator
end( ( IsUpper<MT5>::value )
1284 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+4UL) : A.upperBound(i,j+4UL) )
1286 ConstIterator element( ( IsLower<MT5>::value )
1287 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
1290 const size_t nonzeros(
end - element );
1291 const size_t kpos( nonzeros &
size_t(-4) );
1294 for(
size_t k=0UL; k<kpos; k+=4UL )
1296 const size_t i1( element->index() );
1297 const ET1 v1( element->value() );
1299 const size_t i2( element->index() );
1300 const ET1 v2( element->value() );
1302 const size_t i3( element->index() );
1303 const ET1 v3( element->value() );
1305 const size_t i4( element->index() );
1306 const ET1 v4( element->value() );
1311 C(i,j ) -= v1 * B(i1,j ) + v2 * B(i2,j ) + v3 * B(i3,j ) + v4 * B(i4,j );
1312 C(i,j+1UL) -= v1 * B(i1,j+1UL) + v2 * B(i2,j+1UL) + v3 * B(i3,j+1UL) + v4 * B(i4,j+1UL);
1313 C(i,j+2UL) -= v1 * B(i1,j+2UL) + v2 * B(i2,j+2UL) + v3 * B(i3,j+2UL) + v4 * B(i4,j+2UL);
1314 C(i,j+3UL) -= v1 * B(i1,j+3UL) + v2 * B(i2,j+3UL) + v3 * B(i3,j+3UL) + v4 * B(i4,j+3UL);
1317 for( ; element!=
end; ++element )
1319 const size_t i1( element->index() );
1320 const ET1 v1( element->value() );
1322 C(i,j ) -= v1 * B(i1,j );
1323 C(i,j+1UL) -= v1 * B(i1,j+1UL);
1324 C(i,j+2UL) -= v1 * B(i1,j+2UL);
1325 C(i,j+3UL) -= v1 * B(i1,j+3UL);
1330 for( ; (j+2UL) <= B.columns(); j+=2UL ) {
1331 for(
size_t i=ii; i<iend; ++i )
1333 const ConstIterator
end( ( IsUpper<MT5>::value )
1334 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j+2UL) : A.upperBound(i,j+2UL) )
1336 ConstIterator element( ( IsLower<MT5>::value )
1337 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
1340 const size_t nonzeros(
end - element );
1341 const size_t kpos( nonzeros &
size_t(-4) );
1344 for(
size_t k=0UL; k<kpos; k+=4UL )
1346 const size_t i1( element->index() );
1347 const ET1 v1( element->value() );
1349 const size_t i2( element->index() );
1350 const ET1 v2( element->value() );
1352 const size_t i3( element->index() );
1353 const ET1 v3( element->value() );
1355 const size_t i4( element->index() );
1356 const ET1 v4( element->value() );
1361 C(i,j ) -= v1 * B(i1,j ) + v2 * B(i2,j ) + v3 * B(i3,j ) + v4 * B(i4,j );
1362 C(i,j+1UL) -= v1 * B(i1,j+1UL) + v2 * B(i2,j+1UL) + v3 * B(i3,j+1UL) + v4 * B(i4,j+1UL);
1365 for( ; element!=
end; ++element )
1367 const size_t i1( element->index() );
1368 const ET1 v1( element->value() );
1370 C(i,j ) -= v1 * B(i1,j );
1371 C(i,j+1UL) -= v1 * B(i1,j+1UL);
1376 for( ; j<B.columns(); ++j ) {
1377 for(
size_t i=ii; i<iend; ++i )
1379 const ConstIterator
end( ( IsUpper<MT5>::value )
1380 ?( IsStrictlyUpper<MT5>::value ? A.lowerBound(i,j) : A.upperBound(i,j) )
1382 ConstIterator element( ( IsLower<MT5>::value )
1383 ?( IsStrictlyLower<MT5>::value ? A.upperBound(i,j) : A.lowerBound(i,j) )
1386 const size_t nonzeros(
end - element );
1387 const size_t kpos( nonzeros &
size_t(-4) );
1390 for(
size_t k=0UL; k<kpos; k+=4UL )
1392 const size_t i1( element->index() );
1393 const ET1 v1( element->value() );
1395 const size_t i2( element->index() );
1396 const ET1 v2( element->value() );
1398 const size_t i3( element->index() );
1399 const ET1 v3( element->value() );
1401 const size_t i4( element->index() );
1402 const ET1 v4( element->value() );
1407 C(i,j) -= v1 * B(i1,j) + v2 * B(i2,j) + v3 * B(i3,j) + v4 * B(i4,j);
1410 for( ; element!=
end; ++element )
1412 const size_t i1( element->index() );
1413 const ET1 v1( element->value() );
1415 C(i,j) -= v1 * B(i1,j);
1439 template<
typename MT
1441 friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
1449 subAssign( ~lhs, rhs.lhs_ *
trans( rhs.rhs_ ) );
1481 template<
typename MT
1483 friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> >
1521 template<
typename MT
1523 friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> >
1528 typedef IfTrue_< SO, OppositeType, ResultType > TmpType;
1540 const TmpType tmp( rhs );
1561 template<
typename MT
1563 friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
1592 template<
typename MT
1594 friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> >
1632 template<
typename MT
1634 friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
1667 template<
typename MT
1669 friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> >
1707 template<
typename MT
1709 friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
1786 template<
typename T1
1788 inline const SMatTDMatMultExpr<T1,T2>
1812 template<
typename MT1,
typename MT2 >
1829 template<
typename MT1,
typename MT2 >
1846 template<
typename MT1,
typename MT2 >
1864 template<
typename MT1,
typename MT2 >
1866 :
public BoolConstant< And< IsLower<MT1>, IsLower<MT2> >::value >
1882 template<
typename MT1,
typename MT2 >
1884 :
public BoolConstant< And< IsUniLower<MT1>, IsUniLower<MT2> >::value >
1900 template<
typename MT1,
typename MT2 >
1902 :
public BoolConstant< Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
1903 , And< IsStrictlyLower<MT2>, IsLower<MT1> > >::value >
1919 template<
typename MT1,
typename MT2 >
1921 :
public BoolConstant< And< IsUpper<MT1>, IsUpper<MT2> >::value >
1937 template<
typename MT1,
typename MT2 >
1939 :
public BoolConstant< And< IsUniUpper<MT1>, IsUniUpper<MT2> >::value >
1955 template<
typename MT1,
typename MT2 >
1957 :
public BoolConstant< Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
1958 , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > >::value >
1974 template<
typename MT1,
typename MT2,
typename VT >
1979 using Type = If_< And< IsSparseMatrix<MT1>, IsRowMajorMatrix<MT1>
1980 , IsDenseMatrix<MT2>, IsColumnMajorMatrix<MT2>
1981 , IsDenseVector<VT>, IsColumnVector<VT> >
1982 , SMatDVecMultExprTrait_< MT1, TDMatDVecMultExprTrait_<MT2,VT> >
1992 template<
typename MT1,
typename MT2,
typename VT >
1997 using Type = If_< And< IsSparseMatrix<MT1>, IsRowMajorMatrix<MT1>
1998 , IsDenseMatrix<MT2>, IsColumnMajorMatrix<MT2>
1999 , IsSparseVector<VT>, IsColumnVector<VT> >
2000 , SMatDVecMultExprTrait_< MT1, TDMatSVecMultExprTrait_<MT2,VT> >
2010 template<
typename VT,
typename MT1,
typename MT2 >
2015 using Type = If_< And< IsDenseVector<VT>, IsRowVector<VT>
2016 , IsSparseMatrix<MT1>, IsRowMajorMatrix<MT1>
2017 , IsDenseMatrix<MT2>, IsColumnMajorMatrix<MT2> >
2018 , TDVecTDMatMultExprTrait_< TDVecSMatMultExprTrait_<VT,MT1>, MT2 >
2028 template<
typename VT,
typename MT1,
typename MT2 >
2033 using Type = If_< And< IsSparseVector<VT>, IsRowVector<VT>
2034 , IsSparseMatrix<MT1>, IsRowMajorMatrix<MT1>
2035 , IsDenseMatrix<MT2>, IsColumnMajorMatrix<MT2> >
2036 , TSVecTDMatMultExprTrait_< TSVecSMatMultExprTrait_<VT,MT1>, MT2 >
2046 template<
typename MT1,
typename MT2,
bool AF >
2051 using Type = MultExprTrait_< SubmatrixExprTrait_<const MT1,AF>
2052 , SubmatrixExprTrait_<const MT2,AF> >;
2061 template<
typename MT1,
typename MT2 >
2066 using Type = MultExprTrait_< RowExprTrait_<const MT1>, MT2 >;
2075 template<
typename MT1,
typename MT2 >
2080 using Type = MultExprTrait_< MT1, ColumnExprTrait_<const MT2> >;
#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
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatTDMatMultExpr.h:202
Header file for auxiliary alias declarations.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:72
Header file for mathematical functions.
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
Header file for the SMatDVecMultExprTrait class template.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatTDMatMultExpr.h:200
Header file for the Rows type trait.
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:7800
Compile time check for triangular matrix types.This type trait tests whether or not the given templat...
Definition: IsTriangular.h:87
Header file for basic type definitions.
IfTrue_< evaluateRight, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: SMatTDMatMultExpr.h:215
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatTDMatMultExpr.h:296
EnableIf_< IsDenseMatrix< MT1 > > 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 IsSparseMatrix type trait.
Header file for the serial shim.
If_< IsExpression< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: SMatTDMatMultExpr.h:209
#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 ColumnExprTrait class template.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
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:533
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatTDMatMultExpr.h:312
Header file for the IsRowVector type trait.
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
CompositeType_< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: SMatTDMatMultExpr.h:139
Header file for the And class template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTDMatMultExpr.h:248
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:723
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
ElementType_< RT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: SMatTDMatMultExpr.h:136
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:88
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatTDMatMultExpr.h:332
System settings for performance optimizations.
Header file for the TSVecSMatMultExprTrait class template.
IfTrue_< evaluateLeft, const RT1, CT1 > LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: SMatTDMatMultExpr.h:212
Header file for the IsUniLower type trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
EnableIf_< IsDenseMatrix< MT1 > > 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
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
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:109
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
If_< IsExpression< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTDMatMultExpr.h:206
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatTDMatMultExpr.h:393
SMatTDMatMultExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the SMatTDMatMultExpr class.
Definition: SMatTDMatMultExpr.h:233
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:72
SubvectorExprTrait_< VT, unaligned > subvector(Vector< VT, TF > &vector, size_t index, size_t size)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:152
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatTDMatMultExpr.h:386
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SMatTDMatMultExpr.h:201
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatTDMatMultExpr.h:354
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
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
Header file for the TSVecTDMatMultExprTrait class template.
ResultType_< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatTDMatMultExpr.h:134
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
EnableIf_< IsDenseMatrix< MT1 > > 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
Header file for the Or class template.
Header file for the TDMatSVecMultExprTrait class template.
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose dense matrix operand.
Definition: SMatTDMatMultExpr.h:342
#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.
Header file for the Columns type trait.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for the DMatDVecMultExprTrait class template.
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:90
Expression object for sparse matrix-transpose dense matrix multiplications.The SMatTDMatMultExpr clas...
Definition: Forward.h:102
#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:60
Header file for the IsTriangular type trait.
Constraints on the storage order of matrix types.
ElementType_< RT2 > ET2
Element type of the right-hand side sparse matrix expression.
Definition: SMatTDMatMultExpr.h:137
Header file for the exception macros of the math module.
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
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:254
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Header file for the IsDenseMatrix type trait.
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:109
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
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: RowMajorMatrix.h:61
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SMatTDMatMultExpr.h:198
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:83
Utility type for generic codes.
RightOperand rhs_
Right-hand side dense matrix of the multiplication expression.
Definition: SMatTDMatMultExpr.h:394
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
Header file for the reset shim.
Constraints on the storage order of matrix types.
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
Header file for the RemoveReference type trait.
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:243
#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
Header file for the IsDenseVector type trait.
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatTDMatMultExpr.h:322
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
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:950
Header file for the IsComputation type trait class.
Header file for the TDVecDMatMultExprTrait class template.
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: SMatTDMatMultExpr.h:376
CompositeType_< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTDMatMultExpr.h:138
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
Header file for the IntegralConstant class template.
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatTDMatMultExpr.h:203
Header file for the TSVecDMatMultExprTrait class template.
SMatTDMatMultExpr< MT1, MT2 > This
Type of this SMatTDMatMultExpr instance.
Definition: SMatTDMatMultExpr.h:197
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
Header file for the IsUpper type trait.
Header file for the DMatSVecMultExprTrait class template.
Header file for the IsColumnVector type trait.
Constraint on the data type.
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTDMatMultExpr.h:199
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
ResultType_< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: SMatTDMatMultExpr.h:135
#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:61
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatTDMatMultExpr.h:366
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.