Blaze  3.6
SMatTSMatMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTSMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATTSMATMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
52 #include <blaze/math/Exception.h>
67 #include <blaze/math/views/Check.h>
70 #include <blaze/util/Assert.h>
71 #include <blaze/util/DisableIf.h>
72 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/MaybeUnused.h>
76 #include <blaze/util/mpl/If.h>
77 #include <blaze/util/Types.h>
78 
79 
80 namespace blaze {
81 
82 //=================================================================================================
83 //
84 // CLASS SMATTSMATMULTEXPR
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
95 template< typename MT1 // Type of the left-hand side sparse matrix
96  , typename MT2 > // Type of the right-hand side sparse matrix
97 class SMatTSMatMultExpr
98  : public MatMatMultExpr< SparseMatrix< SMatTSMatMultExpr<MT1,MT2>, IsIdentity_v<MT1> > >
99  , private Computation
100 {
101  private:
102  //**Type definitions****************************************************************************
107  //**********************************************************************************************
108 
109  //**********************************************************************************************
111 
118  template< typename T1, typename T2, typename T3 >
119  static constexpr bool CanExploitSymmetry_v =
120  ( ( IsRowMajorMatrix_v<T1> && IsSymmetric_v<T3> ) ||
121  ( IsColumnMajorMatrix_v<T1> && IsSymmetric_v<T2> ) );
123  //**********************************************************************************************
124 
125  public:
126  //**Type definitions****************************************************************************
129 
132 
137  using ReturnType = const ElementType;
138  using CompositeType = const ResultType;
139 
141  using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
142 
144  using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
145  //**********************************************************************************************
146 
147  //**Compilation flags***************************************************************************
149  static constexpr bool smpAssignable = false;
150  //**********************************************************************************************
151 
152  //**Constructor*********************************************************************************
158  explicit inline SMatTSMatMultExpr( const MT1& lhs, const MT2& rhs ) noexcept
159  : lhs_( lhs ) // Left-hand side sparse matrix of the multiplication expression
160  , rhs_( rhs ) // Right-hand side sparse matrix of the multiplication expression
161  {
162  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.rows(), "Invalid matrix sizes" );
163  }
164  //**********************************************************************************************
165 
166  //**Access operator*****************************************************************************
173  inline ReturnType operator()( size_t i, size_t j ) const {
174  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
175  BLAZE_INTERNAL_ASSERT( j < rhs_.columns(), "Invalid column access index" );
176 
177  return row( lhs_, i, unchecked ) * column( rhs_, j, unchecked );
178  }
179  //**********************************************************************************************
180 
181  //**At function*********************************************************************************
189  inline ReturnType at( size_t i, size_t j ) const {
190  if( i >= lhs_.rows() ) {
191  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
192  }
193  if( j >= rhs_.columns() ) {
194  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
195  }
196  return (*this)(i,j);
197  }
198  //**********************************************************************************************
199 
200  //**Rows function*******************************************************************************
205  inline size_t rows() const noexcept {
206  return lhs_.rows();
207  }
208  //**********************************************************************************************
209 
210  //**Columns function****************************************************************************
215  inline size_t columns() const noexcept {
216  return rhs_.columns();
217  }
218  //**********************************************************************************************
219 
220  //**NonZeros function***************************************************************************
225  inline constexpr size_t nonZeros() const noexcept {
226  return 0UL;
227  }
228  //**********************************************************************************************
229 
230  //**NonZeros function***************************************************************************
236  inline size_t nonZeros( size_t i ) const noexcept {
237  MAYBE_UNUSED( i );
238  return 0UL;
239  }
240  //**********************************************************************************************
241 
242  //**Left operand access*************************************************************************
247  inline LeftOperand leftOperand() const noexcept {
248  return lhs_;
249  }
250  //**********************************************************************************************
251 
252  //**Right operand access************************************************************************
257  inline RightOperand rightOperand() const noexcept {
258  return rhs_;
259  }
260  //**********************************************************************************************
261 
262  //**********************************************************************************************
268  template< typename T >
269  inline bool canAlias( const T* alias ) const noexcept {
270  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
271  }
272  //**********************************************************************************************
273 
274  //**********************************************************************************************
280  template< typename T >
281  inline bool isAliased( const T* alias ) const noexcept {
282  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
283  }
284  //**********************************************************************************************
285 
286  //**********************************************************************************************
291  inline bool canSMPAssign() const noexcept {
292  return ( rows() * columns() >= SMP_SMATTSMATMULT_THRESHOLD );
293  }
294  //**********************************************************************************************
295 
296  private:
297  //**Member variables****************************************************************************
300  //**********************************************************************************************
301 
302  //**Assignment to row-major matrices************************************************************
315  template< typename MT > // Type of the target matrix
316  friend inline auto assign( Matrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
318  {
320 
321  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
322  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
323 
325 
326  const OppositeType_t<MT2> tmp( serial( rhs.rhs_ ) );
327  assign( ~lhs, rhs.lhs_ * tmp );
328  }
330  //**********************************************************************************************
331 
332  //**Restructuring assignment to row-major matrices**********************************************
347  template< typename MT > // Type of the target matrix
348  friend inline auto assign( Matrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
350  {
352 
353  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
354  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
355 
356  assign( ~lhs, rhs.lhs_ * trans( rhs.rhs_ ) );
357  }
359  //**********************************************************************************************
360 
361  //**Assignment to column-major matrices*********************************************************
374  template< typename MT > // Type of the target matrix
375  friend inline auto assign( Matrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
376  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
377  {
379 
381 
382  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
383  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
384 
386 
387  const OppositeType_t<MT1> tmp( serial( rhs.lhs_ ) );
388  assign( ~lhs, tmp * rhs.rhs_ );
389  }
391  //**********************************************************************************************
392 
393  //**Restructuring assignment to column-major matrices*******************************************
408  template< typename MT > // Type of the target matrix
409  friend inline auto assign( Matrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
410  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
411  {
413 
415 
416  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
417  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
418 
419  assign( ~lhs, trans( rhs.lhs_ ) * rhs.rhs_ );
420  }
422  //**********************************************************************************************
423 
424  //**Addition assignment to row-major dense matrices*********************************************
437  template< typename MT > // Type of the target dense matrix
438  friend inline auto addAssign( DenseMatrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
439  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
440  {
442 
443  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
444  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
445 
446  BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( OppositeType_t<MT2> );
447 
448  const OppositeType_t<MT2> tmp( serial( rhs.rhs_ ) );
449  addAssign( ~lhs, rhs.lhs_ * tmp );
450  }
452  //**********************************************************************************************
453 
454  //**Restructuring addition assignment to row-major matrices*************************************
469  template< typename MT > // Type of the target matrix
470  friend inline auto addAssign( Matrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
471  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
472  {
474 
475  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
476  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
477 
478  addAssign( ~lhs, rhs.lhs_ * trans( rhs.rhs_ ) );
479  }
481  //**********************************************************************************************
482 
483  //**Addition assignment to column-major dense matrices******************************************
496  template< typename MT > // Type of the target dense matrix
497  friend inline auto addAssign( DenseMatrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
498  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
499  {
501 
503 
504  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
505  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
506 
508 
509  const OppositeType_t<MT1> tmp( serial( rhs.lhs_ ) );
510  addAssign( ~lhs, tmp * rhs.rhs_ );
511  }
513  //**********************************************************************************************
514 
515  //**Restructuring addition assignment to column-major matrices**********************************
530  template< typename MT > // Type of the target matrix
531  friend inline auto addAssign( Matrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
532  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
533  {
535 
537 
538  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
539  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
540 
541  addAssign( ~lhs, trans( rhs.lhs_ ) * rhs.rhs_ );
542  }
544  //**********************************************************************************************
545 
546  //**Addition assignment to sparse matrices******************************************************
547  // No special implementation for the addition assignment to sparse matrices.
548  //**********************************************************************************************
549 
550  //**Subtraction assignment to row-major dense matrices******************************************
563  template< typename MT > // Type of the target dense matrix
564  friend inline auto subAssign( DenseMatrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
565  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
566  {
568 
569  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
570  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
571 
572  BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( OppositeType_t<MT2> );
573 
574  const OppositeType_t<MT2> tmp( serial( rhs.rhs_ ) );
575  subAssign( ~lhs, rhs.lhs_ * tmp );
576  }
578  //**********************************************************************************************
579 
580  //**Restructuring subtraction assignment to row-major matrices**********************************
595  template< typename MT > // Type of the target matrix
596  friend inline auto subAssign( Matrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
597  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
598  {
600 
601  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
602  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
603 
604  subAssign( ~lhs, rhs.lhs_ * trans( rhs.rhs_ ) );
605  }
607  //**********************************************************************************************
608 
609  //**Subtraction assignment to column-major dense matrices***************************************
622  template< typename MT > // Type of the target dense matrix
623  friend inline auto subAssign( DenseMatrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
624  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
625  {
627 
629 
630  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
631  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
632 
634 
635  const OppositeType_t<MT1> tmp( serial( rhs.lhs_ ) );
636  subAssign( ~lhs, tmp * rhs.rhs_ );
637  }
639  //**********************************************************************************************
640 
641  //**Restructuring subtraction assignment to column-major matrices*******************************
656  template< typename MT > // Type of the target matrix
657  friend inline auto subAssign( Matrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
658  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
659  {
661 
663 
664  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
665  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
666 
667  subAssign( ~lhs, trans( rhs.lhs_ ) * rhs.rhs_ );
668  }
670  //**********************************************************************************************
671 
672  //**Subtraction assignment to sparse matrices***************************************************
673  // No special implementation for the subtraction assignment to sparse matrices.
674  //**********************************************************************************************
675 
676  //**Schur product assignment to row-major dense matrices****************************************
689  template< typename MT // Type of the target dense matrix
690  , bool SO > // Storage order of the target dense matrix
691  friend inline void schurAssign( DenseMatrix<MT,SO>& lhs, const SMatTSMatMultExpr& rhs )
692  {
694 
697 
698  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
699  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
700 
701  const ResultType tmp( serial( rhs ) );
702  schurAssign( ~lhs, tmp );
703  }
705  //**********************************************************************************************
706 
707  //**Schur product assignment to sparse matrices*************************************************
708  // No special implementation for the Schur product assignment to sparse matrices.
709  //**********************************************************************************************
710 
711  //**Multiplication assignment to dense matrices*************************************************
712  // No special implementation for the multiplication assignment to dense matrices.
713  //**********************************************************************************************
714 
715  //**Multiplication assignment to sparse matrices************************************************
716  // No special implementation for the multiplication assignment to sparse matrices.
717  //**********************************************************************************************
718 
719  //**SMP assignment to row-major matrices********************************************************
734  template< typename MT > // Type of the target matrix
735  friend inline auto smpAssign( Matrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
736  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
737  {
739 
740  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
741  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
742 
743  BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( OppositeType_t<MT2> );
744 
745  const OppositeType_t<MT2> tmp( rhs.rhs_ );
746  smpAssign( ~lhs, rhs.lhs_ * tmp );
747  }
749  //**********************************************************************************************
750 
751  //**Restructuring SMP assignment to row-major matrices******************************************
766  template< typename MT > // Type of the target matrix
767  friend inline auto smpAssign( Matrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
768  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
769  {
771 
772  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
773  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
774 
775  smpAssign( ~lhs, rhs.lhs_ * trans( rhs.rhs_ ) );
776  }
778  //**********************************************************************************************
779 
780  //**SMP assignment to column-major matrices*****************************************************
795  template< typename MT > // Type of the target matrix
796  friend inline auto smpAssign( Matrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
797  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
798  {
800 
802 
803  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
804  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
805 
807 
808  const OppositeType_t<MT1> tmp( rhs.lhs_ );
809  smpAssign( ~lhs, tmp * rhs.rhs_ );
810  }
812  //**********************************************************************************************
813 
814  //**Restructuring SMP assignment to column-major matrices***************************************
829  template< typename MT > // Type of the target matrix
830  friend inline auto smpAssign( Matrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
831  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
832  {
834 
836 
837  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
838  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
839 
840  smpAssign( ~lhs, trans( rhs.lhs_ ) * rhs.rhs_ );
841  }
843  //**********************************************************************************************
844 
845  //**SMP addition assignment to row-major dense matrices*****************************************
860  template< typename MT > // Type of the target dense matrix
861  friend inline auto smpAddAssign( DenseMatrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
862  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
863  {
865 
866  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
867  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
868 
869  BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( OppositeType_t<MT2> );
870 
871  const OppositeType_t<MT2> tmp( rhs.rhs_ );
872  smpAddAssign( ~lhs, rhs.lhs_ * tmp );
873  }
875  //**********************************************************************************************
876 
877  //**SMP addition assignment to column-major dense matrices**************************************
892  template< typename MT > // Type of the target dense matrix
893  friend inline auto smpAddAssign( DenseMatrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
894  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
895  {
897 
899 
900  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
901  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
902 
904 
905  const OppositeType_t<MT1> tmp( rhs.lhs_ );
906  smpAddAssign( ~lhs, tmp * rhs.rhs_ );
907  }
909  //**********************************************************************************************
910 
911  //**Restructuring SMP addition assignment to row-major matrices*********************************
926  template< typename MT > // Type of the target matrix
927  friend inline auto smpAddAssign( Matrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
928  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
929  {
931 
932  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
933  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
934 
935  smpAddAssign( ~lhs, rhs.lhs_ * trans( rhs.rhs_ ) );
936  }
938  //**********************************************************************************************
939 
940  //**Restructuring SMP addition assignment to column-major matrices******************************
955  template< typename MT > // Type of the target matrix
956  friend inline auto smpAddAssign( Matrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
957  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
958  {
960 
962 
963  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
964  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
965 
966  smpAddAssign( ~lhs, trans( rhs.lhs_ ) * rhs.rhs_ );
967  }
969  //**********************************************************************************************
970 
971  //**SMP addition assignment to sparse matrices**************************************************
972  // No special implementation for the SMP addition assignment to sparse matrices.
973  //**********************************************************************************************
974 
975  //**SMP subtraction assignment to row-major dense matrices**************************************
990  template< typename MT > // Type of the target dense matrix
991  friend inline auto smpSubAssign( DenseMatrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
992  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
993  {
995 
996  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
997  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
998 
999  BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( OppositeType_t<MT2> );
1000 
1001  const OppositeType_t<MT2> tmp( rhs.rhs_ );
1002  smpSubAssign( ~lhs, rhs.lhs_ * tmp );
1003  }
1005  //**********************************************************************************************
1006 
1007  //**SMP subtraction assignment to column-major dense matrices***********************************
1022  template< typename MT > // Type of the target dense matrix
1023  friend inline auto smpSubAssign( DenseMatrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
1024  -> DisableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1025  {
1027 
1029 
1030  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1031  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1032 
1034 
1035  const OppositeType_t<MT1> tmp( rhs.lhs_ );
1036  smpSubAssign( ~lhs, tmp * rhs.rhs_ );
1037  }
1039  //**********************************************************************************************
1040 
1041  //**Restructuring SMP subtraction assignment to row-major matrices******************************
1056  template< typename MT > // Type of the target matrix
1057  friend inline auto smpSubAssign( Matrix<MT,false>& lhs, const SMatTSMatMultExpr& rhs )
1058  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1059  {
1061 
1062  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1063  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1064 
1065  smpSubAssign( ~lhs, rhs.lhs_ * trans( rhs.rhs_ ) );
1066  }
1068  //**********************************************************************************************
1069 
1070  //**Restructuring SMP subtraction assignment to column-major matrices***************************
1085  template< typename MT > // Type of the target matrix
1086  friend inline auto smpSubAssign( Matrix<MT,true>& lhs, const SMatTSMatMultExpr& rhs )
1087  -> EnableIf_t< CanExploitSymmetry_v<MT,MT1,MT2> >
1088  {
1090 
1092 
1093  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1094  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1095 
1096  smpSubAssign( ~lhs, trans( rhs.lhs_ ) * rhs.rhs_ );
1097  }
1099  //**********************************************************************************************
1100 
1101  //**SMP subtraction assignment to sparse matrices***********************************************
1102  // No special implementation for the SMP subtraction assignment to sparse matrices.
1103  //**********************************************************************************************
1104 
1105  //**SMP Schur product assignment to row-major dense matrices************************************
1118  template< typename MT // Type of the target dense matrix
1119  , bool SO > // Storage order of the target dense matrix
1120  friend inline void smpSchurAssign( DenseMatrix<MT,SO>& lhs, const SMatTSMatMultExpr& rhs )
1121  {
1123 
1126 
1127  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1128  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1129 
1130  const ResultType tmp( rhs );
1131  smpSchurAssign( ~lhs, tmp );
1132  }
1134  //**********************************************************************************************
1135 
1136  //**SMP Schur product assignment to sparse matrices*********************************************
1137  // No special implementation for the SMP Schur product assignment to sparse matrices.
1138  //**********************************************************************************************
1139 
1140  //**SMP multiplication assignment to dense matrices*********************************************
1141  // No special implementation for the SMP multiplication assignment to dense matrices.
1142  //**********************************************************************************************
1143 
1144  //**SMP multiplication assignment to sparse matrices********************************************
1145  // No special implementation for the SMP multiplication assignment to sparse matrices.
1146  //**********************************************************************************************
1147 
1148  //**Compile time checks*************************************************************************
1158  //**********************************************************************************************
1159 };
1160 //*************************************************************************************************
1161 
1162 
1163 
1164 
1165 //=================================================================================================
1166 //
1167 // GLOBAL BINARY ARITHMETIC OPERATORS
1168 //
1169 //=================================================================================================
1170 
1171 //*************************************************************************************************
1184 template< typename MT1 // Type of the left-hand side sparse matrix
1185  , typename MT2 // Type of the right-hand side sparse matrix
1186  , DisableIf_t< ( ( IsIdentity_v<MT1> || IsIdentity_v<MT2> ) &&
1187  IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > ) ||
1188  ( IsIdentity_v<MT1> && IsIdentity_v<MT2> ) ||
1189  ( IsZero_v<MT1> || IsZero_v<MT2> ) >* = nullptr >
1190 inline const SMatTSMatMultExpr<MT1,MT2>
1191  smattsmatmult( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1192 {
1194 
1195  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
1196 
1197  return SMatTSMatMultExpr<MT1,MT2>( ~lhs, ~rhs );
1198 }
1200 //*************************************************************************************************
1201 
1202 
1203 //*************************************************************************************************
1217 template< typename MT1 // Type of the left-hand side sparse matrix
1218  , typename MT2 // Type of the right-hand side sparse matrix
1219  , EnableIf_t< !IsIdentity_v<MT1> && IsIdentity_v<MT2> &&
1220  IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > >* = nullptr >
1221 inline const MT1&
1222  smattsmatmult( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1223 {
1225 
1226  MAYBE_UNUSED( rhs );
1227 
1228  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
1229 
1230  return (~lhs);
1231 }
1233 //*************************************************************************************************
1234 
1235 
1236 //*************************************************************************************************
1250 template< typename MT1 // Type of the left-hand side sparse matrix
1251  , typename MT2 // Type of the right-hand side sparse matrix
1252  , EnableIf_t< IsIdentity_v<MT1> && !IsIdentity_v<MT2> &&
1253  IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > >* = nullptr >
1254 inline const MT2&
1255  smattsmatmult( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1256 {
1258 
1259  MAYBE_UNUSED( lhs );
1260 
1261  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
1262 
1263  return (~rhs);
1264 }
1266 //*************************************************************************************************
1267 
1268 
1269 //*************************************************************************************************
1282 template< typename MT1 // Type of the left-hand side sparse matrix
1283  , typename MT2 // Type of the right-hand side sparse matrix
1284  , EnableIf_t< IsIdentity_v<MT1> && IsIdentity_v<MT2> >* = nullptr >
1285 inline decltype(auto)
1286  smattsmatmult( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1287 {
1289 
1290  MAYBE_UNUSED( rhs );
1291 
1292  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
1293 
1294  using ReturnType = const MultTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1295 
1298 
1299  return ReturnType( (~lhs).rows() );
1300 }
1302 //*************************************************************************************************
1303 
1304 
1305 //*************************************************************************************************
1319 template< typename MT1 // Type of the left-hand side sparse matrix
1320  , typename MT2 // Type of the right-hand side sparse matrix
1321  , EnableIf_t< IsZero_v<MT1> || IsZero_v<MT2> >* = nullptr >
1322 inline decltype(auto)
1323  smattsmatmult( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1324 {
1326 
1327  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
1328 
1329  using ReturnType = const MultTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1330 
1331  BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER( ReturnType, !IsZero_v<MT1> );
1332  BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE( ReturnType );
1333 
1334  return ReturnType( (~lhs).rows(), (~rhs).columns() );
1335 }
1337 //*************************************************************************************************
1338 
1339 
1340 //*************************************************************************************************
1370 template< typename MT1 // Type of the left-hand side sparse matrix
1371  , typename MT2 > // Type of the right-hand side sparse matrix
1372 inline decltype(auto)
1373  operator*( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1374 {
1376 
1377  if( (~lhs).columns() != (~rhs).rows() ) {
1378  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1379  }
1380 
1381  return smattsmatmult( ~lhs, ~rhs );
1382 }
1383 //*************************************************************************************************
1384 
1385 } // namespace blaze
1386 
1387 #endif
Constraint on the data type.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
#define BLAZE_CONSTRAINT_MUST_BE_IDENTITY_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not an identity matrix type,...
Definition: Identity.h:60
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:137
Header file for basic type definitions.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatTSMatMultExpr.h:215
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
Definition: If.h:109
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the serial shim.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
Header file for the IsColumnMajorMatrix type trait.
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatTSMatMultExpr.h:138
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
Constraint on the data type.
Header file for the MAYBE_UNUSED function template.
Header file for the IsIdentity type trait.
Header file for the Computation base class.
Header file for the MatMatMultExpr base class.
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose sparse matrix operand.
Definition: SMatTSMatMultExpr.h:257
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTSMatMultExpr.h:134
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes....
Definition: Forward.h:145
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Header file for the SparseMatrix base class.
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatTSMatMultExpr.h:136
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Expression object for sparse matrix-transpose sparse matrix multiplications.The SMatTSMatMultExpr cla...
Definition: Forward.h:142
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTSMatMultExpr.h:173
Header file for the DisableIf class template.
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatTSMatMultExpr.h:247
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
CompositeType_t< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:105
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is not a zero vector or matrix type,...
Definition: Zero.h:61
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatTSMatMultExpr.h:281
#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
constexpr size_t nonZeros() const noexcept
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatTSMatMultExpr.h:225
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
ResultType_t< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:104
Header file for the exception macros of the math module.
CompositeType_t< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:106
Constraint on the data type.
SMatTSMatMultExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the SMatTSMatMultExpr class.
Definition: SMatTSMatMultExpr.h:158
Header file for the EnableIf class template.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatTSMatMultExpr.h:205
#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:103
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:135
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:141
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.The MultTrait_t alias declaration provid...
Definition: MultTrait.h:240
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
ResultType_t< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:103
#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,...
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatTSMatMultExpr.h:269
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatTSMatMultExpr.h:189
Header file for the IsZero type trait.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for all forward declarations for expression class templates.
MultTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SMatTSMatMultExpr.h:133
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatTSMatMultExpr.h:149
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:114
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
Constraint on the data type.
Constraints on the storage order of matrix types.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
LeftOperand lhs_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatTSMatMultExpr.h:298
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComputation type trait class.
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
size_t nonZeros(size_t i) const noexcept
Returns the number of non-zero elements in the specified row.
Definition: SMatTSMatMultExpr.h:236
Header file for the IntegralConstant class template.
RightOperand rhs_
Right-hand side sparse matrix of the multiplication expression.
Definition: SMatTSMatMultExpr.h:299
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatTSMatMultExpr.h:291
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatMultExpr.h:144
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is a zero vector or matrix type,...
Definition: Zero.h:81
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
constexpr bool IsSame_v
Auxiliary variable template for the IsSame type trait.The IsSame_v variable template provides a conve...
Definition: IsSame.h:159
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
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
Header file for the IsExpression type trait class.
Header file for the function trace functionality.