SMatSMatMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATSMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATSMATMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <vector>
45 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
55 #include <blaze/math/Functions.h>
56 #include <blaze/math/Infinity.h>
58 #include <blaze/math/shims/Reset.h>
91 #include <blaze/util/Assert.h>
92 #include <blaze/util/DisableIf.h>
93 #include <blaze/util/EnableIf.h>
95 #include <blaze/util/InvalidType.h>
97 #include <blaze/util/mpl/And.h>
98 #include <blaze/util/mpl/If.h>
99 #include <blaze/util/mpl/Or.h>
100 #include <blaze/util/Types.h>
102 #include <blaze/util/Unused.h>
103 
104 
105 namespace blaze {
106 
107 //=================================================================================================
108 //
109 // CLASS SMATSMATMULTEXPR
110 //
111 //=================================================================================================
112 
113 //*************************************************************************************************
120 template< typename MT1 // Type of the left-hand side sparse matrix
121  , typename MT2 > // Type of the right-hand side sparse matrix
122 class SMatSMatMultExpr : public SparseMatrix< SMatSMatMultExpr<MT1,MT2>, false >
123  , private MatMatMultExpr
124  , private Computation
125 {
126  private:
127  //**Type definitions****************************************************************************
132  //**********************************************************************************************
133 
134  //**********************************************************************************************
136  enum : bool { evaluateLeft = RequiresEvaluation<MT1>::value };
137  //**********************************************************************************************
138 
139  //**********************************************************************************************
141  enum : bool { evaluateRight = RequiresEvaluation<MT2>::value };
142  //**********************************************************************************************
143 
144  //**********************************************************************************************
146 
151  template< typename T1, typename T2, typename T3 >
152  struct CanExploitSymmetry {
153  enum : bool { value = IsColumnMajorMatrix<T1>::value &&
154  IsSymmetric<T2>::value && IsSymmetric<T3>::value };
155  };
157  //**********************************************************************************************
158 
159  //**********************************************************************************************
161 
166  template< typename T1, typename T2, typename T3 >
167  struct IsEvaluationRequired {
168  enum : bool { value = ( evaluateLeft || evaluateRight ) &&
169  !CanExploitSymmetry<T1,T2,T3>::value };
170  };
172  //**********************************************************************************************
173 
174  public:
175  //**Type definitions****************************************************************************
181  typedef const ElementType ReturnType;
182  typedef const ResultType CompositeType;
183 
185  typedef If_< IsExpression<MT1>, const MT1, const MT1& > LeftOperand;
186 
188  typedef If_< IsExpression<MT2>, const MT2, const MT2& > RightOperand;
189  //**********************************************************************************************
190 
191  //**Compilation flags***************************************************************************
193  enum : bool { smpAssignable = !evaluateLeft && MT1::smpAssignable &&
194  !evaluateRight && MT2::smpAssignable };
195  //**********************************************************************************************
196 
197  //**Constructor*********************************************************************************
203  explicit inline SMatSMatMultExpr( const MT1& lhs, const MT2& rhs ) noexcept
204  : lhs_( lhs ) // Left-hand side sparse matrix of the multiplication expression
205  , rhs_( rhs ) // Right-hand side sparse matrix of the multiplication expression
206  {
207  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.rows(), "Invalid matrix sizes" );
208  }
209  //**********************************************************************************************
210 
211  //**Access operator*****************************************************************************
218  inline ReturnType operator()( size_t i, size_t j ) const {
219  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
220  BLAZE_INTERNAL_ASSERT( j < rhs_.columns(), "Invalid column access index" );
221 
222  if( IsDiagonal<MT1>::value ) {
223  return lhs_(i,i) * rhs_(i,j);
224  }
225  else if( IsDiagonal<MT2>::value ) {
226  return lhs_(i,j) * rhs_(j,j);
227  }
229  const size_t begin( ( IsUpper<MT1>::value )
230  ?( ( IsLower<MT2>::value )
231  ?( max( ( IsStrictlyUpper<MT1>::value ? i+1UL : i )
232  , ( IsStrictlyLower<MT2>::value ? j+1UL : j ) ) )
233  :( IsStrictlyUpper<MT1>::value ? i+1UL : i ) )
234  :( ( IsLower<MT2>::value )
235  ?( IsStrictlyLower<MT2>::value ? j+1UL : j )
236  :( 0UL ) ) );
237  const size_t end( ( IsLower<MT1>::value )
238  ?( ( IsUpper<MT2>::value )
239  ?( min( ( IsStrictlyLower<MT1>::value ? i : i+1UL )
240  , ( IsStrictlyUpper<MT2>::value ? j : j+1UL ) ) )
241  :( IsStrictlyLower<MT1>::value ? i : i+1UL ) )
242  :( ( IsUpper<MT2>::value )
243  ?( IsStrictlyUpper<MT2>::value ? j : j+1UL )
244  :( lhs_.columns() ) ) );
245 
246  if( begin >= end ) return ElementType();
247 
248  const size_t n( end - begin );
249 
250  return subvector( row( lhs_, i ), begin, n ) * subvector( column( rhs_, j ), begin, n );
251  }
252  else {
253  return row( lhs_, i ) * column( rhs_, j );
254  }
255  }
256  //**********************************************************************************************
257 
258  //**At function*********************************************************************************
266  inline ReturnType at( size_t i, size_t j ) const {
267  if( i >= lhs_.rows() ) {
268  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
269  }
270  if( j >= rhs_.columns() ) {
271  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
272  }
273  return (*this)(i,j);
274  }
275  //**********************************************************************************************
276 
277  //**Rows function*******************************************************************************
282  inline size_t rows() const noexcept {
283  return lhs_.rows();
284  }
285  //**********************************************************************************************
286 
287  //**Columns function****************************************************************************
292  inline size_t columns() const noexcept {
293  return rhs_.columns();
294  }
295  //**********************************************************************************************
296 
297  //**NonZeros function***************************************************************************
302  inline constexpr size_t nonZeros() const noexcept {
303  return 0UL;
304  }
305  //**********************************************************************************************
306 
307  //**NonZeros function***************************************************************************
313  inline size_t nonZeros( size_t i ) const noexcept {
314  UNUSED_PARAMETER( i );
315  return 0UL;
316  }
317  //**********************************************************************************************
318 
319  //**Left operand access*************************************************************************
324  inline LeftOperand leftOperand() const noexcept {
325  return lhs_;
326  }
327  //**********************************************************************************************
328 
329  //**Right operand access************************************************************************
334  inline RightOperand rightOperand() const noexcept {
335  return rhs_;
336  }
337  //**********************************************************************************************
338 
339  //**********************************************************************************************
345  template< typename T >
346  inline bool canAlias( const T* alias ) const noexcept {
347  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
348  }
349  //**********************************************************************************************
350 
351  //**********************************************************************************************
357  template< typename T >
358  inline bool isAliased( const T* alias ) const noexcept {
359  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
360  }
361  //**********************************************************************************************
362 
363  //**********************************************************************************************
368  inline bool canSMPAssign() const noexcept {
369  return ( rows() * columns() >= SMP_SMATSMATMULT_THRESHOLD );
370  }
371  //**********************************************************************************************
372 
373  private:
374  //**Member variables****************************************************************************
375  LeftOperand lhs_;
376  RightOperand rhs_;
377  //**********************************************************************************************
378 
379  //**Assignment to dense matrices****************************************************************
392  template< typename MT // Type of the target dense matrix
393  , bool SO > // Storage order of the target dense matrix
395  assign( DenseMatrix<MT,SO>& lhs, const SMatSMatMultExpr& rhs )
396  {
398 
399  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
400  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
401 
402  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse matrix operand
403  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
404 
405  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
406  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
407  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
408  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
409  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
410  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
411 
412  SMatSMatMultExpr::selectAssignKernel( ~lhs, A, B );
413  }
415  //**********************************************************************************************
416 
417  //**Default assignment to dense matrices********************************************************
430  template< typename MT3 // Type of the left-hand side target matrix
431  , typename MT4 // Type of the left-hand side matrix operand
432  , typename MT5 > // Type of the right-hand side matrix operand
433  static inline void selectAssignKernel( MT3& C, const MT4& A, const MT5& B )
434  {
435  typedef ConstIterator_<MT4> LeftIterator;
436  typedef ConstIterator_<MT5> RightIterator;
437 
438  for( size_t i=0UL; i<C.rows(); ++i ) {
439  const LeftIterator lend( A.end(i) );
440  for( LeftIterator lelem=A.begin(i); lelem!=lend; ++lelem ) {
441  const RightIterator rend( B.end( lelem->index() ) );
442  for( RightIterator relem=B.begin( lelem->index() ); relem!=rend; ++relem )
443  {
444  if( IsResizable< ElementType_<MT3> >::value &&
445  isDefault( C(i,relem->index()) ) ) {
446  C(i,relem->index()) = lelem->value() * relem->value();
447  }
448  else {
449  C(i,relem->index()) += lelem->value() * relem->value();
450  }
451  }
452  }
453  }
454  }
456  //**********************************************************************************************
457 
458  //**Assignment to row-major sparse matrices*****************************************************
471  template< typename MT > // Type of the target sparse matrix
472  friend inline void assign( SparseMatrix<MT,false>& lhs, const SMatSMatMultExpr& rhs )
473  {
475 
476  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
477  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
478 
479  typedef ConstIterator_< RemoveReference_<CT1> > LeftIterator;
480  typedef ConstIterator_< RemoveReference_<CT2> > RightIterator;
481 
482  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse matrix operand
483  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
484 
485  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
486  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
487  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
488  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
489  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
490  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
491 
492  // (Over-)Estimating the number of non-zero entries in the resulting matrix
493  size_t nonzeros( 0UL );
494 
495  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
496  const LeftIterator lend( A.end(i) );
497  for( LeftIterator lelem=A.begin(i); lelem!=lend; ++lelem ) {
498  nonzeros += B.nonZeros( lelem->index() );
499  }
500  }
501 
502  if( nonzeros > (~lhs).rows() * (~lhs).columns() ) {
503  nonzeros = (~lhs).rows() * (~lhs).columns();
504  }
505 
506  (~lhs).reserve( nonzeros );
507  nonzeros = 0UL;
508 
509  // Performing the matrix-matrix multiplication
510  std::vector<ElementType> values ( (~lhs).columns(), ElementType() );
511  std::vector<byte_t> valid ( (~lhs).columns(), 0 );
512  std::vector<size_t> indices( (~lhs).columns(), 0UL );
513  size_t minIndex( inf ), maxIndex( 0UL );
514 
515  for( size_t i=0UL; i<(~lhs).rows(); ++i )
516  {
517  const LeftIterator lend( A.end(i) );
518  for( LeftIterator lelem=A.begin(i); lelem!=lend; ++lelem )
519  {
520  const RightIterator rend( B.end( lelem->index() ) );
521  for( RightIterator relem=B.begin( lelem->index() ); relem!=rend; ++relem )
522  {
523  if( !valid[relem->index()] ) {
524  values[relem->index()] = lelem->value() * relem->value();
525  valid [relem->index()] = 1;
526  indices[nonzeros] = relem->index();
527  ++nonzeros;
528  if( relem->index() < minIndex ) minIndex = relem->index();
529  if( relem->index() > maxIndex ) maxIndex = relem->index();
530  }
531  else {
532  values[relem->index()] += lelem->value() * relem->value();
533  }
534  }
535  }
536 
537  BLAZE_INTERNAL_ASSERT( nonzeros <= (~lhs).columns(), "Invalid number of non-zero elements" );
538 
539  if( nonzeros > 0UL )
540  {
541  BLAZE_INTERNAL_ASSERT( minIndex <= maxIndex, "Invalid index detected" );
542 
543  if( ( nonzeros + nonzeros ) < ( maxIndex - minIndex ) )
544  {
545  std::sort( indices.begin(), indices.begin() + nonzeros );
546 
547  for( size_t j=0UL; j<nonzeros; ++j )
548  {
549  const size_t index( indices[j] );
550  if( !isDefault( values[index] ) ) {
551  (~lhs).append( i, index, values[index] );
552  reset( values[index] );
553  }
554 
555  reset( valid [index] );
556  }
557  }
558  else {
559  for( size_t j=minIndex; j<=maxIndex; ++j )
560  {
561  if( !isDefault( values[j] ) ) {
562  (~lhs).append( i, j, values[j] );
563  reset( values[j] );
564  }
565 
566  reset( valid [j] );
567  }
568  }
569 
570  nonzeros = 0UL;
571  minIndex = inf;
572  maxIndex = 0UL;
573  }
574 
575  (~lhs).finalize( i );
576  }
577  }
579  //**********************************************************************************************
580 
581  //**Assignment to column-major sparse matrices**************************************************
594  template< typename MT > // Type of the target sparse matrix
595  friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> >
596  assign( SparseMatrix<MT,true>& lhs, const SMatSMatMultExpr& rhs )
597  {
599 
601 
602  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
603  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
604 
607 
608  const ResultType tmp( serial( rhs ) );
609  (~lhs).reserve( tmp.nonZeros() );
610  assign( ~lhs, tmp );
611  }
613  //**********************************************************************************************
614 
615  //**Restructuring assignment to column-major matrices*******************************************
630  template< typename MT > // Type of the target matrix
631  friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
632  assign( Matrix<MT,true>& lhs, const SMatSMatMultExpr& rhs )
633  {
635 
637 
638  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
639  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
640 
641  assign( ~lhs, trans( rhs.lhs_ ) * trans( rhs.rhs_ ) );
642  }
644  //**********************************************************************************************
645 
646  //**Addition assignment to dense matrices*******************************************************
659  template< typename MT // Type of the target dense matrix
660  , bool SO > // Storage order of the target dense matarix
661  friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> >
662  addAssign( DenseMatrix<MT,SO>& lhs, const SMatSMatMultExpr& rhs )
663  {
665 
666  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
667  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
668 
669  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse matrix operand
670  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
671 
672  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
673  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
674  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
675  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
676  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
677  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
678 
679  SMatSMatMultExpr::selectAddAssignKernel( ~lhs, A, B );
680  }
682  //**********************************************************************************************
683 
684  //**Default addition assignment to dense matrices***********************************************
698  template< typename MT3 // Type of the left-hand side target matrix
699  , typename MT4 // Type of the left-hand side matrix operand
700  , typename MT5 > // Type of the right-hand side matrix operand
701  static inline void selectAddAssignKernel( MT3& C, const MT4& A, const MT5& B )
702  {
703  typedef ConstIterator_<MT4> LeftIterator;
704  typedef ConstIterator_<MT5> RightIterator;
705 
706  for( size_t i=0UL; i<C.rows(); ++i ) {
707  const LeftIterator lend( A.end(i) );
708  for( LeftIterator lelem=A.begin(i); lelem!=lend; ++lelem ) {
709  const RightIterator rend( B.end( lelem->index() ) );
710  for( RightIterator relem=B.begin( lelem->index() ); relem!=rend; ++relem ) {
711  C(i,relem->index()) += lelem->value() * relem->value();
712  }
713  }
714  }
715  }
717  //**********************************************************************************************
718 
719  //**Restructuring addition assignment to column-major matrices**********************************
734  template< typename MT > // Type of the target matrix
735  friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
736  addAssign( Matrix<MT,true>& lhs, const SMatSMatMultExpr& rhs )
737  {
739 
741 
742  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
743  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
744 
745  addAssign( ~lhs, trans( rhs.lhs_ ) * trans( rhs.rhs_ ) );
746  }
748  //**********************************************************************************************
749 
750  //**Addition assignment to sparse matrices******************************************************
751  // No special implementation for the addition assignment to sparse matrices.
752  //**********************************************************************************************
753 
754  //**Subtraction assignment to dense matrices****************************************************
767  template< typename MT // Type of the target dense matrix
768  , bool SO > // Storage order of the target dense matrix
769  friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> >
770  subAssign( DenseMatrix<MT,SO>& lhs, const SMatSMatMultExpr& rhs )
771  {
773 
774  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
775  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
776 
777  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse matrix operand
778  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
779 
780  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
781  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
782  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
783  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
784  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
785  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
786 
787  SMatSMatMultExpr::selectSubAssignKernel( ~lhs, A, B );
788  }
790  //**********************************************************************************************
791 
792  //**Default subtraction assignment to dense matrices********************************************
806  template< typename MT3 // Type of the left-hand side target matrix
807  , typename MT4 // Type of the left-hand side matrix operand
808  , typename MT5 > // Type of the right-hand side matrix operand
809  static inline void selectSubAssignKernel( MT3& C, const MT4& A, const MT5& B )
810  {
811  typedef ConstIterator_<MT4> LeftIterator;
812  typedef ConstIterator_<MT5> RightIterator;
813 
814  for( size_t i=0UL; i<C.rows(); ++i ) {
815  const LeftIterator lend( A.end(i) );
816  for( LeftIterator lelem=A.begin(i); lelem!=lend; ++lelem ) {
817  const RightIterator rend( B.end( lelem->index() ) );
818  for( RightIterator relem=B.begin( lelem->index() ); relem!=rend; ++relem ) {
819  C(i,relem->index()) -= lelem->value() * relem->value();
820  }
821  }
822  }
823  }
825  //**********************************************************************************************
826 
827  //**Restructuring subtraction assignment to column-major matrices*******************************
842  template< typename MT > // Type of the target matrix
843  friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
844  subAssign( Matrix<MT,true>& lhs, const SMatSMatMultExpr& rhs )
845  {
847 
849 
850  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
851  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
852 
853  subAssign( ~lhs, trans( rhs.lhs_ ) * trans( rhs.rhs_ ) );
854  }
856  //**********************************************************************************************
857 
858  //**Subtraction assignment to sparse matrices***************************************************
859  // No special implementation for the subtraction assignment to sparse matrices.
860  //**********************************************************************************************
861 
862  //**Multiplication assignment to dense matrices*************************************************
863  // No special implementation for the multiplication assignment to dense matrices.
864  //**********************************************************************************************
865 
866  //**Multiplication assignment to sparse matrices************************************************
867  // No special implementation for the multiplication assignment to sparse matrices.
868  //**********************************************************************************************
869 
870  //**SMP assignment to matrices******************************************************************
885  template< typename MT // Type of the target matrix
886  , bool SO > // Storage order of the target matrix
887  friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> >
888  smpAssign( Matrix<MT,SO>& lhs, const SMatSMatMultExpr& rhs )
889  {
891 
892  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
893  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
894 
895  CT1 A( rhs.lhs_ ); // Evaluation of the left-hand side sparse matrix operand
896  CT2 B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
897 
898  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
899  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
900  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
901  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
902  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
903  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
904 
905  smpAssign( ~lhs, A * B );
906  }
908  //**********************************************************************************************
909 
910  //**Restructuring SMP assignment to column-major matrices***************************************
925  template< typename MT > // Type of the target matrix
926  friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
927  smpAssign( Matrix<MT,true>& lhs, const SMatSMatMultExpr& rhs )
928  {
930 
932 
933  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
934  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
935 
936  smpAssign( ~lhs, trans( rhs.lhs_ ) * trans( rhs.rhs_ ) );
937  }
939  //**********************************************************************************************
940 
941  //**SMP addition assignment to dense matrices***************************************************
957  template< typename MT // Type of the target dense matrix
958  , bool SO > // Storage order of the target dense matarix
959  friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> >
960  smpAddAssign( DenseMatrix<MT,SO>& lhs, const SMatSMatMultExpr& rhs )
961  {
963 
964  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
965  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
966 
967  CT1 A( rhs.lhs_ ); // Evaluation of the left-hand side sparse matrix operand
968  CT2 B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
969 
970  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
971  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
972  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
973  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
974  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
975  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
976 
977  smpAddAssign( ~lhs, A * B );
978  }
980  //**********************************************************************************************
981 
982  //**Restructuring SMP addition assignment to column-major matrices******************************
997  template< typename MT > // Type of the target matrix
998  friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
999  smpAddAssign( Matrix<MT,true>& lhs, const SMatSMatMultExpr& rhs )
1000  {
1002 
1004 
1005  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1006  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1007 
1008  smpAddAssign( ~lhs, trans( rhs.lhs_ ) * trans( rhs.rhs_ ) );
1009  }
1011  //**********************************************************************************************
1012 
1013  //**SMP addition assignment to sparse matrices**************************************************
1014  // No special implementation for the SMP addition assignment to sparse matrices.
1015  //**********************************************************************************************
1016 
1017  //**SMP subtraction assignment to dense matrices************************************************
1033  template< typename MT // Type of the target dense matrix
1034  , bool SO > // Storage order of the target dense matrix
1035  friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> >
1036  smpSubAssign( DenseMatrix<MT,SO>& lhs, const SMatSMatMultExpr& rhs )
1037  {
1039 
1040  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1041  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1042 
1043  CT1 A( rhs.lhs_ ); // Evaluation of the left-hand side sparse matrix operand
1044  CT2 B( rhs.rhs_ ); // Evaluation of the right-hand side sparse matrix operand
1045 
1046  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
1047  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
1048  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
1049  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
1050  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
1051  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
1052 
1053  smpSubAssign( ~lhs, A * B );
1054  }
1056  //**********************************************************************************************
1057 
1058  //**Restructuring SMP subtraction assignment to column-major matrices***************************
1073  template< typename MT > // Type of the target matrix
1074  friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> >
1075  smpSubAssign( Matrix<MT,true>& lhs, const SMatSMatMultExpr& rhs )
1076  {
1078 
1080 
1081  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1082  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1083 
1084  smpSubAssign( ~lhs, trans( rhs.lhs_ ) * trans( rhs.rhs_ ) );
1085  }
1087  //**********************************************************************************************
1088 
1089  //**SMP subtraction assignment to sparse matrices***********************************************
1090  // No special implementation for the SMP subtraction assignment to sparse matrices.
1091  //**********************************************************************************************
1092 
1093  //**SMP multiplication assignment to dense matrices*********************************************
1094  // No special implementation for the SMP multiplication assignment to dense matrices.
1095  //**********************************************************************************************
1096 
1097  //**SMP multiplication assignment to sparse matrices********************************************
1098  // No special implementation for the SMP multiplication assignment to sparse matrices.
1099  //**********************************************************************************************
1100 
1101  //**Compile time checks*************************************************************************
1109  //**********************************************************************************************
1110 };
1111 //*************************************************************************************************
1112 
1113 
1114 
1115 
1116 //=================================================================================================
1117 //
1118 // GLOBAL BINARY ARITHMETIC OPERATORS
1119 //
1120 //=================================================================================================
1121 
1122 //*************************************************************************************************
1149 template< typename T1 // Type of the left-hand side sparse matrix
1150  , typename T2 > // Type of the right-hand side sparse matrix
1151 inline const SMatSMatMultExpr<T1,T2>
1153 {
1155 
1156  if( (~lhs).columns() != (~rhs).rows() ) {
1157  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1158  }
1159 
1160  return SMatSMatMultExpr<T1,T2>( ~lhs, ~rhs );
1161 }
1162 //*************************************************************************************************
1163 
1164 
1165 
1166 
1167 //=================================================================================================
1168 //
1169 // ROWS SPECIALIZATIONS
1170 //
1171 //=================================================================================================
1172 
1173 //*************************************************************************************************
1175 template< typename MT1, typename MT2 >
1176 struct Rows< SMatSMatMultExpr<MT1,MT2> > : public Rows<MT1>
1177 {};
1179 //*************************************************************************************************
1180 
1181 
1182 
1183 
1184 //=================================================================================================
1185 //
1186 // COLUMNS SPECIALIZATIONS
1187 //
1188 //=================================================================================================
1189 
1190 //*************************************************************************************************
1192 template< typename MT1, typename MT2 >
1193 struct Columns< SMatSMatMultExpr<MT1,MT2> > : public Columns<MT2>
1194 {};
1196 //*************************************************************************************************
1197 
1198 
1199 
1200 
1201 //=================================================================================================
1202 //
1203 // ISLOWER SPECIALIZATIONS
1204 //
1205 //=================================================================================================
1206 
1207 //*************************************************************************************************
1209 template< typename MT1, typename MT2 >
1210 struct IsLower< SMatSMatMultExpr<MT1,MT2> >
1211  : public BoolConstant< And< IsLower<MT1>, IsLower<MT2> >::value >
1212 {};
1214 //*************************************************************************************************
1215 
1216 
1217 
1218 
1219 //=================================================================================================
1220 //
1221 // ISUNILOWER SPECIALIZATIONS
1222 //
1223 //=================================================================================================
1224 
1225 //*************************************************************************************************
1227 template< typename MT1, typename MT2 >
1228 struct IsUniLower< SMatSMatMultExpr<MT1,MT2> >
1229  : public BoolConstant< And< IsUniLower<MT1>, IsUniLower<MT2> >::value >
1230 {};
1232 //*************************************************************************************************
1233 
1234 
1235 
1236 
1237 //=================================================================================================
1238 //
1239 // ISSTRICTLYLOWER SPECIALIZATIONS
1240 //
1241 //=================================================================================================
1242 
1243 //*************************************************************************************************
1245 template< typename MT1, typename MT2 >
1246 struct IsStrictlyLower< SMatSMatMultExpr<MT1,MT2> >
1247  : public BoolConstant< Or< And< IsStrictlyLower<MT1>, IsLower<MT2> >
1248  , And< IsStrictlyLower<MT2>, IsLower<MT1> > >::value >
1249 {};
1251 //*************************************************************************************************
1252 
1253 
1254 
1255 
1256 //=================================================================================================
1257 //
1258 // ISUPPER SPECIALIZATIONS
1259 //
1260 //=================================================================================================
1261 
1262 //*************************************************************************************************
1264 template< typename MT1, typename MT2 >
1265 struct IsUpper< SMatSMatMultExpr<MT1,MT2> >
1266  : public BoolConstant< And< IsUpper<MT1>, IsUpper<MT2> >::value >
1267 {};
1269 //*************************************************************************************************
1270 
1271 
1272 
1273 
1274 //=================================================================================================
1275 //
1276 // ISUNIUPPER SPECIALIZATIONS
1277 //
1278 //=================================================================================================
1279 
1280 //*************************************************************************************************
1282 template< typename MT1, typename MT2 >
1283 struct IsUniUpper< SMatSMatMultExpr<MT1,MT2> >
1284  : public BoolConstant< And< IsUniUpper<MT1>, IsUniUpper<MT2> >::value >
1285 {};
1287 //*************************************************************************************************
1288 
1289 
1290 
1291 
1292 //=================================================================================================
1293 //
1294 // ISSTRICTLYUPPER SPECIALIZATIONS
1295 //
1296 //=================================================================================================
1297 
1298 //*************************************************************************************************
1300 template< typename MT1, typename MT2 >
1301 struct IsStrictlyUpper< SMatSMatMultExpr<MT1,MT2> >
1302  : public BoolConstant< Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> >
1303  , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > >::value >
1304 {};
1306 //*************************************************************************************************
1307 
1308 
1309 
1310 
1311 //=================================================================================================
1312 //
1313 // EXPRESSION TRAIT SPECIALIZATIONS
1314 //
1315 //=================================================================================================
1316 
1317 //*************************************************************************************************
1319 template< typename MT1, typename MT2, typename VT >
1320 struct SMatDVecMultExprTrait< SMatSMatMultExpr<MT1,MT2>, VT >
1321 {
1322  public:
1323  //**********************************************************************************************
1324  using Type = If_< And< IsSparseMatrix<MT1>, IsRowMajorMatrix<MT1>
1325  , IsSparseMatrix<MT2>, IsRowMajorMatrix<MT2>
1326  , IsDenseVector<VT>, IsColumnVector<VT> >
1327  , SMatDVecMultExprTrait_< MT1, SMatDVecMultExprTrait_<MT2,VT> >
1328  , INVALID_TYPE >;
1329  //**********************************************************************************************
1330 };
1332 //*************************************************************************************************
1333 
1334 
1335 //*************************************************************************************************
1337 template< typename MT1, typename MT2, typename VT >
1338 struct SMatSVecMultExprTrait< SMatSMatMultExpr<MT1,MT2>, VT >
1339 {
1340  public:
1341  //**********************************************************************************************
1342  using Type = If_< And< IsSparseMatrix<MT1>, IsRowMajorMatrix<MT1>
1343  , IsSparseMatrix<MT2>, IsRowMajorMatrix<MT2>
1344  , IsSparseVector<VT>, IsColumnVector<VT> >
1345  , SMatSVecMultExprTrait_< MT1, SMatSVecMultExprTrait_<MT2,VT> >
1346  , INVALID_TYPE >;
1347  //**********************************************************************************************
1348 };
1350 //*************************************************************************************************
1351 
1352 
1353 //*************************************************************************************************
1355 template< typename VT, typename MT1, typename MT2 >
1356 struct TDVecSMatMultExprTrait< VT, SMatSMatMultExpr<MT1,MT2> >
1357 {
1358  public:
1359  //**********************************************************************************************
1360  using Type = If_< And< IsDenseVector<VT>, IsRowVector<VT>
1361  , IsSparseMatrix<MT1>, IsRowMajorMatrix<MT1>
1362  , IsSparseMatrix<MT2>, IsRowMajorMatrix<MT2> >
1363  , TDVecSMatMultExprTrait_< TDVecSMatMultExprTrait_<VT,MT1>, MT2 >
1364  , INVALID_TYPE >;
1365  //**********************************************************************************************
1366 };
1368 //*************************************************************************************************
1369 
1370 
1371 //*************************************************************************************************
1373 template< typename VT, typename MT1, typename MT2 >
1374 struct TSVecSMatMultExprTrait< VT, SMatSMatMultExpr<MT1,MT2> >
1375 {
1376  public:
1377  //**********************************************************************************************
1378  using Type = If_< And< IsSparseVector<VT>, IsRowVector<VT>
1379  , IsSparseMatrix<MT1>, IsRowMajorMatrix<MT1>
1380  , IsSparseMatrix<MT2>, IsRowMajorMatrix<MT2> >
1381  , TSVecSMatMultExprTrait_< TSVecSMatMultExprTrait_<VT,MT1>, MT2 >
1382  , INVALID_TYPE >;
1383  //**********************************************************************************************
1384 };
1386 //*************************************************************************************************
1387 
1388 
1389 //*************************************************************************************************
1391 template< typename MT1, typename MT2, bool AF >
1392 struct SubmatrixExprTrait< SMatSMatMultExpr<MT1,MT2>, AF >
1393 {
1394  public:
1395  //**********************************************************************************************
1396  using Type = MultExprTrait_< SubmatrixExprTrait_<const MT1,AF>
1397  , SubmatrixExprTrait_<const MT2,AF> >;
1398  //**********************************************************************************************
1399 };
1401 //*************************************************************************************************
1402 
1403 
1404 //*************************************************************************************************
1406 template< typename MT1, typename MT2 >
1407 struct RowExprTrait< SMatSMatMultExpr<MT1,MT2> >
1408 {
1409  public:
1410  //**********************************************************************************************
1411  using Type = MultExprTrait_< RowExprTrait_<const MT1>, MT2 >;
1412  //**********************************************************************************************
1413 };
1415 //*************************************************************************************************
1416 
1417 
1418 //*************************************************************************************************
1420 template< typename MT1, typename MT2 >
1421 struct ColumnExprTrait< SMatSMatMultExpr<MT1,MT2> >
1422 {
1423  public:
1424  //**********************************************************************************************
1425  using Type = MultExprTrait_< MT1, ColumnExprTrait_<const MT2> >;
1426  //**********************************************************************************************
1427 };
1429 //*************************************************************************************************
1430 
1431 } // namespace blaze
1432 
1433 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
CompositeType_< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatSMatMultExpr.h:130
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SMatSMatMultExpr.h:177
Header file for auxiliary alias declarations.
Header file for mathematical functions.
Header file for the SMatDVecMultExprTrait class template.
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse matrix operand.
Definition: SMatSMatMultExpr.h:334
RightOperand rhs_
Right-hand side sparse matrix of the multiplication expression.
Definition: SMatSMatMultExpr.h:376
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
CompositeType_< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition: SMatSMatMultExpr.h:131
Header file for the IsUniUpper type trait.
const DMatDMatMultExpr< T1, T2 > 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:7800
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.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatSMatMultExpr.h:218
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.
Header file for the serial shim.
Header file for the ColumnExprTrait class template.
If_< IsExpression< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatSMatMultExpr.h:185
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:188
ResultType_< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatSMatMultExpr.h:128
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
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatSMatMultExpr.h:282
Header file for the IsRowVector type trait.
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Header file for the And class template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
Header file for the TDVecSMatMultExprTrait class template.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
If_< IsExpression< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: SMatSMatMultExpr.h:188
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
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 RequiresEvaluation type trait.
Header file for the TSVecSMatMultExprTrait class template.
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:1716
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
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatSMatMultExpr.h:178
DisableIf_< Or< IsComputation< MT >, IsTransExpr< 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:126
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:109
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatSMatMultExpr.h:181
Header file for the SparseMatrix base class.
size_t nonZeros(size_t i) const noexcept
Returns the number of non-zero elements in the specified row.
Definition: SMatSMatMultExpr.h:313
Constraint on the data type.
Header file for the MultExprTrait class template.
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
Header file for the DisableIf class template.
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatSMatMultExpr.h:375
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 If class template.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatSMatMultExpr.h:292
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.
#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 Columns type trait.
Numerical infinity for built-in data types.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatSMatMultExpr.h:179
SMatSMatMultExpr< MT1, MT2 > This
Type of this SMatSMatMultExpr instance.
Definition: SMatSMatMultExpr.h:176
Header file for the IsLower type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:90
Header file for the SMatSVecMultExprTrait class template.
Header file for the IsTriangular type trait.
Header file for the exception macros of the math module.
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatMultExpr.h:109
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
DisableIf_< Or< IsComputation< MT >, IsTransExpr< 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:126
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatSMatMultExpr.h:266
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
Expression object for sparse matrix-sparse matrix multiplications.The SMatSMatMultExpr class represen...
Definition: Forward.h:99
SMatSMatMultExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the SMatSMatMultExpr class.
Definition: SMatSMatMultExpr.h:203
Header file for run time assertion macros.
Utility type for generic codes.
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatSMatMultExpr.h:368
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
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatSMatMultExpr.h:182
Header file for the reset shim.
Header file for the isDefault shim.
Constraint on the data type.
const Infinity inf
Global Infinity instance.The blaze::inf instance can be used wherever a built-in data type is expecte...
Definition: Infinity.h:1098
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatSMatMultExpr.h:324
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatSMatMultExpr.h:346
Header file for the RemoveReference type trait.
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:243
Header file for the IsDenseVector type trait.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatSMatMultExpr.h:358
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
ResultType_< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: SMatSMatMultExpr.h:129
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SMatSMatMultExpr.h:180
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:950
Header file for the IsComputation type trait class.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
Header file for the IntegralConstant class template.
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.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsColumnVector type trait.
Constraint on the data type.
Header file for the IsResizable type trait.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#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
constexpr size_t nonZeros() const noexcept
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatSMatMultExpr.h:302
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.