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 >
323 const LeftIterator lend( x.end() );
324 const RightIterator rend( y.end() );
326 LeftIterator l( x.begin() );
327 RightIterator r( y.begin() );
329 for( ; l!=lend; ++l ) {
330 while( r!=rend && r->index() < l->index() ) ++r;
332 if( l->index() == r->index() ) {
333 (~lhs).append( l->index(), l->value() * r->value() );
353 template<
typename VT >
370 const LeftIterator lend( x.end() );
371 const RightIterator rend( y.end() );
373 LeftIterator l( x.begin() );
374 RightIterator r( y.begin() );
376 for( ; l!=lend; ++l ) {
377 while( r!=rend && r->index() < l->index() ) ++r;
379 if( l->index() == r->index() ) {
380 (~lhs)[l->index()] += l->value() * r->value();
404 template<
typename VT >
421 const LeftIterator lend( x.end() );
422 const RightIterator rend( y.end() );
424 LeftIterator l( x.begin() );
425 RightIterator r( y.begin() );
427 for( ; l!=lend; ++l ) {
428 while( r!=rend && r->index() < l->index() ) ++r;
430 if( l->index() == r->index() ) {
431 (~lhs)[l->index()] -= l->value() * r->value();
455 template<
typename VT >
472 const LeftIterator lend( x.end() );
473 const RightIterator rend( y.end() );
475 LeftIterator l( x.begin() );
476 RightIterator r( y.begin() );
480 for( ; l!=lend; ++l ) {
481 while( r!=rend && r->index() < l->index() ) ++r;
483 if( l->index() == r->index() ) {
484 for( ; i<r->index(); ++i )
486 (~lhs)[l->index()] *= l->value() * r->value();
492 for( ; i<rhs.size(); ++i )
510 template<
typename VT >
528 VT tmp( rhs.size(), rhs.nonZeros() );
530 const Iterator1 end1( (~lhs).
end() );
531 const Iterator2 end2( x.end() );
532 const Iterator3 end3( y.end() );
534 Iterator1 i1( (~lhs).
begin() );
535 Iterator2 i2( x.begin() );
536 Iterator3 i3( y.begin() );
538 for( ; i1!=end1; ++i1 ) {
539 while( i2!=end2 && i2->index() < i1->index() ) ++i2;
540 if( i2==end2 )
break;
541 while( i3!=end3 && i3->index() < i1->index() ) ++i3;
542 if( i3==end3 )
break;
543 if( i1->index() == i2->index() && i1->index() == i3->index() ) {
544 tmp.append( i1->index(), i1->value() * i2->value() * i3->value() );
601 template<
typename VT1
604 inline decltype(
auto)
609 if( (~lhs).
size() != (~rhs).
size() ) {
629 template<
typename VT1,
typename VT2,
bool TF >
630 struct Size< SVecSVecMultExpr<VT1,VT2,TF> >
631 :
public Maximum< Size<VT1>, Size<VT2> >
#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:70
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:198
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:560
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:1762
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:250
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:57
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: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: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:264
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:270
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:819
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:3082
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 a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:74
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.