35#ifndef _BLAZE_MATH_EXPRESSIONS_SVECSCALARDIVEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SVECSCALARDIVEXPR_H_
101 :
public VecScalarDivExpr< SparseVector< SVecScalarDivExpr<VT,ST,TF>, TF > >
132 static constexpr bool useAssign = RequiresEvaluation_v<VT>;
136 template<
typename VT2 >
137 static constexpr bool UseAssign_v =
useAssign;
149 template<
typename VT2 >
150 static constexpr bool UseSMPAssign_v =
151 ( ( !VT2::smpAssignable || !VT::smpAssignable ) &&
useAssign );
345 if( index >=
vector_.size() ) {
348 return (*
this)[index];
377 inline size_t size() const noexcept {
454 template<
typename T >
455 inline bool canAlias(
const T* alias )
const noexcept {
456 return vector_.canAlias( alias );
466 template<
typename T >
467 inline bool isAliased(
const T* alias )
const noexcept {
468 return vector_.isAliased( alias );
492 template<
typename VT2 >
500 assign( *lhs, rhs.vector_ );
501 (*lhs) /= rhs.scalar_;
520 template<
typename VT2 >
528 assign( *lhs, rhs.vector_ );
529 (*lhs) /= rhs.scalar_;
548 template<
typename VT2 >
549 friend inline auto addAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarDivExpr& rhs )
550 -> EnableIf_t< UseAssign_v<VT2> >
561 addAssign( *lhs, tmp );
584 template<
typename VT2 >
585 friend inline auto subAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarDivExpr& rhs )
586 -> EnableIf_t< UseAssign_v<VT2> >
597 subAssign( *lhs, tmp );
620 template<
typename VT2 >
621 friend inline auto multAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarDivExpr& rhs )
622 -> EnableIf_t< UseAssign_v<VT2> >
633 multAssign( *lhs, tmp );
664 template<
typename VT2 >
666 -> EnableIf_t< UseSMPAssign_v<VT2> >
700 template<
typename VT2 >
702 -> EnableIf_t< UseSMPAssign_v<VT2> >
736 template<
typename VT2 >
738 -> EnableIf_t< UseSMPAssign_v<VT2> >
788using SVecScalarDivExprHelper_t =
789 If_t< IsFloatingPoint_v< UnderlyingBuiltin_t<VT> > ||
790 IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
791 , If_t< IsBuiltin_v<ST>
792 , DivTrait_t< UnderlyingBuiltin_t<VT>, ST >
793 ,
decltype(
inv( std::declval<ST>() ) ) >
814 , EnableIf_t< !IsZero_v<VT> &&
815 !IsInvertible_v< SVecScalarDivExprHelper_t<VT,ST> > >* =
nullptr >
816inline decltype(
auto) svecscalardiv(
const SparseVector<VT,TF>& vec, ST scalar )
820 using ScalarType = SVecScalarDivExprHelper_t<VT,ST>;
821 using ReturnType =
const SVecScalarDivExpr<VT,ScalarType,TF>;
823 return ReturnType( *vec, scalar );
844 , EnableIf_t< !IsZero_v<VT> &&
845 IsInvertible_v< SVecScalarDivExprHelper_t<VT,ST> > >* =
nullptr >
846inline decltype(
auto) svecscalardiv(
const SparseVector<VT,TF>& vec, ST scalar )
850 using ScalarType = SVecScalarDivExprHelper_t<VT,ST>;
851 using ReturnType =
const SVecScalarMultExpr<VT,ScalarType,TF>;
853 return ReturnType( *vec,
inv(scalar) );
875 , EnableIf_t< IsZero_v<VT> >* =
nullptr >
876inline decltype(
auto) svecscalardiv(
const SparseVector<VT,TF>& vec, ST scalar )
882 using ReturnType =
const DivTrait_t< ResultType_t<VT>, ST >;
887 return ReturnType( (*vec).size() );
919 , EnableIf_t< IsScalar_v<ST> >* =
nullptr >
926 return svecscalardiv( *vec, scalar );
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.
Header file for the division trait.
Header file for the EnableIf class template.
Constraint on the data type.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the invert shim.
Header file for the IsBuiltin type trait.
Header file for the IsExpression type trait class.
Header file for the IsFloatingPoint type trait.
Header file for the IsInvertible 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 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: SVecScalarDivExpr.h:189
ValueType & ReferenceType
Reference return type.
Definition: SVecScalarDivExpr.h:201
ValueType * PointerType
Pointer return type.
Definition: SVecScalarDivExpr.h:200
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecScalarDivExpr.h:278
IteratorCategory iterator_category
The iterator category.
Definition: SVecScalarDivExpr.h:205
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecScalarDivExpr.h:289
Element ValueType
Type of the underlying pointers.
Definition: SVecScalarDivExpr.h:199
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecScalarDivExpr.h:226
ConstIterator_t< RemoveReference_t< LeftOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:196
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecScalarDivExpr.h:198
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecScalarDivExpr.h:307
DifferenceType difference_type
Difference between two iterators.
Definition: SVecScalarDivExpr.h:209
ConstIterator(IteratorType vector, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SVecScalarDivExpr.h:215
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarDivExpr.h:237
size_t index() const
Access to the current index of the sparse element.
Definition: SVecScalarDivExpr.h:267
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:193
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarDivExpr.h:247
RightOperand scalar_
Right hand side scalar of the multiplication expression.
Definition: SVecScalarDivExpr.h:308
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecScalarDivExpr.h:300
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecScalarDivExpr.h:257
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecScalarDivExpr.h:202
Expression object for divisions of a sparse vector by a scalar.
Definition: SVecScalarDivExpr.h:103
If_t< IsExpression_v< VT >, const VT, const VT & > LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecScalarDivExpr.h:174
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecScalarDivExpr.h:433
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecScalarDivExpr.h:455
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SVecScalarDivExpr.h:165
LeftOperand vector_
Left-hand side sparse vector of the division expression.
Definition: SVecScalarDivExpr.h:474
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: SVecScalarDivExpr.h:443
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the multiplication expression.
Definition: SVecScalarDivExpr.h:132
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: SVecScalarDivExpr.h:410
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SVecScalarDivExpr.h:344
ConstIterator begin() const
Returns an iterator to the first non-zero element of the sparse vector.
Definition: SVecScalarDivExpr.h:357
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SVecScalarDivExpr.h:177
SVecScalarDivExpr(const VT &vector, ST scalar) noexcept
Constructor for the SVecScalarDivExpr class.
Definition: SVecScalarDivExpr.h:319
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecScalarDivExpr.h:168
ResultType_t< VT > RT
Result type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:106
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SVecScalarDivExpr.h:475
CompositeType_t< VT > CT
Composite type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:108
DivTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: SVecScalarDivExpr.h:163
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: SVecScalarDivExpr.h:398
decltype(std::declval< RN >()/std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: SVecScalarDivExpr.h:121
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SVecScalarDivExpr.h:377
If_t< useAssign, const ResultType, const SVecScalarDivExpr & > CompositeType
Data type for composite expression templates.
Definition: SVecScalarDivExpr.h:171
ReturnType_t< VT > RN
Return type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:107
ConstIterator end() const
Returns an iterator just past the last non-zero element of the sparse vector.
Definition: SVecScalarDivExpr.h:367
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: SVecScalarDivExpr.h:118
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SVecScalarDivExpr.h:182
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecScalarDivExpr.h:164
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecScalarDivExpr.h:387
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: SVecScalarDivExpr.h:422
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecScalarDivExpr.h:331
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecScalarDivExpr.h:467
Base class for sparse vectors.
Definition: SparseVector.h:72
Index-value-pair for sparse vectors and matrices.
Definition: ValueIndexPair.h:75
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 VecScalarDivExpr base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.
Definition: FloatingPoint.h:81
#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
#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 DivTrait< T1, T2 >::Type DivTrait_t
Auxiliary alias declaration for the DivTrait class template.
Definition: DivTrait.h:164
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
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
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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 serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all vector/scalar division expression templates.
Definition: VecScalarDivExpr.h:75
Header file for the IsZero type trait.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.