TSMatSVecMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSMATSVECMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <vector>
55 #include <blaze/math/shims/Reset.h>
66 #include <blaze/util/Assert.h>
67 #include <blaze/util/Byte.h>
69 #include <blaze/util/DisableIf.h>
70 #include <blaze/util/EnableIf.h>
71 #include <blaze/util/Exception.h>
73 #include <blaze/util/SelectType.h>
74 #include <blaze/util/Types.h>
76 
77 
78 namespace blaze {
79 
80 //=================================================================================================
81 //
82 // CLASS SMATDVECMULTEXPR
83 //
84 //=================================================================================================
85 
86 //*************************************************************************************************
93 template< typename MT // Type of the left-hand side sparse matrix
94  , typename VT > // Type of the right-hand side sparse vector
95 class TSMatSVecMultExpr : public SparseVector< TSMatSVecMultExpr<MT,VT>, false >
96  , private MatVecMultExpr
97  , private Computation
98 {
99  private:
100  //**Type definitions****************************************************************************
101  typedef typename MT::ResultType MRT;
102  typedef typename VT::ResultType VRT;
103  typedef typename MT::CompositeType MCT;
104  typedef typename VT::CompositeType VCT;
105  //**********************************************************************************************
106 
107  //**********************************************************************************************
109  enum { evaluateMatrix = RequiresEvaluation<MT>::value };
110  //**********************************************************************************************
111 
112  //**********************************************************************************************
114  enum { evaluateVector = RequiresEvaluation<VT>::value || IsComputation<VT>::value };
115  //**********************************************************************************************
116 
117  //**********************************************************************************************
119 
123  template< typename T1 >
124  struct UseSMPAssign {
125  enum { value = ( evaluateMatrix || evaluateVector ) };
126  };
128  //**********************************************************************************************
129 
130  public:
131  //**Type definitions****************************************************************************
136  typedef const ElementType ReturnType;
137 
139  typedef const ResultType CompositeType;
140 
142  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type LeftOperand;
143 
145  typedef typename SelectType< IsExpression<VT>::value, const VT, const VT& >::Type RightOperand;
146 
149 
152  //**********************************************************************************************
153 
154  //**Compilation flags***************************************************************************
156  enum { smpAssignable = !evaluateMatrix && MT::smpAssignable &&
157  !evaluateVector && VT::smpAssignable };
158  //**********************************************************************************************
159 
160  //**Constructor*********************************************************************************
166  explicit inline TSMatSVecMultExpr( const MT& mat, const VT& vec )
167  : mat_( mat ) // Left-hand side sparse matrix of the multiplication expression
168  , vec_( vec ) // Right-hand side sparse vector of the multiplication expression
169  {
170  BLAZE_INTERNAL_ASSERT( mat_.columns() == vec_.size(), "Invalid matrix and vector sizes" );
171  }
172  //**********************************************************************************************
173 
174  //**Subscript operator**************************************************************************
180  inline ReturnType operator[]( size_t index ) const {
181  BLAZE_INTERNAL_ASSERT( index < mat_.rows(), "Invalid vector access index" );
182 
183  typedef typename RemoveReference<MCT>::Type::ConstIterator MatrixIterator;
184  typedef typename RemoveReference<VCT>::Type::ConstIterator VectorIterator;
185 
186  MCT A( mat_ ); // Evaluation of the left-hand side sparse matrix operand
187  VCT x( vec_ ); // Evaluation of the right-hand side sparse vector operand
188 
189  BLAZE_INTERNAL_ASSERT( A.rows() == mat_.rows() , "Invalid number of rows" );
190  BLAZE_INTERNAL_ASSERT( A.columns() == mat_.columns(), "Invalid number of columns" );
191  BLAZE_INTERNAL_ASSERT( x.size() == vec_.size() , "Invalid vector size" );
192 
193  ElementType res;
194 
195  const VectorIterator vend( x.end() );
196  VectorIterator velem( x.begin() );
197 
198  if( vec_.size() > 0UL && velem != vend ) {
199  res = A( index, velem->index() ) * velem->value();
200  ++velem;
201  for( ; velem!=vend; ++velem )
202  res += A( index, velem->index() ) * velem->value();
203  }
204  else {
205  reset( res );
206  }
207 
208  return res;
209  }
210  //**********************************************************************************************
211 
212  //**At function*********************************************************************************
219  inline ReturnType at( size_t index ) const {
220  if( index >= mat_.rows() ) {
221  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
222  }
223  return (*this)[index];
224  }
225  //**********************************************************************************************
226 
227  //**Size function*******************************************************************************
232  inline size_t size() const {
233  return mat_.rows();
234  }
235  //**********************************************************************************************
236 
237  //**NonZeros function***************************************************************************
242  inline size_t nonZeros() const {
243  return mat_.rows();
244  }
245  //**********************************************************************************************
246 
247  //**Left operand access*************************************************************************
252  inline LeftOperand leftOperand() const {
253  return mat_;
254  }
255  //**********************************************************************************************
256 
257  //**Right operand function**********************************************************************
262  inline RightOperand rightOperand() const {
263  return vec_;
264  }
265  //**********************************************************************************************
266 
267  //**********************************************************************************************
273  template< typename T >
274  inline bool canAlias( const T* alias ) const {
275  return ( mat_.isAliased( alias ) || vec_.isAliased( alias ) );
276  }
277  //**********************************************************************************************
278 
279  //**********************************************************************************************
285  template< typename T >
286  inline bool isAliased( const T* alias ) const {
287  return ( mat_.isAliased( alias ) || vec_.isAliased( alias ) );
288  }
289  //**********************************************************************************************
290 
291  //**********************************************************************************************
296  inline bool canSMPAssign() const {
297  return ( size() > SMP_SMATSVECMULT_THRESHOLD );
298  }
299  //**********************************************************************************************
300 
301  private:
302  //**Member variables****************************************************************************
303  LeftOperand mat_;
304  RightOperand vec_;
305  //**********************************************************************************************
306 
307  //**Assignment to dense vectors*****************************************************************
320  template< typename VT1 > // Type of the target dense vector
321  friend inline void assign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
322  {
324 
325  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
326 
327  // Resetting the left-hand side target dense vector
328  reset( ~lhs );
329 
330  // Evaluation of the right-hand side sparse vector operand
331  RT x( serial( rhs.vec_ ) );
332  if( x.nonZeros() == 0UL ) return;
333 
334  // Evaluation of the left-hand side sparse matrix operand
335  LT A( serial( rhs.mat_ ) );
336 
337  // Checking the evaluated operators
338  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
339  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
340  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
341  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
342 
343  // Performing the transpose sparse matrix-sparse vector multiplication
344  TSMatSVecMultExpr::selectAssignKernel( ~lhs, A, x );
345  }
347  //**********************************************************************************************
348 
349  //**Default assignment to dense vectors*********************************************************
363  template< typename VT1 // Type of the left-hand side target vector
364  , typename MT1 // Type of the left-hand side matrix operand
365  , typename VT2 > // Type of the right-hand side vector operand
366  static inline void selectAssignKernel( VT1& y, const MT1& A, const VT2& x )
367  {
368  typedef typename RemoveReference<MT1>::Type::ConstIterator MatrixIterator;
369  typedef typename RemoveReference<VT2>::Type::ConstIterator VectorIterator;
370 
371  const VectorIterator vend ( x.end() );
372  VectorIterator velem( x.begin() );
373 
374  for( ; velem!=vend; ++velem )
375  {
376  const MatrixIterator mend ( A.end ( velem->index() ) );
377  MatrixIterator melem( A.begin( velem->index() ) );
378 
379  for( ; melem!=mend; ++melem ) {
381  isDefault( y[melem->index()] ) )
382  y[melem->index()] = melem->value() * velem->value();
383  else
384  y[melem->index()] += melem->value() * velem->value();
385  }
386  }
387  }
389  //**********************************************************************************************
390 
391  //**Assignment to sparse vectors****************************************************************
403  template< typename VT1 > // Type of the target sparse vector
404  friend inline void assign( SparseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
405  {
407 
408  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
409 
410  typedef typename RemoveReference<LT>::Type::ConstIterator MatrixIterator;
411  typedef typename RemoveReference<RT>::Type::ConstIterator VectorIterator;
412 
413  RT x( serial( rhs.vec_ ) ); // Evaluation of the right-hand side sparse vector operand
414  if( x.nonZeros() == 0UL ) return;
415 
416  LT A( serial( rhs.mat_ ) ); // Evaluation of the left-hand side sparse matrix operand
417 
418  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
419  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
420  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
421  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
422 
423  DynamicVector<ElementType> tmp( (~lhs).size() );
424  std::vector<byte> indices( (~lhs).size(), 0 );
425  size_t nonzeros( 0UL );
426 
427  const VectorIterator vend ( x.end() );
428  VectorIterator velem( x.begin() );
429 
430  for( ; velem!=vend; ++velem )
431  {
432  const MatrixIterator mend ( A.end ( velem->index() ) );
433  MatrixIterator melem( A.begin( velem->index() ) );
434 
435  for( ; melem!=mend; ++melem ) {
436  if( !indices[melem->index()] ) {
437  indices[melem->index()] = 1;
438  ++nonzeros;
439  tmp[melem->index()] = melem->value() * velem->value();
440  }
441  else {
442  tmp[melem->index()] += melem->value() * velem->value();
443  }
444  }
445  }
446 
447  (~lhs).reserve( nonzeros );
448 
449  for( size_t i=0UL; i<(~lhs).size(); ++i ) {
450  if( indices[i] ) {
451  (~lhs).append( i, tmp[i] );
452  }
453  }
454  }
456  //**********************************************************************************************
457 
458  //**Addition assignment to dense vectors********************************************************
471  template< typename VT1 > // Type of the target dense vector
472  friend inline void addAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
473  {
475 
476  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
477 
478  // Evaluation of the right-hand side sparse vector operand
479  RT x( serial( rhs.vec_ ) );
480  if( x.nonZeros() == 0UL ) return;
481 
482  // Evaluation of the left-hand side sparse matrix operand
483  LT A( serial( rhs.mat_ ) );
484 
485  // Checking the evaluated operators
486  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
487  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
488  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
489  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
490 
491  // Performing the transpose sparse matrix-sparse vector multiplication
492  TSMatSVecMultExpr::selectAddAssignKernel( ~lhs, A, x );
493  }
495  //**********************************************************************************************
496 
497  //**Default addition assignment to dense vectors************************************************
511  template< typename VT1 // Type of the left-hand side target vector
512  , typename MT1 // Type of the left-hand side matrix operand
513  , typename VT2 > // Type of the right-hand side vector operand
514  static inline void selectAddAssignKernel( VT1& y, const MT1& A, const VT2& x )
515  {
516  typedef typename RemoveReference<MT1>::Type::ConstIterator MatrixIterator;
517  typedef typename RemoveReference<VT2>::Type::ConstIterator VectorIterator;
518 
519  const VectorIterator vend ( x.end() );
520  VectorIterator velem( x.begin() );
521 
522  for( ; velem!=vend; ++velem )
523  {
524  const MatrixIterator mend ( A.end ( velem->index() ) );
525  MatrixIterator melem( A.begin( velem->index() ) );
526 
527  for( ; melem!=mend; ++melem ) {
528  y[melem->index()] += melem->value() * velem->value();
529  }
530  }
531  }
533  //**********************************************************************************************
534 
535  //**Addition assignment to sparse vectors*******************************************************
536  // No special implementation for the addition assignment to sparse vectors.
537  //**********************************************************************************************
538 
539  //**Subtraction assignment to dense vectors*****************************************************
552  template< typename VT1 > // Type of the target dense vector
553  friend inline void subAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
554  {
556 
557  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
558 
559  // Evaluation of the right-hand side sparse vector operand
560  RT x( serial( rhs.vec_ ) );
561  if( x.nonZeros() == 0UL ) return;
562 
563  // Evaluation of the left-hand side sparse matrix operand
564  LT A( serial( rhs.mat_ ) );
565 
566  // Checking the evaluated operators
567  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
568  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
569  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
570  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
571 
572  // Performing the transpose sparse matrix-sparse vector multiplication
573  TSMatSVecMultExpr::selectSubAssignKernel( ~lhs, A, x );
574  }
576  //**********************************************************************************************
577 
578  //**Default subtraction assignment to dense vectors*********************************************
592  template< typename VT1 // Type of the left-hand side target vector
593  , typename MT1 // Type of the left-hand side matrix operand
594  , typename VT2 > // Type of the right-hand side vector operand
595  static inline void selectSubAssignKernel( VT1& y, const MT1& A, const VT2& x )
596  {
597  typedef typename RemoveReference<MT1>::Type::ConstIterator MatrixIterator;
598  typedef typename RemoveReference<VT2>::Type::ConstIterator VectorIterator;
599 
600  const VectorIterator vend ( x.end() );
601  VectorIterator velem( x.begin() );
602 
603  for( ; velem!=vend; ++velem )
604  {
605  const MatrixIterator mend ( A.end ( velem->index() ) );
606  MatrixIterator melem( A.begin( velem->index() ) );
607 
608  for( ; melem!=mend; ++melem ) {
609  y[melem->index()] -= melem->value() * velem->value();
610  }
611  }
612  }
614  //**********************************************************************************************
615 
616  //**Subtraction assignment to sparse vectors****************************************************
617  // No special implementation for the subtraction assignment to sparse vectors.
618  //**********************************************************************************************
619 
620  //**Multiplication assignment to dense vectors**************************************************
633  template< typename VT1 > // Type of the target dense vector
634  friend inline void multAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
635  {
637 
641 
642  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
643 
644  const ResultType tmp( serial( rhs ) );
645  multAssign( ~lhs, tmp );
646  }
648  //**********************************************************************************************
649 
650  //**Multiplication assignment to sparse vectors*************************************************
651  // No special implementation for the multiplication assignment to sparse vectors.
652  //**********************************************************************************************
653 
654  //**SMP assignment to dense vectors*************************************************************
669  template< typename VT1 > // Type of the target dense vector
670  friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
671  smpAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
672  {
674 
675  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
676 
677  // Resetting the left-hand side target dense vector
678  reset( ~lhs );
679 
680  // Evaluation of the right-hand side sparse vector operand
681  RT x( rhs.vec_ );
682  if( x.nonZeros() == 0UL ) return;
683 
684  // Evaluation of the left-hand side sparse matrix operand
685  LT A( rhs.mat_ );
686 
687  // Checking the evaluated operators
688  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
689  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
690  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
691  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
692 
693  // Performing the transpose sparse matrix-sparse vector multiplication
694  smpAssign( ~lhs, A * x );
695  }
697  //**********************************************************************************************
698 
699  //**SMP assignment to sparse vectors************************************************************
700  // No special implementation for the SMP assignment to sparse vectors.
701  //**********************************************************************************************
702 
703  //**SMP addition assignment to dense vectors****************************************************
718  template< typename VT1 > // Type of the target dense vector
719  friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
720  smpAddAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
721  {
723 
724  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
725 
726  // Evaluation of the right-hand side sparse vector operand
727  RT x( rhs.vec_ );
728  if( x.nonZeros() == 0UL ) return;
729 
730  // Evaluation of the left-hand side sparse matrix operand
731  LT A( rhs.mat_ );
732 
733  // Checking the evaluated operators
734  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
735  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
736  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
737  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
738 
739  // Performing the transpose sparse matrix-sparse vector multiplication
740  smpAddAssign( ~lhs, A * x );
741  }
743  //**********************************************************************************************
744 
745  //**SMP addition assignment to sparse vectors***************************************************
746  // No special implementation for the SMP addition assignment to sparse vectors.
747  //**********************************************************************************************
748 
749  //**SMP subtraction assignment to dense vectors*************************************************
764  template< typename VT1 > // Type of the target dense vector
765  friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
766  smpSubAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
767  {
769 
770  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
771 
772  // Evaluation of the right-hand side sparse vector operand
773  RT x( rhs.vec_ );
774  if( x.nonZeros() == 0UL ) return;
775 
776  // Evaluation of the left-hand side sparse matrix operand
777  LT A( rhs.mat_ );
778 
779  // Checking the evaluated operators
780  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
781  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
782  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
783  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
784 
785  // Performing the transpose sparse matrix-sparse vector multiplication
786  smpSubAssign( ~lhs, A * x );
787  }
789  //**********************************************************************************************
790 
791  //**SMP subtraction assignment to sparse vectors************************************************
792  // No special implementation for the SMP subtraction assignment to sparse vectors.
793  //**********************************************************************************************
794 
795  //**SMP multiplication assignment to dense vectors**********************************************
810  template< typename VT1 > // Type of the target dense vector
811  friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
812  smpMultAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
813  {
815 
819 
820  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
821 
822  const ResultType tmp( rhs );
823  smpMultAssign( ~lhs, tmp );
824  }
826  //**********************************************************************************************
827 
828  //**SMP multiplication assignment to sparse vectors*********************************************
829  // No special implementation for the SMP multiplication assignment to sparse vectors.
830  //**********************************************************************************************
831 
832  //**Compile time checks*************************************************************************
840  //**********************************************************************************************
841 };
842 //*************************************************************************************************
843 
844 
845 
846 
847 //=================================================================================================
848 //
849 // GLOBAL BINARY ARITHMETIC OPERATORS
850 //
851 //=================================================================================================
852 
853 //*************************************************************************************************
884 template< typename T1 // Type of the left-hand side sparse matrix
885  , typename T2 > // Type of the right-hand side sparse vector
886 inline const typename DisableIf< IsMatMatMultExpr<T1>, TSMatSVecMultExpr<T1,T2> >::Type
888 {
890 
891  if( (~mat).columns() != (~vec).size() ) {
892  BLAZE_THROW_INVALID_ARGUMENT( "Matrix and vector sizes do not match" );
893  }
894 
895  return TSMatSVecMultExpr<T1,T2>( ~mat, ~vec );
896 }
897 //*************************************************************************************************
898 
899 
900 
901 
902 //=================================================================================================
903 //
904 // SIZE SPECIALIZATIONS
905 //
906 //=================================================================================================
907 
908 //*************************************************************************************************
910 template< typename MT, typename VT >
911 struct Size< TSMatSVecMultExpr<MT,VT> > : public Rows<MT>
912 {};
914 //*************************************************************************************************
915 
916 
917 
918 
919 //=================================================================================================
920 //
921 // EXPRESSION TRAIT SPECIALIZATIONS
922 //
923 //=================================================================================================
924 
925 //*************************************************************************************************
927 template< typename MT, typename VT, bool AF >
928 struct SubvectorExprTrait< TSMatSVecMultExpr<MT,VT>, AF >
929 {
930  public:
931  //**********************************************************************************************
932  typedef typename MultExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type
933  , typename SubvectorExprTrait<const VT,AF>::Type >::Type Type;
934  //**********************************************************************************************
935 };
937 //*************************************************************************************************
938 
939 } // namespace blaze
940 
941 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:89
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: TSMatSVecMultExpr.h:296
MultTrait< MRT, VRT >::Type ResultType
Result type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:133
MT::ResultType MRT
Result type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:101
Header file for the Rows 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:7820
Header file for basic type definitions.
Header file for the SparseVector base class.
#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:79
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
LeftOperand leftOperand() const
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatSVecMultExpr.h:252
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
SelectType< evaluateMatrix, const MRT, MCT >::Type LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: TSMatSVecMultExpr.h:148
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TSMatSVecMultExpr.h:274
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
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: TSMatSVecMultExpr.h:180
Header file for the implementation of an arbitrarily sized vector.
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:117
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:136
Constraint on the data type.
Constraint on the transpose flag of vector types.
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:261
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Expression object for sparse matrix-sparse vector multiplications.The TSMatSVecMultExpr class represe...
Definition: Forward.h:155
#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:79
SelectType< evaluateVector, const VRT, VCT >::Type RT
Type for the assignment of the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:151
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatSVecMultExpr.h:139
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 exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:142
RightOperand vec_
Right-hand side sparse vector of the multiplication expression.
Definition: TSMatSVecMultExpr.h:304
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
TSMatSVecMultExpr< MT, VT > This
Type of this TSMatSVecMultExpr instance.
Definition: TSMatSVecMultExpr.h:132
#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:79
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TSMatSVecMultExpr.h:286
#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:78
#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:166
VT::ResultType VRT
Result type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:102
size_t size() const
Returns the current size/dimension of the vector.
Definition: TSMatSVecMultExpr.h:232
Header file for the SelectType class template.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
ResultType::ElementType ElementType
Resulting element type.
Definition: TSMatSVecMultExpr.h:135
Header file for the EnableIf class template.
Header file for the serial shim.
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: TSMatSVecMultExpr.h:219
Header file for the byte type.
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:134
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
EnableIf< IsDenseMatrix< MT1 > >::Type 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
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:145
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
LeftOperand mat_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatSVecMultExpr.h:303
MT::CompositeType MCT
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:103
TSMatSVecMultExpr(const MT &mat, const VT &vec)
Constructor for the TSMatSVecMultExpr class.
Definition: TSMatSVecMultExpr.h:166
Header file for run time assertion macros.
EnableIf< IsDenseMatrix< MT1 > >::Type 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
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition: TSMatSVecMultExpr.h:242
Base template for the MultTrait class.
Definition: MultTrait.h:138
VT::CompositeType VCT
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:104
Header file for the reset shim.
Header file for the isDefault shim.
Constraints on the storage order of matrix types.
Header file for the RemoveReference type trait.
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:262
Header file for the IsComputation type trait class.
EnableIf< IsDenseMatrix< MT1 > >::Type 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 vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:118
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
Constraint on the data type.
Header file for exception macros.
Header file for the MatVecMultExpr base class.
Header file for the IsResizable type trait.
EnableIf< IsDenseVector< VT1 > >::Type 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:189
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:79
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.