35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECSCALARDIVEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DVECSCALARDIVEXPR_H_ 101 template<
typename VT
137 static constexpr
bool useAssign = IsComputation_v<VT> && RequiresEvaluation_v<VT>;
140 template<
typename VT2 >
142 static constexpr
bool UseAssign_v =
useAssign;
154 template<
typename VT2 >
155 static constexpr
bool UseSMPAssign_v =
298 inline auto load() const noexcept {
427 ( VT::simdEnabled && IsNumeric_v<ET> &&
428 ( HasSIMDDiv_v<ET,ST> || HasSIMDDiv_v<UnderlyingElement_t<ET>,ST> ) );
471 if( index >=
vector_.size() ) {
474 return (*
this)[index];
516 inline size_t size() const noexcept {
547 template<
typename T >
548 inline bool canAlias(
const T* alias )
const noexcept {
549 return IsExpression_v<VT> &&
vector_.canAlias( alias );
559 template<
typename T >
560 inline bool isAliased(
const T* alias )
const noexcept {
561 return vector_.isAliased( alias );
581 return vector_.canSMPAssign() || (
size() > SMP_DVECSCALARMULT_THRESHOLD );
605 template<
typename VT2 >
613 assign( ~lhs, rhs.vector_ );
614 assign( ~lhs, (~lhs) / rhs.scalar_ );
633 template<
typename VT2 >
641 assign( ~lhs, rhs.vector_ );
642 (~lhs) /= rhs.scalar_;
661 template<
typename VT2 >
662 friend inline auto addAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarDivExpr& rhs )
663 -> EnableIf_t< UseAssign_v<VT2> >
674 addAssign( ~lhs, tmp );
697 template<
typename VT2 >
698 friend inline auto subAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarDivExpr& rhs )
699 -> EnableIf_t< UseAssign_v<VT2> >
710 subAssign( ~lhs, tmp );
733 template<
typename VT2 >
734 friend inline auto multAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarDivExpr& rhs )
735 -> EnableIf_t< UseAssign_v<VT2> >
746 multAssign( ~lhs, tmp );
769 template<
typename VT2 >
770 friend inline auto divAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarDivExpr& rhs )
771 -> EnableIf_t< UseAssign_v<VT2> >
782 divAssign( ~lhs, tmp );
805 template<
typename VT2 >
807 -> EnableIf_t< UseSMPAssign_v<VT2> >
833 template<
typename VT2 >
835 -> EnableIf_t< UseSMPAssign_v<VT2> >
842 (~lhs) /= rhs.scalar_;
861 template<
typename VT2 >
863 -> EnableIf_t< UseSMPAssign_v<VT2> >
897 template<
typename VT2 >
899 -> EnableIf_t< UseSMPAssign_v<VT2> >
933 template<
typename VT2 >
935 -> EnableIf_t< UseSMPAssign_v<VT2> >
969 template<
typename VT2 >
971 -> EnableIf_t< UseSMPAssign_v<VT2> >
1018 template<
typename VT
1021 struct DVecScalarDivExprHelper
1025 using ScalarType = If_t< IsFloatingPoint_v< UnderlyingBuiltin_t<VT> > ||
1026 IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
1027 , If_t< IsComplex_v< UnderlyingNumeric_t<VT> > && IsBuiltin_v<ST>
1028 , DivTrait_t< UnderlyingBuiltin_t<VT>, ST >
1029 , DivTrait_t< UnderlyingNumeric_t<VT>, ST > >
1035 using Type = If_t< IsInvertible_v<ScalarType>
1036 , DVecScalarMultExpr<VT,ScalarType,TF>
1037 , DVecScalarDivExpr<VT,ScalarType,TF> >;
1068 template<
typename VT
1071 , EnableIf_t< IsNumeric_v<ST> >* =
nullptr >
1072 inline decltype(
auto) operator/( const
DenseVector<VT,TF>& vec, ST scalar )
1078 using ReturnType =
typename DVecScalarDivExprHelper<VT,ST,TF>::Type;
1081 if( IsMultExpr_v<ReturnType> ) {
1082 return ReturnType( ~vec, ScalarType(1)/ScalarType(scalar) );
1112 template<
typename VT
1116 , EnableIf_t< IsNumeric_v<ST2> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* =
nullptr >
1117 inline decltype(
auto) operator*( const DVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1121 return vec.leftOperand() * ( scalar / vec.rightOperand() );
1140 template<
typename ST1
1144 , EnableIf_t< IsNumeric_v<ST1> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* =
nullptr >
1145 inline decltype(
auto) operator*( ST1 scalar, const DVecScalarDivExpr<VT,ST2,TF>& vec )
1149 return vec.leftOperand() * ( scalar / vec.rightOperand() );
1168 template<
typename VT
1172 , EnableIf_t< IsNumeric_v<ST2> >* =
nullptr >
1173 inline decltype(
auto) operator/( const DVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1179 using MultType = MultTrait_t<ST1,ST2>;
1180 using ReturnType =
typename DVecScalarDivExprHelper<VT,MultType,TF>::Type;
1181 using ScalarType = RightOperand_t<ReturnType>;
1183 if( IsMultExpr_v<ReturnType> ) {
1184 return ReturnType( vec.leftOperand(), ScalarType(1)/( vec.rightOperand() * scalar ) );
1187 return ReturnType( vec.leftOperand(), vec.rightOperand() * scalar );
1204 template<
typename VT,
typename ST,
bool TF >
1205 struct IsAligned< DVecScalarDivExpr<VT,ST,TF> >
1206 :
public IsAligned<VT>
1222 template<
typename VT,
typename ST,
bool TF >
1223 struct IsPadded< DVecScalarDivExpr<VT,ST,TF> >
1224 :
public IsPadded<VT>
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: DVecScalarDivExpr.h:588
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:570
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, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
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:560
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DVecScalarDivExpr.h:426
Header file for basic type definitions.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DVecScalarDivExpr.h:166
RightOperand scalar_
Scalar of the division expression.
Definition: DVecScalarDivExpr.h:419
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:587
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:190
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecScalarDivExpr.h:169
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
Header file for the VecScalarDivExpr base class.
ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DVecScalarDivExpr.h:211
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecScalarDivExpr.h:188
Header file for the DenseVector base class.
PointerType pointer
Pointer return type.
Definition: DVecScalarDivExpr.h:197
DVecScalarDivExpr(const VT &vector, ST scalar) noexcept
Constructor for the DVecScalarDivExpr class.
Definition: DVecScalarDivExpr.h:445
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:178
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 & operator++()
Pre-increment operator.
Definition: DVecScalarDivExpr.h:246
ConstIterator_t< VT > IteratorType
ConstIterator type of the dense vector expression.
Definition: DVecScalarDivExpr.h:202
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecScalarDivExpr.h:399
const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecScalarDivExpr.h:257
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:526
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DVecScalarDivExpr.h:436
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:457
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:113
Iterator over the elements of the dense vector.
Definition: DVecScalarDivExpr.h:184
#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:375
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
ReferenceType reference
Reference return type.
Definition: DVecScalarDivExpr.h:198
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:484
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:110
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:137
ElementType ValueType
Type of the underlying elements.
Definition: DVecScalarDivExpr.h:189
Constraint on the data type.
Header file for the exception macros of the math module.
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecScalarDivExpr.h:223
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:342
IteratorType iterator_
Iterator to the current element.
Definition: DVecScalarDivExpr.h:418
Constraint on the data type.
Header file for all forward declarations for expression class templates.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:320
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecScalarDivExpr.h:192
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:175
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecScalarDivExpr.h:516
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecScalarDivExpr.h:298
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:112
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecScalarDivExpr.h:506
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:353
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:364
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DVecScalarDivExpr.h:123
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecScalarDivExpr.h:496
IteratorCategory iterator_category
The iterator category.
Definition: DVecScalarDivExpr.h:195
Constraint on the data type.
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: DVecScalarDivExpr.h:536
#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
ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecScalarDivExpr.h:267
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
DivTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: DVecScalarDivExpr.h:164
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecScalarDivExpr.h:411
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
Header file for the IsInvertible type trait.
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecScalarDivExpr.h:288
If_t< useAssign, const ResultType, const DVecScalarDivExpr &> CompositeType
Data type for composite expression templates.
Definition: DVecScalarDivExpr.h:172
#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
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecScalarDivExpr.h:165
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:104
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
#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
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecScalarDivExpr.h:235
Header file for the HasSIMDDiv type trait.
ReturnType_t< VT > RN
Return type of the dense vector expression.
Definition: DVecScalarDivExpr.h:111
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecScalarDivExpr.h:387
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecScalarDivExpr.h:470
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:548
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:138
decltype(std::declval< RN >()/std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DVecScalarDivExpr.h:126
ElementType & ReferenceType
Reference return type.
Definition: DVecScalarDivExpr.h:191
Header file for the IsComplex type trait.
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecScalarDivExpr.h:580
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecScalarDivExpr.h:278
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:309
typename T::RightOperand RightOperand_t
Alias declaration for nested RightOperand type definitions.The RightOperand_t alias declaration provi...
Definition: Aliases.h:430
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DVecScalarDivExpr.h:431
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, 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
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:331
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:196
Header file for the IsExpression type trait class.
Header file for the function trace functionality.