35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSMATSVECMULTEXPR_H_
88 class TSMatSVecMultExpr :
public SparseVector< TSMatSVecMultExpr<MT,VT>, false >
89 ,
private MatVecMultExpr
159 const VectorIterator vend( x.end() );
160 VectorIterator velem( x.begin() );
162 if(
vec_.size() > 0UL && velem != vend ) {
163 res = A( index, velem->index() ) * velem->value();
165 for( ; velem!=vend; ++velem )
166 res += A( index, velem->index() ) * velem->value();
222 template<
typename T >
224 return (
mat_.isAliased( alias ) ||
vec_.isAliased( alias ) );
234 template<
typename T >
236 return (
mat_.isAliased( alias ) ||
vec_.isAliased( alias ) );
260 template<
typename VT1 >
276 if( x.nonZeros() == 0UL )
return;
288 const VectorIterator vend ( x.end() );
289 VectorIterator velem( x.begin() );
291 for( ; velem!=vend; ++velem )
293 const MatrixIterator mend ( A.end( velem->index() ) );
294 MatrixIterator melem( A.begin( velem->index() ) );
296 for( ; melem!=mend; ++melem ) {
297 if(
isDefault( (~lhs)[melem->index()] ) )
298 (~lhs)[melem->index()] = melem->value() * velem->value();
300 (~lhs)[melem->index()] += melem->value() * velem->value();
321 template<
typename VT1 >
337 if( x.nonZeros() == 0UL )
return;
349 const VectorIterator vend ( x.end() );
350 VectorIterator velem( x.begin() );
352 for( ; velem!=vend; ++velem )
354 const MatrixIterator mend ( A.end( velem->index() ) );
355 MatrixIterator melem( A.begin( velem->index() ) );
357 for( ; melem!=mend; ++melem ) {
358 (~lhs)[melem->index()] += melem->value() * velem->value();
377 template<
typename VT1 >
388 if( x.nonZeros() == 0UL )
return;
397 DynamicVector<ElementType> tmp( (~lhs).
size() );
398 std::vector<bool> indices( (~lhs).
size(),
false );
399 size_t nonzeros( 0UL );
401 const VectorIterator vend ( x.end() );
402 VectorIterator velem( x.begin() );
404 for( ; velem!=vend; ++velem )
406 const MatrixIterator mend ( A.end( velem->index() ) );
407 MatrixIterator melem( A.begin( velem->index() ) );
409 for( ; melem!=mend; ++melem ) {
410 if( !indices[melem->index()] ) {
411 indices[melem->index()] =
true;
413 tmp[melem->index()] = melem->value() * velem->value();
416 tmp[melem->index()] += melem->value() * velem->value();
421 (~lhs).reserve( nonzeros );
423 for(
size_t i=0UL; i<(~lhs).
size(); ++i ) {
425 (~lhs).append( i, tmp[i] );
445 template<
typename VT1 >
457 if( x.nonZeros() == 0UL )
return;
469 const VectorIterator vend ( x.end() );
470 VectorIterator velem( x.begin() );
472 for( ; velem!=vend; ++velem )
474 const MatrixIterator mend ( A.end( velem->index() ) );
475 MatrixIterator melem( A.begin( velem->index() ) );
477 for( ; melem!=mend; ++melem ) {
478 (~lhs)[melem->index()] += melem->value() * velem->value();
502 template<
typename VT1 >
514 if( x.nonZeros() == 0UL )
return;
526 const VectorIterator vend ( x.end() );
527 VectorIterator velem( x.begin() );
529 for( ; velem!=vend; ++velem )
531 const MatrixIterator mend ( A.end( velem->index() ) );
532 MatrixIterator melem( A.begin( velem->index() ) );
534 for( ; melem!=mend; ++melem ) {
535 (~lhs)[melem->index()] -= melem->value() * velem->value();
559 template<
typename VT1 >
631 template<
typename T1
633 inline const typename DisableIf< IsMatMatMultExpr<T1>, TSMatSVecMultExpr<T1,T2> >::Type
638 if( (~mat).
columns() != (~vec).size() )
639 throw std::invalid_argument(
"Matrix and vector sizes do not match" );
656 template<
typename MT,
typename VT >
657 struct SubvectorExprTrait< TSMatSVecMultExpr<MT,VT> >
661 typedef typename MultExprTrait< typename SubmatrixExprTrait<const MT>::Type, VT >::Type Type;
VT::CompositeType VCT
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:97
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
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:3703
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition: TSMatSVecMultExpr.h:191
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:112
#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:109
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TSMatSVecMultExpr.h:235
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2375
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:248
size_t size() const
Returns the current size/dimension of the vector.
Definition: TSMatSVecMultExpr.h:181
Header file for the Computation base class.
MCT LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: TSMatSVecMultExpr.h:118
Header file for the RequiresEvaluation type trait.
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:115
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:104
Constraint on the data type.
MT::ResultType MRT
Result type of the left-hand side sparse matrix expression.
Definition: TSMatSVecMultExpr.h:94
Constraint on the data type.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:250
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:138
#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:2379
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:179
ResultType::ElementType ElementType
Resulting element type.
Definition: TSMatSVecMultExpr.h:105
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.
SelectType< IsComputation< VT >::value, const VRT, VCT >::Type RT
Type for the assignment of the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:121
LeftOperand leftOperand() const
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatSVecMultExpr.h:201
#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:102
LeftOperand mat_
Left-hand side sparse matrix of the multiplication expression.
Definition: TSMatSVecMultExpr.h:242
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TSMatSVecMultExpr.h:223
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:269
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.
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:243
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:209
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
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:239
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:144
Header file for the RemoveReference type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:106
VT::ResultType VRT
Result type of the right-hand side sparse vector expression.
Definition: TSMatSVecMultExpr.h:95
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:105
#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:2370
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:104
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
MultTrait< MRT, VRT >::Type ResultType
Result type for expression template evaluations.
Definition: TSMatSVecMultExpr.h:103
Header file for basic type definitions.
TSMatSVecMultExpr(const MT &mat, const VT &vec)
Constructor for the TSMatSVecMultExpr class.
Definition: TSMatSVecMultExpr.h:130
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: TSMatSVecMultExpr.h:211
Header file for the MatVecMultExpr base class.
Header file for the IsResizable type trait.
#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:96
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.