35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSVECTSMATMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSVECTSMATMULTEXPR_H_
85 class TSVecTSMatMultExpr :
public SparseVector< TSVecTSMatMultExpr<VT,MT>, true >
86 ,
private TVecMatMultExpr
154 VectorIterator velem( x.begin() );
155 const VectorIterator vend( x.end() );
156 if( velem == vend ) {
161 MatrixIterator melem( A.begin(index) );
162 const MatrixIterator mend( A.end(index) );
163 if( melem == mend ) {
169 if( velem->index() < melem->index() ) {
171 if( velem == vend )
break;
173 else if( melem->index() < velem->index() ) {
175 if( melem == mend )
break;
178 res = velem->value() * melem->value();
185 if( melem != mend && velem != vend )
188 if( velem->index() < melem->index() ) {
190 if( velem == vend )
break;
192 else if( melem->index() < velem->index() ) {
194 if( melem == mend )
break;
197 res += velem->value() * melem->value();
199 if( velem == vend )
break;
201 if( melem == mend )
break;
216 return mat_.columns();
226 return mat_.columns();
256 template<
typename T >
258 return (
vec_.isAliased( alias ) ||
mat_.isAliased( alias ) );
268 template<
typename T >
270 return (
vec_.isAliased( alias ) ||
mat_.isAliased( alias ) );
293 template<
typename VT1 >
308 if( x.nonZeros() == 0UL )
return;
320 const VectorIterator vend( x.end() );
322 for(
size_t j=0UL; j<A.columns(); ++j )
324 const MatrixIterator mend ( A.end(j) );
325 MatrixIterator melem( A.begin(j) );
327 if( melem == mend )
continue;
329 VectorIterator velem( x.begin() );
332 if( velem->index() < melem->index() ) {
334 if( velem == vend )
break;
336 else if( melem->index() < velem->index() ) {
338 if( melem == mend )
break;
341 (~lhs)[j] = velem->value() * melem->value();
348 if( velem != vend && melem != mend )
351 if( velem->index() < melem->index() ) {
353 if( velem == vend )
break;
355 else if( melem->index() < velem->index() ) {
357 if( melem == mend )
break;
360 (~lhs)[j] += velem->value() * melem->value();
362 if( velem == vend )
break;
364 if( melem == mend )
break;
386 template<
typename VT1 >
398 if( x.nonZeros() == 0UL )
return;
411 const VectorIterator vend( x.end() );
413 for(
size_t j=0UL; j<A.columns(); ++j )
415 const MatrixIterator mend ( A.end(j) );
416 MatrixIterator melem( A.begin(j) );
418 if( melem == mend )
continue;
420 VectorIterator velem( x.begin() );
425 if( velem->index() < melem->index() ) {
427 if( velem == vend )
break;
429 else if( melem->index() < velem->index() ) {
431 if( melem == mend )
break;
434 accu = velem->value() * melem->value();
441 if( velem != vend && melem != mend )
444 if( velem->index() < melem->index() ) {
446 if( velem == vend )
break;
448 else if( melem->index() < velem->index() ) {
450 if( melem == mend )
break;
453 accu += velem->value() * melem->value();
455 if( velem == vend )
break;
457 if( melem == mend )
break;
463 (~lhs).insert( j, accu );
482 template<
typename VT1 >
494 if( x.nonZeros() == 0UL )
return;
506 const VectorIterator vend( x.end() );
508 for(
size_t j=0UL; j<A.columns(); ++j )
510 const MatrixIterator mend ( A.end(j) );
511 MatrixIterator melem( A.begin(j) );
513 if( melem == mend )
continue;
515 VectorIterator velem( x.begin() );
518 if( velem->index() < melem->index() ) {
520 if( velem == vend )
break;
522 else if( melem->index() < velem->index() ) {
524 if( melem == mend )
break;
527 (~lhs)[j] += velem->value() * melem->value();
529 if( velem == vend )
break;
531 if( melem == mend )
break;
556 template<
typename VT1 >
568 if( x.nonZeros() == 0UL )
return;
580 const VectorIterator vend( x.end() );
582 for(
size_t j=0UL; j<A.columns(); ++j )
584 const MatrixIterator mend ( A.end(j) );
585 MatrixIterator melem( A.begin(j) );
587 if( melem == mend )
continue;
589 VectorIterator velem( x.begin() );
592 if( velem->index() < melem->index() ) {
594 if( velem == vend )
break;
596 else if( melem->index() < velem->index() ) {
598 if( melem == mend )
break;
601 (~lhs)[j] -= velem->value() * melem->value();
603 if( velem == vend )
break;
605 if( melem == mend )
break;
630 template<
typename VT1 >
702 template<
typename T1
704 inline const typename DisableIf< IsMatMatMultExpr<T2>, TSVecTSMatMultExpr<T1,T2> >::Type
709 if( (~vec).size() != (~mat).
rows() )
710 throw std::invalid_argument(
"Vector and matrix sizes do not match" );
727 template<
typename VT,
typename MT >
728 struct SubvectorExprTrait< TSVecTSMatMultExpr<VT,MT> >
732 typedef typename MultExprTrait< VT, typename SubmatrixExprTrait<const MT>::Type >::Type Type;
SelectType< IsComputation< VT >::value, const VRT, VCT >::Type LT
Type for the assignment of the left-hand side sparse vector operand.
Definition: TSVecTSMatMultExpr.h:113
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 size() const
Returns the current size/dimension of the vector.
Definition: TSVecTSMatMultExpr.h:215
Header file for the SparseVector base class.
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
Header file for the Computation base class.
TSVecTSMatMultExpr< VT, MT > This
Type of this TSVecTSMatMultExpr instance.
Definition: TSVecTSMatMultExpr.h:99
Header file for the RequiresEvaluation type trait.
MT::CompositeType MCT
Composite type of the right-hand side sparse matrix expression.
Definition: TSVecTSMatMultExpr.h:94
LeftOperand leftOperand() const
Returns the left-hand side sparse vector operand.
Definition: TSVecTSMatMultExpr.h:235
TSVecTSMatMultExpr(const VT &vec, const MT &mat)
Constructor for the TSVecTSMatMultExpr class.
Definition: TSVecTSMatMultExpr.h:125
LeftOperand vec_
Left-hand side sparse vector of the multiplication expression.
Definition: TSVecTSMatMultExpr.h:276
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.
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.
MCT RT
Type for the assignment of the right-hand side sparse matrix operand.
Definition: TSVecTSMatMultExpr.h:116
#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
Expression object for sparse vector-sparse matrix multiplications.The TSVecTSMatMultExpr class repres...
Definition: Forward.h:146
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
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
size_t nonZeros() const
Returns an estimation for the number of non-zero elements in the sparse vector.
Definition: TSVecTSMatMultExpr.h:225
Constraints on the storage order of matrix types.
MultTrait< VRT, MRT >::Type ResultType
Result type for expression template evaluations.
Definition: TSVecTSMatMultExpr.h:100
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.
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: TSVecTSMatMultExpr.h:110
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSVecTSMatMultExpr.h:104
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: TSVecTSMatMultExpr.h:101
MT::ResultType MRT
Result type of the right-hand side sparse matrix expression.
Definition: TSVecTSMatMultExpr.h:92
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
VT::CompositeType VCT
Composite type of the left-hand side sparse vector expression.
Definition: TSVecTSMatMultExpr.h:93
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
ResultType::ElementType ElementType
Resulting element type.
Definition: TSVecTSMatMultExpr.h:102
Header file for the isDefault shim.
Header file for the TVecMatMultExpr base class.
Header file for the RemoveReference type trait.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TSVecTSMatMultExpr.h:269
Header file for the IsComputation type trait class.
RightOperand mat_
Right-hand side sparse matrix of the multiplication expression.
Definition: TSVecTSMatMultExpr.h:277
VT::ResultType VRT
Result type of the left-hand side sparse vector expression.
Definition: TSVecTSMatMultExpr.h:91
const ElementType ReturnType
Return type for expression template evaluations.
Definition: TSVecTSMatMultExpr.h:103
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: TSVecTSMatMultExpr.h:139
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
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: TSVecTSMatMultExpr.h:107
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TSVecTSMatMultExpr.h:257
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: TransposeFlag.h:81
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:138
#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.
Header file for the FunctionTrace class.
RightOperand rightOperand() const
Returns the right-hand side transpose sparse matrix operand.
Definition: TSVecTSMatMultExpr.h:245