35#ifndef _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_
36#define _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_
87template<
typename VT,
bool TF,
typename ST >
88auto operator*=( SparseVector<VT,TF>& vec, ST scalar )
89 -> EnableIf_t< IsScalar_v<ST>, VT& >;
91template<
typename VT,
bool TF,
typename ST >
92auto operator*=( SparseVector<VT,TF>&& vec, ST scalar )
93 -> EnableIf_t< IsScalar_v<ST>, VT& >;
95template<
typename VT,
bool TF,
typename ST >
96auto operator/=( SparseVector<VT,TF>& vec, ST scalar )
97 -> EnableIf_t< IsScalar_v<ST>, VT& >;
99template<
typename VT,
bool TF,
typename ST >
100auto operator/=( SparseVector<VT,TF>&& vec, ST scalar )
101 -> EnableIf_t< IsScalar_v<ST>, VT& >;
125 if( IsRestricted_v<VT> ) {
126 if( !tryMult( *vec, 0UL, (*vec).size(), scalar ) ) {
137 decltype(
auto) left( derestrict( *vec ) );
139 const auto last( left.end() );
140 for(
auto element=left.begin(); element!=last; ++element ) {
141 element->value() *= scalar;
199 if( IsRestricted_v<VT> ) {
200 if( !tryDiv( *vec, 0UL, (*vec).size(), scalar ) ) {
206 IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
212 decltype(
auto) left( derestrict( *vec ) );
214 if( IsInvertible_v<ScalarType> ) {
215 const ScalarType tmp( ScalarType(1)/
static_cast<ScalarType
>( scalar ) );
216 for(
auto element=left.begin(); element!=left.end(); ++element ) {
217 element->value() *= tmp;
221 for(
auto element=left.begin(); element!=left.end(); ++element ) {
222 element->value() /= scalar;
270template<
typename VT,
bool TF >
271bool isnan(
const SparseVector<VT,TF>& sv );
273template<
typename VT,
bool TF >
274bool isinf(
const SparseVector<VT,TF>& sv );
276template<
typename VT,
bool TF >
277bool isfinite(
const SparseVector<VT,TF>& sv );
279template< RelaxationFlag RF,
typename VT,
bool TF >
280bool isUniform(
const SparseVector<VT,TF>& sv );
282template< RelaxationFlag RF,
typename VT,
bool TF >
283bool isZero(
const SparseVector<VT,TF>& sv );
316 const auto end( a.end() );
317 for(
auto element=a.begin(); element!=
end; ++element ) {
318 if(
isnan( element->value() ) )
return true;
353 const auto end( a.end() );
354 for(
auto element=a.begin(); element!=
end; ++element ) {
355 if(
isinf( element->value() ) )
return true;
390 const auto end( a.end() );
391 for(
auto element=a.begin(); element!=
end; ++element ) {
392 if( !
isfinite( element->value() ) )
return false;
439 if( IsUniform_v<VT> || (*sv).size() < 2UL )
444 if( a.nonZeros() != a.size() )
446 const auto end( a.end() );
447 for(
auto element=a.begin(); element!=
end; ++element ) {
448 if( !isDefault<RF>( element->value() ) )
454 const auto& cmp( a[0] );
455 auto element( a.begin() );
456 const auto end( a.end() );
460 for( ; element!=
end; ++element ) {
461 if( !equal<RF>( element->value(), cmp ) )
509 if( IsZero_v<VT> || (*sv).nonZeros() == 0UL )
514 const auto end( a.end() );
515 for(
auto element=a.begin(); element!=
end; ++element ) {
516 if( !isZero<RF>( element->value() ) )
542auto erase( SparseVector<VT,TF>& sv, Args&&... args )
543 ->
decltype( (*sv).erase( std::forward<Args>( args )... ) )
545 return (*sv).erase( std::forward<Args>( args )... );
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
Header file for run time assertion macros.
Header file for the division trait.
Header file for the EnableIf class template.
Header file for the If class template.
Header file for the IsBuiltin type trait.
Header file for the IsComplex type trait.
Header file for the isDefault shim.
Header file for the isfinite shim.
Header file for the IsFloatingPoint type trait.
Header file for the isinf shim.
Header file for the IsInvertible type trait.
Header file for the isnan shim.
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
Header file for the IsScalar type trait.
Constraint on the data type.
Header file for the relaxation flag enumeration.
Header file for the RemoveReference type trait.
Header file for the UnderlyingBuiltin type trait.
Header file for the UnderlyingScalar type trait.
Base class for sparse vectors.
Definition: SparseVector.h:72
Header file for the SparseVector base class.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
typename DivTrait< T1, T2 >::Type DivTrait_t
Auxiliary alias declaration for the DivTrait class template.
Definition: DivTrait.h:164
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_t
Auxiliary alias declaration for the UnderlyingBuiltin type trait.
Definition: UnderlyingBuiltin.h:117
constexpr bool IsResizable_v
Auxiliary variable template for the IsResizable type trait.
Definition: IsResizable.h:136
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
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:584
#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
bool isfinite(const SparseVector< VT, TF > &sv)
Checks the given sparse vector for finite elements.
Definition: SparseVector.h:381
bool isnan(const SparseVector< VT, TF > &sv)
Checks the given sparse vector for not-a-number elements.
Definition: SparseVector.h:307
bool isinf(const SparseVector< VT, TF > &sv)
Checks the given sparse vector for infinite elements.
Definition: SparseVector.h:344
auto operator*=(SparseVector< VT, TF > &&vec, ST scalar) -> EnableIf_t< IsScalar_v< ST >, VT & >
Multiplication assignment operator for the multiplication of a temporary sparse vector and a scalar (...
Definition: SparseVector.h:168
bool isUniform(const SparseVector< VT, TF > &sv)
Checks if the given sparse vector is a uniform vector.
Definition: SparseVector.h:435
auto operator/=(SparseVector< VT, TF > &&vec, ST scalar) -> EnableIf_t< IsScalar_v< ST >, VT & >
Division assignment operator for the division of a temporary sparse vector by a scalar value ( ).
Definition: SparseVector.h:251
bool isZero(const SparseVector< VT, TF > &sv)
Checks if the given sparse vector is a zero vector.
Definition: SparseVector.h:507
constexpr bool IsFloatingPoint_v
Auxiliary variable template for the IsFloatingPoint type trait.
Definition: IsFloatingPoint.h:95
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the exception macros of the math module.
Header file for the equal shim.
Header file for the isZero shim.
Header file for the pow2 shim.
Header file for the sqrt shim.
Header file for the IsZero type trait.
Header file for basic type definitions.