35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECSCALARDIVEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DVECSCALARDIVEXPR_H_ 102 template<
typename VT
138 static constexpr
bool useAssign = IsComputation_v<VT> && RequiresEvaluation_v<VT>;
141 template<
typename VT2 >
143 static constexpr
bool UseAssign_v =
useAssign;
155 template<
typename VT2 >
156 static constexpr
bool UseSMPAssign_v =
157 ( ( !VT2::smpAssignable || !VT::smpAssignable ) &&
useAssign );
299 inline auto load() const noexcept {
428 ( VT::simdEnabled && IsNumeric_v<ET> &&
429 ( HasSIMDDiv_v<ET,ST> || HasSIMDDiv_v<UnderlyingElement_t<ET>,ST> ) );
472 if( index >=
vector_.size() ) {
475 return (*
this)[index];
517 inline size_t size() const noexcept {
548 template<
typename T >
549 inline bool canAlias(
const T* alias )
const noexcept {
550 return IsExpression_v<VT> &&
vector_.canAlias( alias );
560 template<
typename T >
561 inline bool isAliased(
const T* alias )
const noexcept {
562 return vector_.isAliased( alias );
582 return vector_.canSMPAssign() || (
size() > SMP_DVECSCALARMULT_THRESHOLD );
606 template<
typename VT2 >
614 assign( ~lhs, rhs.vector_ );
615 assign( ~lhs, (~lhs) / rhs.scalar_ );
634 template<
typename VT2 >
642 assign( ~lhs, rhs.vector_ );
643 (~lhs) /= rhs.scalar_;
662 template<
typename VT2 >
663 friend inline auto addAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarDivExpr& rhs )
664 -> EnableIf_t< UseAssign_v<VT2> >
675 addAssign( ~lhs, tmp );
698 template<
typename VT2 >
699 friend inline auto subAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarDivExpr& rhs )
700 -> EnableIf_t< UseAssign_v<VT2> >
711 subAssign( ~lhs, tmp );
734 template<
typename VT2 >
735 friend inline auto multAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarDivExpr& rhs )
736 -> EnableIf_t< UseAssign_v<VT2> >
747 multAssign( ~lhs, tmp );
770 template<
typename VT2 >
771 friend inline auto divAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarDivExpr& rhs )
772 -> EnableIf_t< UseAssign_v<VT2> >
783 divAssign( ~lhs, tmp );
806 template<
typename VT2 >
808 -> EnableIf_t< UseSMPAssign_v<VT2> >
834 template<
typename VT2 >
836 -> EnableIf_t< UseSMPAssign_v<VT2> >
843 (~lhs) /= rhs.scalar_;
862 template<
typename VT2 >
864 -> EnableIf_t< UseSMPAssign_v<VT2> >
898 template<
typename VT2 >
900 -> EnableIf_t< UseSMPAssign_v<VT2> >
934 template<
typename VT2 >
936 -> EnableIf_t< UseSMPAssign_v<VT2> >
970 template<
typename VT2 >
972 -> EnableIf_t< UseSMPAssign_v<VT2> >
1019 template<
typename VT
1022 struct DVecScalarDivExprHelper
1026 using ScalarType = If_t< IsFloatingPoint_v< UnderlyingBuiltin_t<VT> > ||
1027 IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
1028 , If_t< IsComplex_v< UnderlyingNumeric_t<VT> > && IsBuiltin_v<ST>
1029 , DivTrait_t< UnderlyingBuiltin_t<VT>, ST >
1030 , DivTrait_t< UnderlyingNumeric_t<VT>, ST > >
1036 using Type = If_t< IsInvertible_v<ScalarType>
1037 , DVecScalarMultExpr<VT,ScalarType,TF>
1038 , DVecScalarDivExpr<VT,ScalarType,TF> >;
1069 template<
typename VT
1072 , EnableIf_t< IsNumeric_v<ST> >* =
nullptr >
1073 inline decltype(
auto) operator/( const
DenseVector<VT,TF>& vec, ST scalar )
1079 using ReturnType =
typename DVecScalarDivExprHelper<VT,ST,TF>::Type;
1082 if( IsMultExpr_v<ReturnType> ) {
1083 return ReturnType( ~vec, ScalarType(1)/ScalarType(scalar) );
1086 return ReturnType( ~vec, scalar );
1113 template<
typename VT
1117 , EnableIf_t< IsNumeric_v<ST2> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* =
nullptr >
1118 inline decltype(
auto) operator*( const DVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1122 return vec.leftOperand() * ( scalar / vec.rightOperand() );
1141 template<
typename ST1
1145 , EnableIf_t< IsNumeric_v<ST1> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* =
nullptr >
1146 inline decltype(
auto) operator*( ST1 scalar, const DVecScalarDivExpr<VT,ST2,TF>& vec )
1150 return vec.leftOperand() * ( scalar / vec.rightOperand() );
1169 template<
typename VT
1173 , EnableIf_t< IsNumeric_v<ST2> >* =
nullptr >
1174 inline decltype(
auto) operator/( const DVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1180 using MultType = MultTrait_t<ST1,ST2>;
1181 using ReturnType =
typename DVecScalarDivExprHelper<VT,MultType,TF>::Type;
1182 using ScalarType = RightOperand_t<ReturnType>;
1184 if( IsMultExpr_v<ReturnType> ) {
1185 return ReturnType( vec.leftOperand(), ScalarType(1)/( vec.rightOperand() * scalar ) );
1188 return ReturnType( vec.leftOperand(), vec.rightOperand() * scalar );
1205 template<
typename VT,
typename ST,
bool TF >
1206 struct IsAligned< DVecScalarDivExpr<VT,ST,TF> >
1207 :
public IsAligned<VT>
1223 template<
typename VT,
typename ST,
bool TF >
1224 struct IsPadded< DVecScalarDivExpr<VT,ST,TF> >
1225 :
public IsPadded<VT>
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: DVecScalarDivExpr.h:589
Header file for the UnderlyingNumeric type trait.
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecScalarDivExpr.h:571
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecScalarDivExpr.h:561
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DVecScalarDivExpr.h:427
Header file for basic type definitions.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
Definition: If.h:109
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DVecScalarDivExpr.h:167
RightOperand scalar_
Scalar of the division expression.
Definition: DVecScalarDivExpr.h:420
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the serial shim.
LeftOperand vector_
Left-hand side dense vector of the division expression.
Definition: DVecScalarDivExpr.h:588
typename DivTrait< T1, T2 >::Type DivTrait_t
Auxiliary alias declaration for the DivTrait class template.The DivTrait_t alias declaration provides...
Definition: DivTrait.h:239
ElementType * PointerType
Pointer return type.
Definition: DVecScalarDivExpr.h:191
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecScalarDivExpr.h:170
Header file for the VecScalarDivExpr base class.
ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DVecScalarDivExpr.h:212
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecScalarDivExpr.h:189
Header file for the DenseVector base class.
PointerType pointer
Pointer return type.
Definition: DVecScalarDivExpr.h:198
DVecScalarDivExpr(const VT &vector, ST scalar) noexcept
Constructor for the DVecScalarDivExpr class.
Definition: DVecScalarDivExpr.h:446
Header file for the Computation base class.
Header file for the UnderlyingElement type trait.
Header file for the RequiresEvaluation type trait.
Base class for all vector/scalar division expression templates.The VecScalarDivExpr class serves as a...
Definition: VecScalarDivExpr.h:66
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: DVecScalarDivExpr.h:179
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
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:220
ConstIterator_t< VT > IteratorType
ConstIterator type of the dense vector expression.
Definition: DVecScalarDivExpr.h:203
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecScalarDivExpr.h:400
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecScalarDivExpr.h:527
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DVecScalarDivExpr.h:437
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecScalarDivExpr.h:458
Header file for the UnderlyingBuiltin type trait.
Header file for the IsMultExpr type trait class.
CompositeType_t< VT > CT
Composite type of the dense vector expression.
Definition: DVecScalarDivExpr.h:114
Iterator over the elements of the dense vector.
Definition: DVecScalarDivExpr.h:185
#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
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecScalarDivExpr.h:376
ReferenceType reference
Reference return type.
Definition: DVecScalarDivExpr.h:199
Header file for all SIMD functionality.
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecScalarDivExpr.h:485
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE(A, B)
Data type constraint.In case the two types A and B are not the same (ignoring all cv-qualifiers of bo...
Definition: SameType.h:71
ResultType_t< VT > RT
Result type of the dense vector expression.
Definition: DVecScalarDivExpr.h:111
Header file for the IsAligned type trait.
Constraint on the data type.
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the division expression.
Definition: DVecScalarDivExpr.h:138
ElementType ValueType
Type of the underlying elements.
Definition: DVecScalarDivExpr.h:190
ReturnType operator *() const
Direct access to the element at the current iterator position.
Definition: DVecScalarDivExpr.h:289
Constraint on the data type.
Header file for the exception macros of the math module.
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:343
IteratorType iterator_
Iterator to the current element.
Definition: DVecScalarDivExpr.h:419
Constraint on the data type.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:321
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecScalarDivExpr.h:193
Header file for the IsNumeric type trait.
If_t< IsExpression_v< VT >, const VT, const VT & > LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecScalarDivExpr.h:176
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecScalarDivExpr.h:517
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecScalarDivExpr.h:299
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
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
Header file for the division trait.
ElementType_t< VT > ET
Element type of the dense vector expression.
Definition: DVecScalarDivExpr.h:113
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecScalarDivExpr.h:507
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:354
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:365
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DVecScalarDivExpr.h:124
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecScalarDivExpr.h:497
IteratorCategory iterator_category
The iterator category.
Definition: DVecScalarDivExpr.h:196
Constraint on the data type.
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: DVecScalarDivExpr.h:537
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecScalarDivExpr.h:258
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:61
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for all forward declarations for expression class templates.
DivTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: DVecScalarDivExpr.h:165
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecScalarDivExpr.h:412
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
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
#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:81
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DVecScalarDivExpr.h:247
Header file for the IsInvertible type trait.
If_t< useAssign, const ResultType, const DVecScalarDivExpr & > CompositeType
Data type for composite expression templates.
Definition: DVecScalarDivExpr.h:173
#define BLAZE_CONSTRAINT_MUST_NOT_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.In case the given data type T is a floating point data type,...
Definition: FloatingPoint.h:81
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecScalarDivExpr.h:279
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecScalarDivExpr.h:166
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
Expression object for divisions of a dense vector by a scalar.The DVecScalarDivExpr class represents ...
Definition: DVecScalarDivExpr.h:105
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecScalarDivExpr.h:268
#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
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecScalarDivExpr.h:236
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecScalarDivExpr.h:224
Macro for CUDA compatibility.
Header file for the HasSIMDDiv type trait.
ReturnType_t< VT > RN
Return type of the dense vector expression.
Definition: DVecScalarDivExpr.h:112
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecScalarDivExpr.h:388
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecScalarDivExpr.h:471
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
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
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecScalarDivExpr.h:549
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:146
decltype(std::declval< RN >()/std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DVecScalarDivExpr.h:127
ElementType & ReferenceType
Reference return type.
Definition: DVecScalarDivExpr.h:192
Header file for the IsComplex type trait.
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecScalarDivExpr.h:581
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:310
typename T::RightOperand RightOperand_t
Alias declaration for nested RightOperand type definitions.The RightOperand_t alias declaration provi...
Definition: Aliases.h:430
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DVecScalarDivExpr.h:432
System settings for the inline keywords.
#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.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:332
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:191
ValueType value_type
Type of the underlying elements.
Definition: DVecScalarDivExpr.h:197
Header file for the IsExpression type trait class.
Header file for the function trace functionality.