35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECSVECMULTEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SVECSVECMULTEXPR_H_ 84 template<
typename VT1
87 class SVecSVecMultExpr
88 :
public VecVecMultExpr< SparseVector< SVecSVecMultExpr<VT1,VT2,TF>, TF > >
136 enum :
bool { smpAssignable =
false };
170 if( index >=
lhs_.size() ) {
173 return (*
this)[index];
182 inline size_t size() const noexcept {
223 template<
typename T >
224 inline bool canAlias(
const T* alias )
const noexcept {
225 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
235 template<
typename T >
236 inline bool isAliased(
const T* alias )
const noexcept {
237 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
259 template<
typename VT >
276 const LeftIterator lend( x.end() );
277 const RightIterator rend( y.end() );
279 LeftIterator l( x.begin() );
280 RightIterator r( y.begin() );
282 for( ; l!=lend; ++l ) {
283 while( r!=rend && r->index() < l->index() ) ++r;
285 if( l->index() == r->index() ) {
286 (~lhs)[l->index()] = l->value() * r->value();
306 template<
typename VT >
324 (~lhs).reserve(
min( x.nonZeros(), y.nonZeros() ) );
327 const LeftIterator lend( x.end() );
328 const RightIterator rend( y.end() );
330 LeftIterator l( x.begin() );
331 RightIterator r( y.begin() );
333 for( ; l!=lend; ++l ) {
334 while( r!=rend && r->index() < l->index() ) ++r;
336 if( l->index() == r->index() ) {
337 (~lhs).append( l->index(), l->value() * r->value() );
357 template<
typename VT >
374 const LeftIterator lend( x.end() );
375 const RightIterator rend( y.end() );
377 LeftIterator l( x.begin() );
378 RightIterator r( y.begin() );
380 for( ; l!=lend; ++l ) {
381 while( r!=rend && r->index() < l->index() ) ++r;
383 if( l->index() == r->index() ) {
384 (~lhs)[l->index()] += l->value() * r->value();
408 template<
typename VT >
425 const LeftIterator lend( x.end() );
426 const RightIterator rend( y.end() );
428 LeftIterator l( x.begin() );
429 RightIterator r( y.begin() );
431 for( ; l!=lend; ++l ) {
432 while( r!=rend && r->index() < l->index() ) ++r;
434 if( l->index() == r->index() ) {
435 (~lhs)[l->index()] -= l->value() * r->value();
459 template<
typename VT >
476 const LeftIterator lend( x.end() );
477 const RightIterator rend( y.end() );
479 LeftIterator l( x.begin() );
480 RightIterator r( y.begin() );
484 for( ; l!=lend; ++l ) {
485 while( r!=rend && r->index() < l->index() ) ++r;
487 if( l->index() == r->index() ) {
488 for( ; i<r->index(); ++i )
490 (~lhs)[l->index()] *= l->value() * r->value();
496 for( ; i<rhs.size(); ++i )
514 template<
typename VT >
532 VT tmp( rhs.size(), rhs.nonZeros() );
534 const Iterator1 end1( (~lhs).
end() );
535 const Iterator2 end2( x.end() );
536 const Iterator3 end3( y.end() );
538 Iterator1 i1( (~lhs).
begin() );
539 Iterator2 i2( x.begin() );
540 Iterator3 i3( y.begin() );
542 for( ; i1!=end1; ++i1 ) {
543 while( i2!=end2 && i2->index() < i1->index() ) ++i2;
544 if( i2==end2 )
break;
545 while( i3!=end3 && i3->index() < i1->index() ) ++i3;
546 if( i3==end3 )
break;
547 if( i1->index() == i2->index() && i1->index() == i3->index() ) {
548 tmp.append( i1->index(), i1->value() * i2->value() * i3->value() );
605 template<
typename VT1
608 inline decltype(
auto)
613 if( (~lhs).
size() != (~rhs).
size() ) {
633 template<
typename VT1,
typename VT2,
bool TF >
634 struct Size< SVecSVecMultExpr<VT1,VT2,TF>, 0UL >
635 :
public Maximum< Size<VT1,0UL>, Size<VT2,0UL> >
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
SVecSVecMultExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the SVecSVecMultExpr class.
Definition: SVecSVecMultExpr.h:142
Header file for auxiliary alias declarations.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecSVecMultExpr.h:118
Headerfile for the generic min algorithm.
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:69
Header file for basic type definitions.
Header file for the SparseVector base class.
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SVecSVecMultExpr.h:117
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SVecSVecMultExpr.h:119
Header file for the serial shim.
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SVecSVecMultExpr.h:169
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecSVecMultExpr.h:192
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
CompositeType_< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition: SVecSVecMultExpr.h:98
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecSVecMultExpr.h:224
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
If_< IsExpression< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: SVecSVecMultExpr.h:131
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: SVecSVecMultExpr.h:212
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
Compile time value evaluation.The Maximum alias declaration selects the larger of the two given templ...
Definition: Maximum.h:73
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Header file for the Computation base class.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecSVecMultExpr.h:156
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
CompositeType_< VT1 > CT1
Composite type of the left-hand side sparse vector expression.
Definition: SVecSVecMultExpr.h:97
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
Header file for the Maximum class template.
typename MultExprTrait< T1, T2 >::Type MultExprTrait_
Auxiliary alias declaration for the MultExprTrait class template.The MultExprTrait_ alias declaration...
Definition: MultExprTrait.h:112
Header file for the MultExprTrait class template.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SVecSVecMultExpr.h:182
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
const ResultType CompositeType
Data type for composite expression templates.
Definition: SVecSVecMultExpr.h:125
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
MultExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: SVecSVecMultExpr.h:111
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
#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:61
Constraint on the data type.
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecSVecMultExpr.h:202
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition: SVecSVecMultExpr.h:244
Header file for the exception macros of the math module.
Header file for the VecVecMultExpr base class.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
ReturnType_< VT1 > RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecSVecMultExpr.h:95
Header file for all forward declarations for expression class templates.
Constraint on the data type.
ReturnType_< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition: SVecSVecMultExpr.h:96
ResultType_< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition: SVecSVecMultExpr.h:94
Expression object for sparse vector-sparse vector multiplications.The SVecSVecMultExpr class represen...
Definition: Forward.h:143
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecSVecMultExpr.h:122
Header file for run time assertion macros.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:154
Header file for the reset shim.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
If_< IsExpression< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecSVecMultExpr.h:128
ResultType_< VT1 > RT1
Result type of the left-hand side sparse vector expression.
Definition: SVecSVecMultExpr.h:93
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:272
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
Header file for the RemoveReference type trait.
LeftOperand lhs_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecSVecMultExpr.h:243
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_VECVECMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid vector/vector ...
Definition: VecVecMultExpr.h:108
Header file for the IsComputation type trait class.
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
Header file for the Size type trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
#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
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecSVecMultExpr.h:236
Header file for the IsExpression type trait class.
Header file for the function trace functionality.