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>
52 #include <blaze/math/Exception.h>
65 #include <blaze/math/shims/Reset.h>
85 #include <blaze/math/views/Check.h>
90 #include <blaze/util/Assert.h>
91 #include <blaze/util/DisableIf.h>
92 #include <blaze/util/EnableIf.h>
94 #include <blaze/util/mpl/And.h>
95 #include <blaze/util/mpl/Bool.h>
96 #include <blaze/util/mpl/If.h>
97 #include <blaze/util/mpl/Or.h>
98 #include <blaze/util/Types.h>
100 
101 
102 namespace blaze {
103 
104 //=================================================================================================
105 //
106 // CLASS SMATDMATMULTEXPR
107 //
108 //=================================================================================================
109 
110 //*************************************************************************************************
117 template< typename MT1 // Type of the left-hand side dense matrix
118  , typename MT2 // Type of the right-hand side sparse matrix
119  , bool SF // Symmetry flag
120  , bool HF // Hermitian flag
121  , bool LF // Lower flag
122  , bool UF > // Upper flag
123 class TSMatTDMatMultExpr
124  : public MatMatMultExpr< DenseMatrix< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, true > >
125  , private Computation
126 {
127  private:
128  //**Type definitions****************************************************************************
135  //**********************************************************************************************
136 
137  //**********************************************************************************************
139  enum : bool { evaluateLeft = IsComputation<MT1>::value || RequiresEvaluation<MT1>::value };
140  //**********************************************************************************************
141 
142  //**********************************************************************************************
144  enum : bool { evaluateRight = IsComputation<MT2>::value || RequiresEvaluation<MT2>::value };
145  //**********************************************************************************************
146 
147  //**********************************************************************************************
149  enum : bool {
150  SYM = ( SF && !( HF || LF || UF ) ),
151  HERM = ( HF && !( LF || UF ) ),
152  LOW = ( LF || ( ( SF || HF ) && UF ) ),
153  UPP = ( UF || ( ( SF || HF ) && LF ) )
154  };
155  //**********************************************************************************************
156 
157  //**********************************************************************************************
159 
164  template< typename T1, typename T2, typename T3 >
165  struct CanExploitSymmetry {
166  enum : bool { value = ( IsSymmetric<T2>::value || IsSymmetric<T3>::value ) };
167  };
169  //**********************************************************************************************
170 
171  //**********************************************************************************************
173 
177  template< typename T1, typename T2, typename T3 >
178  struct IsEvaluationRequired {
179  enum : bool { value = ( evaluateLeft || evaluateRight ) &&
180  !CanExploitSymmetry<T1,T2,T3>::value };
181  };
183  //**********************************************************************************************
184 
185  //**********************************************************************************************
187 
191  template< typename T1, typename T2, typename T3 >
192  struct UseOptimizedKernel {
193  enum : bool { value = useOptimizedKernels &&
195  !IsResizable< ElementType_<T1> >::value &&
197  };
199  //**********************************************************************************************
200 
201  //**********************************************************************************************
203 
206  template< typename T1, typename T2, typename T3 >
207  struct UseDefaultKernel {
208  enum : bool { value = !UseOptimizedKernel<T1,T2,T3>::value };
209  };
211  //**********************************************************************************************
212 
213  //**********************************************************************************************
215 
218  using ForwardFunctor = IfTrue_< HERM
219  , DeclHerm
220  , IfTrue_< SYM
221  , DeclSym
222  , IfTrue_< LOW
223  , IfTrue_< UPP
224  , DeclDiag
225  , DeclLow >
226  , IfTrue_< UPP
227  , DeclUpp
228  , Noop > > > >;
230  //**********************************************************************************************
231 
232  public:
233  //**Type definitions****************************************************************************
236 
241  using ReturnType = const ElementType;
242  using CompositeType = const ResultType;
243 
245  using LeftOperand = If_< IsExpression<MT1>, const MT1, const MT1& >;
246 
248  using RightOperand = If_< IsExpression<MT2>, const MT2, const MT2& >;
249 
252 
255  //**********************************************************************************************
256 
257  //**Compilation flags***************************************************************************
259  enum : bool { simdEnabled = false };
260 
262  enum : bool { smpAssignable = !evaluateLeft && MT1::smpAssignable &&
263  !evaluateRight && MT2::smpAssignable };
264  //**********************************************************************************************
265 
266  //**Constructor*********************************************************************************
272  explicit inline TSMatTDMatMultExpr( const MT1& lhs, const MT2& rhs ) noexcept
273  : lhs_( lhs ) // Left-hand side sparse matrix of the multiplication expression
274  , rhs_( rhs ) // Right-hand side dense matrix of the multiplication expression
275  {
276  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.rows(), "Invalid matrix sizes" );
277  }
278  //**********************************************************************************************
279 
280  //**Access operator*****************************************************************************
287  inline ReturnType operator()( size_t i, size_t j ) const {
288  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
289  BLAZE_INTERNAL_ASSERT( j < rhs_.columns(), "Invalid column access index" );
290 
291  if( IsDiagonal<MT1>::value ) {
292  return lhs_(i,i) * rhs_(i,j);
293  }
294  else if( IsDiagonal<MT2>::value ) {
295  return lhs_(i,j) * rhs_(j,j);
296  }
298  const size_t begin( ( IsUpper<MT1>::value )
299  ?( ( IsLower<MT2>::value )
300  ?( max( ( IsStrictlyUpper<MT1>::value ? i+1UL : i )
301  , ( IsStrictlyLower<MT2>::value ? j+1UL : j ) ) )
302  :( IsStrictlyUpper<MT1>::value ? i+1UL : i ) )
303  :( ( IsLower<MT2>::value )
304  ?( IsStrictlyLower<MT2>::value ? j+1UL : j )
305  :( 0UL ) ) );
306  const size_t end( ( IsLower<MT1>::value )
307  ?( ( IsUpper<MT2>::value )
308  ?( min( ( IsStrictlyLower<MT1>::value ? i : i+1UL )
309  , ( IsStrictlyUpper<MT2>::value ? j : j+1UL ) ) )
310  :( IsStrictlyLower<MT1>::value ? i : i+1UL ) )
311  :( ( IsUpper<MT2>::value )
312  ?( IsStrictlyUpper<MT2>::value ? j : j+1UL )
313  :( lhs_.columns() ) ) );
314 
315  if( begin >= end ) return ElementType();
316 
317  const size_t n( end - begin );
318 
319  return subvector( row( lhs_, i, unchecked ), begin, n, unchecked ) *
320  subvector( column( rhs_, j, unchecked ), begin, n, unchecked );
321  }
322  else {
323  return row( lhs_, i, unchecked ) * column( rhs_, j, unchecked );
324  }
325  }
326  //**********************************************************************************************
327 
328  //**At function*********************************************************************************
336  inline ReturnType at( size_t i, size_t j ) const {
337  if( i >= lhs_.rows() ) {
338  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
339  }
340  if( j >= rhs_.columns() ) {
341  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
342  }
343  return (*this)(i,j);
344  }
345  //**********************************************************************************************
346 
347  //**Rows function*******************************************************************************
352  inline size_t rows() const noexcept {
353  return lhs_.rows();
354  }
355  //**********************************************************************************************
356 
357  //**Columns function****************************************************************************
362  inline size_t columns() const noexcept {
363  return rhs_.columns();
364  }
365  //**********************************************************************************************
366 
367  //**Left operand access*************************************************************************
372  inline LeftOperand leftOperand() const noexcept {
373  return lhs_;
374  }
375  //**********************************************************************************************
376 
377  //**Right operand access************************************************************************
382  inline RightOperand rightOperand() const noexcept {
383  return rhs_;
384  }
385  //**********************************************************************************************
386 
387  //**********************************************************************************************
393  template< typename T >
394  inline bool canAlias( const T* alias ) const noexcept {
395  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
396  }
397  //**********************************************************************************************
398 
399  //**********************************************************************************************
405  template< typename T >
406  inline bool isAliased( const T* alias ) const noexcept {
407  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
408  }
409  //**********************************************************************************************
410 
411  //**********************************************************************************************
416  inline bool isAligned() const noexcept {
417  return rhs_.isAligned();
418  }
419  //**********************************************************************************************
420 
421  //**********************************************************************************************
426  inline bool canSMPAssign() const noexcept {
427  return ( rows() * columns() >= SMP_TSMATTDMATMULT_THRESHOLD ) && !IsDiagonal<MT2>::value;
428  }
429  //**********************************************************************************************
430 
431  private:
432  //**Member variables****************************************************************************
435  //**********************************************************************************************
436 
437  //**Assignment to dense matrices****************************************************************
450  template< typename MT // Type of the target dense matrix
451  , bool SO > // Storage order of the target dense matrix
453  assign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
454  {
456 
457  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
458  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
459 
460  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
461  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
462 
463  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
464  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
465  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
466  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
467  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
468  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
469 
470  TSMatTDMatMultExpr::selectAssignKernel( ~lhs, A, B );
471  }
473  //**********************************************************************************************
474 
475  //**Assignment to dense matrices (kernel selection)*********************************************
486  template< typename MT3 // Type of the left-hand side target matrix
487  , typename MT4 // Type of the left-hand side matrix operand
488  , typename MT5 > // Type of the right-hand side matrix operand
489  static inline void selectAssignKernel( MT3& C, const MT4& A, const MT5& B )
490  {
491  const size_t size( C.rows() * C.columns() );
492 
493  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATTDMATMULT_THRESHOLD ) ||
494  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
495  selectSmallAssignKernel( C, A, B );
496  else
497  selectLargeAssignKernel( C, A, B );
498  }
500  //**********************************************************************************************
501 
502  //**Default assignment to dense matrices********************************************************
517  template< typename MT3 // Type of the left-hand side target matrix
518  , typename MT4 // Type of the left-hand side matrix operand
519  , typename MT5 > // Type of the right-hand side matrix operand
520  static inline void selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B )
521  {
523 
524  reset( C );
525 
527  {
528  for( size_t i=0UL; i<A.columns(); ++i )
529  {
530  const ConstIterator end( A.end(i) );
531  ConstIterator element( A.begin(i) );
532 
533  for( ; element!=end; ++element ) {
534  C(element->index(),i) = element->value() * B(i,i);
535  }
536  }
537  }
538  else
539  {
540  const size_t block( 64UL );
541 
542  for( size_t jj=0UL; jj<B.columns(); jj+=block )
543  {
544  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
545 
546  for( size_t i=0UL; i<A.columns(); ++i )
547  {
548  const ConstIterator end( A.end(i) );
549  ConstIterator element( A.begin(i) );
550 
551  for( ; element!=end; ++element )
552  {
553  const size_t i1( element->index() );
554 
555  const size_t jbegin( ( IsUpper<MT5>::value )
556  ?( ( SYM || HERM || UPP )
557  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
558  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
559  :( SYM || HERM || UPP ? max(i1,jj) : jj ) );
560  const size_t jend( ( IsLower<MT5>::value )
561  ?( ( LOW )
562  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
563  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
564  :( LOW ? min(i1+1UL,jpos) : jpos ) );
565 
566  if( jbegin >= jend )
567  continue;
568 
569  for( size_t j=jbegin; j<jend; ++j ) {
570  if( isDefault( C(i1,j) ) )
571  C(i1,j) = element->value() * B(i,j);
572  else
573  C(i1,j) += element->value() * B(i,j);
574  }
575  }
576  }
577  }
578  }
579 
580  if( SYM || HERM ) {
581  for( size_t j=0UL; j<B.columns(); ++j ) {
582  for( size_t i=j+1UL; i<A.rows(); ++i ) {
583  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
584  }
585  }
586  }
587  }
589  //**********************************************************************************************
590 
591  //**Default assignment to dense matrices (small matrices)***************************************
605  template< typename MT3 // Type of the left-hand side target matrix
606  , typename MT4 // Type of the left-hand side matrix operand
607  , typename MT5 > // Type of the right-hand side matrix operand
609  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
610  {
611  selectDefaultAssignKernel( C, A, B );
612  }
614  //**********************************************************************************************
615 
616  //**Optimized assignment to dense matrices (small matrices)*************************************
631  template< typename MT3 // Type of the left-hand side target matrix
632  , typename MT4 // Type of the left-hand side matrix operand
633  , typename MT5 > // Type of the right-hand side matrix operand
635  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
636  {
638 
639  const size_t block( IsRowMajorMatrix<MT3>::value ? 128UL : 64UL );
640 
641  for( size_t jj=0UL; jj<B.columns(); jj+=block )
642  {
643  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
644 
645  for( size_t i=0UL; i<A.rows(); ++i ) {
646  for( size_t j=jj; j<jpos; ++j ) {
647  reset( C(i,j) );
648  }
649  }
650 
651  for( size_t i=0UL; i<A.columns(); ++i )
652  {
653  const ConstIterator end( A.end(i) );
654  ConstIterator element( A.begin(i) );
655 
656  const size_t nonzeros( A.nonZeros(i) );
657  const size_t kpos( nonzeros & size_t(-4) );
658  BLAZE_INTERNAL_ASSERT( ( nonzeros - ( nonzeros % 4UL ) ) == kpos, "Invalid end calculation" );
659 
660  for( size_t k=0UL; k<kpos; k+=4UL )
661  {
662  const size_t i1( element->index() );
663  const ET1 v1( element->value() );
664  ++element;
665  const size_t i2( element->index() );
666  const ET1 v2( element->value() );
667  ++element;
668  const size_t i3( element->index() );
669  const ET1 v3( element->value() );
670  ++element;
671  const size_t i4( element->index() );
672  const ET1 v4( element->value() );
673  ++element;
674 
675  BLAZE_INTERNAL_ASSERT( i1 < i2 && i2 < i3 && i3 < i4, "Invalid sparse matrix index detected" );
676 
677  const size_t jbegin( ( IsUpper<MT5>::value )
678  ?( ( SYM || HERM || UPP )
679  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
680  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
681  :( SYM || HERM || UPP ? max(i1,jj) : jj ) );
682  const size_t jend( ( IsLower<MT5>::value )
683  ?( ( LOW )
684  ?( min( i4+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
685  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
686  :( LOW ? min(i4+1UL,jpos) : jpos ) );
687 
688  if( jbegin >= jend )
689  continue;
690 
691  for( size_t j=jbegin; j<jend; ++j ) {
692  C(i1,j) += v1 * B(i,j);
693  C(i2,j) += v2 * B(i,j);
694  C(i3,j) += v3 * B(i,j);
695  C(i4,j) += v4 * B(i,j);
696  }
697  }
698 
699  for( ; element!=end; ++element )
700  {
701  const size_t i1( element->index() );
702 
703  const size_t jbegin( ( IsUpper<MT5>::value )
704  ?( ( SYM || HERM || UPP )
705  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
706  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
707  :( SYM || HERM || UPP ? max(i1,jj) : jj ) );
708  const size_t jend( ( IsLower<MT5>::value )
709  ?( ( LOW )
710  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
711  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
712  :( LOW ? min(i1+1UL,jpos) : jpos ) );
713 
714  if( jbegin >= jend )
715  continue;
716 
717  for( size_t j=jbegin; j<jend; ++j ) {
718  C(i1,j) += element->value() * B(i,j);
719  }
720  }
721  }
722  }
723 
724  if( SYM || HERM ) {
725  for( size_t j=0UL; j<B.columns(); ++j ) {
726  for( size_t i=j+1UL; i<A.rows(); ++i ) {
727  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
728  }
729  }
730  }
731  }
733  //**********************************************************************************************
734 
735  //**Default assignment to dense matrices (large matrices)***************************************
749  template< typename MT3 // Type of the left-hand side target matrix
750  , typename MT4 // Type of the left-hand side matrix operand
751  , typename MT5 > // Type of the right-hand side matrix operand
753  selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B )
754  {
755  selectDefaultAssignKernel( C, A, B );
756  }
758  //**********************************************************************************************
759 
760  //**Optimized assignment to dense matrices (large matrices)*************************************
775  template< typename MT3 // Type of the left-hand side target matrix
776  , typename MT4 // Type of the left-hand side matrix operand
777  , typename MT5 > // Type of the right-hand side matrix operand
779  selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B )
780  {
782 
783  const ForwardFunctor fwd;
784 
785  const OppositeType_<MT4> tmp( serial( A ) );
786  assign( C, fwd( tmp * B ) );
787  }
789  //**********************************************************************************************
790 
791  //**Assignment to sparse matrices***************************************************************
804  template< typename MT // Type of the target sparse matrix
805  , bool SO > // Storage order of the target sparse matrix
807  assign( SparseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
808  {
810 
812 
819 
820  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
821  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
822 
823  const ForwardFunctor fwd;
824 
825  const TmpType tmp( serial( rhs ) );
826  assign( ~lhs, fwd( tmp ) );
827  }
829  //**********************************************************************************************
830 
831  //**Restructuring assignment********************************************************************
846  template< typename MT // Type of the target matrix
847  , bool SO > // Storage order of the target matrix
849  assign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
850  {
852 
854 
855  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
856  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
857 
858  const ForwardFunctor fwd;
859 
861  assign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
862  else if( IsSymmetric<MT1>::value )
863  assign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
864  else
865  assign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
866  }
868  //**********************************************************************************************
869 
870  //**Addition assignment to dense matrices*******************************************************
883  template< typename MT // Type of the target dense matrix
884  , bool SO > // Storage order of the target dense matrix
886  addAssign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
887  {
889 
890  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
891  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
892 
893  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
894  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
895 
896  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
897  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
898  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
899  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
900  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
901  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
902 
903  TSMatTDMatMultExpr::selectAddAssignKernel( ~lhs, A, B );
904  }
906  //**********************************************************************************************
907 
908  //**Addition assignment to dense matrices (kernel selection)************************************
919  template< typename MT3 // Type of the left-hand side target matrix
920  , typename MT4 // Type of the left-hand side matrix operand
921  , typename MT5 > // Type of the right-hand side matrix operand
922  static inline void selectAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
923  {
924  const size_t size( C.rows() * C.columns() );
925 
926  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATTDMATMULT_THRESHOLD ) ||
927  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
928  selectSmallAddAssignKernel( C, A, B );
929  else
930  selectLargeAddAssignKernel( C, A, B );
931  }
933  //**********************************************************************************************
934 
935  //**Default addition assignment to dense matrices***********************************************
950  template< typename MT3 // Type of the left-hand side target matrix
951  , typename MT4 // Type of the left-hand side matrix operand
952  , typename MT5 > // Type of the right-hand side matrix operand
953  static inline void selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
954  {
956 
958  {
959  for( size_t i=0UL; i<A.columns(); ++i )
960  {
961  const ConstIterator end( A.end(i) );
962  ConstIterator element( A.begin(i) );
963 
964  for( ; element!=end; ++element ) {
965  C(element->index(),i) += element->value() * B(i,i);
966  }
967  }
968  }
969  else
970  {
971  const size_t block( 64UL );
972 
973  for( size_t jj=0UL; jj<B.columns(); jj+=block )
974  {
975  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
976 
977  for( size_t i=0UL; i<A.columns(); ++i )
978  {
979  const ConstIterator end( A.end(i) );
980  ConstIterator element( A.begin(i) );
981 
982  for( ; element!=end; ++element )
983  {
984  const size_t i1( element->index() );
985 
986  const size_t jbegin( ( IsUpper<MT5>::value )
987  ?( ( UPP )
988  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
989  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
990  :( UPP ? max(i1,jj) : jj ) );
991  const size_t jend( ( IsLower<MT5>::value )
992  ?( ( LOW )
993  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
994  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
995  :( LOW ? min(i1+1UL,jpos) : jpos ) );
996 
997  if( jbegin >= jend )
998  continue;
999 
1000  for( size_t j=jbegin; j<jend; ++j ) {
1001  C(i1,j) += element->value() * B(i,j);
1002  }
1003  }
1004  }
1005  }
1006  }
1007  }
1009  //**********************************************************************************************
1010 
1011  //**Default addition assignment to dense matrices (small matrices)******************************
1025  template< typename MT3 // Type of the left-hand side target matrix
1026  , typename MT4 // Type of the left-hand side matrix operand
1027  , typename MT5 > // Type of the right-hand side matrix operand
1029  selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1030  {
1031  selectDefaultAddAssignKernel( C, A, B );
1032  }
1034  //**********************************************************************************************
1035 
1036  //**Optimized addition assignment to dense matrices (small matrices)****************************
1051  template< typename MT3 // Type of the left-hand side target matrix
1052  , typename MT4 // Type of the left-hand side matrix operand
1053  , typename MT5 > // Type of the right-hand side matrix operand
1055  selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1056  {
1058 
1059  const size_t block( IsRowMajorMatrix<MT3>::value ? 128UL : 64UL );
1060 
1061  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1062  {
1063  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1064 
1065  for( size_t i=0UL; i<A.columns(); ++i )
1066  {
1067  const ConstIterator end( A.end(i) );
1068  ConstIterator element( A.begin(i) );
1069 
1070  const size_t nonzeros( A.nonZeros(i) );
1071  const size_t kpos( nonzeros & size_t(-4) );
1072  BLAZE_INTERNAL_ASSERT( ( nonzeros - ( nonzeros % 4UL ) ) == kpos, "Invalid end calculation" );
1073 
1074  for( size_t k=0UL; k<kpos; k+=4UL )
1075  {
1076  const size_t i1( element->index() );
1077  const ET1 v1( element->value() );
1078  ++element;
1079  const size_t i2( element->index() );
1080  const ET1 v2( element->value() );
1081  ++element;
1082  const size_t i3( element->index() );
1083  const ET1 v3( element->value() );
1084  ++element;
1085  const size_t i4( element->index() );
1086  const ET1 v4( element->value() );
1087  ++element;
1088 
1089  BLAZE_INTERNAL_ASSERT( i1 < i2 && i2 < i3 && i3 < i4, "Invalid sparse matrix index detected" );
1090 
1091  const size_t jbegin( ( IsUpper<MT5>::value )
1092  ?( ( UPP )
1093  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1094  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1095  :( UPP ? max(i1,jj) : jj ) );
1096  const size_t jend( ( IsLower<MT5>::value )
1097  ?( ( LOW )
1098  ?( min( i4+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1099  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1100  :( LOW ? min(i4+1UL,jpos) : jpos ) );
1101 
1102  if( jbegin >= jend )
1103  continue;
1104 
1105  for( size_t j=jbegin; j<jend; ++j ) {
1106  C(i1,j) += v1 * B(i,j);
1107  C(i2,j) += v2 * B(i,j);
1108  C(i3,j) += v3 * B(i,j);
1109  C(i4,j) += v4 * B(i,j);
1110  }
1111  }
1112 
1113  for( ; element!=end; ++element )
1114  {
1115  const size_t i1( element->index() );
1116 
1117  const size_t jbegin( ( IsUpper<MT5>::value )
1118  ?( ( UPP )
1119  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1120  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1121  :( UPP ? max(i1,jj) : jj ) );
1122  const size_t jend( ( IsLower<MT5>::value )
1123  ?( ( LOW )
1124  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1125  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1126  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1127 
1128  if( jbegin >= jend )
1129  continue;
1130 
1131  for( size_t j=jbegin; j<jend; ++j ) {
1132  C(i1,j) += element->value() * B(i,j);
1133  }
1134  }
1135  }
1136  }
1137  }
1139  //**********************************************************************************************
1140 
1141  //**Default addition assignment to dense matrices (large matrices)******************************
1155  template< typename MT3 // Type of the left-hand side target matrix
1156  , typename MT4 // Type of the left-hand side matrix operand
1157  , typename MT5 > // Type of the right-hand side matrix operand
1159  selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1160  {
1161  selectDefaultAddAssignKernel( C, A, B );
1162  }
1164  //**********************************************************************************************
1165 
1166  //**Optimized addition assignment to dense matrices (large matrices)****************************
1181  template< typename MT3 // Type of the left-hand side target matrix
1182  , typename MT4 // Type of the left-hand side matrix operand
1183  , typename MT5 > // Type of the right-hand side matrix operand
1185  selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1186  {
1188 
1189  const ForwardFunctor fwd;
1190 
1191  const OppositeType_<MT4> tmp( serial( A ) );
1192  addAssign( C, fwd( tmp * B ) );
1193  }
1195  //**********************************************************************************************
1196 
1197  //**Restructuring addition assignment***********************************************************
1212  template< typename MT // Type of the target matrix
1213  , bool SO > // Storage order of the target matrix
1215  addAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1216  {
1218 
1220 
1221  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1222  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1223 
1224  const ForwardFunctor fwd;
1225 
1227  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1228  else if( IsSymmetric<MT1>::value )
1229  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1230  else
1231  addAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1232  }
1234  //**********************************************************************************************
1235 
1236  //**Addition assignment to sparse matrices******************************************************
1237  // No special implementation for the addition assignment to sparse matrices.
1238  //**********************************************************************************************
1239 
1240  //**Subtraction assignment to dense matrices****************************************************
1253  template< typename MT // Type of the target dense matrix
1254  , bool SO > // Storage order of the target dense matrix
1256  subAssign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1257  {
1259 
1260  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1261  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1262 
1263  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
1264  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
1265 
1266  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1267  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1268  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1269  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1270  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1271  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1272 
1273  TSMatTDMatMultExpr::selectSubAssignKernel( ~lhs, A, B );
1274  }
1276  //**********************************************************************************************
1277 
1278  //**Subtraction assignment to dense matrices (kernel selection)*********************************
1289  template< typename MT3 // Type of the left-hand side target matrix
1290  , typename MT4 // Type of the left-hand side matrix operand
1291  , typename MT5 > // Type of the right-hand side matrix operand
1292  static inline void selectSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1293  {
1294  const size_t size( C.rows() * C.columns() );
1295 
1296  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATTDMATMULT_THRESHOLD ) ||
1297  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
1298  selectSmallSubAssignKernel( C, A, B );
1299  else
1300  selectLargeSubAssignKernel( C, A, B );
1301  }
1303  //**********************************************************************************************
1304 
1305  //**Default subtraction assignment to dense matrices********************************************
1320  template< typename MT3 // Type of the left-hand side target matrix
1321  , typename MT4 // Type of the left-hand side matrix operand
1322  , typename MT5 > // Type of the right-hand side matrix operand
1323  static inline void selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1324  {
1326 
1328  {
1329  for( size_t i=0UL; i<A.columns(); ++i )
1330  {
1331  const ConstIterator end( A.end(i) );
1332  ConstIterator element( A.begin(i) );
1333 
1334  for( ; element!=end; ++element ) {
1335  C(element->index(),i) -= element->value() * B(i,i);
1336  }
1337  }
1338  }
1339  else
1340  {
1341  const size_t block( 64UL );
1342 
1343  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1344  {
1345  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1346 
1347  for( size_t i=0UL; i<A.columns(); ++i )
1348  {
1349  const ConstIterator end( A.end(i) );
1350  ConstIterator element( A.begin(i) );
1351 
1352  for( ; element!=end; ++element )
1353  {
1354  const size_t i1( element->index() );
1355 
1356  const size_t jbegin( ( IsUpper<MT5>::value )
1357  ?( ( UPP )
1358  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1359  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1360  :( UPP ? max(i1,jj) : jj ) );
1361  const size_t jend( ( IsLower<MT5>::value )
1362  ?( ( LOW )
1363  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1364  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1365  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1366 
1367  if( jbegin >= jend )
1368  continue;
1369 
1370  for( size_t j=jbegin; j<jend; ++j ) {
1371  C(i1,j) -= element->value() * B(i,j);
1372  }
1373  }
1374  }
1375  }
1376  }
1377  }
1379  //**********************************************************************************************
1380 
1381  //**Default subtraction assignment to dense matrices (small matrices)***************************
1395  template< typename MT3 // Type of the left-hand side target matrix
1396  , typename MT4 // Type of the left-hand side matrix operand
1397  , typename MT5 > // Type of the right-hand side matrix operand
1399  selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1400  {
1401  selectDefaultSubAssignKernel( C, A, B );
1402  }
1404  //**********************************************************************************************
1405 
1406  //**Optimized subtraction assignment to dense matrices (small matrices)*************************
1421  template< typename MT3 // Type of the left-hand side target matrix
1422  , typename MT4 // Type of the left-hand side matrix operand
1423  , typename MT5 > // Type of the right-hand side matrix operand
1425  selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1426  {
1428 
1429  const size_t block( IsRowMajorMatrix<MT3>::value ? 128UL : 64UL );
1430 
1431  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1432  {
1433  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1434 
1435  for( size_t i=0UL; i<A.columns(); ++i )
1436  {
1437  const ConstIterator end( A.end(i) );
1438  ConstIterator element( A.begin(i) );
1439 
1440  const size_t nonzeros( A.nonZeros(i) );
1441  const size_t kpos( nonzeros & size_t(-4) );
1442  BLAZE_INTERNAL_ASSERT( ( nonzeros - ( nonzeros % 4UL ) ) == kpos, "Invalid end calculation" );
1443 
1444  for( size_t k=0UL; k<kpos; k+=4UL )
1445  {
1446  const size_t i1( element->index() );
1447  const ET1 v1( element->value() );
1448  ++element;
1449  const size_t i2( element->index() );
1450  const ET1 v2( element->value() );
1451  ++element;
1452  const size_t i3( element->index() );
1453  const ET1 v3( element->value() );
1454  ++element;
1455  const size_t i4( element->index() );
1456  const ET1 v4( element->value() );
1457  ++element;
1458 
1459  BLAZE_INTERNAL_ASSERT( i1 < i2 && i2 < i3 && i3 < i4, "Invalid sparse matrix index detected" );
1460 
1461  const size_t jbegin( ( IsUpper<MT5>::value )
1462  ?( ( UPP )
1463  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1464  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1465  :( UPP ? max(i1,jj) : jj ) );
1466  const size_t jend( ( IsLower<MT5>::value )
1467  ?( ( LOW )
1468  ?( min( i4+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1469  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1470  :( LOW ? min(i4+1UL,jpos) : jpos ) );
1471 
1472  if( jbegin >= jend )
1473  continue;
1474 
1475  for( size_t j=jbegin; j<jend; ++j ) {
1476  C(i1,j) -= v1 * B(i,j);
1477  C(i2,j) -= v2 * B(i,j);
1478  C(i3,j) -= v3 * B(i,j);
1479  C(i4,j) -= v4 * B(i,j);
1480  }
1481  }
1482 
1483  for( ; element!=end; ++element )
1484  {
1485  const size_t i1( element->index() );
1486 
1487  const size_t jbegin( ( IsUpper<MT5>::value )
1488  ?( ( UPP )
1489  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1490  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1491  :( UPP ? max(i1,jj) : jj ) );
1492  const size_t jend( ( IsLower<MT5>::value )
1493  ?( ( LOW )
1494  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1495  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1496  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1497 
1498  if( jbegin >= jend )
1499  continue;
1500 
1501  for( size_t j=jbegin; j<jend; ++j ) {
1502  C(i1,j) -= element->value() * B(i,j);
1503  }
1504  }
1505  }
1506  }
1507  }
1509  //**********************************************************************************************
1510 
1511  //**Default subtraction assignment to dense matrices (large matrices)***************************
1525  template< typename MT3 // Type of the left-hand side target matrix
1526  , typename MT4 // Type of the left-hand side matrix operand
1527  , typename MT5 > // Type of the right-hand side matrix operand
1529  selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1530  {
1531  selectDefaultSubAssignKernel( C, A, B );
1532  }
1534  //**********************************************************************************************
1535 
1536  //**Optimized subtraction assignment to dense matrices (large matrices)*************************
1551  template< typename MT3 // Type of the left-hand side target matrix
1552  , typename MT4 // Type of the left-hand side matrix operand
1553  , typename MT5 > // Type of the right-hand side matrix operand
1555  selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1556  {
1558 
1559  const ForwardFunctor fwd;
1560 
1561  const OppositeType_<MT4> tmp( serial( A ) );
1562  subAssign( C, fwd( tmp * B ) );
1563  }
1565  //**********************************************************************************************
1566 
1567  //**Restructuring subtraction assignment********************************************************
1582  template< typename MT // Type of the target matrix
1583  , bool SO > // Storage order of the target matrix
1585  subAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1586  {
1588 
1590 
1591  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1592  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1593 
1594  const ForwardFunctor fwd;
1595 
1597  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1598  else if( IsSymmetric<MT1>::value )
1599  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1600  else
1601  subAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1602  }
1604  //**********************************************************************************************
1605 
1606  //**Subtraction assignment to sparse matrices***************************************************
1607  // No special implementation for the subtraction assignment to sparse matrices.
1608  //**********************************************************************************************
1609 
1610  //**Schur product assignment to dense matrices**************************************************
1623  template< typename MT // Type of the target dense matrix
1624  , bool SO > // Storage order of the target dense matrix
1625  friend inline void schurAssign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1626  {
1628 
1632 
1633  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1634  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1635 
1636  const ResultType tmp( serial( rhs ) );
1637  schurAssign( ~lhs, tmp );
1638  }
1640  //**********************************************************************************************
1641 
1642  //**Schur product assignment to sparse matrices*************************************************
1643  // No special implementation for the Schur product assignment to sparse matrices.
1644  //**********************************************************************************************
1645 
1646  //**Multiplication assignment to dense matrices*************************************************
1647  // No special implementation for the multiplication assignment to dense matrices.
1648  //**********************************************************************************************
1649 
1650  //**Multiplication assignment to sparse matrices************************************************
1651  // No special implementation for the multiplication assignment to sparse matrices.
1652  //**********************************************************************************************
1653 
1654  //**SMP assignment to dense matrices************************************************************
1670  template< typename MT // Type of the target dense matrix
1671  , bool SO > // Storage order of the target dense matrix
1673  smpAssign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1674  {
1676 
1677  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1678  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1679 
1680  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1681  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1682 
1683  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1684  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1685  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1686  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1687  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1688  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1689 
1690  smpAssign( ~lhs, A * B );
1691  }
1693  //**********************************************************************************************
1694 
1695  //**SMP assignment to sparse matrices***********************************************************
1711  template< typename MT // Type of the target sparse matrix
1712  , bool SO > // Storage order of the target sparse matrix
1715  {
1717 
1719 
1726 
1727  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1728  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1729 
1730  const ForwardFunctor fwd;
1731 
1732  const TmpType tmp( rhs );
1733  smpAssign( ~lhs, fwd( tmp ) );
1734  }
1736  //**********************************************************************************************
1737 
1738  //**Restructuring SMP assignment****************************************************************
1753  template< typename MT // Type of the target matrix
1754  , bool SO > // Storage order of the target matrix
1756  smpAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1757  {
1759 
1761 
1762  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1763  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1764 
1765  const ForwardFunctor fwd;
1766 
1768  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1769  else if( IsSymmetric<MT1>::value )
1770  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1771  else
1772  smpAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1773  }
1775  //**********************************************************************************************
1776 
1777  //**SMP addition assignment to dense matrices***************************************************
1793  template< typename MT // Type of the target dense matrix
1794  , bool SO > // Storage order of the target dense matrix
1797  {
1799 
1800  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1801  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1802 
1803  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1804  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1805 
1806  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1807  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1808  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1809  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1810  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1811  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1812 
1813  smpAddAssign( ~lhs, A * B );
1814  }
1816  //**********************************************************************************************
1817 
1818  //**Restructuring SMP addition assignment*******************************************************
1833  template< typename MT // Type of the target matrix
1834  , bool SO > // Storage order of the target matrix
1836  smpAddAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1837  {
1839 
1841 
1842  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1843  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1844 
1845  const ForwardFunctor fwd;
1846 
1848  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1849  else if( IsSymmetric<MT1>::value )
1850  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1851  else
1852  smpAddAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1853  }
1855  //**********************************************************************************************
1856 
1857  //**SMP addition assignment to sparse matrices**************************************************
1858  // No special implementation for the SMP addition assignment to sparse matrices.
1859  //**********************************************************************************************
1860 
1861  //**SMP subtraction assignment to dense matrices************************************************
1877  template< typename MT // Type of the target dense matrix
1878  , bool SO > // Storage order of the target dense matrix
1881  {
1883 
1884  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1885  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1886 
1887  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1888  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1889 
1890  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1891  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1892  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1893  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1894  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1895  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1896 
1897  smpSubAssign( ~lhs, A * B );
1898  }
1900  //**********************************************************************************************
1901 
1902  //**Restructuring SMP subtraction assignment****************************************************
1917  template< typename MT // Type of the target matrix
1918  , bool SO > // Storage order of the target matrix
1920  smpSubAssign( Matrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1921  {
1923 
1925 
1926  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1927  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1928 
1929  const ForwardFunctor fwd;
1930 
1932  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) );
1933  else if( IsSymmetric<MT1>::value )
1934  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1935  else
1936  smpSubAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) );
1937  }
1939  //**********************************************************************************************
1940 
1941  //**SMP subtraction assignment to sparse matrices***********************************************
1942  // No special implementation for the SMP subtraction assignment to sparse matrices.
1943  //**********************************************************************************************
1944 
1945  //**SMP Schur product assignment to dense matrices**********************************************
1958  template< typename MT // Type of the target dense matrix
1959  , bool SO > // Storage order of the target dense matrix
1960  friend inline void smpSchurAssign( DenseMatrix<MT,SO>& lhs, const TSMatTDMatMultExpr& rhs )
1961  {
1963 
1967 
1968  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1969  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1970 
1971  const ResultType tmp( rhs );
1972  smpSchurAssign( ~lhs, tmp );
1973  }
1975  //**********************************************************************************************
1976 
1977  //**SMP Schur product assignment to sparse matrices*********************************************
1978  // No special implementation for the SMP Schur product assignment to sparse matrices.
1979  //**********************************************************************************************
1980 
1981  //**SMP multiplication assignment to dense matrices*********************************************
1982  // No special implementation for the SMP multiplication assignment to dense matrices.
1983  //**********************************************************************************************
1984 
1985  //**SMP multiplication assignment to sparse matrices********************************************
1986  // No special implementation for the SMP multiplication assignment to sparse matrices.
1987  //**********************************************************************************************
1988 
1989  //**Compile time checks*************************************************************************
1997  //**********************************************************************************************
1998 };
1999 //*************************************************************************************************
2000 
2001 
2002 
2003 
2004 //=================================================================================================
2005 //
2006 // GLOBAL BINARY ARITHMETIC OPERATORS
2007 //
2008 //=================================================================================================
2009 
2010 //*************************************************************************************************
2039 template< typename MT1 // Type of the left-hand side sparse matrix
2040  , typename MT2 > // Type of the right-hand side dense matrix
2041 inline decltype(auto)
2042  operator*( const SparseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,true>& rhs )
2043 {
2045 
2046  if( (~lhs).columns() != (~rhs).rows() ) {
2047  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
2048  }
2049 
2051  return ReturnType( ~lhs, ~rhs );
2052 }
2053 //*************************************************************************************************
2054 
2055 
2056 
2057 
2058 //=================================================================================================
2059 //
2060 // GLOBAL FUNCTIONS
2061 //
2062 //=================================================================================================
2063 
2064 //*************************************************************************************************
2088 template< typename MT1 // Type of the left-hand side dense matrix
2089  , typename MT2 // Type of the right-hand side dense matrix
2090  , bool SF // Symmetry flag
2091  , bool HF // Hermitian flag
2092  , bool LF // Lower flag
2093  , bool UF > // Upper flag
2094 inline decltype(auto) declsym( const TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2095 {
2097 
2098  if( !isSquare( dm ) ) {
2099  BLAZE_THROW_INVALID_ARGUMENT( "Invalid symmetric matrix specification" );
2100  }
2101 
2103  return ReturnType( dm.leftOperand(), dm.rightOperand() );
2104 }
2106 //*************************************************************************************************
2107 
2108 
2109 //*************************************************************************************************
2133 template< typename MT1 // Type of the left-hand side dense matrix
2134  , typename MT2 // Type of the right-hand side dense matrix
2135  , bool SF // Symmetry flag
2136  , bool HF // Hermitian flag
2137  , bool LF // Lower flag
2138  , bool UF > // Upper flag
2139 inline decltype(auto) declherm( const TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2140 {
2142 
2143  if( !isSquare( dm ) ) {
2144  BLAZE_THROW_INVALID_ARGUMENT( "Invalid Hermitian matrix specification" );
2145  }
2146 
2148  return ReturnType( dm.leftOperand(), dm.rightOperand() );
2149 }
2151 //*************************************************************************************************
2152 
2153 
2154 //*************************************************************************************************
2178 template< typename MT1 // Type of the left-hand side dense matrix
2179  , typename MT2 // Type of the right-hand side dense matrix
2180  , bool SF // Symmetry flag
2181  , bool HF // Hermitian flag
2182  , bool LF // Lower flag
2183  , bool UF > // Upper flag
2184 inline decltype(auto) decllow( const TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2185 {
2187 
2188  if( !isSquare( dm ) ) {
2189  BLAZE_THROW_INVALID_ARGUMENT( "Invalid lower matrix specification" );
2190  }
2191 
2193  return ReturnType( dm.leftOperand(), dm.rightOperand() );
2194 }
2196 //*************************************************************************************************
2197 
2198 
2199 //*************************************************************************************************
2223 template< typename MT1 // Type of the left-hand side dense matrix
2224  , typename MT2 // Type of the right-hand side dense matrix
2225  , bool SF // Symmetry flag
2226  , bool HF // Hermitian flag
2227  , bool LF // Lower flag
2228  , bool UF > // Upper flag
2229 inline decltype(auto) declupp( const TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2230 {
2232 
2233  if( !isSquare( dm ) ) {
2234  BLAZE_THROW_INVALID_ARGUMENT( "Invalid upper matrix specification" );
2235  }
2236 
2238  return ReturnType( dm.leftOperand(), dm.rightOperand() );
2239 }
2241 //*************************************************************************************************
2242 
2243 
2244 //*************************************************************************************************
2268 template< typename MT1 // Type of the left-hand side dense matrix
2269  , typename MT2 // Type of the right-hand side dense matrix
2270  , bool SF // Symmetry flag
2271  , bool HF // Hermitian flag
2272  , bool LF // Lower flag
2273  , bool UF > // Upper flag
2274 inline decltype(auto) decldiag( const TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm )
2275 {
2277 
2278  if( !isSquare( dm ) ) {
2279  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
2280  }
2281 
2283  return ReturnType( dm.leftOperand(), dm.rightOperand() );
2284 }
2286 //*************************************************************************************************
2287 
2288 
2289 
2290 
2291 //=================================================================================================
2292 //
2293 // SIZE SPECIALIZATIONS
2294 //
2295 //=================================================================================================
2296 
2297 //*************************************************************************************************
2299 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2300 struct Size< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, 0UL >
2301  : public Size<MT1,0UL>
2302 {};
2303 
2304 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2305 struct Size< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, 1UL >
2306  : public Size<MT2,1UL>
2307 {};
2309 //*************************************************************************************************
2310 
2311 
2312 
2313 
2314 //=================================================================================================
2315 //
2316 // ISALIGNED SPECIALIZATIONS
2317 //
2318 //=================================================================================================
2319 
2320 //*************************************************************************************************
2322 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2323 struct IsAligned< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2324  : public IsAligned<MT2>
2325 {};
2327 //*************************************************************************************************
2328 
2329 
2330 
2331 
2332 //=================================================================================================
2333 //
2334 // ISSYMMETRIC SPECIALIZATIONS
2335 //
2336 //=================================================================================================
2337 
2338 //*************************************************************************************************
2340 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2341 struct IsSymmetric< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2342  : public Or< Bool<SF>
2343  , And< Bool<HF>
2344  , IsBuiltin< ElementType_< TSMatTDMatMultExpr<MT1,MT2,false,true,false,false> > > >
2345  , And< Bool<LF>, Bool<UF> > >
2346 {};
2348 //*************************************************************************************************
2349 
2350 
2351 
2352 
2353 //=================================================================================================
2354 //
2355 // ISHERMITIAN SPECIALIZATIONS
2356 //
2357 //=================================================================================================
2358 
2359 //*************************************************************************************************
2361 template< typename MT1, typename MT2, bool SF, bool LF, bool UF >
2362 struct IsHermitian< TSMatTDMatMultExpr<MT1,MT2,SF,true,LF,UF> >
2363  : public TrueType
2364 {};
2366 //*************************************************************************************************
2367 
2368 
2369 
2370 
2371 //=================================================================================================
2372 //
2373 // ISLOWER SPECIALIZATIONS
2374 //
2375 //=================================================================================================
2376 
2377 //*************************************************************************************************
2379 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2380 struct IsLower< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2381  : public Or< Bool<LF>
2382  , And< IsLower<MT1>, IsLower<MT2> >
2383  , And< Or< Bool<SF>, Bool<HF> >
2384  , IsUpper<MT1>, IsUpper<MT2> > >
2385 {};
2387 //*************************************************************************************************
2388 
2389 
2390 
2391 
2392 //=================================================================================================
2393 //
2394 // ISUNILOWER SPECIALIZATIONS
2395 //
2396 //=================================================================================================
2397 
2398 //*************************************************************************************************
2400 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2401 struct IsUniLower< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2402  : public Or< And< IsUniLower<MT1>, IsUniLower<MT2> >
2403  , And< Or< Bool<SF>, Bool<HF> >
2404  , IsUniUpper<MT1>, IsUniUpper<MT2> > >
2405 {};
2407 //*************************************************************************************************
2408 
2409 
2410 
2411 
2412 //=================================================================================================
2413 //
2414 // ISSTRICTLYLOWER SPECIALIZATIONS
2415 //
2416 //=================================================================================================
2417 
2418 //*************************************************************************************************
2420 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2421 struct IsStrictlyLower< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2422  : public Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2423  , And< IsStrictlyLower<MT2>, IsLower<MT1> >
2424  , And< Or< Bool<SF>, Bool<HF> >
2425  , Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2426  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > > > >
2427 {};
2429 //*************************************************************************************************
2430 
2431 
2432 
2433 
2434 //=================================================================================================
2435 //
2436 // ISUPPER SPECIALIZATIONS
2437 //
2438 //=================================================================================================
2439 
2440 //*************************************************************************************************
2442 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2443 struct IsUpper< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2444  : public Or< Bool<UF>
2445  , And< IsUpper<MT1>, IsUpper<MT2> >
2446  , And< Or< Bool<SF>, Bool<HF> >
2447  , IsLower<MT1>, IsLower<MT2> > >
2448 {};
2450 //*************************************************************************************************
2451 
2452 
2453 
2454 
2455 //=================================================================================================
2456 //
2457 // ISUNIUPPER SPECIALIZATIONS
2458 //
2459 //=================================================================================================
2460 
2461 //*************************************************************************************************
2463 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2464 struct IsUniUpper< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2465  : public Or< And< IsUniUpper<MT1>, IsUniUpper<MT2> >
2466  , And< Or< Bool<SF>, Bool<HF> >
2467  , IsUniLower<MT1>, IsUniLower<MT2> > >
2468 {};
2470 //*************************************************************************************************
2471 
2472 
2473 
2474 
2475 //=================================================================================================
2476 //
2477 // ISSTRICTLYUPPER SPECIALIZATIONS
2478 //
2479 //=================================================================================================
2480 
2481 //*************************************************************************************************
2483 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2484 struct IsStrictlyUpper< TSMatTDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2485  : public Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2486  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> >
2487  , And< Or< Bool<SF>, Bool<HF> >
2488  , Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2489  , And< IsStrictlyLower<MT2>, IsLower<MT1> > > > >
2490 {};
2492 //*************************************************************************************************
2493 
2494 } // namespace blaze
2495 
2496 #endif
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:329
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:131
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:71
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: TSMatTDMatMultExpr.h:426
decltype(auto) decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:996
Header file for the IsUniUpper type trait.
EnableIf_< IsDenseMatrix< MT1 > > smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:196
ResultType_< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: TSMatTDMatMultExpr.h:130
Compile time check for triangular matrix types.This type trait tests whether or not the given templat...
Definition: IsTriangular.h:86
Header file for basic type definitions.
ElementType_< RT2 > ET2
Element type of the right-hand side sparse matrix expression.
Definition: TSMatTDMatMultExpr.h:132
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:168
ElementType_< RT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: TSMatTDMatMultExpr.h:131
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:164
Header file for the serial shim.
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:265
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
Flag for symmetric matrices.
Definition: TSMatTDMatMultExpr.h:150
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: TSMatTDMatMultExpr.h:416
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:406
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
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:588
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
Flag for Hermitian matrices.
Definition: TSMatTDMatMultExpr.h:151
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
IfTrue_< evaluateRight, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: TSMatTDMatMultExpr.h:254
Header file for the And class template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:87
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: TSMatTDMatMultExpr.h:237
decltype(auto) declupp(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as upper.
Definition: DMatDeclUppExpr.h:1026
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:87
Constraints on the storage order of matrix types.
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:343
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
RightOperand rhs_
Right-hand side dense matrix of the multiplication expression.
Definition: TSMatTDMatMultExpr.h:434
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
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
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TSMatTDMatMultExpr.h:238
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatTDMatMultExpr.h:242
Constraint on the data type.
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:71
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:394
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:86
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the DeclLow functor.
Header file for the If class template.
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:110
#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
ResultType_< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: TSMatTDMatMultExpr.h:129
Generic wrapper for the decllow() function.
Definition: DeclLow.h:58
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:102
Header file for the Or class template.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TSMatTDMatMultExpr.h:287
#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.
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatTDMatMultExpr.h:433
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
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:272
decltype(auto) decllow(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as lower.
Definition: DMatDeclLowExpr.h:1026
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:89
Generic wrapper for the null function.
Definition: Noop.h:59
Header file for the IsTriangular type trait.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: TSMatTDMatMultExpr.h:352
CompositeType_< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatTDMatMultExpr.h:133
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatTDMatMultExpr.h:372
Constraints on the storage order of matrix types.
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
Header file for the exception macros of the math module.
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
Header file for the DeclDiag functor.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatTDMatMultExpr.h:241
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatMultExpr.h:107
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:86
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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
Header file for run time assertion macros.
Compile time check for column-major matrix types.This type trait tests whether or not the given templ...
Definition: IsColumnMajorMatrix.h:110
Flag for upper matrices.
Definition: TSMatTDMatMultExpr.h:153
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:154
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
ElementType_< ResultType > ElementType
Resulting element type.
Definition: TSMatTDMatMultExpr.h:240
Header file for the reset shim.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
decltype(auto) declsym(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as symmetric.
Definition: DMatDeclSymExpr.h:1028
Header file for the isDefault shim.
Compile time check for Hermitian matrices.This type trait tests whether or not the given template par...
Definition: IsHermitian.h:85
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:101
Constraint on the data type.
Constraints on the storage order of matrix types.
Generic wrapper for the declherm() function.
Definition: DeclHerm.h:58
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
Header file for the Noop functor.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: TSMatTDMatMultExpr.h:239
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:263
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.In case either of the two given data types T1 or T2 is not a matrix type ...
Definition: StorageOrder.h:84
Generic wrapper for the declupp() function.
Definition: DeclUpp.h:58
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
decltype(auto) declherm(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as Hermitian.
Definition: DMatDeclHermExpr.h:1028
If_< IsExpression< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatTDMatMultExpr.h:245
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComputation type trait class.
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose dense matrix operand.
Definition: TSMatTDMatMultExpr.h:382
Header file for the IsBuiltin type trait.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: TSMatTDMatMultExpr.h:362
Flag for lower matrices.
Definition: TSMatTDMatMultExpr.h:152
Compile time logical &#39;or&#39; evaluation.The Or alias declaration performs at compile time a logical &#39;or&#39;...
Definition: Or.h:76
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
If_< IsExpression< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: TSMatTDMatMultExpr.h:248
CompositeType_< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: TSMatTDMatMultExpr.h:134
Generic wrapper for the decldiag() function.
Definition: DeclDiag.h:58
Header file for the DeclHerm functor.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
Header file for the IsUpper type trait.
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1321
Constraint on the data type.
Generic wrapper for the declsym() function.
Definition: DeclSym.h:58
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
Header file for the IsResizable type trait.
IfTrue_< evaluateLeft, const RT1, CT1 > LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: TSMatTDMatMultExpr.h:251
Header file for the Size type trait.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the Bool class template.
Header file for the DeclSym functor.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: TSMatTDMatMultExpr.h:336