35 #ifndef _BLAZE_MATH_DENSE_DENSEMATRIX_H_ 36 #define _BLAZE_MATH_DENSE_DENSEMATRIX_H_ 94 template<
typename T1,
typename T2 >
95 inline bool operator==(
const DenseMatrix<T1,false>& lhs,
const DenseMatrix<T2,false>& rhs );
97 template<
typename T1,
typename T2 >
98 inline bool operator==(
const DenseMatrix<T1,true>& lhs,
const DenseMatrix<T2,true>& rhs );
100 template<
typename T1,
typename T2,
bool SO >
101 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const DenseMatrix<T2,!SO>& rhs );
103 template<
typename T1,
typename T2,
bool SO >
104 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,false>& rhs );
106 template<
typename T1,
typename T2,
bool SO >
107 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,true>& rhs );
109 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
110 inline bool operator==(
const SparseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
112 template<
typename T1,
typename T2 >
113 inline EnableIf_<IsNumeric<T2>,
bool >
operator==(
const DenseMatrix<T1,false>& mat, T2 scalar );
115 template<
typename T1,
typename T2 >
116 inline EnableIf_<IsNumeric<T2>,
bool >
operator==(
const DenseMatrix<T1,true>& mat, T2 scalar );
118 template<
typename T1,
typename T2,
bool SO >
119 inline EnableIf_<IsNumeric<T2>,
bool >
operator==( T1 scalar,
const DenseMatrix<T2,SO>& mat );
121 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
122 inline bool operator!=(
const DenseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
124 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
125 inline bool operator!=(
const DenseMatrix<T1,SO1>& lhs,
const SparseMatrix<T2,SO2>& rhs );
127 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
128 inline bool operator!=(
const SparseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
130 template<
typename T1,
typename T2,
bool SO >
131 inline EnableIf_<IsNumeric<T2>,
bool >
operator!=(
const DenseMatrix<T1,SO>& mat, T2 scalar );
133 template<
typename T1,
typename T2,
bool SO >
134 inline EnableIf_<IsNumeric<T2>,
bool >
operator!=( T1 scalar,
const DenseMatrix<T2,SO>& mat );
147 template<
typename T1
164 for(
size_t i=0; i<A.rows(); ++i ) {
165 for(
size_t j=0; j<A.columns(); ++j ) {
166 if( !
equal( A(i,j), B(i,j) ) )
return false;
183 template<
typename T1
200 for(
size_t j=0; j<A.columns(); ++j ) {
201 for(
size_t i=0; i<A.rows(); ++i ) {
202 if( !
equal( A(i,j), B(i,j) ) )
return false;
219 template<
typename T1
237 const size_t rows ( A.rows() );
238 const size_t columns( A.columns() );
239 const size_t block ( 16 );
241 for(
size_t ii=0; ii<
rows; ii+=block ) {
242 const size_t iend( ( rows < ii+block )?( rows ):( ii+block ) );
243 for(
size_t jj=0; jj<
columns; jj+=block ) {
244 const size_t jend( ( columns < jj+block )?( columns ):( jj+block ) );
245 for(
size_t i=ii; i<iend; ++i ) {
246 for(
size_t j=jj; j<jend; ++j ) {
247 if( !
equal( A(i,j), B(i,j) ) )
return false;
266 template<
typename T1
287 for(
size_t i=0; i<B.rows(); ++i ) {
289 for(
ConstIterator element=B.begin(i); element!=B.end(i); ++element, ++j ) {
290 for( ; j<element->index(); ++j ) {
293 if( !
equal( element->value(), A(i,j) ) )
return false;
295 for( ; j<A.columns(); ++j ) {
313 template<
typename T1
334 for(
size_t j=0; j<B.columns(); ++j ) {
336 for(
ConstIterator element=B.begin(j); element!=B.end(j); ++element, ++i ) {
337 for( ; i<element->index(); ++i ) {
340 if( !
equal( element->value(), A(i,j) ) )
return false;
342 for( ; i<A.rows(); ++i ) {
360 template<
typename T1
366 return ( rhs == lhs );
383 template<
typename T1
394 for(
size_t i=0; i<A.rows(); ++i ) {
395 for(
size_t j=0; j<A.columns(); ++j ) {
396 if( !
equal( A(i,j), scalar ) )
return false;
417 template<
typename T1
428 for(
size_t j=0; j<A.columns(); ++j ) {
429 for(
size_t i=0; i<A.rows(); ++i ) {
430 if( !
equal( A(i,j), scalar ) )
return false;
451 template<
typename T1
456 return ( mat == scalar );
469 template<
typename T1
475 return !( lhs == rhs );
488 template<
typename T1
494 return !( lhs == rhs );
507 template<
typename T1
513 return !( rhs == lhs );
530 template<
typename T1
535 return !( mat == scalar );
552 template<
typename T1
557 return !( mat == scalar );
573 template<
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<
bool RF,
typename MT,
bool SO >
609 template<
typename MT,
bool SO >
612 template<
typename MT,
bool SO >
638 template<
typename MT
647 for(
size_t i=0UL; i<A.rows(); ++i ) {
648 for(
size_t j=0UL; j<A.columns(); ++j )
649 if(
isnan( A(i,j) ) )
return true;
653 for(
size_t j=0UL; j<A.columns(); ++j ) {
654 for(
size_t i=0UL; i<A.rows(); ++i )
655 if(
isnan( A(i,j) ) )
return true;
719 for(
size_t i=1UL; i<A.rows(); ++i ) {
720 for(
size_t j=0UL; j<i; ++j ) {
721 if( !equal<RF>( A(i,j), A(j,i) ) )
727 for(
size_t j=1UL; j<A.columns(); ++j ) {
728 for(
size_t i=0UL; i<j; ++i ) {
729 if( !equal<RF>( A(i,j), A(j,i) ) )
795 for(
size_t i=0UL; i<A.rows(); ++i ) {
796 for(
size_t j=0UL; j<i; ++j ) {
797 if( !equal<RF>( A(i,j),
conj( A(j,i) ) ) )
800 if( !isReal<RF>( A(i,i) ) )
805 for(
size_t j=0UL; j<A.columns(); ++j ) {
806 for(
size_t i=0UL; i<j; ++i ) {
807 if( !equal<RF>( A(i,j),
conj( A(j,i) ) ) )
810 if( !isReal<RF>( A(j,j) ) )
841 for(
size_t i=ibegin; i<iend; ++i ) {
843 for(
size_t j=0UL; j<i; ++j ) {
844 if( !isDefault<RF>( (~dm)(i,j) ) )
848 if( !isDefault<RF>( (~dm)(i,i) ) )
851 for(
size_t j=i+1UL; j<(~dm).
columns(); ++j ) {
852 if( !isDefault<RF>( (~dm)(i,j) ) )
885 for(
size_t j=jbegin; j<jend; ++j ) {
887 for(
size_t i=0UL; i<j; ++i ) {
888 if( !isDefault<RF>( (~dm)(i,j) ) )
892 if( !isDefault<RF>( (~dm)(j,j) ) )
895 for(
size_t i=j+1UL; i<(~dm).
rows(); ++i ) {
896 if( !isDefault<RF>( (~dm)(i,j) ) )
928 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
929 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
930 if( (~dm)(i,j) != cmp )
961 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
962 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
963 if( (~dm)(i,j) != cmp )
1017 ( (~dm).
rows() == 1UL && (~dm).
columns() == 1UL ) )
1086 if( (~dm).
rows() < 2UL )
1092 for(
size_t i=0UL; i<A.rows()-1UL; ++i ) {
1093 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1094 if( !isDefault<RF>( A(i,j) ) )
1100 for(
size_t j=1UL; j<A.columns(); ++j ) {
1101 for(
size_t i=0UL; i<j; ++i ) {
1102 if( !isDefault<RF>( A(i,j) ) )
1174 for(
size_t i=0UL; i<A.rows(); ++i ) {
1175 if( !isOne<RF>( A(i,i) ) )
1177 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1178 if( !isZero<RF>( A(i,j) ) )
1184 for(
size_t j=0UL; j<A.columns(); ++j ) {
1185 for(
size_t i=0UL; i<j; ++i ) {
1186 if( !isZero<RF>( A(i,j) ) )
1189 if( !isOne<RF>( A(j,j) ) )
1261 for(
size_t i=0UL; i<A.rows(); ++i ) {
1262 for(
size_t j=i; j<A.columns(); ++j ) {
1263 if( !isDefault<RF>( A(i,j) ) )
1269 for(
size_t j=0UL; j<A.columns(); ++j ) {
1270 for(
size_t i=0UL; i<=j; ++i ) {
1271 if( !isDefault<RF>( A(i,j) ) )
1341 if( (~dm).
rows() < 2UL )
1347 for(
size_t i=1UL; i<A.rows(); ++i ) {
1348 for(
size_t j=0UL; j<i; ++j ) {
1349 if( !isDefault<RF>( A(i,j) ) )
1355 for(
size_t j=0UL; j<A.columns()-1UL; ++j ) {
1356 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1357 if( !isDefault<RF>( A(i,j) ) )
1429 for(
size_t i=0UL; i<A.rows(); ++i ) {
1430 for(
size_t j=0UL; j<i; ++j ) {
1431 if( !isZero<RF>( A(i,j) ) )
1434 if( !isOne<RF>( A(i,i) ) )
1439 for(
size_t j=0UL; j<A.columns(); ++j ) {
1440 if( !isOne<RF>( A(j,j) ) )
1442 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1443 if( !isZero<RF>( A(i,j) ) )
1516 for(
size_t i=0UL; i<A.rows(); ++i ) {
1517 for(
size_t j=0UL; j<=i; ++j ) {
1518 if( !isDefault<RF>( A(i,j) ) )
1524 for(
size_t j=0UL; j<A.columns(); ++j ) {
1525 for(
size_t i=j; i<A.rows(); ++i ) {
1526 if( !isDefault<RF>( A(i,j) ) )
1597 if( (~dm).
rows() < 2UL )
1603 for(
size_t i=0UL; i<A.rows(); ++i ) {
1605 for(
size_t j=0UL; j<i; ++j ) {
1606 if( !isDefault<RF>( A(i,j) ) )
1611 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1612 if( !isDefault<RF>( A(i,j) ) )
1619 for(
size_t j=0UL; j<A.columns(); ++j ) {
1621 for(
size_t i=0UL; i<j; ++i ) {
1622 if( !isDefault<RF>( A(i,j) ) )
1627 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1628 if( !isDefault<RF>( A(i,j) ) )
1699 if( (~dm).
rows() == 0UL )
1705 for(
size_t i=0UL; i<A.rows(); ++i ) {
1707 for(
size_t j=0UL; j<i; ++j ) {
1708 if( !isZero<RF>( A(i,j) ) )
1716 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1717 if( !isZero<RF>( A(i,j) ) )
1724 for(
size_t j=0UL; j<A.columns(); ++j ) {
1726 for(
size_t i=0UL; i<j; ++i ) {
1727 if( !isZero<RF>( A(i,j) ) )
1735 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1736 if( !isZero<RF>( A(i,j) ) )
1760 template<
typename MT
1771 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1773 ET minimum( A(0,0) );
1776 for(
size_t j=1UL; j<A.columns(); ++j )
1777 minimum =
min( minimum, A(0UL,j) );
1778 for(
size_t i=1UL; i<A.rows(); ++i )
1779 for(
size_t j=0UL; j<A.columns(); ++j )
1780 minimum =
min( minimum, A(i,j) );
1783 for(
size_t i=1UL; i<A.rows(); ++i )
1784 minimum =
min( minimum, A(i,0UL) );
1785 for(
size_t j=1UL; j<A.columns(); ++j )
1786 for(
size_t i=0UL; i<A.rows(); ++i )
1787 minimum =
min( minimum, A(i,j) );
1807 template<
typename MT
1818 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1820 ET maximum( A(0,0) );
1823 for(
size_t j=1UL; j<A.columns(); ++j )
1824 maximum =
max( maximum, A(0UL,j) );
1825 for(
size_t i=1UL; i<A.rows(); ++i )
1826 for(
size_t j=0UL; j<A.columns(); ++j )
1827 maximum =
max( maximum, A(i,j) );
1830 for(
size_t i=1UL; i<A.rows(); ++i )
1831 maximum =
max( maximum, A(i,0UL) );
1832 for(
size_t j=1UL; j<A.columns(); ++j )
1833 for(
size_t i=0UL; i<A.rows(); ++i )
1834 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.
Header file for auxiliary alias declarations.
Headerfile for the generic min algorithm.
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1073
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1328
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1245
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:1158
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1762
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:1584
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:343
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1809
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:78
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1686
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
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
Headerfile for the generic max algorithm.
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.
Header file for the DenseMatrix base class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
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:340
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:682
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:1010
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:1500
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:154
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:778
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
Compile time check for built-in data types.This type trait tests whether or not the given template pa...
Definition: IsBuiltin.h:75
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:700
#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:224
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:324
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
Header file for the IsBuiltin type trait.
bool isUniUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper unitriangular matrix.
Definition: DenseMatrix.h:1413
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
Header file for the IsUpper type trait.
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1321
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:742
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.