35 #ifndef _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_
36 #define _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_
69 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
70 inline bool operator==(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
72 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
73 inline bool operator!=(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
98 if( (~lhs).
size() != (~rhs).
size() )
return false;
106 const LhsConstIterator lend( a.end() );
107 const RhsConstIterator rend( b.end() );
109 LhsConstIterator lelem( a.begin() );
110 RhsConstIterator relem( b.begin() );
112 while( lelem != lend && relem != rend )
114 if(
isDefault( lelem->value() ) ) { ++lelem;
continue; }
115 if(
isDefault( relem->value() ) ) { ++relem;
continue; }
117 if( lelem->index() != relem->index() || !
equal( lelem->value(), relem->value() ) ) {
126 while( lelem != lend ) {
132 while( relem != rend ) {
151 template<
typename T1
157 return !( lhs == rhs );
173 template<
typename VT,
bool TF >
174 bool isnan(
const SparseVector<VT,TF>& sv );
176 template<
typename VT,
bool TF >
177 bool isUniform(
const SparseVector<VT,TF>& dv );
179 template<
typename VT,
bool TF >
180 typename CMathTrait<typename VT::ElementType>::Type
length(
const SparseVector<VT,TF>& sv );
182 template<
typename VT,
bool TF >
185 template<
typename VT,
bool TF >
188 template<
typename VT,
bool TF >
214 template<
typename VT
223 const ConstIterator
end( a.end() );
224 for( ConstIterator element=a.begin(); element!=
end; ++element ) {
225 if(
isnan( element->value() ) )
return true;
258 template<
typename VT
266 if( (~sv).
size() < 2UL )
273 for( ConstIterator element=(~sv).
begin(); element!=(~sv).
end(); ++element ) {
280 ConstReference cmp( (~sv)[0] );
281 ConstIterator element( (~sv).
begin() );
285 for( ; element!=(~sv).
end(); ++element ) {
286 if( element->value() != cmp )
329 template<
typename VT
340 for( ConstIterator element=(~sv).
begin(); element!=(~sv).
end(); ++element )
341 sum +=
sq( element->value() );
342 return std::sqrt( sum );
360 template<
typename VT
369 ElementType
sum( 0 );
370 for( ConstIterator element=(~sv).
begin(); element!=(~sv).
end(); ++element )
371 sum +=
sq( element->value() );
399 template<
typename VT
411 const ConstIterator
end( a.end() );
412 ConstIterator element( a.begin() );
414 if( element ==
end ) {
417 else if( a.nonZeros() == a.size() ) {
418 ET minimum( element->value() );
420 for( ; element!=
end; ++element )
421 minimum =
min( minimum, element->value() );
426 for( ; element!=
end; ++element )
427 minimum =
min( minimum, element->value() );
456 template<
typename VT
468 const ConstIterator
end( a.end() );
469 ConstIterator element( a.begin() );
471 if( element ==
end ) {
474 else if( a.nonZeros() == a.size() ) {
475 ET maximum( element->value() );
477 for( ; element!=
end; ++element )
478 maximum =
max( maximum, element->value() );
483 for( ; element!=
end; ++element )
484 maximum =
max( maximum, element->value() );
Header file for the isnan shim.
BLAZE_ALWAYS_INLINE int16_t sum(const sse_int16_t &a)
Returns the sum of all elements in the 16-bit integral intrinsic vector.
Definition: Reduction.h:63
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1649
Constraint on the data type.
Header file for mathematical functions.
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the square shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:264
double Type
Return type of the functions for integral and double arguments.
Definition: CMathTrait.h:79
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:258
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:386
bool isnan(const DenseMatrix< MT, SO > &dm)
Checks the given dense matrix for not-a-number elements.
Definition: DenseMatrix.h:640
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Header file for the vector transpose flag types.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1602
Header file for the equal shim.
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:195
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
CMathTrait< typename VT::ElementType >::Type length(const DenseVector< VT, TF > &dv)
Calculation of the dense vector length .
Definition: DenseVector.h:516
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
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.
bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:376
#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
Header file for the isDefault shim.
Header file for the RemoveReference type trait.
Header file for the cmath trait.
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:910
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
const MultExprTrait< T, T >::Type sq(const T &a)
Squaring the given value/object.
Definition: Square.h:65
const VT::ElementType sqrLength(const DenseVector< VT, TF > &dv)
Calculation of the dense vector square length .
Definition: DenseVector.h:546