35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATSVECMULTEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATSVECMULTEXPR_H_
104 :
public MatVecMultExpr< DenseVector< DMatSVecMultExpr<MT,VT>, false > >
122 static constexpr bool evaluateVector = ( IsComputation_v<VT> || RequiresEvaluation_v<VT> );
139 template<
typename VT2 >
140 static constexpr bool UseAssign_v =
useAssign;
150 template<
typename T1 >
151 static constexpr bool UseSMPAssign_v =
useAssign;
216 if( IsDiagonal_v<MT> )
218 return mat_(index,index) *
vec_[index];
220 else if( IsLower_v<MT> )
222 const size_t n( IsStrictlyLower_v<MT> ? index : index+1UL );
226 else if( IsUpper_v<MT> )
228 const size_t begin( IsStrictlyUpper_v<MT> ? index+1UL : index );
229 const size_t n (
mat_.columns() -
begin );
248 if( index >=
mat_.rows() ) {
251 return (*
this)[index];
260 inline size_t size() const noexcept {
291 template<
typename T >
292 inline bool canAlias(
const T* alias )
const noexcept {
293 return mat_.isAliased( alias ) ||
vec_.isAliased( alias );
303 template<
typename T >
304 inline bool isAliased(
const T* alias )
const noexcept {
305 return mat_.isAliased( alias ) ||
vec_.isAliased( alias );
315 return mat_.isAligned();
325 return (
size() > SMP_DMATSVECMULT_THRESHOLD );
351 template<
typename VT1 >
361 if( x.nonZeros() == 0UL ) {
376 assign( *lhs, A * x );
397 template<
typename VT1 >
431 template<
typename VT1 >
432 friend inline auto addAssign( DenseVector<VT1,false>& lhs,
const DMatSVecMultExpr& rhs )
433 -> EnableIf_t< UseAssign_v<VT1> >
441 if( x.nonZeros() == 0UL )
return;
453 addAssign( *lhs, A * x );
478 template<
typename VT1 >
479 friend inline auto subAssign( DenseVector<VT1,false>& lhs,
const DMatSVecMultExpr& rhs )
480 -> EnableIf_t< UseAssign_v<VT1> >
488 if( x.nonZeros() == 0UL )
return;
500 subAssign( *lhs, A * x );
525 template<
typename VT1 >
526 friend inline auto multAssign( DenseVector<VT1,false>& lhs,
const DMatSVecMultExpr& rhs )
527 -> EnableIf_t< UseAssign_v<VT1> >
538 multAssign( *lhs, tmp );
563 template<
typename VT1 >
564 friend inline auto divAssign( DenseVector<VT1,false>& lhs,
const DMatSVecMultExpr& rhs )
565 -> EnableIf_t< UseAssign_v<VT1> >
576 divAssign( *lhs, tmp );
600 template<
typename VT1 >
602 -> EnableIf_t< UseSMPAssign_v<VT1> >
610 if( x.nonZeros() == 0UL ) {
645 template<
typename VT1 >
647 -> EnableIf_t< UseSMPAssign_v<VT1> >
678 template<
typename VT1 >
680 -> EnableIf_t< UseSMPAssign_v<VT1> >
688 if( x.nonZeros() == 0UL )
return;
724 template<
typename VT1 >
726 -> EnableIf_t< UseSMPAssign_v<VT1> >
734 if( x.nonZeros() == 0UL )
return;
770 template<
typename VT1 >
772 -> EnableIf_t< UseSMPAssign_v<VT1> >
807 template<
typename VT1 >
809 -> EnableIf_t< UseSMPAssign_v<VT1> >
867 , DisableIf_t< IsSymmetric_v<MT> || IsZero_v<VT> >* =
nullptr >
868inline const DMatSVecMultExpr<MT,VT>
869 dmatsvecmult(
const DenseMatrix<MT,false>& mat,
const SparseVector<VT,false>& vec )
875 return DMatSVecMultExpr<MT,VT>( *mat, *vec );
897 , EnableIf_t< IsSymmetric_v<MT> && !IsZero_v<VT> >* =
nullptr >
899 dmatsvecmult(
const DenseMatrix<MT,false>& mat,
const SparseVector<VT,false>& vec )
905 return trans( *mat ) * (*vec);
926 , EnableIf_t< IsZero_v<VT> >* =
nullptr >
928 dmatsvecmult(
const DenseMatrix<MT,false>& mat,
const SparseVector<VT,false>& vec )
936 using ReturnType =
const MultTrait_t< ResultType_t<MT>, ResultType_t<VT> >;
941 return ReturnType( (*mat).rows() );
988 if( (*mat).columns() != (*vec).size() ) {
992 return dmatsvecmult( *mat, *vec );
1007template<
typename MT,
typename VT >
1008struct IsAligned< DMatSVecMultExpr<MT,VT> >
1009 :
public IsAligned<MT>
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
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 IsAligned type trait.
Header file for the IsComputation type trait class.
Header file for the IsDiagonal type trait.
Header file for the IsExpression type trait class.
Header file for the IsLower type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric 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 data type.
Constraint on the data type.
Expression object for dense matrix-sparse vector multiplications.
Definition: DMatSVecMultExpr.h:106
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatSVecMultExpr.h:189
If_t< useAssign, const ResultType, const DMatSVecMultExpr & > CompositeType
Data type for composite expression templates.
Definition: DMatSVecMultExpr.h:169
LeftOperand mat_
Left-hand side dense matrix of the multiplication expression.
Definition: DMatSVecMultExpr.h:331
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatSVecMultExpr.h:164
If_t< evaluateVector, const VRT, VCT > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: DMatSVecMultExpr.h:181
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatSVecMultExpr.h:270
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatSVecMultExpr.h:292
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatSVecMultExpr.h:304
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatSVecMultExpr.h:165
static constexpr bool evaluateVector
Compilation switch for the composite type of the right-hand side sparse vector expression.
Definition: DMatSVecMultExpr.h:122
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatSVecMultExpr.h:314
If_t< evaluateMatrix, const MRT, MCT > LT
Type for the assignment of the left-hand side dense matrix operand.
Definition: DMatSVecMultExpr.h:178
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatSVecMultExpr.h:186
MultTrait_t< MRT, VRT > ResultType
Result type for expression template evaluations.
Definition: DMatSVecMultExpr.h:163
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DMatSVecMultExpr.h:247
ResultType_t< VT > VRT
Result type of the right-hand side sparse vector expression.
Definition: DMatSVecMultExpr.h:110
If_t< IsExpression_v< MT >, const MT, const MT & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatSVecMultExpr.h:172
CompositeType_t< MT > MCT
Composite type of the left-hand side dense matrix expression.
Definition: DMatSVecMultExpr.h:111
RightOperand vec_
Right-hand side sparse vector of the multiplication expression.
Definition: DMatSVecMultExpr.h:332
ResultType_t< MT > MRT
Result type of the left-hand side dense matrix expression.
Definition: DMatSVecMultExpr.h:109
DMatSVecMultExpr(const MT &mat, const VT &vec) noexcept
Constructor for the DMatSVecMultExpr class.
Definition: DMatSVecMultExpr.h:199
const ElementType ReturnType
Return type for expression template evaluations.
Definition: DMatSVecMultExpr.h:166
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: DMatSVecMultExpr.h:280
static constexpr bool evaluateMatrix
Compilation switch for the composite type of the left-hand side dense matrix expression.
Definition: DMatSVecMultExpr.h:117
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DMatSVecMultExpr.h:213
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatSVecMultExpr.h:324
static constexpr bool useAssign
Compilation switch for the evaluation strategy of the multiplication expression.
Definition: DMatSVecMultExpr.h:133
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DMatSVecMultExpr.h:260
If_t< IsExpression_v< VT >, const VT, const VT & > RightOperand
Composite type of the right-hand side dense vector expression.
Definition: DMatSVecMultExpr.h:175
CompositeType_t< VT > VCT
Composite type of the right-hand side sparse vector expression.
Definition: DMatSVecMultExpr.h:112
Base class for dense matrices.
Definition: DenseMatrix.h:82
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Base class for sparse vectors.
Definition: SparseVector.h:72
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.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the DenseVector base class.
Header file for the MatMatMultExpr base class.
Header file for the MatVecMultExpr base class.
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#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_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_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#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_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.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_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 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 smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:221
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
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#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
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.