35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSMATSVECMULTEXPR_H_
90 class TSMatSVecMultExpr :
public SparseVector< TSMatSVecMultExpr<MT,VT>, false >
91 ,
private MatVecMultExpr
118 template<
typename T1 >
119 struct UseSMPAssign {
120 enum { value = ( evaluateMatrix || evaluateVector ) };
151 enum { smpAssignable = !evaluateMatrix && MT::smpAssignable &&
152 !evaluateVector && VT::smpAssignable };
190 const VectorIterator vend( x.end() );
191 VectorIterator velem( x.begin() );
193 if(
vec_.size() > 0UL && velem != vend ) {
194 res = A( index, velem->index() ) * velem->value();
196 for( ; velem!=vend; ++velem )
197 res += A( index, velem->index() ) * velem->value();
253 template<
typename T >
255 return (
mat_.isAliased( alias ) ||
vec_.isAliased( alias ) );
265 template<
typename T >
267 return (
mat_.isAliased( alias ) ||
vec_.isAliased( alias ) );
300 template<
typename VT1 >
312 if( x.nonZeros() == 0UL )
return;
324 TSMatSVecMultExpr::selectAssignKernel( ~lhs, A, x );
343 template<
typename VT1
346 static inline void selectAssignKernel( VT1& y,
const MT1& A,
const VT2& x )
351 const VectorIterator vend ( x.end() );
352 VectorIterator velem( x.begin() );
354 for( ; velem!=vend; ++velem )
356 const MatrixIterator mend ( A.end ( velem->index() ) );
357 MatrixIterator melem( A.begin( velem->index() ) );
359 for( ; melem!=mend; ++melem ) {
362 y[melem->index()] = melem->value() * velem->value();
364 y[melem->index()] += melem->value() * velem->value();
383 template<
typename VT1 >
394 if( x.nonZeros() == 0UL )
return;
403 DynamicVector<ElementType> tmp( (~lhs).
size() );
404 std::vector<bool> indices( (~lhs).
size(),
false );
405 size_t nonzeros( 0UL );
407 const VectorIterator vend ( x.end() );
408 VectorIterator velem( x.begin() );
410 for( ; velem!=vend; ++velem )
412 const MatrixIterator mend ( A.end( velem->index() ) );
413 MatrixIterator melem( A.begin( velem->index() ) );
415 for( ; melem!=mend; ++melem ) {
416 if( !indices[melem->index()] ) {
417 indices[melem->index()] =
true;
419 tmp[melem->index()] = melem->value() * velem->value();
422 tmp[melem->index()] += melem->value() * velem->value();
427 (~lhs).reserve( nonzeros );
429 for(
size_t i=0UL; i<(~lhs).
size(); ++i ) {
431 (~lhs).append( i, tmp[i] );
451 template<
typename VT1 >
460 if( x.nonZeros() == 0UL )
return;
472 TSMatSVecMultExpr::selectAddAssignKernel( ~lhs, A, x );
491 template<
typename VT1
494 static inline void selectAddAssignKernel( VT1& y,
const MT1& A,
const VT2& x )
499 const VectorIterator vend ( x.end() );
500 VectorIterator velem( x.begin() );
502 for( ; velem!=vend; ++velem )
504 const MatrixIterator mend ( A.end ( velem->index() ) );
505 MatrixIterator melem( A.begin( velem->index() ) );
507 for( ; melem!=mend; ++melem ) {
508 y[melem->index()] += melem->value() * velem->value();
532 template<
typename VT1 >
541 if( x.nonZeros() == 0UL )
return;
553 TSMatSVecMultExpr::selectSubAssignKernel( ~lhs, A, x );
572 template<
typename VT1
575 static inline void selectSubAssignKernel( VT1& y,
const MT1& A,
const VT2& x )
580 const VectorIterator vend ( x.end() );
581 VectorIterator velem( x.begin() );
583 for( ; velem!=vend; ++velem )
585 const MatrixIterator mend ( A.end ( velem->index() ) );
586 MatrixIterator melem( A.begin( velem->index() ) );
588 for( ; melem!=mend; ++melem ) {
589 y[melem->index()] -= melem->value() * velem->value();
613 template<
typename VT1 >
649 template<
typename VT1 >
650 friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
662 if( x.nonZeros() == 0UL )
return;
698 template<
typename VT1 >
699 friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
708 if( x.nonZeros() == 0UL )
return;
744 template<
typename VT1 >
745 friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
754 if( x.nonZeros() == 0UL )
return;
790 template<
typename VT1 >
791 friend inline typename EnableIf< UseSMPAssign<VT1> >::Type
863 template<
typename T1
865 inline const typename DisableIf< IsMatMatMultExpr<T1>, TSMatSVecMultExpr<T1,T2> >::Type
871 throw std::invalid_argument(
"Matrix and vector sizes do not match" );
888 template<
typename MT,
typename VT,
bool AF >
893 typedef typename MultExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type, VT >::Type Type;
VT::CompositeType VCT
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:99
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
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
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:4329
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition: TSMatSVecMultExpr.h:222
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:137
void smpSubAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:152
#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:134
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
void smpMultAssign(DenseVector< 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:179
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TSMatSVecMultExpr.h:266
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2408
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:251
size_t size() const
Returns the current size/dimension of the vector.
Definition: TSMatSVecMultExpr.h:212
SelectType< evaluateVector, const VRT, VCT >::Type RT
Type for the assignment of the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:146
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:690
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:143
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:140
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:96
Constraint on the data type.
void smpAddAssign(DenseMatrix< 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:122
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:253
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:2412
Header file for the IsMatMatMultExpr type trait class.
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:271
ResultType::ElementType ElementType
Resulting element type.
Definition: TSMatSVecMultExpr.h:130
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:232
#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:127
LeftOperand mat_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatSVecMultExpr.h:283
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TSMatSVecMultExpr.h:254
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:361
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 complete DynamicVector implementation.
Header file for the EnableIf class template.
Header file for the serial shim.
void smpAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:92
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
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:284
Base template for the MultTrait class.
Definition: MultTrait.h:141
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:301
Header file for the reset shim.
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:331
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:175
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: TSMatSVecMultExpr.h:276
Header file for the RemoveReference type trait.
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:131
VT::ResultType VRT
Result type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:97
Header file for the IsComputation type trait class.
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:2403
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:129
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:170
MultTrait< MRT, VRT >::Type ResultType
Result type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:128
Header file for basic type definitions.
TSMatSVecMultExpr(const MT &mat, const VT &vec)
Constructor for the TSMatSVecMultExpr class.
Definition: TSMatSVecMultExpr.h:161
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:242
Header file for the MatVecMultExpr base class.
Header file for the IsResizable 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:98
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.