TSMatDMatMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATDMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSMATDMATMULTEXPR_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>
112 #include <blaze/system/Thresholds.h>
113 #include <blaze/util/Assert.h>
115 #include <blaze/util/DisableIf.h>
116 #include <blaze/util/EnableIf.h>
119 #include <blaze/util/InvalidType.h>
120 #include <blaze/util/mpl/And.h>
121 #include <blaze/util/mpl/Bool.h>
122 #include <blaze/util/mpl/If.h>
123 #include <blaze/util/mpl/Or.h>
124 #include <blaze/util/Types.h>
126 
127 
128 namespace blaze {
129 
130 //=================================================================================================
131 //
132 // CLASS SMATDMATMULTEXPR
133 //
134 //=================================================================================================
135 
136 //*************************************************************************************************
143 template< typename MT1 // Type of the left-hand side dense matrix
144  , typename MT2 // Type of the right-hand side sparse matrix
145  , bool SF // Symmetry flag
146  , bool HF // Hermitian flag
147  , bool LF // Lower flag
148  , bool UF > // Upper flag
149 class TSMatDMatMultExpr : public DenseMatrix< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, true >
150  , private MatMatMultExpr
151  , private Computation
152 {
153  private:
154  //**Type definitions****************************************************************************
161  //**********************************************************************************************
162 
163  //**********************************************************************************************
165  enum : bool { evaluateLeft = IsComputation<MT1>::value || RequiresEvaluation<MT1>::value };
166  //**********************************************************************************************
167 
168  //**********************************************************************************************
170  enum : bool { evaluateRight = IsComputation<MT2>::value || RequiresEvaluation<MT2>::value };
171  //**********************************************************************************************
172 
173  //**********************************************************************************************
175  enum : bool {
176  SYM = ( SF && !( HF || LF || UF ) ),
177  HERM = ( HF && !( LF || UF ) ),
178  LOW = ( LF || ( ( SF || HF ) && UF ) ),
179  UPP = ( UF || ( ( SF || HF ) && LF ) )
180  };
181  //**********************************************************************************************
182 
183  //**********************************************************************************************
185 
190  template< typename T1, typename T2, typename T3 >
191  struct CanExploitSymmetry {
192  enum : bool { value = IsSymmetric<T2>::value };
193  };
195  //**********************************************************************************************
196 
197  //**********************************************************************************************
199 
203  template< typename T1, typename T2, typename T3 >
204  struct IsEvaluationRequired {
205  enum : bool { value = ( evaluateLeft || evaluateRight ) &&
206  !CanExploitSymmetry<T1,T2,T3>::value };
207  };
209  //**********************************************************************************************
210 
211  //**********************************************************************************************
213 
217  template< typename T1, typename T2, typename T3 >
218  struct UseOptimizedKernel {
219  enum : bool { value = useOptimizedKernels &&
221  !IsResizable< ElementType_<T1> >::value &&
223  };
225  //**********************************************************************************************
226 
227  //**********************************************************************************************
229 
232  template< typename T1, typename T2, typename T3 >
233  struct UseDefaultKernel {
234  enum : bool { value = !UseOptimizedKernel<T1,T2,T3>::value };
235  };
237  //**********************************************************************************************
238 
239  //**********************************************************************************************
241 
244  typedef IfTrue_< HERM
245  , DeclHerm
246  , IfTrue_< SYM
247  , DeclSym
248  , IfTrue_< LOW
249  , IfTrue_< UPP
250  , DeclDiag
251  , DeclLow >
252  , IfTrue_< UPP
253  , DeclUpp
254  , Noop > > > > ForwardFunctor;
256  //**********************************************************************************************
257 
258  public:
259  //**Type definitions****************************************************************************
262 
267  typedef const ElementType ReturnType;
268  typedef const ResultType CompositeType;
269 
271  typedef If_< IsExpression<MT1>, const MT1, const MT1& > LeftOperand;
272 
274  typedef If_< IsExpression<MT2>, const MT2, const MT2& > RightOperand;
275 
278 
281  //**********************************************************************************************
282 
283  //**Compilation flags***************************************************************************
285  enum : bool { simdEnabled = false };
286 
288  enum : bool { smpAssignable = !evaluateLeft && MT1::smpAssignable &&
289  !evaluateRight && MT2::smpAssignable };
290  //**********************************************************************************************
291 
292  //**Constructor*********************************************************************************
298  explicit inline TSMatDMatMultExpr( const MT1& lhs, const MT2& rhs ) noexcept
299  : lhs_( lhs ) // Left-hand side sparse matrix of the multiplication expression
300  , rhs_( rhs ) // Right-hand side dense matrix of the multiplication expression
301  {
302  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.rows(), "Invalid matrix sizes" );
303  }
304  //**********************************************************************************************
305 
306  //**Access operator*****************************************************************************
313  inline ReturnType operator()( size_t i, size_t j ) const {
314  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
315  BLAZE_INTERNAL_ASSERT( j < rhs_.columns(), "Invalid column access index" );
316 
317  if( IsDiagonal<MT1>::value ) {
318  return lhs_(i,i) * rhs_(i,j);
319  }
320  else if( IsDiagonal<MT2>::value ) {
321  return lhs_(i,j) * rhs_(j,j);
322  }
324  const size_t begin( ( IsUpper<MT1>::value )
325  ?( ( IsLower<MT2>::value )
326  ?( max( ( IsStrictlyUpper<MT1>::value ? i+1UL : i )
327  , ( IsStrictlyLower<MT2>::value ? j+1UL : j ) ) )
328  :( IsStrictlyUpper<MT1>::value ? i+1UL : i ) )
329  :( ( IsLower<MT2>::value )
330  ?( IsStrictlyLower<MT2>::value ? j+1UL : j )
331  :( 0UL ) ) );
332  const size_t end( ( IsLower<MT1>::value )
333  ?( ( IsUpper<MT2>::value )
334  ?( min( ( IsStrictlyLower<MT1>::value ? i : i+1UL )
335  , ( IsStrictlyUpper<MT2>::value ? j : j+1UL ) ) )
336  :( IsStrictlyLower<MT1>::value ? i : i+1UL ) )
337  :( ( IsUpper<MT2>::value )
338  ?( IsStrictlyUpper<MT2>::value ? j : j+1UL )
339  :( lhs_.columns() ) ) );
340 
341  if( begin >= end ) return ElementType();
342 
343  const size_t n( end - begin );
344 
345  return subvector( row( lhs_, i ), begin, n ) * subvector( column( rhs_, j ), begin, n );
346  }
347  else {
348  return row( lhs_, i ) * column( rhs_, j );
349  }
350  }
351  //**********************************************************************************************
352 
353  //**At function*********************************************************************************
361  inline ReturnType at( size_t i, size_t j ) const {
362  if( i >= lhs_.rows() ) {
363  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
364  }
365  if( j >= rhs_.columns() ) {
366  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
367  }
368  return (*this)(i,j);
369  }
370  //**********************************************************************************************
371 
372  //**Rows function*******************************************************************************
377  inline size_t rows() const noexcept {
378  return lhs_.rows();
379  }
380  //**********************************************************************************************
381 
382  //**Columns function****************************************************************************
387  inline size_t columns() const noexcept {
388  return rhs_.columns();
389  }
390  //**********************************************************************************************
391 
392  //**Left operand access*************************************************************************
397  inline LeftOperand leftOperand() const noexcept {
398  return lhs_;
399  }
400  //**********************************************************************************************
401 
402  //**Right operand access************************************************************************
407  inline RightOperand rightOperand() const noexcept {
408  return rhs_;
409  }
410  //**********************************************************************************************
411 
412  //**********************************************************************************************
418  template< typename T >
419  inline bool canAlias( const T* alias ) const noexcept {
420  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
421  }
422  //**********************************************************************************************
423 
424  //**********************************************************************************************
430  template< typename T >
431  inline bool isAliased( const T* alias ) const noexcept {
432  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
433  }
434  //**********************************************************************************************
435 
436  //**********************************************************************************************
441  inline bool isAligned() const noexcept {
442  return rhs_.isAligned();
443  }
444  //**********************************************************************************************
445 
446  //**********************************************************************************************
451  inline bool canSMPAssign() const noexcept {
452  return ( rows() * columns() >= SMP_TSMATDMATMULT_THRESHOLD ) && !IsDiagonal<MT2>::value;
453  }
454  //**********************************************************************************************
455 
456  private:
457  //**Member variables****************************************************************************
458  LeftOperand lhs_;
459  RightOperand rhs_;
460  //**********************************************************************************************
461 
462  //**Assignment to dense matrices****************************************************************
475  template< typename MT // Type of the target dense matrix
476  , bool SO > // Storage order of the target dense matrix
478  assign( DenseMatrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
479  {
481 
482  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
483  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
484 
485  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
486  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
487 
488  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
489  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
490  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
491  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
492  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
493  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
494 
495  TSMatDMatMultExpr::selectAssignKernel( ~lhs, A, B );
496  }
498  //**********************************************************************************************
499 
500  //**Assignment to dense matrices (kernel selection)*********************************************
511  template< typename MT3 // Type of the left-hand side target matrix
512  , typename MT4 // Type of the left-hand side matrix operand
513  , typename MT5 > // Type of the right-hand side matrix operand
514  static inline void selectAssignKernel( MT3& C, const MT4& A, const MT5& B )
515  {
516  const size_t size( C.rows() * C.columns() );
517 
518  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATDMATMULT_THRESHOLD ) ||
519  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
520  selectSmallAssignKernel( C, A, B );
521  else
522  selectLargeAssignKernel( C, A, B );
523  }
525  //**********************************************************************************************
526 
527  //**Default assignment to dense matrices********************************************************
542  template< typename MT3 // Type of the left-hand side target matrix
543  , typename MT4 // Type of the left-hand side matrix operand
544  , typename MT5 > // Type of the right-hand side matrix operand
545  static inline void selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B )
546  {
548 
549  reset( C );
550 
552  {
553  for( size_t i=0UL; i<A.columns(); ++i )
554  {
555  const ConstIterator end( A.end(i) );
556  ConstIterator element( A.begin(i) );
557 
558  for( ; element!=end; ++element ) {
559  C(element->index(),i) = element->value() * B(i,i);
560  }
561  }
562  }
563  else
564  {
565  const size_t block( IsRowMajorMatrix<MT3>::value ? 256UL : 8UL );
566 
567  for( size_t jj=0UL; jj<B.columns(); jj+=block )
568  {
569  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
570 
571  for( size_t i=0UL; i<A.columns(); ++i )
572  {
573  const ConstIterator end( A.end(i) );
574  ConstIterator element( A.begin(i) );
575 
576  for( ; element!=end; ++element )
577  {
578  const size_t i1( element->index() );
579 
580  const size_t jbegin( ( IsUpper<MT5>::value )
581  ?( ( SYM || HERM || UPP )
582  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
583  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
584  :( SYM || HERM || UPP ? max(i1,jj) : jj ) );
585  const size_t jend( ( IsLower<MT5>::value )
586  ?( ( LOW )
587  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
588  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
589  :( LOW ? min(i1+1UL,jpos) : jpos ) );
590 
591  if( jbegin >= jend )
592  continue;
593 
594  for( size_t j=jbegin; j<jend; ++j ) {
595  if( isDefault( C(i1,j) ) )
596  C(i1,j) = element->value() * B(i,j);
597  else
598  C(i1,j) += element->value() * B(i,j);
599  }
600  }
601  }
602  }
603  }
604 
605  if( SYM || HERM ) {
606  for( size_t j=0UL; j<B.columns(); ++j ) {
607  for( size_t i=j+1UL; i<A.rows(); ++i ) {
608  C(i,j) = HERM ? conj( C(j,i) ) : C(j,i);
609  }
610  }
611  }
612  }
614  //**********************************************************************************************
615 
616  //**Default assignment to dense matrices (small matrices)***************************************
630  template< typename MT3 // Type of the left-hand side target matrix
631  , typename MT4 // Type of the left-hand side matrix operand
632  , typename MT5 > // Type of the right-hand side matrix operand
634  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
635  {
636  selectDefaultAssignKernel( C, A, B );
637  }
639  //**********************************************************************************************
640 
641  //**Optimized assignment to dense matrices (small matrices)*************************************
656  template< typename MT3 // Type of the left-hand side target matrix
657  , typename MT4 // Type of the left-hand side matrix operand
658  , typename MT5 > // Type of the right-hand side matrix operand
660  selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B )
661  {
663 
664  const size_t block( ( IsRowMajorMatrix<MT3>::value )?( 256UL ):( 8UL ) );
665 
666  reset( C );
667 
668  for( size_t jj=0UL; jj<B.columns(); jj+=block )
669  {
670  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
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 TSMatDMatMultExpr& 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 to row-major matrices**********************************************
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 TSMatDMatMultExpr& 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 
881  assign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
882  }
884  //**********************************************************************************************
885 
886  //**Addition assignment to dense matrices*******************************************************
899  template< typename MT // Type of the target dense matrix
900  , bool SO > // Storage order of the target dense matrix
902  addAssign( DenseMatrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
903  {
905 
906  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
907  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
908 
909  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
910  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
911 
912  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
913  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
914  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
915  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
916  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
917  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
918 
919  TSMatDMatMultExpr::selectAddAssignKernel( ~lhs, A, B );
920  }
922  //**********************************************************************************************
923 
924  //**Addition assignment to dense matrices (kernel selection)************************************
935  template< typename MT3 // Type of the left-hand side target matrix
936  , typename MT4 // Type of the left-hand side matrix operand
937  , typename MT5 > // Type of the right-hand side matrix operand
938  static inline void selectAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
939  {
940  const size_t size( C.rows() * C.columns() );
941 
942  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATDMATMULT_THRESHOLD ) ||
943  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
944  selectSmallAddAssignKernel( C, A, B );
945  else
946  selectLargeAddAssignKernel( C, A, B );
947  }
949  //**********************************************************************************************
950 
951  //**Default addition assignment to dense matrices***********************************************
966  template< typename MT3 // Type of the left-hand side target matrix
967  , typename MT4 // Type of the left-hand side matrix operand
968  , typename MT5 > // Type of the right-hand side matrix operand
969  static inline void selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
970  {
972 
974  {
975  for( size_t i=0UL; i<A.columns(); ++i )
976  {
977  const ConstIterator end( A.end(i) );
978  ConstIterator element( A.begin(i) );
979 
980  for( ; element!=end; ++element ) {
981  C(element->index(),i) += element->value() * B(i,i);
982  }
983  }
984  }
985  else
986  {
987  const size_t block( IsRowMajorMatrix<MT3>::value ? 256UL : 8UL );
988 
989  for( size_t jj=0UL; jj<B.columns(); jj+=block )
990  {
991  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
992 
993  for( size_t i=0UL; i<A.columns(); ++i )
994  {
995  const ConstIterator end( A.end(i) );
996  ConstIterator element( A.begin(i) );
997 
998  for( ; element!=end; ++element )
999  {
1000  const size_t i1( element->index() );
1001 
1002  const size_t jbegin( ( IsUpper<MT5>::value )
1003  ?( ( UPP )
1004  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1005  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1006  :( UPP ? max(i1,jj) : jj ) );
1007  const size_t jend( ( IsLower<MT5>::value )
1008  ?( ( LOW )
1009  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1010  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1011  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1012 
1013  if( jbegin >= jend )
1014  continue;
1015 
1016  for( size_t j=jbegin; j<jend; ++j ) {
1017  C(i1,j) += element->value() * B(i,j);
1018  }
1019  }
1020  }
1021  }
1022  }
1023  }
1025  //**********************************************************************************************
1026 
1027  //**Default addition assignment to dense matrices (small matrices)******************************
1041  template< typename MT3 // Type of the left-hand side target matrix
1042  , typename MT4 // Type of the left-hand side matrix operand
1043  , typename MT5 > // Type of the right-hand side matrix operand
1045  selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1046  {
1047  selectDefaultAddAssignKernel( C, A, B );
1048  }
1050  //**********************************************************************************************
1051 
1052  //**Optimized addition assignment to dense matrices (small matrices)****************************
1067  template< typename MT3 // Type of the left-hand side target matrix
1068  , typename MT4 // Type of the left-hand side matrix operand
1069  , typename MT5 > // Type of the right-hand side matrix operand
1071  selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1072  {
1074 
1075  const size_t block( ( IsRowMajorMatrix<MT3>::value )?( 256UL ):( 8UL ) );
1076 
1077  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1078  {
1079  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1080 
1081  for( size_t i=0UL; i<A.columns(); ++i )
1082  {
1083  const ConstIterator end( A.end(i) );
1084  ConstIterator element( A.begin(i) );
1085 
1086  const size_t nonzeros( A.nonZeros(i) );
1087  const size_t kpos( nonzeros & size_t(-4) );
1088  BLAZE_INTERNAL_ASSERT( ( nonzeros - ( nonzeros % 4UL ) ) == kpos, "Invalid end calculation" );
1089 
1090  for( size_t k=0UL; k<kpos; k+=4UL )
1091  {
1092  const size_t i1( element->index() );
1093  const ET1 v1( element->value() );
1094  ++element;
1095  const size_t i2( element->index() );
1096  const ET1 v2( element->value() );
1097  ++element;
1098  const size_t i3( element->index() );
1099  const ET1 v3( element->value() );
1100  ++element;
1101  const size_t i4( element->index() );
1102  const ET1 v4( element->value() );
1103  ++element;
1104 
1105  BLAZE_INTERNAL_ASSERT( i1 < i2 && i2 < i3 && i3 < i4, "Invalid sparse matrix index detected" );
1106 
1107  const size_t jbegin( ( IsUpper<MT5>::value )
1108  ?( ( UPP )
1109  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1110  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1111  :( UPP ? max(i1,jj) : jj ) );
1112  const size_t jend( ( IsLower<MT5>::value )
1113  ?( ( LOW )
1114  ?( min( i4+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1115  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1116  :( LOW ? min(i4+1UL,jpos) : jpos ) );
1117 
1118  if( jbegin >= jend )
1119  continue;
1120 
1121  for( size_t j=jbegin; j<jend; ++j ) {
1122  C(i1,j) += v1 * B(i,j);
1123  C(i2,j) += v2 * B(i,j);
1124  C(i3,j) += v3 * B(i,j);
1125  C(i4,j) += v4 * B(i,j);
1126  }
1127  }
1128 
1129  for( ; element!=end; ++element )
1130  {
1131  const size_t i1( element->index() );
1132 
1133  const size_t jbegin( ( IsUpper<MT5>::value )
1134  ?( ( UPP )
1135  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1136  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1137  :( UPP ? max(i1,jj) : jj ) );
1138  const size_t jend( ( IsLower<MT5>::value )
1139  ?( ( LOW )
1140  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1141  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1142  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1143 
1144  if( jbegin >= jend )
1145  continue;
1146 
1147  for( size_t j=jbegin; j<jend; ++j ) {
1148  C(i1,j) += element->value() * B(i,j);
1149  }
1150  }
1151  }
1152  }
1153  }
1155  //**********************************************************************************************
1156 
1157  //**Default addition assignment to dense matrices (large matrices)******************************
1171  template< typename MT3 // Type of the left-hand side target matrix
1172  , typename MT4 // Type of the left-hand side matrix operand
1173  , typename MT5 > // Type of the right-hand side matrix operand
1175  selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1176  {
1177  selectDefaultAddAssignKernel( C, A, B );
1178  }
1180  //**********************************************************************************************
1181 
1182  //**Optimized addition assignment to dense matrices (large matrices)****************************
1197  template< typename MT3 // Type of the left-hand side target matrix
1198  , typename MT4 // Type of the left-hand side matrix operand
1199  , typename MT5 > // Type of the right-hand side matrix operand
1201  selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
1202  {
1204 
1205  const ForwardFunctor fwd;
1206 
1207  const OppositeType_<MT4> tmp( serial( A ) );
1208  addAssign( C, fwd( tmp * B ) );
1209  }
1211  //**********************************************************************************************
1212 
1213  //**Restructuring addition assignment to row-major matrices*************************************
1228  template< typename MT // Type of the target matrix
1229  , bool SO > // Storage order of the target matrix
1231  addAssign( Matrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
1232  {
1234 
1236 
1237  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1238  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1239 
1240  const ForwardFunctor fwd;
1241 
1242  addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1243  }
1245  //**********************************************************************************************
1246 
1247  //**Addition assignment to sparse matrices******************************************************
1248  // No special implementation for the addition assignment to sparse matrices.
1249  //**********************************************************************************************
1250 
1251  //**Subtraction assignment to dense matrices****************************************************
1264  template< typename MT // Type of the target dense matrix
1265  , bool SO > // Storage order of the target dense matrix
1267  subAssign( DenseMatrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
1268  {
1270 
1271  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1272  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1273 
1274  LT A( serial( rhs.lhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
1275  RT B( serial( rhs.rhs_ ) ); // Evaluation of the left-hand side dense matrix operand
1276 
1277  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1278  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1279  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1280  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1281  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1282  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1283 
1284  TSMatDMatMultExpr::selectSubAssignKernel( ~lhs, A, B );
1285  }
1287  //**********************************************************************************************
1288 
1289  //**Subtraction assignment to dense matrices (kernel selection)*********************************
1300  template< typename MT3 // Type of the left-hand side target matrix
1301  , typename MT4 // Type of the left-hand side matrix operand
1302  , typename MT5 > // Type of the right-hand side matrix operand
1303  static inline void selectSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1304  {
1305  const size_t size( C.rows() * C.columns() );
1306 
1307  if( ( IsRowMajorMatrix<MT3>::value && size < TSMATDMATMULT_THRESHOLD ) ||
1308  ( IsColumnMajorMatrix<MT3>::value && size < 625UL ) )
1309  selectSmallSubAssignKernel( C, A, B );
1310  else
1311  selectLargeSubAssignKernel( C, A, B );
1312  }
1314  //**********************************************************************************************
1315 
1316  //**Default subtraction assignment to dense matrices********************************************
1331  template< typename MT3 // Type of the left-hand side target matrix
1332  , typename MT4 // Type of the left-hand side matrix operand
1333  , typename MT5 > // Type of the right-hand side matrix operand
1334  static inline void selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1335  {
1337 
1339  {
1340  for( size_t i=0UL; i<A.columns(); ++i )
1341  {
1342  const ConstIterator end( A.end(i) );
1343  ConstIterator element( A.begin(i) );
1344 
1345  for( ; element!=end; ++element ) {
1346  C(element->index(),i) -= element->value() * B(i,i);
1347  }
1348  }
1349  }
1350  else
1351  {
1352  const size_t block( IsRowMajorMatrix<MT3>::value ? 256UL : 8UL );
1353 
1354  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1355  {
1356  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1357 
1358  for( size_t i=0UL; i<A.columns(); ++i )
1359  {
1360  const ConstIterator end( A.end(i) );
1361  ConstIterator element( A.begin(i) );
1362 
1363  for( ; element!=end; ++element )
1364  {
1365  const size_t i1( element->index() );
1366 
1367  const size_t jbegin( ( IsUpper<MT5>::value )
1368  ?( ( UPP )
1369  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1370  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1371  :( UPP ? max(i1,jj) : jj ) );
1372  const size_t jend( ( IsLower<MT5>::value )
1373  ?( ( LOW )
1374  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1375  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1376  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1377 
1378  if( jbegin >= jend )
1379  continue;
1380 
1381  for( size_t j=jbegin; j<jend; ++j ) {
1382  C(i1,j) -= element->value() * B(i,j);
1383  }
1384  }
1385  }
1386  }
1387  }
1388  }
1390  //**********************************************************************************************
1391 
1392  //**Default subtraction assignment to dense matrices (small matrices)***************************
1406  template< typename MT3 // Type of the left-hand side target matrix
1407  , typename MT4 // Type of the left-hand side matrix operand
1408  , typename MT5 > // Type of the right-hand side matrix operand
1410  selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1411  {
1412  selectDefaultSubAssignKernel( C, A, B );
1413  }
1415  //**********************************************************************************************
1416 
1417  //**Optimized subtraction assignment to dense matrices (small matrices)*************************
1432  template< typename MT3 // Type of the left-hand side target matrix
1433  , typename MT4 // Type of the left-hand side matrix operand
1434  , typename MT5 > // Type of the right-hand side matrix operand
1436  selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1437  {
1439 
1440  const size_t block( ( IsRowMajorMatrix<MT3>::value )?( 256UL ):( 8UL ) );
1441 
1442  for( size_t jj=0UL; jj<B.columns(); jj+=block )
1443  {
1444  const size_t jpos( ( jj+block > B.columns() )?( B.columns() ):( jj+block ) );
1445 
1446  for( size_t i=0UL; i<A.columns(); ++i )
1447  {
1448  const ConstIterator end( A.end(i) );
1449  ConstIterator element( A.begin(i) );
1450 
1451  const size_t nonzeros( A.nonZeros(i) );
1452  const size_t kpos( nonzeros & size_t(-4) );
1453  BLAZE_INTERNAL_ASSERT( ( nonzeros - ( nonzeros % 4UL ) ) == kpos, "Invalid end calculation" );
1454 
1455  for( size_t k=0UL; k<kpos; k+=4UL )
1456  {
1457  const size_t i1( element->index() );
1458  const ET1 v1( element->value() );
1459  ++element;
1460  const size_t i2( element->index() );
1461  const ET1 v2( element->value() );
1462  ++element;
1463  const size_t i3( element->index() );
1464  const ET1 v3( element->value() );
1465  ++element;
1466  const size_t i4( element->index() );
1467  const ET1 v4( element->value() );
1468  ++element;
1469 
1470  BLAZE_INTERNAL_ASSERT( i1 < i2 && i2 < i3 && i3 < i4, "Invalid sparse matrix index detected" );
1471 
1472  const size_t jbegin( ( IsUpper<MT5>::value )
1473  ?( ( UPP )
1474  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1475  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1476  :( UPP ? max(i1,jj) : jj ) );
1477  const size_t jend( ( IsLower<MT5>::value )
1478  ?( ( LOW )
1479  ?( min( i4+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1480  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1481  :( LOW ? min(i4+1UL,jpos) : jpos ) );
1482 
1483  if( jbegin >= jend )
1484  continue;
1485 
1486  for( size_t j=jbegin; j<jend; ++j ) {
1487  C(i1,j) -= v1 * B(i,j);
1488  C(i2,j) -= v2 * B(i,j);
1489  C(i3,j) -= v3 * B(i,j);
1490  C(i4,j) -= v4 * B(i,j);
1491  }
1492  }
1493 
1494  for( ; element!=end; ++element )
1495  {
1496  const size_t i1( element->index() );
1497 
1498  const size_t jbegin( ( IsUpper<MT5>::value )
1499  ?( ( UPP )
1500  ?( max( i1, IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) )
1501  :( max( IsStrictlyUpper<MT5>::value ? i+1UL : i, jj ) ) )
1502  :( UPP ? max(i1,jj) : jj ) );
1503  const size_t jend( ( IsLower<MT5>::value )
1504  ?( ( LOW )
1505  ?( min( i1+1UL, IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) )
1506  :( min( IsStrictlyLower<MT5>::value ? i : i+1UL, jpos ) ) )
1507  :( LOW ? min(i1+1UL,jpos) : jpos ) );
1508 
1509  if( jbegin >= jend )
1510  continue;
1511 
1512  for( size_t j=jbegin; j<jend; ++j ) {
1513  C(i1,j) -= element->value() * B(i,j);
1514  }
1515  }
1516  }
1517  }
1518  }
1520  //**********************************************************************************************
1521 
1522  //**Default subtraction assignment to dense matrices (large matrices)***************************
1536  template< typename MT3 // Type of the left-hand side target matrix
1537  , typename MT4 // Type of the left-hand side matrix operand
1538  , typename MT5 > // Type of the right-hand side matrix operand
1540  selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1541  {
1542  selectDefaultSubAssignKernel( C, A, B );
1543  }
1545  //**********************************************************************************************
1546 
1547  //**Optimized subtraction assignment to dense matrices (large matrices)*************************
1562  template< typename MT3 // Type of the left-hand side target matrix
1563  , typename MT4 // Type of the left-hand side matrix operand
1564  , typename MT5 > // Type of the right-hand side matrix operand
1566  selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
1567  {
1569 
1570  const ForwardFunctor fwd;
1571 
1572  const OppositeType_<MT4> tmp( serial( A ) );
1573  subAssign( C, fwd( tmp * B ) );
1574  }
1576  //**********************************************************************************************
1577 
1578  //**Restructuring subtraction assignment to row-major matrices**********************************
1593  template< typename MT // Type of the target matrix
1594  , bool SO > // Storage order of the target matrix
1596  subAssign( Matrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
1597  {
1599 
1601 
1602  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1603  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1604 
1605  const ForwardFunctor fwd;
1606 
1607  subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1608  }
1610  //**********************************************************************************************
1611 
1612  //**Subtraction assignment to sparse matrices***************************************************
1613  // No special implementation for the subtraction assignment to sparse matrices.
1614  //**********************************************************************************************
1615 
1616  //**Multiplication assignment to dense matrices*************************************************
1617  // No special implementation for the multiplication assignment to dense matrices.
1618  //**********************************************************************************************
1619 
1620  //**Multiplication assignment to sparse matrices************************************************
1621  // No special implementation for the multiplication assignment to sparse matrices.
1622  //**********************************************************************************************
1623 
1624  //**SMP assignment to dense matrices************************************************************
1640  template< typename MT // Type of the target dense matrix
1641  , bool SO > // Storage order of the target dense matrix
1643  smpAssign( DenseMatrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
1644  {
1646 
1647  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1648  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1649 
1650  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1651  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1652 
1653  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1654  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1655  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1656  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1657  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1658  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1659 
1660  smpAssign( ~lhs, A * B );
1661  }
1663  //**********************************************************************************************
1664 
1665  //**SMP assignment to sparse matrices***********************************************************
1681  template< typename MT // Type of the target sparse matrix
1682  , bool SO > // Storage order of the target sparse matrix
1684  smpAssign( SparseMatrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
1685  {
1687 
1689 
1696 
1697  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1698  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1699 
1700  const ForwardFunctor fwd;
1701 
1702  const TmpType tmp( rhs );
1703  smpAssign( ~lhs, fwd( tmp ) );
1704  }
1706  //**********************************************************************************************
1707 
1708  //**Restructuring SMP assignment to row-major matrices******************************************
1723  template< typename MT // Type of the target matrix
1724  , bool SO > // Storage order of the target matrix
1726  smpAssign( Matrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
1727  {
1729 
1730  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1731  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1732 
1733  const ForwardFunctor fwd;
1734 
1735  smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1736  }
1738  //**********************************************************************************************
1739 
1740  //**SMP addition assignment to dense matrices***************************************************
1756  template< typename MT // Type of the target dense matrix
1757  , bool SO > // Storage order of the target dense matrix
1760  {
1762 
1763  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1764  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1765 
1766  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1767  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1768 
1769  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1770  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1771  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1772  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1773  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1774  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1775 
1776  smpAddAssign( ~lhs, A * B );
1777  }
1779  //**********************************************************************************************
1780 
1781  //**Restructuring SMP addition assignment to row-major matrices*********************************
1796  template< typename MT // Type of the target matrix
1797  , bool SO > // Storage order of the target matrix
1799  smpAddAssign( Matrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
1800  {
1802 
1803  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1804  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1805 
1806  const ForwardFunctor fwd;
1807 
1808  smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1809  }
1811  //**********************************************************************************************
1812 
1813  //**SMP addition assignment to sparse matrices**************************************************
1814  // No special implementation for the SMP addition assignment to sparse matrices.
1815  //**********************************************************************************************
1816 
1817  //**SMP subtraction assignment to dense matrices************************************************
1833  template< typename MT // Type of the target dense matrix
1834  , bool SO > // Storage order of the target dense matrix
1837  {
1839 
1840  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1841  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1842 
1843  LT A( rhs.lhs_ ); // Evaluation of the right-hand side sparse matrix operand
1844  RT B( rhs.rhs_ ); // Evaluation of the left-hand side dense matrix operand
1845 
1846  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1847  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1848  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1849  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1850  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1851  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1852 
1853  smpSubAssign( ~lhs, A * B );
1854  }
1856  //**********************************************************************************************
1857 
1858  //**Restructuring SMP subtraction assignment to row-major matrices******************************
1873  template< typename MT // Type of the target matrix
1874  , bool SO > // Storage order of the target matrix
1876  smpSubAssign( Matrix<MT,SO>& lhs, const TSMatDMatMultExpr& rhs )
1877  {
1879 
1880  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1881  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1882 
1883  const ForwardFunctor fwd;
1884 
1885  smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) );
1886  }
1888  //**********************************************************************************************
1889 
1890  //**SMP subtraction assignment to sparse matrices***********************************************
1891  // No special implementation for the SMP subtraction assignment to sparse matrices.
1892  //**********************************************************************************************
1893 
1894  //**SMP multiplication assignment to dense matrices*********************************************
1895  // No special implementation for the SMP multiplication assignment to dense matrices.
1896  //**********************************************************************************************
1897 
1898  //**SMP multiplication assignment to sparse matrices********************************************
1899  // No special implementation for the SMP multiplication assignment to sparse matrices.
1900  //**********************************************************************************************
1901 
1902  //**Compile time checks*************************************************************************
1910  //**********************************************************************************************
1911 };
1912 //*************************************************************************************************
1913 
1914 
1915 
1916 
1917 //=================================================================================================
1918 //
1919 // GLOBAL BINARY ARITHMETIC OPERATORS
1920 //
1921 //=================================================================================================
1922 
1923 //*************************************************************************************************
1954 template< typename T1 // Type of the left-hand side sparse matrix
1955  , typename T2 > // Type of the right-hand side dense matrix
1958 {
1960 
1961  if( (~lhs).columns() != (~rhs).rows() ) {
1962  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1963  }
1964 
1966 }
1967 //*************************************************************************************************
1968 
1969 
1970 
1971 
1972 //=================================================================================================
1973 //
1974 // GLOBAL FUNCTIONS
1975 //
1976 //=================================================================================================
1977 
1978 //*************************************************************************************************
2004 template< typename MT1 // Type of the left-hand side dense matrix
2005  , typename MT2 // Type of the right-hand side dense matrix
2006  , bool SF // Symmetry flag
2007  , bool HF // Hermitian flag
2008  , bool LF // Lower flag
2009  , bool UF > // Upper flag
2012 {
2014 
2015  if( !isSquare( dm ) ) {
2016  BLAZE_THROW_INVALID_ARGUMENT( "Invalid symmetric matrix specification" );
2017  }
2018 
2019  return TSMatDMatMultExpr<MT1,MT2,true,HF,LF,UF>( dm.leftOperand(), dm.rightOperand() );
2020 }
2022 //*************************************************************************************************
2023 
2024 
2025 //*************************************************************************************************
2051 template< typename MT1 // Type of the left-hand side dense matrix
2052  , typename MT2 // Type of the right-hand side dense matrix
2053  , bool SF // Symmetry flag
2054  , bool HF // Hermitian flag
2055  , bool LF // Lower flag
2056  , bool UF > // Upper flag
2059 {
2061 
2062  if( !isSquare( dm ) ) {
2063  BLAZE_THROW_INVALID_ARGUMENT( "Invalid Hermitian matrix specification" );
2064  }
2065 
2066  return TSMatDMatMultExpr<MT1,MT2,SF,true,LF,UF>( dm.leftOperand(), dm.rightOperand() );
2067 }
2069 //*************************************************************************************************
2070 
2071 
2072 //*************************************************************************************************
2098 template< typename MT1 // Type of the left-hand side dense matrix
2099  , typename MT2 // Type of the right-hand side dense matrix
2100  , bool SF // Symmetry flag
2101  , bool HF // Hermitian flag
2102  , bool LF // Lower flag
2103  , bool UF > // Upper flag
2106 {
2108 
2109  if( !isSquare( dm ) ) {
2110  BLAZE_THROW_INVALID_ARGUMENT( "Invalid lower matrix specification" );
2111  }
2112 
2113  return TSMatDMatMultExpr<MT1,MT2,SF,HF,true,UF>( dm.leftOperand(), dm.rightOperand() );
2114 }
2116 //*************************************************************************************************
2117 
2118 
2119 //*************************************************************************************************
2145 template< typename MT1 // Type of the left-hand side dense matrix
2146  , typename MT2 // Type of the right-hand side dense matrix
2147  , bool SF // Symmetry flag
2148  , bool HF // Hermitian flag
2149  , bool LF // Lower flag
2150  , bool UF > // Upper flag
2153 {
2155 
2156  if( !isSquare( dm ) ) {
2157  BLAZE_THROW_INVALID_ARGUMENT( "Invalid upper matrix specification" );
2158  }
2159 
2160  return TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,true>( dm.leftOperand(), dm.rightOperand() );
2161 }
2163 //*************************************************************************************************
2164 
2165 
2166 //*************************************************************************************************
2192 template< typename MT1 // Type of the left-hand side dense matrix
2193  , typename MT2 // Type of the right-hand side dense matrix
2194  , bool SF // Symmetry flag
2195  , bool HF // Hermitian flag
2196  , bool LF // Lower flag
2197  , bool UF > // Upper flag
2200 {
2202 
2203  if( !isSquare( dm ) ) {
2204  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
2205  }
2206 
2207  return TSMatDMatMultExpr<MT1,MT2,SF,HF,true,true>( dm.leftOperand(), dm.rightOperand() );
2208 }
2210 //*************************************************************************************************
2211 
2212 
2213 
2214 
2215 //=================================================================================================
2216 //
2217 // ROWS SPECIALIZATIONS
2218 //
2219 //=================================================================================================
2220 
2221 //*************************************************************************************************
2223 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2224 struct Rows< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public Rows<MT1>
2225 {};
2227 //*************************************************************************************************
2228 
2229 
2230 
2231 
2232 //=================================================================================================
2233 //
2234 // COLUMNS SPECIALIZATIONS
2235 //
2236 //=================================================================================================
2237 
2238 //*************************************************************************************************
2240 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2241 struct Columns< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public Columns<MT2>
2242 {};
2244 //*************************************************************************************************
2245 
2246 
2247 
2248 
2249 //=================================================================================================
2250 //
2251 // ISALIGNED SPECIALIZATIONS
2252 //
2253 //=================================================================================================
2254 
2255 //*************************************************************************************************
2257 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2258 struct IsAligned< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2259  : public BoolConstant< IsAligned<MT2>::value >
2260 {};
2262 //*************************************************************************************************
2263 
2264 
2265 
2266 
2267 //=================================================================================================
2268 //
2269 // ISSYMMETRIC SPECIALIZATIONS
2270 //
2271 //=================================================================================================
2272 
2273 //*************************************************************************************************
2275 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2276 struct IsSymmetric< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2277  : public BoolConstant< Or< Bool<SF>
2278  , And< Bool<HF>
2279  , IsBuiltin< ElementType_< TSMatDMatMultExpr<MT1,MT2,false,true,false,false> > > >
2280  , And< Bool<LF>, Bool<UF> > >::value >
2281 {};
2283 //*************************************************************************************************
2284 
2285 
2286 
2287 
2288 //=================================================================================================
2289 //
2290 // ISHERMITIAN SPECIALIZATIONS
2291 //
2292 //=================================================================================================
2293 
2294 //*************************************************************************************************
2296 template< typename MT1, typename MT2, bool SF, bool LF, bool UF >
2297 struct IsHermitian< TSMatDMatMultExpr<MT1,MT2,SF,true,LF,UF> >
2298  : public TrueType
2299 {};
2301 //*************************************************************************************************
2302 
2303 
2304 
2305 
2306 //=================================================================================================
2307 //
2308 // ISLOWER SPECIALIZATIONS
2309 //
2310 //=================================================================================================
2311 
2312 //*************************************************************************************************
2314 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2315 struct IsLower< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2316  : public BoolConstant< Or< Bool<LF>
2317  , And< IsLower<MT1>, IsLower<MT2> >
2318  , And< Or< Bool<SF>, Bool<HF> >
2319  , IsUpper<MT1>, IsUpper<MT2> > >::value >
2320 {};
2322 //*************************************************************************************************
2323 
2324 
2325 
2326 
2327 //=================================================================================================
2328 //
2329 // ISUNILOWER SPECIALIZATIONS
2330 //
2331 //=================================================================================================
2332 
2333 //*************************************************************************************************
2335 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2336 struct IsUniLower< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2337  : public BoolConstant< Or< And< IsUniLower<MT1>, IsUniLower<MT2> >
2338  , And< Or< Bool<SF>, Bool<HF> >
2339  , IsUniUpper<MT1>, IsUniUpper<MT2> > >::value >
2340 {};
2342 //*************************************************************************************************
2343 
2344 
2345 
2346 
2347 //=================================================================================================
2348 //
2349 // ISSTRICTLYLOWER SPECIALIZATIONS
2350 //
2351 //=================================================================================================
2352 
2353 //*************************************************************************************************
2355 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2356 struct IsStrictlyLower< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2357  : public BoolConstant< Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2358  , And< IsStrictlyLower<MT2>, IsLower<MT1> >
2359  , And< Or< Bool<SF>, Bool<HF> >
2360  , Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2361  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > > > >::value >
2362 {};
2364 //*************************************************************************************************
2365 
2366 
2367 
2368 
2369 //=================================================================================================
2370 //
2371 // ISUPPER SPECIALIZATIONS
2372 //
2373 //=================================================================================================
2374 
2375 //*************************************************************************************************
2377 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2378 struct IsUpper< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2379  : public BoolConstant< Or< Bool<UF>
2380  , And< IsUpper<MT1>, IsUpper<MT2> >
2381  , And< Or< Bool<SF>, Bool<HF> >
2382  , IsLower<MT1>, IsLower<MT2> > >::value >
2383 {};
2385 //*************************************************************************************************
2386 
2387 
2388 
2389 
2390 //=================================================================================================
2391 //
2392 // ISUNIUPPER SPECIALIZATIONS
2393 //
2394 //=================================================================================================
2395 
2396 //*************************************************************************************************
2398 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2399 struct IsUniUpper< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2400  : public BoolConstant< Or< And< IsUniUpper<MT1>, IsUniUpper<MT2> >
2401  , And< Or< Bool<SF>, Bool<HF> >
2402  , IsUniLower<MT1>, IsUniLower<MT2> > >::value >
2403 {};
2405 //*************************************************************************************************
2406 
2407 
2408 
2409 
2410 //=================================================================================================
2411 //
2412 // ISSTRICTLYUPPER SPECIALIZATIONS
2413 //
2414 //=================================================================================================
2415 
2416 //*************************************************************************************************
2418 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2419 struct IsStrictlyUpper< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2420  : public BoolConstant< Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
2421  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> >
2422  , And< Or< Bool<SF>, Bool<HF> >
2423  , Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
2424  , And< IsStrictlyLower<MT2>, IsLower<MT1> > > > >::value >
2425 {};
2427 //*************************************************************************************************
2428 
2429 
2430 
2431 
2432 //=================================================================================================
2433 //
2434 // EXPRESSION TRAIT SPECIALIZATIONS
2435 //
2436 //=================================================================================================
2437 
2438 //*************************************************************************************************
2440 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF, typename VT >
2441 struct TDMatDVecMultExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, VT >
2442 {
2443  public:
2444  //**********************************************************************************************
2449  , INVALID_TYPE >;
2450  //**********************************************************************************************
2451 };
2453 //*************************************************************************************************
2454 
2455 
2456 //*************************************************************************************************
2458 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF, typename VT >
2459 struct TDMatSVecMultExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, VT >
2460 {
2461  public:
2462  //**********************************************************************************************
2467  , INVALID_TYPE >;
2468  //**********************************************************************************************
2469 };
2471 //*************************************************************************************************
2472 
2473 
2474 //*************************************************************************************************
2476 template< typename VT, typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2477 struct TDVecTDMatMultExprTrait< VT, TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2478 {
2479  public:
2480  //**********************************************************************************************
2485  , INVALID_TYPE >;
2486  //**********************************************************************************************
2487 };
2489 //*************************************************************************************************
2490 
2491 
2492 //*************************************************************************************************
2494 template< typename VT, typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2495 struct TSVecTDMatMultExprTrait< VT, TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2496 {
2497  public:
2498  //**********************************************************************************************
2503  , INVALID_TYPE >;
2504  //**********************************************************************************************
2505 };
2507 //*************************************************************************************************
2508 
2509 
2510 //*************************************************************************************************
2512 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2513 struct TDMatDeclSymExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2514 {
2515  public:
2516  //**********************************************************************************************
2520  , INVALID_TYPE >;
2521  //**********************************************************************************************
2522 };
2524 //*************************************************************************************************
2525 
2526 
2527 //*************************************************************************************************
2529 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2530 struct TDMatDeclHermExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2531 {
2532  public:
2533  //**********************************************************************************************
2537  , INVALID_TYPE >;
2538  //**********************************************************************************************
2539 };
2541 //*************************************************************************************************
2542 
2543 
2544 //*************************************************************************************************
2546 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2547 struct TDMatDeclLowExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2548 {
2549  public:
2550  //**********************************************************************************************
2554  , INVALID_TYPE >;
2555  //**********************************************************************************************
2556 };
2558 //*************************************************************************************************
2559 
2560 
2561 //*************************************************************************************************
2563 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2564 struct TDMatDeclUppExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2565 {
2566  public:
2567  //**********************************************************************************************
2571  , INVALID_TYPE >;
2572  //**********************************************************************************************
2573 };
2575 //*************************************************************************************************
2576 
2577 
2578 //*************************************************************************************************
2580 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2581 struct TDMatDeclDiagExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2582 {
2583  public:
2584  //**********************************************************************************************
2588  , INVALID_TYPE >;
2589  //**********************************************************************************************
2590 };
2592 //*************************************************************************************************
2593 
2594 
2595 //*************************************************************************************************
2597 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF, bool AF >
2598 struct SubmatrixExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, AF >
2599 {
2600  public:
2601  //**********************************************************************************************
2604  //**********************************************************************************************
2605 };
2607 //*************************************************************************************************
2608 
2609 
2610 //*************************************************************************************************
2612 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2613 struct RowExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2614 {
2615  public:
2616  //**********************************************************************************************
2617  using Type = MultExprTrait_< RowExprTrait_<const MT1>, MT2 >;
2618  //**********************************************************************************************
2619 };
2621 //*************************************************************************************************
2622 
2623 
2624 //*************************************************************************************************
2626 template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF >
2627 struct ColumnExprTrait< TSMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> >
2628 {
2629  public:
2630  //**********************************************************************************************
2632  //**********************************************************************************************
2633 };
2635 //*************************************************************************************************
2636 
2637 } // namespace blaze
2638 
2639 #endif
typename SubmatrixExprTrait< MT, AF >::Type SubmatrixExprTrait_
Auxiliary alias declaration for the SubmatrixExprTrait type trait.The SubmatrixExprTrait_ alias decla...
Definition: SubmatrixExprTrait.h:134
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: TSMatDMatMultExpr.h:265
#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
If_< IsExpression< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:271
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
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
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: TSMatDMatMultExpr.h:441
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.
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.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TSMatDMatMultExpr.h:313
Header file for the serial shim.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: TSMatDMatMultExpr.h:387
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
Header file for the ColumnExprTrait class template.
Header file for the DeclUpp functor.
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatDMatMultExpr.h:458
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
Header file for the TSVecTSMatMultExprTrait class template.
ResultType_< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:156
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
ElementType_< RT2 > ET2
Element type of the right-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:158
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 DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
IfTrue_< evaluateLeft, const RT1, CT1 > LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: TSMatDMatMultExpr.h:277
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
CompositeType_< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:160
Flag for lower matrices.
Definition: TSMatDMatMultExpr.h:178
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatDMatMultExpr.h:397
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.
Header file for the TDMatDeclDiagExprTrait class template.
Header file for the RequiresEvaluation type trait.
System settings for performance optimizations.
CompositeType_< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:159
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatDMatMultExpr.h:267
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
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: TSMatDMatMultExpr.h:377
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
RightOperand rhs_
Right-hand side dense matrix of the multiplication expression.
Definition: TSMatDMatMultExpr.h:459
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: TSMatDMatMultExpr.h:263
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
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:86
IfTrue_< evaluateRight, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: TSMatDMatMultExpr.h:280
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TSMatDMatMultExpr.h:264
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.
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
Flag for Hermitian matrices.
Definition: TSMatDMatMultExpr.h:177
Flag for upper matrices.
Definition: TSMatDMatMultExpr.h:179
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
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.
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.
Header file for the TSMatDVecMultExprTrait class template.
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
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 DMatDVecMultExprTrait class template.
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:90
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
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatDMatMultExpr.h:268
#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
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: TSMatDMatMultExpr.h:361
Evaluation of the expression type of a dense matrix declsym operation.Via this type trait it is possi...
Definition: TDMatDeclSymExprTrait.h:75
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: TSMatDMatMultExpr.h:451
Constraints on the storage order of matrix types.
typename TDVecDMatMultExprTrait< VT, MT >::Type TDVecDMatMultExprTrait_
Auxiliary alias declaration for the TDVecDMatMultExprTrait class template.The TDVecDMatMultExprTrait_...
Definition: TDVecDMatMultExprTrait.h:119
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
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: TSMatDMatMultExpr.h:407
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
ResultType_< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: TSMatDMatMultExpr.h:155
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
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
Flag for symmetric matrices.
Definition: TSMatDMatMultExpr.h:176
Utility type for generic codes.
Header file for the TDMatDeclLowExprTrait class template.
ElementType_< RT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:157
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
TSMatDMatMultExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the TSMatDMatMultExpr class.
Definition: TSMatDMatMultExpr.h:298
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
Constraints on the storage order of matrix types.
Generic wrapper for the declherm() function.
Definition: DeclHerm.h:58
Header file for the TDMatDeclSymExprTrait class template.
Header file for the Noop functor.
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.
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
ElementType_< ResultType > ElementType
Resulting element type.
Definition: TSMatDMatMultExpr.h:266
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: TSMatDMatMultExpr.h:431
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.
Header file for the IsBuiltin type trait.
Expression object for transpose sparse matrix-dense matrix multiplications.The TSMatDMatMultExpr clas...
Definition: Forward.h:150
Header file for the TDVecDMatMultExprTrait class template.
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
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: TSMatDMatMultExpr.h:419
Header file for the TSVecDMatMultExprTrait class template.
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:78
Header file for the DeclHerm functor.
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.
Header file for the DMatSVecMultExprTrait class template.
Header file for the IsColumnVector type trait.
Constraint on the data type.
TSMatDMatMultExpr< MT1, MT2, SF, HF, LF, UF > This
Type of this TSMatDMatMultExpr instance.
Definition: TSMatDMatMultExpr.h:261
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
If_< IsExpression< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: TSMatDMatMultExpr.h:274
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.
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.