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>
88 #include <blaze/util/Assert.h>
89 #include <blaze/util/DisableIf.h>
90 #include <blaze/util/EnableIf.h>
93 #include <blaze/util/InvalidType.h>
94 #include <blaze/util/mpl/And.h>
95 #include <blaze/util/mpl/Bool.h>
96 #include <blaze/util/mpl/If.h>
97 #include <blaze/util/mpl/Or.h>
98 #include <blaze/util/Types.h>
100 
101 
102 namespace blaze {
103 
104 //=================================================================================================
105 //
106 // CLASS DMATSMATMULTEXPR
107 //
108 //=================================================================================================
109 
110 //*************************************************************************************************
117 template< typename MT1 // Type of the left-hand side dense matrix
118  , typename MT2 // Type of the right-hand side sparse matrix
119  , bool SF // Symmetry flag
120  , bool HF // Hermitian flag
121  , bool LF // Lower flag
122  , bool UF > // Upper flag
124  : public MatMatMultExpr< DenseMatrix< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>, false > >
125  , private Computation
126 {
127  private:
128  //**Type definitions****************************************************************************
135  //**********************************************************************************************
136 
137  //**********************************************************************************************
139  enum : bool { evaluateLeft = IsComputation<MT1>::value || RequiresEvaluation<MT1>::value };
140  //**********************************************************************************************
141 
142  //**********************************************************************************************
144  enum : bool { evaluateRight = IsComputation<MT2>::value || RequiresEvaluation<MT2>::value };
145  //**********************************************************************************************
146 
147  //**********************************************************************************************
149  enum : bool {
150  SYM = ( SF && !( HF || LF || UF ) ),
151  HERM = ( HF && !( LF || UF ) ),
152  LOW = ( LF || ( ( SF || HF ) && UF ) ),
153  UPP = ( UF || ( ( SF || HF ) && LF ) )
154  };
155  //**********************************************************************************************
156 
157  //**********************************************************************************************
159 
164  template< typename T1, typename T2, typename T3 >
165  struct CanExploitSymmetry {
166  enum : bool { value = ( IsSymmetric<T2>::value || IsSymmetric<T3>::value ) };
167  };
169  //**********************************************************************************************
170 
171  //**********************************************************************************************
173 
177  template< typename T1, typename T2, typename T3 >
178  struct IsEvaluationRequired {
179  enum : bool { value = ( evaluateLeft || evaluateRight ) &&
180  !CanExploitSymmetry<T1,T2,T3>::value };
181  };
183  //**********************************************************************************************
184 
185  //**********************************************************************************************
187 
190  template< typename T1, typename T2, typename T3 >
191  struct UseOptimizedKernel {
192  enum : bool { value = useOptimizedKernels &&
194  !IsResizable< ElementType_<T1> >::value };
195  };
197  //**********************************************************************************************
198 
199  //**********************************************************************************************
201 
204  template< typename T1, typename T2, typename T3 >
205  struct UseDefaultKernel {
206  enum : bool { value = !UseOptimizedKernel<T1,T2,T3>::value };
207  };
209  //**********************************************************************************************
210 
211  //**********************************************************************************************
213 
216  using ForwardFunctor = IfTrue_< HERM
217  , DeclHerm
218  , IfTrue_< SYM
219  , DeclSym
220  , IfTrue_< LOW
221  , IfTrue_< UPP
222  , DeclDiag
223  , DeclLow >
224  , IfTrue_< UPP
225  , DeclUpp
226  , Noop > > > >;
228  //**********************************************************************************************
229 
230  public:
231  //**Type definitions****************************************************************************
234 
239  using ReturnType = const ElementType;
240  using CompositeType = const ResultType;
241 
243  using LeftOperand = If_< IsExpression<MT1>, const MT1, const MT1& >;
244 
246  using RightOperand = If_< IsExpression<MT2>, const MT2, const MT2& >;
247 
250 
253  //**********************************************************************************************
254 
255  //**Compilation flags***************************************************************************
257  enum : bool { simdEnabled = false };
258 
260  enum : bool { smpAssignable = !evaluateLeft && MT1::smpAssignable &&
261  !evaluateRight && MT2::smpAssignable };
262  //**********************************************************************************************
263 
264  //**Constructor*********************************************************************************
270  explicit inline DMatSMatMultExpr( const MT1& lhs, const MT2& rhs ) noexcept
271  : lhs_( lhs ) // Left-hand side dense matrix of the multiplication expression
272  , rhs_( rhs ) // Right-hand side sparse matrix of the multiplication expression
273  {
274  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.rows(), "Invalid matrix sizes" );
275  }
276  //**********************************************************************************************
277 
278  //**Access operator*****************************************************************************
285  inline ReturnType operator()( size_t i, size_t j ) const {
286  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
287  BLAZE_INTERNAL_ASSERT( j < rhs_.columns(), "Invalid column access index" );
288 
289  if( IsDiagonal<MT1>::value ) {
290  return lhs_(i,i) * rhs_(i,j);
291  }
292  else if( IsDiagonal<MT2>::value ) {
293  return lhs_(i,j) * rhs_(j,j);
294  }
296  const size_t begin( ( IsUpper<MT1>::value )
297  ?( ( IsLower<MT2>::value )
298  ?( max( ( IsStrictlyUpper<MT1>::value ? i+1UL : i )
299  , ( IsStrictlyLower<MT2>::value ? j+1UL : j ) ) )
300  :( IsStrictlyUpper<MT1>::value ? i+1UL : i ) )
301  :( ( IsLower<MT2>::value )
302  ?( IsStrictlyLower<MT2>::value ? j+1UL : j )
303  :( 0UL ) ) );
304  const size_t end( ( IsLower<MT1>::value )
305  ?( ( IsUpper<MT2>::value )
306  ?( min( ( IsStrictlyLower<MT1>::value ? i : i+1UL )
307  , ( IsStrictlyUpper<MT2>::value ? j : j+1UL ) ) )
308  :( IsStrictlyLower<MT1>::value ? i : i+1UL ) )
309  :( ( IsUpper<MT2>::value )
310  ?( IsStrictlyUpper<MT2>::value ? j : j+1UL )
311  :( lhs_.columns() ) ) );
312 
313  if( begin >= end ) return ElementType();
314 
315  const size_t n( end - begin );
316 
317  return subvector( row( lhs_, i ), begin, n ) * subvector( column( rhs_, j ), begin, n );
318  }
319  else {
320  return row( lhs_, i ) * column( rhs_, j );
321  }
322  }
323  //**********************************************************************************************
324 
325  //**At function*********************************************************************************
333  inline ReturnType at( size_t i, size_t j ) const {
334  if( i >= lhs_.rows() ) {
335  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
336  }
337  if( j >= rhs_.columns() ) {
338  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
339  }
340  return (*this)(i,j);
341  }
342  //**********************************************************************************************
343 
344  //**Rows function*******************************************************************************
349  inline size_t rows() const noexcept {
350  return lhs_.rows();
351  }
352  //**********************************************************************************************
353 
354  //**Columns function****************************************************************************
359  inline size_t columns() const noexcept {
360  return rhs_.columns();
361  }
362  //**********************************************************************************************
363 
364  //**Left operand access*************************************************************************
369  inline LeftOperand leftOperand() const noexcept {
370  return lhs_;
371  }
372  //**********************************************************************************************
373 
374  //**Right operand access************************************************************************
379  inline RightOperand rightOperand() const noexcept {
380  return rhs_;
381  }
382  //**********************************************************************************************
383 
384  //**********************************************************************************************
390  template< typename T >
391  inline bool canAlias( const T* alias ) const noexcept {
392  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
393  }
394  //**********************************************************************************************
395 
396  //**********************************************************************************************
402  template< typename T >
403  inline bool isAliased( const T* alias ) const noexcept {
404  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
405  }
406  //**********************************************************************************************
407 
408  //**********************************************************************************************
413  inline bool isAligned() const noexcept {
414  return lhs_.isAligned();
415  }
416  //**********************************************************************************************
417 
418  //**********************************************************************************************
423  inline bool canSMPAssign() const noexcept {
424  return ( rows() * columns() >= SMP_DMATSMATMULT_THRESHOLD ) && !IsDiagonal<MT1>::value;
425  }
426  //**********************************************************************************************
427 
428  private:
429  //**Member variables****************************************************************************
432  //**********************************************************************************************
433 
434  //**Assignment to dense matrices****************************************************************
447  template< typename MT // Type of the target dense matrix
448  , bool SO > // Storage order of the target dense matrix
450  assign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
451  {
453 
454  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
455  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
456 
457  LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
458  RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
459 
460  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
461  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
462  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
463  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
464  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
465  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
466 
467  DMatSMatMultExpr::selectAssignKernel( ~lhs, A, B );
468  }
470  //**********************************************************************************************
471 
472  //**Assignment to dense matrices (kernel selection)*********************************************
483  template< typename MT3 // Type of the left-hand side target matrix
484  , typename MT4 // Type of the left-hand side matrix operand
485  , typename MT5 > // Type of the right-hand side matrix operand
486  static inline void selectAssignKernel( MT3& C, const MT4& A, const MT5& B )
487  {
488  if( C.rows() * C.columns() < DMATSMATMULT_THRESHOLD )
489  selectSmallAssignKernel( C, A, B );
490  else
491  selectLargeAssignKernel( C, A, B );
492  }
494  //**********************************************************************************************
495 
496  //**Default assignment to dense matrices********************************************************
510  template< typename MT3 // Type of the left-hand side target matrix
511  , typename MT4 // Type of the left-hand side matrix operand
512  , typename MT5 > // Type of the right-hand side matrix operand
513  static inline void selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B )
514  {
516 
517  reset( C );
518 
519  for( size_t k=0UL; k<B.rows(); ++k )
520  {
522  {
523  ConstIterator element( B.begin(k) );
524  const ConstIterator end( B.end(k) );
525 
526  for( ; element!=end; ++element ) {
527  C(k,element->index()) = A(k,k) * element->value();
528  }
529  }
530  else
531  {
532  const size_t iibegin( ( IsLower<MT4>::value )
533  ?( IsStrictlyLower<MT4>::value ? k+1UL : k )
534  :( 0UL ) );
535  const size_t iiend( ( IsUpper<MT4>::value )
536  ?( IsStrictlyUpper<MT4>::value ? k : k+1UL )
537  :( A.rows() ) );
538  BLAZE_INTERNAL_ASSERT( iibegin <= iiend, "Invalid loop indices detected" );
539 
540  for( size_t ii=iibegin; ii<iiend; ii+=8UL )
541  {
542  ConstIterator element( B.begin(k) );
543  const ConstIterator end( B.end(k) );
544  const size_t itmp( ( ii+8UL > iiend )?( iiend ):( ii+8UL ) );
545 
546  for( ; element!=end; ++element )
547  {
548  const size_t j1( element->index() );
549  const size_t ibegin( SYM || HERM || LOW ? max(j1,ii) : ii );
550  const size_t iend( UPP ? min(j1+1UL,itmp) : itmp );
551 
552  for( size_t i=ibegin; i<iend; ++i ) {
553  if( isDefault( C(i,element->index()) ) )
554  C(i,j1) = A(i,k) * element->value();
555  else
556  C(i,j1) += A(i,k) * element->value();
557  }
558  }
559  }
560  }
561  }
562 
563  if( SYM || HERM ) {
564  for( size_t i=0UL; i<A.rows(); ++i ) {
565  for( size_t j=i+1UL; j<B.columns(); ++j ) {
566  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
567  }
568  }
569  }
570  }
572  //**********************************************************************************************
573 
574  //**Default assignment to dense matrices (small matrices)***************************************
587  template< typename MT3 // Type of the left-hand side target matrix
588  , typename MT4 // Type of the left-hand side matrix operand
589  , typename MT5 > // Type of the right-hand side matrix operand
591  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
592  {
593  selectDefaultAssignKernel( C, A, B );
594  }
596  //**********************************************************************************************
597 
598  //**Optimized assignment to dense matrices (small matrices)*************************************
613  template< typename MT3 // Type of the left-hand side target matrix
614  , typename MT4 // Type of the left-hand side matrix operand
615  , typename MT5 > // Type of the right-hand side matrix operand
617  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
618  {
620 
621  reset( C );
622 
623  for( size_t j=0UL; j<B.rows(); ++j )
624  {
625  const size_t iibegin( ( IsLower<MT4>::value )
626  ?( IsStrictlyLower<MT4>::value ? j+1UL : j )
627  :( 0UL ) );
628  const size_t iiend( ( IsUpper<MT4>::value )
629  ?( IsStrictlyUpper<MT4>::value ? j : j+1UL )
630  :( A.rows() ) );
631  BLAZE_INTERNAL_ASSERT( iibegin <= iiend, "Invalid loop indices detected" );
632 
633  for( size_t ii=iibegin; ii<iiend; ii+=8UL )
634  {
635  ConstIterator element( B.begin(j) );
636  const ConstIterator end( B.end(j) );
637  const size_t itmp( ( ii+8UL > iiend )?( iiend ):( ii+8UL ) );
638 
639  for( ; element!=end; ++element )
640  {
641  const size_t j1( element->index() );
642  const size_t ibegin( SYM || HERM || LOW ? max(j1,ii) : ii );
643  const size_t iend( UPP ? min(j1+1UL,itmp) : itmp );
644 
645  for( size_t i=ibegin; i<iend; ++i ) {
646  C(i,j1) += A(i,j) * element->value();
647  }
648  }
649  }
650  }
651 
652  if( SYM || HERM ) {
653  for( size_t i=0UL; i<A.rows(); ++i ) {
654  for( size_t j=i+1UL; j<B.columns(); ++j ) {
655  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
656  }
657  }
658  }
659  }
661  //**********************************************************************************************
662 
663  //**Default assignment to dense matrices (large matrices)***************************************
676  template< typename MT3 // Type of the left-hand side target matrix
677  , typename MT4 // Type of the left-hand side matrix operand
678  , typename MT5 > // Type of the right-hand side matrix operand
680  selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B )
681  {
682  selectDefaultAssignKernel( C, A, B );
683  }
685  //**********************************************************************************************
686 
687  //**Optimized assignment to dense matrices (large matrices)*************************************
702  template< typename MT3 // Type of the left-hand side target matrix
703  , typename MT4 // Type of the left-hand side matrix operand
704  , typename MT5 > // Type of the right-hand side matrix operand
706  selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B )
707  {
709 
710  const ForwardFunctor fwd;
711 
712  const OppositeType_<MT5> tmp( serial( B ) );
713  assign( C, fwd( A * tmp ) );
714  }
716  //**********************************************************************************************
717 
718  //**Assignment to sparse matrices***************************************************************
731  template< typename MT // Type of the target sparse matrix
732  , bool SO > // Storage order of the target sparse matrix
734  assign( SparseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
735  {
737 
739 
746 
747  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
748  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
749 
750  const ForwardFunctor fwd;
751 
752  const TmpType tmp( serial( rhs ) );
753  assign( ~lhs, fwd( tmp ) );
754  }
756  //**********************************************************************************************
757 
758  //**Restructuring assignment********************************************************************
773  template< typename MT // Type of the target matrix
774  , bool SO > // Storage order of the target matrix
776  assign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
777  {
779 
781 
782  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
783  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
784 
785  const ForwardFunctor fwd;
786 
788  assign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
789  else if( IsSymmetric<MT1>::value )
790  assign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
791  else
792  assign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
793  }
795  //**********************************************************************************************
796 
797  //**Addition assignment to dense matrices*******************************************************
810  template< typename MT // Type of the target dense matrix
811  , bool SO > // Storage order of the target dense matrix
813  addAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
814  {
816 
817  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
818  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
819 
820  LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
821  RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
822 
823  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
824  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
825  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
826  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
827  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
828  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
829 
830  DMatSMatMultExpr::selectAddAssignKernel( ~lhs, A, B );
831  }
833  //**********************************************************************************************
834 
835  //**Addition assignment to dense matrices (kernel selection)************************************
846  template< typename MT3 // Type of the left-hand side target matrix
847  , typename MT4 // Type of the left-hand side matrix operand
848  , typename MT5 > // Type of the right-hand side matrix operand
849  static inline void selectAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
850  {
851  if( C.rows() * C.columns() < DMATSMATMULT_THRESHOLD )
852  selectSmallAddAssignKernel( C, A, B );
853  else
854  selectLargeAddAssignKernel( C, A, B );
855  }
857  //**********************************************************************************************
858 
859  //**Optimized addition assignment to dense matrices (small matrices)****************************
873  template< typename MT3 // Type of the left-hand side target matrix
874  , typename MT4 // Type of the left-hand side matrix operand
875  , typename MT5 > // Type of the right-hand side matrix operand
876  static inline void selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
877  {
879 
880  for( size_t j=0UL; j<B.rows(); ++j )
881  {
883  {
884  ConstIterator element( B.begin(j) );
885  const ConstIterator end( B.end(j) );
886 
887  for( ; element!=end; ++element ) {
888  C(j,element->index()) += A(j,j) * element->value();
889  }
890  }
891  else
892  {
893  const size_t iibegin( ( IsLower<MT4>::value )
894  ?( IsStrictlyLower<MT4>::value ? j+1UL : j )
895  :( 0UL ) );
896  const size_t iiend( ( IsUpper<MT4>::value )
897  ?( IsStrictlyUpper<MT4>::value ? j : j+1UL )
898  :( A.rows() ) );
899  BLAZE_INTERNAL_ASSERT( iibegin <= iiend, "Invalid loop indices detected" );
900 
901  for( size_t ii=iibegin; ii<iiend; ii+=8UL )
902  {
903  ConstIterator element( B.begin(j) );
904  const ConstIterator end( B.end(j) );
905  const size_t itmp( ( ii+8UL > iiend )?( iiend ):( ii+8UL ) );
906 
907  for( ; element!=end; ++element )
908  {
909  const size_t j1( element->index() );
910  const size_t ibegin( LOW ? max(j1,ii) : ii );
911  const size_t iend( UPP ? min(j1+1UL,itmp) : itmp );
912 
913  for( size_t i=ibegin; i<iend; ++i ) {
914  C(i,j1) += A(i,j) * element->value();
915  }
916  }
917  }
918  }
919  }
920  }
922  //**********************************************************************************************
923 
924  //**Optimized addition assignment to dense matrices (large matrices)****************************
938  template< typename MT3 // Type of the left-hand side target matrix
939  , typename MT4 // Type of the left-hand side matrix operand
940  , typename MT5 > // Type of the right-hand side matrix operand
941  static inline void selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
942  {
944 
945  const ForwardFunctor fwd;
946 
947  const OppositeType_<MT5> tmp( serial( B ) );
948  addAssign( C, fwd( A * tmp ) );
949  }
951  //**********************************************************************************************
952 
953  //**Restructuring addition assignment***********************************************************
968  template< typename MT // Type of the target matrix
969  , bool SO > // Storage order of the target matrix
971  addAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
972  {
974 
976 
977  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
978  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
979 
980  const ForwardFunctor fwd;
981 
983  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
984  else if( IsSymmetric<MT1>::value )
985  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
986  else
987  addAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
988  }
990  //**********************************************************************************************
991 
992  //**Addition assignment to sparse matrices******************************************************
993  // No special implementation for the addition assignment to sparse matrices.
994  //**********************************************************************************************
995 
996  //**Subtraction assignment to dense matrices****************************************************
1009  template< typename MT // Type of the target dense matrix
1010  , bool SO > // Storage order of the target dense matrix
1012  subAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1013  {
1015 
1016  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1017  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1018 
1019  LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
1020  RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
1021 
1022  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1023  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1024  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1025  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1026  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1027  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1028 
1029  DMatSMatMultExpr::selectSubAssignKernel( ~lhs, A, B );
1030  }
1032  //**********************************************************************************************
1033 
1034  //**Subtraction assignment to dense matrices (kernel selection)*********************************
1045  template< typename MT3 // Type of the left-hand side target matrix
1046  , typename MT4 // Type of the left-hand side matrix operand
1047  , typename MT5 > // Type of the right-hand side matrix operand
1048  static inline void selectSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1049  {
1050  if( C.rows() * C.columns() < DMATSMATMULT_THRESHOLD )
1051  selectSmallSubAssignKernel( C, A, B );
1052  else
1053  selectLargeSubAssignKernel( C, A, B );
1054  }
1056  //**********************************************************************************************
1057 
1058  //**Optimized subtraction assignment to dense matrices (small matrices)*************************
1072  template< typename MT3 // Type of the left-hand side target matrix
1073  , typename MT4 // Type of the left-hand side matrix operand
1074  , typename MT5 > // Type of the right-hand side matrix operand
1075  static inline void selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1076  {
1078 
1079  for( size_t j=0UL; j<B.rows(); ++j )
1080  {
1082  {
1083  ConstIterator element( B.begin(j) );
1084  const ConstIterator end( B.end(j) );
1085 
1086  for( ; element!=end; ++element ) {
1087  C(j,element->index()) -= A(j,j) * element->value();
1088  }
1089  }
1090  else
1091  {
1092  const size_t iibegin( ( IsLower<MT4>::value )
1093  ?( IsStrictlyLower<MT4>::value ? j+1UL : j )
1094  :( 0UL ) );
1095  const size_t iiend( ( IsUpper<MT4>::value )
1096  ?( IsStrictlyUpper<MT4>::value ? j : j+1UL )
1097  :( A.rows() ) );
1098  BLAZE_INTERNAL_ASSERT( iibegin <= iiend, "Invalid loop indices detected" );
1099 
1100  for( size_t ii=iibegin; ii<iiend; ii+=8UL )
1101  {
1102  ConstIterator element( B.begin(j) );
1103  const ConstIterator end( B.end(j) );
1104  const size_t itmp( ( ii+8UL > iiend )?( iiend ):( ii+8UL ) );
1105 
1106  for( ; element!=end; ++element )
1107  {
1108  const size_t j1( element->index() );
1109  const size_t ibegin( LOW ? max(j1,ii) : ii );
1110  const size_t iend( UPP ? min(j1+1UL,itmp) : itmp );
1111 
1112  for( size_t i=ibegin; i<iend; ++i ) {
1113  C(i,j1) -= A(i,j) * element->value();
1114  }
1115  }
1116  }
1117  }
1118  }
1119  }
1121  //**********************************************************************************************
1122 
1123  //**Optimized subtraction assignment to dense matrices (large matrices)*************************
1137  template< typename MT3 // Type of the left-hand side target matrix
1138  , typename MT4 // Type of the left-hand side matrix operand
1139  , typename MT5 > // Type of the right-hand side matrix operand
1140  static inline void selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1141  {
1143 
1144  const ForwardFunctor fwd;
1145 
1146  const OppositeType_<MT5> tmp( serial( B ) );
1147  subAssign( C, fwd( A * tmp ) );
1148  }
1150  //**********************************************************************************************
1151 
1152  //**Restructuring subtraction assignment********************************************************
1167  template< typename MT // Type of the target matrix
1168  , bool SO > // Storage order of the target matrix
1170  subAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1171  {
1173 
1175 
1176  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1177  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1178 
1179  const ForwardFunctor fwd;
1180 
1182  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1183  else if( IsSymmetric<MT1>::value )
1184  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1185  else
1186  subAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1187  }
1189  //**********************************************************************************************
1190 
1191  //**Subtraction assignment to sparse matrices***************************************************
1192  // No special implementation for the subtraction assignment to sparse matrices.
1193  //**********************************************************************************************
1194 
1195  //**Schur product assignment to dense matrices**************************************************
1208  template< typename MT // Type of the target dense matrix
1209  , bool SO > // Storage order of the target dense matrix
1210  friend inline void schurAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1211  {
1213 
1217 
1218  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1219  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1220 
1221  const ResultType tmp( serial( rhs ) );
1222  schurAssign( ~lhs, tmp );
1223  }
1225  //**********************************************************************************************
1226 
1227  //**Schur product assignment to sparse matrices*************************************************
1228  // No special implementation for the Schur product assignment to sparse matrices.
1229  //**********************************************************************************************
1230 
1231  //**Multiplication assignment to dense matrices*************************************************
1232  // No special implementation for the multiplication assignment to dense matrices.
1233  //**********************************************************************************************
1234 
1235  //**Multiplication assignment to sparse matrices************************************************
1236  // No special implementation for the multiplication assignment to sparse matrices.
1237  //**********************************************************************************************
1238 
1239  //**SMP assignment to dense matrices************************************************************
1254  template< typename MT // Type of the target dense matrix
1255  , bool SO > // Storage order of the target dense matrix
1257  smpAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1258  {
1260 
1261  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1262  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1263 
1264  LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand
1265  RT B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
1266 
1267  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1268  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1269  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1270  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1271  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1272  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1273 
1274  smpAssign( ~lhs, A * B );
1275  }
1277  //**********************************************************************************************
1278 
1279  //**SMP assignment to sparse matrices***********************************************************
1294  template< typename MT // Type of the target sparse matrix
1295  , bool SO > // Storage order of the target sparse matrix
1297  smpAssign( SparseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1298  {
1300 
1302 
1309 
1310  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1311  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1312 
1313  const ForwardFunctor fwd;
1314 
1315  const TmpType tmp( rhs );
1316  smpAssign( ~lhs, fwd( tmp ) );
1317  }
1319  //**********************************************************************************************
1320 
1321  //**Restructuring SMP assignment****************************************************************
1336  template< typename MT // Type of the target matrix
1337  , bool SO > // Storage order of the target matrix
1339  smpAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1340  {
1342 
1344 
1345  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1346  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1347 
1348  const ForwardFunctor fwd;
1349 
1351  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1352  else if( IsSymmetric<MT1>::value )
1353  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1354  else
1355  smpAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1356  }
1358  //**********************************************************************************************
1359 
1360  //**SMP addition assignment to dense matrices***************************************************
1375  template< typename MT // Type of the target dense matrix
1376  , bool SO > // Storage order of the target sparse matrix
1379  {
1381 
1382  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1383  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1384 
1385  LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand
1386  RT B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
1387 
1388  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1389  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1390  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1391  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1392  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1393  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1394 
1395  smpAddAssign( ~lhs, A * B );
1396  }
1398  //**********************************************************************************************
1399 
1400  //**Restructuring SMP addition assignment*******************************************************
1415  template< typename MT // Type of the target matrix
1416  , bool SO > // Storage order of the target matrix
1418  smpAddAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1419  {
1421 
1423 
1424  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1425  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1426 
1427  const ForwardFunctor fwd;
1428 
1430  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1431  else if( IsSymmetric<MT1>::value )
1432  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1433  else
1434  smpAddAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1435  }
1437  //**********************************************************************************************
1438 
1439  //**SMP addition assignment to sparse matrices**************************************************
1440  // No special implementation for the SMP addition assignment to sparse matrices.
1441  //**********************************************************************************************
1442 
1443  //**SMP subtraction assignment to dense matrices************************************************
1459  template< typename MT // Type of the target dense matrix
1460  , bool SO > // Storage order of the target sparse matrix
1463  {
1465 
1466  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1467  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1468 
1469  LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand
1470  RT B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
1471 
1472  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1473  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1474  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1475  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1476  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1477  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1478 
1479  smpSubAssign( ~lhs, A * B );
1480  }
1482  //**********************************************************************************************
1483 
1484  //**Restructuring SMP subtraction assignment****************************************************
1499  template< typename MT // Type of the target matrix
1500  , bool SO > // Storage order of the target matrix
1502  smpSubAssign( Matrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1503  {
1505 
1507 
1508  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1509  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1510 
1511  const ForwardFunctor fwd;
1512 
1514  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1515  else if( IsSymmetric<MT1>::value )
1516  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1517  else
1518  smpSubAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1519  }
1521  //**********************************************************************************************
1522 
1523  //**SMP subtraction assignment to sparse matrices***********************************************
1524  // No special implementation for the SMP subtraction assignment to sparse matrices.
1525  //**********************************************************************************************
1526 
1527  //**SMP Schur product assignment to dense matrices**********************************************
1540  template< typename MT // Type of the target dense matrix
1541  , bool SO > // Storage order of the target sparse matrix
1542  friend inline void smpSchurAssign( DenseMatrix<MT,SO>& lhs, const DMatSMatMultExpr& rhs )
1543  {
1545 
1549 
1550  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1551  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1552 
1553  const ResultType tmp( rhs );
1554  smpSchurAssign( ~lhs, tmp );
1555  }
1557  //**********************************************************************************************
1558 
1559  //**SMP Schur product assignment to sparse matrices*********************************************
1560  // No special implementation for the SMP Schur product assignment to sparse matrices.
1561  //**********************************************************************************************
1562 
1563  //**SMP multiplication assignment to dense matrices*********************************************
1564  // No special implementation for the SMP multiplication assignment to dense matrices.
1565  //**********************************************************************************************
1566 
1567  //**SMP multiplication assignment to sparse matrices********************************************
1568  // No special implementation for the SMP multiplication assignment to sparse matrices.
1569  //**********************************************************************************************
1570 
1571  //**Compile time checks*************************************************************************
1579  //**********************************************************************************************
1580 };
1581 //*************************************************************************************************
1582 
1583 
1584 
1585 
1586 //=================================================================================================
1587 //
1588 // GLOBAL BINARY ARITHMETIC OPERATORS
1589 //
1590 //=================================================================================================
1591 
1592 //*************************************************************************************************
1621 template< typename MT1 // Type of the left-hand side dense matrix
1622  , typename MT2 > // Type of the right-hand side sparse matrix
1623 inline decltype(auto)
1624  operator*( const DenseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,false>& rhs )
1625 {
1627 
1628  if( (~lhs).columns() != (~rhs).rows() ) {
1629  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1630  }
1631 
1633  return ReturnType( ~lhs, ~rhs );
1634 }
1635 //*************************************************************************************************
1636 
1637 
1638 
1639 
1640 //=================================================================================================
1641 //
1642 // GLOBAL FUNCTIONS
1643 //
1644 //=================================================================================================
1645 
1646 //*************************************************************************************************
1670 template< typename MT1 // Type of the left-hand side dense matrix
1671  , typename MT2 // Type of the right-hand side sparse matrix
1672  , bool SF // Symmetry flag
1673  , bool HF // Hermitian flag
1674  , bool LF // Lower flag
1675  , bool UF > // Upper flag
1676 inline decltype(auto) declsym( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1677 {
1679 
1680  if( !isSquare( dm ) ) {
1681  BLAZE_THROW_INVALID_ARGUMENT( "Invalid symmetric matrix specification" );
1682  }
1683 
1685  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1686 }
1688 //*************************************************************************************************
1689 
1690 
1691 //*************************************************************************************************
1715 template< typename MT1 // Type of the left-hand side dense matrix
1716  , typename MT2 // Type of the right-hand side sparse matrix
1717  , bool SF // Symmetry flag
1718  , bool HF // Hermitian flag
1719  , bool LF // Lower flag
1720  , bool UF > // Upper flag
1721 inline decltype(auto) declherm( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1722 {
1724 
1725  if( !isSquare( dm ) ) {
1726  BLAZE_THROW_INVALID_ARGUMENT( "Invalid Hermitian matrix specification" );
1727  }
1728 
1730  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1731 }
1733 //*************************************************************************************************
1734 
1735 
1736 //*************************************************************************************************
1760 template< typename MT1 // Type of the left-hand side dense matrix
1761  , typename MT2 // Type of the right-hand side sparse matrix
1762  , bool SF // Symmetry flag
1763  , bool HF // Hermitian flag
1764  , bool LF // Lower flag
1765  , bool UF > // Upper flag
1766 inline decltype(auto) decllow( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1767 {
1769 
1770  if( !isSquare( dm ) ) {
1771  BLAZE_THROW_INVALID_ARGUMENT( "Invalid lower matrix specification" );
1772  }
1773 
1775  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1776 }
1778 //*************************************************************************************************
1779 
1780 
1781 //*************************************************************************************************
1805 template< typename MT1 // Type of the left-hand side dense matrix
1806  , typename MT2 // Type of the right-hand side sparse matrix
1807  , bool SF // Symmetry flag
1808  , bool HF // Hermitian flag
1809  , bool LF // Lower flag
1810  , bool UF > // Upper flag
1811 inline decltype(auto) declupp( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1812 {
1814 
1815  if( !isSquare( dm ) ) {
1816  BLAZE_THROW_INVALID_ARGUMENT( "Invalid upper matrix specification" );
1817  }
1818 
1820  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1821 }
1823 //*************************************************************************************************
1824 
1825 
1826 //*************************************************************************************************
1850 template< typename MT1 // Type of the left-hand side dense matrix
1851  , typename MT2 // Type of the right-hand side sparse matrix
1852  , bool SF // Symmetry flag
1853  , bool HF // Hermitian flag
1854  , bool LF // Lower flag
1855  , bool UF > // Upper flag
1856 inline decltype(auto) decldiag( const DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
1857 {
1859 
1860  if( !isSquare( dm ) ) {
1861  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
1862  }
1863 
1865  return ReturnType( dm.leftOperand(), dm.rightOperand() );
1866 }
1868 //*************************************************************************************************
1869 
1870 
1871 
1872 
1873 //=================================================================================================
1874 //
1875 // ROWS SPECIALIZATIONS
1876 //
1877 //=================================================================================================
1878 
1879 //*************************************************************************************************
1881 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1882 struct Rows< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1883  : public Rows<MT1>
1884 {};
1886 //*************************************************************************************************
1887 
1888 
1889 
1890 
1891 //=================================================================================================
1892 //
1893 // COLUMNS SPECIALIZATIONS
1894 //
1895 //=================================================================================================
1896 
1897 //*************************************************************************************************
1899 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1900 struct Columns< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1901  : public Columns<MT2>
1902 {};
1904 //*************************************************************************************************
1905 
1906 
1907 
1908 
1909 //=================================================================================================
1910 //
1911 // ISALIGNED SPECIALIZATIONS
1912 //
1913 //=================================================================================================
1914 
1915 //*************************************************************************************************
1917 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1918 struct IsAligned< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1919  : public BoolConstant< IsAligned<MT1>::value >
1920 {};
1922 //*************************************************************************************************
1923 
1924 
1925 
1926 
1927 //=================================================================================================
1928 //
1929 // ISSYMMETRIC SPECIALIZATIONS
1930 //
1931 //=================================================================================================
1932 
1933 //*************************************************************************************************
1935 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1936 struct IsSymmetric< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1937  : public BoolConstant< Or< Bool<SF>
1938  , And< Bool<HF>
1939  , IsBuiltin< ElementType_< DMatSMatMultExpr<MT1,MT2,false,true,false,false> > > >
1940  , And< Bool<LF>, Bool<UF> > >::value >
1941 {};
1943 //*************************************************************************************************
1944 
1945 
1946 
1947 
1948 //=================================================================================================
1949 //
1950 // ISHERMITIAN SPECIALIZATIONS
1951 //
1952 //=================================================================================================
1953 
1954 //*************************************************************************************************
1956 template< typename MT1, typename MT2, bool SF, bool LF, bool UF >
1957 struct IsHermitian< DMatSMatMultExpr<MT1,MT2,SF,true,LF,UF> >
1958  : public TrueType
1959 {};
1961 //*************************************************************************************************
1962 
1963 
1964 
1965 
1966 //=================================================================================================
1967 //
1968 // ISLOWER SPECIALIZATIONS
1969 //
1970 //=================================================================================================
1971 
1972 //*************************************************************************************************
1974 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1975 struct IsLower< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1976  : public BoolConstant< Or< Bool<LF>
1977  , And< IsLower<MT1>, IsLower<MT2> >
1978  , And< Or< Bool<SF>, Bool<HF> >
1979  , IsUpper<MT1>, IsUpper<MT2> > >::value >
1980 {};
1982 //*************************************************************************************************
1983 
1984 
1985 
1986 
1987 //=================================================================================================
1988 //
1989 // ISUNILOWER SPECIALIZATIONS
1990 //
1991 //=================================================================================================
1992 
1993 //*************************************************************************************************
1995 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
1996 struct IsUniLower< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
1997  : public BoolConstant< Or< And< IsUniLower<MT1>, IsUniLower<MT2> >
1998  , And< Or< Bool<SF>, Bool<HF> >
1999  , IsUniUpper<MT1>, IsUniUpper<MT2> > >::value >
2000 {};
2002 //*************************************************************************************************
2003 
2004 
2005 
2006 
2007 //=================================================================================================
2008 //
2009 // ISSTRICTLYLOWER SPECIALIZATIONS
2010 //
2011 //=================================================================================================
2012 
2013 //*************************************************************************************************
2015 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2016 struct IsStrictlyLower< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2017  : public BoolConstant< Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2018  , And< IsStrictlyLower<MT2>, IsLower<MT1> >
2019  , And< Or< Bool<SF>, Bool<HF> >
2020  , Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2021  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > > > >::value >
2022 {};
2024 //*************************************************************************************************
2025 
2026 
2027 
2028 
2029 //=================================================================================================
2030 //
2031 // ISUPPER SPECIALIZATIONS
2032 //
2033 //=================================================================================================
2034 
2035 //*************************************************************************************************
2037 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2038 struct IsUpper< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2039  : public BoolConstant< Or< Bool<UF>
2040  , And< IsUpper<MT1>, IsUpper<MT2> >
2041  , And< Or< Bool<SF>, Bool<HF> >
2042  , IsLower<MT1>, IsLower<MT2> > >::value >
2043 {};
2045 //*************************************************************************************************
2046 
2047 
2048 
2049 
2050 //=================================================================================================
2051 //
2052 // ISUNIUPPER SPECIALIZATIONS
2053 //
2054 //=================================================================================================
2055 
2056 //*************************************************************************************************
2058 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2059 struct IsUniUpper< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2060  : public BoolConstant< Or< And< IsUniUpper<MT1>, IsUniUpper<MT2> >
2061  , And< Or< Bool<SF>, Bool<HF> >
2062  , IsUniLower<MT1>, IsUniLower<MT2> > >::value >
2063 {};
2065 //*************************************************************************************************
2066 
2067 
2068 
2069 
2070 //=================================================================================================
2071 //
2072 // ISSTRICTLYUPPER SPECIALIZATIONS
2073 //
2074 //=================================================================================================
2075 
2076 //*************************************************************************************************
2078 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2079 struct IsStrictlyUpper< DMatSMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2080  : public BoolConstant< Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2081  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> >
2082  , And< Or< Bool<SF>, Bool<HF> >
2083  , Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2084  , And< IsStrictlyLower<MT2>, IsLower<MT1> > > > >::value >
2085 {};
2087 //*************************************************************************************************
2088 
2089 } // namespace blaze
2090 
2091 #endif
#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.
Headerfile for the generic min algorithm.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:72
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:391
Header file for the Rows type trait.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatSMatMultExpr.h:349
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:87
Header file for basic type definitions.
Flag for symmetric matrices.
Definition: DMatSMatMultExpr.h:150
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatSMatMultExpr.h:413
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatSMatMultExpr.h:240
Subvector< VT, AF > 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:322
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:246
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:198
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
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:1762
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
Flag for Hermitian matrices.
Definition: DMatSMatMultExpr.h:151
decltype(auto) declupp(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as upper.
Definition: DMatDeclUppExpr.h:1027
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:250
Column< MT > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:124
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:88
Constraints on the storage order of matrix types.
DMatSMatMultExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatSMatMultExpr class.
Definition: DMatSMatMultExpr.h:270
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:379
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:1809
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:78
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
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:285
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatSMatMultExpr.h:423
Row< MT > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:124
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:72
const ElementType ReturnType
Return type for expression template evaluations.
Definition: DMatSMatMultExpr.h:239
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:359
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatSMatMultExpr.h:235
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:236
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the DeclLow functor.
Flag for lower matrices.
Definition: DMatSMatMultExpr.h:152
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:369
#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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
ResultType_< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatSMatMultExpr.h:129
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:1027
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
ResultType_< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: DMatSMatMultExpr.h:130
Flag for upper matrices.
Definition: DMatSMatMultExpr.h:153
Generic wrapper for the null function.
Definition: Noop.h:58
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:264
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:108
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:333
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:252
Utility type for generic codes.
Expression object for dense matrix-sparse matrix multiplications.The DMatSMatMultExpr class represent...
Definition: DMatSMatMultExpr.h:123
CompositeType_< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition: DMatSMatMultExpr.h:134
If_< IsExpression< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatSMatMultExpr.h:243
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
ElementType_< RT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatSMatMultExpr.h:131
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:1029
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:819
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:133
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
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:790
decltype(auto) declherm(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as Hermitian.
Definition: DMatDeclHermExpr.h:1029
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatSMatMultExpr.h:237
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
IfTrue_< evaluateLeft, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense matrix operand.
Definition: DMatSMatMultExpr.h:249
Header file for the IntegralConstant class template.
Compile time evaluation of the number of columns of a matrix.The Columns type trait evaluates the num...
Definition: Columns.h:75
Generic wrapper for the decldiag() function.
Definition: DeclDiag.h:58
Compile time evaluation of the number of rows of a matrix.The Rows type trait evaluates the number of...
Definition: Rows.h:75
RightOperand rhs_
Right-hand side sparse matrix of the multiplication expression.
Definition: DMatSMatMultExpr.h:431
Header file for the DeclHerm functor.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DMatSMatMultExpr.h:238
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:742
Header file for the IsResizable 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:403
#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:132
LeftOperand lhs_
Left-hand side dense matrix of the multiplication expression.
Definition: DMatSMatMultExpr.h:430