35 #ifndef _BLAZE_MATH_SPARSEMATRIX_H_
36 #define _BLAZE_MATH_SPARSEMATRIX_H_
96 template<
typename T1,
typename T2,
bool SO >
97 inline bool operator==(
const SparseMatrix<T1,false>& lhs,
const SparseMatrix<T2,false>& rhs );
99 template<
typename T1,
typename T2,
bool SO >
100 inline bool operator==(
const SparseMatrix<T1,true>& lhs,
const SparseMatrix<T2,true>& rhs );
102 template<
typename T1,
typename T2,
bool SO >
103 inline bool operator==(
const SparseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,!SO>& rhs );
105 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
106 inline bool operator!=(
const SparseMatrix<T1,SO1>& lhs,
const SparseMatrix<T2,SO2>& rhs );
119 template<
typename T1
138 for(
size_t i=0; i<A.rows(); ++i )
140 const LhsConstIterator lend( A.end(i) );
141 const RhsConstIterator rend( B.end(i) );
143 LhsConstIterator lelem( A.begin(i) );
144 RhsConstIterator relem( B.begin(i) );
146 while( lelem != lend && relem != rend ) {
147 if( lelem->index() < relem->index() && !
isDefault( (lelem++)->value() ) )
149 else if( lelem->index() > relem->index() && !
isDefault( (relem++)->value() ) )
151 else if( !
equal( (lelem++)->value(), (relem++)->value() ) )
155 while( lelem != lend ) {
160 while( relem != rend ) {
179 template<
typename T1
198 for(
size_t j=0; j<A.columns(); ++j )
200 const LhsConstIterator lend( A.end(j) );
201 const RhsConstIterator rend( B.end(j) );
203 LhsConstIterator lelem( A.begin(j) );
204 RhsConstIterator relem( B.begin(j) );
206 while( lelem != lend && relem != rend ) {
207 if( lelem->index() < relem->index() && !
isDefault( (lelem++)->value() ) )
209 else if( lelem->index() > relem->index() && !
isDefault( (relem++)->value() ) )
211 else if( !
equal( (lelem++)->value(), (relem++)->value() ) )
215 while( lelem != lend ) {
220 while( relem != rend ) {
239 template<
typename T1
245 return ( ~lhs == tmp );
258 template<
typename T1
264 return !( lhs == rhs );
280 template<
typename MT,
bool SO >
281 bool isnan(
const SparseMatrix<MT,SO>& sm );
283 template<
typename MT,
bool SO >
284 bool isDiagonal(
const SparseMatrix<MT,SO>& sm );
286 template<
typename MT,
bool SO >
289 template<
typename MT,
bool SO >
292 template<
typename MT,
bool SO >
318 template<
typename MT
328 for(
size_t i=0UL; i<A.rows(); ++i ) {
329 for( ConstIterator element=A.begin(i); element!=A.end(i); ++element )
330 if(
isnan( element->value() ) )
return true;
334 for(
size_t j=0UL; j<A.columns(); ++j ) {
335 for( ConstIterator element=A.begin(j); element!=A.end(j); ++element )
336 if(
isnan( element->value() ) )
return true;
364 template<
typename MT
373 if( rows != columns )
return false;
376 for(
size_t i=0UL; i<
rows; ++i ) {
377 for( ConstIterator element=(~sm).begin(i); element!=(~sm).end(i); ++element )
378 if( element->index() != i && !
isDefault( element->value() ) )
383 for(
size_t j=0UL; j<
columns; ++j ) {
384 for( ConstIterator element=(~sm).begin(j); element!=(~sm).end(j); ++element )
385 if( element->index() != j && !
isDefault( element->value() ) )
402 template<
typename MT
411 if( rows != columns )
return false;
414 for(
size_t i=0UL; i<
rows; ++i ) {
415 for( ConstIterator element=(~sm).begin(i); element!=(~sm).end(i); ++element )
417 const size_t index( element->index() );
422 const ConstIterator pos( (~sm).lowerBound( index, i ) );
423 if( pos == (~sm).end(index) || pos->index() != i || !
equal( pos->value(), element->value() ) )
429 for(
size_t j=0UL; j<
columns; ++j ) {
430 for( ConstIterator element=(~sm).begin(j); element!=(~sm).end(j); ++element )
432 const size_t index( element->index() );
437 const ConstIterator pos( (~sm).lowerBound( j, index ) );
438 if( pos == (~sm).end(index) || pos->index() != j || !
equal( pos->value(), element->value() ) )
461 template<
typename MT
473 const size_t nonzeros( A.nonZeros() );
475 if( nonzeros == 0UL ) {
480 if( nonzeros == A.rows() * A.columns() ) {
481 minimum = A.begin( 0UL )->value();
484 const size_t index( ( SO ==
rowMajor )?( A.rows() ):( A.columns() ) );
486 for(
size_t i=0UL; i<index; ++i ) {
487 const ConstIterator end( A.end( i ) );
488 ConstIterator element( A.begin( i ) );
489 for( ; element!=end; ++element )
490 minimum = min( minimum, element->value() );
510 template<
typename MT
522 const size_t nonzeros( A.nonZeros() );
524 if( nonzeros == 0UL ) {
529 if( nonzeros == A.rows() * A.columns() ) {
530 maximum = A.begin( 0UL )->value();
533 const size_t index( ( SO ==
rowMajor )?( A.rows() ):( A.columns() ) );
535 for(
size_t i=0UL; i<index; ++i ) {
536 const ConstIterator end( A.end( i ) );
537 ConstIterator element( A.begin( i ) );
538 for( ; element!=end; ++element )
539 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:685
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:4642
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:723
Header file for the sparse matrix SMP implementation.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2408
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 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:107
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:2412
Header file for the transpose sparse matrix/transpose sparse matrix addition expression.
Header file for the dense matrix SMP implementation.
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:2405
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
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:408
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 serial evaluation 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:170
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:351
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:154