35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECSVECADDEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SVECSVECADDEXPR_H_
84 template<
typename VT1
87 class SVecSVecAddExpr :
public SparseVector< SVecSVecAddExpr<VT1,VT2,TF>, TF >
88 ,
private VecVecAddExpr
175 return min(
lhs_.size(),
lhs_.nonZeros() +
rhs_.nonZeros() );
205 template<
typename T >
207 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
217 template<
typename T >
219 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
242 template<
typename VT >
260 const LeftIterator lend( x.end() );
261 const RightIterator rend( y.end() );
263 for( LeftIterator l=x.begin(); l!=lend; ++l ) {
264 (~lhs)[l->index()] = l->value();
267 for( RightIterator r=y.begin(); r!=rend; ++r ) {
269 (~lhs)[r->index()] = r->value();
271 (~lhs)[r->index()] += r->value();
290 template<
typename VT >
308 const LeftIterator lend( x.end() );
309 const RightIterator rend( y.end() );
311 for( LeftIterator l=x.begin(); l!=lend; ++l ) {
312 (~lhs)[l->index()] = l->value();
315 for( RightIterator r=y.begin(); r!=rend; ++r ) {
316 (~lhs)[r->index()] += r->value();
334 template<
typename VT >
351 const LeftIterator lend( x.end() );
352 const RightIterator rend( y.end() );
354 LeftIterator l( x.begin() );
355 RightIterator r( y.begin() );
357 while( l != lend && r != rend )
359 if( l->index() < r->index() ) {
360 (~lhs).append( l->index(), l->value() );
363 else if( l->index() > r->index() ) {
364 (~lhs).append( r->index(), r->value() );
368 (~lhs).append( l->index(), l->value() + r->value() );
375 (~lhs).append( l->index(), l->value() );
380 (~lhs).append( r->index(), r->value() );
399 template<
typename VT >
428 template<
typename VT >
457 template<
typename VT >
522 template<
typename T1
525 inline const SVecSVecAddExpr<T1,T2,TF>
530 if( (~lhs).size() != (~rhs).size() )
531 throw std::invalid_argument(
"Vector sizes do not match" );
548 template<
typename VT1,
typename VT2,
bool TF >
549 struct SubvectorExprTrait< SVecSVecAddExpr<VT1,VT2,TF> >
553 typedef typename AddExprTrait< typename SubvectorExprTrait<const VT1>::Type
554 ,
typename SubvectorExprTrait<const VT2>::Type >::Type Type;
Header file for mathematical functions.
Evaluation of the return type of an addition expression.Via this type trait it is possible to evaluat...
Definition: AddExprTrait.h:103
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
VT2::ResultType RT2
Result type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:94
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
LeftOperand leftOperand() const
Returns the left-hand side sparse vector operand.
Definition: SVecSVecAddExpr.h:184
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
VT1::ReturnType RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:95
AddExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SVecSVecAddExpr.h:113
Header file for the AddExprTrait class template.
Header file for the Computation base class.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SVecSVecAddExpr.h:218
RightOperand rhs_
Right-hand side sparse vector of the addition expression.
Definition: SVecSVecAddExpr.h:226
Constraint on the data type.
Expression object for sparse vector-sparse vector additions.The SVecSVecAddExpr class represents the ...
Definition: Forward.h:113
SVecSVecAddExpr< VT1, VT2, TF > This
Type of this SVecSVecAddExpr instance.
Definition: SVecSVecAddExpr.h:118
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 IsTemporary type trait class.
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: SVecSVecAddExpr.h:194
Header file for the VecVecAddExpr base class.
VT2::TransposeType TT2
Transpose type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:100
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SVecSVecAddExpr.h:206
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecSVecAddExpr.h:174
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
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
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
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2372
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.
Header file for the EnableIf class template.
VT1::CompositeType CT1
Composite type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:97
VT1::ResultType RT1
Result type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:93
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2374
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
const ResultType CompositeType
Data type for composite expression templates.
Definition: SVecSVecAddExpr.h:127
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:141
Header file for the addition trait.
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SVecSVecAddExpr.h:120
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
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
VT2::ReturnType RN2
Return type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:96
VT2::CompositeType CT2
Composite type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:98
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
size_t size() const
Returns the current size/dimension of the vector.
Definition: SVecSVecAddExpr.h:164
Header file for the isDefault shim.
SVecSVecAddExpr(const VT1 &lhs, const VT2 &rhs)
Constructor for the SVecSVecAddExpr class.
Definition: SVecSVecAddExpr.h:139
VT1::TransposeType TT1
Transpose type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:99
SelectType< IsExpression< VT2 >::value, const VT2, const VT2 & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:133
Header file for the RemoveReference type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
ResultType::ElementType ElementType
Resulting element type.
Definition: SVecSVecAddExpr.h:121
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SVecSVecAddExpr.h:124
AddTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: SVecSVecAddExpr.h:119
Header file for the IsComputation type trait class.
SelectType< IsExpression< VT1 >::value, const VT1, const VT1 & >::Type LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecSVecAddExpr.h:130
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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
Header file for basic type definitions.
Header file for the SubvectorExprTrait class template.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecSVecAddExpr.h:153
LeftOperand lhs_
Left-hand side sparse vector of the addition expression.
Definition: SVecSVecAddExpr.h:225
Header file for the IsResizable 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:238
#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 FunctionTrace class.