35 #ifndef _BLAZE_MATH_SPARSEVECTOR_H_
36 #define _BLAZE_MATH_SPARSEVECTOR_H_
86 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
87 inline bool operator==(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
89 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
90 inline bool operator!=(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
103 template<
typename T1
115 if( (~lhs).size() != (~rhs).size() )
return false;
123 const LhsConstIterator lend( a.end() );
124 const RhsConstIterator rend( b.end() );
126 LhsConstIterator lelem( a.begin() );
127 RhsConstIterator relem( b.begin() );
129 while( lelem != lend && relem != rend )
131 if(
isDefault( lelem->value() ) ) { ++lelem;
continue; }
132 if(
isDefault( relem->value() ) ) { ++relem;
continue; }
134 if( lelem->index() != relem->index() || !
equal( lelem->value(), relem->value() ) ) {
143 while( lelem != lend ) {
149 while( relem != rend ) {
168 template<
typename T1
174 return !( lhs == rhs );
190 template<
typename VT,
bool TF >
191 bool isnan(
const SparseVector<VT,TF>& sv );
193 template<
typename VT,
bool TF >
194 typename CMathTrait<typename VT::ElementType>::Type
length(
const SparseVector<VT,TF>& sv );
196 template<
typename VT,
bool TF >
199 template<
typename VT,
bool TF >
202 template<
typename VT,
bool TF >
228 template<
typename VT
237 const ConstIterator end( a.end() );
238 for( ConstIterator element=a.begin(); element!=end; ++element ) {
239 if(
isnan( element->value() ) )
return true;
279 template<
typename VT
290 for( ConstIterator element=(~sv).begin(); element!=(~sv).end(); ++element )
291 sum +=
sq( element->value() );
292 return std::sqrt( sum );
310 template<
typename VT
319 ElementType
sum( 0 );
320 for( ConstIterator element=(~sv).begin(); element!=(~sv).end(); ++element )
321 sum +=
sq( element->value() );
349 template<
typename VT
361 const ConstIterator end( a.end() );
362 ConstIterator element( a.begin() );
364 if( element == end ) {
367 else if( a.nonZeros() == a.size() ) {
368 ET minimum( element->value() );
370 for( ; element!=end; ++element )
371 minimum = min( minimum, element->value() );
376 for( ; element!=end; ++element )
377 minimum = min( minimum, element->value() );
406 template<
typename VT
418 const ConstIterator end( a.end() );
419 ConstIterator element( a.begin() );
421 if( element == end ) {
424 else if( a.nonZeros() == a.size() ) {
425 ET maximum( element->value() );
427 for( ; element!=end; ++element )
428 maximum = max( maximum, element->value() );
433 for( ; element!=end; ++element )
434 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 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:4642
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:2408
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:640
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.
Header file for the dense vector SMP implementation.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
Header file for the sparse vector/scalar division expression.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
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:483
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.
Header file for the sparse vector serial evaluation expression.
#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:408
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.
Header file for the sparse vector SMP implementation.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
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:513
const VT::ElementType min(const SparseVector< VT, TF > &sv)
Returns the smallest element of the sparse vector.
Definition: SparseVector.h:351