35#ifndef _BLAZE_MATH_EXPRESSIONS_TSMATSVECMULTEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_TSMATSVECMULTEXPR_H_
102 :
public MatVecMultExpr< SparseVector< TSMatSVecMultExpr<MT,VT>, false > >
129 template<
typename T1 >
194 return mat_(index,index) *
vec_[index];
205 const size_t n (
mat_.columns() -
begin );
224 if( index >=
mat_.rows() ) {
227 return (*
this)[index];
236 inline size_t size() const noexcept {
277 template<
typename T >
278 inline bool canAlias(
const T* alias )
const noexcept {
279 return (
mat_.isAliased( alias ) ||
vec_.isAliased( alias ) );
289 template<
typename T >
290 inline bool isAliased(
const T* alias )
const noexcept {
291 return (
mat_.isAliased( alias ) ||
vec_.isAliased( alias ) );
301 return (
size() > SMP_SMATSVECMULT_THRESHOLD );
324 template<
typename VT1 >
336 if( x.nonZeros() == 0UL )
return;
348 TSMatSVecMultExpr::selectAssignKernel( *lhs, A, x );
367 template<
typename VT1
370 static inline void selectAssignKernel( VT1& y,
const MT1& A,
const VT2& x )
372 const auto vend ( x.end() );
373 auto velem( x.begin() );
375 for( ; velem!=vend; ++velem )
377 const auto mend ( A.end ( velem->index() ) );
378 auto melem( A.begin( velem->index() ) );
380 for( ; melem!=mend; ++melem ) {
383 y[melem->index()] = melem->value() * velem->value();
385 y[melem->index()] += melem->value() * velem->value();
404 template<
typename VT1 >
405 friend inline void assign( SparseVector<VT1,false>& lhs,
const TSMatSVecMultExpr& rhs )
411 const DynamicVector<ElementType_t<VT1>,
false> tmp(
serial( rhs ) );
430 template<
typename VT1 >
431 friend inline void addAssign( DenseVector<VT1,false>& lhs,
const TSMatSVecMultExpr& rhs )
439 if( x.nonZeros() == 0UL )
return;
451 TSMatSVecMultExpr::selectAddAssignKernel( *lhs, A, x );
470 template<
typename VT1
473 static inline void selectAddAssignKernel( VT1& y,
const MT1& A,
const VT2& x )
475 const auto vend ( x.end() );
476 auto velem( x.begin() );
478 for( ; velem!=vend; ++velem )
480 const auto mend ( A.end ( velem->index() ) );
481 auto melem( A.begin( velem->index() ) );
483 for( ; melem!=mend; ++melem ) {
484 y[melem->index()] += melem->value() * velem->value();
508 template<
typename VT1 >
509 friend inline void subAssign( DenseVector<VT1,false>& lhs,
const TSMatSVecMultExpr& rhs )
517 if( x.nonZeros() == 0UL )
return;
529 TSMatSVecMultExpr::selectSubAssignKernel( *lhs, A, x );
548 template<
typename VT1
551 static inline void selectSubAssignKernel( VT1& y,
const MT1& A,
const VT2& x )
553 const auto vend ( x.end() );
554 auto velem( x.begin() );
556 for( ; velem!=vend; ++velem )
558 const auto mend ( A.end ( velem->index() ) );
559 auto melem( A.begin( velem->index() ) );
561 for( ; melem!=mend; ++melem ) {
562 y[melem->index()] -= melem->value() * velem->value();
586 template<
typename VT1 >
587 friend inline void multAssign( DenseVector<VT1,false>& lhs,
const TSMatSVecMultExpr& rhs )
598 multAssign( *lhs, tmp );
622 template<
typename VT1 >
635 if( x.nonZeros() == 0UL )
return;
671 template<
typename VT1 >
681 if( x.nonZeros() == 0UL )
return;
717 template<
typename VT1 >
727 if( x.nonZeros() == 0UL )
return;
763 template<
typename VT1 >
903 return ReturnType( (*mat).rows() );
949 if( (*mat).columns() != (*vec).size() ) {
953 return tsmatsvecmult( *mat, *vec );
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition Aliases.h:110
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition Aliases.h:550
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition Aliases.h:450
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Constraints on the storage order of matrix types.
Constraint on the transpose flag of vector types.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the IsComputation type trait class.
Header file for the isDefault shim.
Header file for the IsDiagonal type trait.
Header file for the IsExpression type trait class.
Header file for the IsIdentity type trait.
Header file for the IsLower type trait.
Header file for the IsResizable type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsUpper type trait.
Deactivation of problematic macros.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Constraint on the data type.
Base class for N-dimensional dense vectors.
Definition DenseVector.h:77
Base class for sparse matrices.
Definition SparseMatrix.h:77
Base class for sparse vectors.
Definition SparseVector.h:72
Expression object for sparse matrix-sparse vector multiplications.
Definition TSMatSVecMultExpr.h:104
const ResultType CompositeType
Data type for composite expression templates.
Definition TSMatSVecMultExpr.h:148
If_t< IsExpression_v< MT >, const MT, const MT & > LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition TSMatSVecMultExpr.h:151
static constexpr bool evaluateVector
Compilation switch for the composite type of the right-hand side sparse vector expression.
Definition TSMatSVecMultExpr.h:120
CompositeType_t< VT > VCT
Composite type of the right-hand side sparse vector expression.
Definition TSMatSVecMultExpr.h:110
LeftOperand mat_
Left-hand side sparse matrix of the multiplication expression.
Definition TSMatSVecMultExpr.h:307
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose sparse matrix operand.
Definition TSMatSVecMultExpr.h:256
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition TSMatSVecMultExpr.h:246
ElementType_t< ResultType > ElementType
Resulting element type.
Definition TSMatSVecMultExpr.h:144
static constexpr bool evaluateMatrix
Compilation switch for the composite type of the left-hand side sparse matrix expression.
Definition TSMatSVecMultExpr.h:115
TSMatSVecMultExpr< MT, VT > This
Type of this TSMatSVecMultExpr instance.
Definition TSMatSVecMultExpr.h:137
If_t< evaluateMatrix, const MRT, MCT > LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition TSMatSVecMultExpr.h:157
MatVecMultExpr< SparseVector< This, false > > BaseType
Base type of this TSMatSVecMultExpr instance.
Definition TSMatSVecMultExpr.h:140
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition TSMatSVecMultExpr.h:223
TSMatSVecMultExpr(const MT &mat, const VT &vec) noexcept
Constructor for the TSMatSVecMultExpr class.
Definition TSMatSVecMultExpr.h:175
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition TSMatSVecMultExpr.h:189
ResultType_t< VT > VRT
Result type of the right-hand side sparse vector expression.
Definition TSMatSVecMultExpr.h:108
const ElementType ReturnType
Return type for expression template evaluations.
Definition TSMatSVecMultExpr.h:145
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition TSMatSVecMultExpr.h:266
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition TSMatSVecMultExpr.h:290
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition TSMatSVecMultExpr.h:236
MultTrait_t< MRT, VRT > ResultType
Result type for expression template evaluations.
Definition TSMatSVecMultExpr.h:142
RightOperand vec_
Right-hand side sparse vector of the multiplication expression.
Definition TSMatSVecMultExpr.h:308
If_t< IsExpression_v< VT >, const VT, const VT & > RightOperand
Composite type of the right-hand side sparse vector expression.
Definition TSMatSVecMultExpr.h:154
If_t< evaluateVector, const VRT, VCT > RT
Type for the assignment of the right-hand side sparse vector operand.
Definition TSMatSVecMultExpr.h:160
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition TSMatSVecMultExpr.h:278
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition TSMatSVecMultExpr.h:300
ResultType_t< MT > MRT
Result type of the left-hand side sparse matrix expression.
Definition TSMatSVecMultExpr.h:107
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition TSMatSVecMultExpr.h:143
CompositeType_t< MT > MCT
Composite type of the left-hand side sparse matrix expression.
Definition TSMatSVecMultExpr.h:109
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition TSMatSVecMultExpr.h:165
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of an arbitrarily sized vector.
Header file for the Computation base class.
Header file for the MatVecMultExpr base class.
Header file for the SparseVector base class.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition DMatSerialExpr.h:812
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition DiagonalMatrix.h:169
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_MATMATMULTEXPR_TYPE(T)
Constraint on the data type.
Definition MatMatMultExpr.h:83
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:81
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATVECMULTEXPR(T1, T2)
Constraint on the data type.
Definition MatVecMultExpr.h:104
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition SparseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.
Definition ColumnVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition ColumnMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:61
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.
Definition MultTrait.h:165
constexpr bool RequiresEvaluation_v
Auxiliary variable template for the RequiresEvaluation type trait.
Definition RequiresEvaluation.h:91
constexpr bool IsStrictlyUpper_v
Auxiliary variable template for the IsStrictlyUpper type trait.
Definition IsStrictlyUpper.h:173
constexpr bool IsStrictlyLower_v
Auxiliary variable template for the IsStrictlyLower type trait.
Definition IsStrictlyLower.h:173
constexpr bool IsUpper_v
Auxiliary variable template for the IsUpper type trait.
Definition IsUpper.h:175
constexpr bool IsDiagonal_v
Auxiliary variable template for the IsDiagonal type trait.
Definition IsDiagonal.h:148
constexpr bool IsComputation_v
Auxiliary variable template for the IsComputation type trait.
Definition IsComputation.h:90
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.
Definition IsZero.h:166
constexpr bool IsIdentity_v
Auxiliary variable template for the IsIdentity type trait.
Definition IsIdentity.h:137
constexpr bool IsLower_v
Auxiliary variable template for the IsLower type trait.
Definition IsLower.h:175
constexpr bool IsResizable_v
Auxiliary variable template for the IsResizable type trait.
Definition IsResizable.h:136
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition Matrix.h:806
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition Matrix.h:518
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
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
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
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:192
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition DenseMatrix.h:131
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition Subvector.h:158
constexpr bool IsSame_v
Auxiliary variable template for the IsSame type trait.
Definition IsSame.h:159
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition FunctionTrace.h:94
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:175
constexpr Unchecked unchecked
Global Unchecked instance.
Definition Check.h:146
Header file for the exception macros of the math module.
Header file for all forward declarations for expression class templates.
Header file for the reset shim.
Header file for the serial shim.
Base class for all compute expression templates.
Definition Computation.h:68
Base class for all matrix/vector multiplication expression templates.
Definition MatVecMultExpr.h:69
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the IsZero type trait.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.