35#ifndef _BLAZE_MATH_EXPRESSIONS_DVECSCALARMULTEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DVECSCALARMULTEXPR_H_
137 static constexpr bool useAssign = ( IsComputation_v<VT> && RequiresEvaluation_v<VT> );
141 template<
typename VT2 >
142 static constexpr bool UseAssign_v =
useAssign;
154 template<
typename VT2 >
155 static constexpr bool UseSMPAssign_v =
156 ( ( !VT2::smpAssignable || !VT::smpAssignable ) &&
useAssign );
302 inline auto load() const noexcept {
431 ( VT::simdEnabled && IsNumeric_v<ET> &&
432 ( HasSIMDMult_v<ET,ST> || HasSIMDMult_v<UnderlyingElement_t<ET>,ST> ) );
475 if( index >=
vector_.size() ) {
478 return (*
this)[index];
520 inline size_t size() const noexcept {
551 template<
typename T >
552 inline bool canAlias(
const T* alias )
const noexcept {
553 return IsExpression_v<VT> &&
vector_.canAlias( alias );
563 template<
typename T >
564 inline bool isAliased(
const T* alias )
const noexcept {
565 return vector_.isAliased( alias );
585 return vector_.canSMPAssign() || (
size() > SMP_DVECSCALARMULT_THRESHOLD );
609 template<
typename VT2 >
617 assign( *lhs, rhs.vector_ );
618 assign( *lhs, (*lhs) * rhs.scalar_ );
637 template<
typename VT2 >
645 assign( *lhs, rhs.vector_ );
646 (*lhs) *= rhs.scalar_;
665 template<
typename VT2 >
666 friend inline auto addAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarMultExpr& rhs )
667 -> EnableIf_t< UseAssign_v<VT2> >
678 addAssign( *lhs, tmp );
701 template<
typename VT2 >
702 friend inline auto subAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarMultExpr& rhs )
703 -> EnableIf_t< UseAssign_v<VT2> >
714 subAssign( *lhs, tmp );
737 template<
typename VT2 >
738 friend inline auto multAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarMultExpr& rhs )
739 -> EnableIf_t< UseAssign_v<VT2> >
750 multAssign( *lhs, tmp );
773 template<
typename VT2 >
774 friend inline auto divAssign( DenseVector<VT2,TF>& lhs,
const DVecScalarMultExpr& rhs )
775 -> EnableIf_t< UseAssign_v<VT2> >
786 divAssign( *lhs, tmp );
809 template<
typename VT2 >
811 -> EnableIf_t< UseSMPAssign_v<VT2> >
837 template<
typename VT2 >
839 -> EnableIf_t< UseSMPAssign_v<VT2> >
846 (*lhs) *= rhs.scalar_;
865 template<
typename VT2 >
867 -> EnableIf_t< UseSMPAssign_v<VT2> >
901 template<
typename VT2 >
903 -> EnableIf_t< UseSMPAssign_v<VT2> >
937 template<
typename VT2 >
939 -> EnableIf_t< UseSMPAssign_v<VT2> >
973 template<
typename VT2 >
975 -> EnableIf_t< UseSMPAssign_v<VT2> >
1032template<
typename VT
1040 return ReturnType( *dv, ScalarType(-1) );
1075template<
typename VT
1078 , EnableIf_t< IsScalar_v<ST> >* =
nullptr >
1085 return ReturnType( *vec, scalar );
1112template<
typename ST
1115 , EnableIf_t< IsScalar_v<ST> >* =
nullptr >
1122 return ReturnType( *vec, scalar );
1153template<
typename VT
1159 const auto len (
l2Norm( *vec ) );
1160 auto ilen( !
isZero(len) ?
inv(len) : len );
1163 return ReturnType( *vec, ilen );
1178template<
typename VT,
typename ST,
bool TF >
1179struct IsAligned< DVecScalarMultExpr<VT,ST,TF> >
1180 :
public IsAligned<VT>
1196template<
typename VT,
typename ST,
bool TF >
1197struct IsPadded< DVecScalarMultExpr<VT,ST,TF> >
1198 :
public IsPadded<VT>
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.
decltype(auto) normalize(const DenseVector< VT, TF > &vec)
Normalization of the dense vector ( ).
Definition: DVecScalarMultExpr.h:1155
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the HasSIMDMult type trait.
Macro for CUDA compatibility.
Header file for the If class template.
Header file for the invert shim.
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 IsNumeric type trait.
Header file for the IsPadded type trait.
Header file for the IsScalar type trait.
Header file for the IsTemporary type trait class.
Deactivation of problematic macros.
Header file for the multiplication trait.
Header file for all SIMD functionality.
Constraint on the data type.
Header file for the UnderlyingBuiltin type trait.
Header file for the UnderlyingElement type trait.
Iterator over the elements of the dense vector.
Definition: DVecScalarMultExpr.h:189
ElementType ValueType
Type of the underlying elements.
Definition: DVecScalarMultExpr.h:193
IteratorCategory iterator_category
The iterator category.
Definition: DVecScalarMultExpr.h:199
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecScalarMultExpr.h:271
IteratorType iterator_
Iterator to the current element.
Definition: DVecScalarMultExpr.h:422
BLAZE_DEVICE_CALLABLE DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecScalarMultExpr.h:379
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecScalarMultExpr.h:196
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecScalarMultExpr.h:391
BLAZE_DEVICE_CALLABLE ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecScalarMultExpr.h:292
BLAZE_DEVICE_CALLABLE bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarMultExpr.h:357
DifferenceType difference_type
Difference between two iterators.
Definition: DVecScalarMultExpr.h:203
ElementType * PointerType
Pointer return type.
Definition: DVecScalarMultExpr.h:194
ConstIterator_t< VT > IteratorType
ConstIterator type of the dense vector expression.
Definition: DVecScalarMultExpr.h:206
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecScalarMultExpr.h:192
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DVecScalarMultExpr.h:250
BLAZE_DEVICE_CALLABLE bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecScalarMultExpr.h:313
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecScalarMultExpr.h:302
BLAZE_DEVICE_CALLABLE bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecScalarMultExpr.h:324
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecScalarMultExpr.h:282
RightOperand scalar_
Scalar of the multiplication expression.
Definition: DVecScalarMultExpr.h:423
BLAZE_DEVICE_CALLABLE bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarMultExpr.h:368
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecScalarMultExpr.h:261
ElementType & ReferenceType
Reference return type.
Definition: DVecScalarMultExpr.h:195
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecScalarMultExpr.h:403
BLAZE_DEVICE_CALLABLE bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarMultExpr.h:346
PointerType pointer
Pointer return type.
Definition: DVecScalarMultExpr.h:201
BLAZE_DEVICE_CALLABLE bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarMultExpr.h:335
ValueType value_type
Type of the underlying elements.
Definition: DVecScalarMultExpr.h:200
ReferenceType reference
Reference return type.
Definition: DVecScalarMultExpr.h:202
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecScalarMultExpr.h:227
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecScalarMultExpr.h:415
BLAZE_DEVICE_CALLABLE ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DVecScalarMultExpr.h:215
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecScalarMultExpr.h:239
Expression object for dense vector-scalar multiplications.
Definition: DVecScalarMultExpr.h:107
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecScalarMultExpr.h:500
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecScalarMultExpr.h:530
LeftOperand vector_
Left-hand side dense vector of the multiplication expression.
Definition: DVecScalarMultExpr.h:591
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DVecScalarMultExpr.h:430
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecScalarMultExpr.h:461
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecScalarMultExpr.h:520
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: DVecScalarMultExpr.h:540
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecScalarMultExpr.h:584
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecScalarMultExpr.h:510
ReturnType_t< VT > RN
Return type of the dense vector expression.
Definition: DVecScalarMultExpr.h:111
CompositeType_t< VT > CT
Composite type of the dense vector expression.
Definition: DVecScalarMultExpr.h:113
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecScalarMultExpr.h:169
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DVecScalarMultExpr.h:440
ResultType_t< VT > RT
Result type of the dense vector expression.
Definition: DVecScalarMultExpr.h:110
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecScalarMultExpr.h:474
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DVecScalarMultExpr.h:123
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecScalarMultExpr.h:552
If_t< useAssign, const ResultType, const DVecScalarMultExpr & > CompositeType
Data type for composite expression templates.
Definition: DVecScalarMultExpr.h:176
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecScalarMultExpr.h:488
If_t< IsExpression_v< VT >, const VT, const VT & > LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecScalarMultExpr.h:179
ElementType_t< VT > ET
Element type of the dense vector expression.
Definition: DVecScalarMultExpr.h:112
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DVecScalarMultExpr.h:170
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DVecScalarMultExpr.h:435
DVecScalarMultExpr(const VT &vector, ST scalar) noexcept
Constructor for the DVecScalarMultExpr class.
Definition: DVecScalarMultExpr.h:449
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: DVecScalarMultExpr.h:182
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecScalarMultExpr.h:574
MultTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: DVecScalarMultExpr.h:168
decltype(std::declval< RN >() *std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DVecScalarMultExpr.h:126
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecScalarMultExpr.h:564
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: DVecScalarMultExpr.h:592
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecScalarMultExpr.h:173
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the multiplication expression.
Definition: DVecScalarMultExpr.h:137
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.
Header file for the Computation base class.
Header file for the DenseMatrix base class.
Header file for the DenseVector base class.
Header file for the SparseMatrix base class.
Header file for the SparseVector base class.
Header file for the VecScalarMultExpr base class.
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE(A, B)
Data type constraint.
Definition: SameType.h:71
decltype(auto) l2Norm(const DenseMatrix< MT, SO > &dm)
Computes the L2 norm for the given dense matrix.
Definition: DMatNormExpr.h:651
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
decltype(auto) inv(const DenseMatrix< MT, SO > &dm)
Calculation of the inverse of the given dense matrix.
Definition: DMatInvExpr.h:405
bool isZero(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a zero matrix.
Definition: DenseMatrix.h:1819
#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_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition: Scalar.h:61
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.
Definition: MultTrait.h:165
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_t
Auxiliary alias declaration for the UnderlyingBuiltin type trait.
Definition: UnderlyingBuiltin.h:117
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
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
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
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#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 isZero shim.
Header file for the serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all vector/scalar multiplication expression templates.
Definition: VecScalarMultExpr.h:76
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.