35 #ifndef _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_ 36 #define _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_ 87 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
88 inline bool operator==(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
90 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
91 inline bool operator!=(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
93 template<
typename VT,
bool TF,
typename ST >
94 inline EnableIf_< IsNumeric<ST>, VT& >
operator*=( SparseVector<VT,TF>& vec, ST scalar );
96 template<
typename VT,
bool TF,
typename ST >
97 inline EnableIf_< IsNumeric<ST>, VT& >
operator*=( SparseVector<VT,TF>&& vec, ST scalar );
99 template<
typename VT,
bool TF,
typename ST >
100 inline EnableIf_< IsNumeric<ST>, VT& >
operator/=( SparseVector<VT,TF>& vec, ST scalar );
102 template<
typename VT,
bool TF,
typename ST >
103 inline EnableIf_< IsNumeric<ST>, VT& >
operator/=( SparseVector<VT,TF>&& vec, ST scalar );
116 template<
typename T1
128 if( (~lhs).
size() != (~rhs).
size() )
return false;
136 const LhsConstIterator lend( a.end() );
137 const RhsConstIterator rend( b.end() );
139 LhsConstIterator lelem( a.begin() );
140 RhsConstIterator relem( b.begin() );
142 while( lelem != lend && relem != rend )
144 if(
isDefault( lelem->value() ) ) { ++lelem;
continue; }
145 if(
isDefault( relem->value() ) ) { ++relem;
continue; }
147 if( lelem->index() != relem->index() || !
equal( lelem->value(), relem->value() ) ) {
156 while( lelem != lend ) {
162 while( relem != rend ) {
181 template<
typename T1
187 return !( lhs == rhs );
205 template<
typename VT
211 if( !tryMult( ~vec, 0UL, (~vec).
size(), scalar ) ) {
222 BLAZE_DECLTYPE_AUTO( left, derestrict( ~vec ) );
224 const auto last( left.end() );
225 for(
auto element=left.begin(); element!=last; ++element ) {
226 element->value() *= scalar;
250 template<
typename VT
275 template<
typename VT
283 if( !tryDiv( ~vec, 0UL, (~vec).
size(), scalar ) ) {
296 BLAZE_DECLTYPE_AUTO( left, derestrict( ~vec ) );
299 const ScalarType tmp( ScalarType(1)/static_cast<ScalarType>( scalar ) );
300 for(
auto element=left.begin(); element!=left.end(); ++element ) {
301 element->value() *= tmp;
305 for(
auto element=left.begin(); element!=left.end(); ++element ) {
306 element->value() /= scalar;
332 template<
typename VT
353 template<
typename VT,
bool TF >
356 template<
typename VT,
bool TF >
359 template<
typename VT,
bool TF >
362 template<
typename VT,
bool TF >
365 template<
typename VT,
bool TF >
368 template<
typename VT,
bool TF >
394 template<
typename VT
405 if(
isnan( element->value() ) )
return true;
438 template<
typename VT
451 if( a.nonZeros() != a.size() )
453 for(
ConstIterator element=a.begin(); element!=a.end(); ++element ) {
465 for( ; element!=a.end(); ++element ) {
466 if( element->value() != cmp )
489 template<
typename VT
500 sum +=
pow2( element->value() );
543 template<
typename VT
574 template<
typename VT
589 if( element ==
end ) {
592 else if( a.nonZeros() == a.size() ) {
593 ET minimum( element->value() );
595 for( ; element!=
end; ++element )
596 minimum =
min( minimum, element->value() );
601 for( ; element!=
end; ++element )
602 minimum =
min( minimum, element->value() );
631 template<
typename VT
646 if( element ==
end ) {
649 else if( a.nonZeros() == a.size() ) {
650 ET maximum( element->value() );
652 for( ; element!=
end; ++element )
653 maximum =
max( maximum, element->value() );
658 for( ; element!=
end; ++element )
659 maximum =
max( maximum, element->value() );
Header file for the isnan shim.
Header file for the UnderlyingNumeric type trait.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Headerfile for the generic min algorithm.
Constraint on the data type.
#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.
constexpr bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:76
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
const ElementType_< VT > sqrLength(const DenseVector< VT, TF > &dv)
Calculation of the square length (magnitude) of the dense vector .
Definition: DenseVector.h:661
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
Header file for the And class template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
Header file for the decltype(auto) workaround.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
Header file for the vector transpose flag types.
auto length(const DenseVector< VT, TF > &dv) -> decltype(sqrt(sqrLength(~dv)))
Calculation of the length (magnitude) of the dense vector .
Definition: DenseVector.h:714
Compile time check for data types with restricted data access.This type trait tests whether the given...
Definition: IsRestricted.h:82
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
Header file for the sqrt shim.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Headerfile for the generic max algorithm.
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.
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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
Header file for the isZero shim.
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for the pow2 shim.
Header file for the equal shim.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:710
Header file for the exception macros of the math module.
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:75
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:1151
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:292
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
BLAZE_ALWAYS_INLINE ValueType_< T > sum(const SIMDi8< T > &a) noexcept
Returns the sum of all elements in the 8-bit integral SIMD vector.
Definition: Reduction.h:65
Header file for run time assertion macros.
Header file for the division trait.
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
#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 isDefault shim.
Compile time check for built-in data types.This type trait tests whether or not the given template pa...
Definition: IsBuiltin.h:75
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsInvertible.h:82
BLAZE_ALWAYS_INLINEdecltype(auto) constexpr pow2(const T &a) noexcept(noexcept(a *a))
Squaring the given value/object.
Definition: Pow2.h:65
Header file for the RemoveReference type trait.
Header file for the IsInvertible type trait.
typename T::ConstReference ConstReference_
Alias declaration for nested ConstReference type definitions.The ConstReference_ alias declaration pr...
Definition: Aliases.h:143
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
decltype(auto) sqrt(const DenseMatrix< MT, SO > &dm)
Computes the square root of each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1448
Header file for the IsBuiltin type trait.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
Header file for the IsComplex type trait.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
#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