35 #ifndef _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_
36 #define _BLAZE_MATH_SPARSE_SPARSEVECTOR_H_
70 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
71 inline bool operator==(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
73 template<
typename T1,
bool TF1,
typename T2,
bool TF2 >
74 inline bool operator!=(
const SparseVector<T1,TF1>& lhs,
const SparseVector<T2,TF2>& rhs );
99 if( (~lhs).
size() != (~rhs).
size() )
return false;
107 const LhsConstIterator lend( a.end() );
108 const RhsConstIterator rend( b.end() );
110 LhsConstIterator lelem( a.begin() );
111 RhsConstIterator relem( b.begin() );
113 while( lelem != lend && relem != rend )
115 if(
isDefault( lelem->value() ) ) { ++lelem;
continue; }
116 if(
isDefault( relem->value() ) ) { ++relem;
continue; }
118 if( lelem->index() != relem->index() || !
equal( lelem->value(), relem->value() ) ) {
127 while( lelem != lend ) {
133 while( relem != rend ) {
152 template<
typename T1
158 return !( lhs == rhs );
174 template<
typename VT,
bool TF >
175 bool isnan(
const SparseVector<VT,TF>& sv );
177 template<
typename VT,
bool TF >
178 bool isUniform(
const SparseVector<VT,TF>& dv );
180 template<
typename VT,
bool TF >
181 const ElementType_<VT>
sqrLength(
const SparseVector<VT,TF>& sv );
183 template<
typename VT,
bool TF >
184 inline auto length(
const SparseVector<VT,TF>& sv ) -> decltype(
sqrt(
sqrLength( ~sv ) ) );
186 template<
typename VT,
bool TF >
187 const ElementType_<VT>
min(
const SparseVector<VT,TF>& sv );
189 template<
typename VT,
bool TF >
190 const ElementType_<VT>
max(
const SparseVector<VT,TF>& sv );
215 template<
typename VT
224 const ConstIterator
end( a.end() );
225 for( ConstIterator element=a.begin(); element!=
end; ++element ) {
226 if(
isnan( element->value() ) )
return true;
259 template<
typename VT
267 if( (~sv).
size() < 2UL )
274 for( ConstIterator element=(~sv).
begin(); element!=(~sv).
end(); ++element ) {
281 ConstReference cmp( (~sv)[0] );
282 ConstIterator element( (~sv).
begin() );
286 for( ; element!=(~sv).
end(); ++element ) {
287 if( element->value() != cmp )
310 template<
typename VT
319 ElementType
sum( 0 );
320 for( ConstIterator element=(~sv).
begin(); element!=(~sv).
end(); ++element )
321 sum +=
sq( element->value() );
364 template<
typename VT
395 template<
typename VT
407 const ConstIterator
end( a.end() );
408 ConstIterator element( a.begin() );
410 if( element ==
end ) {
413 else if( a.nonZeros() == a.size() ) {
414 ET minimum( element->value() );
416 for( ; element!=
end; ++element )
417 minimum =
min( minimum, element->value() );
422 for( ; element!=
end; ++element )
423 minimum =
min( minimum, element->value() );
452 template<
typename VT
464 const ConstIterator
end( a.end() );
465 ConstIterator element( a.begin() );
467 if( element ==
end ) {
470 else if( a.nonZeros() == a.size() ) {
471 ET maximum( element->value() );
473 for( ; element!=
end; ++element )
474 maximum =
max( maximum, element->value() );
479 for( ; element!=
end; ++element )
480 maximum =
max( maximum, element->value() );
Header file for the isnan shim.
Header file for auxiliary alias declarations.
Constraint on the data type.
Header file for mathematical functions.
Header file for basic type definitions.
Header file for the SparseVector base class.
BLAZE_ALWAYS_INLINE const complex< int8_t > sum(const SIMDcint8 &a) noexcept
Returns the sum of all elements in the 8-bit integral complex SIMD vector.
Definition: Reduction.h:63
Header file for the square shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
const ElementType_< VT > sqrLength(const DenseVector< VT, TF > &dv)
Calculation of the dense vector square length .
Definition: DenseVector.h:521
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:188
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
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:384
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Header file for the vector transpose flag types.
auto length(const DenseVector< VT, TF > &dv) -> decltype(sqrt(sqrLength(~dv)))
Calculation of the dense vector length .
Definition: DenseVector.h:574
Header file for the sqrt shim.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
BLAZE_ALWAYS_INLINE constexpr MultExprTrait_< T, T > sq(const T &a) noexcept(noexcept(a *a))
Squaring the given value/object.
Definition: Square.h:66
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for the equal shim.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:655
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:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
const DMatForEachExpr< MT, Sqrt, SO > sqrt(const DenseMatrix< MT, SO > &dm)
Computes the square root of each single element of the dense matrix dm.
Definition: DMatForEachExpr.h:1282
Header file for run time assertion macros.
bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:73
#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:61
Header file for the isDefault shim.
Header file for the RemoveReference type trait.
typename T::ConstReference ConstReference_
Alias declaration for nested ConstReference type definitions.The ConstReference_ alias declaration pr...
Definition: Aliases.h:143
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:982
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
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