SMatSVecMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATSVECMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
51 #include <blaze/math/Exception.h>
57 #include <blaze/math/shims/Reset.h>
70 #include <blaze/util/Assert.h>
72 #include <blaze/util/DisableIf.h>
73 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/mpl/If.h>
76 #include <blaze/util/mpl/Or.h>
77 #include <blaze/util/Types.h>
79 
80 
81 namespace blaze {
82 
83 //=================================================================================================
84 //
85 // CLASS SMATDVECMULTEXPR
86 //
87 //=================================================================================================
88 
89 //*************************************************************************************************
96 template< typename MT // Type of the left-hand side sparse matrix
97  , typename VT > // Type of the right-hand side sparse vector
98 class SMatSVecMultExpr : public SparseVector< SMatSVecMultExpr<MT,VT>, false >
99  , private MatVecMultExpr
100  , private Computation
101 {
102  private:
103  //**Type definitions****************************************************************************
108  //**********************************************************************************************
109 
110  //**********************************************************************************************
112  enum : bool { evaluateMatrix = RequiresEvaluation<MT>::value };
113  //**********************************************************************************************
114 
115  //**********************************************************************************************
117  enum : bool { evaluateVector = RequiresEvaluation<VT>::value || IsComputation<VT>::value };
118  //**********************************************************************************************
119 
120  //**********************************************************************************************
122 
126  template< typename T1 >
127  struct UseSMPAssign {
128  enum : bool { value = ( evaluateMatrix || evaluateVector ) };
129  };
131  //**********************************************************************************************
132 
133  public:
134  //**Type definitions****************************************************************************
139  typedef const ElementType ReturnType;
140 
142  typedef const ResultType CompositeType;
143 
145  typedef If_< IsExpression<MT>, const MT, const MT& > LeftOperand;
146 
148  typedef If_< IsExpression<VT>, const VT, const VT& > RightOperand;
149 
152 
155  //**********************************************************************************************
156 
157  //**Compilation flags***************************************************************************
159  enum : bool { smpAssignable = !evaluateMatrix && MT::smpAssignable &&
160  !evaluateVector && VT::smpAssignable };
161  //**********************************************************************************************
162 
163  //**Constructor*********************************************************************************
169  explicit inline SMatSVecMultExpr( const MT& mat, const VT& vec ) noexcept
170  : mat_( mat ) // Left-hand side sparse matrix of the multiplication expression
171  , vec_( vec ) // Right-hand side sparse vector of the multiplication expression
172  {
173  BLAZE_INTERNAL_ASSERT( mat_.columns() == vec_.size(), "Invalid matrix and vector sizes" );
174  }
175  //**********************************************************************************************
176 
177  //**Subscript operator**************************************************************************
183  inline ReturnType operator[]( size_t index ) const {
184  BLAZE_INTERNAL_ASSERT( index < mat_.rows(), "Invalid vector access index" );
185  return row( mat_, index ) * vec_;
186  }
187  //**********************************************************************************************
188 
189  //**At function*********************************************************************************
196  inline ReturnType at( size_t index ) const {
197  if( index >= mat_.rows() ) {
198  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
199  }
200  return (*this)[index];
201  }
202  //**********************************************************************************************
203 
204  //**Size function*******************************************************************************
209  inline size_t size() const noexcept {
210  return mat_.rows();
211  }
212  //**********************************************************************************************
213 
214  //**NonZeros function***************************************************************************
219  inline size_t nonZeros() const {
220  return mat_.rows();
221  }
222  //**********************************************************************************************
223 
224  //**Left operand access*************************************************************************
229  inline LeftOperand leftOperand() const noexcept {
230  return mat_;
231  }
232  //**********************************************************************************************
233 
234  //**Right operand access************************************************************************
239  inline RightOperand rightOperand() const noexcept {
240  return vec_;
241  }
242  //**********************************************************************************************
243 
244  //**********************************************************************************************
250  template< typename T >
251  inline bool canAlias( const T* alias ) const noexcept {
252  return ( mat_.isAliased( alias ) || vec_.isAliased( alias ) );
253  }
254  //**********************************************************************************************
255 
256  //**********************************************************************************************
262  template< typename T >
263  inline bool isAliased( const T* alias ) const noexcept {
264  return ( mat_.isAliased( alias ) || vec_.isAliased( alias ) );
265  }
266  //**********************************************************************************************
267 
268  //**********************************************************************************************
273  inline bool canSMPAssign() const noexcept {
274  return ( size() > SMP_SMATSVECMULT_THRESHOLD );
275  }
276  //**********************************************************************************************
277 
278  private:
279  //**Member variables****************************************************************************
280  LeftOperand mat_;
281  RightOperand vec_;
282  //**********************************************************************************************
283 
284  //**Assignment to dense vectors*****************************************************************
296  template< typename VT1 > // Type of the target dense vector
297  friend inline void assign( DenseVector<VT1,false>& lhs, const SMatSVecMultExpr& rhs )
298  {
300 
301  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
302 
303  // Resetting the left-hand side target dense vector
304  reset( ~lhs );
305 
306  // Evaluation of the right-hand side sparse vector operand
307  RT x( serial( rhs.vec_ ) );
308  if( x.nonZeros() == 0UL ) return;
309 
310  // Evaluation of the left-hand side sparse matrix operand
311  LT A( serial( rhs.mat_ ) );
312 
313  // Checking the evaluated operators
314  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
315  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
316  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
317  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
318 
319  // Performing the sparse matrix-sparse vector multiplication
320  SMatSVecMultExpr::selectAssignKernel( ~lhs, A, x );
321  }
323  //**********************************************************************************************
324 
325  //**Default assignment to dense vectors*********************************************************
339  template< typename VT1 // Type of the left-hand side target vector
340  , typename MT1 // Type of the left-hand side matrix operand
341  , typename VT2 > // Type of the right-hand side vector operand
342  static inline void selectAssignKernel( VT1& y, const MT1& A, const VT2& x )
343  {
344  typedef ConstIterator_< RemoveReference_<LT> > MatrixIterator;
345  typedef ConstIterator_< RemoveReference_<RT> > VectorIterator;
346 
347  const VectorIterator vend( x.end() );
348 
349  for( size_t i=0UL; i<y.size(); ++i )
350  {
351  const MatrixIterator mend ( A.end(i) );
352  MatrixIterator melem( A.begin(i) );
353 
354  if( melem == mend ) continue;
355 
356  VectorIterator velem( x.begin() );
357 
358  while( true ) {
359  if( melem->index() < velem->index() ) {
360  ++melem;
361  if( melem == mend ) break;
362  }
363  else if( velem->index() < melem->index() ) {
364  ++velem;
365  if( velem == vend ) break;
366  }
367  else {
368  y[i] = melem->value() * velem->value();
369  ++melem;
370  ++velem;
371  break;
372  }
373  }
374 
375  if( melem != mend && velem != vend )
376  {
377  while( true ) {
378  if( melem->index() < velem->index() ) {
379  ++melem;
380  if( melem == mend ) break;
381  }
382  else if( velem->index() < melem->index() ) {
383  ++velem;
384  if( velem == vend ) break;
385  }
386  else {
387  y[i] += melem->value() * velem->value();
388  ++melem;
389  if( melem == mend ) break;
390  ++velem;
391  if( velem == vend ) break;
392  }
393  }
394  }
395  }
396  }
398  //**********************************************************************************************
399 
400  //**Assignment to sparse vectors****************************************************************
412  template< typename VT1 > // Type of the target sparse vector
413  friend inline void assign( SparseVector<VT1,false>& lhs, const SMatSVecMultExpr& rhs )
414  {
416 
417  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
418 
419  typedef ConstIterator_< RemoveReference_<LT> > MatrixIterator;
420  typedef ConstIterator_< RemoveReference_<RT> > VectorIterator;
421 
422  RT x( rhs.vec_ ); // Evaluation of the right-hand side sparse vector operand
423  if( x.nonZeros() == 0UL ) return;
424 
425  LT A( rhs.mat_ ); // Evaluation of the left-hand side sparse matrix operand
426 
427  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
428  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
429  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
430  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
431 
432  ElementType accu;
433  const VectorIterator vend( x.end() );
434 
435  for( size_t i=0UL; i<(~lhs).size(); ++i )
436  {
437  const MatrixIterator mend ( A.end(i) );
438  MatrixIterator melem( A.begin(i) );
439 
440  if( melem == mend ) continue;
441 
442  VectorIterator velem( x.begin() );
443 
444  reset( accu );
445 
446  while( true ) {
447  if( melem->index() < velem->index() ) {
448  ++melem;
449  if( melem == mend ) break;
450  }
451  else if( velem->index() < melem->index() ) {
452  ++velem;
453  if( velem == vend ) break;
454  }
455  else {
456  accu = melem->value() * velem->value();
457  ++melem;
458  ++velem;
459  break;
460  }
461  }
462 
463  if( melem != mend && velem != vend )
464  {
465  while( true ) {
466  if( melem->index() < velem->index() ) {
467  ++melem;
468  if( melem == mend ) break;
469  }
470  else if( velem->index() < melem->index() ) {
471  ++velem;
472  if( velem == vend ) break;
473  }
474  else {
475  accu += melem->value() * velem->value();
476  ++melem;
477  if( melem == mend ) break;
478  ++velem;
479  if( velem == vend ) break;
480  }
481  }
482  }
483 
484  if( !isDefault( accu ) )
485  (~lhs).insert( i, accu );
486  }
487  }
489  //**********************************************************************************************
490 
491  //**Addition assignment to dense vectors********************************************************
503  template< typename VT1 > // Type of the target dense vector
504  friend inline void addAssign( DenseVector<VT1,false>& lhs, const SMatSVecMultExpr& rhs )
505  {
507 
508  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
509 
510  // Evaluation of the right-hand side sparse vector operand
511  RT x( serial( rhs.vec_ ) );
512  if( x.nonZeros() == 0UL ) return;
513 
514  // Evaluation of the left-hand side sparse matrix operand
515  LT A( serial( rhs.mat_ ) );
516 
517  // Checking the evaluated operators
518  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
519  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
520  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
521  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
522 
523  // Performing the sparse matrix-sparse vector multiplication
524  SMatSVecMultExpr::selectAddAssignKernel( ~lhs, A, x );
525  }
527  //**********************************************************************************************
528 
529  //**Default addition assignment to dense vectors************************************************
543  template< typename VT1 // Type of the left-hand side target vector
544  , typename MT1 // Type of the left-hand side matrix operand
545  , typename VT2 > // Type of the right-hand side vector operand
546  static inline void selectAddAssignKernel( VT1& y, const MT1& A, const VT2& x )
547  {
548  typedef ConstIterator_< RemoveReference_<LT> > MatrixIterator;
549  typedef ConstIterator_< RemoveReference_<RT> > VectorIterator;
550 
551  const VectorIterator vend( x.end() );
552 
553  for( size_t i=0UL; i<y.size(); ++i )
554  {
555  const MatrixIterator mend ( A.end(i) );
556  MatrixIterator melem( A.begin(i) );
557 
558  if( melem == mend ) continue;
559 
560  VectorIterator velem( x.begin() );
561 
562  while( true ) {
563  if( melem->index() < velem->index() ) {
564  ++melem;
565  if( melem == mend ) break;
566  }
567  else if( velem->index() < melem->index() ) {
568  ++velem;
569  if( velem == vend ) break;
570  }
571  else {
572  y[i] += melem->value() * velem->value();
573  ++melem;
574  if( melem == mend ) break;
575  ++velem;
576  if( velem == vend ) break;
577  }
578  }
579  }
580  }
582  //**********************************************************************************************
583 
584  //**Addition assignment to sparse vectors*******************************************************
585  // No special implementation for the addition assignment to sparse vectors.
586  //**********************************************************************************************
587 
588  //**Subtraction assignment to dense vectors*****************************************************
600  template< typename VT1 > // Type of the target dense vector
601  friend inline void subAssign( DenseVector<VT1,false>& lhs, const SMatSVecMultExpr& rhs )
602  {
604 
605  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
606 
607  // Evaluation of the right-hand side sparse vector operand
608  RT x( serial( rhs.vec_ ) );
609  if( x.nonZeros() == 0UL ) return;
610 
611  // Evaluation of the left-hand side sparse matrix operand
612  LT A( serial( rhs.mat_ ) );
613 
614  // Checking the evaluated operators
615  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
616  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
617  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
618  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
619 
620  // Performing the sparse matrix-sparse vector multiplication
621  SMatSVecMultExpr::selectSubAssignKernel( ~lhs, A, x );
622  }
624  //**********************************************************************************************
625 
626  //**Default subtraction assignment to dense vectors*********************************************
640  template< typename VT1 // Type of the left-hand side target vector
641  , typename MT1 // Type of the left-hand side matrix operand
642  , typename VT2 > // Type of the right-hand side vector operand
643  static inline void selectSubAssignKernel( VT1& y, const MT1& A, const VT2& x )
644  {
645  typedef ConstIterator_< RemoveReference_<LT> > MatrixIterator;
646  typedef ConstIterator_< RemoveReference_<RT> > VectorIterator;
647 
648  const VectorIterator vend( x.end() );
649 
650  for( size_t i=0UL; i<y.size(); ++i )
651  {
652  const MatrixIterator mend ( A.end(i) );
653  MatrixIterator melem( A.begin(i) );
654 
655  if( melem == mend ) continue;
656 
657  VectorIterator velem( x.begin() );
658 
659  while( true ) {
660  if( melem->index() < velem->index() ) {
661  ++melem;
662  if( melem == mend ) break;
663  }
664  else if( velem->index() < melem->index() ) {
665  ++velem;
666  if( velem == vend ) break;
667  }
668  else {
669  y[i] -= melem->value() * velem->value();
670  ++melem;
671  if( melem == mend ) break;
672  ++velem;
673  if( velem == vend ) break;
674  }
675  }
676  }
677  }
679  //**********************************************************************************************
680 
681  //**Subtraction assignment to sparse vectors****************************************************
682  // No special implementation for the subtraction assignment to sparse vectors.
683  //**********************************************************************************************
684 
685  //**Multiplication assignment to dense vectors**************************************************
697  template< typename VT1 > // Type of the target dense vector
698  friend inline void multAssign( DenseVector<VT1,false>& lhs, const SMatSVecMultExpr& rhs )
699  {
701 
705 
706  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
707 
708  const ResultType tmp( serial( rhs ) );
709  multAssign( ~lhs, tmp );
710  }
712  //**********************************************************************************************
713 
714  //**Multiplication assignment to sparse vectors*************************************************
715  // No special implementation for the multiplication assignment to sparse vectors.
716  //**********************************************************************************************
717 
718  //**SMP assignment to dense vectors*************************************************************
732  template< typename VT1 > // Type of the target dense vector
733  friend inline EnableIf_< UseSMPAssign<VT1> >
735  {
737 
738  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
739 
740  // Resetting the left-hand side target dense vector
741  reset( ~lhs );
742 
743  // Evaluation of the right-hand side sparse vector operand
744  RT x( rhs.vec_ );
745  if( x.nonZeros() == 0UL ) return;
746 
747  // Evaluation of the left-hand side sparse matrix operand
748  LT A( rhs.mat_ );
749 
750  // Checking the evaluated operators
751  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
752  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
753  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
754  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
755 
756  // Performing the sparse matrix-sparse vector multiplication
757  smpAssign( ~lhs, A * x );
758  }
760  //**********************************************************************************************
761 
762  //**SMP assignment to sparse vectors************************************************************
763  // No special implementation for the SMP assignment to sparse vectors.
764  //**********************************************************************************************
765 
766  //**SMP addition assignment to dense vectors****************************************************
781  template< typename VT1 > // Type of the target dense vector
782  friend inline EnableIf_< UseSMPAssign<VT1> >
784  {
786 
787  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
788 
789  // Evaluation of the right-hand side sparse vector operand
790  RT x( rhs.vec_ );
791  if( x.nonZeros() == 0UL ) return;
792 
793  // Evaluation of the left-hand side sparse matrix operand
794  LT A( rhs.mat_ );
795 
796  // Checking the evaluated operators
797  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
798  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
799  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
800  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
801 
802  // Performing the sparse matrix-sparse vector multiplication
803  smpAddAssign( ~lhs, A * x );
804  }
806  //**********************************************************************************************
807 
808  //**SMP addition assignment to sparse vectors***************************************************
809  // No special implementation for the SMP addition assignment to sparse vectors.
810  //**********************************************************************************************
811 
812  //**SMP subtraction assignment to dense vectors*************************************************
827  template< typename VT1 > // Type of the target dense vector
828  friend inline EnableIf_< UseSMPAssign<VT1> >
830  {
832 
833  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
834 
835  // Evaluation of the right-hand side sparse vector operand
836  RT x( rhs.vec_ );
837  if( x.nonZeros() == 0UL ) return;
838 
839  // Evaluation of the left-hand side sparse matrix operand
840  LT A( rhs.mat_ );
841 
842  // Checking the evaluated operators
843  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
844  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
845  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
846  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
847 
848  // Performing the sparse matrix-sparse vector multiplication
849  smpSubAssign( ~lhs, A * x );
850  }
852  //**********************************************************************************************
853 
854  //**SMP subtraction assignment to sparse vectors************************************************
855  // No special implementation for the SMP subtraction assignment to sparse vectors.
856  //**********************************************************************************************
857 
858  //**SMP multiplication assignment to dense vectors**********************************************
873  template< typename VT1 > // Type of the target dense vector
874  friend inline EnableIf_< UseSMPAssign<VT1> >
876  {
878 
882 
883  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
884 
885  const ResultType tmp( rhs );
886  smpMultAssign( ~lhs, tmp );
887  }
889  //**********************************************************************************************
890 
891  //**SMP multiplication assignment to sparse vectors*********************************************
892  // No special implementation for the SMP multiplication assignment to sparse vectors.
893  //**********************************************************************************************
894 
895  //**Compile time checks*************************************************************************
904  //**********************************************************************************************
905 };
906 //*************************************************************************************************
907 
908 
909 
910 
911 //=================================================================================================
912 //
913 // GLOBAL BINARY ARITHMETIC OPERATORS
914 //
915 //=================================================================================================
916 
917 //*************************************************************************************************
948 template< typename T1 // Type of the left-hand side sparse matrix
949  , typename T2 > // Type of the right-hand side sparse vector
952 {
954 
955  if( (~mat).columns() != (~vec).size() ) {
956  BLAZE_THROW_INVALID_ARGUMENT( "Matrix and vector sizes do not match" );
957  }
958 
959  return SMatSVecMultExpr<T1,T2>( ~mat, ~vec );
960 }
961 //*************************************************************************************************
962 
963 
964 
965 
966 //=================================================================================================
967 //
968 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
969 //
970 //=================================================================================================
971 
972 //*************************************************************************************************
987 template< typename T1 // Type of the left-hand side sparse matrix
988  , typename T2 > // Type of the right-hand side sparse vector
991 {
993 
995 
996  if( (~mat).columns() != (~vec).size() ) {
997  BLAZE_THROW_INVALID_ARGUMENT( "Matrix and vector sizes do not match" );
998  }
999 
1000  return trans( ~mat ) * (~vec);
1001 }
1003 //*************************************************************************************************
1004 
1005 
1006 //*************************************************************************************************
1020 template< typename T1 // Type of the left-hand side sparse matrix
1021  , bool SO // Storage order of the left-hand side sparse matrix
1022  , typename T2 > // Type of the right-hand side sparse vector
1024  operator*( const SparseMatrix<T1,SO>& mat, const SparseVector<T2,false>& vec )
1025 {
1027 
1029 
1030  return (~mat).leftOperand() * ( (~mat).rightOperand() * vec );
1031 }
1033 //*************************************************************************************************
1034 
1035 
1036 
1037 
1038 //=================================================================================================
1039 //
1040 // SIZE SPECIALIZATIONS
1041 //
1042 //=================================================================================================
1043 
1044 //*************************************************************************************************
1046 template< typename MT, typename VT >
1047 struct Size< SMatSVecMultExpr<MT,VT> > : public Rows<MT>
1048 {};
1050 //*************************************************************************************************
1051 
1052 
1053 
1054 
1055 //=================================================================================================
1056 //
1057 // EXPRESSION TRAIT SPECIALIZATIONS
1058 //
1059 //=================================================================================================
1060 
1061 //*************************************************************************************************
1063 template< typename MT, typename VT, bool AF >
1064 struct SubvectorExprTrait< SMatSVecMultExpr<MT,VT>, AF >
1065 {
1066  public:
1067  //**********************************************************************************************
1070  //**********************************************************************************************
1071 };
1073 //*************************************************************************************************
1074 
1075 } // namespace blaze
1076 
1077 #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
Header file for auxiliary alias declarations.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:72
CompositeType_< VT > VCT
Composite type of the right-hand side sparse vector expression.
Definition: SMatSVecMultExpr.h:107
IfTrue_< evaluateVector, const VRT, VCT > RT
Type for the assignment of the right-hand side sparse vector operand.
Definition: SMatSVecMultExpr.h:154
LeftOperand mat_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatSVecMultExpr.h:280
Evaluation of the expression type type of a subvector operation.Via this type trait it is possible to...
Definition: SubvectorExprTrait.h:79
Header file for the Rows type trait.
Header file for basic type definitions.
Header file for the SparseVector base class.
CompositeType_< MT > MCT
Composite type of the left-hand side sparse matrix expression.
Definition: SMatSVecMultExpr.h:106
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a column dense or sparse vector type...
Definition: ColumnVector.h:61
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
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatSVecMultExpr.h:139
Header file for the serial shim.
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition: SMatSVecMultExpr.h:219
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SMatSVecMultExpr.h:196
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
EnableIf_< IsDenseVector< VT1 > > smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:193
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatSVecMultExpr.h:263
Header file for the Computation base class.
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
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
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:119
Constraint on the data type.
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
Constraint on the transpose flag of vector types.
Constraint on the data type.
typename MultExprTrait< T1, T2 >::Type MultExprTrait_
Auxiliary alias declaration for the MultExprTrait class template.The MultExprTrait_ alias declaration...
Definition: MultExprTrait.h:344
Header file for the MultExprTrait class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:72
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.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Expression object for sparse matrix-sparse vector multiplications.The SMatSVecMultExpr class represen...
Definition: Forward.h:111
Header file for the If class template.
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
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SMatSVecMultExpr.h:138
Header file for the Or class template.
Header file for the IsMatMatMultExpr type trait class.
#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
IfTrue_< evaluateMatrix, const MRT, MCT > LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: SMatSVecMultExpr.h:151
typename SubvectorExprTrait< VT, AF >::Type SubvectorExprTrait_
Auxiliary alias declaration for the SubvectorExprTrait type trait.The SubvectorExprTrait_ alias decla...
Definition: SubvectorExprTrait.h:133
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
ResultType_< VT > VRT
Result type of the right-hand side sparse vector expression.
Definition: SMatSVecMultExpr.h:105
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatSVecMultExpr.h:137
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:336
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatSVecMultExpr.h:273
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SMatSVecMultExpr.h:183
#define BLAZE_CONSTRAINT_MUST_NOT_BE_MATMATMULTEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a matrix/matrix multiplication expressio...
Definition: MatMatMultExpr.h:89
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:128
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:60
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATVECMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/vector ...
Definition: MatVecMultExpr.h:110
Header file for the exception macros of the math module.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
SMatSVecMultExpr< MT, VT > This
Type of this SMatSVecMultExpr instance.
Definition: SMatSVecMultExpr.h:135
If_< IsExpression< VT >, const VT, const VT &> RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: SMatSVecMultExpr.h:148
Header file for the EnableIf class template.
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatSVecMultExpr.h:229
RightOperand vec_
Right-hand side sparse vector of the multiplication expression.
Definition: SMatSVecMultExpr.h:281
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
Header file for run time assertion macros.
ResultType_< MT > MRT
Result type of the left-hand side sparse matrix expression.
Definition: SMatSVecMultExpr.h:104
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
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SMatSVecMultExpr.h:209
Header file for the reset shim.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:93
Header file for the isDefault shim.
Constraint on the data type.
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: SMatSVecMultExpr.h:239
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatSVecMultExpr.h:251
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatSVecMultExpr.h:142
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:733
Header file for the IsComputation type trait class.
Compile time evaluation of the size of a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:75
If_< IsExpression< MT >, const MT, const MT &> LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatSVecMultExpr.h:145
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:120
Compile time evaluation of the number of rows of a matrix.The Rows type trait evaluates the number of...
Definition: Rows.h:76
Header file for the SubvectorExprTrait class template.
Compile time check whether the given type is a matrix/matrix multiplication expression template...
Definition: IsMatMatMultExpr.h:73
Constraint on the data type.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
SMatSVecMultExpr(const MT &mat, const VT &vec) noexcept
Constructor for the SMatSVecMultExpr class.
Definition: SMatSVecMultExpr.h:169
Header file for the MatVecMultExpr base class.
Constraint on the data type.
MultTrait_< MRT, VRT > ResultType
Result type for expression template evaluations.
Definition: SMatSVecMultExpr.h:136
const DMatDMatMultExpr< T1, T2, false, false, false, false > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7505
Header file for the Size type trait.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#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.