35 #ifndef _BLAZE_MATH_SPARSEVECTOR_H_
36 #define _BLAZE_MATH_SPARSEVECTOR_H_
83 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
84 inline bool operator==(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
86 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
87 inline bool operator!=(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
100 template<
typename T1
112 if( (~lhs).size() != (~rhs).size() )
return false;
120 const LhsConstIterator lend( a.end() );
121 const RhsConstIterator rend( b.end() );
123 LhsConstIterator lelem( a.begin() );
124 RhsConstIterator relem( b.begin() );
126 while( lelem != lend && relem != rend )
128 if(
isDefault( lelem->value() ) ) { ++lelem;
continue; }
129 if(
isDefault( relem->value() ) ) { ++relem;
continue; }
131 if( lelem->index() != relem->index() || !
equal( lelem->value(), relem->value() ) ) {
140 while( lelem != lend ) {
146 while( relem != rend ) {
165 template<
typename T1
171 return !( lhs == rhs );
187 template<
typename VT,
bool TF >
188 bool isnan(
const SparseVector<VT,TF>& sv );
190 template<
typename VT,
bool TF >
191 typename CMathTrait<typename VT::ElementType>::Type
length(
const SparseVector<VT,TF>& sv );
193 template<
typename VT,
bool TF >
196 template<
typename VT,
bool TF >
199 template<
typename VT,
bool TF >
225 template<
typename VT
234 const ConstIterator end( a.end() );
235 for( ConstIterator element=a.begin(); element!=end; ++element ) {
236 if(
isnan( element->value() ) )
return true;
276 template<
typename VT
287 for( ConstIterator element=(~sv).begin(); element!=(~sv).end(); ++element )
288 sum +=
sq( element->value() );
289 return std::sqrt( sum );
307 template<
typename VT
316 ElementType
sum( 0 );
317 for( ConstIterator element=(~sv).begin(); element!=(~sv).end(); ++element )
318 sum +=
sq( element->value() );
346 template<
typename VT
358 const ConstIterator end( a.end() );
359 ConstIterator element( a.begin() );
361 if( element == end ) {
364 else if( a.nonZeros() == a.size() ) {
365 ET minimum( element->value() );
367 for( ; element!=end; ++element )
368 minimum = min( minimum, element->value() );
373 for( ; element!=end; ++element )
374 minimum = min( minimum, element->value() );
403 template<
typename VT
415 const ConstIterator end( a.end() );
416 ConstIterator element( a.begin() );
418 if( element == end ) {
421 else if( a.nonZeros() == a.size() ) {
422 ET maximum( element->value() );
424 for( ; element!=end; ++element )
425 maximum = max( maximum, element->value() );
430 for( ; element!=end; ++element )
431 maximum = max( maximum, element->value() );
Header file for the isnan shim.
Constraint on the data type.
Header file for the sparse vector transpose expression.
Header file for the SparseVector base class.
Header file for the sparse vector/sparse vector addition expression.
double Type
Return type of the <cmath> functions for integral and double arguments.
Definition: CMathTrait.h:79
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
const Quaternion< Type > sq(const Quaternion< Type > &m)
Squaring the given quaternion.
Definition: Quaternion.h:1034
int16_t sum(const sse_int16_t &a)
Returns the sum of all elements in the 16-bit integral intrinsic vector.
Definition: Reduction.h:62
Header file for the sparse vector/sparse vector multiplication expression.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2375
Header file for the DenseVector base class.
bool isnan(const DenseMatrix< MT, SO > &dm)
Checks the given dense matrix for not-a-number elements.
Definition: DenseMatrix.h:637
Header file for the sparse vector/dense vector inner product expression.
Header file for the sparse vector/sparse vector subtraction expression.
Header file for the vector transpose flag types.
Header file for the dense vector/sparse vector multiplication expression.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
Header file for the sparse vector/scalar division expression.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
Header file for the sparse vector absolute value expression.
CMathTrait< typename VT::ElementType >::Type length(const DenseVector< VT, TF > &dv)
Calculation of the dense vector length .
Definition: DenseVector.h:480
Header file for the sparse vector/sparse vector inner product expression.
Header file for the equal shim.
Header file for the sparse vector evaluation expression.
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Header file for run time assertion macros.
Header file for all basic Vector functionality.
bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:352
Header file for the square shim.
#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:79
const VT::ElementType max(const SparseVector< VT, TF > &sv)
Returns the largest element of the sparse vector.
Definition: SparseVector.h:405
Header file for the isDefault shim.
Header file for the RemoveReference type trait.
Header file for the cmath trait.
Header file for the dense vector/sparse vector inner product expression.
Header file for the sparse vector/sparse vector multiplication expression.
Header file for the sparse vector/scalar multiplication expression.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
Header file for basic type definitions.
const VT::ElementType sqrLength(const DenseVector< VT, TF > &dv)
Calculation of the dense vector square length .
Definition: DenseVector.h:510
const VT::ElementType min(const SparseVector< VT, TF > &sv)
Returns the smallest element of the sparse vector.
Definition: SparseVector.h:348