35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECDVECADDEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DVECDVECADDEXPR_H_
96 template<
typename VT1
139 template<
typename VT >
142 enum :
bool { value = useAssign };
155 template<
typename VT >
156 struct UseSMPAssign {
157 enum :
bool { value = ( !VT1::smpAssignable || !VT2::smpAssignable ) && useAssign };
215 explicit inline ConstIterator( LeftIteratorType left, RightIteratorType right )
297 return (*left_) + (*right_);
306 inline auto load() const noexcept {
307 return left_.load() + right_.load();
318 return left_ == rhs.
left_;
329 return left_ != rhs.
left_;
340 return left_ < rhs.
left_;
351 return left_ > rhs.
left_;
362 return left_ <= rhs.
left_;
373 return left_ >= rhs.
left_;
384 return left_ - rhs.
left_;
434 enum :
bool { simdEnabled = VT1::simdEnabled && VT2::simdEnabled &&
438 enum :
bool { smpAssignable = VT1::smpAssignable && VT2::smpAssignable };
479 inline ReturnType
at(
size_t index )
const {
480 if( index >=
lhs_.size() ) {
483 return (*
this)[index];
496 return lhs_.load( index ) +
rhs_.load( index );
525 inline size_t size() const noexcept {
556 template<
typename T >
557 inline bool canAlias(
const T* alias )
const noexcept {
569 template<
typename T >
570 inline bool isAliased(
const T* alias )
const noexcept {
571 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
581 return lhs_.isAligned() &&
rhs_.isAligned();
591 return lhs_.canSMPAssign() ||
rhs_.canSMPAssign() ||
592 (
size() > SMP_DVECDVECADD_THRESHOLD );
616 template<
typename VT >
625 addAssign( ~lhs, rhs.
rhs_ );
628 addAssign( ~lhs, rhs.
lhs_ );
631 assign ( ~lhs, rhs.
lhs_ );
632 addAssign( ~lhs, rhs.
rhs_ );
652 template<
typename VT >
664 const ResultType tmp(
serial( rhs ) );
684 template<
typename VT >
685 friend inline EnableIf_< UseAssign<VT> >
692 addAssign( ~lhs, rhs.lhs_ );
693 addAssign( ~lhs, rhs.rhs_ );
716 template<
typename VT >
717 friend inline EnableIf_< UseAssign<VT> >
724 subAssign( ~lhs, rhs.lhs_ );
725 subAssign( ~lhs, rhs.rhs_ );
748 template<
typename VT >
749 friend inline EnableIf_< UseAssign<VT> >
760 const ResultType tmp(
serial( rhs ) );
761 multAssign( ~lhs, tmp );
784 template<
typename VT >
785 friend inline EnableIf_< UseAssign<VT> >
796 const ResultType tmp(
serial( rhs ) );
797 divAssign( ~lhs, tmp );
820 template<
typename VT >
821 friend inline EnableIf_< UseSMPAssign<VT> >
828 if( !IsComputation<VT1>::value &&
isSame( ~lhs, rhs.lhs_ ) ) {
831 else if( !IsComputation<VT2>::value &&
isSame( ~lhs, rhs.rhs_ ) ) {
856 template<
typename VT >
857 friend inline EnableIf_< UseSMPAssign<VT> >
868 const ResultType tmp( rhs );
888 template<
typename VT >
889 friend inline EnableIf_< UseSMPAssign<VT> >
920 template<
typename VT >
921 friend inline EnableIf_< UseSMPAssign<VT> >
952 template<
typename VT >
953 friend inline EnableIf_< UseSMPAssign<VT> >
964 const ResultType tmp( rhs );
988 template<
typename VT >
989 friend inline EnableIf_< UseSMPAssign<VT> >
1000 const ResultType tmp( rhs );
1055 template<
typename T1
1058 inline const DVecDVecAddExpr<T1,T2,TF>
1063 if( (~lhs).
size() != (~rhs).
size() ) {
1082 template<
typename VT1,
typename VT2,
bool TF >
1084 :
public Max< Size<VT1>, Size<VT2> >
1100 template<
typename VT1,
typename VT2,
bool TF >
1102 :
public BoolConstant< And< IsAligned<VT1>, IsAligned<VT2> >::value >
1118 template<
typename VT1,
typename VT2,
bool TF >
1120 :
public BoolConstant< And< IsPadded<VT1>, IsPadded<VT2> >::value >
1136 template<
typename VT1,
typename VT2,
bool TF,
bool AF >
1141 using Type = AddExprTrait_< SubvectorExprTrait_<const VT1,AF>
1142 , SubvectorExprTrait_<const VT2,AF> >;
#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
Iterator over the elements of the dense vector.
Definition: DVecDVecAddExpr.h:185
Pointer difference type of the Blaze library.
ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DVecDVecAddExpr.h:215
Header file for auxiliary alias declarations.
Header file for the Max class template.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:72
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:70
AddExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: DVecDVecAddExpr.h:125
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecDVecAddExpr.h:383
PointerType pointer
Pointer return type.
Definition: DVecDVecAddExpr.h:198
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecDVecAddExpr.h:166
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
Header file for basic type definitions.
IfTrue_< useAssign, const ResultType, const DVecDVecAddExpr & > CompositeType
Data type for composite expression templates.
Definition: DVecDVecAddExpr.h:173
IteratorCategory iterator_category
The iterator category.
Definition: DVecDVecAddExpr.h:196
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:160
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecDVecAddExpr.h:505
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:699
ElementType ValueType
Type of the underlying elements.
Definition: DVecDVecAddExpr.h:190
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
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:317
If_< IsExpression< VT1 >, const VT1, const VT1 & > LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:176
Header file for the And class template.
Header file for the DenseVector base class.
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:162
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecDVecAddExpr.h:296
Header file for the AddExprTrait class template.
ElementType_< VT2 > ET2
Element type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:112
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
DVecDVecAddExpr< VT1, VT2, TF > This
Type of this DVecDVecAddExpr instance.
Definition: DVecDVecAddExpr.h:164
CompositeType_< VT1 > CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:109
Header file for the Computation base class.
ReturnType_< VT2 > RN2
Return type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:108
RightOperand rhs_
Right-hand side dense vector of the addition expression.
Definition: DVecDVecAddExpr.h:599
Header file for the RequiresEvaluation type trait.
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecDVecAddExpr.h:479
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
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:129
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecDVecAddExpr.h:189
Constraint on the data type.
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:343
Constraint on the data type.
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecDVecAddExpr.h:240
If_< IsExpression< VT2 >, const VT2, const VT2 & > RightOperand
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:179
ConstIterator_< VT1 > LeftIteratorType
ConstIterator type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:203
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:72
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecDVecAddExpr.h:407
ConstIterator_< VT2 > RightIteratorType
ConstIterator type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:206
Header file for the IsTemporary type trait class.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecDVecAddExpr.h:193
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:361
typename AddExprTrait< T1, T2 >::Type AddExprTrait_
Auxiliary alias declaration for the AddExprTrait class template.The AddExprTrait_ alias declaration p...
Definition: AddExprTrait.h:219
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the If class template.
ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecDVecAddExpr.h:274
Header file for the VecVecAddExpr base class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:350
EnableIf_< IsDenseMatrix< MT1 > > 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
#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:109
Header file for the HasSIMDAdd type trait.
RightOperand rightOperand() const noexcept
Returns the right-hand side dense vector operand.
Definition: DVecDVecAddExpr.h:545
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecDVecAddExpr.h:170
ElementType & ReferenceType
Reference return type.
Definition: DVecDVecAddExpr.h:192
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for all SIMD functionality.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DVecDVecAddExpr.h:427
Header file for the IsAligned type trait.
Constraint on the data type.
DVecDVecAddExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the DVecDVecAddExpr class.
Definition: DVecDVecAddExpr.h:452
#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:60
Constraint on the data type.
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecAddExpr.h:493
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecDVecAddExpr.h:535
Header file for the exception macros of the math module.
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecDVecAddExpr.h:227
Header file for all forward declarations for expression class templates.
Base class for all vector/vector addition expression templates.The VecVecAddExpr class serves as a ta...
Definition: VecVecAddExpr.h:65
Header file for the EnableIf class template.
CompositeType_< VT2 > CT2
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:110
Header file for the IsPadded type trait.
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecDVecAddExpr.h:525
Constraint on the data type.
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecDVecAddExpr.h:286
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecDVecAddExpr.h:515
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecDVecAddExpr.h:590
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:372
Header file for run time assertion macros.
ElementType * PointerType
Pointer return type.
Definition: DVecDVecAddExpr.h:191
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecDVecAddExpr.h:557
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:160
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecDVecAddExpr.h:570
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecAddExpr.h:306
EnableIf_< IsDenseVector< VT1 > > smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:222
const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecDVecAddExpr.h:264
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DVecDVecAddExpr.h:167
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecDVecAddExpr.h:580
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DVecDVecAddExpr.h:426
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
LeftOperand lhs_
Left-hand side dense vector of the addition expression.
Definition: DVecDVecAddExpr.h:598
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecDVecAddExpr.h:419
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Expression object for dense vector-dense vector additions.The DVecDVecAddExpr class represents the co...
Definition: DVecDVecAddExpr.h:99
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecDVecAddExpr.h:395
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecDVecAddExpr.h:466
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
ValueType value_type
Type of the underlying elements.
Definition: DVecDVecAddExpr.h:197
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:328
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecDVecAddExpr.h:252
DifferenceType difference_type
Difference between two iterators.
Definition: DVecDVecAddExpr.h:200
Header file for the IsComputation type trait class.
ElementType_< VT1 > ET1
Element type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:111
AddTrait_< RE1, RE2 > ResultType
Result type for expression template evaluations.
Definition: DVecDVecAddExpr.h:165
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
#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
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:339
Header file for the IntegralConstant class template.
Header file for the SubvectorExprTrait class template.
ReturnType_< VT1 > RN1
Return type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:107
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
ResultType_< VT2 > RE2
Result type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:106
Constraint on the data type.
System settings for the inline keywords.
ResultType_< VT1 > RE1
Result type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:105
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
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
typename AddTrait< T1, T2 >::Type AddTrait_
Auxiliary alias declaration for the AddTrait class template.The AddTrait_ alias declaration provides ...
Definition: AddTrait.h:245
#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
ReferenceType reference
Reference return type.
Definition: DVecDVecAddExpr.h:199
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:71
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.