35#ifndef _BLAZE_MATH_EXPRESSIONS_SVECSVECADDEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SVECSVECADDEXPR_H_
92 :
public VecVecAddExpr< SparseVector< SVecSVecAddExpr<VT1,VT2,TF>, TF > >
125 template<
typename VT >
126 static constexpr bool UseSMPAssign_v = VT::smpAssignable;
191 if( index >=
lhs_.size() ) {
194 return (*
this)[index];
203 inline size_t size() const noexcept {
244 template<
typename T >
245 inline bool canAlias(
const T* alias )
const noexcept {
246 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
256 template<
typename T >
257 inline bool isAliased(
const T* alias )
const noexcept {
258 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
281 template<
typename VT >
296 const auto lend( x.end() );
297 const auto rend( y.end() );
299 for(
auto l=x.begin(); l!=lend; ++l ) {
300 (*lhs)[l->index()] = l->value();
303 for(
auto r=y.begin(); r!=rend; ++r ) {
305 (*lhs)[r->index()] = r->value();
307 (*lhs)[r->index()] += r->value();
326 template<
typename VT >
341 const auto lend( x.end() );
342 const auto rend( y.end() );
344 for(
auto l=x.begin(); l!=lend; ++l ) {
345 (*lhs)[l->index()] = l->value();
348 for(
auto r=y.begin(); r!=rend; ++r ) {
349 (*lhs)[r->index()] += r->value();
367 template<
typename VT >
368 friend inline void assign( SparseVector<VT,TF>& lhs,
const SVecSVecAddExpr& rhs )
382 (*lhs).reserve(
min( x.size(), x.nonZeros() + y.nonZeros() ) );
385 const auto lend( x.end() );
386 const auto rend( y.end() );
391 while( l != lend && r != rend )
393 if( l->index() < r->index() ) {
394 (*lhs).append( l->index(), l->value() );
397 else if( l->index() > r->index() ) {
398 (*lhs).append( r->index(), r->value() );
402 (*lhs).append( l->index(), l->value() + r->value() );
409 (*lhs).append( l->index(), l->value() );
414 (*lhs).append( r->index(), r->value() );
433 template<
typename VT >
434 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const SVecSVecAddExpr& rhs )
440 addAssign( *lhs, rhs.lhs_ );
441 addAssign( *lhs, rhs.rhs_ );
462 template<
typename VT >
463 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const SVecSVecAddExpr& rhs )
469 subAssign( *lhs, rhs.lhs_ );
470 subAssign( *lhs, rhs.rhs_ );
491 template<
typename VT >
492 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const SVecSVecAddExpr& rhs )
503 multAssign( *lhs, tmp );
534 template<
typename VT >
566 template<
typename VT >
599 template<
typename VT >
654template<
typename VT1
686template<
typename VT1
719template<
typename VT1
751template<
typename VT1
769 return ReturnType( (*lhs).size() );
799template<
typename VT1
807 if( (*lhs).size() != (*rhs).size() ) {
811 return svecsvecadd( *lhs, *rhs );
Header file for the addition trait.
Header file for auxiliary alias declarations.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition Aliases.h:470
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition Aliases.h:110
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition Aliases.h:550
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition Aliases.h:450
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the isDefault shim.
Header file for the IsExpression type trait class.
Header file for the IsResizable type trait.
Header file for the IsSame and IsStrictlySame type traits.
Header file for the IsTemporary type trait class.
Deactivation of problematic macros.
Header file for the MAYBE_UNUSED function template.
Constraint on the data type.
Base class for N-dimensional dense vectors.
Definition DenseVector.h:77
Expression object for sparse vector-sparse vector additions.
Definition SVecSVecAddExpr.h:94
const ResultType CompositeType
Data type for composite expression templates.
Definition SVecSVecAddExpr.h:146
AddTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition SVecSVecAddExpr.h:138
SVecSVecAddExpr< VT1, VT2, TF > This
Type of this SVecSVecAddExpr instance.
Definition SVecSVecAddExpr.h:133
ReturnType_t< VT1 > RN1
Return type of the left-hand side sparse vector expression.
Definition SVecSVecAddExpr.h:99
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition SVecSVecAddExpr.h:157
ResultType_t< VT1 > RT1
Result type of the left-hand side sparse vector expression.
Definition SVecSVecAddExpr.h:97
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition SVecSVecAddExpr.h:223
LeftOperand lhs_
Left-hand side sparse vector of the addition expression.
Definition SVecSVecAddExpr.h:264
CompositeType_t< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition SVecSVecAddExpr.h:102
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition SVecSVecAddExpr.h:245
ElementType_t< ResultType > ElementType
Resulting element type.
Definition SVecSVecAddExpr.h:140
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition SVecSVecAddExpr.h:190
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition SVecSVecAddExpr.h:257
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition SVecSVecAddExpr.h:139
If_t< IsExpression_v< VT1 >, const VT1, const VT1 & > LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition SVecSVecAddExpr.h:149
VecVecAddExpr< SparseVector< This, TF > > BaseType
Base type of this SVecSVecAddExpr instance.
Definition SVecSVecAddExpr.h:136
CompositeType_t< VT1 > CT1
Composite type of the left-hand side sparse vector expression.
Definition SVecSVecAddExpr.h:101
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition SVecSVecAddExpr.h:203
decltype(std::declval< RN1 >()+std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition SVecSVecAddExpr.h:115
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition SVecSVecAddExpr.h:143
If_t< IsExpression_v< VT2 >, const VT2, const VT2 & > RightOperand
Composite type of the right-hand side sparse vector expression.
Definition SVecSVecAddExpr.h:152
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition SVecSVecAddExpr.h:213
RightOperand rhs_
Right-hand side sparse vector of the addition expression.
Definition SVecSVecAddExpr.h:265
ResultType_t< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition SVecSVecAddExpr.h:98
ReturnType_t< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition SVecSVecAddExpr.h:100
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition SVecSVecAddExpr.h:177
SVecSVecAddExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the SVecSVecAddExpr class.
Definition SVecSVecAddExpr.h:163
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition SVecSVecAddExpr.h:112
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition SVecSVecAddExpr.h:233
Base class for sparse vectors.
Definition SparseVector.h:72
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the SparseVector base class.
Header file for the VecVecAddExpr base class.
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition DMatDMatMapExpr.h:1339
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition DMatSerialExpr.h:812
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition DiagonalMatrix.h:169
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition SparseVector.h:61
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_VECVECADDEXPR(T1, T2)
Constraint on the data type.
Definition VecVecAddExpr.h:104
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:61
typename AddTrait< T1, T2 >::Type AddTrait_t
Auxiliary alias declaration for the AddTrait class template.
Definition AddTrait.h:163
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.
Definition IsZero.h:166
constexpr bool IsTemporary_v
Auxiliary variable template for the IsTemporary type trait.
Definition IsTemporary.h:88
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition DenseMatrix.h:162
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector.
Definition DenseVector.h:192
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition DenseMatrix.h:131
constexpr bool IsSame_v
Auxiliary variable template for the IsSame type trait.
Definition IsSame.h:159
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition FunctionTrace.h:94
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:175
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Header file for the serial shim.
Base class for all compute expression templates.
Definition Computation.h:68
Base class for all vector/vector addition expression templates.
Definition VecVecAddExpr.h:68
Header file for the IsZero type trait.
Header file for basic type definitions.
Header file for the generic min algorithm.