35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECSCALARMULTEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SVECSCALARMULTEXPR_H_ 96 class SVecScalarMultExpr
97 :
public VecScalarMultExpr< SparseVector< SVecScalarMultExpr<VT,ST,TF>, TF > >
131 template<
typename VT2 >
134 enum :
bool { value = useAssign };
147 template<
typename VT2 >
148 struct UseSMPAssign {
149 enum :
bool { value = ( !VT2::smpAssignable || !VT::smpAssignable ) && useAssign };
176 enum :
bool { smpAssignable =
false };
339 if( index >=
vector_.size() ) {
342 return (*
this)[index];
371 inline size_t size() const noexcept {
448 template<
typename T >
449 inline bool canAlias(
const T* alias )
const noexcept {
450 return vector_.canAlias( alias );
460 template<
typename T >
461 inline bool isAliased(
const T* alias )
const noexcept {
462 return vector_.isAliased( alias );
486 template<
typename VT2 >
494 assign( ~lhs, rhs.vector_ );
495 (~lhs) *= rhs.scalar_;
514 template<
typename VT2 >
522 assign( ~lhs, rhs.vector_ );
523 (~lhs) *= rhs.scalar_;
542 template<
typename VT2 >
543 friend inline EnableIf_< UseAssign<VT2> >
555 addAssign( ~lhs, tmp );
578 template<
typename VT2 >
579 friend inline EnableIf_< UseAssign<VT2> >
591 subAssign( ~lhs, tmp );
614 template<
typename VT2 >
615 friend inline EnableIf_< UseAssign<VT2> >
627 multAssign( ~lhs, tmp );
658 template<
typename VT2 >
659 friend inline EnableIf_< UseSMPAssign<VT2> >
694 template<
typename VT2 >
695 friend inline EnableIf_< UseSMPAssign<VT2> >
730 template<
typename VT2 >
731 friend inline EnableIf_< UseSMPAssign<VT2> >
789 template<
typename VT
831 template<
typename VT
835 inline decltype(
auto) operator*( const
SparseVector<VT,TF>& vec, ST scalar )
867 template<
typename ST
871 inline decltype(
auto) operator*( ST scalar, const
SparseVector<VT,TF>& vec )
908 template<
typename VT
945 template<
typename VT
953 return ReturnType( sv.leftOperand(), -sv.rightOperand() );
980 template<
typename VT
989 return vec.leftOperand() * ( vec.rightOperand() * scalar );
1008 template<
typename ST1
1017 return vec.leftOperand() * ( scalar * vec.rightOperand() );
1036 template<
typename VT
1045 return vec.leftOperand() * ( vec.rightOperand() / scalar );
1065 template<
typename VT1
1069 inline decltype(
auto)
1074 return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1094 template<
typename VT1
1098 inline decltype(
auto)
1103 return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1123 template<
typename VT1
1126 inline decltype(
auto)
1131 return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1151 template<
typename VT1
1154 inline decltype(
auto)
1159 return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1179 template<
typename VT1
1183 inline decltype(
auto)
1188 return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1208 template<
typename VT1
1212 inline decltype(
auto)
1217 return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1237 template<
typename VT1
1242 inline decltype(
auto)
1247 return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1267 template<
typename VT1
1270 inline decltype(
auto)
1275 return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1295 template<
typename VT1
1298 inline decltype(
auto)
1303 return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1323 template<
typename VT1
1327 inline decltype(
auto)
1332 return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1352 template<
typename MT
1356 inline decltype(
auto)
1361 return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1381 template<
typename VT
1385 inline decltype(
auto)
1390 return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1410 template<
typename MT
1414 inline decltype(
auto)
1419 return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1439 template<
typename VT
1443 inline decltype(
auto)
1448 return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1464 template<
typename VT,
typename ST,
bool TF >
1465 struct Size< SVecScalarMultExpr<VT,ST,TF>, 0UL >
1466 :
public Size<VT,0UL>
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: SVecScalarMultExpr.h:437
Pointer difference type of the Blaze library.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecScalarMultExpr.h:381
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:272
Header file for auxiliary alias declarations.
Constraint on the data type.
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:69
Header file for basic type definitions.
Header file for the SparseVector base class.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:283
ResultType_< VT > RT
Result type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:102
decltype(auto) operator/(const DenseMatrix< MT, SO > &mat, ST scalar)
Division operator for the division of a dense matrix by a scalar value ( ).
Definition: DMatScalarDivExpr.h:1070
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:164
Header file for the serial shim.
IteratorCategory iterator_category
The iterator category.
Definition: SVecScalarMultExpr.h:199
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecScalarMultExpr.h:294
ConstIterator begin() const
Returns an iterator to the first non-zero element of the sparse vector.
Definition: SVecScalarMultExpr.h:351
MultExprTrait_< RN, ST > ExprReturnType
Expression return type for the subscript operator.
Definition: SVecScalarMultExpr.h:117
EnableIf_< IsDenseVector< VT1 > > smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:193
Header file for the And class template.
Iterator over the elements of the sparse vector/scalar multiplication expression. ...
Definition: SVecScalarMultExpr.h:182
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Header file for the Computation base class.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:733
Header file for the RequiresEvaluation type trait.
Header file for the VecScalarMultExpr base class.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecScalarMultExpr.h:192
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_
Auxiliary alias declaration for the UnderlyingBuiltin type trait.The UnderlyingBuiltin_ alias declara...
Definition: UnderlyingBuiltin.h:133
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecScalarMultExpr.h:220
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
auto length(const DenseVector< VT, TF > &dv) -> decltype(sqrt(sqrLength(~dv)))
Calculation of the length (magnitude) of the dense vector .
Definition: DenseVector.h:714
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:231
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:469
typename MultExprTrait< T1, T2 >::Type MultExprTrait_
Auxiliary alias declaration for the MultExprTrait class template.The MultExprTrait_ alias declaration...
Definition: MultExprTrait.h:112
Header file for the MultExprTrait class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:71
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Header file for the ValueIndexPair class.
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
Header file for the If class template.
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:302
Header file for the UnderlyingBuiltin type trait.
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
Header file for the Or class template.
#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
ReturnType_< VT > RN
Return type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:103
decltype(auto) normalize(const DenseVector< VT, TF > &vec)
Normalization of the dense vector ( ).
Definition: DVecScalarMultExpr.h:1154
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecScalarMultExpr.h:461
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecScalarMultExpr.h:162
#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
Constraint on the data type.
Header file for the exception macros of the math module.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecScalarMultExpr.h:325
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8893
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:241
ConstIterator_< RemoveReference_< LeftOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:190
Header file for the EnableIf class template.
Header file for the IsNumeric type trait.
Header file for run time assertion macros.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecScalarMultExpr.h:158
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:301
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: SVecScalarMultExpr.h:404
ConstIterator end() const
Returns an iterator just past the last non-zero element of the sparse vector.
Definition: SVecScalarMultExpr.h:361
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecScalarMultExpr.h:449
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:154
MultTrait_< RT, ST > ResultType
Result type for expression template evaluations.
Definition: SVecScalarMultExpr.h:157
Constraint on the data type.
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SVecScalarMultExpr.h:371
#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
#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
IfTrue_< useAssign, const ResultType, const SVecScalarMultExpr &> CompositeType
Data type for composite expression templates.
Definition: SVecScalarMultExpr.h:165
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsInvertible.h:82
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
#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 RemoveReference type trait.
Header file for the IsInvertible type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: SVecScalarMultExpr.h:392
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
If_< IsExpression< VT >, const VT, const VT &> LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:168
Header file for the IsComputation type trait class.
Expression object for sparse vector-scalar multiplications.The SVecScalarMultExpr class represents th...
Definition: Forward.h:139
Compile time logical 'or' evaluation.The Or alias declaration performs at compile time a logical 'or'...
Definition: Or.h:76
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
size_t index() const
Access to the current index of the sparse element.
Definition: SVecScalarMultExpr.h:261
SVecScalarMultExpr(const VT &vector, ST scalar) noexcept
Constructor for the SVecScalarMultExpr class.
Definition: SVecScalarMultExpr.h:313
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: SVecScalarMultExpr.h:416
CompositeType_< VT > CT
Composite type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:104
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
LeftOperand vector_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecScalarMultExpr.h:468
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SVecScalarMultExpr.h:159
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SVecScalarMultExpr.h:338
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecScalarMultExpr.h:251
Header file for the Size type trait.
#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
#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
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecScalarMultExpr.h:427
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SVecScalarMultExpr.h:171
#define BLAZE_CONSTRAINT_MUST_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.In case the given data type T is not a floating point data type...
Definition: FloatingPoint.h:61
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
ConstIterator(IteratorType vector, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SVecScalarMultExpr.h:209