35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECABSEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SVECABSEXPR_H_
93 class SVecAbsExpr :
public SparseVector< SVecAbsExpr<VT,TF>, TF >
130 template<
typename VT2 >
133 enum { value = useAssign };
146 template<
typename VT2 >
147 struct UseSMPAssign {
148 enum { value = ( !VT2::smpAssignable || !VT::smpAssignable ) && useAssign };
172 enum { smpAssignable = VT::smpAssignable };
228 return Element(
abs( it_->value() ), it_->index() );
249 return abs( it_->value() );
270 return it_ == rhs.
it_;
281 return it_ != rhs.
it_;
292 return it_ - rhs.
it_;
362 return sv_.nonZeros();
418 template<
typename T >
420 return sv_.canAlias( alias );
430 template<
typename T >
432 return sv_.isAliased( alias );
442 return sv_.canSMPAssign();
465 template<
typename VT2 >
495 template<
typename VT2 >
509 const Iterator
end( (~lhs).
end() );
510 for( Iterator element=(~lhs).
begin(); element!=
end; ++element ) {
511 element->value() =
abs( element->value() );
531 template<
typename VT2 >
532 friend inline typename EnableIf< UseAssign<VT2> >::Type
543 const ResultType tmp(
serial( rhs ) );
567 template<
typename VT2 >
568 friend inline typename EnableIf< UseAssign<VT2> >::Type
579 const ResultType tmp(
serial( rhs ) );
603 template<
typename VT2 >
604 friend inline typename EnableIf< UseAssign<VT2> >::Type
615 const ResultType tmp(
serial( rhs ) );
639 template<
typename VT2 >
640 friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
671 template<
typename VT2 >
672 friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
683 const ResultType tmp( rhs );
707 template<
typename VT2 >
708 friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
719 const ResultType tmp( rhs );
743 template<
typename VT2 >
744 friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
755 const ResultType tmp( rhs );
800 template<
typename VT
830 template<
typename VT
832 inline const SVecAbsExpr<VT,TF>&
abs(
const SVecAbsExpr<VT,TF>& sv )
852 template<
typename VT,
bool TF >
870 template<
typename VT >
875 typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value
876 , SVecAbsExpr<VT,false>
877 , INVALID_TYPE >::Type Type;
886 template<
typename VT >
891 typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value
892 , SVecAbsExpr<VT,true>
893 , INVALID_TYPE >::Type Type;
902 template<
typename VT,
bool TF,
bool AF >
903 struct SubvectorExprTrait<
SVecAbsExpr<VT,TF>, AF >
907 typedef typename AbsExprTrait< typename SubvectorExprTrait<const VT,AF>::Type >::Type Type;
Pointer difference type of the Blaze library.
ValueType * PointerType
Pointer return type.
Definition: SVecAbsExpr.h:190
BLAZE_ALWAYS_INLINE 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:879
Header file for the TSVecAbsExprTrait class template.
ConstIterator begin() const
Returns an iterator to the first non-zero element of the sparse vector.
Definition: SVecAbsExpr.h:331
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
Header file for basic type definitions.
Header file for the SparseVector base class.
IteratorType it_
Iterator over the elements of the sparse vector expression.
Definition: SVecAbsExpr.h:298
size_t index() const
Access to the current index of the sparse element.
Definition: SVecAbsExpr.h:258
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: SVecAbsExpr.h:396
ValueType & ReferenceType
Reference return type.
Definition: SVecAbsExpr.h:191
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecAbsExpr.h:226
VT::TransposeType TT
Transpose type of the sparse vector expression.
Definition: SVecAbsExpr.h:102
SelectType< useAssign, const ResultType, const SVecAbsExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SVecAbsExpr.h:164
const SVecAbsExpr< VT, TF > abs(const SparseVector< VT, TF > &sv)
Returns a vector containing the absolute values of each single element of sv.
Definition: SVecAbsExpr.h:802
VT::ResultType RT
Result type of the sparse vector expression.
Definition: SVecAbsExpr.h:99
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
Header file for the IsRowVector type trait.
const DMatAbsExpr< MT, SO > abs(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the absolute values of each single element of dm.
Definition: DMatAbsExpr.h:914
Element ValueType
Type of the underlying pointers.
Definition: SVecAbsExpr.h:189
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:699
Header file for the Computation base class.
SVecAbsExpr< VT, TF > This
Type of this SVecAbsExpr instance.
Definition: SVecAbsExpr.h:155
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecAbsExpr.h:215
Header file for the SVecAbsExprTrait class template.
Header file for the RequiresEvaluation type trait.
SVecAbsExpr(const VT &sv)
Constructor for the SVecAbsExpr class.
Definition: SVecAbsExpr.h:308
AbsExprTrait< RN >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SVecAbsExpr.h:116
IteratorCategory iterator_category
The iterator category.
Definition: SVecAbsExpr.h:195
Expression object for the sparse vector abs() function.The SVecAbsExpr class represents the compile t...
Definition: Forward.h:109
VT::ReturnType RN
Return type of the sparse vector expression.
Definition: SVecAbsExpr.h:100
Constraint on the data type.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SVecAbsExpr.h:419
RemoveReference< Operand >::Type::ConstIterator IteratorType
Iterator type of the sparse vector expression.
Definition: SVecAbsExpr.h:186
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:263
ConstIterator end() const
Returns an iterator just past the last non-zero element of the sparse vector.
Definition: SVecAbsExpr.h:341
Header file for the ValueIndexPair class.
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 IsTemporary type trait class.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecAbsExpr.h:361
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: SVecAbsExpr.h:384
ET ElementType
Resulting element type.
Definition: SVecAbsExpr.h:158
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
DifferenceType difference_type
Difference between two iterators.
Definition: SVecAbsExpr.h:199
BLAZE_ALWAYS_INLINE 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:635
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: SVecAbsExpr.h:372
VT::ElementType ET
Element type of the sparse vector expression.
Definition: SVecAbsExpr.h:103
ValueType value_type
Type of the underlying pointers.
Definition: SVecAbsExpr.h:196
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: SVecAbsExpr.h:441
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
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecAbsExpr.h:269
Header file for the VecAbsExpr base class.
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
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition: SVecAbsExpr.h:183
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2504
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecAbsExpr.h:319
TT TransposeType
Transpose type for expression template evaluations.
Definition: SVecAbsExpr.h:157
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
Constraint on the data type.
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.
Header file for the serial shim.
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecAbsExpr.h:188
Operand operand() const
Returns the sparse vector operand.
Definition: SVecAbsExpr.h:407
EnableIf< IsDenseMatrix< MT1 > >::Type 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:160
Header file for the IsSparseVector type trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Iterator over the elements of the sparse vector absolute value expression.
Definition: SVecAbsExpr.h:178
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SVecAbsExpr.h:161
Header file for run time assertion macros.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
Utility type for generic codes.
Operand sv_
Sparse vector of the absolute value expression.
Definition: SVecAbsExpr.h:448
BLAZE_ALWAYS_INLINE 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:742
ConstIterator(IteratorType it)
Constructor for the ConstIterator class.
Definition: SVecAbsExpr.h:205
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecAbsExpr.h:192
VT::CompositeType CT
Composite type of the sparse vector expression.
Definition: SVecAbsExpr.h:101
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2510
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecAbsExpr.h:237
#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:118
Header file for the RemoveReference type trait.
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecAbsExpr.h:247
PointerType pointer
Pointer return type.
Definition: SVecAbsExpr.h:197
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecAbsExpr.h:291
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecAbsExpr.h:280
Header file for the IsComputation type trait class.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SVecAbsExpr.h:431
size_t size() const
Returns the current size/dimension of the vector.
Definition: SVecAbsExpr.h:351
RT ResultType
Result type for expression template evaluations.
Definition: SVecAbsExpr.h:156
EnableIf< IsDenseMatrix< MT1 > >::Type 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:129
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
#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:2502
ReferenceType reference
Reference return type.
Definition: SVecAbsExpr.h:198
Header file for the SubvectorExprTrait class template.
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type Operand
Composite data type of the sparse vector expression.
Definition: SVecAbsExpr.h:167
Header file for the AbsExprTrait class template.
Header file for the IsColumnVector type trait.
Evaluation of the return type of an absolute value expression.Via this type trait it is possible to e...
Definition: AbsExprTrait.h:87
EnableIf< IsDenseVector< VT1 > >::Type 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:189
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: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.
BLAZE_ALWAYS_INLINE 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:849