35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECSVECADDEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SVECSVECADDEXPR_H_ 88 template<
typename VT1
92 :
public VecVecAddExpr< SparseVector< SVecSVecAddExpr<VT1,VT2,TF>, TF > >
125 template<
typename VT >
126 struct UseSMPAssign {
127 enum :
bool { value = VT::smpAssignable };
154 enum :
bool { smpAssignable =
false };
188 if( index >=
lhs_.size() ) {
191 return (*
this)[index];
200 inline size_t size() const noexcept {
241 template<
typename T >
242 inline bool canAlias(
const T* alias )
const noexcept {
243 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
253 template<
typename T >
254 inline bool isAliased(
const T* alias )
const noexcept {
255 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
278 template<
typename VT >
296 const LeftIterator lend( x.end() );
297 const RightIterator rend( y.end() );
299 for( LeftIterator l=x.begin(); l!=lend; ++l ) {
300 (~lhs)[l->index()] = l->value();
303 for( RightIterator r=y.begin(); r!=rend; ++r ) {
305 (~lhs)[r->index()] = r->value();
307 (~lhs)[r->index()] += r->value();
326 template<
typename VT >
344 const LeftIterator lend( x.end() );
345 const RightIterator rend( y.end() );
347 for( LeftIterator l=x.begin(); l!=lend; ++l ) {
348 (~lhs)[l->index()] = l->value();
351 for( RightIterator r=y.begin(); r!=rend; ++r ) {
352 (~lhs)[r->index()] += r->value();
370 template<
typename VT >
388 (~lhs).reserve(
min( x.size(), x.nonZeros() + y.nonZeros() ) );
391 const LeftIterator lend( x.end() );
392 const RightIterator rend( y.end() );
394 LeftIterator l( x.begin() );
395 RightIterator r( y.begin() );
397 while( l != lend && r != rend )
399 if( l->index() < r->index() ) {
400 (~lhs).append( l->index(), l->value() );
403 else if( l->index() > r->index() ) {
404 (~lhs).append( r->index(), r->value() );
408 (~lhs).append( l->index(), l->value() + r->value() );
415 (~lhs).append( l->index(), l->value() );
420 (~lhs).append( r->index(), r->value() );
439 template<
typename VT >
446 addAssign( ~lhs, rhs.lhs_ );
447 addAssign( ~lhs, rhs.rhs_ );
468 template<
typename VT >
475 subAssign( ~lhs, rhs.lhs_ );
476 subAssign( ~lhs, rhs.rhs_ );
497 template<
typename VT >
509 multAssign( ~lhs, tmp );
540 template<
typename VT >
572 template<
typename VT >
605 template<
typename VT >
672 template<
typename VT1
675 inline decltype(
auto)
680 if( (~lhs).
size() != (~rhs).
size() ) {
700 template<
typename VT1,
typename VT2,
bool TF >
701 struct Size< SVecSVecAddExpr<VT1,VT2,TF>, 0UL >
702 :
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
ResultType_< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:98
Header file for auxiliary alias declarations.
Headerfile for the generic min algorithm.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecSVecAddExpr.h:242
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.
LeftOperand lhs_
Left-hand side sparse vector of the addition expression.
Definition: SVecSVecAddExpr.h:261
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecSVecAddExpr.h:210
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:164
Header file for the serial shim.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecSVecAddExpr.h:174
EnableIf_< IsDenseVector< VT1 > > smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:193
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
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
Header file for the AddExprTrait class template.
Header file for the Computation base class.
const ResultType CompositeType
Data type for composite expression templates.
Definition: SVecSVecAddExpr.h:143
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecSVecAddExpr.h:220
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecSVecAddExpr.h:254
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
Expression object for sparse vector-sparse vector additions.The SVecSVecAddExpr class represents the ...
Definition: Forward.h:141
CompositeType_< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:102
Header file for the Maximum class template.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
CompositeType_< VT1 > CT1
Composite type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:101
Header file for the DisableIf class template.
Header file for the IsTemporary type trait class.
typename AddExprTrait< T1, T2 >::Type AddExprTrait_
Auxiliary alias declaration for the AddExprTrait class template.The AddExprTrait_ alias declaration p...
Definition: AddExprTrait.h:112
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SVecSVecAddExpr.h:137
Header file for the VecVecAddExpr base class.
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: SVecSVecAddExpr.h:230
#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
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_VECVECADDEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid vector/vector ...
Definition: VecVecAddExpr.h:108
ReturnType_< VT1 > RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:99
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
ResultType_< VT1 > RT1
Result type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:97
ReturnType_< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:100
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.
Header file for the exception macros of the math module.
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SVecSVecAddExpr.h:200
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
Header file for the EnableIf class template.
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecSVecAddExpr.h:140
Constraint on the data type.
Header file for run time assertion macros.
Header file for the addition trait.
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
SVecSVecAddExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the SVecSVecAddExpr class.
Definition: SVecSVecAddExpr.h:160
#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
Header file for the isDefault shim.
AddExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: SVecSVecAddExpr.h:115
If_< IsExpression< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:149
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
RightOperand rhs_
Right-hand side sparse vector of the addition expression.
Definition: SVecSVecAddExpr.h:262
If_< IsExpression< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:146
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
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SVecSVecAddExpr.h:187
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
AddTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SVecSVecAddExpr.h:135
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecSVecAddExpr.h:136
Header file for the IsResizable type trait.
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
typename AddTrait< T1, T2 >::Type AddTrait_
Auxiliary alias declaration for the AddTrait class template.The AddTrait_ alias declaration provides ...
Definition: AddTrait.h:291
#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
Header file for the IsExpression type trait class.
Header file for the function trace functionality.