35 #ifndef _BLAZE_MATH_SPARSE_SPARSEMATRIX_H_
36 #define _BLAZE_MATH_SPARSE_SPARSEMATRIX_H_
71 template<
typename T1,
typename T2,
bool SO >
72 inline bool operator==(
const SparseMatrix<T1,false>& lhs,
const SparseMatrix<T2,false>& rhs );
74 template<
typename T1,
typename T2,
bool SO >
75 inline bool operator==(
const SparseMatrix<T1,true>& lhs,
const SparseMatrix<T2,true>& rhs );
77 template<
typename T1,
typename T2,
bool SO >
78 inline bool operator==(
const SparseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,!SO>& rhs );
80 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
81 inline bool operator!=(
const SparseMatrix<T1,SO1>& lhs,
const SparseMatrix<T2,SO2>& rhs );
113 for(
size_t i=0; i<A.rows(); ++i )
115 const LhsConstIterator lend( A.end(i) );
116 const RhsConstIterator rend( B.end(i) );
118 LhsConstIterator lelem( A.begin(i) );
119 RhsConstIterator relem( B.begin(i) );
121 while( lelem != lend && relem != rend ) {
122 if( lelem->index() < relem->index() && !
isDefault( (lelem++)->value() ) )
124 else if( lelem->index() > relem->index() && !
isDefault( (relem++)->value() ) )
126 else if( !
equal( (lelem++)->value(), (relem++)->value() ) )
130 while( lelem != lend ) {
135 while( relem != rend ) {
154 template<
typename T1
173 for(
size_t j=0; j<A.columns(); ++j )
175 const LhsConstIterator lend( A.end(j) );
176 const RhsConstIterator rend( B.end(j) );
178 LhsConstIterator lelem( A.begin(j) );
179 RhsConstIterator relem( B.begin(j) );
181 while( lelem != lend && relem != rend ) {
182 if( lelem->index() < relem->index() && !
isDefault( (lelem++)->value() ) )
184 else if( lelem->index() > relem->index() && !
isDefault( (relem++)->value() ) )
186 else if( !
equal( (lelem++)->value(), (relem++)->value() ) )
190 while( lelem != lend ) {
195 while( relem != rend ) {
214 template<
typename T1
220 return ( ~lhs == tmp );
233 template<
typename T1
239 return !( lhs == rhs );
255 template<
typename MT,
bool SO >
256 bool isnan(
const SparseMatrix<MT,SO>& sm );
258 template<
typename MT,
bool SO >
259 bool isDiagonal(
const SparseMatrix<MT,SO>& sm );
261 template<
typename MT,
bool SO >
264 template<
typename MT,
bool SO >
265 bool isLower(
const SparseMatrix<MT,SO>& sm );
267 template<
typename MT,
bool SO >
268 bool isUpper(
const SparseMatrix<MT,SO>& sm );
270 template<
typename MT,
bool SO >
273 template<
typename MT,
bool SO >
299 template<
typename MT
309 for(
size_t i=0UL; i<A.rows(); ++i ) {
310 for( ConstIterator element=A.begin(i); element!=A.end(i); ++element )
311 if(
isnan( element->value() ) )
return true;
315 for(
size_t j=0UL; j<A.columns(); ++j ) {
316 for( ConstIterator element=A.begin(j); element!=A.end(j); ++element )
317 if(
isnan( element->value() ) )
return true;
362 template<
typename MT
377 for(
size_t i=0UL; i<A.rows(); ++i ) {
378 for( ConstIterator element=A.begin(i); element!=A.end(i); ++element )
379 if( element->index() != i && !
isDefault( element->value() ) )
384 for(
size_t j=0UL; j<A.columns(); ++j ) {
385 for( ConstIterator element=A.begin(j); element!=A.end(j); ++element )
386 if( element->index() != j && !
isDefault( element->value() ) )
422 template<
typename MT
438 if( (~sm).
rows() < 2UL )
447 for(
size_t i=0UL; i<A.rows(); ++i ) {
448 for( ConstIterator element=A.begin(i); element!=A.end(i); ++element )
450 const size_t j( element->index() );
452 if( i == j ||
isDefault( element->value() ) )
455 const ConstIterator pos( A.find( j, i ) );
456 if( pos == A.end(j) || !
equal( pos->value(), element->value() ) )
462 for(
size_t j=0UL; j<A.columns(); ++j ) {
463 for( ConstIterator element=A.begin(j); element!=A.end(j); ++element )
465 const size_t i( element->index() );
467 if( j == i ||
isDefault( element->value() ) )
470 const ConstIterator pos( A.find( j, i ) );
471 if( pos == A.end(i) || !
equal( pos->value(), element->value() ) )
518 template<
typename MT
534 if( (~sm).
rows() < 2UL )
543 for(
size_t i=0UL; i<A.rows()-1UL; ++i ) {
544 for( ConstIterator element=A.lowerBound(i,i+1UL); element!=A.end(i); ++element )
552 for(
size_t j=1UL; j<A.columns(); ++j ) {
553 for( ConstIterator element=A.begin(j); element!=A.end(j); ++element )
555 if( element->index() >= j )
605 template<
typename MT
621 if( (~sm).
rows() < 2UL )
630 for(
size_t i=1UL; i<A.rows(); ++i ) {
631 for( ConstIterator element=A.begin(i); element!=A.end(i); ++element )
633 if( element->index() >= i )
642 for(
size_t j=0UL; j<A.columns()-1UL; ++j ) {
643 for( ConstIterator element=A.lowerBound(j+1UL,j); element!=A.end(j); ++element )
668 template<
typename MT
680 const size_t nonzeros( A.nonZeros() );
682 if( nonzeros == 0UL ) {
687 if( nonzeros == A.rows() * A.columns() ) {
688 minimum = A.begin( 0UL )->value();
691 const size_t index( ( SO ==
rowMajor )?( A.rows() ):( A.columns() ) );
693 for(
size_t i=0UL; i<index; ++i ) {
694 const ConstIterator
end( A.end( i ) );
695 ConstIterator element( A.begin( i ) );
696 for( ; element!=
end; ++element )
697 minimum =
min( minimum, element->value() );
717 template<
typename MT
729 const size_t nonzeros( A.nonZeros() );
731 if( nonzeros == 0UL ) {
736 if( nonzeros == A.rows() * A.columns() ) {
737 maximum = A.begin( 0UL )->value();
740 const size_t index( ( SO ==
rowMajor )?( A.rows() ):( A.columns() ) );
742 for(
size_t i=0UL; i<index; ++i ) {
743 const ConstIterator
end( A.end( i ) );
744 ConstIterator element( A.begin( i ) );
745 for( ; element!=
end; ++element )
746 maximum =
max( maximum, element->value() );
Header file for the isnan shim.
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:994
Header file for mathematical functions.
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:671
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:902
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
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:731
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:85
bool isnan(const DenseMatrix< MT, SO > &dm)
Checks the given dense matrix for not-a-number elements.
Definition: DenseMatrix.h:609
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:85
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:809
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 SparseMatrix base class.
Header file for the IsSquare type trait.
Header file for the matrix storage order types.
Header file for the IsSymmetric type trait.
Header file for the If class template.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
Header file for the IsLower type trait.
Header file for the equal shim.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2475
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:890
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2477
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
Header file for the isDefault shim.
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Header file for the RemoveReference type trait.
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
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.
Header file for the IsUpper type trait.
Header file for the IsExpression type trait class.