TSMatTDMatMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATTDMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSMATTDMATMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
55 #include <blaze/math/Functions.h>
64 #include <blaze/math/shims/Reset.h>
108 #include <blaze/system/Thresholds.h>
109 #include <blaze/util/Assert.h>
111 #include <blaze/util/DisableIf.h>
112 #include <blaze/util/EnableIf.h>
115 #include <blaze/util/InvalidType.h>
116 #include <blaze/util/mpl/And.h>
117 #include <blaze/util/mpl/Bool.h>
118 #include <blaze/util/mpl/If.h>
119 #include <blaze/util/mpl/Or.h>
120 #include <blaze/util/Types.h>
122 
123 
124 namespace blaze {
125 
126 //=================================================================================================
127 //
128 // CLASS SMATDMATMULTEXPR
129 //
130 //=================================================================================================
131 
132 //*************************************************************************************************
139 template< typename MT1 // Type of the left-hand side dense matrix
140  , typename MT2 // Type of the right-hand side sparse matrix
141  , bool SF // Symmetry flag
142  , bool HF // Hermitian flag
143  , bool LF // Lower flag
144  , bool UF > // Upper flag
145 class TSMatTDMatMultExpr : public DenseMatrix< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, true >
146  , private MatMatMultExpr
147  , private Computation
148 {
149  private:
150  //**Type definitions****************************************************************************
157  //**********************************************************************************************
158 
159  //**********************************************************************************************
161  enum : bool { evaluateLeft = IsComputation<MT1>::value || RequiresEvaluation<MT1>::value };
162  //**********************************************************************************************
163 
164  //**********************************************************************************************
166  enum : bool { evaluateRight = IsComputation<MT2>::value || RequiresEvaluation<MT2>::value };
167  //**********************************************************************************************
168 
169  //**********************************************************************************************
171  enum : bool {
172  SYM = ( SF && !( HF || LF || UF ) ),
173  HERM = ( HF && !( LF || UF ) ),
174  LOW = ( LF || ( ( SF || HF ) && UF ) ),
175  UPP = ( UF || ( ( SF || HF ) && LF ) )
176  };
177  //**********************************************************************************************
178 
179  //**********************************************************************************************
181 
186  template< typename T1, typename T2, typename T3 >
187  struct CanExploitSymmetry {
188  enum : bool { value = ( IsSymmetric<T2>::value || IsSymmetric<T3>::value ) };
189  };
191  //**********************************************************************************************
192 
193  //**********************************************************************************************
195 
199  template< typename T1, typename T2, typename T3 >
200  struct IsEvaluationRequired {
201  enum : bool { value = ( evaluateLeft || evaluateRight ) &&
202  !CanExploitSymmetry<T1,T2,T3>::value };
203  };
205  //**********************************************************************************************
206 
207  //**********************************************************************************************
209 
213  template< typename T1, typename T2, typename T3 >
214  struct UseOptimizedKernel {
215  enum : bool { value = useOptimizedKernels &&
217  !IsResizable< ElementType_<T1> >::value &&
219  };
221  //**********************************************************************************************
222 
223  //**********************************************************************************************
225 
228  template< typename T1, typename T2, typename T3 >
229  struct UseDefaultKernel {
230  enum : bool { value = !UseOptimizedKernel<T1,T2,T3>::value };
231  };
233  //**********************************************************************************************
234 
235  //**********************************************************************************************
237 
240  typedef IfTrue_< HERM
241  , DeclHerm
242  , IfTrue_< SYM
243  , DeclSym
244  , IfTrue_< LOW
245  , IfTrue_< UPP
246  , DeclDiag
247  , DeclLow >
248  , IfTrue_< UPP
249  , DeclUpp
250  , Noop > > > > ForwardFunctor;
252  //**********************************************************************************************
253 
254  public:
255  //**Type definitions****************************************************************************
258 
263  typedef const ElementType ReturnType;
264  typedef const ResultType CompositeType;
265 
267  typedef If_< IsExpression<MT1>, const MT1, const MT1& > LeftOperand;
268 
270  typedef If_< IsExpression<MT2>, const MT2, const MT2& > RightOperand;
271 
274 
277  //**********************************************************************************************
278 
279  //**Compilation flags***************************************************************************
281  enum : bool { simdEnabled = false };
282 
284  enum : bool { smpAssignable = !evaluateLeft && MT1::smpAssignable &&
285  !evaluateRight && MT2::smpAssignable };
286  //**********************************************************************************************
287 
288  //**Constructor*********************************************************************************
294  explicit inline TSMatTDMatMultExpr( const MT1& lhs, const MT2& rhs ) noexcept
295  : lhs_( lhs ) // Left-hand side sparse matrix of the multiplication expression
296  , rhs_( rhs ) // Right-hand side dense matrix of the multiplication expression
297  {
298  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.rows(), "Invalid matrix sizes" );
299  }
300  //**********************************************************************************************
301 
302  //**Access operator*****************************************************************************
309  inline ReturnType operator()( size_t i, size_t j ) const {
310  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
311  BLAZE_INTERNAL_ASSERT( j < rhs_.columns(), "Invalid column access index" );
312 
313  if( IsDiagonal<MT1>::value ) {
314  return lhs_(i,i) * rhs_(i,j);
315  }
316  else if( IsDiagonal<MT2>::value ) {
317  return lhs_(i,j) * rhs_(j,j);
318  }
320  const size_t begin( ( IsUpper<MT1>::value )
321  ?( ( IsLower<MT2>::value )
322  ?( max( ( IsStrictlyUpper<MT1>::value ? i+1UL : i )
323  , ( IsStrictlyLower<MT2>::value ? j+1UL : j ) ) )
324  :( IsStrictlyUpper<MT1>::value ? i+1UL : i ) )
325  :( ( IsLower<MT2>::value )
326  ?( IsStrictlyLower<MT2>::value ? j+1UL : j )
327  :( 0UL ) ) );
328  const size_t end( ( IsLower<MT1>::value )
329  ?( ( IsUpper<MT2>::value )
330  ?( min( ( IsStrictlyLower<MT1>::value ? i : i+1UL )
331  , ( IsStrictlyUpper<MT2>::value ? j : j+1UL ) ) )
332  :( IsStrictlyLower<MT1>::value ? i : i+1UL ) )
333  :( ( IsUpper<MT2>::value )
334  ?( IsStrictlyUpper<MT2>::value ? j : j+1UL )
335  :( lhs_.columns() ) ) );
336 
337  if( begin >= end ) return ElementType();
338 
339  const size_t n( end - begin );
340 
341  return subvector( row( lhs_, i ), begin, n ) * subvector( column( rhs_, j ), begin, n );
342  }
343  else {
344  return row( lhs_, i ) * column( rhs_, j );
345  }
346  }
347  //**********************************************************************************************
348 
349  //**At function*********************************************************************************
357  inline ReturnType at( size_t i, size_t j ) const {
358  if( i >= lhs_.rows() ) {
359  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
360  }
361  if( j >= rhs_.columns() ) {
362  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
363  }
364  return (*this)(i,j);
365  }
366  //**********************************************************************************************
367 
368  //**Rows function*******************************************************************************
373  inline size_t rows() const noexcept {
374  return lhs_.rows();
375  }
376  //**********************************************************************************************
377 
378  //**Columns function****************************************************************************
383  inline size_t columns() const noexcept {
384  return rhs_.columns();
385  }
386  //**********************************************************************************************
387 
388  //**Left operand access*************************************************************************
393  inline LeftOperand leftOperand() const noexcept {
394  return lhs_;
395  }
396  //**********************************************************************************************
397 
398  //**Right operand access************************************************************************
403  inline RightOperand rightOperand() const noexcept {
404  return rhs_;
405  }
406  //**********************************************************************************************
407 
408  //**********************************************************************************************
414  template< typename T >
415  inline bool canAlias( const T* alias ) const noexcept {
416  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
417  }
418  //**********************************************************************************************
419 
420  //**********************************************************************************************
426  template< typename T >
427  inline bool isAliased( const T* alias ) const noexcept {
428  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
429  }
430  //**********************************************************************************************
431 
432  //**********************************************************************************************
437  inline bool isAligned() const noexcept {
438  return rhs_.isAligned();
439  }
440  //**********************************************************************************************
441 
442  //**********************************************************************************************
447  inline bool canSMPAssign() const noexcept {
448  return ( rows() * columns() >= SMP_TSMATTDMATMULT_THRESHOLD ) && !IsDiagonal<MT2>::value;
449  }
450  //**********************************************************************************************
451 
452  private:
453  //**Member variables****************************************************************************
454  LeftOperand lhs_;
455  RightOperand rhs_;
456  //**********************************************************************************************
457 
458  //**Assignment to dense matrices****************************************************************
471  template< typename MT // Type of the target dense matrix
472  , bool SO > // Storage order of the target dense matrix
474  assign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
475  {
477 
478  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
479  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
480 
481  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
482  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
483 
484  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
485  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
486  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
487  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
488  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
489  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
490 
491  TSMatTDMatMultExpr::selectAssignKernel( ~lhs, A, B );
492  }
494  //**********************************************************************************************
495 
496  //**Assignment to dense matrices (kernel selection)*********************************************
507  template< typename MT3 // Type of the left-hand side target matrix
508  , typename MT4 // Type of the left-hand side matrix operand
509  , typename MT5 > // Type of the right-hand side matrix operand
510  static inline void selectAssignKernel( MT3& C, const MT4& A, const MT5& B )
511  {
512  const size_t size( C.rows() * C.columns() );
513 
514  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATTDMATMULT_THRESHOLD ) ||
515  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
516  selectSmallAssignKernel( C, A, B );
517  else
518  selectLargeAssignKernel( C, A, B );
519  }
521  //**********************************************************************************************
522 
523  //**Default assignment to dense matrices********************************************************
538  template< typename MT3 // Type of the left-hand side target matrix
539  , typename MT4 // Type of the left-hand side matrix operand
540  , typename MT5 > // Type of the right-hand side matrix operand
541  static inline void selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B )
542  {
544 
545  reset( C );
546 
548  {
549  for( size_t i=0UL; i<A.columns(); ++i )
550  {
551  const ConstIterator end( A.end(i) );
552  ConstIterator element( A.begin(i) );
553 
554  for( ; element!=end; ++element ) {
555  C(element->index(),i) = element->value() * B(i,i);
556  }
557  }
558  }
559  else
560  {
561  const size_t block( 64UL );
562 
563  for( size_t jj=0UL; jj<B.columns(); jj+=block )
564  {
565  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
566 
567  for( size_t i=0UL; i<A.columns(); ++i )
568  {
569  const ConstIterator end( A.end(i) );
570  ConstIterator element( A.begin(i) );
571 
572  for( ; element!=end; ++element )
573  {
574  const size_t i1( element->index() );
575 
576  const size_t jbegin( ( IsUpper<MT5>::value )
577  ?( ( SYM || HERM || UPP )
578  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
579  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
580  :( SYM || HERM || UPP ? max(i1,jj) : jj ) );
581  const size_t jend( ( IsLower<MT5>::value )
582  ?( ( LOW )
583  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
584  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
585  :( LOW ? min(i1+1UL,jpos) : jpos ) );
586 
587  if( jbegin >= jend )
588  continue;
589 
590  for( size_t j=jbegin; j<jend; ++j ) {
591  if( isDefault( C(i1,j) ) )
592  C(i1,j) = element->value() * B(i,j);
593  else
594  C(i1,j) += element->value() * B(i,j);
595  }
596  }
597  }
598  }
599  }
600 
601  if( SYM || HERM ) {
602  for( size_t j=0UL; j<B.columns(); ++j ) {
603  for( size_t i=j+1UL; i<A.rows(); ++i ) {
604  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
605  }
606  }
607  }
608  }
610  //**********************************************************************************************
611 
612  //**Default assignment to dense matrices (small matrices)***************************************
626  template< typename MT3 // Type of the left-hand side target matrix
627  , typename MT4 // Type of the left-hand side matrix operand
628  , typename MT5 > // Type of the right-hand side matrix operand
630  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
631  {
632  selectDefaultAssignKernel( C, A, B );
633  }
635  //**********************************************************************************************
636 
637  //**Optimized assignment to dense matrices (small matrices)*************************************
652  template< typename MT3 // Type of the left-hand side target matrix
653  , typename MT4 // Type of the left-hand side matrix operand
654  , typename MT5 > // Type of the right-hand side matrix operand
656  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
657  {
659 
660  const size_t block( IsRowMajorMatrix<MT3>::value ? 128UL : 64UL );
661 
662  for( size_t jj=0UL; jj<B.columns(); jj+=block )
663  {
664  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
665 
666  for( size_t i=0UL; i<A.rows(); ++i ) {
667  for( size_t j=jj; j<jpos; ++j ) {
668  reset( C(i,j) );
669  }
670  }
671 
672  for( size_t i=0UL; i<A.columns(); ++i )
673  {
674  const ConstIterator end( A.end(i) );
675  ConstIterator element( A.begin(i) );
676 
677  const size_t nonzeros( A.nonZeros(i) );
678  const size_t kpos( nonzeros & size_t(-4) );
679  BLAZE_INTERNAL_ASSERT( ( nonzeros - ( nonzeros % 4UL ) ) == kpos, "Invalid end calculation" );
680 
681  for( size_t k=0UL; k<kpos; k+=4UL )
682  {
683  const size_t i1( element->index() );
684  const ET1 v1( element->value() );
685  ++element;
686  const size_t i2( element->index() );
687  const ET1 v2( element->value() );
688  ++element;
689  const size_t i3( element->index() );
690  const ET1 v3( element->value() );
691  ++element;
692  const size_t i4( element->index() );
693  const ET1 v4( element->value() );
694  ++element;
695 
696  BLAZE_INTERNAL_ASSERT( i1 < i2 && i2 < i3 && i3 < i4, "Invalid sparse matrix index detected" );
697 
698  const size_t jbegin( ( IsUpper<MT5>::value )
699  ?( ( SYM || HERM || UPP )
700  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
701  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
702  :( SYM || HERM || UPP ? max(i1,jj) : jj ) );
703  const size_t jend( ( IsLower<MT5>::value )
704  ?( ( LOW )
705  ?( min( i4+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
706  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
707  :( LOW ? min(i4+1UL,jpos) : jpos ) );
708 
709  if( jbegin >= jend )
710  continue;
711 
712  for( size_t j=jbegin; j<jend; ++j ) {
713  C(i1,j) += v1 * B(i,j);
714  C(i2,j) += v2 * B(i,j);
715  C(i3,j) += v3 * B(i,j);
716  C(i4,j) += v4 * B(i,j);
717  }
718  }
719 
720  for( ; element!=end; ++element )
721  {
722  const size_t i1( element->index() );
723 
724  const size_t jbegin( ( IsUpper<MT5>::value )
725  ?( ( SYM || HERM || UPP )
726  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
727  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
728  :( SYM || HERM || UPP ? max(i1,jj) : jj ) );
729  const size_t jend( ( IsLower<MT5>::value )
730  ?( ( LOW )
731  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
732  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
733  :( LOW ? min(i1+1UL,jpos) : jpos ) );
734 
735  if( jbegin >= jend )
736  continue;
737 
738  for( size_t j=jbegin; j<jend; ++j ) {
739  C(i1,j) += element->value() * B(i,j);
740  }
741  }
742  }
743  }
744 
745  if( SYM || HERM ) {
746  for( size_t j=0UL; j<B.columns(); ++j ) {
747  for( size_t i=j+1UL; i<A.rows(); ++i ) {
748  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
749  }
750  }
751  }
752  }
754  //**********************************************************************************************
755 
756  //**Default assignment to dense matrices (large matrices)***************************************
770  template< typename MT3 // Type of the left-hand side target matrix
771  , typename MT4 // Type of the left-hand side matrix operand
772  , typename MT5 > // Type of the right-hand side matrix operand
774  selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B )
775  {
776  selectDefaultAssignKernel( C, A, B );
777  }
779  //**********************************************************************************************
780 
781  //**Optimized assignment to dense matrices (large matrices)*************************************
796  template< typename MT3 // Type of the left-hand side target matrix
797  , typename MT4 // Type of the left-hand side matrix operand
798  , typename MT5 > // Type of the right-hand side matrix operand
800  selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B )
801  {
803 
804  const ForwardFunctor fwd;
805 
806  const OppositeType_<MT4> tmp( serial( A ) );
807  assign( C, fwd( tmp * B ) );
808  }
810  //**********************************************************************************************
811 
812  //**Assignment to sparse matrices***************************************************************
825  template< typename MT // Type of the target sparse matrix
826  , bool SO > // Storage order of the target sparse matrix
828  assign( SparseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
829  {
831 
833 
840 
841  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
842  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
843 
844  const ForwardFunctor fwd;
845 
846  const TmpType tmp( serial( rhs ) );
847  assign( ~lhs, fwd( tmp ) );
848  }
850  //**********************************************************************************************
851 
852  //**Restructuring assignment********************************************************************
867  template< typename MT // Type of the target matrix
868  , bool SO > // Storage order of the target matrix
870  assign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
871  {
873 
875 
876  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
877  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
878 
879  const ForwardFunctor fwd;
880 
882  assign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
883  else if( IsSymmetric<MT1>::value )
884  assign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
885  else
886  assign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
887  }
889  //**********************************************************************************************
890 
891  //**Addition assignment to dense matrices*******************************************************
904  template< typename MT // Type of the target dense matrix
905  , bool SO > // Storage order of the target dense matrix
907  addAssign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
908  {
910 
911  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
912  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
913 
914  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
915  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
916 
917  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
918  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
919  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
920  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
921  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
922  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
923 
924  TSMatTDMatMultExpr::selectAddAssignKernel( ~lhs, A, B );
925  }
927  //**********************************************************************************************
928 
929  //**Addition assignment to dense matrices (kernel selection)************************************
940  template< typename MT3 // Type of the left-hand side target matrix
941  , typename MT4 // Type of the left-hand side matrix operand
942  , typename MT5 > // Type of the right-hand side matrix operand
943  static inline void selectAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
944  {
945  const size_t size( C.rows() * C.columns() );
946 
947  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATTDMATMULT_THRESHOLD ) ||
948  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
949  selectSmallAddAssignKernel( C, A, B );
950  else
951  selectLargeAddAssignKernel( C, A, B );
952  }
954  //**********************************************************************************************
955 
956  //**Default addition assignment to dense matrices***********************************************
971  template< typename MT3 // Type of the left-hand side target matrix
972  , typename MT4 // Type of the left-hand side matrix operand
973  , typename MT5 > // Type of the right-hand side matrix operand
974  static inline void selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
975  {
977 
979  {
980  for( size_t i=0UL; i<A.columns(); ++i )
981  {
982  const ConstIterator end( A.end(i) );
983  ConstIterator element( A.begin(i) );
984 
985  for( ; element!=end; ++element ) {
986  C(element->index(),i) += element->value() * B(i,i);
987  }
988  }
989  }
990  else
991  {
992  const size_t block( 64UL );
993 
994  for( size_t jj=0UL; jj<B.columns(); jj+=block )
995  {
996  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
997 
998  for( size_t i=0UL; i<A.columns(); ++i )
999  {
1000  const ConstIterator end( A.end(i) );
1001  ConstIterator element( A.begin(i) );
1002 
1003  for( ; element!=end; ++element )
1004  {
1005  const size_t i1( element->index() );
1006 
1007  const size_t jbegin( ( IsUpper<MT5>::value )
1008  ?( ( UPP )
1009  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1010  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1011  :( UPP ? max(i1,jj) : jj ) );
1012  const size_t jend( ( IsLower<MT5>::value )
1013  ?( ( LOW )
1014  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1015  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1016  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1017 
1018  if( jbegin >= jend )
1019  continue;
1020 
1021  for( size_t j=jbegin; j<jend; ++j ) {
1022  C(i1,j) += element->value() * B(i,j);
1023  }
1024  }
1025  }
1026  }
1027  }
1028  }
1030  //**********************************************************************************************
1031 
1032  //**Default addition assignment to dense matrices (small matrices)******************************
1046  template< typename MT3 // Type of the left-hand side target matrix
1047  , typename MT4 // Type of the left-hand side matrix operand
1048  , typename MT5 > // Type of the right-hand side matrix operand
1050  selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1051  {
1052  selectDefaultAddAssignKernel( C, A, B );
1053  }
1055  //**********************************************************************************************
1056 
1057  //**Optimized addition 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
1076  selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1077  {
1079 
1080  const size_t block( IsRowMajorMatrix<MT3>::value ? 128UL : 64UL );
1081 
1082  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1083  {
1084  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1085 
1086  for( size_t i=0UL; i<A.columns(); ++i )
1087  {
1088  const ConstIterator end( A.end(i) );
1089  ConstIterator element( A.begin(i) );
1090 
1091  const size_t nonzeros( A.nonZeros(i) );
1092  const size_t kpos( nonzeros & size_t(-4) );
1093  BLAZE_INTERNAL_ASSERT( ( nonzeros - ( nonzeros % 4UL ) ) == kpos, "Invalid end calculation" );
1094 
1095  for( size_t k=0UL; k<kpos; k+=4UL )
1096  {
1097  const size_t i1( element->index() );
1098  const ET1 v1( element->value() );
1099  ++element;
1100  const size_t i2( element->index() );
1101  const ET1 v2( element->value() );
1102  ++element;
1103  const size_t i3( element->index() );
1104  const ET1 v3( element->value() );
1105  ++element;
1106  const size_t i4( element->index() );
1107  const ET1 v4( element->value() );
1108  ++element;
1109 
1110  BLAZE_INTERNAL_ASSERT( i1 < i2 && i2 < i3 && i3 < i4, "Invalid sparse matrix index detected" );
1111 
1112  const size_t jbegin( ( IsUpper<MT5>::value )
1113  ?( ( UPP )
1114  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1115  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1116  :( UPP ? max(i1,jj) : jj ) );
1117  const size_t jend( ( IsLower<MT5>::value )
1118  ?( ( LOW )
1119  ?( min( i4+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1120  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1121  :( LOW ? min(i4+1UL,jpos) : jpos ) );
1122 
1123  if( jbegin >= jend )
1124  continue;
1125 
1126  for( size_t j=jbegin; j<jend; ++j ) {
1127  C(i1,j) += v1 * B(i,j);
1128  C(i2,j) += v2 * B(i,j);
1129  C(i3,j) += v3 * B(i,j);
1130  C(i4,j) += v4 * B(i,j);
1131  }
1132  }
1133 
1134  for( ; element!=end; ++element )
1135  {
1136  const size_t i1( element->index() );
1137 
1138  const size_t jbegin( ( IsUpper<MT5>::value )
1139  ?( ( UPP )
1140  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1141  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1142  :( UPP ? max(i1,jj) : jj ) );
1143  const size_t jend( ( IsLower<MT5>::value )
1144  ?( ( LOW )
1145  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1146  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1147  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1148 
1149  if( jbegin >= jend )
1150  continue;
1151 
1152  for( size_t j=jbegin; j<jend; ++j ) {
1153  C(i1,j) += element->value() * B(i,j);
1154  }
1155  }
1156  }
1157  }
1158  }
1160  //**********************************************************************************************
1161 
1162  //**Default addition assignment to dense matrices (large matrices)******************************
1176  template< typename MT3 // Type of the left-hand side target matrix
1177  , typename MT4 // Type of the left-hand side matrix operand
1178  , typename MT5 > // Type of the right-hand side matrix operand
1180  selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1181  {
1182  selectDefaultAddAssignKernel( C, A, B );
1183  }
1185  //**********************************************************************************************
1186 
1187  //**Optimized addition assignment to dense matrices (large matrices)****************************
1202  template< typename MT3 // Type of the left-hand side target matrix
1203  , typename MT4 // Type of the left-hand side matrix operand
1204  , typename MT5 > // Type of the right-hand side matrix operand
1206  selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1207  {
1209 
1210  const ForwardFunctor fwd;
1211 
1212  const OppositeType_<MT4> tmp( serial( A ) );
1213  addAssign( C, fwd( tmp * B ) );
1214  }
1216  //**********************************************************************************************
1217 
1218  //**Restructuring addition assignment***********************************************************
1233  template< typename MT // Type of the target matrix
1234  , bool SO > // Storage order of the target matrix
1236  addAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1237  {
1239 
1241 
1242  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1243  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1244 
1245  const ForwardFunctor fwd;
1246 
1248  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1249  else if( IsSymmetric<MT1>::value )
1250  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1251  else
1252  addAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1253  }
1255  //**********************************************************************************************
1256 
1257  //**Addition assignment to sparse matrices******************************************************
1258  // No special implementation for the addition assignment to sparse matrices.
1259  //**********************************************************************************************
1260 
1261  //**Subtraction assignment to dense matrices****************************************************
1274  template< typename MT // Type of the target dense matrix
1275  , bool SO > // Storage order of the target dense matrix
1277  subAssign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1278  {
1280 
1281  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1282  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1283 
1284  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
1285  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
1286 
1287  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1288  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1289  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1290  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1291  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1292  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1293 
1294  TSMatTDMatMultExpr::selectSubAssignKernel( ~lhs, A, B );
1295  }
1297  //**********************************************************************************************
1298 
1299  //**Subtraction assignment to dense matrices (kernel selection)*********************************
1310  template< typename MT3 // Type of the left-hand side target matrix
1311  , typename MT4 // Type of the left-hand side matrix operand
1312  , typename MT5 > // Type of the right-hand side matrix operand
1313  static inline void selectSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1314  {
1315  const size_t size( C.rows() * C.columns() );
1316 
1317  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATTDMATMULT_THRESHOLD ) ||
1318  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
1319  selectSmallSubAssignKernel( C, A, B );
1320  else
1321  selectLargeSubAssignKernel( C, A, B );
1322  }
1324  //**********************************************************************************************
1325 
1326  //**Default subtraction assignment to dense matrices********************************************
1341  template< typename MT3 // Type of the left-hand side target matrix
1342  , typename MT4 // Type of the left-hand side matrix operand
1343  , typename MT5 > // Type of the right-hand side matrix operand
1344  static inline void selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1345  {
1347 
1349  {
1350  for( size_t i=0UL; i<A.columns(); ++i )
1351  {
1352  const ConstIterator end( A.end(i) );
1353  ConstIterator element( A.begin(i) );
1354 
1355  for( ; element!=end; ++element ) {
1356  C(element->index(),i) -= element->value() * B(i,i);
1357  }
1358  }
1359  }
1360  else
1361  {
1362  const size_t block( 64UL );
1363 
1364  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1365  {
1366  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1367 
1368  for( size_t i=0UL; i<A.columns(); ++i )
1369  {
1370  const ConstIterator end( A.end(i) );
1371  ConstIterator element( A.begin(i) );
1372 
1373  for( ; element!=end; ++element )
1374  {
1375  const size_t i1( element->index() );
1376 
1377  const size_t jbegin( ( IsUpper<MT5>::value )
1378  ?( ( UPP )
1379  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1380  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1381  :( UPP ? max(i1,jj) : jj ) );
1382  const size_t jend( ( IsLower<MT5>::value )
1383  ?( ( LOW )
1384  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1385  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1386  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1387 
1388  if( jbegin >= jend )
1389  continue;
1390 
1391  for( size_t j=jbegin; j<jend; ++j ) {
1392  C(i1,j) -= element->value() * B(i,j);
1393  }
1394  }
1395  }
1396  }
1397  }
1398  }
1400  //**********************************************************************************************
1401 
1402  //**Default subtraction assignment to dense matrices (small matrices)***************************
1416  template< typename MT3 // Type of the left-hand side target matrix
1417  , typename MT4 // Type of the left-hand side matrix operand
1418  , typename MT5 > // Type of the right-hand side matrix operand
1420  selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1421  {
1422  selectDefaultSubAssignKernel( C, A, B );
1423  }
1425  //**********************************************************************************************
1426 
1427  //**Optimized subtraction assignment to dense matrices (small matrices)*************************
1442  template< typename MT3 // Type of the left-hand side target matrix
1443  , typename MT4 // Type of the left-hand side matrix operand
1444  , typename MT5 > // Type of the right-hand side matrix operand
1446  selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1447  {
1449 
1450  const size_t block( IsRowMajorMatrix<MT3>::value ? 128UL : 64UL );
1451 
1452  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1453  {
1454  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1455 
1456  for( size_t i=0UL; i<A.columns(); ++i )
1457  {
1458  const ConstIterator end( A.end(i) );
1459  ConstIterator element( A.begin(i) );
1460 
1461  const size_t nonzeros( A.nonZeros(i) );
1462  const size_t kpos( nonzeros & size_t(-4) );
1463  BLAZE_INTERNAL_ASSERT( ( nonzeros - ( nonzeros % 4UL ) ) == kpos, "Invalid end calculation" );
1464 
1465  for( size_t k=0UL; k<kpos; k+=4UL )
1466  {
1467  const size_t i1( element->index() );
1468  const ET1 v1( element->value() );
1469  ++element;
1470  const size_t i2( element->index() );
1471  const ET1 v2( element->value() );
1472  ++element;
1473  const size_t i3( element->index() );
1474  const ET1 v3( element->value() );
1475  ++element;
1476  const size_t i4( element->index() );
1477  const ET1 v4( element->value() );
1478  ++element;
1479 
1480  BLAZE_INTERNAL_ASSERT( i1 < i2 && i2 < i3 && i3 < i4, "Invalid sparse matrix index detected" );
1481 
1482  const size_t jbegin( ( IsUpper<MT5>::value )
1483  ?( ( UPP )
1484  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1485  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1486  :( UPP ? max(i1,jj) : jj ) );
1487  const size_t jend( ( IsLower<MT5>::value )
1488  ?( ( LOW )
1489  ?( min( i4+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1490  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1491  :( LOW ? min(i4+1UL,jpos) : jpos ) );
1492 
1493  if( jbegin >= jend )
1494  continue;
1495 
1496  for( size_t j=jbegin; j<jend; ++j ) {
1497  C(i1,j) -= v1 * B(i,j);
1498  C(i2,j) -= v2 * B(i,j);
1499  C(i3,j) -= v3 * B(i,j);
1500  C(i4,j) -= v4 * B(i,j);
1501  }
1502  }
1503 
1504  for( ; element!=end; ++element )
1505  {
1506  const size_t i1( element->index() );
1507 
1508  const size_t jbegin( ( IsUpper<MT5>::value )
1509  ?( ( UPP )
1510  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1511  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1512  :( UPP ? max(i1,jj) : jj ) );
1513  const size_t jend( ( IsLower<MT5>::value )
1514  ?( ( LOW )
1515  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1516  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1517  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1518 
1519  if( jbegin >= jend )
1520  continue;
1521 
1522  for( size_t j=jbegin; j<jend; ++j ) {
1523  C(i1,j) -= element->value() * B(i,j);
1524  }
1525  }
1526  }
1527  }
1528  }
1530  //**********************************************************************************************
1531 
1532  //**Default subtraction assignment to dense matrices (large matrices)***************************
1546  template< typename MT3 // Type of the left-hand side target matrix
1547  , typename MT4 // Type of the left-hand side matrix operand
1548  , typename MT5 > // Type of the right-hand side matrix operand
1550  selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1551  {
1552  selectDefaultSubAssignKernel( C, A, B );
1553  }
1555  //**********************************************************************************************
1556 
1557  //**Optimized subtraction assignment to dense matrices (large matrices)*************************
1572  template< typename MT3 // Type of the left-hand side target matrix
1573  , typename MT4 // Type of the left-hand side matrix operand
1574  , typename MT5 > // Type of the right-hand side matrix operand
1576  selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1577  {
1579 
1580  const ForwardFunctor fwd;
1581 
1582  const OppositeType_<MT4> tmp( serial( A ) );
1583  subAssign( C, fwd( tmp * B ) );
1584  }
1586  //**********************************************************************************************
1587 
1588  //**Restructuring subtraction assignment********************************************************
1603  template< typename MT // Type of the target matrix
1604  , bool SO > // Storage order of the target matrix
1606  subAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1607  {
1609 
1611 
1612  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1613  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1614 
1615  const ForwardFunctor fwd;
1616 
1618  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1619  else if( IsSymmetric<MT1>::value )
1620  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1621  else
1622  subAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1623  }
1625  //**********************************************************************************************
1626 
1627  //**Subtraction assignment to sparse matrices***************************************************
1628  // No special implementation for the subtraction assignment to sparse matrices.
1629  //**********************************************************************************************
1630 
1631  //**Multiplication assignment to dense matrices*************************************************
1632  // No special implementation for the multiplication assignment to dense matrices.
1633  //**********************************************************************************************
1634 
1635  //**Multiplication assignment to sparse matrices************************************************
1636  // No special implementation for the multiplication assignment to sparse matrices.
1637  //**********************************************************************************************
1638 
1639  //**SMP assignment to dense matrices************************************************************
1655  template< typename MT // Type of the target dense matrix
1656  , bool SO > // Storage order of the target dense matrix
1658  smpAssign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1659  {
1661 
1662  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1663  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1664 
1665  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1666  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1667 
1668  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1669  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1670  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1671  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1672  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1673  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1674 
1675  smpAssign( ~lhs, A * B );
1676  }
1678  //**********************************************************************************************
1679 
1680  //**SMP assignment to sparse matrices***********************************************************
1696  template< typename MT // Type of the target sparse matrix
1697  , bool SO > // Storage order of the target sparse matrix
1700  {
1702 
1704 
1711 
1712  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1713  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1714 
1715  const ForwardFunctor fwd;
1716 
1717  const TmpType tmp( rhs );
1718  smpAssign( ~lhs, fwd( tmp ) );
1719  }
1721  //**********************************************************************************************
1722 
1723  //**Restructuring SMP assignment****************************************************************
1738  template< typename MT // Type of the target matrix
1739  , bool SO > // Storage order of the target matrix
1741  smpAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1742  {
1744 
1746 
1747  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1748  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1749 
1750  const ForwardFunctor fwd;
1751 
1753  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1754  else if( IsSymmetric<MT1>::value )
1755  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1756  else
1757  smpAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1758  }
1760  //**********************************************************************************************
1761 
1762  //**SMP addition assignment to dense matrices***************************************************
1778  template< typename MT // Type of the target dense matrix
1779  , bool SO > // Storage order of the target dense matrix
1782  {
1784 
1785  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1786  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1787 
1788  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1789  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1790 
1791  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1792  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1793  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1794  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1795  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1796  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1797 
1798  smpAddAssign( ~lhs, A * B );
1799  }
1801  //**********************************************************************************************
1802 
1803  //**Restructuring SMP addition assignment*******************************************************
1818  template< typename MT // Type of the target matrix
1819  , bool SO > // Storage order of the target matrix
1821  smpAddAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1822  {
1824 
1826 
1827  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1828  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1829 
1830  const ForwardFunctor fwd;
1831 
1833  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1834  else if( IsSymmetric<MT1>::value )
1835  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1836  else
1837  smpAddAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1838  }
1840  //**********************************************************************************************
1841 
1842  //**SMP addition assignment to sparse matrices**************************************************
1843  // No special implementation for the SMP addition assignment to sparse matrices.
1844  //**********************************************************************************************
1845 
1846  //**SMP subtraction assignment to dense matrices************************************************
1862  template< typename MT // Type of the target dense matrix
1863  , bool SO > // Storage order of the target dense matrix
1866  {
1868 
1869  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1870  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1871 
1872  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1873  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1874 
1875  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1876  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1877  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1878  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1879  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1880  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1881 
1882  smpSubAssign( ~lhs, A * B );
1883  }
1885  //**********************************************************************************************
1886 
1887  //**Restructuring SMP subtraction assignment****************************************************
1902  template< typename MT // Type of the target matrix
1903  , bool SO > // Storage order of the target matrix
1905  smpSubAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1906  {
1908 
1910 
1911  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1912  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1913 
1914  const ForwardFunctor fwd;
1915 
1917  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1918  else if( IsSymmetric<MT1>::value )
1919  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1920  else
1921  smpSubAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1922  }
1924  //**********************************************************************************************
1925 
1926  //**SMP subtraction assignment to sparse matrices***********************************************
1927  // No special implementation for the SMP subtraction assignment to sparse matrices.
1928  //**********************************************************************************************
1929 
1930  //**SMP multiplication assignment to dense matrices*********************************************
1931  // No special implementation for the SMP multiplication assignment to dense matrices.
1932  //**********************************************************************************************
1933 
1934  //**SMP multiplication assignment to sparse matrices********************************************
1935  // No special implementation for the SMP multiplication assignment to sparse matrices.
1936  //**********************************************************************************************
1937 
1938  //**Compile time checks*************************************************************************
1946  //**********************************************************************************************
1947 };
1948 //*************************************************************************************************
1949 
1950 
1951 
1952 
1953 //=================================================================================================
1954 //
1955 // GLOBAL BINARY ARITHMETIC OPERATORS
1956 //
1957 //=================================================================================================
1958 
1959 //*************************************************************************************************
1988 template< typename T1 // Type of the left-hand side sparse matrix
1989  , typename T2 > // Type of the right-hand side dense matrix
1992 {
1994 
1995  if( (~lhs).columns() != (~rhs).rows() ) {
1996  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1997  }
1998 
2000 }
2001 //*************************************************************************************************
2002 
2003 
2004 
2005 
2006 //=================================================================================================
2007 //
2008 // GLOBAL FUNCTIONS
2009 //
2010 //=================================================================================================
2011 
2012 //*************************************************************************************************
2036 template< typename MT1 // Type of the left-hand side dense matrix
2037  , typename MT2 // Type of the right-hand side dense matrix
2038  , bool SF // Symmetry flag
2039  , bool HF // Hermitian flag
2040  , bool LF // Lower flag
2041  , bool UF > // Upper flag
2044 {
2046 
2047  if( !isSquare( dm ) ) {
2048  BLAZE_THROW_INVALID_ARGUMENT( "Invalid symmetric matrix specification" );
2049  }
2050 
2051  return TSMatTDMatMultExpr<MT1,MT2,true,HF,LF,UF>( dm.leftOperand(), dm.rightOperand() );
2052 }
2054 //*************************************************************************************************
2055 
2056 
2057 //*************************************************************************************************
2081 template< typename MT1 // Type of the left-hand side dense matrix
2082  , typename MT2 // Type of the right-hand side dense matrix
2083  , bool SF // Symmetry flag
2084  , bool HF // Hermitian flag
2085  , bool LF // Lower flag
2086  , bool UF > // Upper flag
2089 {
2091 
2092  if( !isSquare( dm ) ) {
2093  BLAZE_THROW_INVALID_ARGUMENT( "Invalid Hermitian matrix specification" );
2094  }
2095 
2096  return TSMatTDMatMultExpr<MT1,MT2,SF,true,LF,UF>( dm.leftOperand(), dm.rightOperand() );
2097 }
2099 //*************************************************************************************************
2100 
2101 
2102 //*************************************************************************************************
2126 template< typename MT1 // Type of the left-hand side dense matrix
2127  , typename MT2 // Type of the right-hand side dense matrix
2128  , bool SF // Symmetry flag
2129  , bool HF // Hermitian flag
2130  , bool LF // Lower flag
2131  , bool UF > // Upper flag
2134 {
2136 
2137  if( !isSquare( dm ) ) {
2138  BLAZE_THROW_INVALID_ARGUMENT( "Invalid lower matrix specification" );
2139  }
2140 
2141  return TSMatTDMatMultExpr<MT1,MT2,SF,HF,true,UF>( dm.leftOperand(), dm.rightOperand() );
2142 }
2144 //*************************************************************************************************
2145 
2146 
2147 //*************************************************************************************************
2171 template< typename MT1 // Type of the left-hand side dense matrix
2172  , typename MT2 // Type of the right-hand side dense matrix
2173  , bool SF // Symmetry flag
2174  , bool HF // Hermitian flag
2175  , bool LF // Lower flag
2176  , bool UF > // Upper flag
2179 {
2181 
2182  if( !isSquare( dm ) ) {
2183  BLAZE_THROW_INVALID_ARGUMENT( "Invalid upper matrix specification" );
2184  }
2185 
2186  return TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,true>( dm.leftOperand(), dm.rightOperand() );
2187 }
2189 //*************************************************************************************************
2190 
2191 
2192 //*************************************************************************************************
2216 template< typename MT1 // Type of the left-hand side dense matrix
2217  , typename MT2 // Type of the right-hand side dense matrix
2218  , bool SF // Symmetry flag
2219  , bool HF // Hermitian flag
2220  , bool LF // Lower flag
2221  , bool UF > // Upper flag
2224 {
2226 
2227  if( !isSquare( dm ) ) {
2228  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
2229  }
2230 
2231  return TSMatTDMatMultExpr<MT1,MT2,SF,HF,true,true>( dm.leftOperand(), dm.rightOperand() );
2232 }
2234 //*************************************************************************************************
2235 
2236 
2237 
2238 
2239 //=================================================================================================
2240 //
2241 // ROWS SPECIALIZATIONS
2242 //
2243 //=================================================================================================
2244 
2245 //*************************************************************************************************
2247 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2248 struct Rows< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public Rows<MT1>
2249 {};
2251 //*************************************************************************************************
2252 
2253 
2254 
2255 
2256 //=================================================================================================
2257 //
2258 // COLUMNS SPECIALIZATIONS
2259 //
2260 //=================================================================================================
2261 
2262 //*************************************************************************************************
2264 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2265 struct Columns< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public Columns<MT2>
2266 {};
2268 //*************************************************************************************************
2269 
2270 
2271 
2272 
2273 //=================================================================================================
2274 //
2275 // ISALIGNED SPECIALIZATIONS
2276 //
2277 //=================================================================================================
2278 
2279 //*************************************************************************************************
2281 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2282 struct IsAligned< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2283  : public BoolConstant< IsAligned<MT2>::value >
2284 {};
2286 //*************************************************************************************************
2287 
2288 
2289 
2290 
2291 //=================================================================================================
2292 //
2293 // ISSYMMETRIC SPECIALIZATIONS
2294 //
2295 //=================================================================================================
2296 
2297 //*************************************************************************************************
2299 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2300 struct IsSymmetric< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2301  : public BoolConstant< Or< Bool<SF>
2302  , And< Bool<HF>
2303  , IsBuiltin< ElementType_< TSMatTDMatMultExpr<MT1,MT2,false,true,false,false> > > >
2304  , And< Bool<LF>, Bool<UF> > >::value >
2305 {};
2307 //*************************************************************************************************
2308 
2309 
2310 
2311 
2312 //=================================================================================================
2313 //
2314 // ISHERMITIAN SPECIALIZATIONS
2315 //
2316 //=================================================================================================
2317 
2318 //*************************************************************************************************
2320 template< typename MT1, typename MT2, bool SF, bool LF, bool UF >
2321 struct IsHermitian< TSMatTDMatMultExpr<MT1,MT2,SF,true,LF,UF> >
2322  : public TrueType
2323 {};
2325 //*************************************************************************************************
2326 
2327 
2328 
2329 
2330 //=================================================================================================
2331 //
2332 // ISLOWER SPECIALIZATIONS
2333 //
2334 //=================================================================================================
2335 
2336 //*************************************************************************************************
2338 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2339 struct IsLower< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2340  : public BoolConstant< Or< Bool<LF>
2341  , And< IsLower<MT1>, IsLower<MT2> >
2342  , And< Or< Bool<SF>, Bool<HF> >
2343  , IsUpper<MT1>, IsUpper<MT2> > >::value >
2344 {};
2346 //*************************************************************************************************
2347 
2348 
2349 
2350 
2351 //=================================================================================================
2352 //
2353 // ISUNILOWER SPECIALIZATIONS
2354 //
2355 //=================================================================================================
2356 
2357 //*************************************************************************************************
2359 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2360 struct IsUniLower< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2361  : public BoolConstant< Or< And< IsUniLower<MT1>, IsUniLower<MT2> >
2362  , And< Or< Bool<SF>, Bool<HF> >
2363  , IsUniUpper<MT1>, IsUniUpper<MT2> > >::value >
2364 {};
2366 //*************************************************************************************************
2367 
2368 
2369 
2370 
2371 //=================================================================================================
2372 //
2373 // ISSTRICTLYLOWER SPECIALIZATIONS
2374 //
2375 //=================================================================================================
2376 
2377 //*************************************************************************************************
2379 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2380 struct IsStrictlyLower< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2381  : public BoolConstant< Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2382  , And< IsStrictlyLower<MT2>, IsLower<MT1> >
2383  , And< Or< Bool<SF>, Bool<HF> >
2384  , Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2385  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > > > >::value >
2386 {};
2388 //*************************************************************************************************
2389 
2390 
2391 
2392 
2393 //=================================================================================================
2394 //
2395 // ISUPPER SPECIALIZATIONS
2396 //
2397 //=================================================================================================
2398 
2399 //*************************************************************************************************
2401 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2402 struct IsUpper< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2403  : public BoolConstant< Or< Bool<UF>
2404  , And< IsUpper<MT1>, IsUpper<MT2> >
2405  , And< Or< Bool<SF>, Bool<HF> >
2406  , IsLower<MT1>, IsLower<MT2> > >::value >
2407 {};
2409 //*************************************************************************************************
2410 
2411 
2412 
2413 
2414 //=================================================================================================
2415 //
2416 // ISUNIUPPER SPECIALIZATIONS
2417 //
2418 //=================================================================================================
2419 
2420 //*************************************************************************************************
2422 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2423 struct IsUniUpper< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2424  : public BoolConstant< Or< And< IsUniUpper<MT1>, IsUniUpper<MT2> >
2425  , And< Or< Bool<SF>, Bool<HF> >
2426  , IsUniLower<MT1>, IsUniLower<MT2> > >::value >
2427 {};
2429 //*************************************************************************************************
2430 
2431 
2432 
2433 
2434 //=================================================================================================
2435 //
2436 // ISSTRICTLYUPPER SPECIALIZATIONS
2437 //
2438 //=================================================================================================
2439 
2440 //*************************************************************************************************
2442 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2443 struct IsStrictlyUpper< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2444  : public BoolConstant< Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2445  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> >
2446  , And< Or< Bool<SF>, Bool<HF> >
2447  , Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2448  , And< IsStrictlyLower<MT2>, IsLower<MT1> > > > >::value >
2449 {};
2451 //*************************************************************************************************
2452 
2453 
2454 
2455 
2456 //=================================================================================================
2457 //
2458 // EXPRESSION TRAIT SPECIALIZATIONS
2459 //
2460 //=================================================================================================
2461 
2462 //*************************************************************************************************
2464 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF, typename VT >
2465 struct TDMatDVecMultExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, VT >
2466 {
2467  public:
2468  //**********************************************************************************************
2473  , INVALID_TYPE >;
2474  //**********************************************************************************************
2475 };
2477 //*************************************************************************************************
2478 
2479 
2480 //*************************************************************************************************
2482 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF, typename VT >
2483 struct TDMatSVecMultExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, VT >
2484 {
2485  public:
2486  //**********************************************************************************************
2491  , INVALID_TYPE >;
2492  //**********************************************************************************************
2493 };
2495 //*************************************************************************************************
2496 
2497 
2498 //*************************************************************************************************
2500 template< typename VT, typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2501 struct TDVecTDMatMultExprTrait< VT, TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2502 {
2503  public:
2504  //**********************************************************************************************
2509  , INVALID_TYPE >;
2510  //**********************************************************************************************
2511 };
2513 //*************************************************************************************************
2514 
2515 
2516 //*************************************************************************************************
2518 template< typename VT, typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2519 struct TSVecTDMatMultExprTrait< VT, TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2520 {
2521  public:
2522  //**********************************************************************************************
2527  , INVALID_TYPE >;
2528  //**********************************************************************************************
2529 };
2531 //*************************************************************************************************
2532 
2533 
2534 //*************************************************************************************************
2536 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2537 struct TDMatDeclSymExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2538 {
2539  public:
2540  //**********************************************************************************************
2544  , INVALID_TYPE >;
2545  //**********************************************************************************************
2546 };
2548 //*************************************************************************************************
2549 
2550 
2551 //*************************************************************************************************
2553 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2554 struct TDMatDeclHermExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2555 {
2556  public:
2557  //**********************************************************************************************
2561  , INVALID_TYPE >;
2562  //**********************************************************************************************
2563 };
2565 //*************************************************************************************************
2566 
2567 
2568 //*************************************************************************************************
2570 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2571 struct TDMatDeclLowExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2572 {
2573  public:
2574  //**********************************************************************************************
2578  , INVALID_TYPE >;
2579  //**********************************************************************************************
2580 };
2582 //*************************************************************************************************
2583 
2584 
2585 //*************************************************************************************************
2587 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2588 struct TDMatDeclUppExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2589 {
2590  public:
2591  //**********************************************************************************************
2595  , INVALID_TYPE >;
2596  //**********************************************************************************************
2597 };
2599 //*************************************************************************************************
2600 
2601 
2602 //*************************************************************************************************
2604 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2605 struct TDMatDeclDiagExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2606 {
2607  public:
2608  //**********************************************************************************************
2612  , INVALID_TYPE >;
2613  //**********************************************************************************************
2614 };
2616 //*************************************************************************************************
2617 
2618 
2619 //*************************************************************************************************
2621 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF, bool AF >
2622 struct SubmatrixExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, AF >
2623 {
2624  public:
2625  //**********************************************************************************************
2628  //**********************************************************************************************
2629 };
2631 //*************************************************************************************************
2632 
2633 
2634 //*************************************************************************************************
2636 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2637 struct RowExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2638 {
2639  public:
2640  //**********************************************************************************************
2641  using Type = MultExprTrait_< RowExprTrait_<const MT1>, MT2 >;
2642  //**********************************************************************************************
2643 };
2645 //*************************************************************************************************
2646 
2647 
2648 //*************************************************************************************************
2650 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2651 struct ColumnExprTrait< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2652 {
2653  public:
2654  //**********************************************************************************************
2656  //**********************************************************************************************
2657 };
2659 //*************************************************************************************************
2660 
2661 } // namespace blaze
2662 
2663 #endif
typename SubmatrixExprTrait< MT, AF >::Type SubmatrixExprTrait_
Auxiliary alias declaration for the SubmatrixExprTrait type trait.The SubmatrixExprTrait_ alias decla...
Definition: SubmatrixExprTrait.h:134
ElementType_< RT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: TSMatTDMatMultExpr.h:153
#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
Evaluation of the expression type of a dense matrix declherm operation.Via this type trait it is poss...
Definition: TDMatDeclHermExprTrait.h:75
Compile time check for row vector types.This type trait tests whether or not the given template argum...
Definition: IsRowVector.h:80
const DMatForEachExpr< MT, Conj, SO > conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatForEachExpr.h:1214
Header file for auxiliary alias declarations.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:72
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: TSMatTDMatMultExpr.h:447
Evaluation of the expression type of a dense matrix decllow operation.Via this type trait it is possi...
Definition: TDMatDeclLowExprTrait.h:75
Header file for mathematical functions.
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
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.
Expression object for transpose sparse matrix-transpose dense matrix multiplications.The TSMatTDMatMultExpr class represents the compile time expression for multiplications between a column-major sparse matrix and a column-major dense matrix.
Definition: Forward.h:156
Flag for Hermitian matrices.
Definition: TSMatTDMatMultExpr.h:173
ElementType_< RT2 > ET2
Element type of the right-hand side sparse matrix expression.
Definition: TSMatTDMatMultExpr.h:154
typename TSVecTDMatMultExprTrait< VT, MT >::Type TSVecTDMatMultExprTrait_
Auxiliary alias declaration for the TSVecTDMatMultExprTrait class template.The TSVecTDMatMultExprTrai...
Definition: TSVecTDMatMultExprTrait.h:124
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the IsSparseMatrix type trait.
TSMatTDMatMultExpr< MT1, MT2, SF, HF, LF, UF > This
Type of this TSMatTDMatMultExpr instance.
Definition: TSMatTDMatMultExpr.h:257
Header file for the serial shim.
Header file for the IsDiagonal type trait.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:261
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
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: TSMatTDMatMultExpr.h:437
Header file for the ColumnExprTrait class template.
Header file for the DeclUpp functor.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: TSMatTDMatMultExpr.h:427
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:194
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: TSMatTDMatMultExpr.h:259
Header file for the TSVecTSMatMultExprTrait class template.
Header file for the IsRowVector type trait.
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
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:1755
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatTDMatMultExpr.h:263
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
Evaluation of the expression type of a sparse vector/transpose dense matrix multiplication.Via this type trait it is possible to evaluate the resulting expression type of a sparse vector/transpose dense matrix multiplication. Given the transpose sparse vector type VT and the column-major dense matrix type MT, the nested type Type corresponds to the resulting expression type. In case either VT is not a transpose sparse vector type or MT is not a column-major dense matrix type, the resulting data type Type is set to INVALID_TYPE.
Definition: TSVecTDMatMultExprTrait.h:81
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
DisableIf_< IsSymmetric< MT >, const DMatDeclSymExpr< MT, SO > > declsym(const DenseMatrix< MT, SO > &dm)
Declares the given non-symmetric dense matrix expression dm as symmetric.
Definition: DMatDeclSymExpr.h:841
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.
CompositeType_< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: TSMatTDMatMultExpr.h:156
Header file for the TDMatDeclDiagExprTrait class template.
Header file for the RequiresEvaluation type trait.
System settings for performance optimizations.
Header file for the IsUniLower type trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
RightOperand rhs_
Right-hand side dense matrix of the multiplication expression.
Definition: TSMatTDMatMultExpr.h:455
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:71
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:119
Constraint on the data type.
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
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.
typename MultExprTrait< T1, T2 >::Type MultExprTrait_
Auxiliary alias declaration for the MultExprTrait class template.The MultExprTrait_ alias declaration...
Definition: MultExprTrait.h:344
Header file for the MultExprTrait class template.
DisableIf_< IsHermitian< MT >, const DMatDeclHermExpr< MT, SO > > declherm(const DenseMatrix< MT, SO > &dm)
Declares the given non-Hermitian dense matrix expression dm as Hermitian.
Definition: DMatDeclHermExpr.h:841
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:72
SubvectorExprTrait_< VT, unaligned > subvector(Vector< VT, TF > &vector, size_t index, size_t size)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:152
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: TSMatTDMatMultExpr.h:415
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:86
Header file for the DisableIf class template.
Compile time check for dense vector types.This type trait tests whether or not the given template par...
Definition: IsDenseVector.h:78
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
CompositeType_< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatTDMatMultExpr.h:155
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the DeclLow functor.
Header file for the If class template.
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:83
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
Header file for the TSVecTDMatMultExprTrait class template.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
Evaluation of the expression type of a dense matrix declupp operation.Via this type trait it is possi...
Definition: TDMatDeclUppExprTrait.h:75
ResultType_< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: TSMatTDMatMultExpr.h:152
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:98
Header file for the Or class template.
Header file for the TDMatSVecMultExprTrait class template.
Header file for the TDVecTSMatMultExprTrait class template.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TSMatTDMatMultExpr.h:309
Header file for the TDMatDeclHermExprTrait class template.
#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.
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatTDMatMultExpr.h:454
Header file for the TSMatDVecMultExprTrait class template.
If_< IsExpression< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatTDMatMultExpr.h:267
Header file for the TDMatDeclUppExprTrait class template.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
TSMatTDMatMultExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the TSMatTDMatMultExpr class.
Definition: TSMatTDMatMultExpr.h:294
Evaluation of the expression type of a dense matrix decldiag operation.Via this type trait it is poss...
Definition: TDMatDeclDiagExprTrait.h:75
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:78
Evaluation of the expression type type of a submatrix operation.Via this type trait it is possible to...
Definition: SubmatrixExprTrait.h:80
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
typename TSMatDVecMultExprTrait< MT, VT >::Type TSMatDVecMultExprTrait_
Auxiliary alias declaration for the TSMatDVecMultExprTrait class template.The TSMatDVecMultExprTrait_...
Definition: TSMatDVecMultExprTrait.h:124
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:128
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:60
Generic wrapper for the null function.
Definition: Noop.h:58
Header file for the IsTriangular type trait.
Compile time check for column vector types.This type trait tests whether or not the given template ar...
Definition: IsColumnVector.h:80
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: TSMatTDMatMultExpr.h:373
Evaluation of the expression type of a dense matrix declsym operation.Via this type trait it is possi...
Definition: TDMatDeclSymExprTrait.h:75
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatTDMatMultExpr.h:393
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.
DisableIf_< IsLower< MT >, const DMatDeclLowExpr< MT, SO > > decllow(const DenseMatrix< MT, SO > &dm)
Declares the given non-lower dense matrix expression dm as lower.
Definition: DMatDeclLowExpr.h:842
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
Evaluation of the expression type type of a row operation.Via this type trait it is possible to evalu...
Definition: RowExprTrait.h:79
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:260
Header file for the DeclDiag functor.
Compile time check for dense matrix types.This type trait tests whether or not the given template par...
Definition: IsDenseMatrix.h:78
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Header file for the IsDenseMatrix type trait.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:128
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatMultExpr.h:109
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:86
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
Evaluation of the expression type of a transpose dense matrix/sparse vector multiplication.Via this type trait it is possible to evaluate the resulting expression type of a transpose dense matrix/sparse vector multiplication. Given the column-major dense matrix type MT and the non-transpose sparse vector type VT, the nested type Type corresponds to the resulting expression type. In case either MT is not a column-major dense matrix type or VT is not a non-transpose sparse vector type, the resulting data type Type is set to INVALID_TYPE.
Definition: TDMatSVecMultExprTrait.h:79
Header file for the IsSparseVector type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
Header file for the SubmatrixExprTrait class template.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
typename TDVecTDMatMultExprTrait< VT, MT >::Type TDVecTDMatMultExprTrait_
Auxiliary alias declaration for the TDVecTDMatMultExprTrait class template.The TDVecTDMatMultExprTrai...
Definition: TDVecTDMatMultExprTrait.h:120
Header file for run time assertion macros.
Compile time check for column-major matrix types.This type trait tests whether or not the given templ...
Definition: IsColumnMajorMatrix.h:83
ResultType_< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: TSMatTDMatMultExpr.h:151
Utility type for generic codes.
Header file for the TDMatDeclLowExprTrait class template.
If_< IsExpression< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: TSMatTDMatMultExpr.h:270
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
Header file for the reset shim.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:93
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:94
Flag for upper matrices.
Definition: TSMatTDMatMultExpr.h:175
Constraints on the storage order of matrix types.
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatTDMatMultExpr.h:264
Generic wrapper for the declherm() function.
Definition: DeclHerm.h:58
Header file for the TDMatDeclSymExprTrait class template.
Header file for the Noop functor.
IfTrue_< evaluateRight, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: TSMatTDMatMultExpr.h:276
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:243
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.In case either of the two given data types T1 or T2 is not a matrix type ...
Definition: StorageOrder.h:84
Header file for the IsDenseVector type trait.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: TSMatTDMatMultExpr.h:261
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
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
Evaluation of the expression type of a dense vector/transpose dense matrix multiplication.Via this type trait it is possible to evaluate the resulting expression type of a dense vector/transpose dense matrix multiplication. Given the transpose dense vector type VT and the column-major dense matrix type MT, the nested type Type corresponds to the resulting expression type. In case either VT is not a transpose dense vector type or MT is not a column-major dense matrix type, the resulting data type Type is set to INVALID_TYPE.
Definition: TDVecTDMatMultExprTrait.h:79
Header file for the IsRowMajorMatrix type trait.
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:733
Header file for the IsComputation type trait class.
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose dense matrix operand.
Definition: TSMatTDMatMultExpr.h:403
Header file for the IsBuiltin type trait.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: TSMatTDMatMultExpr.h:383
Header file for the TDMatDVecMultExprTrait class template.
Evaluation of the expression type of a transpose dense matrix/dense vector multiplication.Via this type trait it is possible to evaluate the resulting expression type of a transpose dense matrix/dense vector multiplication. Given the column-major dense matrix type MT and the non-transpose dense vector type VT, the nested type Type corresponds to the resulting expression type. In case either MT is not a column-major dense matrix type or VT is not a non-transpose dense vector type, the resulting data type Type is set to INVALID_TYPE.
Definition: TDMatDVecMultExprTrait.h:79
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:76
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:76
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:78
ElementType_< ResultType > ElementType
Resulting element type.
Definition: TSMatTDMatMultExpr.h:262
Header file for the DeclHerm functor.
Flag for lower matrices.
Definition: TSMatTDMatMultExpr.h:174
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
Header file for the IsUpper type trait.
Flag for symmetric matrices.
Definition: TSMatTDMatMultExpr.h:172
Header file for the IsColumnVector type trait.
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:677
Header file for the IsResizable type trait.
const DMatDMatMultExpr< T1, T2, false, false, false, false > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7505
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
DisableIf_< IsDiagonal< MT >, const DMatDeclDiagExpr< MT, SO > > decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given non-diagonal dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:841
DisableIf_< IsUpper< MT >, const DMatDeclUppExpr< MT, SO > > declupp(const DenseMatrix< MT, SO > &dm)
Declares the given non-upper dense matrix expression dm as upper.
Definition: DMatDeclUppExpr.h:842
Evaluation of the expression type type of a column operation.Via this type trait it is possible to ev...
Definition: ColumnExprTrait.h:78
#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 TDVecTDMatMultExprTrait class template.
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TSMatTDMatMultExpr.h:260
Header file for the DeclSym functor.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
IfTrue_< evaluateLeft, const RT1, CT1 > LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: TSMatTDMatMultExpr.h:273
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: TSMatTDMatMultExpr.h:357