35 #ifndef _BLAZE_MATH_DENSE_DENSEMATRIX_H_
36 #define _BLAZE_MATH_DENSE_DENSEMATRIX_H_
87 template<
typename T1,
typename T2 >
88 inline bool operator==(
const DenseMatrix<T1,false>& lhs,
const DenseMatrix<T2,false>& rhs );
90 template<
typename T1,
typename T2 >
91 inline bool operator==(
const DenseMatrix<T1,true>& lhs,
const DenseMatrix<T2,true>& rhs );
93 template<
typename T1,
typename T2,
bool SO >
94 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const DenseMatrix<T2,!SO>& rhs );
96 template<
typename T1,
typename T2,
bool SO >
97 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,false>& rhs );
99 template<
typename T1,
typename T2,
bool SO >
100 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,true>& rhs );
102 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
103 inline bool operator==(
const SparseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
105 template<
typename T1,
typename T2 >
106 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
107 operator==(
const DenseMatrix<T1,false>& mat, T2 scalar );
109 template<
typename T1,
typename T2 >
110 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
111 operator==(
const DenseMatrix<T1,true>& mat, T2 scalar );
113 template<
typename T1,
typename T2,
bool SO >
114 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
115 operator==( T1 scalar,
const DenseMatrix<T2,SO>& mat );
117 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
118 inline bool operator!=(
const DenseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
120 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
121 inline bool operator!=(
const DenseMatrix<T1,SO1>& lhs,
const SparseMatrix<T2,SO2>& rhs );
123 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
124 inline bool operator!=(
const SparseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
126 template<
typename T1,
typename T2,
bool SO >
127 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
128 operator!=(
const DenseMatrix<T1,SO>& mat, T2 scalar );
130 template<
typename T1,
typename T2,
bool SO >
131 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
132 operator!=( T1 scalar,
const DenseMatrix<T2,SO>& mat );
145 template<
typename T1
162 for(
size_t i=0; i<A.rows(); ++i ) {
163 for(
size_t j=0; j<A.columns(); ++j ) {
164 if( !
equal( A(i,j), B(i,j) ) )
return false;
181 template<
typename T1
198 for(
size_t j=0; j<A.columns(); ++j ) {
199 for(
size_t i=0; i<A.rows(); ++i ) {
200 if( !
equal( A(i,j), B(i,j) ) )
return false;
217 template<
typename T1
235 const size_t rows ( A.rows() );
236 const size_t columns( A.columns() );
237 const size_t block ( 16 );
239 for(
size_t ii=0; ii<
rows; ii+=block ) {
240 const size_t iend( ( rows < ii+block )?( rows ):( ii+block ) );
241 for(
size_t jj=0; jj<
columns; jj+=block ) {
242 const size_t jend( ( columns < jj+block )?( columns ):( jj+block ) );
243 for(
size_t i=ii; i<iend; ++i ) {
244 for(
size_t j=jj; j<jend; ++j ) {
245 if( !
equal( A(i,j), B(i,j) ) )
return false;
264 template<
typename T1
285 for(
size_t i=0; i<B.rows(); ++i ) {
287 for( ConstIterator element=B.begin(i); element!=B.end(i); ++element, ++j ) {
288 for( ; j<element->index(); ++j ) {
291 if( !
equal( element->value(), A(i,j) ) )
return false;
293 for( ; j<A.columns(); ++j ) {
311 template<
typename T1
332 for(
size_t j=0; j<B.columns(); ++j ) {
334 for( ConstIterator element=B.begin(j); element!=B.end(j); ++element, ++i ) {
335 for( ; i<element->index(); ++i ) {
338 if( !
equal( element->value(), A(i,j) ) )
return false;
340 for( ; i<A.rows(); ++i ) {
358 template<
typename T1
364 return ( rhs == lhs );
381 template<
typename T1
383 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
393 for(
size_t i=0; i<A.rows(); ++i ) {
394 for(
size_t j=0; j<A.columns(); ++j ) {
395 if( !
equal( A(i,j), scalar ) )
return false;
416 template<
typename T1
418 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
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
454 inline typename EnableIf< IsNumeric<T1>,
bool >::Type
457 return ( mat == scalar );
470 template<
typename T1
476 return !( lhs == rhs );
489 template<
typename T1
495 return !( lhs == rhs );
508 template<
typename T1
514 return !( rhs == lhs );
531 template<
typename T1
534 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
537 return !( mat == scalar );
554 template<
typename T1
557 inline typename EnableIf< IsNumeric<T1>,
bool >::Type
560 return !( mat == scalar );
576 template<
typename MT,
bool SO >
577 bool isnan(
const DenseMatrix<MT,SO>& dm );
579 template<
typename MT,
bool SO >
582 template<
typename MT,
bool SO >
583 bool isUniform(
const DenseMatrix<MT,SO>& dm );
585 template<
typename MT,
bool SO >
586 bool isLower(
const DenseMatrix<MT,SO>& dm );
588 template<
typename MT,
bool SO >
589 bool isUniLower(
const DenseMatrix<MT,SO>& dm );
591 template<
typename MT,
bool SO >
594 template<
typename MT,
bool SO >
595 bool isUpper(
const DenseMatrix<MT,SO>& dm );
597 template<
typename MT,
bool SO >
598 bool isUniUpper(
const DenseMatrix<MT,SO>& dm );
600 template<
typename MT,
bool SO >
603 template<
typename MT,
bool SO >
604 bool isDiagonal(
const DenseMatrix<MT,SO>& dm );
606 template<
typename MT,
bool SO >
607 bool isIdentity(
const DenseMatrix<MT,SO>& dm );
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;
690 template<
typename MT
702 if( (~dm).
rows() < 2UL )
711 for(
size_t i=1UL; i<A.rows(); ++i ) {
712 for(
size_t j=0UL; j<i; ++j ) {
713 if( !
equal( A(i,j), A(j,i) ) )
719 for(
size_t j=1UL; j<A.columns(); ++j ) {
720 for(
size_t i=0UL; i<j; ++i ) {
721 if( !
equal( A(i,j), A(j,i) ) )
740 template<
typename MT >
741 bool isUniform_backend(
const DenseMatrix<MT,false>& dm,
TrueType )
749 const size_t ibegin( ( IsStrictlyLower<MT>::value )?( 1UL ):( 0UL ) );
750 const size_t iend ( ( IsStrictlyUpper<MT>::value )?( (~dm).
rows()-1UL ):( (~dm).
rows() ) );
752 for(
size_t i=ibegin; i<iend; ++i ) {
753 if( !IsUpper<MT>::value ) {
754 for(
size_t j=0UL; j<i; ++j ) {
761 if( !IsLower<MT>::value ) {
762 for(
size_t j=i+1UL; j<(~dm).
columns(); ++j ) {
783 template<
typename MT >
784 bool isUniform_backend(
const DenseMatrix<MT,true>& dm,
TrueType )
792 const size_t jbegin( ( IsStrictlyUpper<MT>::value )?( 1UL ):( 0UL ) );
793 const size_t jend ( ( IsStrictlyLower<MT>::value )?( (~dm).
columns()-1UL ):( (~dm).
columns() ) );
795 for(
size_t j=jbegin; j<jend; ++j ) {
796 if( !IsLower<MT>::value ) {
797 for(
size_t i=0UL; i<j; ++i ) {
804 if( !IsUpper<MT>::value ) {
805 for(
size_t i=j+1UL; i<(~dm).
rows(); ++i ) {
826 template<
typename MT >
827 bool isUniform_backend(
const DenseMatrix<MT,false>& dm,
FalseType )
837 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
838 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
839 if( (~dm)(i,j) != cmp )
858 template<
typename MT >
859 bool isUniform_backend(
const DenseMatrix<MT,true>& dm,
FalseType )
869 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
870 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
871 if( (~dm)(i,j) != cmp )
908 template<
typename MT
915 if( (~dm).
rows() == 0UL || (~dm).
columns() == 0UL ||
916 ( (~dm).
rows() == 1UL && (~dm).
columns() == 1UL ) )
962 template<
typename MT
977 if( (~dm).
rows() < 2UL )
983 for(
size_t i=0UL; i<A.rows()-1UL; ++i ) {
984 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
991 for(
size_t j=1UL; j<A.columns(); ++j ) {
992 for(
size_t i=0UL; i<j; ++i ) {
1039 template<
typename MT
1058 for(
size_t i=0UL; i<A.rows(); ++i ) {
1059 if( !
isOne( A(i,i) ) )
1061 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1068 for(
size_t j=0UL; j<A.columns(); ++j ) {
1069 for(
size_t i=0UL; i<j; ++i ) {
1073 if( !
isOne( A(j,j) ) )
1119 template<
typename MT
1138 for(
size_t i=0UL; i<A.rows(); ++i ) {
1139 for(
size_t j=i; j<A.columns(); ++j ) {
1146 for(
size_t j=0UL; j<A.columns(); ++j ) {
1147 for(
size_t i=0UL; i<=j; ++i ) {
1195 template<
typename MT
1210 if( (~dm).
rows() < 2UL )
1216 for(
size_t i=1UL; i<A.rows(); ++i ) {
1217 for(
size_t j=0UL; j<i; ++j ) {
1224 for(
size_t j=0UL; j<A.columns()-1UL; ++j ) {
1225 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1272 template<
typename MT
1291 for(
size_t i=0UL; i<A.rows(); ++i ) {
1292 for(
size_t j=0UL; j<i; ++j ) {
1296 if( !
isOne( A(i,i) ) )
1301 for(
size_t j=0UL; j<A.columns(); ++j ) {
1302 if( !
isOne( A(j,j) ) )
1304 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1352 template<
typename MT
1371 for(
size_t i=0UL; i<A.rows(); ++i ) {
1372 for(
size_t j=0UL; j<=i; ++j ) {
1379 for(
size_t j=0UL; j<A.columns(); ++j ) {
1380 for(
size_t i=j; i<A.rows(); ++i ) {
1429 template<
typename MT
1444 if( (~dm).
rows() < 2UL )
1450 for(
size_t i=0UL; i<A.rows(); ++i ) {
1452 for(
size_t j=0UL; j<i; ++j ) {
1458 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1466 for(
size_t j=0UL; j<A.columns(); ++j ) {
1468 for(
size_t i=0UL; i<j; ++i ) {
1474 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1523 template<
typename MT
1539 if( (~dm).
rows() == 0UL )
1545 for(
size_t i=0UL; i<A.rows(); ++i ) {
1547 for(
size_t j=0UL; j<i; ++j ) {
1556 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1564 for(
size_t j=0UL; j<A.columns(); ++j ) {
1566 for(
size_t i=0UL; i<j; ++i ) {
1575 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1600 template<
typename MT
1611 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1613 ET minimum( A(0,0) );
1616 for(
size_t j=1UL; j<A.columns(); ++j )
1617 minimum =
min( minimum, A(0UL,j) );
1618 for(
size_t i=1UL; i<A.rows(); ++i )
1619 for(
size_t j=0UL; j<A.columns(); ++j )
1620 minimum =
min( minimum, A(i,j) );
1623 for(
size_t i=1UL; i<A.rows(); ++i )
1624 minimum =
min( minimum, A(i,0UL) );
1625 for(
size_t j=1UL; j<A.columns(); ++j )
1626 for(
size_t i=0UL; i<A.rows(); ++i )
1627 minimum =
min( minimum, A(i,j) );
1647 template<
typename MT
1658 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1660 ET maximum( A(0,0) );
1663 for(
size_t j=1UL; j<A.columns(); ++j )
1664 maximum =
max( maximum, A(0UL,j) );
1665 for(
size_t i=1UL; i<A.rows(); ++i )
1666 for(
size_t j=0UL; j<A.columns(); ++j )
1667 maximum =
max( maximum, A(i,j) );
1670 for(
size_t i=1UL; i<A.rows(); ++i )
1671 maximum =
max( maximum, A(i,0UL) );
1672 for(
size_t j=1UL; j<A.columns(); ++j )
1673 for(
size_t i=0UL; i<A.rows(); ++i )
1674 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:79
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:1649
Header file for mathematical functions.
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1431
Header file for the IsUniUpper type trait.
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
Compile time check for triangular matrix types.This type trait tests whether or not the given templat...
Definition: IsTriangular.h:105
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:902
#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:118
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1121
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1354
Header file for the FalseType type/value trait base class.
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:692
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
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:90
Header file for the IsIdentity type trait.
bool isnan(const DenseMatrix< MT, SO > &dm)
Checks the given dense matrix for not-a-number elements.
Definition: DenseMatrix.h:640
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
Header file for the IsUniLower type trait.
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:964
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:107
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Header file for the SparseMatrix base class.
Header file for the IsSquare type trait.
Header file for the matrix storage order types.
Constraint on the data type.
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:85
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:2511
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1602
Header file for the DenseMatrix base class.
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:92
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:1197
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
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:1041
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
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:85
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:92
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
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.
#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:118
Header file for the RemoveReference type trait.
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:910
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
boost::false_type 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 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:2502
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
bool isUniUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper unitriangular matrix.
Definition: DenseMatrix.h:1274
Header file for the IsUpper type trait.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
EnableIf< IsNumeric< Type >, bool >::Type isOne(const Type &v)
Returns whether the given value/object represents the numeric value 1.
Definition: IsOne.h:80
#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:105
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1525
Header file for the IsExpression type trait class.