35 #ifndef _BLAZE_MATH_DENSE_DENSEMATRIX_H_ 36 #define _BLAZE_MATH_DENSE_DENSEMATRIX_H_ 91 template<
typename T1,
typename T2 >
92 inline bool operator==(
const DenseMatrix<T1,false>& lhs,
const DenseMatrix<T2,false>& rhs );
94 template<
typename T1,
typename T2 >
95 inline bool operator==(
const DenseMatrix<T1,true>& lhs,
const DenseMatrix<T2,true>& rhs );
97 template<
typename T1,
typename T2,
bool SO >
98 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const DenseMatrix<T2,!SO>& rhs );
100 template<
typename T1,
typename T2,
bool SO >
101 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,false>& rhs );
103 template<
typename T1,
typename T2,
bool SO >
104 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,true>& rhs );
106 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
107 inline bool operator==(
const SparseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
109 template<
typename T1,
typename T2 >
110 inline EnableIf_<IsNumeric<T2>,
bool >
operator==(
const DenseMatrix<T1,false>& mat, T2 scalar );
112 template<
typename T1,
typename T2 >
113 inline EnableIf_<IsNumeric<T2>,
bool >
operator==(
const DenseMatrix<T1,true>& mat, T2 scalar );
115 template<
typename T1,
typename T2,
bool SO >
116 inline EnableIf_<IsNumeric<T2>,
bool >
operator==( T1 scalar,
const DenseMatrix<T2,SO>& mat );
118 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
119 inline bool operator!=(
const DenseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
121 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
122 inline bool operator!=(
const DenseMatrix<T1,SO1>& lhs,
const SparseMatrix<T2,SO2>& rhs );
124 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
125 inline bool operator!=(
const SparseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
127 template<
typename T1,
typename T2,
bool SO >
128 inline EnableIf_<IsNumeric<T2>,
bool >
operator!=(
const DenseMatrix<T1,SO>& mat, T2 scalar );
130 template<
typename T1,
typename T2,
bool SO >
131 inline EnableIf_<IsNumeric<T2>,
bool >
operator!=( T1 scalar,
const DenseMatrix<T2,SO>& mat );
144 template<
typename T1
161 for(
size_t i=0; i<A.rows(); ++i ) {
162 for(
size_t j=0; j<A.columns(); ++j ) {
163 if( !
equal( A(i,j), B(i,j) ) )
return false;
180 template<
typename T1
197 for(
size_t j=0; j<A.columns(); ++j ) {
198 for(
size_t i=0; i<A.rows(); ++i ) {
199 if( !
equal( A(i,j), B(i,j) ) )
return false;
216 template<
typename T1
234 const size_t rows ( A.rows() );
235 const size_t columns( A.columns() );
236 const size_t block ( 16 );
238 for(
size_t ii=0; ii<
rows; ii+=block ) {
239 const size_t iend( ( rows < ii+block )?( rows ):( ii+block ) );
240 for(
size_t jj=0; jj<
columns; jj+=block ) {
241 const size_t jend( ( columns < jj+block )?( columns ):( jj+block ) );
242 for(
size_t i=ii; i<iend; ++i ) {
243 for(
size_t j=jj; j<jend; ++j ) {
244 if( !
equal( A(i,j), B(i,j) ) )
return false;
263 template<
typename T1
284 for(
size_t i=0; i<B.rows(); ++i ) {
286 for( ConstIterator element=B.begin(i); element!=B.end(i); ++element, ++j ) {
287 for( ; j<element->index(); ++j ) {
290 if( !
equal( element->value(), A(i,j) ) )
return false;
292 for( ; j<A.columns(); ++j ) {
310 template<
typename T1
331 for(
size_t j=0; j<B.columns(); ++j ) {
333 for( ConstIterator element=B.begin(j); element!=B.end(j); ++element, ++i ) {
334 for( ; i<element->index(); ++i ) {
337 if( !
equal( element->value(), A(i,j) ) )
return false;
339 for( ; i<A.rows(); ++i ) {
357 template<
typename T1
363 return ( rhs == lhs );
380 template<
typename T1
391 for(
size_t i=0; i<A.rows(); ++i ) {
392 for(
size_t j=0; j<A.columns(); ++j ) {
393 if( !
equal( A(i,j), scalar ) )
return false;
414 template<
typename T1
425 for(
size_t j=0; j<A.columns(); ++j ) {
426 for(
size_t i=0; i<A.rows(); ++i ) {
427 if( !
equal( A(i,j), scalar ) )
return false;
448 template<
typename T1
453 return ( mat == scalar );
466 template<
typename T1
472 return !( lhs == rhs );
485 template<
typename T1
491 return !( lhs == rhs );
504 template<
typename T1
510 return !( rhs == lhs );
527 template<
typename T1
532 return !( mat == scalar );
549 template<
typename T1
554 return !( mat == scalar );
570 template<
typename MT,
bool SO >
573 template<
bool RF,
typename MT,
bool SO >
576 template<
bool RF,
typename MT,
bool SO >
579 template<
bool RF,
typename MT,
bool SO >
582 template<
bool RF,
typename MT,
bool SO >
585 template<
bool RF,
typename MT,
bool SO >
588 template<
bool RF,
typename MT,
bool SO >
591 template<
bool RF,
typename MT,
bool SO >
594 template<
bool RF,
typename MT,
bool SO >
597 template<
bool RF,
typename MT,
bool SO >
600 template<
bool RF,
typename MT,
bool SO >
603 template<
bool RF,
typename MT,
bool SO >
606 template<
typename MT,
bool SO >
609 template<
typename MT,
bool SO >
635 template<
typename MT
644 for(
size_t i=0UL; i<A.rows(); ++i ) {
645 for(
size_t j=0UL; j<A.columns(); ++j )
646 if(
isnan( A(i,j) ) )
return true;
650 for(
size_t j=0UL; j<A.columns(); ++j ) {
651 for(
size_t i=0UL; i<A.rows(); ++i )
652 if(
isnan( A(i,j) ) )
return true;
707 if( (~dm).
rows() < 2UL )
716 for(
size_t i=1UL; i<A.rows(); ++i ) {
717 for(
size_t j=0UL; j<i; ++j ) {
718 if( !equal<RF>( A(i,j), A(j,i) ) )
724 for(
size_t j=1UL; j<A.columns(); ++j ) {
725 for(
size_t i=0UL; i<j; ++i ) {
726 if( !equal<RF>( A(i,j), A(j,i) ) )
789 for(
size_t i=0UL; i<A.rows(); ++i ) {
790 for(
size_t j=0UL; j<i; ++j ) {
791 if( !equal<RF>( A(i,j),
conj( A(j,i) ) ) )
794 if( !isReal<RF>( A(i,i) ) )
799 for(
size_t j=0UL; j<A.columns(); ++j ) {
800 for(
size_t i=0UL; i<j; ++i ) {
801 if( !equal<RF>( A(i,j),
conj( A(j,i) ) ) )
804 if( !isReal<RF>( A(j,j) ) )
835 for(
size_t i=ibegin; i<iend; ++i ) {
837 for(
size_t j=0UL; j<i; ++j ) {
838 if( !isDefault<RF>( (~dm)(i,j) ) )
842 if( !isDefault<RF>( (~dm)(i,i) ) )
845 for(
size_t j=i+1UL; j<(~dm).
columns(); ++j ) {
846 if( !isDefault<RF>( (~dm)(i,j) ) )
879 for(
size_t j=jbegin; j<jend; ++j ) {
881 for(
size_t i=0UL; i<j; ++i ) {
882 if( !isDefault<RF>( (~dm)(i,j) ) )
886 if( !isDefault<RF>( (~dm)(j,j) ) )
889 for(
size_t i=j+1UL; i<(~dm).
rows(); ++i ) {
890 if( !isDefault<RF>( (~dm)(i,j) ) )
922 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
923 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
924 if( (~dm)(i,j) != cmp )
955 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
956 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
957 if( (~dm)(i,j) != cmp )
1009 if( (~dm).
rows() == 0UL || (~dm).
columns() == 0UL ||
1010 ( (~dm).
rows() == 1UL && (~dm).
columns() == 1UL ) )
1079 if( (~dm).
rows() < 2UL )
1085 for(
size_t i=0UL; i<A.rows()-1UL; ++i ) {
1086 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1087 if( !isDefault<RF>( A(i,j) ) )
1093 for(
size_t j=1UL; j<A.columns(); ++j ) {
1094 for(
size_t i=0UL; i<j; ++i ) {
1095 if( !isDefault<RF>( A(i,j) ) )
1167 for(
size_t i=0UL; i<A.rows(); ++i ) {
1168 if( !isOne<RF>( A(i,i) ) )
1170 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1171 if( !isZero<RF>( A(i,j) ) )
1177 for(
size_t j=0UL; j<A.columns(); ++j ) {
1178 for(
size_t i=0UL; i<j; ++i ) {
1179 if( !isZero<RF>( A(i,j) ) )
1182 if( !isOne<RF>( A(j,j) ) )
1254 for(
size_t i=0UL; i<A.rows(); ++i ) {
1255 for(
size_t j=i; j<A.columns(); ++j ) {
1256 if( !isDefault<RF>( A(i,j) ) )
1262 for(
size_t j=0UL; j<A.columns(); ++j ) {
1263 for(
size_t i=0UL; i<=j; ++i ) {
1264 if( !isDefault<RF>( A(i,j) ) )
1334 if( (~dm).
rows() < 2UL )
1340 for(
size_t i=1UL; i<A.rows(); ++i ) {
1341 for(
size_t j=0UL; j<i; ++j ) {
1342 if( !isDefault<RF>( A(i,j) ) )
1348 for(
size_t j=0UL; j<A.columns()-1UL; ++j ) {
1349 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1350 if( !isDefault<RF>( A(i,j) ) )
1422 for(
size_t i=0UL; i<A.rows(); ++i ) {
1423 for(
size_t j=0UL; j<i; ++j ) {
1424 if( !isZero<RF>( A(i,j) ) )
1427 if( !isOne<RF>( A(i,i) ) )
1432 for(
size_t j=0UL; j<A.columns(); ++j ) {
1433 if( !isOne<RF>( A(j,j) ) )
1435 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1436 if( !isZero<RF>( A(i,j) ) )
1509 for(
size_t i=0UL; i<A.rows(); ++i ) {
1510 for(
size_t j=0UL; j<=i; ++j ) {
1511 if( !isDefault<RF>( A(i,j) ) )
1517 for(
size_t j=0UL; j<A.columns(); ++j ) {
1518 for(
size_t i=j; i<A.rows(); ++i ) {
1519 if( !isDefault<RF>( A(i,j) ) )
1590 if( (~dm).
rows() < 2UL )
1596 for(
size_t i=0UL; i<A.rows(); ++i ) {
1598 for(
size_t j=0UL; j<i; ++j ) {
1599 if( !isDefault<RF>( A(i,j) ) )
1604 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1605 if( !isDefault<RF>( A(i,j) ) )
1612 for(
size_t j=0UL; j<A.columns(); ++j ) {
1614 for(
size_t i=0UL; i<j; ++i ) {
1615 if( !isDefault<RF>( A(i,j) ) )
1620 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1621 if( !isDefault<RF>( A(i,j) ) )
1692 if( (~dm).
rows() == 0UL )
1698 for(
size_t i=0UL; i<A.rows(); ++i ) {
1700 for(
size_t j=0UL; j<i; ++j ) {
1701 if( !isZero<RF>( A(i,j) ) )
1709 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1710 if( !isZero<RF>( A(i,j) ) )
1717 for(
size_t j=0UL; j<A.columns(); ++j ) {
1719 for(
size_t i=0UL; i<j; ++i ) {
1720 if( !isZero<RF>( A(i,j) ) )
1728 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1729 if( !isZero<RF>( A(i,j) ) )
1753 template<
typename MT
1764 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1766 ET minimum( A(0,0) );
1769 for(
size_t j=1UL; j<A.columns(); ++j )
1770 minimum =
min( minimum, A(0UL,j) );
1771 for(
size_t i=1UL; i<A.rows(); ++i )
1772 for(
size_t j=0UL; j<A.columns(); ++j )
1773 minimum =
min( minimum, A(i,j) );
1776 for(
size_t i=1UL; i<A.rows(); ++i )
1777 minimum =
min( minimum, A(i,0UL) );
1778 for(
size_t j=1UL; j<A.columns(); ++j )
1779 for(
size_t i=0UL; i<A.rows(); ++i )
1780 minimum =
min( minimum, A(i,j) );
1800 template<
typename MT
1811 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1813 ET maximum( A(0,0) );
1816 for(
size_t j=1UL; j<A.columns(); ++j )
1817 maximum =
max( maximum, A(0UL,j) );
1818 for(
size_t i=1UL; i<A.rows(); ++i )
1819 for(
size_t j=0UL; j<A.columns(); ++j )
1820 maximum =
max( maximum, A(i,j) );
1823 for(
size_t i=1UL; i<A.rows(); ++i )
1824 maximum =
max( maximum, A(i,0UL) );
1825 for(
size_t j=1UL; j<A.columns(); ++j )
1826 for(
size_t i=0UL; i<A.rows(); ++i )
1827 maximum =
max( maximum, A(i,j) );
#define BLAZE_CONSTRAINT_MUST_BE_TRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a lower or upper triangular matrix t...
Definition: Triangular.h:61
Header file for the isnan shim.
const DMatForEachExpr< MT, Conj, SO > conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatForEachExpr.h:1214
Header file for auxiliary alias declarations.
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Header file for mathematical functions.
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1066
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1321
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1238
Header file for the IsUniUpper type trait.
Compile time check for triangular matrix types.This type trait tests whether or not the given templat...
Definition: IsTriangular.h:87
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper triangular matrix type...
Definition: Triangular.h:81
constexpr bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:76
Header file for the FalseType type/value trait base class.
Header file for the IsDiagonal type trait.
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
bool isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:1151
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1755
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
Header file for the IsIdentity type trait.
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1577
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:88
Header file for the IsUniLower type trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:71
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:119
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1679
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
Header file for the SparseMatrix base class.
Header file for the matrix storage order types.
Constraint on the data type.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:86
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
Header file for the DenseMatrix base class.
Header file for the isZero shim.
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for the IsLower type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:90
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:336
Header file for the equal shim.
Header file for the IsUniTriangular type trait.
Header file for the IsTriangular type trait.
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:655
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:1004
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the isOne shim.
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:86
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
Compile time check for identity matrices.This type trait tests whether or not the given template para...
Definition: IsIdentity.h:90
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1493
Header file for run time assertion macros.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:775
Header file for the isDefault shim.
Compile time check for Hermitian matrices.This type trait tests whether or not the given template par...
Definition: IsHermitian.h:85
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:697
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
typename T::ConstReference ConstReference_
Alias declaration for nested ConstReference type definitions.The ConstReference_ alias declaration pr...
Definition: Aliases.h:143
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:320
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
bool isUniUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper unitriangular matrix.
Definition: DenseMatrix.h:1406
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Header file for the IsUpper type trait.
Header file for the IsHermitian type trait.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:677
Header file for the isReal shim.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the TrueType type/value trait base class.
Compile time check for unitriangular matrix types.This type trait tests whether or not the given temp...
Definition: IsUniTriangular.h:87
Header file for the IsExpression type trait class.