35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECSCALARDIVEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SVECSCALARDIVEXPR_H_ 102 class SVecScalarDivExpr
103 :
public VecScalarDivExpr< SparseVector< SVecScalarDivExpr<VT,ST,TF>, TF > >
104 ,
private Computation
134 static constexpr
bool useAssign = RequiresEvaluation_v<VT>;
137 template<
typename VT2 >
139 static constexpr
bool UseAssign_v =
useAssign;
151 template<
typename VT2 >
152 static constexpr
bool UseSMPAssign_v =
343 if( index >=
vector_.size() ) {
346 return (*
this)[index];
375 inline size_t size() const noexcept {
452 template<
typename T >
453 inline bool canAlias(
const T* alias )
const noexcept {
454 return vector_.canAlias( alias );
464 template<
typename T >
465 inline bool isAliased(
const T* alias )
const noexcept {
466 return vector_.isAliased( alias );
490 template<
typename VT2 >
498 assign( ~lhs, rhs.vector_ );
499 (~lhs) /= rhs.scalar_;
518 template<
typename VT2 >
526 assign( ~lhs, rhs.vector_ );
527 (~lhs) /= rhs.scalar_;
546 template<
typename VT2 >
547 friend inline auto addAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarDivExpr& rhs )
548 -> EnableIf_t< UseAssign_v<VT2> >
559 addAssign( ~lhs, tmp );
582 template<
typename VT2 >
583 friend inline auto subAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarDivExpr& rhs )
584 -> EnableIf_t< UseAssign_v<VT2> >
595 subAssign( ~lhs, tmp );
618 template<
typename VT2 >
619 friend inline auto multAssign( DenseVector<VT2,TF>& lhs,
const SVecScalarDivExpr& rhs )
620 -> EnableIf_t< UseAssign_v<VT2> >
631 multAssign( ~lhs, tmp );
662 template<
typename VT2 >
664 -> EnableIf_t< UseSMPAssign_v<VT2> >
698 template<
typename VT2 >
700 -> EnableIf_t< UseSMPAssign_v<VT2> >
734 template<
typename VT2 >
736 -> EnableIf_t< UseSMPAssign_v<VT2> >
784 template<
typename VT
787 struct SVecScalarDivExprHelper
791 using ScalarType = If_t< IsFloatingPoint_v< UnderlyingBuiltin_t<VT> > ||
792 IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
793 , If_t< IsComplex_v< UnderlyingNumeric_t<VT> > && IsBuiltin_v<ST>
794 , DivTrait_t< UnderlyingBuiltin_t<VT>, ST >
795 , DivTrait_t< UnderlyingNumeric_t<VT>, ST > >
801 using Type = If_t< IsInvertible_v<ScalarType>
802 , SVecScalarMultExpr<VT,ScalarType,TF>
803 , SVecScalarDivExpr<VT,ScalarType,TF> >;
823 template<
typename VT
826 , DisableIf_t< IsZero_v<VT> >* =
nullptr >
827 inline const typename SVecScalarDivExprHelper<VT,ST,TF>::Type
828 svecscalardiv(
const SparseVector<VT,TF>& vec, ST scalar )
832 using ReturnType =
typename SVecScalarDivExprHelper<VT,ST,TF>::Type;
833 using ScalarType = RightOperand_t<ReturnType>;
835 if( IsMultExpr_v<ReturnType> ) {
836 return ReturnType( ~vec, ScalarType(1)/ScalarType(scalar) );
859 template<
typename VT
862 , EnableIf_t< IsZero_v<VT> >* =
nullptr >
863 inline decltype(
auto)
864 svecscalardiv( const SparseVector<VT,TF>& vec, ST scalar )
870 using ReturnType =
const DivTrait_t< ResultType_t<VT>, ST >;
904 template<
typename VT
907 , EnableIf_t< IsNumeric_v<ST> >* =
nullptr >
908 inline decltype(
auto) operator/( const
SparseVector<VT,TF>& vec, ST scalar )
914 return svecscalardiv( ~vec, scalar );
940 template<
typename VT
944 , EnableIf_t< IsNumeric_v<ST2> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* =
nullptr >
945 inline decltype(
auto) operator*( const SVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
949 return vec.leftOperand() * ( scalar / vec.rightOperand() );
968 template<
typename ST1
972 , EnableIf_t< IsNumeric_v<ST1> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* =
nullptr >
973 inline decltype(
auto) operator*( ST1 scalar, const SVecScalarDivExpr<VT,ST2,TF>& vec )
977 return vec.leftOperand() * ( scalar / vec.rightOperand() );
996 template<
typename VT
1000 , EnableIf_t< IsNumeric_v<ST2> >* =
nullptr >
1001 inline decltype(
auto) operator/( const SVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1007 using MultType = MultTrait_t<ST1,ST2>;
1008 using ReturnType =
typename SVecScalarDivExprHelper<VT,MultType,TF>::Type;
1009 using ScalarType = RightOperand_t<ReturnType>;
1011 if( IsMultExpr_v<ReturnType> ) {
1012 return ReturnType( vec.leftOperand(), ScalarType(1)/( vec.rightOperand() * scalar ) );
1015 return ReturnType( vec.leftOperand(), vec.rightOperand() * scalar );
Header file for the UnderlyingNumeric type trait.
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
Constraint on the data type.
ConstIterator(IteratorType vector, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SVecScalarDivExpr.h:213
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SVecScalarDivExpr.h:375
#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
Header file for basic type definitions.
Header file for the SparseVector base class.
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
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SVecScalarDivExpr.h:180
ResultType_t< VT > RT
Result type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:108
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.
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
size_t index() const
Access to the current index of the sparse element.
Definition: SVecScalarDivExpr.h:265
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
Header file for the VecScalarDivExpr base class.
Constraint on the data type.
ConstIterator end() const
Returns an iterator just past the last non-zero element of the sparse vector.
Definition: SVecScalarDivExpr.h:365
DivTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: SVecScalarDivExpr.h:161
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
IteratorCategory iterator_category
The iterator category.
Definition: SVecScalarDivExpr.h:203
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:191
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarDivExpr.h:245
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
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SVecScalarDivExpr.h:175
SVecScalarDivExpr(const VT &vector, ST scalar) noexcept
Constructor for the SVecScalarDivExpr class.
Definition: SVecScalarDivExpr.h:317
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecScalarDivExpr.h:298
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
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SVecScalarDivExpr.h:163
RightOperand scalar_
Right hand side scalar of the multiplication expression.
Definition: SVecScalarDivExpr.h:306
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: SVecScalarDivExpr.h:420
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecScalarDivExpr.h:200
Header file for the ValueIndexPair class.
Header file for the DisableIf class template.
Header file for the IsTemporary type trait class.
Element ValueType
Type of the underlying pointers.
Definition: SVecScalarDivExpr.h:197
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecScalarDivExpr.h:305
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is not a zero vector or matrix type...
Definition: Zero.h:61
Header file for the UnderlyingBuiltin type trait.
Header file for the IsMultExpr type trait class.
Iterator over the elements of the sparse vector/scalar multiplication expression. ...
Definition: SVecScalarDivExpr.h:186
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
ValueType * PointerType
Pointer return type.
Definition: SVecScalarDivExpr.h:198
Constraint on the data type.
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecScalarDivExpr.h:255
ValueType & ReferenceType
Reference return type.
Definition: SVecScalarDivExpr.h:199
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecScalarDivExpr.h:465
Header file for the exception macros of the math module.
decltype(std::declval< RN >()/std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: SVecScalarDivExpr.h:123
Constraint on the data type.
If_t< useAssign, const ResultType, const SVecScalarDivExpr &> CompositeType
Data type for composite expression templates.
Definition: SVecScalarDivExpr.h:169
Header file for all forward declarations for expression class templates.
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecScalarDivExpr.h:224
Constraint on the data type.
Header file for the EnableIf class template.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecScalarDivExpr.h:385
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: SVecScalarDivExpr.h:396
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SVecScalarDivExpr.h:473
Header file for the IsNumeric type trait.
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the multiplication expression.
Definition: SVecScalarDivExpr.h:134
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecScalarDivExpr.h:166
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecScalarDivExpr.h:453
ConstIterator begin() const
Returns an iterator to the first non-zero element of the sparse vector.
Definition: SVecScalarDivExpr.h:355
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarDivExpr.h:235
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecScalarDivExpr.h:196
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: SVecScalarDivExpr.h:441
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.
ReturnType_t< VT > RN
Return type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:109
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.
Constraint on the data type.
#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
Header file for the IsZero type trait.
If_t< IsExpression_v< VT >, const VT, const VT &> LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecScalarDivExpr.h:172
#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
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
ConstIterator_t< RemoveReference_t< LeftOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:194
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecScalarDivExpr.h:431
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
Expression object for divisions of a sparse vector by a scalar.The SVecScalarDivExpr class represents...
Definition: Forward.h:147
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecScalarDivExpr.h:162
LeftOperand vector_
Left-hand side sparse vector of the division expression.
Definition: SVecScalarDivExpr.h:472
Header file for the RemoveReference type trait.
Header file for the IsInvertible type trait.
#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
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: SVecScalarDivExpr.h:408
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecScalarDivExpr.h:276
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
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:138
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SVecScalarDivExpr.h:342
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: SVecScalarDivExpr.h:120
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecScalarDivExpr.h:287
Header file for the IsComplex type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is a zero vector or matrix type...
Definition: Zero.h:81
#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
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecScalarDivExpr.h:329
#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
CompositeType_t< VT > CT
Composite type of the sparse vector expression.
Definition: SVecScalarDivExpr.h:110
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
Header file for the IsExpression type trait class.
Header file for the function trace functionality.