35 #ifndef _BLAZE_MATH_DENSE_DENSEMATRIX_H_
36 #define _BLAZE_MATH_DENSE_DENSEMATRIX_H_
89 template<
typename T1,
typename T2 >
90 inline bool operator==(
const DenseMatrix<T1,false>& lhs,
const DenseMatrix<T2,false>& rhs );
92 template<
typename T1,
typename T2 >
93 inline bool operator==(
const DenseMatrix<T1,true>& lhs,
const DenseMatrix<T2,true>& rhs );
95 template<
typename T1,
typename T2,
bool SO >
96 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const DenseMatrix<T2,!SO>& rhs );
98 template<
typename T1,
typename T2,
bool SO >
99 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,false>& rhs );
101 template<
typename T1,
typename T2,
bool SO >
102 inline bool operator==(
const DenseMatrix<T1,SO>& lhs,
const SparseMatrix<T2,true>& rhs );
104 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
105 inline bool operator==(
const SparseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
107 template<
typename T1,
typename T2 >
108 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
109 operator==(
const DenseMatrix<T1,false>& mat, T2 scalar );
111 template<
typename T1,
typename T2 >
112 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
113 operator==(
const DenseMatrix<T1,true>& mat, T2 scalar );
115 template<
typename T1,
typename T2,
bool SO >
116 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
117 operator==( T1 scalar,
const DenseMatrix<T2,SO>& mat );
119 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
120 inline bool operator!=(
const DenseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
122 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
123 inline bool operator!=(
const DenseMatrix<T1,SO1>& lhs,
const SparseMatrix<T2,SO2>& rhs );
125 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
126 inline bool operator!=(
const SparseMatrix<T1,SO1>& lhs,
const DenseMatrix<T2,SO2>& rhs );
128 template<
typename T1,
typename T2,
bool SO >
129 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
130 operator!=(
const DenseMatrix<T1,SO>& mat, T2 scalar );
132 template<
typename T1,
typename T2,
bool SO >
133 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
134 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
385 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
395 for(
size_t i=0; i<A.rows(); ++i ) {
396 for(
size_t j=0; j<A.columns(); ++j ) {
397 if( !
equal( A(i,j), scalar ) )
return false;
418 template<
typename T1
420 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
430 for(
size_t j=0; j<A.columns(); ++j ) {
431 for(
size_t i=0; i<A.rows(); ++i ) {
432 if( !
equal( A(i,j), scalar ) )
return false;
453 template<
typename T1
456 inline typename EnableIf< IsNumeric<T1>,
bool >::Type
459 return ( mat == scalar );
472 template<
typename T1
478 return !( lhs == rhs );
491 template<
typename T1
497 return !( lhs == rhs );
510 template<
typename T1
516 return !( rhs == lhs );
533 template<
typename T1
536 inline typename EnableIf< IsNumeric<T2>,
bool >::Type
539 return !( mat == scalar );
556 template<
typename T1
559 inline typename EnableIf< IsNumeric<T1>,
bool >::Type
562 return !( mat == scalar );
578 template<
typename MT,
bool SO >
579 bool isnan(
const DenseMatrix<MT,SO>& dm );
581 template<
typename MT,
bool SO >
584 template<
typename MT,
bool SO >
587 template<
typename MT,
bool SO >
588 bool isUniform(
const DenseMatrix<MT,SO>& dm );
590 template<
typename MT,
bool SO >
591 bool isLower(
const DenseMatrix<MT,SO>& dm );
593 template<
typename MT,
bool SO >
594 bool isUniLower(
const DenseMatrix<MT,SO>& dm );
596 template<
typename MT,
bool SO >
599 template<
typename MT,
bool SO >
600 bool isUpper(
const DenseMatrix<MT,SO>& dm );
602 template<
typename MT,
bool SO >
603 bool isUniUpper(
const DenseMatrix<MT,SO>& dm );
605 template<
typename MT,
bool SO >
608 template<
typename MT,
bool SO >
609 bool isDiagonal(
const DenseMatrix<MT,SO>& dm );
611 template<
typename MT,
bool SO >
612 bool isIdentity(
const DenseMatrix<MT,SO>& dm );
614 template<
typename MT,
bool SO >
617 template<
typename MT,
bool SO >
643 template<
typename MT
652 for(
size_t i=0UL; i<A.rows(); ++i ) {
653 for(
size_t j=0UL; j<A.columns(); ++j )
654 if(
isnan( A(i,j) ) )
return true;
658 for(
size_t j=0UL; j<A.columns(); ++j ) {
659 for(
size_t i=0UL; i<A.rows(); ++i )
660 if(
isnan( A(i,j) ) )
return true;
695 template<
typename MT
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( 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( A(i,j), A(j,i) ) )
765 template<
typename MT
778 if( (~dm).
rows() < 2UL )
787 for(
size_t i=0UL; i<A.rows(); ++i ) {
788 for(
size_t j=0UL; j<i; ++j ) {
797 for(
size_t j=0UL; j<A.columns(); ++j ) {
798 for(
size_t i=0UL; i<j; ++i ) {
820 template<
typename MT >
821 bool isUniform_backend(
const DenseMatrix<MT,false>& dm,
TrueType )
829 const size_t ibegin( ( IsStrictlyLower<MT>::value )?( 1UL ):( 0UL ) );
830 const size_t iend ( ( IsStrictlyUpper<MT>::value )?( (~dm).
rows()-1UL ):( (~dm).
rows() ) );
832 for(
size_t i=ibegin; i<iend; ++i ) {
833 if( !IsUpper<MT>::value ) {
834 for(
size_t j=0UL; j<i; ++j ) {
841 if( !IsLower<MT>::value ) {
842 for(
size_t j=i+1UL; j<(~dm).
columns(); ++j ) {
863 template<
typename MT >
864 bool isUniform_backend(
const DenseMatrix<MT,true>& dm,
TrueType )
872 const size_t jbegin( ( IsStrictlyUpper<MT>::value )?( 1UL ):( 0UL ) );
873 const size_t jend ( ( IsStrictlyLower<MT>::value )?( (~dm).
columns()-1UL ):( (~dm).
columns() ) );
875 for(
size_t j=jbegin; j<jend; ++j ) {
876 if( !IsLower<MT>::value ) {
877 for(
size_t i=0UL; i<j; ++i ) {
884 if( !IsUpper<MT>::value ) {
885 for(
size_t i=j+1UL; i<(~dm).
rows(); ++i ) {
906 template<
typename MT >
907 bool isUniform_backend(
const DenseMatrix<MT,false>& dm,
FalseType )
917 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
918 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
919 if( (~dm)(i,j) != cmp )
938 template<
typename MT >
939 bool isUniform_backend(
const DenseMatrix<MT,true>& dm,
FalseType )
949 for(
size_t j=0UL; j<(~dm).
columns(); ++j ) {
950 for(
size_t i=0UL; i<(~dm).
rows(); ++i ) {
951 if( (~dm)(i,j) != cmp )
988 template<
typename MT
995 if( (~dm).
rows() == 0UL || (~dm).
columns() == 0UL ||
996 ( (~dm).
rows() == 1UL && (~dm).
columns() == 1UL ) )
1042 template<
typename MT
1057 if( (~dm).
rows() < 2UL )
1063 for(
size_t i=0UL; i<A.rows()-1UL; ++i ) {
1064 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1071 for(
size_t j=1UL; j<A.columns(); ++j ) {
1072 for(
size_t i=0UL; i<j; ++i ) {
1119 template<
typename MT
1138 for(
size_t i=0UL; i<A.rows(); ++i ) {
1139 if( !
isOne( A(i,i) ) )
1141 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1148 for(
size_t j=0UL; j<A.columns(); ++j ) {
1149 for(
size_t i=0UL; i<j; ++i ) {
1153 if( !
isOne( A(j,j) ) )
1199 template<
typename MT
1218 for(
size_t i=0UL; i<A.rows(); ++i ) {
1219 for(
size_t j=i; j<A.columns(); ++j ) {
1226 for(
size_t j=0UL; j<A.columns(); ++j ) {
1227 for(
size_t i=0UL; i<=j; ++i ) {
1275 template<
typename MT
1290 if( (~dm).
rows() < 2UL )
1296 for(
size_t i=1UL; i<A.rows(); ++i ) {
1297 for(
size_t j=0UL; j<i; ++j ) {
1304 for(
size_t j=0UL; j<A.columns()-1UL; ++j ) {
1305 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 ) {
1376 if( !
isOne( A(i,i) ) )
1381 for(
size_t j=0UL; j<A.columns(); ++j ) {
1382 if( !
isOne( A(j,j) ) )
1384 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1432 template<
typename MT
1451 for(
size_t i=0UL; i<A.rows(); ++i ) {
1452 for(
size_t j=0UL; j<=i; ++j ) {
1459 for(
size_t j=0UL; j<A.columns(); ++j ) {
1460 for(
size_t i=j; i<A.rows(); ++i ) {
1509 template<
typename MT
1524 if( (~dm).
rows() < 2UL )
1530 for(
size_t i=0UL; i<A.rows(); ++i ) {
1532 for(
size_t j=0UL; j<i; ++j ) {
1538 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1546 for(
size_t j=0UL; j<A.columns(); ++j ) {
1548 for(
size_t i=0UL; i<j; ++i ) {
1554 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1603 template<
typename MT
1619 if( (~dm).
rows() == 0UL )
1625 for(
size_t i=0UL; i<A.rows(); ++i ) {
1627 for(
size_t j=0UL; j<i; ++j ) {
1636 for(
size_t j=i+1UL; j<A.columns(); ++j ) {
1644 for(
size_t j=0UL; j<A.columns(); ++j ) {
1646 for(
size_t i=0UL; i<j; ++i ) {
1655 for(
size_t i=j+1UL; i<A.rows(); ++i ) {
1680 template<
typename MT
1691 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1693 ET minimum( A(0,0) );
1696 for(
size_t j=1UL; j<A.columns(); ++j )
1697 minimum =
min( minimum, A(0UL,j) );
1698 for(
size_t i=1UL; i<A.rows(); ++i )
1699 for(
size_t j=0UL; j<A.columns(); ++j )
1700 minimum =
min( minimum, A(i,j) );
1703 for(
size_t i=1UL; i<A.rows(); ++i )
1704 minimum =
min( minimum, A(i,0UL) );
1705 for(
size_t j=1UL; j<A.columns(); ++j )
1706 for(
size_t i=0UL; i<A.rows(); ++i )
1707 minimum =
min( minimum, A(i,j) );
1727 template<
typename MT
1738 if( A.rows() == 0UL || A.columns() == 0UL )
return ET();
1740 ET maximum( A(0,0) );
1743 for(
size_t j=1UL; j<A.columns(); ++j )
1744 maximum =
max( maximum, A(0UL,j) );
1745 for(
size_t i=1UL; i<A.rows(); ++i )
1746 for(
size_t j=0UL; j<A.columns(); ++j )
1747 maximum =
max( maximum, A(i,j) );
1750 for(
size_t i=1UL; i<A.rows(); ++i )
1751 maximum =
max( maximum, A(i,0UL) );
1752 for(
size_t j=1UL; j<A.columns(); ++j )
1753 for(
size_t i=0UL; i<A.rows(); ++i )
1754 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.
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:609
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Header file for mathematical functions.
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1511
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:603
#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:1201
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1434
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:569
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:697
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
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.
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:1044
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:117
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Header file for the SparseMatrix base class.
ConjExprTrait< typename DiagonalProxy< MT >::RepresentedType >::Type conj(const DiagonalProxy< MT > &proxy)
Computing the complex conjugate of the represented element.
Definition: DiagonalProxy.h:487
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:2592
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
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:1277
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:629
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:1121
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
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 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:92
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
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:73
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: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:990
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 isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:767
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:2583
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
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:1354
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
Header file for the IsHermitian type trait.
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:105
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1605
Header file for the IsExpression type trait class.