35 #ifndef _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_ 36 #define _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_ 82 template<
typename VT,
bool TF,
typename ST >
83 auto operator*=( SparseVector<VT,TF>& vec, ST scalar )
84 -> EnableIf_t< IsNumeric_v<ST>, VT& >;
86 template<
typename VT,
bool TF,
typename ST >
87 auto operator*=( SparseVector<VT,TF>&& vec, ST scalar )
88 -> EnableIf_t< IsNumeric_v<ST>, VT& >;
90 template<
typename VT,
bool TF,
typename ST >
91 auto operator/=( SparseVector<VT,TF>& vec, ST scalar )
92 -> EnableIf_t< IsNumeric_v<ST>, VT& >;
94 template<
typename VT,
bool TF,
typename ST >
95 auto operator/=( SparseVector<VT,TF>&& vec, ST scalar )
96 -> EnableIf_t< IsNumeric_v<ST>, VT& >;
114 template<
typename VT
120 if( IsRestricted_v<VT> ) {
121 if( !tryMult( ~vec, 0UL, (~vec).
size(), scalar ) ) {
132 decltype(
auto) left( derestrict( ~vec ) );
134 const auto last( left.end() );
135 for(
auto element=left.begin(); element!=last; ++element ) {
136 element->value() *= scalar;
160 template<
typename VT
186 template<
typename VT
194 if( IsRestricted_v<VT> ) {
195 if( !tryDiv( ~vec, 0UL, (~vec).
size(), scalar ) ) {
201 IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
207 decltype(
auto) left( derestrict( ~vec ) );
209 if( IsInvertible_v<ScalarType> ) {
210 const ScalarType tmp( ScalarType(1)/static_cast<ScalarType>( scalar ) );
211 for(
auto element=left.begin(); element!=left.end(); ++element ) {
212 element->value() *= tmp;
216 for(
auto element=left.begin(); element!=left.end(); ++element ) {
217 element->value() /= scalar;
243 template<
typename VT
265 template<
typename VT,
bool TF >
266 bool isnan(
const SparseVector<VT,TF>& sv );
268 template<
bool RF,
typename VT,
bool TF >
269 bool isUniform(
const SparseVector<VT,TF>& sv );
271 template<
bool RF,
typename VT,
bool TF >
272 bool isZero(
const SparseVector<VT,TF>& sv );
297 template<
typename VT
305 const auto end( a.end() );
306 for(
auto element=a.begin(); element!=
end; ++element ) {
307 if(
isnan( element->value() ) )
return true;
354 if( IsUniform_v<VT> || (~sv).
size() < 2UL )
359 if( a.nonZeros() != a.size() )
361 const auto end( a.end() );
362 for(
auto element=a.begin(); element!=
end; ++element ) {
363 if( !isDefault<RF>( element->value() ) )
369 const auto& cmp( a[0] );
370 auto element( a.begin() );
371 const auto end( a.end() );
375 for( ; element!=
end; ++element ) {
376 if( !equal<RF>( element->value(), cmp ) )
424 if( IsZero_v<VT> || (~sv).
nonZeros() == 0UL )
429 const auto end( a.end() );
430 for(
auto element=a.begin(); element!=
end; ++element ) {
431 if( !isZero<RF>( element->value() ) )
454 template<
typename VT
457 auto erase( SparseVector<VT,TF>& sv, Args&&... args )
458 -> decltype( (~sv).erase( std::forward<Args>( args )... ) )
460 return (~sv).erase( std::forward<Args>( args )... );
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.
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,...
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 template for the If class template.The If_t alias template provides a convenient shor...
Definition: If.h:109
Header file for the isZero 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
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
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
Header file for the sqrt shim.
constexpr bool IsResizable_v
Auxiliary variable template for the IsResizable type trait.The IsResizable_v variable template provid...
Definition: IsResizable.h:133
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.
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:717
Header file for the exception macros of the math module.
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:1638
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:438
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:558
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
Header file for the division trait.
Header file for the IsZero type trait.
Header file for the isDefault shim.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Header file for the RemoveReference type trait.
Header file for the IsInvertible type trait.
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:146
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
Header file for the IsComplex type trait.
auto operator *=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:494
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,...
Definition: Assert.h:101