35#ifndef _BLAZE_MATH_EXPRESSIONS_SVECSCALARMULTEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SVECSCALARMULTEXPR_H_
132 template<
typename VT2 >
133 static constexpr bool UseAssign_v =
useAssign;
145 template<
typename VT2 >
146 static constexpr bool UseSMPAssign_v =
147 ( ( !VT2::smpAssignable || !VT::smpAssignable ) &&
useAssign );
341 if( index >=
vector_.size() ) {
344 return (*
this)[index];
373 inline size_t size() const noexcept {
450 template<
typename T >
451 inline bool canAlias(
const T* alias )
const noexcept {
452 return vector_.canAlias( alias );
462 template<
typename T >
463 inline bool isAliased(
const T* alias )
const noexcept {
464 return vector_.isAliased( alias );
488 template<
typename VT2 >
496 assign( *lhs, rhs.vector_ );
497 (*lhs) *= rhs.scalar_;
516 template<
typename VT2 >
524 assign( *lhs, rhs.vector_ );
525 (*lhs) *= rhs.scalar_;
544 template<
typename VT2 >
545 friend inline auto addAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarMultExpr& rhs )
557 addAssign( *lhs, tmp );
580 template<
typename VT2 >
581 friend inline auto subAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarMultExpr& rhs )
593 subAssign( *lhs, tmp );
616 template<
typename VT2 >
617 friend inline auto multAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarMultExpr& rhs )
629 multAssign( *lhs, tmp );
660 template<
typename VT2 >
696 template<
typename VT2 >
732 template<
typename VT2 >
800 return ReturnType( *sv, ScalarType(-1) );
830inline const SVecScalarMultExpr< VT, MultTrait_t< UnderlyingBuiltin_t<VT>, ST >, TF >
831 svecscalarmult(
const SparseVector<VT,TF>& vec, ST scalar )
836 using ReturnType =
const SVecScalarMultExpr<VT,ScalarType,TF>;
837 return ReturnType( *vec, scalar );
872 return ReturnType( (*vec).size() );
907 return svecscalarmult( *vec, scalar );
941 return svecscalarmult( *vec, scalar );
978 const auto len (
length( *vec ) );
979 auto ilen( !
isZero(len) ?
inv(len) : len );
982 return ReturnType( *vec, ilen );
Header file for auxiliary alias declarations.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition Aliases.h:470
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.
Definition Aliases.h:130
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition Aliases.h:110
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition Aliases.h:550
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition Aliases.h:450
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 If class template.
Header file for the invert shim.
Header file for the IsExpression type trait class.
Header file for the IsScalar type trait.
Header file for the IsTemporary type trait class.
Deactivation of problematic macros.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Header file for the RemoveReference type trait.
Constraint on the data type.
Header file for the UnderlyingBuiltin type trait.
Header file for the ValueIndexPair class.
Constraint on the data type.
Base class for N-dimensional dense vectors.
Definition DenseVector.h:77
Iterator over the elements of the sparse vector/scalar multiplication expression.
Definition SVecScalarMultExpr.h:185
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition SVecScalarMultExpr.h:303
ptrdiff_t DifferenceType
Difference between two iterators.
Definition SVecScalarMultExpr.h:198
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition SVecScalarMultExpr.h:233
ReferenceType reference
Reference return type.
Definition SVecScalarMultExpr.h:204
ReturnType value() const
Access to the current value of the sparse element.
Definition SVecScalarMultExpr.h:253
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition SVecScalarMultExpr.h:194
ValueType value_type
Type of the underlying pointers.
Definition SVecScalarMultExpr.h:202
PointerType pointer
Pointer return type.
Definition SVecScalarMultExpr.h:203
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition SVecScalarMultExpr.h:189
ValueType & ReferenceType
Reference return type.
Definition SVecScalarMultExpr.h:197
ValueType * PointerType
Pointer return type.
Definition SVecScalarMultExpr.h:196
IteratorCategory iterator_category
The iterator category.
Definition SVecScalarMultExpr.h:201
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition SVecScalarMultExpr.h:304
ConstIterator(IteratorType vector, RightOperand scalar)
Constructor for the ConstIterator class.
Definition SVecScalarMultExpr.h:211
DifferenceType difference_type
Difference between two iterators.
Definition SVecScalarMultExpr.h:205
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition SVecScalarMultExpr.h:285
Element ValueType
Type of the underlying pointers.
Definition SVecScalarMultExpr.h:195
ConstIterator & operator++()
Pre-increment operator.
Definition SVecScalarMultExpr.h:222
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition SVecScalarMultExpr.h:274
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition SVecScalarMultExpr.h:243
ConstIterator_t< RemoveReference_t< LeftOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition SVecScalarMultExpr.h:192
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition SVecScalarMultExpr.h:296
size_t index() const
Access to the current index of the sparse element.
Definition SVecScalarMultExpr.h:263
Expression object for sparse vector-scalar multiplications.
Definition SVecScalarMultExpr.h:99
ResultType_t< VT > RT
Result type of the sparse vector expression.
Definition SVecScalarMultExpr.h:102
VecScalarMultExpr< SparseVector< This, TF > > BaseType
Base type of this SVecScalarMultExpr instance.
Definition SVecScalarMultExpr.h:157
CompositeType_t< VT > CT
Composite type of the sparse vector expression.
Definition SVecScalarMultExpr.h:104
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition SVecScalarMultExpr.h:471
decltype(std::declval< RN >() *std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition SVecScalarMultExpr.h:117
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition SVecScalarMultExpr.h:327
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition SVecScalarMultExpr.h:383
ST RightOperand
Composite type of the right-hand side scalar value.
Definition SVecScalarMultExpr.h:173
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the multiplication expression.
Definition SVecScalarMultExpr.h:128
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition SVecScalarMultExpr.h:373
ConstIterator begin() const
Returns an iterator to the first non-zero element of the sparse vector.
Definition SVecScalarMultExpr.h:353
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition SVecScalarMultExpr.h:340
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition SVecScalarMultExpr.h:394
SVecScalarMultExpr(const VT &vector, ST scalar) noexcept
Constructor for the SVecScalarMultExpr class.
Definition SVecScalarMultExpr.h:315
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition SVecScalarMultExpr.h:164
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition SVecScalarMultExpr.h:429
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition SVecScalarMultExpr.h:451
ReturnType_t< VT > RN
Return type of the sparse vector expression.
Definition SVecScalarMultExpr.h:103
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition SVecScalarMultExpr.h:406
ElementType_t< ResultType > ElementType
Resulting element type.
Definition SVecScalarMultExpr.h:161
LeftOperand vector_
Left-hand side sparse vector of the multiplication expression.
Definition SVecScalarMultExpr.h:470
MultTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition SVecScalarMultExpr.h:159
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition SVecScalarMultExpr.h:160
SVecScalarMultExpr< VT, ST, TF > This
Type of this SVecScalarMultExpr instance.
Definition SVecScalarMultExpr.h:154
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition SVecScalarMultExpr.h:439
ConstIterator end() const
Returns an iterator just past the last non-zero element of the sparse vector.
Definition SVecScalarMultExpr.h:363
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition SVecScalarMultExpr.h:463
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition SVecScalarMultExpr.h:178
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition SVecScalarMultExpr.h:418
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition SVecScalarMultExpr.h:114
If_t< IsExpression_v< VT >, const VT, const VT & > LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition SVecScalarMultExpr.h:170
If_t< useAssign, const ResultType, const SVecScalarMultExpr & > CompositeType
Data type for composite expression templates.
Definition SVecScalarMultExpr.h:167
Base class for sparse vectors.
Definition SparseVector.h:72
Index-value-pair for sparse vectors and matrices.
Definition ValueIndexPair.h:75
Pointer difference type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation 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) 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
decltype(auto) length(const DenseVector< VT, TF > &dv)
Calculation of the length (magnitude) of the dense vector .
Definition DVecNormExpr.h:654
#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_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition SparseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition Scalar.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:61
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.
Definition MultTrait.h:165
constexpr bool RequiresEvaluation_v
Auxiliary variable template for the RequiresEvaluation type trait.
Definition RequiresEvaluation.h:91
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_t
Auxiliary alias declaration for the UnderlyingBuiltin type trait.
Definition UnderlyingBuiltin.h:117
constexpr bool IsTemporary_v
Auxiliary variable template for the IsTemporary type trait.
Definition IsTemporary.h:88
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
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 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
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
#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
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:175
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
Header file for the IsZero type trait.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.