35#ifndef _BLAZE_MATH_EXPRESSIONS_TSVECSMATMULTEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_TSVECSMATMULTEXPR_H_
102 :
public TVecMatMultExpr< SparseVector< TSVecSMatMultExpr<VT,MT>, true > >
129 template<
typename T1 >
192 return vec_[index] *
mat_(index,index);
222 if( index >=
mat_.columns() ) {
225 return (*
this)[index];
234 inline size_t size() const noexcept {
235 return mat_.columns();
245 return mat_.columns();
275 template<
typename T >
276 inline bool canAlias(
const T* alias )
const noexcept {
277 return (
vec_.isAliased( alias ) ||
mat_.isAliased( alias ) );
287 template<
typename T >
288 inline bool isAliased(
const T* alias )
const noexcept {
289 return (
vec_.isAliased( alias ) ||
mat_.isAliased( alias ) );
299 return (
size() > SMP_TSVECSMATMULT_THRESHOLD );
322 template<
typename VT1 >
334 if( x.nonZeros() == 0UL )
return;
346 TSVecSMatMultExpr::selectAssignKernel( *lhs, x, A );
365 template<
typename VT1
368 static inline void selectAssignKernel( VT1& y,
const VT2& x,
const MT1& A )
370 const auto vend( x.end() );
371 auto velem( x.begin() );
373 for( ; velem!=vend; ++velem )
375 const auto mend( A.end( velem->index() ) );
376 auto melem( A.begin( velem->index() ) );
378 for( ; melem!=mend; ++melem ) {
381 y[melem->index()] = velem->value() * melem->value();
383 y[melem->index()] += velem->value() * melem->value();
402 template<
typename VT1 >
403 friend inline void assign( SparseVector<VT1,true>& lhs,
const TSVecSMatMultExpr& rhs )
409 const DynamicVector<ElementType_t<VT1>,
true> tmp(
serial( rhs ) );
428 template<
typename VT1 >
429 friend inline void addAssign( DenseVector<VT1,true>& lhs,
const TSVecSMatMultExpr& rhs )
437 if( x.nonZeros() == 0UL )
return;
449 TSVecSMatMultExpr::selectAddAssignKernel( *lhs, x, A );
468 template<
typename VT1
471 static inline void selectAddAssignKernel( VT1& y,
const VT2& x,
const MT1& A )
473 const auto vend( x.end() );
474 auto velem( x.begin() );
476 for( ; velem!=vend; ++velem )
478 const auto mend( A.end( velem->index() ) );
479 auto melem( A.begin( velem->index() ) );
481 for( ; melem!=mend; ++melem ) {
482 y[melem->index()] += velem->value() * melem->value();
506 template<
typename VT1 >
507 friend inline void subAssign( DenseVector<VT1,true>& lhs,
const TSVecSMatMultExpr& rhs )
515 if( x.nonZeros() == 0UL )
return;
527 TSVecSMatMultExpr::selectSubAssignKernel( *lhs, x, A );
546 template<
typename VT1
549 static inline void selectSubAssignKernel( VT1& y,
const VT2& x,
const MT1& A )
551 const auto vend( x.end() );
552 auto velem( x.begin() );
554 for( ; velem!=vend; ++velem )
556 const auto mend( A.end( velem->index() ) );
557 auto melem( A.begin( velem->index() ) );
559 for( ; melem!=mend; ++melem ) {
560 y[melem->index()] -= velem->value() * melem->value();
584 template<
typename VT1 >
585 friend inline void multAssign( DenseVector<VT1,true>& lhs,
const TSVecSMatMultExpr& rhs )
596 multAssign( *lhs, tmp );
620 template<
typename VT1 >
633 if( x.nonZeros() == 0UL )
return;
669 template<
typename VT1 >
679 if( x.nonZeros() == 0UL )
return;
715 template<
typename VT1 >
725 if( x.nonZeros() == 0UL )
return;
761 template<
typename VT1 >
902 return ReturnType( (*mat).columns() );
948 if( (*vec).size() != (*mat).rows() ) {
952 return tsvecsmatmult( *vec, *mat );
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.
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.
Constraints on the storage order of matrix types.
Constraint on the transpose flag of vector types.
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 vector-sparse matrix multiplications.
Definition TSVecSMatMultExpr.h:104
ResultType_t< MT > MRT
Result type of the right-hand side sparse matrix expression.
Definition TSVecSMatMultExpr.h:108
static constexpr bool evaluateMatrix
Compilation switch for the composite type of the right-hand side sparse matrix expression.
Definition TSVecSMatMultExpr.h:120
TSVecSMatMultExpr(const VT &vec, const MT &mat) noexcept
Constructor for the TSVecSMatMultExpr class.
Definition TSVecSMatMultExpr.h:173
static constexpr bool evaluateVector
Compilation switch for the composite type of the left-hand side sparse vector expression.
Definition TSVecSMatMultExpr.h:115
If_t< IsExpression_v< VT >, const VT, const VT & > LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition TSVecSMatMultExpr.h:149
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition TSVecSMatMultExpr.h:163
ElementType_t< ResultType > ElementType
Resulting element type.
Definition TSVecSMatMultExpr.h:144
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition TSVecSMatMultExpr.h:221
If_t< IsExpression_v< MT >, const MT, const MT & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition TSVecSMatMultExpr.h:152
RightOperand mat_
Right-hand side sparse matrix of the multiplication expression.
Definition TSVecSMatMultExpr.h:306
const ResultType CompositeType
Data type for composite expression templates.
Definition TSVecSMatMultExpr.h:146
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition TSVecSMatMultExpr.h:276
CompositeType_t< MT > MCT
Composite type of the right-hand side sparse matrix expression.
Definition TSVecSMatMultExpr.h:110
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition TSVecSMatMultExpr.h:234
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition TSVecSMatMultExpr.h:298
If_t< evaluateVector, const VRT, VCT > LT
Type for the assignment of the left-hand side sparse vector operand.
Definition TSVecSMatMultExpr.h:155
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition TSVecSMatMultExpr.h:143
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition TSVecSMatMultExpr.h:254
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition TSVecSMatMultExpr.h:288
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition TSVecSMatMultExpr.h:244
TVecMatMultExpr< SparseVector< This, true > > BaseType
Base type of this TSVecSMatMultExpr instance.
Definition TSVecSMatMultExpr.h:140
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition TSVecSMatMultExpr.h:187
MultTrait_t< VRT, MRT > ResultType
Result type for expression template evaluations.
Definition TSVecSMatMultExpr.h:142
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse matrix operand.
Definition TSVecSMatMultExpr.h:264
TSVecSMatMultExpr< VT, MT > This
Type of this TSVecSMatMultExpr instance.
Definition TSVecSMatMultExpr.h:137
const ElementType ReturnType
Return type for expression template evaluations.
Definition TSVecSMatMultExpr.h:145
CompositeType_t< VT > VCT
Composite type of the left-hand side sparse vector expression.
Definition TSVecSMatMultExpr.h:109
If_t< evaluateMatrix, const MRT, MCT > RT
Type for the assignment of the right-hand side sparse matrix operand.
Definition TSVecSMatMultExpr.h:158
LeftOperand vec_
Left-hand side sparse vector of the multiplication expression.
Definition TSVecSMatMultExpr.h:305
ResultType_t< VT > VRT
Result type of the left-hand side sparse vector expression.
Definition TSVecSMatMultExpr.h:107
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 SparseVector base class.
Header file for the TVecMatMultExpr base class.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition Column.h:137
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_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition RowMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_TVECMATMULTEXPR(T1, T2)
Constraint on the data type.
Definition TVecMatMultExpr.h:104
#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_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_ROW_VECTOR_TYPE(T)
Constraint on the data type.
Definition RowVector.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
#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 vector/matrix multiplication expression templates.
Definition TVecMatMultExpr.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.