35 #ifndef _BLAZE_MATH_SPARSEMATRIX_H_
36 #define _BLAZE_MATH_SPARSEMATRIX_H_
93 template<
typename T1,
typename T2,
bool SO >
94 inline bool operator==(
const SparseMatrix<T1,false>& lhs,
const SparseMatrix<T2,false>& rhs );
96 template<
typename T1,
typename T2,
bool SO >
97 inline bool operator==(
const SparseMatrix<T1,true>& lhs,
const SparseMatrix<T2,true>& rhs );
99 template<
typename T1,
typename T2,
bool SO >
100 inline bool operator==(
const SparseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,!SO>& rhs );
102 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
103 inline bool operator!=(
const SparseMatrix<T1,SO1>& lhs,
const SparseMatrix<T2,SO2>& rhs );
116 template<
typename T1
135 for(
size_t i=0; i<A.rows(); ++i )
137 const LhsConstIterator lend( A.end(i) );
138 const RhsConstIterator rend( B.end(i) );
140 LhsConstIterator lelem( A.begin(i) );
141 RhsConstIterator relem( B.begin(i) );
143 while( lelem != lend && relem != rend ) {
144 if( lelem->index() < relem->index() && !
isDefault( (lelem++)->value() ) )
146 else if( lelem->index() > relem->index() && !
isDefault( (relem++)->value() ) )
148 else if( !
equal( (lelem++)->value(), (relem++)->value() ) )
152 while( lelem != lend ) {
157 while( relem != rend ) {
176 template<
typename T1
195 for(
size_t j=0; j<A.columns(); ++j )
197 const LhsConstIterator lend( A.end(j) );
198 const RhsConstIterator rend( B.end(j) );
200 LhsConstIterator lelem( A.begin(j) );
201 RhsConstIterator relem( B.begin(j) );
203 while( lelem != lend && relem != rend ) {
204 if( lelem->index() < relem->index() && !
isDefault( (lelem++)->value() ) )
206 else if( lelem->index() > relem->index() && !
isDefault( (relem++)->value() ) )
208 else if( !
equal( (lelem++)->value(), (relem++)->value() ) )
212 while( lelem != lend ) {
217 while( relem != rend ) {
236 template<
typename T1
242 return ( ~lhs == tmp );
255 template<
typename T1
261 return !( lhs == rhs );
277 template<
typename MT,
bool SO >
278 bool isnan(
const SparseMatrix<MT,SO>& sm );
280 template<
typename MT,
bool SO >
281 bool isDiagonal(
const SparseMatrix<MT,SO>& sm );
283 template<
typename MT,
bool SO >
286 template<
typename MT,
bool SO >
289 template<
typename MT,
bool SO >
315 template<
typename MT
325 for(
size_t i=0UL; i<A.rows(); ++i ) {
326 for( ConstIterator element=A.begin(i); element!=A.end(i); ++element )
327 if(
isnan( element->value() ) )
return true;
331 for(
size_t j=0UL; j<A.columns(); ++j ) {
332 for( ConstIterator element=A.begin(j); element!=A.end(j); ++element )
333 if(
isnan( element->value() ) )
return true;
361 template<
typename MT
370 if( rows != columns )
return false;
373 for(
size_t i=0UL; i<
rows; ++i ) {
374 for( ConstIterator element=(~sm).begin(i); element!=(~sm).end(i); ++element )
375 if( element->index() != i && !
isDefault( element->value() ) )
380 for(
size_t j=0UL; j<
columns; ++j ) {
381 for( ConstIterator element=(~sm).begin(j); element!=(~sm).end(j); ++element )
382 if( element->index() != j && !
isDefault( element->value() ) )
399 template<
typename MT
408 if( rows != columns )
return false;
411 for(
size_t i=0UL; i<
rows; ++i ) {
412 for( ConstIterator element=(~sm).begin(i); element!=(~sm).end(i); ++element )
414 const size_t index( element->index() );
419 const ConstIterator pos( (~sm).lowerBound( index, i ) );
420 if( pos == (~sm).end(index) || pos->index() != i || !
equal( pos->value(), element->value() ) )
426 for(
size_t j=0UL; j<
columns; ++j ) {
427 for( ConstIterator element=(~sm).begin(j); element!=(~sm).end(j); ++element )
429 const size_t index( element->index() );
434 const ConstIterator pos( (~sm).lowerBound( j, index ) );
435 if( pos == (~sm).end(index) || pos->index() != j || !
equal( pos->value(), element->value() ) )
458 template<
typename MT
470 const size_t nonzeros( A.nonZeros() );
472 if( nonzeros == 0UL ) {
477 if( nonzeros == A.rows() * A.columns() ) {
478 minimum = A.begin( 0UL )->value();
481 const size_t index( ( SO ==
rowMajor )?( A.rows() ):( A.columns() ) );
483 for(
size_t i=0UL; i<index; ++i ) {
484 const ConstIterator end( A.end( i ) );
485 ConstIterator element( A.begin( i ) );
486 for( ; element!=end; ++element )
487 minimum = min( minimum, element->value() );
507 template<
typename MT
519 const size_t nonzeros( A.nonZeros() );
521 if( nonzeros == 0UL ) {
526 if( nonzeros == A.rows() * A.columns() ) {
527 maximum = A.begin( 0UL )->value();
530 const size_t index( ( SO ==
rowMajor )?( A.rows() ):( A.columns() ) );
532 for(
size_t i=0UL; i<index; ++i ) {
533 const ConstIterator end( A.end( i ) );
534 ConstIterator element( A.begin( i ) );
535 for( ; element!=end; ++element )
536 maximum = max( maximum, element->value() );
Header file for the isnan shim.
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:682
Header file for the dense vector/sparse vector outer product expression.
Header file for the transpose sparse vector/transpose sparse matrix multiplication expression...
Header file for the transpose sparse matrix/sparse matrix subtraction expression. ...
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4622
Header file for the transpose sparse matrix/transpose sparse matrix subtraction expression.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:720
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2384
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 matrix/transpose sparse matrix addition expression.
Header file for the sparse matrix/transpose sparse matrix multiplication expression.
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:104
Header file for the transpose sparse matrix/dense vector multiplication expression.
Header file for the SparseMatrix base class.
Header file for the sparse matrix/transpose sparse matrix subtraction expression. ...
Header file for the transpose sparse matrix/sparse vector multiplication expression.
Header file for the matrix storage order types.
Header file for the sparse matrix absolute value expression.
Header file for the transpose dense vector/sparse matrix multiplication expression.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
Header file for the transpose sparse matrix/transpose sparse matrix addition expression.
Header file for the DenseMatrix base class.
Header file for the sparse matrix/scalar multiplication expression.
Header file for the sparse vector/dense vector outer product expression.
Header file for the transpose sparse matrix/sparse matrix multiplication expression.
Header file for the sparse vector/sparse vector outer product expression.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2381
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2382
Header file for the equal shim.
Header file for all basic Matrix functionality.
Header file for the transpose sparse vector/sparse matrix multiplication 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.
bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:352
Header file for the sparse matrix transpose expression.
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 transpose sparse matrix/transpose sparse matrix multiplication expression...
Header file for the sparse matrix/scalar division expression.
Header file for the sparse matrix/sparse matrix addition expression.
Header file for the RemoveReference type trait.
Header file for the sparse matrix evaluation expression.
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
Header file for the sparse matrix/dense vector multiplication expression.
Header file for the sparse matrix/sparse vector multiplication expression.
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
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 min(const SparseVector< VT, TF > &sv)
Returns the smallest element of the sparse vector.
Definition: SparseVector.h:348
Header file for the transpose dense vector/transpose sparse matrix multiplication expression...
Header file for the sparse matrix/sparse matrix subtraction expression.
Header file for the sparse matrix/sparse matrix multiplication expression.
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:138