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 <blaze/math/Aliases.h>
53 #include <blaze/math/Exception.h>
59 #include <blaze/math/shims/Reset.h>
73 #include <blaze/math/views/Check.h>
75 #include <blaze/util/Assert.h>
76 #include <blaze/util/DisableIf.h>
77 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/mpl/If.h>
80 #include <blaze/util/Types.h>
81 
82 
83 namespace blaze {
84 
85 //=================================================================================================
86 //
87 // CLASS SMATDVECMULTEXPR
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
98 template< typename MT // Type of the left-hand side sparse matrix
99  , typename VT > // Type of the right-hand side sparse vector
100 class TSMatSVecMultExpr
101  : public MatVecMultExpr< SparseVector< TSMatSVecMultExpr<MT,VT>, false > >
102  , private Computation
103 {
104  private:
105  //**Type definitions****************************************************************************
110  //**********************************************************************************************
111 
112  //**********************************************************************************************
114  static constexpr bool evaluateMatrix = RequiresEvaluation_v<MT>;
115  //**********************************************************************************************
116 
117  //**********************************************************************************************
119  static constexpr bool evaluateVector = ( RequiresEvaluation_v<VT> || IsComputation_v<VT> );
120  //**********************************************************************************************
121 
122  //**********************************************************************************************
124 
128  template< typename T1 >
129  static constexpr bool UseSMPAssign_v = ( evaluateMatrix || evaluateVector );
131  //**********************************************************************************************
132 
133  public:
134  //**Type definitions****************************************************************************
140  using ReturnType = const ElementType;
141 
143  using CompositeType = const ResultType;
144 
146  using LeftOperand = If_t< IsExpression_v<MT>, const MT, const MT& >;
147 
149  using RightOperand = If_t< IsExpression_v<VT>, const VT, const VT& >;
150 
153 
156  //**********************************************************************************************
157 
158  //**Compilation flags***************************************************************************
160  static constexpr bool smpAssignable =
162  //**********************************************************************************************
163 
164  //**Constructor*********************************************************************************
170  explicit inline TSMatSVecMultExpr( const MT& mat, const VT& vec ) noexcept
171  : mat_( mat ) // Left-hand side sparse matrix of the multiplication expression
172  , vec_( vec ) // Right-hand side sparse vector of the multiplication expression
173  {
174  BLAZE_INTERNAL_ASSERT( mat_.columns() == vec_.size(), "Invalid matrix and vector sizes" );
175  }
176  //**********************************************************************************************
177 
178  //**Subscript operator**************************************************************************
184  inline ReturnType operator[]( size_t index ) const {
185  BLAZE_INTERNAL_ASSERT( index < mat_.rows(), "Invalid vector access index" );
186 
187  if( IsDiagonal_v<MT> )
188  {
189  return mat_(index,index) * vec_[index];
190  }
191  else if( IsLower_v<MT> )
192  {
193  const size_t n( IsStrictlyLower_v<MT> ? index : index+1UL );
194  return subvector( row( mat_, index, unchecked ), 0UL, n, unchecked ) *
195  subvector( vec_, 0UL, n, unchecked );
196  }
197  else if( IsUpper_v<MT> )
198  {
199  const size_t begin( IsStrictlyUpper_v<MT> ? index+1UL : index );
200  const size_t n ( mat_.columns() - begin );
201  return subvector( row( mat_, index, unchecked ), begin, n, unchecked ) *
202  subvector( vec_, begin, n, unchecked );
203  }
204  else
205  {
206  return row( mat_, index, unchecked ) * vec_;
207  }
208  }
209  //**********************************************************************************************
210 
211  //**At function*********************************************************************************
218  inline ReturnType at( size_t index ) const {
219  if( index >= mat_.rows() ) {
220  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
221  }
222  return (*this)[index];
223  }
224  //**********************************************************************************************
225 
226  //**Size function*******************************************************************************
231  inline size_t size() const noexcept {
232  return mat_.rows();
233  }
234  //**********************************************************************************************
235 
236  //**NonZeros function***************************************************************************
241  inline size_t nonZeros() const {
242  return mat_.rows();
243  }
244  //**********************************************************************************************
245 
246  //**Left operand access*************************************************************************
251  inline LeftOperand leftOperand() const noexcept {
252  return mat_;
253  }
254  //**********************************************************************************************
255 
256  //**Right operand function**********************************************************************
261  inline RightOperand rightOperand() const noexcept {
262  return vec_;
263  }
264  //**********************************************************************************************
265 
266  //**********************************************************************************************
272  template< typename T >
273  inline bool canAlias( const T* alias ) const noexcept {
274  return ( mat_.isAliased( alias ) || vec_.isAliased( alias ) );
275  }
276  //**********************************************************************************************
277 
278  //**********************************************************************************************
284  template< typename T >
285  inline bool isAliased( const T* alias ) const noexcept {
286  return ( mat_.isAliased( alias ) || vec_.isAliased( alias ) );
287  }
288  //**********************************************************************************************
289 
290  //**********************************************************************************************
295  inline bool canSMPAssign() const noexcept {
296  return ( size() > SMP_SMATSVECMULT_THRESHOLD );
297  }
298  //**********************************************************************************************
299 
300  private:
301  //**Member variables****************************************************************************
304  //**********************************************************************************************
305 
306  //**Assignment to dense vectors*****************************************************************
319  template< typename VT1 > // Type of the target dense vector
320  friend inline void assign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
321  {
323 
324  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
325 
326  // Resetting the left-hand side target dense vector
327  reset( ~lhs );
328 
329  // Evaluation of the right-hand side sparse vector operand
330  RT x( serial( rhs.vec_ ) );
331  if( x.nonZeros() == 0UL ) return;
332 
333  // Evaluation of the left-hand side sparse matrix operand
334  LT A( serial( rhs.mat_ ) );
335 
336  // Checking the evaluated operators
337  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
338  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
339  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
340  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
341 
342  // Performing the transpose sparse matrix-sparse vector multiplication
343  TSMatSVecMultExpr::selectAssignKernel( ~lhs, A, x );
344  }
346  //**********************************************************************************************
347 
348  //**Default assignment to dense vectors*********************************************************
362  template< typename VT1 // Type of the left-hand side target vector
363  , typename MT1 // Type of the left-hand side matrix operand
364  , typename VT2 > // Type of the right-hand side vector operand
365  static inline void selectAssignKernel( VT1& y, const MT1& A, const VT2& x )
366  {
367  const auto vend ( x.end() );
368  auto velem( x.begin() );
369 
370  for( ; velem!=vend; ++velem )
371  {
372  const auto mend ( A.end ( velem->index() ) );
373  auto melem( A.begin( velem->index() ) );
374 
375  for( ; melem!=mend; ++melem ) {
377  isDefault( y[melem->index()] ) )
378  y[melem->index()] = melem->value() * velem->value();
379  else
380  y[melem->index()] += melem->value() * velem->value();
381  }
382  }
383  }
385  //**********************************************************************************************
386 
387  //**Assignment to sparse vectors****************************************************************
399  template< typename VT1 > // Type of the target sparse vector
400  friend inline void assign( SparseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
401  {
403 
404  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
405 
406  const DynamicVector<ElementType_t<VT1>,false> tmp( serial( rhs ) );
407  assign( ~lhs, tmp );
408  }
410  //**********************************************************************************************
411 
412  //**Addition assignment to dense vectors********************************************************
425  template< typename VT1 > // Type of the target dense vector
426  friend inline void addAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
427  {
429 
430  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
431 
432  // Evaluation of the right-hand side sparse vector operand
433  RT x( serial( rhs.vec_ ) );
434  if( x.nonZeros() == 0UL ) return;
435 
436  // Evaluation of the left-hand side sparse matrix operand
437  LT A( serial( rhs.mat_ ) );
438 
439  // Checking the evaluated operators
440  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
441  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
442  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
443  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
444 
445  // Performing the transpose sparse matrix-sparse vector multiplication
446  TSMatSVecMultExpr::selectAddAssignKernel( ~lhs, A, x );
447  }
449  //**********************************************************************************************
450 
451  //**Default addition assignment to dense vectors************************************************
465  template< typename VT1 // Type of the left-hand side target vector
466  , typename MT1 // Type of the left-hand side matrix operand
467  , typename VT2 > // Type of the right-hand side vector operand
468  static inline void selectAddAssignKernel( VT1& y, const MT1& A, const VT2& x )
469  {
470  const auto vend ( x.end() );
471  auto velem( x.begin() );
472 
473  for( ; velem!=vend; ++velem )
474  {
475  const auto mend ( A.end ( velem->index() ) );
476  auto melem( A.begin( velem->index() ) );
477 
478  for( ; melem!=mend; ++melem ) {
479  y[melem->index()] += melem->value() * velem->value();
480  }
481  }
482  }
484  //**********************************************************************************************
485 
486  //**Addition assignment to sparse vectors*******************************************************
487  // No special implementation for the addition assignment to sparse vectors.
488  //**********************************************************************************************
489 
490  //**Subtraction assignment to dense vectors*****************************************************
503  template< typename VT1 > // Type of the target dense vector
504  friend inline void subAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& 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 transpose sparse matrix-sparse vector multiplication
524  TSMatSVecMultExpr::selectSubAssignKernel( ~lhs, A, x );
525  }
527  //**********************************************************************************************
528 
529  //**Default subtraction 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 selectSubAssignKernel( VT1& y, const MT1& A, const VT2& x )
547  {
548  const auto vend ( x.end() );
549  auto velem( x.begin() );
550 
551  for( ; velem!=vend; ++velem )
552  {
553  const auto mend ( A.end ( velem->index() ) );
554  auto melem( A.begin( velem->index() ) );
555 
556  for( ; melem!=mend; ++melem ) {
557  y[melem->index()] -= melem->value() * velem->value();
558  }
559  }
560  }
562  //**********************************************************************************************
563 
564  //**Subtraction assignment to sparse vectors****************************************************
565  // No special implementation for the subtraction assignment to sparse vectors.
566  //**********************************************************************************************
567 
568  //**Multiplication assignment to dense vectors**************************************************
581  template< typename VT1 > // Type of the target dense vector
582  friend inline void multAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
583  {
585 
589 
590  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
591 
592  const ResultType tmp( serial( rhs ) );
593  multAssign( ~lhs, tmp );
594  }
596  //**********************************************************************************************
597 
598  //**Multiplication assignment to sparse vectors*************************************************
599  // No special implementation for the multiplication assignment to sparse vectors.
600  //**********************************************************************************************
601 
602  //**SMP assignment to dense vectors*************************************************************
617  template< typename VT1 > // Type of the target dense vector
618  friend inline auto smpAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
619  -> EnableIf_t< UseSMPAssign_v<VT1> >
620  {
622 
623  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
624 
625  // Resetting the left-hand side target dense vector
626  reset( ~lhs );
627 
628  // Evaluation of the right-hand side sparse vector operand
629  RT x( rhs.vec_ );
630  if( x.nonZeros() == 0UL ) return;
631 
632  // Evaluation of the left-hand side sparse matrix operand
633  LT A( rhs.mat_ );
634 
635  // Checking the evaluated operators
636  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
637  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
638  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
639  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
640 
641  // Performing the transpose sparse matrix-sparse vector multiplication
642  smpAssign( ~lhs, A * x );
643  }
645  //**********************************************************************************************
646 
647  //**SMP assignment to sparse vectors************************************************************
648  // No special implementation for the SMP assignment to sparse vectors.
649  //**********************************************************************************************
650 
651  //**SMP addition assignment to dense vectors****************************************************
666  template< typename VT1 > // Type of the target dense vector
667  friend inline auto smpAddAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
668  -> EnableIf_t< UseSMPAssign_v<VT1> >
669  {
671 
672  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
673 
674  // Evaluation of the right-hand side sparse vector operand
675  RT x( rhs.vec_ );
676  if( x.nonZeros() == 0UL ) return;
677 
678  // Evaluation of the left-hand side sparse matrix operand
679  LT A( rhs.mat_ );
680 
681  // Checking the evaluated operators
682  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
683  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
684  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
685  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
686 
687  // Performing the transpose sparse matrix-sparse vector multiplication
688  smpAddAssign( ~lhs, A * x );
689  }
691  //**********************************************************************************************
692 
693  //**SMP addition assignment to sparse vectors***************************************************
694  // No special implementation for the SMP addition assignment to sparse vectors.
695  //**********************************************************************************************
696 
697  //**SMP subtraction assignment to dense vectors*************************************************
712  template< typename VT1 > // Type of the target dense vector
713  friend inline auto smpSubAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
714  -> EnableIf_t< UseSMPAssign_v<VT1> >
715  {
717 
718  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
719 
720  // Evaluation of the right-hand side sparse vector operand
721  RT x( rhs.vec_ );
722  if( x.nonZeros() == 0UL ) return;
723 
724  // Evaluation of the left-hand side sparse matrix operand
725  LT A( rhs.mat_ );
726 
727  // Checking the evaluated operators
728  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.mat_.rows() , "Invalid number of rows" );
729  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.mat_.columns(), "Invalid number of columns" );
730  BLAZE_INTERNAL_ASSERT( x.size() == rhs.vec_.size() , "Invalid vector size" );
731  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).size() , "Invalid vector size" );
732 
733  // Performing the transpose sparse matrix-sparse vector multiplication
734  smpSubAssign( ~lhs, A * x );
735  }
737  //**********************************************************************************************
738 
739  //**SMP subtraction assignment to sparse vectors************************************************
740  // No special implementation for the SMP subtraction assignment to sparse vectors.
741  //**********************************************************************************************
742 
743  //**SMP multiplication assignment to dense vectors**********************************************
758  template< typename VT1 > // Type of the target dense vector
759  friend inline auto smpMultAssign( DenseVector<VT1,false>& lhs, const TSMatSVecMultExpr& rhs )
760  -> EnableIf_t< UseSMPAssign_v<VT1> >
761  {
763 
767 
768  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
769 
770  const ResultType tmp( rhs );
771  smpMultAssign( ~lhs, tmp );
772  }
774  //**********************************************************************************************
775 
776  //**SMP multiplication assignment to sparse vectors*********************************************
777  // No special implementation for the SMP multiplication assignment to sparse vectors.
778  //**********************************************************************************************
779 
780  //**Compile time checks*************************************************************************
790  //**********************************************************************************************
791 };
792 //*************************************************************************************************
793 
794 
795 
796 
797 //=================================================================================================
798 //
799 // GLOBAL BINARY ARITHMETIC OPERATORS
800 //
801 //=================================================================================================
802 
803 //*************************************************************************************************
816 template< typename MT // Type of the left-hand side sparse matrix
817  , typename VT // Type of the right-hand side sparse vector
818  , DisableIf_t< ( IsIdentity_v<MT> &&
819  IsSame_v< ElementType_t<MT>, ElementType_t<VT> > ) ||
820  ( IsZero_v<MT> || IsZero_v<VT> ) >* = nullptr >
821 inline const TSMatSVecMultExpr<MT,VT>
822  tsmatsvecmult( const SparseMatrix<MT,true>& mat, const SparseVector<VT,false>& vec )
823 {
825 
826  BLAZE_INTERNAL_ASSERT( (~mat).columns() == (~vec).size(), "Invalid matrix and vector sizes" );
827 
828  return TSMatSVecMultExpr<MT,VT>( ~mat, ~vec );
829 }
831 //*************************************************************************************************
832 
833 
834 //*************************************************************************************************
848 template< typename MT // Type of the left-hand side sparse matrix
849  , typename VT // Type of the right-hand side sparse vector
850  , EnableIf_t< ( IsIdentity_v<MT> &&
851  IsSame_v< ElementType_t<MT>, ElementType_t<VT> > ) &&
852  !IsZero_v<VT> >* = nullptr >
853 inline const VT&
854  tsmatsvecmult( const SparseMatrix<MT,true>& mat, const SparseVector<VT,false>& vec )
855 {
857 
858  UNUSED_PARAMETER( mat );
859 
860  BLAZE_INTERNAL_ASSERT( (~mat).columns() == (~vec).size(), "Invalid matrix and vector sizes" );
861 
862  return (~vec);
863 }
865 //*************************************************************************************************
866 
867 
868 //*************************************************************************************************
881 template< typename MT // Type of the left-hand side sparse matrix
882  , typename VT // Type of the right-hand side sparse vector
883  , EnableIf_t< IsZero_v<MT> || IsZero_v<VT> >* = nullptr >
884 inline decltype(auto)
885  tsmatsvecmult( const SparseMatrix<MT,true>& mat, const SparseVector<VT,false>& vec )
886 {
888 
889  UNUSED_PARAMETER( vec );
890 
891  BLAZE_INTERNAL_ASSERT( (~mat).columns() == (~vec).size(), "Invalid matrix and vector sizes" );
892 
893  using ReturnType = const MultTrait_t< ResultType_t<MT>, ResultType_t<VT> >;
894 
897 
898  return ReturnType( (~mat).rows() );
899 }
901 //*************************************************************************************************
902 
903 
904 //*************************************************************************************************
935 template< typename MT // Type of the left-hand side sparse matrix
936  , typename VT > // Type of the right-hand side sparse vector
937 inline decltype(auto)
938  operator*( const SparseMatrix<MT,true>& mat, const SparseVector<VT,false>& vec )
939 {
941 
943 
944  if( (~mat).columns() != (~vec).size() ) {
945  BLAZE_THROW_INVALID_ARGUMENT( "Matrix and vector sizes do not match" );
946  }
947 
948  return tsmatsvecmult( ~mat, ~vec );
949 }
950 //*************************************************************************************************
951 
952 } // namespace blaze
953 
954 #endif
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:329
CompositeType_t< VT > VCT
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:109
#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.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for basic type definitions.
Header file for the SparseVector base class.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
#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
Header file for the serial shim.
Header file for the IsDiagonal type trait.
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatSVecMultExpr.h:251
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition: TSMatSVecMultExpr.h:241
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: TSMatSVecMultExpr.h:231
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
Constraint on the data type.
Header file for the IsIdentity type trait.
Header file for the Computation base class.
Header file for the reset shim.
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: TSMatSVecMultExpr.h:160
Header file for the RequiresEvaluation type trait.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the implementation of an arbitrarily sized vector.
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:140
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:137
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Constraint on the transpose flag of vector types.
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: TSMatSVecMultExpr.h:218
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
MultTrait_t< MRT, VRT > ResultType
Result type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:137
constexpr bool IsResizable_v
Auxiliary variable template for the IsResizable type trait.The IsResizable_v variable template provid...
Definition: IsResizable.h:134
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Expression object for sparse matrix-sparse vector multiplications.The TSMatSVecMultExpr class represe...
Definition: Forward.h:176
Header file for the If class template.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is not a zero vector or matrix type...
Definition: Zero.h:61
#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
RightOperand vec_
Right-hand side sparse vector of the multiplication expression.
Definition: TSMatSVecMultExpr.h:303
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: TSMatSVecMultExpr.h:295
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Header file for the IsLower type trait.
#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
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: TSMatSVecMultExpr.h:139
#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:83
#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:104
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:261
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: TSMatSVecMultExpr.h:285
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatSVecMultExpr.h:143
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.The MultTrait_t alias declaration provid...
Definition: MultTrait.h:240
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: TSMatSVecMultExpr.h:273
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: TSMatSVecMultExpr.h:184
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:138
LeftOperand mat_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatSVecMultExpr.h:302
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
If_t< evaluateVector, const VRT, VCT > RT
Type for the assignment of the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:155
TSMatSVecMultExpr(const MT &mat, const VT &vec) noexcept
Constructor for the TSMatSVecMultExpr class.
Definition: TSMatSVecMultExpr.h:170
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
static constexpr bool evaluateMatrix
Compilation switch for the composite type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:114
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
Header file for the IsZero type trait.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
ResultType_t< MT > MRT
Result type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:106
If_t< IsExpression_v< MT >, const MT, const MT &> LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:146
Header file for the isDefault shim.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
Constraints on the storage order of matrix types.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
If_t< evaluateMatrix, const MRT, MCT > LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: TSMatSVecMultExpr.h:152
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
static constexpr bool evaluateVector
Compilation switch for the composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:119
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
If_t< IsExpression_v< VT >, const VT, const VT &> RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:149
Header file for the IsComputation type trait class.
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:138
Constraint on the data type.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
ResultType_t< VT > VRT
Result type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:107
Header file for the IsUpper type trait.
Header file for the MatVecMultExpr base class.
Constraint on the data type.
CompositeType_t< MT > MCT
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:108
Header file for the IsResizable type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is a zero vector or matrix type...
Definition: Zero.h:81
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#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
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:191
#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.