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 >
571 bool isnan(
const DenseMatrix<MT,SO>& dm );
573 template<
typename MT,
bool SO >
576 template<
typename MT,
bool SO >
579 template<
typename MT,
bool SO >
580 bool isUniform(
const DenseMatrix<MT,SO>& dm );
582 template<
typename MT,
bool SO >
583 bool isLower(
const DenseMatrix<MT,SO>& dm );
585 template<
typename MT,
bool SO >
586 bool isUniLower(
const DenseMatrix<MT,SO>& dm );
588 template<
typename MT,
bool SO >
591 template<
typename MT,
bool SO >
592 bool isUpper(
const DenseMatrix<MT,SO>& dm );
594 template<
typename MT,
bool SO >
595 bool isUniUpper(
const DenseMatrix<MT,SO>& dm );
597 template<
typename MT,
bool SO >
600 template<
typename MT,
bool SO >
601 bool isDiagonal(
const DenseMatrix<MT,SO>& dm );
603 template<
typename MT,
bool SO >
604 bool isIdentity(
const DenseMatrix<MT,SO>& dm );
606 template<
typename MT,
bool SO >
607 const ElementType_<MT>
min(
const DenseMatrix<MT,SO>& dm );
609 template<
typename MT,
bool SO >
610 const ElementType_<MT>
max(
const DenseMatrix<MT,SO>& dm );
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;
687 template<
typename MT
699 if( (~dm).
rows() < 2UL )
708 for(
size_t i=1UL; i<A.rows(); ++i ) {
709 for(
size_t j=0UL; j<i; ++j ) {
710 if( !
equal( A(i,j), A(j,i) ) )
716 for(
size_t j=1UL; j<A.columns(); ++j ) {
717 for(
size_t i=0UL; i<j; ++i ) {
718 if( !
equal( A(i,j), A(j,i) ) )
757 template<
typename MT
770 if( (~dm).
rows() < 2UL )
779 for(
size_t i=0UL; i<A.rows(); ++i ) {
780 for(
size_t j=0UL; j<i; ++j ) {
789 for(
size_t j=0UL; j<A.columns(); ++j ) {
790 for(
size_t i=0UL; i<j; ++i ) {
812 template<
typename MT >
813 bool isUniform_backend(
const DenseMatrix<MT,false>& dm,
TrueType )
821 const size_t ibegin( ( IsStrictlyLower<MT>::value )?( 1UL ):( 0UL ) );
822 const size_t iend ( ( IsStrictlyUpper<MT>::value )?( (~dm).
rows()-1UL ):( (~dm).
rows() ) );
824 for(
size_t i=ibegin; i<iend; ++i ) {
825 if( !IsUpper<MT>::value ) {
826 for(
size_t j=0UL; j<i; ++j ) {
833 if( !IsLower<MT>::value ) {
834 for(
size_t j=i+1UL; j<(~dm).
columns(); ++j ) {
855 template<
typename MT >
856 bool isUniform_backend(
const DenseMatrix<MT,true>& dm,
TrueType )
864 const size_t jbegin( ( IsStrictlyUpper<MT>::value )?( 1UL ):( 0UL ) );
865 const size_t jend ( ( IsStrictlyLower<MT>::value )?( (~dm).
columns()-1UL ):( (~dm).
columns() ) );
867 for(
size_t j=jbegin; j<jend; ++j ) {
868 if( !IsLower<MT>::value ) {
869 for(
size_t i=0UL; i<j; ++i ) {
876 if( !IsUpper<MT>::value ) {
877 for(
size_t i=j+1UL; i<(~dm).
rows(); ++i ) {
898 template<
typename MT >
899 bool isUniform_backend(
const DenseMatrix<MT,false>& dm,
FalseType )
907 ConstReference_<MT> cmp( (~dm)(0UL,0UL) );
909 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
910 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
911 if( (~dm)(i,j) != cmp )
930 template<
typename MT >
931 bool isUniform_backend(
const DenseMatrix<MT,true>& dm,
FalseType )
939 ConstReference_<MT> cmp( (~dm)(0UL,0UL) );
941 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
942 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
943 if( (~dm)(i,j) != cmp )
980 template<
typename MT
987 if( (~dm).
rows() == 0UL || (~dm).
columns() == 0UL ||
988 ( (~dm).
rows() == 1UL && (~dm).
columns() == 1UL ) )
1034 template<
typename MT
1049 if( (~dm).
rows() < 2UL )
1055 for(
size_t i=0UL; i<A.rows()-1UL; ++i ) {
1056 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1063 for(
size_t j=1UL; j<A.columns(); ++j ) {
1064 for(
size_t i=0UL; i<j; ++i ) {
1111 template<
typename MT
1129 for(
size_t i=0UL; i<A.rows(); ++i ) {
1130 if( !
isOne( A(i,i) ) )
1132 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1139 for(
size_t j=0UL; j<A.columns(); ++j ) {
1140 for(
size_t i=0UL; i<j; ++i ) {
1144 if( !
isOne( A(j,j) ) )
1190 template<
typename MT
1208 for(
size_t i=0UL; i<A.rows(); ++i ) {
1209 for(
size_t j=i; j<A.columns(); ++j ) {
1216 for(
size_t j=0UL; j<A.columns(); ++j ) {
1217 for(
size_t i=0UL; i<=j; ++i ) {
1265 template<
typename MT
1280 if( (~dm).
rows() < 2UL )
1286 for(
size_t i=1UL; i<A.rows(); ++i ) {
1287 for(
size_t j=0UL; j<i; ++j ) {
1294 for(
size_t j=0UL; j<A.columns()-1UL; ++j ) {
1295 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1342 template<
typename MT
1360 for(
size_t i=0UL; i<A.rows(); ++i ) {
1361 for(
size_t j=0UL; j<i; ++j ) {
1365 if( !
isOne( A(i,i) ) )
1370 for(
size_t j=0UL; j<A.columns(); ++j ) {
1371 if( !
isOne( A(j,j) ) )
1373 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1421 template<
typename MT
1439 for(
size_t i=0UL; i<A.rows(); ++i ) {
1440 for(
size_t j=0UL; j<=i; ++j ) {
1447 for(
size_t j=0UL; j<A.columns(); ++j ) {
1448 for(
size_t i=j; i<A.rows(); ++i ) {
1497 template<
typename MT
1512 if( (~dm).
rows() < 2UL )
1518 for(
size_t i=0UL; i<A.rows(); ++i ) {
1520 for(
size_t j=0UL; j<i; ++j ) {
1526 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1534 for(
size_t j=0UL; j<A.columns(); ++j ) {
1536 for(
size_t i=0UL; i<j; ++i ) {
1542 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1591 template<
typename MT
1606 if( (~dm).
rows() == 0UL )
1612 for(
size_t i=0UL; i<A.rows(); ++i ) {
1614 for(
size_t j=0UL; j<i; ++j ) {
1623 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1631 for(
size_t j=0UL; j<A.columns(); ++j ) {
1633 for(
size_t i=0UL; i<j; ++i ) {
1642 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1667 template<
typename MT
1678 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1680 ET minimum( A(0,0) );
1683 for(
size_t j=1UL; j<A.columns(); ++j )
1684 minimum =
min( minimum, A(0UL,j) );
1685 for(
size_t i=1UL; i<A.rows(); ++i )
1686 for(
size_t j=0UL; j<A.columns(); ++j )
1687 minimum =
min( minimum, A(i,j) );
1690 for(
size_t i=1UL; i<A.rows(); ++i )
1691 minimum =
min( minimum, A(i,0UL) );
1692 for(
size_t j=1UL; j<A.columns(); ++j )
1693 for(
size_t i=0UL; i<A.rows(); ++i )
1694 minimum =
min( minimum, A(i,j) );
1714 template<
typename MT
1725 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1727 ET maximum( A(0,0) );
1730 for(
size_t j=1UL; j<A.columns(); ++j )
1731 maximum =
max( maximum, A(0UL,j) );
1732 for(
size_t i=1UL; i<A.rows(); ++i )
1733 for(
size_t j=0UL; j<A.columns(); ++j )
1734 maximum =
max( maximum, A(i,j) );
1737 for(
size_t i=1UL; i<A.rows(); ++i )
1738 maximum =
max( maximum, A(i,0UL) );
1739 for(
size_t j=1UL; j<A.columns(); ++j )
1740 for(
size_t i=0UL; i<A.rows(); ++i )
1741 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.
BoolConstant< false > FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:635
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:1158
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 isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1499
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
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1192
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1423
Header file for the FalseType type/value trait base class.
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:595
Header file for the IsDiagonal type trait.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:689
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
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.
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:88
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
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:1716
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1036
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:109
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
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:2647
Header file for the DenseMatrix base class.
Header file for the isZero shim.
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:330
Header file for the equal shim.
Header file for the IsUniTriangular type trait.
Header file for the IsTriangular type trait.
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1267
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 isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:1113
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
Header file for run time assertion macros.
bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:73
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
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
#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
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:982
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:759
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:615
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isUniUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper unitriangular matrix.
Definition: DenseMatrix.h:1344
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:609
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
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1593
Header file for the IsExpression type trait class.