DMatSMatMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATSMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATSMATMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
52 #include <blaze/math/Exception.h>
65 #include <blaze/math/shims/Reset.h>
83 #include <blaze/math/views/Check.h>
88 #include <blaze/util/Assert.h>
89 #include <blaze/util/DisableIf.h>
90 #include <blaze/util/EnableIf.h>
92 #include <blaze/util/mpl/And.h>
93 #include <blaze/util/mpl/Bool.h>
94 #include <blaze/util/mpl/If.h>
95 #include <blaze/util/mpl/Or.h>
96 #include <blaze/util/Types.h>
98 
99 
100 namespace blaze {
101 
102 //=================================================================================================
103 //
104 // CLASS DMATSMATMULTEXPR
105 //
106 //=================================================================================================
107 
108 //*************************************************************************************************
115 template< typename MT1 // Type of the left-hand side dense matrix
116  , typename MT2 // Type of the right-hand side sparse matrix
117  , bool SF // Symmetry flag
118  , bool HF // Hermitian flag
119  , bool LF // Lower flag
120  , bool UF > // Upper flag
122  : public MatMatMultExpr< DenseMatrix< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>, false > >
123  , private Computation
124 {
125  private:
126  //**Type definitions****************************************************************************
133  //**********************************************************************************************
134 
135  //**********************************************************************************************
137  enum : bool { evaluateLeft = IsComputation<MT1>::value || RequiresEvaluation<MT1>::value };
138  //**********************************************************************************************
139 
140  //**********************************************************************************************
142  enum : bool { evaluateRight = IsComputation<MT2>::value || RequiresEvaluation<MT2>::value };
143  //**********************************************************************************************
144 
145  //**********************************************************************************************
147  enum : bool {
148  SYM = ( SF && !( HF || LF || UF ) ),
149  HERM = ( HF && !( LF || UF ) ),
150  LOW = ( LF || ( ( SF || HF ) && UF ) ),
151  UPP = ( UF || ( ( SF || HF ) && LF ) )
152  };
153  //**********************************************************************************************
154 
155  //**********************************************************************************************
157 
162  template< typename T1, typename T2, typename T3 >
163  struct CanExploitSymmetry {
164  enum : bool { value = ( IsSymmetric<T2>::value || IsSymmetric<T3>::value ) };
165  };
167  //**********************************************************************************************
168 
169  //**********************************************************************************************
171 
175  template< typename T1, typename T2, typename T3 >
176  struct IsEvaluationRequired {
177  enum : bool { value = ( evaluateLeft || evaluateRight ) &&
178  !CanExploitSymmetry<T1,T2,T3>::value };
179  };
181  //**********************************************************************************************
182 
183  //**********************************************************************************************
185 
188  template< typename T1, typename T2, typename T3 >
189  struct UseOptimizedKernel {
190  enum : bool { value = useOptimizedKernels &&
192  !IsResizable< ElementType_<T1> >::value };
193  };
195  //**********************************************************************************************
196 
197  //**********************************************************************************************
199 
202  template< typename T1, typename T2, typename T3 >
203  struct UseDefaultKernel {
204  enum : bool { value = !UseOptimizedKernel<T1,T2,T3>::value };
205  };
207  //**********************************************************************************************
208 
209  //**********************************************************************************************
211 
214  using ForwardFunctor = IfTrue_< HERM
215  , DeclHerm
216  , IfTrue_< SYM
217  , DeclSym
218  , IfTrue_< LOW
219  , IfTrue_< UPP
220  , DeclDiag
221  , DeclLow >
222  , IfTrue_< UPP
223  , DeclUpp
224  , Noop > > > >;
226  //**********************************************************************************************
227 
228  public:
229  //**Type definitions****************************************************************************
232 
237  using ReturnType = const ElementType;
238  using CompositeType = const ResultType;
239 
241  using LeftOperand = If_< IsExpression<MT1>, const MT1, const MT1& >;
242 
244  using RightOperand = If_< IsExpression<MT2>, const MT2, const MT2& >;
245 
248 
251  //**********************************************************************************************
252 
253  //**Compilation flags***************************************************************************
255  enum : bool { simdEnabled = false };
256 
258  enum : bool { smpAssignable = !evaluateLeft && MT1::smpAssignable &&
259  !evaluateRight && MT2::smpAssignable };
260  //**********************************************************************************************
261 
262  //**Constructor*********************************************************************************
268  explicit inline DMatSMatMultExpr( const MT1& lhs, const MT2& rhs ) noexcept
269  : lhs_( lhs ) // Left-hand side dense matrix of the multiplication expression
270  , rhs_( rhs ) // Right-hand side sparse matrix of the multiplication expression
271  {
272  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.rows(), "Invalid matrix sizes" );
273  }
274  //**********************************************************************************************
275 
276  //**Access operator*****************************************************************************
283  inline ReturnType operator()( size_t i, size_t j ) const {
284  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
285  BLAZE_INTERNAL_ASSERT( j < rhs_.columns(), "Invalid column access index" );
286 
287  if( IsDiagonal<MT1>::value ) {
288  return lhs_(i,i) * rhs_(i,j);
289  }
290  else if( IsDiagonal<MT2>::value ) {
291  return lhs_(i,j) * rhs_(j,j);
292  }
294  const size_t begin( ( IsUpper<MT1>::value )
295  ?( ( IsLower<MT2>::value )
296  ?( max( ( IsStrictlyUpper<MT1>::value ? i+1UL : i )
297  , ( IsStrictlyLower<MT2>::value ? j+1UL : j ) ) )
298  :( IsStrictlyUpper<MT1>::value ? i+1UL : i ) )
299  :( ( IsLower<MT2>::value )
300  ?( IsStrictlyLower<MT2>::value ? j+1UL : j )
301  :( 0UL ) ) );
302  const size_t end( ( IsLower<MT1>::value )
303  ?( ( IsUpper<MT2>::value )
304  ?( min( ( IsStrictlyLower<MT1>::value ? i : i+1UL )
305  , ( IsStrictlyUpper<MT2>::value ? j : j+1UL ) ) )
306  :( IsStrictlyLower<MT1>::value ? i : i+1UL ) )
307  :( ( IsUpper<MT2>::value )
308  ?( IsStrictlyUpper<MT2>::value ? j : j+1UL )
309  :( lhs_.columns() ) ) );
310 
311  if( begin >= end ) return ElementType();
312 
313  const size_t n( end - begin );
314 
315  return subvector( row( lhs_, i, unchecked ), begin, n, unchecked ) *
316  subvector( column( rhs_, j, unchecked ), begin, n, unchecked );
317  }
318  else {
319  return row( lhs_, i, unchecked ) * column( rhs_, j, unchecked );
320  }
321  }
322  //**********************************************************************************************
323 
324  //**At function*********************************************************************************
332  inline ReturnType at( size_t i, size_t j ) const {
333  if( i >= lhs_.rows() ) {
334  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
335  }
336  if( j >= rhs_.columns() ) {
337  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
338  }
339  return (*this)(i,j);
340  }
341  //**********************************************************************************************
342 
343  //**Rows function*******************************************************************************
348  inline size_t rows() const noexcept {
349  return lhs_.rows();
350  }
351  //**********************************************************************************************
352 
353  //**Columns function****************************************************************************
358  inline size_t columns() const noexcept {
359  return rhs_.columns();
360  }
361  //**********************************************************************************************
362 
363  //**Left operand access*************************************************************************
368  inline LeftOperand leftOperand() const noexcept {
369  return lhs_;
370  }
371  //**********************************************************************************************
372 
373  //**Right operand access************************************************************************
378  inline RightOperand rightOperand() const noexcept {
379  return rhs_;
380  }
381  //**********************************************************************************************
382 
383  //**********************************************************************************************
389  template< typename T >
390  inline bool canAlias( const T* alias ) const noexcept {
391  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
392  }
393  //**********************************************************************************************
394 
395  //**********************************************************************************************
401  template< typename T >
402  inline bool isAliased( const T* alias ) const noexcept {
403  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
404  }
405  //**********************************************************************************************
406 
407  //**********************************************************************************************
412  inline bool isAligned() const noexcept {
413  return lhs_.isAligned();
414  }
415  //**********************************************************************************************
416 
417  //**********************************************************************************************
422  inline bool canSMPAssign() const noexcept {
423  return ( rows() * columns() >= SMP_DMATSMATMULT_THRESHOLD ) && !IsDiagonal<MT1>::value;
424  }
425  //**********************************************************************************************
426 
427  private:
428  //**Member variables****************************************************************************
431  //**********************************************************************************************
432 
433  //**Assignment to dense matrices****************************************************************
446  template< typename MT // Type of the target dense matrix
447  , bool SO > // Storage order of the target dense matrix
449  assign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
450  {
452 
453  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
454  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
455 
456  LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
457  RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
458 
459  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
460  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
461  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
462  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
463  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
464  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
465 
466  DMatSMatMultExpr::selectAssignKernel( ~lhs, A, B );
467  }
469  //**********************************************************************************************
470 
471  //**Assignment to dense matrices (kernel selection)*********************************************
482  template< typename MT3 // Type of the left-hand side target matrix
483  , typename MT4 // Type of the left-hand side matrix operand
484  , typename MT5 > // Type of the right-hand side matrix operand
485  static inline void selectAssignKernel( MT3& C, const MT4& A, const MT5& B )
486  {
487  if( C.rows() * C.columns() < DMATSMATMULT_THRESHOLD )
488  selectSmallAssignKernel( C, A, B );
489  else
490  selectLargeAssignKernel( C, A, B );
491  }
493  //**********************************************************************************************
494 
495  //**Default assignment to dense matrices********************************************************
509  template< typename MT3 // Type of the left-hand side target matrix
510  , typename MT4 // Type of the left-hand side matrix operand
511  , typename MT5 > // Type of the right-hand side matrix operand
512  static inline void selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B )
513  {
515 
516  reset( C );
517 
518  for( size_t k=0UL; k<B.rows(); ++k )
519  {
521  {
522  ConstIterator element( B.begin(k) );
523  const ConstIterator end( B.end(k) );
524 
525  for( ; element!=end; ++element ) {
526  C(k,element->index()) = A(k,k) * element->value();
527  }
528  }
529  else
530  {
531  const size_t iibegin( ( IsLower<MT4>::value )
532  ?( IsStrictlyLower<MT4>::value ? k+1UL : k )
533  :( 0UL ) );
534  const size_t iiend( ( IsUpper<MT4>::value )
535  ?( IsStrictlyUpper<MT4>::value ? k : k+1UL )
536  :( A.rows() ) );
537  BLAZE_INTERNAL_ASSERT( iibegin <= iiend, "Invalid loop indices detected" );
538 
539  for( size_t ii=iibegin; ii<iiend; ii+=8UL )
540  {
541  ConstIterator element( B.begin(k) );
542  const ConstIterator end( B.end(k) );
543  const size_t itmp( ( ii+8UL > iiend )?( iiend ):( ii+8UL ) );
544 
545  for( ; element!=end; ++element )
546  {
547  const size_t j1( element->index() );
548  const size_t ibegin( SYM || HERM || LOW ? max(j1,ii) : ii );
549  const size_t iend( UPP ? min(j1+1UL,itmp) : itmp );
550 
551  for( size_t i=ibegin; i<iend; ++i ) {
552  if( isDefault( C(i,element->index()) ) )
553  C(i,j1) = A(i,k) * element->value();
554  else
555  C(i,j1) += A(i,k) * element->value();
556  }
557  }
558  }
559  }
560  }
561 
562  if( SYM || HERM ) {
563  for( size_t i=0UL; i<A.rows(); ++i ) {
564  for( size_t j=i+1UL; j<B.columns(); ++j ) {
565  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
566  }
567  }
568  }
569  }
571  //**********************************************************************************************
572 
573  //**Default assignment to dense matrices (small matrices)***************************************
586  template< typename MT3 // Type of the left-hand side target matrix
587  , typename MT4 // Type of the left-hand side matrix operand
588  , typename MT5 > // Type of the right-hand side matrix operand
590  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
591  {
592  selectDefaultAssignKernel( C, A, B );
593  }
595  //**********************************************************************************************
596 
597  //**Optimized assignment to dense matrices (small matrices)*************************************
612  template< typename MT3 // Type of the left-hand side target matrix
613  , typename MT4 // Type of the left-hand side matrix operand
614  , typename MT5 > // Type of the right-hand side matrix operand
616  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
617  {
619 
620  reset( C );
621 
622  for( size_t j=0UL; j<B.rows(); ++j )
623  {
624  const size_t iibegin( ( IsLower<MT4>::value )
625  ?( IsStrictlyLower<MT4>::value ? j+1UL : j )
626  :( 0UL ) );
627  const size_t iiend( ( IsUpper<MT4>::value )
628  ?( IsStrictlyUpper<MT4>::value ? j : j+1UL )
629  :( A.rows() ) );
630  BLAZE_INTERNAL_ASSERT( iibegin <= iiend, "Invalid loop indices detected" );
631 
632  for( size_t ii=iibegin; ii<iiend; ii+=8UL )
633  {
634  ConstIterator element( B.begin(j) );
635  const ConstIterator end( B.end(j) );
636  const size_t itmp( ( ii+8UL > iiend )?( iiend ):( ii+8UL ) );
637 
638  for( ; element!=end; ++element )
639  {
640  const size_t j1( element->index() );
641  const size_t ibegin( SYM || HERM || LOW ? max(j1,ii) : ii );
642  const size_t iend( UPP ? min(j1+1UL,itmp) : itmp );
643 
644  for( size_t i=ibegin; i<iend; ++i ) {
645  C(i,j1) += A(i,j) * element->value();
646  }
647  }
648  }
649  }
650 
651  if( SYM || HERM ) {
652  for( size_t i=0UL; i<A.rows(); ++i ) {
653  for( size_t j=i+1UL; j<B.columns(); ++j ) {
654  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
655  }
656  }
657  }
658  }
660  //**********************************************************************************************
661 
662  //**Default assignment to dense matrices (large matrices)***************************************
675  template< typename MT3 // Type of the left-hand side target matrix
676  , typename MT4 // Type of the left-hand side matrix operand
677  , typename MT5 > // Type of the right-hand side matrix operand
679  selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B )
680  {
681  selectDefaultAssignKernel( C, A, B );
682  }
684  //**********************************************************************************************
685 
686  //**Optimized assignment to dense matrices (large matrices)*************************************
701  template< typename MT3 // Type of the left-hand side target matrix
702  , typename MT4 // Type of the left-hand side matrix operand
703  , typename MT5 > // Type of the right-hand side matrix operand
705  selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B )
706  {
708 
709  const ForwardFunctor fwd;
710 
711  const OppositeType_<MT5> tmp( serial( B ) );
712  assign( C, fwd( A * tmp ) );
713  }
715  //**********************************************************************************************
716 
717  //**Assignment to sparse matrices***************************************************************
730  template< typename MT // Type of the target sparse matrix
731  , bool SO > // Storage order of the target sparse matrix
733  assign( SparseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
734  {
736 
738 
745 
746  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
747  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
748 
749  const ForwardFunctor fwd;
750 
751  const TmpType tmp( serial( rhs ) );
752  assign( ~lhs, fwd( tmp ) );
753  }
755  //**********************************************************************************************
756 
757  //**Restructuring assignment********************************************************************
772  template< typename MT // Type of the target matrix
773  , bool SO > // Storage order of the target matrix
775  assign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
776  {
778 
780 
781  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
782  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
783 
784  const ForwardFunctor fwd;
785 
787  assign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
788  else if( IsSymmetric<MT1>::value )
789  assign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
790  else
791  assign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
792  }
794  //**********************************************************************************************
795 
796  //**Addition assignment to dense matrices*******************************************************
809  template< typename MT // Type of the target dense matrix
810  , bool SO > // Storage order of the target dense matrix
812  addAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
813  {
815 
816  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
817  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
818 
819  LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
820  RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
821 
822  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
823  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
824  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
825  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
826  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
827  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
828 
829  DMatSMatMultExpr::selectAddAssignKernel( ~lhs, A, B );
830  }
832  //**********************************************************************************************
833 
834  //**Addition assignment to dense matrices (kernel selection)************************************
845  template< typename MT3 // Type of the left-hand side target matrix
846  , typename MT4 // Type of the left-hand side matrix operand
847  , typename MT5 > // Type of the right-hand side matrix operand
848  static inline void selectAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
849  {
850  if( C.rows() * C.columns() < DMATSMATMULT_THRESHOLD )
851  selectSmallAddAssignKernel( C, A, B );
852  else
853  selectLargeAddAssignKernel( C, A, B );
854  }
856  //**********************************************************************************************
857 
858  //**Optimized addition assignment to dense matrices (small matrices)****************************
872  template< typename MT3 // Type of the left-hand side target matrix
873  , typename MT4 // Type of the left-hand side matrix operand
874  , typename MT5 > // Type of the right-hand side matrix operand
875  static inline void selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
876  {
878 
879  for( size_t j=0UL; j<B.rows(); ++j )
880  {
882  {
883  ConstIterator element( B.begin(j) );
884  const ConstIterator end( B.end(j) );
885 
886  for( ; element!=end; ++element ) {
887  C(j,element->index()) += A(j,j) * element->value();
888  }
889  }
890  else
891  {
892  const size_t iibegin( ( IsLower<MT4>::value )
893  ?( IsStrictlyLower<MT4>::value ? j+1UL : j )
894  :( 0UL ) );
895  const size_t iiend( ( IsUpper<MT4>::value )
896  ?( IsStrictlyUpper<MT4>::value ? j : j+1UL )
897  :( A.rows() ) );
898  BLAZE_INTERNAL_ASSERT( iibegin <= iiend, "Invalid loop indices detected" );
899 
900  for( size_t ii=iibegin; ii<iiend; ii+=8UL )
901  {
902  ConstIterator element( B.begin(j) );
903  const ConstIterator end( B.end(j) );
904  const size_t itmp( ( ii+8UL > iiend )?( iiend ):( ii+8UL ) );
905 
906  for( ; element!=end; ++element )
907  {
908  const size_t j1( element->index() );
909  const size_t ibegin( LOW ? max(j1,ii) : ii );
910  const size_t iend( UPP ? min(j1+1UL,itmp) : itmp );
911 
912  for( size_t i=ibegin; i<iend; ++i ) {
913  C(i,j1) += A(i,j) * element->value();
914  }
915  }
916  }
917  }
918  }
919  }
921  //**********************************************************************************************
922 
923  //**Optimized addition assignment to dense matrices (large matrices)****************************
937  template< typename MT3 // Type of the left-hand side target matrix
938  , typename MT4 // Type of the left-hand side matrix operand
939  , typename MT5 > // Type of the right-hand side matrix operand
940  static inline void selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
941  {
943 
944  const ForwardFunctor fwd;
945 
946  const OppositeType_<MT5> tmp( serial( B ) );
947  addAssign( C, fwd( A * tmp ) );
948  }
950  //**********************************************************************************************
951 
952  //**Restructuring addition assignment***********************************************************
967  template< typename MT // Type of the target matrix
968  , bool SO > // Storage order of the target matrix
970  addAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
971  {
973 
975 
976  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
977  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
978 
979  const ForwardFunctor fwd;
980 
982  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
983  else if( IsSymmetric<MT1>::value )
984  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
985  else
986  addAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
987  }
989  //**********************************************************************************************
990 
991  //**Addition assignment to sparse matrices******************************************************
992  // No special implementation for the addition assignment to sparse matrices.
993  //**********************************************************************************************
994 
995  //**Subtraction assignment to dense matrices****************************************************
1008  template< typename MT // Type of the target dense matrix
1009  , bool SO > // Storage order of the target dense matrix
1011  subAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1012  {
1014 
1015  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1016  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1017 
1018  LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
1019  RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
1020 
1021  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1022  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1023  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1024  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1025  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1026  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1027 
1028  DMatSMatMultExpr::selectSubAssignKernel( ~lhs, A, B );
1029  }
1031  //**********************************************************************************************
1032 
1033  //**Subtraction assignment to dense matrices (kernel selection)*********************************
1044  template< typename MT3 // Type of the left-hand side target matrix
1045  , typename MT4 // Type of the left-hand side matrix operand
1046  , typename MT5 > // Type of the right-hand side matrix operand
1047  static inline void selectSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1048  {
1049  if( C.rows() * C.columns() < DMATSMATMULT_THRESHOLD )
1050  selectSmallSubAssignKernel( C, A, B );
1051  else
1052  selectLargeSubAssignKernel( C, A, B );
1053  }
1055  //**********************************************************************************************
1056 
1057  //**Optimized subtraction assignment to dense matrices (small matrices)*************************
1071  template< typename MT3 // Type of the left-hand side target matrix
1072  , typename MT4 // Type of the left-hand side matrix operand
1073  , typename MT5 > // Type of the right-hand side matrix operand
1074  static inline void selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1075  {
1077 
1078  for( size_t j=0UL; j<B.rows(); ++j )
1079  {
1081  {
1082  ConstIterator element( B.begin(j) );
1083  const ConstIterator end( B.end(j) );
1084 
1085  for( ; element!=end; ++element ) {
1086  C(j,element->index()) -= A(j,j) * element->value();
1087  }
1088  }
1089  else
1090  {
1091  const size_t iibegin( ( IsLower<MT4>::value )
1092  ?( IsStrictlyLower<MT4>::value ? j+1UL : j )
1093  :( 0UL ) );
1094  const size_t iiend( ( IsUpper<MT4>::value )
1095  ?( IsStrictlyUpper<MT4>::value ? j : j+1UL )
1096  :( A.rows() ) );
1097  BLAZE_INTERNAL_ASSERT( iibegin <= iiend, "Invalid loop indices detected" );
1098 
1099  for( size_t ii=iibegin; ii<iiend; ii+=8UL )
1100  {
1101  ConstIterator element( B.begin(j) );
1102  const ConstIterator end( B.end(j) );
1103  const size_t itmp( ( ii+8UL > iiend )?( iiend ):( ii+8UL ) );
1104 
1105  for( ; element!=end; ++element )
1106  {
1107  const size_t j1( element->index() );
1108  const size_t ibegin( LOW ? max(j1,ii) : ii );
1109  const size_t iend( UPP ? min(j1+1UL,itmp) : itmp );
1110 
1111  for( size_t i=ibegin; i<iend; ++i ) {
1112  C(i,j1) -= A(i,j) * element->value();
1113  }
1114  }
1115  }
1116  }
1117  }
1118  }
1120  //**********************************************************************************************
1121 
1122  //**Optimized subtraction assignment to dense matrices (large matrices)*************************
1136  template< typename MT3 // Type of the left-hand side target matrix
1137  , typename MT4 // Type of the left-hand side matrix operand
1138  , typename MT5 > // Type of the right-hand side matrix operand
1139  static inline void selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1140  {
1142 
1143  const ForwardFunctor fwd;
1144 
1145  const OppositeType_<MT5> tmp( serial( B ) );
1146  subAssign( C, fwd( A * tmp ) );
1147  }
1149  //**********************************************************************************************
1150 
1151  //**Restructuring subtraction assignment********************************************************
1166  template< typename MT // Type of the target matrix
1167  , bool SO > // Storage order of the target matrix
1169  subAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1170  {
1172 
1174 
1175  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1176  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1177 
1178  const ForwardFunctor fwd;
1179 
1181  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1182  else if( IsSymmetric<MT1>::value )
1183  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1184  else
1185  subAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1186  }
1188  //**********************************************************************************************
1189 
1190  //**Subtraction assignment to sparse matrices***************************************************
1191  // No special implementation for the subtraction assignment to sparse matrices.
1192  //**********************************************************************************************
1193 
1194  //**Schur product assignment to dense matrices**************************************************
1207  template< typename MT // Type of the target dense matrix
1208  , bool SO > // Storage order of the target dense matrix
1209  friend inline void schurAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1210  {
1212 
1216 
1217  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1218  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1219 
1220  const ResultType tmp( serial( rhs ) );
1221  schurAssign( ~lhs, tmp );
1222  }
1224  //**********************************************************************************************
1225 
1226  //**Schur product assignment to sparse matrices*************************************************
1227  // No special implementation for the Schur product assignment to sparse matrices.
1228  //**********************************************************************************************
1229 
1230  //**Multiplication assignment to dense matrices*************************************************
1231  // No special implementation for the multiplication assignment to dense matrices.
1232  //**********************************************************************************************
1233 
1234  //**Multiplication assignment to sparse matrices************************************************
1235  // No special implementation for the multiplication assignment to sparse matrices.
1236  //**********************************************************************************************
1237 
1238  //**SMP assignment to dense matrices************************************************************
1253  template< typename MT // Type of the target dense matrix
1254  , bool SO > // Storage order of the target dense matrix
1256  smpAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1257  {
1259 
1260  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1261  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1262 
1263  LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand
1264  RT B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
1265 
1266  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1267  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1268  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1269  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1270  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1271  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1272 
1273  smpAssign( ~lhs, A * B );
1274  }
1276  //**********************************************************************************************
1277 
1278  //**SMP assignment to sparse matrices***********************************************************
1293  template< typename MT // Type of the target sparse matrix
1294  , bool SO > // Storage order of the target sparse matrix
1296  smpAssign( SparseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1297  {
1299 
1301 
1308 
1309  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1310  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1311 
1312  const ForwardFunctor fwd;
1313 
1314  const TmpType tmp( rhs );
1315  smpAssign( ~lhs, fwd( tmp ) );
1316  }
1318  //**********************************************************************************************
1319 
1320  //**Restructuring SMP assignment****************************************************************
1335  template< typename MT // Type of the target matrix
1336  , bool SO > // Storage order of the target matrix
1338  smpAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1339  {
1341 
1343 
1344  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1345  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1346 
1347  const ForwardFunctor fwd;
1348 
1350  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1351  else if( IsSymmetric<MT1>::value )
1352  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1353  else
1354  smpAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1355  }
1357  //**********************************************************************************************
1358 
1359  //**SMP addition assignment to dense matrices***************************************************
1374  template< typename MT // Type of the target dense matrix
1375  , bool SO > // Storage order of the target sparse matrix
1378  {
1380 
1381  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1382  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1383 
1384  LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand
1385  RT B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
1386 
1387  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1388  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1389  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1390  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1391  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1392  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1393 
1394  smpAddAssign( ~lhs, A * B );
1395  }
1397  //**********************************************************************************************
1398 
1399  //**Restructuring SMP addition assignment*******************************************************
1414  template< typename MT // Type of the target matrix
1415  , bool SO > // Storage order of the target matrix
1417  smpAddAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1418  {
1420 
1422 
1423  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1424  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1425 
1426  const ForwardFunctor fwd;
1427 
1429  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1430  else if( IsSymmetric<MT1>::value )
1431  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1432  else
1433  smpAddAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1434  }
1436  //**********************************************************************************************
1437 
1438  //**SMP addition assignment to sparse matrices**************************************************
1439  // No special implementation for the SMP addition assignment to sparse matrices.
1440  //**********************************************************************************************
1441 
1442  //**SMP subtraction assignment to dense matrices************************************************
1458  template< typename MT // Type of the target dense matrix
1459  , bool SO > // Storage order of the target sparse matrix
1462  {
1464 
1465  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1466  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1467 
1468  LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand
1469  RT B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
1470 
1471  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1472  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1473  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1474  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1475  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1476  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1477 
1478  smpSubAssign( ~lhs, A * B );
1479  }
1481  //**********************************************************************************************
1482 
1483  //**Restructuring SMP subtraction assignment****************************************************
1498  template< typename MT // Type of the target matrix
1499  , bool SO > // Storage order of the target matrix
1501  smpSubAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1502  {
1504 
1506 
1507  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1508  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1509 
1510  const ForwardFunctor fwd;
1511 
1513  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1514  else if( IsSymmetric<MT1>::value )
1515  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1516  else
1517  smpSubAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1518  }
1520  //**********************************************************************************************
1521 
1522  //**SMP subtraction assignment to sparse matrices***********************************************
1523  // No special implementation for the SMP subtraction assignment to sparse matrices.
1524  //**********************************************************************************************
1525 
1526  //**SMP Schur product assignment to dense matrices**********************************************
1539  template< typename MT // Type of the target dense matrix
1540  , bool SO > // Storage order of the target sparse matrix
1541  friend inline void smpSchurAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1542  {
1544 
1548 
1549  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1550  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1551 
1552  const ResultType tmp( rhs );
1553  smpSchurAssign( ~lhs, tmp );
1554  }
1556  //**********************************************************************************************
1557 
1558  //**SMP Schur product assignment to sparse matrices*********************************************
1559  // No special implementation for the SMP Schur product assignment to sparse matrices.
1560  //**********************************************************************************************
1561 
1562  //**SMP multiplication assignment to dense matrices*********************************************
1563  // No special implementation for the SMP multiplication assignment to dense matrices.
1564  //**********************************************************************************************
1565 
1566  //**SMP multiplication assignment to sparse matrices********************************************
1567  // No special implementation for the SMP multiplication assignment to sparse matrices.
1568  //**********************************************************************************************
1569 
1570  //**Compile time checks*************************************************************************
1578  //**********************************************************************************************
1579 };
1580 //*************************************************************************************************
1581 
1582 
1583 
1584 
1585 //=================================================================================================
1586 //
1587 // GLOBAL BINARY ARITHMETIC OPERATORS
1588 //
1589 //=================================================================================================
1590 
1591 //*************************************************************************************************
1620 template< typename MT1 // Type of the left-hand side dense matrix
1621  , typename MT2 > // Type of the right-hand side sparse matrix
1622 inline decltype(auto)
1623  operator*( const DenseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,false>& rhs )
1624 {
1626 
1627  if( (~lhs).columns() != (~rhs).rows() ) {
1628  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1629  }
1630 
1632  return ReturnType( ~lhs, ~rhs );
1633 }
1634 //*************************************************************************************************
1635 
1636 
1637 
1638 
1639 //=================================================================================================
1640 //
1641 // GLOBAL FUNCTIONS
1642 //
1643 //=================================================================================================
1644 
1645 //*************************************************************************************************
1669 template< typename MT1 // Type of the left-hand side dense matrix
1670  , typename MT2 // Type of the right-hand side sparse matrix
1671  , bool SF // Symmetry flag
1672  , bool HF // Hermitian flag
1673  , bool LF // Lower flag
1674  , bool UF > // Upper flag
1675 inline decltype(auto) declsym( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1676 {
1678 
1679  if( !isSquare( dm ) ) {
1680  BLAZE_THROW_INVALID_ARGUMENT( "Invalid symmetric matrix specification" );
1681  }
1682 
1684  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1685 }
1687 //*************************************************************************************************
1688 
1689 
1690 //*************************************************************************************************
1714 template< typename MT1 // Type of the left-hand side dense matrix
1715  , typename MT2 // Type of the right-hand side sparse matrix
1716  , bool SF // Symmetry flag
1717  , bool HF // Hermitian flag
1718  , bool LF // Lower flag
1719  , bool UF > // Upper flag
1720 inline decltype(auto) declherm( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1721 {
1723 
1724  if( !isSquare( dm ) ) {
1725  BLAZE_THROW_INVALID_ARGUMENT( "Invalid Hermitian matrix specification" );
1726  }
1727 
1729  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1730 }
1732 //*************************************************************************************************
1733 
1734 
1735 //*************************************************************************************************
1759 template< typename MT1 // Type of the left-hand side dense matrix
1760  , typename MT2 // Type of the right-hand side sparse matrix
1761  , bool SF // Symmetry flag
1762  , bool HF // Hermitian flag
1763  , bool LF // Lower flag
1764  , bool UF > // Upper flag
1765 inline decltype(auto) decllow( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1766 {
1768 
1769  if( !isSquare( dm ) ) {
1770  BLAZE_THROW_INVALID_ARGUMENT( "Invalid lower matrix specification" );
1771  }
1772 
1774  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1775 }
1777 //*************************************************************************************************
1778 
1779 
1780 //*************************************************************************************************
1804 template< typename MT1 // Type of the left-hand side dense matrix
1805  , typename MT2 // Type of the right-hand side sparse matrix
1806  , bool SF // Symmetry flag
1807  , bool HF // Hermitian flag
1808  , bool LF // Lower flag
1809  , bool UF > // Upper flag
1810 inline decltype(auto) declupp( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1811 {
1813 
1814  if( !isSquare( dm ) ) {
1815  BLAZE_THROW_INVALID_ARGUMENT( "Invalid upper matrix specification" );
1816  }
1817 
1819  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1820 }
1822 //*************************************************************************************************
1823 
1824 
1825 //*************************************************************************************************
1849 template< typename MT1 // Type of the left-hand side dense matrix
1850  , typename MT2 // Type of the right-hand side sparse matrix
1851  , bool SF // Symmetry flag
1852  , bool HF // Hermitian flag
1853  , bool LF // Lower flag
1854  , bool UF > // Upper flag
1855 inline decltype(auto) decldiag( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1856 {
1858 
1859  if( !isSquare( dm ) ) {
1860  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
1861  }
1862 
1864  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1865 }
1867 //*************************************************************************************************
1868 
1869 
1870 
1871 
1872 //=================================================================================================
1873 //
1874 // SIZE SPECIALIZATIONS
1875 //
1876 //=================================================================================================
1877 
1878 //*************************************************************************************************
1880 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1881 struct Size< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>, 0UL >
1882  : public Size<MT1,0UL>
1883 {};
1884 
1885 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1886 struct Size< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>, 1UL >
1887  : public Size<MT2,1UL>
1888 {};
1890 //*************************************************************************************************
1891 
1892 
1893 
1894 
1895 //=================================================================================================
1896 //
1897 // ISALIGNED SPECIALIZATIONS
1898 //
1899 //=================================================================================================
1900 
1901 //*************************************************************************************************
1903 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1904 struct IsAligned< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1905  : public IsAligned<MT1>
1906 {};
1908 //*************************************************************************************************
1909 
1910 
1911 
1912 
1913 //=================================================================================================
1914 //
1915 // ISSYMMETRIC SPECIALIZATIONS
1916 //
1917 //=================================================================================================
1918 
1919 //*************************************************************************************************
1921 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1922 struct IsSymmetric< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1923  : public Or< Bool<SF>
1924  , And< Bool<HF>
1925  , IsBuiltin< ElementType_< DMatSMatMultExpr<MT1,MT2,false,true,false,false> > > >
1926  , And< Bool<LF>, Bool<UF> > >
1927 {};
1929 //*************************************************************************************************
1930 
1931 
1932 
1933 
1934 //=================================================================================================
1935 //
1936 // ISHERMITIAN SPECIALIZATIONS
1937 //
1938 //=================================================================================================
1939 
1940 //*************************************************************************************************
1942 template< typename MT1, typename MT2, bool SF, bool LF, bool UF >
1943 struct IsHermitian< DMatSMatMultExpr<MT1,MT2,SF,true,LF,UF> >
1944  : public TrueType
1945 {};
1947 //*************************************************************************************************
1948 
1949 
1950 
1951 
1952 //=================================================================================================
1953 //
1954 // ISLOWER SPECIALIZATIONS
1955 //
1956 //=================================================================================================
1957 
1958 //*************************************************************************************************
1960 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1961 struct IsLower< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1962  : public Or< Bool<LF>
1963  , And< IsLower<MT1>, IsLower<MT2> >
1964  , And< Or< Bool<SF>, Bool<HF> >
1965  , IsUpper<MT1>, IsUpper<MT2> > >
1966 {};
1968 //*************************************************************************************************
1969 
1970 
1971 
1972 
1973 //=================================================================================================
1974 //
1975 // ISUNILOWER SPECIALIZATIONS
1976 //
1977 //=================================================================================================
1978 
1979 //*************************************************************************************************
1981 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1982 struct IsUniLower< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1983  : public Or< And< IsUniLower<MT1>, IsUniLower<MT2> >
1984  , And< Or< Bool<SF>, Bool<HF> >
1985  , IsUniUpper<MT1>, IsUniUpper<MT2> > >
1986 {};
1988 //*************************************************************************************************
1989 
1990 
1991 
1992 
1993 //=================================================================================================
1994 //
1995 // ISSTRICTLYLOWER SPECIALIZATIONS
1996 //
1997 //=================================================================================================
1998 
1999 //*************************************************************************************************
2001 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2002 struct IsStrictlyLower< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2003  : public Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2004  , And< IsStrictlyLower<MT2>, IsLower<MT1> >
2005  , And< Or< Bool<SF>, Bool<HF> >
2006  , Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2007  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > > > >
2008 {};
2010 //*************************************************************************************************
2011 
2012 
2013 
2014 
2015 //=================================================================================================
2016 //
2017 // ISUPPER SPECIALIZATIONS
2018 //
2019 //=================================================================================================
2020 
2021 //*************************************************************************************************
2023 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2024 struct IsUpper< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2025  : public Or< Bool<UF>
2026  , And< IsUpper<MT1>, IsUpper<MT2> >
2027  , And< Or< Bool<SF>, Bool<HF> >
2028  , IsLower<MT1>, IsLower<MT2> > >
2029 {};
2031 //*************************************************************************************************
2032 
2033 
2034 
2035 
2036 //=================================================================================================
2037 //
2038 // ISUNIUPPER SPECIALIZATIONS
2039 //
2040 //=================================================================================================
2041 
2042 //*************************************************************************************************
2044 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2045 struct IsUniUpper< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2046  : public Or< And< IsUniUpper<MT1>, IsUniUpper<MT2> >
2047  , And< Or< Bool<SF>, Bool<HF> >
2048  , IsUniLower<MT1>, IsUniLower<MT2> > >
2049 {};
2051 //*************************************************************************************************
2052 
2053 
2054 
2055 
2056 //=================================================================================================
2057 //
2058 // ISSTRICTLYUPPER SPECIALIZATIONS
2059 //
2060 //=================================================================================================
2061 
2062 //*************************************************************************************************
2064 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2065 struct IsStrictlyUpper< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2066  : public Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2067  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> >
2068  , And< Or< Bool<SF>, Bool<HF> >
2069  , Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2070  , And< IsStrictlyLower<MT2>, IsLower<MT1> > > > >
2071 {};
2073 //*************************************************************************************************
2074 
2075 } // namespace blaze
2076 
2077 #endif
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:329
#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:131
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:71
decltype(auto) decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:996
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatSMatMultExpr.h:390
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatSMatMultExpr.h:348
Header file for the IsUniUpper type trait.
EnableIf_< IsDenseMatrix< MT1 > > smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:196
Compile time check for triangular matrix types.This type trait tests whether or not the given templat...
Definition: IsTriangular.h:86
Header file for basic type definitions.
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatSMatMultExpr.h:412
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatSMatMultExpr.h:238
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:164
Header file for the serial shim.
If_< IsExpression< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: DMatSMatMultExpr.h:244
Header file for the IsDiagonal type trait.
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
#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.
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:364
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
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:1903
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:87
decltype(auto) declupp(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as upper.
Definition: DMatDeclUppExpr.h:1026
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Flag for symmetric matrices.
Definition: DMatSMatMultExpr.h:148
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:87
Constraints on the storage order of matrix types.
DMatSMatMultExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatSMatMultExpr class.
Definition: DMatSMatMultExpr.h:268
Header file for the RequiresEvaluation type trait.
System settings for performance optimizations.
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse matrix operand.
Definition: DMatSMatMultExpr.h:378
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:343
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
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:133
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
Flag for lower matrices.
Definition: DMatSMatMultExpr.h:150
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
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatSMatMultExpr.h:283
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatSMatMultExpr.h:422
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
Constraint on the data type.
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:71
const ElementType ReturnType
Return type for expression template evaluations.
Definition: DMatSMatMultExpr.h:237
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:86
Headerfile for the generic max algorithm.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatSMatMultExpr.h:358
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatSMatMultExpr.h:233
Header file for the DisableIf class template.
Header file for the multiplication trait.
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatSMatMultExpr.h:234
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
Generic wrapper for the decllow() function.
Definition: DeclLow.h:58
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:102
Header file for the Or class template.
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatSMatMultExpr.h:368
#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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
ResultType_< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatSMatMultExpr.h:127
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
decltype(auto) decllow(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as lower.
Definition: DMatDeclLowExpr.h:1026
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:89
Flag for upper matrices.
Definition: DMatSMatMultExpr.h:151
ResultType_< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: DMatSMatMultExpr.h:128
Generic wrapper for the null function.
Definition: Noop.h:59
Header file for the IsTriangular type trait.
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
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:430
Header file for the DeclDiag functor.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
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:107
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:86
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatSMatMultExpr.h:332
Header file for the conjugate shim.
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
Base class for all matrix/matrix multiplication expression templates.The MatMatMultExpr class serves ...
Definition: MatMatMultExpr.h:67
#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
Header file for run time assertion macros.
IfTrue_< evaluateRight, const RT2, CT2 > RT
Type for the assignment of the right-hand side sparse matrix operand.
Definition: DMatSMatMultExpr.h:250
Expression object for dense matrix-sparse matrix multiplications.The DMatSMatMultExpr class represent...
Definition: DMatSMatMultExpr.h:121
CompositeType_< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition: DMatSMatMultExpr.h:132
If_< IsExpression< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatSMatMultExpr.h:241
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:154
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
ElementType_< RT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatSMatMultExpr.h:129
Header file for the reset shim.
#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:1028
Header file for the isDefault shim.
Compile time check for Hermitian matrices.This type trait tests whether or not the given template par...
Definition: IsHermitian.h:85
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:101
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:816
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
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:263
#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
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
CompositeType_< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatSMatMultExpr.h:131
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
decltype(auto) declherm(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as Hermitian.
Definition: DMatDeclHermExpr.h:1028
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatSMatMultExpr.h:235
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
Flag for Hermitian matrices.
Definition: DMatSMatMultExpr.h:149
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
Compile time logical &#39;or&#39; evaluation.The Or alias declaration performs at compile time a logical &#39;or&#39;...
Definition: Or.h:76
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
IfTrue_< evaluateLeft, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense matrix operand.
Definition: DMatSMatMultExpr.h:247
Generic wrapper for the decldiag() function.
Definition: DeclDiag.h:58
RightOperand rhs_
Right-hand side sparse matrix of the multiplication expression.
Definition: DMatSMatMultExpr.h:430
Header file for the DeclHerm functor.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DMatSMatMultExpr.h:236
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
Header file for the IsUpper type trait.
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1321
Constraint on the data type.
Generic wrapper for the declsym() function.
Definition: DeclSym.h:58
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
Header file for the IsResizable type trait.
Header file for the Size type trait.
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 Bool class template.
Header file for the DeclSym functor.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatSMatMultExpr.h:402
#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.
ElementType_< RT2 > ET2
Element type of the right-hand side sparse matrix expression.
Definition: DMatSMatMultExpr.h:130
LeftOperand lhs_
Left-hand side dense matrix of the multiplication expression.
Definition: DMatSMatMultExpr.h:429