35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATSVECMULTEXPR_H_
88 class SMatSVecMultExpr :
public SparseVector< SMatSVecMultExpr<MT,VT>, false >
89 ,
private MatVecMultExpr
153 if(
vec_.size() == 0UL )
163 MatrixIterator melem( A.begin(index) );
164 const MatrixIterator mend( A.end(index) );
165 if( melem == mend ) {
169 VectorIterator velem( x.begin() );
170 const VectorIterator vend( x.end() );
171 if( velem == vend ) {
176 if( melem->index() < velem->index() ) {
178 if( melem == mend )
break;
180 else if( velem->index() < melem->index() ) {
182 if( velem == vend )
break;
185 res = melem->value() * velem->value();
192 if( melem != mend && velem != vend )
195 if( melem->index() < velem->index() ) {
197 if( melem == mend )
break;
199 else if( velem->index() < melem->index() ) {
201 if( velem == vend )
break;
204 res += melem->value() * velem->value();
206 if( melem == mend )
break;
208 if( velem == vend )
break;
219 MatrixIterator melem( A.begin(index) );
220 const MatrixIterator mend( A.end(index) );
225 res = melem->value() *
vec_[melem->index()];
227 for( ; melem!=mend; ++melem ) {
228 res += melem->value() *
vec_[melem->index()];
237 VectorIterator velem( x.begin() );
238 const VectorIterator vend( x.end() );
243 res =
mat_(index,velem->index()) * velem->value();
245 for( ; velem!=vend; ++velem ) {
246 res +=
mat_(index,velem->index()) * velem->value();
253 for(
size_t j=1UL; j<
vec_.size(); ++j ) {
308 template<
typename T >
310 return (
mat_.isAliased( alias ) ||
vec_.isAliased( alias ) );
320 template<
typename T >
322 return (
mat_.isAliased( alias ) ||
vec_.isAliased( alias ) );
344 template<
typename VT1 >
359 if( x.nonZeros() == 0UL )
return;
371 const VectorIterator vend( x.end() );
373 for(
size_t i=0UL; i<(~lhs).
size(); ++i )
375 const MatrixIterator mend ( A.end(i) );
376 MatrixIterator melem( A.begin(i) );
378 if( melem == mend )
continue;
380 VectorIterator velem( x.begin() );
383 if( melem->index() < velem->index() ) {
385 if( melem == mend )
break;
387 else if( velem->index() < melem->index() ) {
389 if( velem == vend )
break;
392 (~lhs)[i] = melem->value() * velem->value();
399 if( melem != mend && velem != vend )
402 if( melem->index() < velem->index() ) {
404 if( melem == mend )
break;
406 else if( velem->index() < melem->index() ) {
408 if( velem == vend )
break;
411 (~lhs)[i] += melem->value() * velem->value();
413 if( melem == mend )
break;
415 if( velem == vend )
break;
436 template<
typename VT1 >
447 if( x.nonZeros() == 0UL )
return;
457 const VectorIterator vend( x.end() );
459 for(
size_t i=0UL; i<(~lhs).
size(); ++i )
461 const MatrixIterator mend ( A.end(i) );
462 MatrixIterator melem( A.begin(i) );
464 if( melem == mend )
continue;
466 VectorIterator velem( x.begin() );
471 if( melem->index() < velem->index() ) {
473 if( melem == mend )
break;
475 else if( velem->index() < melem->index() ) {
477 if( velem == vend )
break;
480 accu = melem->value() * velem->value();
487 if( melem != mend && velem != vend )
490 if( melem->index() < velem->index() ) {
492 if( melem == mend )
break;
494 else if( velem->index() < melem->index() ) {
496 if( velem == vend )
break;
499 accu += melem->value() * velem->value();
501 if( melem == mend )
break;
503 if( velem == vend )
break;
509 (~lhs).insert( i, accu );
527 template<
typename VT1 >
539 if( x.nonZeros() == 0UL )
return;
551 const VectorIterator vend( x.end() );
553 for(
size_t i=0UL; i<(~lhs).
size(); ++i )
555 const MatrixIterator mend ( A.end(i) );
556 MatrixIterator melem( A.begin(i) );
558 if( melem == mend )
continue;
560 VectorIterator velem( x.begin() );
563 if( melem->index() < velem->index() ) {
565 if( melem == mend )
break;
567 else if( velem->index() < melem->index() ) {
569 if( velem == vend )
break;
572 (~lhs)[i] += melem->value() * velem->value();
574 if( melem == mend )
break;
576 if( velem == vend )
break;
600 template<
typename VT1 >
612 if( x.nonZeros() == 0UL )
return;
624 const VectorIterator vend( x.end() );
626 for(
size_t i=0UL; i<(~lhs).
size(); ++i )
628 const MatrixIterator mend ( A.end(i) );
629 MatrixIterator melem( A.begin(i) );
631 if( melem == mend )
continue;
633 VectorIterator velem( x.begin() );
636 if( melem->index() < velem->index() ) {
638 if( melem == mend )
break;
640 else if( velem->index() < melem->index() ) {
642 if( velem == vend )
break;
645 (~lhs)[i] -= melem->value() * velem->value();
647 if( melem == mend )
break;
649 if( velem == vend )
break;
673 template<
typename VT1 >
745 template<
typename T1
747 inline const typename DisableIf< IsMatMatMultExpr<T1>, SMatSVecMultExpr<T1,T2> >::Type
752 if( (~mat).
columns() != (~vec).size() )
753 throw std::invalid_argument(
"Matrix and vector sizes do not match" );
781 template<
typename T1
784 inline const typename EnableIf< IsMatMatMultExpr<T1>, MultExprTrait<T1,T2> >::Type::Type
789 return (~mat).leftOperand() * ( (~mat).rightOperand() * vec );
804 template<
typename MT,
typename VT >
805 struct SubvectorExprTrait< SMatSVecMultExpr<MT,VT> >
809 typedef typename MultExprTrait< typename SubmatrixExprTrait<const MT>::Type, VT >::Type Type;
RightOperand vec_
Right-hand side sparse vector of the multiplication expression.
Definition: SMatSVecMultExpr.h:329
SMatSVecMultExpr(const MT &mat, const VT &vec)
Constructor for the SMatSVecMultExpr class.
Definition: SMatSVecMultExpr.h:130
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
Header file for the SparseVector base class.
SelectType< IsComputation< VT >::value, const VRT, VCT >::Type RT
Type for the assignment of the right-hand side sparse vector operand.
Definition: SMatSVecMultExpr.h:121
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SMatSVecMultExpr.h:144
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatSVecMultExpr.h:309
MCT LT
Type for the assignment of the left-hand side sparse matrix operand.
Definition: SMatSVecMultExpr.h:118
#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
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
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
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: SMatSVecMultExpr.h:115
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatSVecMultExpr.h:109
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatSVecMultExpr.h:104
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
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.
size_t size() const
Returns the current size/dimension of the vector.
Definition: SMatSVecMultExpr.h:267
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatSVecMultExpr.h:106
Constraint on the data type.
Header file for the MultExprTrait class template.
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: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 SMatSVecMultExpr class represen...
Definition: Forward.h:96
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
Header file for the IsMatMatMultExpr type trait class.
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatSVecMultExpr.h:112
MultTrait< MRT, VRT >::Type ResultType
Result type for expression template evaluations.
Definition: SMatSVecMultExpr.h:103
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
MT::CompositeType MCT
Composite type of the left-hand side sparse matrix expression.
Definition: SMatSVecMultExpr.h:96
VT::CompositeType VCT
Composite type of the right-hand side sparse vector expression.
Definition: SMatSVecMultExpr.h:97
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.
#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
Constraints on the storage order of matrix types.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
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.
ResultType::ElementType ElementType
Resulting element type.
Definition: SMatSVecMultExpr.h:105
Header file for the EnableIf class template.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatSVecMultExpr.h:321
SMatSVecMultExpr< MT, VT > This
Type of this SMatSVecMultExpr instance.
Definition: SMatSVecMultExpr.h:102
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
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.
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
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: SMatSVecMultExpr.h:297
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.
MT::ResultType MRT
Result type of the left-hand side sparse matrix expression.
Definition: SMatSVecMultExpr.h:94
Header file for the RemoveReference type trait.
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition: SMatSVecMultExpr.h:277
Header file for the IsComputation type trait class.
VT::ResultType VRT
Result type of the right-hand side sparse vector expression.
Definition: SMatSVecMultExpr.h:95
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
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
Header file for basic type definitions.
Header file for the SubvectorExprTrait class template.
LeftOperand mat_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatSVecMultExpr.h:328
Header file for the MatVecMultExpr base class.
#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
Header file for the IsExpression type trait class.
LeftOperand leftOperand() const
Returns the left-hand side sparse matrix operand.
Definition: SMatSVecMultExpr.h:287
Header file for the FunctionTrace class.