All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <stdexcept>
44 #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>
72 #include <blaze/util/SelectType.h>
73 #include <blaze/util/Types.h>
75 
76 
77 namespace blaze {
78 
79 //=================================================================================================
80 //
81 // CLASS SMATDVECMULTEXPR
82 //
83 //=================================================================================================
84 
85 //*************************************************************************************************
92 template< typename MT // Type of the left-hand side sparse matrix
93  , typename VT > // Type of the right-hand side sparse vector
94 class TSMatSVecMultExpr : public SparseVector< TSMatSVecMultExpr<MT,VT>, false >
95  , private MatVecMultExpr
96  , private Computation
97 {
98  private:
99  //**Type definitions****************************************************************************
100  typedef typename MT::ResultType MRT;
101  typedef typename VT::ResultType VRT;
102  typedef typename MT::CompositeType MCT;
103  typedef typename VT::CompositeType VCT;
104  //**********************************************************************************************
105 
106  //**********************************************************************************************
108  enum { evaluateMatrix = RequiresEvaluation<MT>::value };
109  //**********************************************************************************************
110 
111  //**********************************************************************************************
113  enum { evaluateVector = RequiresEvaluation<VT>::value || IsComputation<VT>::value };
114  //**********************************************************************************************
115 
116  //**********************************************************************************************
118 
122  template< typename T1 >
123  struct UseSMPAssign {
124  enum { value = ( evaluateMatrix || evaluateVector ) };
125  };
127  //**********************************************************************************************
128 
129  public:
130  //**Type definitions****************************************************************************
135  typedef const ElementType ReturnType;
136 
138  typedef const ResultType CompositeType;
139 
141  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type LeftOperand;
142 
144  typedef typename SelectType< IsExpression<VT>::value, const VT, const VT& >::Type RightOperand;
145 
148 
151  //**********************************************************************************************
152 
153  //**Compilation flags***************************************************************************
155  enum { smpAssignable = !evaluateMatrix && MT::smpAssignable &&
156  !evaluateVector && VT::smpAssignable };
157  //**********************************************************************************************
158 
159  //**Constructor*********************************************************************************
165  explicit inline TSMatSVecMultExpr( const MT& mat, const VT& vec )
166  : mat_( mat ) // Left-hand side sparse matrix of the multiplication expression
167  , vec_( vec ) // Right-hand side sparse vector of the multiplication expression
168  {
169  BLAZE_INTERNAL_ASSERT( mat_.columns() == vec_.size(), "Invalid matrix and vector sizes" );
170  }
171  //**********************************************************************************************
172 
173  //**Subscript operator**************************************************************************
179  inline ReturnType operator[]( size_t index ) const {
180  BLAZE_INTERNAL_ASSERT( index < mat_.rows(), "Invalid vector access index" );
181 
182  typedef typename RemoveReference<MCT>::Type::ConstIterator MatrixIterator;
183  typedef typename RemoveReference<VCT>::Type::ConstIterator VectorIterator;
184 
185  MCT A( mat_ ); // Evaluation of the left-hand side sparse matrix operand
186  VCT x( vec_ ); // Evaluation of the right-hand side sparse vector operand
187 
188  BLAZE_INTERNAL_ASSERT( A.rows() == mat_.rows() , "Invalid number of rows" );
189  BLAZE_INTERNAL_ASSERT( A.columns() == mat_.columns(), "Invalid number of columns" );
190  BLAZE_INTERNAL_ASSERT( x.size() == vec_.size() , "Invalid vector size" );
191 
192  ElementType res;
193 
194  const VectorIterator vend( x.end() );
195  VectorIterator velem( x.begin() );
196 
197  if( vec_.size() > 0UL && velem != vend ) {
198  res = A( index, velem->index() ) * velem->value();
199  ++velem;
200  for( ; velem!=vend; ++velem )
201  res += A( index, velem->index() ) * velem->value();
202  }
203  else {
204  reset( res );
205  }
206 
207  return res;
208  }
209  //**********************************************************************************************
210 
211  //**Size function*******************************************************************************
216  inline size_t size() const {
217  return mat_.rows();
218  }
219  //**********************************************************************************************
220 
221  //**NonZeros function***************************************************************************
226  inline size_t nonZeros() const {
227  return mat_.rows();
228  }
229  //**********************************************************************************************
230 
231  //**Left operand access*************************************************************************
236  inline LeftOperand leftOperand() const {
237  return mat_;
238  }
239  //**********************************************************************************************
240 
241  //**Right operand function**********************************************************************
246  inline RightOperand rightOperand() const {
247  return vec_;
248  }
249  //**********************************************************************************************
250 
251  //**********************************************************************************************
257  template< typename T >
258  inline bool canAlias( const T* alias ) const {
259  return ( mat_.isAliased( alias ) || vec_.isAliased( alias ) );
260  }
261  //**********************************************************************************************
262 
263  //**********************************************************************************************
269  template< typename T >
270  inline bool isAliased( const T* alias ) const {
271  return ( mat_.isAliased( alias ) || vec_.isAliased( alias ) );
272  }
273  //**********************************************************************************************
274 
275  //**********************************************************************************************
280  inline bool canSMPAssign() const {
281  return ( size() > SMP_SMATSVECMULT_THRESHOLD );
282  }
283  //**********************************************************************************************
284 
285  private:
286  //**Member variables****************************************************************************
289  //**********************************************************************************************
290 
291  //**Assignment to dense vectors*****************************************************************
304  template< typename VT1 > // Type of the target dense vector
305  friend inline void assign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
306  {
308 
309  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
310 
311  // Resetting the left-hand side target dense vector
312  reset( ~lhs );
313 
314  // Evaluation of the right-hand side sparse vector operand
315  RT x( serial( rhs.vec_ ) );
316  if( x.nonZeros() == 0UL ) return;
317 
318  // Evaluation of the left-hand side sparse matrix operand
319  LT A( serial( rhs.mat_ ) );
320 
321  // Checking the evaluated operators
322  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
323  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
324  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
325  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
326 
327  // Performing the transpose sparse matrix-sparse vector multiplication
328  TSMatSVecMultExpr::selectAssignKernel( ~lhs, A, x );
329  }
331  //**********************************************************************************************
332 
333  //**Default assignment to dense vectors*********************************************************
347  template< typename VT1 // Type of the left-hand side target vector
348  , typename MT1 // Type of the left-hand side matrix operand
349  , typename VT2 > // Type of the right-hand side vector operand
350  static inline void selectAssignKernel( VT1& y, const MT1& A, const VT2& x )
351  {
352  typedef typename RemoveReference<MT1>::Type::ConstIterator MatrixIterator;
353  typedef typename RemoveReference<VT2>::Type::ConstIterator VectorIterator;
354 
355  const VectorIterator vend ( x.end() );
356  VectorIterator velem( x.begin() );
357 
358  for( ; velem!=vend; ++velem )
359  {
360  const MatrixIterator mend ( A.end ( velem->index() ) );
361  MatrixIterator melem( A.begin( velem->index() ) );
362 
363  for( ; melem!=mend; ++melem ) {
365  isDefault( y[melem->index()] ) )
366  y[melem->index()] = melem->value() * velem->value();
367  else
368  y[melem->index()] += melem->value() * velem->value();
369  }
370  }
371  }
373  //**********************************************************************************************
374 
375  //**Assignment to sparse vectors****************************************************************
387  template< typename VT1 > // Type of the target sparse vector
388  friend inline void assign( SparseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
389  {
391 
392  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
393 
394  typedef typename RemoveReference<LT>::Type::ConstIterator MatrixIterator;
395  typedef typename RemoveReference<RT>::Type::ConstIterator VectorIterator;
396 
397  RT x( serial( rhs.vec_ ) ); // Evaluation of the right-hand side sparse vector operand
398  if( x.nonZeros() == 0UL ) return;
399 
400  LT A( serial( rhs.mat_ ) ); // Evaluation of the left-hand side sparse matrix operand
401 
402  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
403  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
404  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
405  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
406 
407  DynamicVector<ElementType> tmp( (~lhs).size() );
408  std::vector<byte> indices( (~lhs).size(), 0 );
409  size_t nonzeros( 0UL );
410 
411  const VectorIterator vend ( x.end() );
412  VectorIterator velem( x.begin() );
413 
414  for( ; velem!=vend; ++velem )
415  {
416  const MatrixIterator mend ( A.end ( velem->index() ) );
417  MatrixIterator melem( A.begin( velem->index() ) );
418 
419  for( ; melem!=mend; ++melem ) {
420  if( !indices[melem->index()] ) {
421  indices[melem->index()] = 1;
422  ++nonzeros;
423  tmp[melem->index()] = melem->value() * velem->value();
424  }
425  else {
426  tmp[melem->index()] += melem->value() * velem->value();
427  }
428  }
429  }
430 
431  (~lhs).reserve( nonzeros );
432 
433  for( size_t i=0UL; i<(~lhs).size(); ++i ) {
434  if( indices[i] ) {
435  (~lhs).append( i, tmp[i] );
436  }
437  }
438  }
440  //**********************************************************************************************
441 
442  //**Addition assignment to dense vectors********************************************************
455  template< typename VT1 > // Type of the target dense vector
456  friend inline void addAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
457  {
459 
460  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
461 
462  // Evaluation of the right-hand side sparse vector operand
463  RT x( serial( rhs.vec_ ) );
464  if( x.nonZeros() == 0UL ) return;
465 
466  // Evaluation of the left-hand side sparse matrix operand
467  LT A( serial( rhs.mat_ ) );
468 
469  // Checking the evaluated operators
470  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
471  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
472  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
473  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
474 
475  // Performing the transpose sparse matrix-sparse vector multiplication
476  TSMatSVecMultExpr::selectAddAssignKernel( ~lhs, A, x );
477  }
479  //**********************************************************************************************
480 
481  //**Default addition assignment to dense vectors************************************************
495  template< typename VT1 // Type of the left-hand side target vector
496  , typename MT1 // Type of the left-hand side matrix operand
497  , typename VT2 > // Type of the right-hand side vector operand
498  static inline void selectAddAssignKernel( VT1& y, const MT1& A, const VT2& x )
499  {
500  typedef typename RemoveReference<MT1>::Type::ConstIterator MatrixIterator;
501  typedef typename RemoveReference<VT2>::Type::ConstIterator VectorIterator;
502 
503  const VectorIterator vend ( x.end() );
504  VectorIterator velem( x.begin() );
505 
506  for( ; velem!=vend; ++velem )
507  {
508  const MatrixIterator mend ( A.end ( velem->index() ) );
509  MatrixIterator melem( A.begin( velem->index() ) );
510 
511  for( ; melem!=mend; ++melem ) {
512  y[melem->index()] += melem->value() * velem->value();
513  }
514  }
515  }
517  //**********************************************************************************************
518 
519  //**Addition assignment to sparse vectors*******************************************************
520  // No special implementation for the addition assignment to sparse vectors.
521  //**********************************************************************************************
522 
523  //**Subtraction assignment to dense vectors*****************************************************
536  template< typename VT1 > // Type of the target dense vector
537  friend inline void subAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
538  {
540 
541  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
542 
543  // Evaluation of the right-hand side sparse vector operand
544  RT x( serial( rhs.vec_ ) );
545  if( x.nonZeros() == 0UL ) return;
546 
547  // Evaluation of the left-hand side sparse matrix operand
548  LT A( serial( rhs.mat_ ) );
549 
550  // Checking the evaluated operators
551  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
552  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
553  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
554  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
555 
556  // Performing the transpose sparse matrix-sparse vector multiplication
557  TSMatSVecMultExpr::selectSubAssignKernel( ~lhs, A, x );
558  }
560  //**********************************************************************************************
561 
562  //**Default subtraction assignment to dense vectors*********************************************
576  template< typename VT1 // Type of the left-hand side target vector
577  , typename MT1 // Type of the left-hand side matrix operand
578  , typename VT2 > // Type of the right-hand side vector operand
579  static inline void selectSubAssignKernel( VT1& y, const MT1& A, const VT2& x )
580  {
581  typedef typename RemoveReference<MT1>::Type::ConstIterator MatrixIterator;
582  typedef typename RemoveReference<VT2>::Type::ConstIterator VectorIterator;
583 
584  const VectorIterator vend ( x.end() );
585  VectorIterator velem( x.begin() );
586 
587  for( ; velem!=vend; ++velem )
588  {
589  const MatrixIterator mend ( A.end ( velem->index() ) );
590  MatrixIterator melem( A.begin( velem->index() ) );
591 
592  for( ; melem!=mend; ++melem ) {
593  y[melem->index()] -= melem->value() * velem->value();
594  }
595  }
596  }
598  //**********************************************************************************************
599 
600  //**Subtraction assignment to sparse vectors****************************************************
601  // No special implementation for the subtraction assignment to sparse vectors.
602  //**********************************************************************************************
603 
604  //**Multiplication assignment to dense vectors**************************************************
617  template< typename VT1 > // Type of the target dense vector
618  friend inline void multAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
619  {
621 
625 
626  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
627 
628  const ResultType tmp( serial( rhs ) );
629  multAssign( ~lhs, tmp );
630  }
632  //**********************************************************************************************
633 
634  //**Multiplication assignment to sparse vectors*************************************************
635  // No special implementation for the multiplication assignment to sparse vectors.
636  //**********************************************************************************************
637 
638  //**SMP assignment to dense vectors*************************************************************
653  template< typename VT1 > // Type of the target dense vector
654  friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
655  smpAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
656  {
658 
659  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
660 
661  // Resetting the left-hand side target dense vector
662  reset( ~lhs );
663 
664  // Evaluation of the right-hand side sparse vector operand
665  RT x( rhs.vec_ );
666  if( x.nonZeros() == 0UL ) return;
667 
668  // Evaluation of the left-hand side sparse matrix operand
669  LT A( rhs.mat_ );
670 
671  // Checking the evaluated operators
672  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
673  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
674  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
675  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
676 
677  // Performing the transpose sparse matrix-sparse vector multiplication
678  smpAssign( ~lhs, A * x );
679  }
681  //**********************************************************************************************
682 
683  //**SMP assignment to sparse vectors************************************************************
684  // No special implementation for the SMP assignment to sparse vectors.
685  //**********************************************************************************************
686 
687  //**SMP addition assignment to dense vectors****************************************************
702  template< typename VT1 > // Type of the target dense vector
703  friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
704  smpAddAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
705  {
707 
708  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
709 
710  // Evaluation of the right-hand side sparse vector operand
711  RT x( rhs.vec_ );
712  if( x.nonZeros() == 0UL ) return;
713 
714  // Evaluation of the left-hand side sparse matrix operand
715  LT A( rhs.mat_ );
716 
717  // Checking the evaluated operators
718  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
719  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
720  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
721  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
722 
723  // Performing the transpose sparse matrix-sparse vector multiplication
724  smpAddAssign( ~lhs, A * x );
725  }
727  //**********************************************************************************************
728 
729  //**SMP addition assignment to sparse vectors***************************************************
730  // No special implementation for the SMP addition assignment to sparse vectors.
731  //**********************************************************************************************
732 
733  //**SMP subtraction assignment to dense vectors*************************************************
748  template< typename VT1 > // Type of the target dense vector
749  friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
750  smpSubAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
751  {
753 
754  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
755 
756  // Evaluation of the right-hand side sparse vector operand
757  RT x( rhs.vec_ );
758  if( x.nonZeros() == 0UL ) return;
759 
760  // Evaluation of the left-hand side sparse matrix operand
761  LT A( rhs.mat_ );
762 
763  // Checking the evaluated operators
764  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
765  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
766  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
767  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
768 
769  // Performing the transpose sparse matrix-sparse vector multiplication
770  smpSubAssign( ~lhs, A * x );
771  }
773  //**********************************************************************************************
774 
775  //**SMP subtraction assignment to sparse vectors************************************************
776  // No special implementation for the SMP subtraction assignment to sparse vectors.
777  //**********************************************************************************************
778 
779  //**SMP multiplication assignment to dense vectors**********************************************
794  template< typename VT1 > // Type of the target dense vector
795  friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
796  smpMultAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
797  {
799 
803 
804  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
805 
806  const ResultType tmp( rhs );
807  smpMultAssign( ~lhs, tmp );
808  }
810  //**********************************************************************************************
811 
812  //**SMP multiplication assignment to sparse vectors*********************************************
813  // No special implementation for the SMP multiplication assignment to sparse vectors.
814  //**********************************************************************************************
815 
816  //**Compile time checks*************************************************************************
824  //**********************************************************************************************
825 };
826 //*************************************************************************************************
827 
828 
829 
830 
831 //=================================================================================================
832 //
833 // GLOBAL BINARY ARITHMETIC OPERATORS
834 //
835 //=================================================================================================
836 
837 //*************************************************************************************************
868 template< typename T1 // Type of the left-hand side sparse matrix
869  , typename T2 > // Type of the right-hand side sparse vector
870 inline const typename DisableIf< IsMatMatMultExpr<T1>, TSMatSVecMultExpr<T1,T2> >::Type
872 {
874 
875  if( (~mat).columns() != (~vec).size() )
876  throw std::invalid_argument( "Matrix and vector sizes do not match" );
877 
878  return TSMatSVecMultExpr<T1,T2>( ~mat, ~vec );
879 }
880 //*************************************************************************************************
881 
882 
883 
884 
885 //=================================================================================================
886 //
887 // SIZE SPECIALIZATIONS
888 //
889 //=================================================================================================
890 
891 //*************************************************************************************************
893 template< typename MT, typename VT >
894 struct Size< TSMatSVecMultExpr<MT,VT> >
895  : public Rows<MT>
896 {};
898 //*************************************************************************************************
899 
900 
901 
902 
903 //=================================================================================================
904 //
905 // EXPRESSION TRAIT SPECIALIZATIONS
906 //
907 //=================================================================================================
908 
909 //*************************************************************************************************
911 template< typename MT, typename VT, bool AF >
912 struct SubvectorExprTrait< TSMatSVecMultExpr<MT,VT>, AF >
913 {
914  public:
915  //**********************************************************************************************
916  typedef typename MultExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type, VT >::Type Type;
917  //**********************************************************************************************
918 };
920 //*************************************************************************************************
921 
922 } // namespace blaze
923 
924 #endif
VT::CompositeType VCT
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:103
const size_t SMP_SMATSVECMULT_THRESHOLD
SMP row-major sparse matrix/sparse vector multiplication threshold.This threshold specifies when a ro...
Definition: Thresholds.h:598
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:89
BLAZE_ALWAYS_INLINE void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:879
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:4838
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition: TSMatSVecMultExpr.h:226
Header file for the SparseVector base class.
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:141
#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: TransposeFlag.h:159
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatSVecMultExpr.h:138
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TSMatSVecMultExpr.h:270
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:257
size_t size() const
Returns the current size/dimension of the vector.
Definition: TSMatSVecMultExpr.h:216
SelectType< evaluateVector, const VRT, VCT >::Type RT
Type for the assignment of the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:150
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
SelectType< evaluateMatrix, const MRT, MCT >::Type LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: TSMatSVecMultExpr.h:147
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:144
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:107
Constraint on the data type.
MT::ResultType MRT
Result type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:100
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:259
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.
Expression object for sparse matrix-sparse vector multiplications.The TSMatSVecMultExpr class represe...
Definition: Forward.h:142
#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: StorageOrder.h:161
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
Header file for the IsMatMatMultExpr type trait class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
ResultType::ElementType ElementType
Resulting element type.
Definition: TSMatSVecMultExpr.h:134
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#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
Constraint on the data type.
LeftOperand leftOperand() const
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatSVecMultExpr.h:236
#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
TSMatSVecMultExpr< MT, VT > This
Type of this TSMatSVecMultExpr instance.
Definition: TSMatSVecMultExpr.h:131
#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
LeftOperand mat_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatSVecMultExpr.h:287
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TSMatSVecMultExpr.h:258
Header file for the SelectType class template.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the serial shim.
Header file for the byte type.
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
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Header file for run time assertion macros.
RightOperand vec_
Right-hand side sparse vector of the multiplication expression.
Definition: TSMatSVecMultExpr.h:288
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
Base template for the MultTrait class.
Definition: MultTrait.h:142
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
Header file for the reset shim.
Header file for the isDefault shim.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: TSMatSVecMultExpr.h:179
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: TSMatSVecMultExpr.h:280
Header file for the RemoveReference type trait.
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:135
VT::ResultType VRT
Result type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:101
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:108
#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:2473
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:133
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
MultTrait< MRT, VRT >::Type ResultType
Result type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:132
Header file for basic type definitions.
TSMatSVecMultExpr(const MT &mat, const VT &vec)
Constructor for the TSMatSVecMultExpr class.
Definition: TSMatSVecMultExpr.h:165
Constraint on the data type.
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:246
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
MT::CompositeType MCT
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:102
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849