35#ifndef _BLAZE_MATH_EXPRESSIONS_DVECDVECADDEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DVECDVECADDEXPR_H_
98 :
public VecVecAddExpr< DenseVector< DVecDVecAddExpr<VT1,VT2,TF>, TF > >
120 static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
135 ( RequiresEvaluation_v<VT1> || RequiresEvaluation_v<VT2> || !
returnExpr );
139 template<
typename VT >
140 static constexpr bool UseAssign_v =
useAssign;
152 template<
typename VT >
153 static constexpr bool UseSMPAssign_v =
154 ( ( !VT1::smpAssignable || !VT2::smpAssignable ) &&
useAssign );
298 return (*
left_) + (*right_);
307 inline auto load() const noexcept {
436 ( VT1::simdEnabled && VT2::simdEnabled && HasSIMDAdd_v<ET1,ET2> );
439 static constexpr bool smpAssignable = ( VT1::smpAssignable && VT2::smpAssignable );
481 if( index >=
lhs_.size() ) {
484 return (*
this)[index];
497 return lhs_.load( index ) +
rhs_.load( index );
526 inline size_t size() const noexcept {
557 template<
typename T >
558 inline bool canAlias(
const T* alias )
const noexcept {
559 return ( IsExpression_v<VT1> && ( RequiresEvaluation_v<VT1> ?
lhs_.isAliased( alias ) :
lhs_.canAlias( alias ) ) ) ||
560 ( IsExpression_v<VT2> && ( RequiresEvaluation_v<VT2> ?
rhs_.isAliased( alias ) :
rhs_.canAlias( alias ) ) );
570 template<
typename T >
571 inline bool isAliased(
const T* alias )
const noexcept {
572 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
582 return lhs_.isAligned() &&
rhs_.isAligned();
592 return lhs_.canSMPAssign() ||
rhs_.canSMPAssign() ||
593 (
size() > SMP_DVECDVECADD_THRESHOLD );
617 template<
typename VT >
625 if( !IsComputation_v<VT1> &&
isSame( *lhs, rhs.lhs_ ) ) {
626 addAssign( *lhs, rhs.rhs_ );
628 else if( !IsComputation_v<VT2> &&
isSame( *lhs, rhs.rhs_ ) ) {
629 addAssign( *lhs, rhs.lhs_ );
631 else if( !RequiresEvaluation_v<VT2> ) {
632 assign ( *lhs, rhs.rhs_ );
633 addAssign( *lhs, rhs.lhs_ );
636 assign ( *lhs, rhs.lhs_ );
637 addAssign( *lhs, rhs.rhs_ );
657 template<
typename VT >
689 template<
typename VT >
690 friend inline auto addAssign( DenseVector<VT,TF>& lhs,
const DVecDVecAddExpr& rhs )
691 -> EnableIf_t< UseAssign_v<VT> >
697 if( !RequiresEvaluation_v<VT2> ) {
698 addAssign( *lhs, rhs.rhs_ );
699 addAssign( *lhs, rhs.lhs_ );
702 addAssign( *lhs, rhs.lhs_ );
703 addAssign( *lhs, rhs.rhs_ );
727 template<
typename VT >
728 friend inline auto subAssign( DenseVector<VT,TF>& lhs,
const DVecDVecAddExpr& rhs )
729 -> EnableIf_t< UseAssign_v<VT> >
735 if( !RequiresEvaluation_v<VT2> ) {
736 subAssign( *lhs, rhs.rhs_ );
737 subAssign( *lhs, rhs.lhs_ );
740 subAssign( *lhs, rhs.lhs_ );
741 subAssign( *lhs, rhs.rhs_ );
765 template<
typename VT >
766 friend inline auto multAssign( DenseVector<VT,TF>& lhs,
const DVecDVecAddExpr& rhs )
767 -> EnableIf_t< UseAssign_v<VT> >
778 multAssign( *lhs, tmp );
801 template<
typename VT >
802 friend inline auto divAssign( DenseVector<VT,TF>& lhs,
const DVecDVecAddExpr& rhs )
803 -> EnableIf_t< UseAssign_v<VT> >
814 divAssign( *lhs, tmp );
837 template<
typename VT >
839 -> EnableIf_t< UseSMPAssign_v<VT> >
845 if( !IsComputation_v<VT1> &&
isSame( *lhs, rhs.lhs_ ) ) {
848 else if( !IsComputation_v<VT2> &&
isSame( *lhs, rhs.rhs_ ) ) {
851 else if( !RequiresEvaluation_v<VT2> ) {
877 template<
typename VT >
879 -> EnableIf_t< UseSMPAssign_v<VT> >
909 template<
typename VT >
911 -> EnableIf_t< UseSMPAssign_v<VT> >
917 if( !RequiresEvaluation_v<VT2> ) {
947 template<
typename VT >
949 -> EnableIf_t< UseSMPAssign_v<VT> >
955 if( !RequiresEvaluation_v<VT2> ) {
985 template<
typename VT >
987 -> EnableIf_t< UseSMPAssign_v<VT> >
1021 template<
typename VT >
1023 -> EnableIf_t< UseSMPAssign_v<VT> >
1088template<
typename VT1
1091inline decltype(
auto)
1096 if( (*lhs).size() != (*rhs).size() ) {
1101 return ReturnType( *lhs, *rhs );
1116template<
typename VT1,
typename VT2,
bool TF >
1117struct IsAligned< DVecDVecAddExpr<VT1,VT2,TF> >
1118 :
public BoolConstant< IsAligned_v<VT1> && IsAligned_v<VT2> >
1134template<
typename VT1,
typename VT2,
bool TF >
1135struct IsPadded< DVecDVecAddExpr<VT1,VT2,TF> >
1136 :
public BoolConstant< IsPadded_v<VT1> && IsPadded_v<VT2> >
Header file for the addition trait.
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.
Definition: Aliases.h:130
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Constraint on the data type.
Header file for the EnableIf class template.
Constraint on the data type.
Header file for the function trace functionality.
Header file for the HasSIMDAdd type trait.
Macro for CUDA compatibility.
Header file for the If class template.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsComputation type trait class.
Header file for the IsExpression type trait class.
Header file for the IsPadded type trait.
Header file for the IsTemporary type trait class.
Deactivation of problematic macros.
Header file for all SIMD functionality.
Iterator over the elements of the dense vector.
Definition: DVecDVecAddExpr.h:187
BLAZE_DEVICE_CALLABLE bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:351
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecDVecAddExpr.h:194
IteratorCategory iterator_category
The iterator category.
Definition: DVecDVecAddExpr.h:197
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecDVecAddExpr.h:241
BLAZE_DEVICE_CALLABLE DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecDVecAddExpr.h:384
BLAZE_DEVICE_CALLABLE bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:373
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecDVecAddExpr.h:396
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecDVecAddExpr.h:228
ReferenceType reference
Reference return type.
Definition: DVecDVecAddExpr.h:200
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecDVecAddExpr.h:190
BLAZE_DEVICE_CALLABLE bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:340
ConstIterator_t< VT1 > LeftIteratorType
ConstIterator type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:204
PointerType pointer
Pointer return type.
Definition: DVecDVecAddExpr.h:199
BLAZE_DEVICE_CALLABLE bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:318
BLAZE_DEVICE_CALLABLE ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DVecDVecAddExpr.h:216
ElementType * PointerType
Pointer return type.
Definition: DVecDVecAddExpr.h:192
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecDVecAddExpr.h:287
ElementType & ReferenceType
Reference return type.
Definition: DVecDVecAddExpr.h:193
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecAddExpr.h:307
ConstIterator_t< VT2 > RightIteratorType
ConstIterator type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:207
BLAZE_DEVICE_CALLABLE bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:362
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecDVecAddExpr.h:265
ElementType ValueType
Type of the underlying elements.
Definition: DVecDVecAddExpr.h:191
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecDVecAddExpr.h:408
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DVecDVecAddExpr.h:427
ValueType value_type
Type of the underlying elements.
Definition: DVecDVecAddExpr.h:198
BLAZE_DEVICE_CALLABLE ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecDVecAddExpr.h:297
BLAZE_DEVICE_CALLABLE bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecDVecAddExpr.h:329
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecDVecAddExpr.h:275
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DVecDVecAddExpr.h:428
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DVecDVecAddExpr.h:253
DifferenceType difference_type
Difference between two iterators.
Definition: DVecDVecAddExpr.h:201
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecDVecAddExpr.h:420
Expression object for dense vector-dense vector additions.
Definition: DVecDVecAddExpr.h:100
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecDVecAddExpr.h:571
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecDVecAddExpr.h:467
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecDVecAddExpr.h:558
CompositeType_t< VT2 > CT2
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:108
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DVecDVecAddExpr.h:444
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecDVecAddExpr.h:506
ElementType_t< VT1 > ET1
Element type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:109
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DVecDVecAddExpr.h:435
If_t< useAssign, const ResultType, const DVecDVecAddExpr & > CompositeType
Data type for composite expression templates.
Definition: DVecDVecAddExpr.h:174
ResultType_t< VT1 > RT1
Result type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:103
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DVecDVecAddExpr.h:120
RightOperand rightOperand() const noexcept
Returns the right-hand side dense vector operand.
Definition: DVecDVecAddExpr.h:546
AddTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DVecDVecAddExpr.h:166
ResultType_t< VT2 > RT2
Result type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:104
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecDVecAddExpr.h:480
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DVecDVecAddExpr.h:168
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecAddExpr.h:494
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the addition expression.
Definition: DVecDVecAddExpr.h:134
RightOperand rhs_
Right-hand side dense vector of the addition expression.
Definition: DVecDVecAddExpr.h:600
DVecDVecAddExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the DVecDVecAddExpr class.
Definition: DVecDVecAddExpr.h:453
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecDVecAddExpr.h:581
If_t< IsExpression_v< VT1 >, const VT1, const VT1 & > LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:177
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DVecDVecAddExpr.h:439
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecDVecAddExpr.h:591
ReturnType_t< VT2 > RN2
Return type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:106
ElementType_t< VT2 > ET2
Element type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:110
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecDVecAddExpr.h:171
decltype(std::declval< RN1 >()+std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DVecDVecAddExpr.h:123
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecDVecAddExpr.h:526
CompositeType_t< VT1 > CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:107
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecDVecAddExpr.h:516
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecDVecAddExpr.h:536
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecDVecAddExpr.h:167
ReturnType_t< VT1 > RN1
Return type of the left-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:105
If_t< IsExpression_v< VT2 >, const VT2, const VT2 & > RightOperand
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecAddExpr.h:180
LeftOperand lhs_
Left-hand side dense vector of the addition expression.
Definition: DVecDVecAddExpr.h:599
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
SIMD characteristics of data types.
Definition: SIMDTrait.h:297
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 DenseVector base class.
Header file for the VecVecAddExpr base class.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
#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_FORM_VALID_VECVECADDEXPR(T1, T2)
Constraint on the data type.
Definition: VecVecAddExpr.h:104
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
typename AddTrait< T1, T2 >::Type AddTrait_t
Auxiliary alias declaration for the AddTrait class template.
Definition: AddTrait.h:163
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:1424
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
auto smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:221
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 smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
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
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition: IntegralConstant.h:110
#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
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
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.