35 #ifndef _BLAZE_MATH_ADAPTORS_HERMITIANMATRIX_H_ 36 #define _BLAZE_MATH_ADAPTORS_HERMITIANMATRIX_H_ 116 template<
typename MT,
bool SO,
bool DF >
117 void reset( HermitianMatrix<MT,SO,DF>& m );
119 template<
typename MT,
bool SO,
bool DF >
120 void reset( HermitianMatrix<MT,SO,DF>& m,
size_t i );
122 template<
typename MT,
bool SO,
bool DF >
123 void clear( HermitianMatrix<MT,SO,DF>& m );
125 template<
bool RF,
typename MT,
bool SO,
bool DF >
126 bool isDefault(
const HermitianMatrix<MT,SO,DF>& m );
128 template<
typename MT,
bool SO,
bool DF >
129 bool isIntact(
const HermitianMatrix<MT,SO,DF>& m );
131 template<
typename MT,
bool SO,
bool DF >
132 void swap( HermitianMatrix<MT,SO,DF>& a, HermitianMatrix<MT,SO,DF>& b ) noexcept;
144 template<
typename MT
167 template<
typename MT
184 template<
typename MT
225 return isDefault<RF>( m.matrix_ );
251 template<
typename MT
269 template<
typename MT
305 inline void invert( HermitianMatrix<MT,SO,true>& m )
323 m.matrix_ = std::move( tmp );
347 template<
typename MT
351 inline bool trySet(
const HermitianMatrix<MT,SO,DF>& mat,
size_t i,
size_t j,
const ET& value )
358 return ( i != j ||
isReal( value ) );
380 template<
typename MT
384 inline bool tryAdd(
const HermitianMatrix<MT,SO,DF>& mat,
size_t i,
size_t j,
const ET& value )
386 return trySet( mat, i, j, value );
408 template<
typename MT
412 inline bool trySub(
const HermitianMatrix<MT,SO,DF>& mat,
size_t i,
size_t j,
const ET& value )
414 return trySet( mat, i, j, value );
436 template<
typename MT
440 inline bool tryMult(
const HermitianMatrix<MT,SO,DF>& mat,
size_t i,
size_t j,
const ET& value )
442 return trySet( mat, i, j, value );
464 template<
typename MT
468 inline bool tryDiv(
const HermitianMatrix<MT,SO,DF>& mat,
size_t i,
size_t j,
const ET& value )
470 return trySet( mat, i, j, value );
492 template<
typename MT
496 inline bool tryAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
497 const Vector<VT,false>& rhs,
size_t row,
size_t column )
507 using ET = ElementType_t< HermitianMatrix<MT,SO,DF> >;
509 return ( IsBuiltin_v<ET> ||
536 template<
typename MT
540 inline bool tryAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
541 const Vector<VT,true>& rhs,
size_t row,
size_t column )
551 using ET = ElementType_t< HermitianMatrix<MT,SO,DF> >;
553 return ( IsBuiltin_v<ET> ||
582 template<
typename MT
587 inline bool tryAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
const DenseVector<VT,TF>& rhs,
600 for(
size_t i=0UL; i<(~rhs).
size(); ++i ) {
601 if( !
isReal( (~rhs)[i] ) )
630 template<
typename MT
635 inline bool tryAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
const SparseVector<VT,TF>& rhs,
648 for(
const auto& element : ~rhs ) {
649 if( !
isReal( element.value() ) )
676 template<
typename MT1
681 inline bool tryAssign(
const HermitianMatrix<MT1,SO1,DF>& lhs,
682 const Matrix<MT2,SO2>& rhs,
size_t row,
size_t column )
693 const size_t M( (~rhs).
rows() );
694 const size_t N( (~rhs).
columns() );
705 const size_t subrow( lower ? 0UL :
column -
row );
706 const size_t subcol( lower ?
row -
column : 0UL );
730 template<
typename MT
735 inline bool tryAddAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
736 const Vector<VT,TF>& rhs,
size_t row,
size_t column )
738 return tryAssign( lhs, ~rhs,
row,
column );
762 template<
typename MT
767 inline bool tryAddAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
const Vector<VT,TF>& rhs,
792 template<
typename MT1
797 inline bool tryAddAssign(
const HermitianMatrix<MT1,SO1,DF>& lhs,
798 const Matrix<MT2,SO2>& rhs,
size_t row,
size_t column )
800 return tryAssign( lhs, ~rhs,
row,
column );
823 template<
typename MT
828 inline bool trySubAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
829 const Vector<VT,TF>& rhs,
size_t row,
size_t column )
831 return tryAssign( lhs, ~rhs,
row,
column );
855 template<
typename MT
860 inline bool trySubAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
const Vector<VT,TF>& rhs,
886 template<
typename MT1
891 inline bool trySubAssign(
const HermitianMatrix<MT1,SO1,DF>& lhs,
892 const Matrix<MT2,SO2>& rhs,
size_t row,
size_t column )
894 return tryAssign( lhs, ~rhs,
row,
column );
917 template<
typename MT
922 inline bool tryMultAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
923 const Vector<VT,TF>& rhs,
size_t row,
size_t column )
925 return tryAssign( lhs, ~rhs,
row,
column );
949 template<
typename MT
954 inline bool tryMultAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
const Vector<VT,TF>& rhs,
980 template<
typename MT1
985 inline bool trySchurAssign(
const HermitianMatrix<MT1,SO1,DF>& lhs,
986 const Matrix<MT2,SO2>& rhs,
size_t row,
size_t column )
988 return tryAssign( lhs, ~rhs,
row,
column );
1010 template<
typename MT
1015 inline bool tryDivAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
1016 const Vector<VT,TF>& rhs,
size_t row,
size_t column )
1018 return tryAssign( lhs, ~rhs,
row,
column );
1042 template<
typename MT
1047 inline bool tryDivAssign(
const HermitianMatrix<MT,SO,DF>& lhs,
const Vector<VT,TF>& rhs,
1066 template<
typename MT,
bool SO,
bool DF >
1067 struct Size< HermitianMatrix<MT,SO,DF>, 0UL >
1068 :
public Size<MT,0UL>
1071 template<
typename MT,
bool SO,
bool DF >
1072 struct Size< HermitianMatrix<MT,SO,DF>, 1UL >
1073 :
public Size<MT,1UL>
1089 template<
typename MT,
bool SO,
bool DF >
1090 struct MaxSize< HermitianMatrix<MT,SO,DF>, 0UL >
1091 :
public MaxSize<MT,0UL>
1094 template<
typename MT,
bool SO,
bool DF >
1095 struct MaxSize< HermitianMatrix<MT,SO,DF>, 1UL >
1096 :
public MaxSize<MT,1UL>
1112 template<
typename MT,
bool SO,
bool DF >
1113 struct IsSquare< HermitianMatrix<MT,SO,DF> >
1130 template<
typename MT,
bool SO,
bool DF >
1131 struct IsUniform< HermitianMatrix<MT,SO,DF> >
1132 :
public IsUniform<MT>
1148 template<
typename MT,
bool SO,
bool DF >
1149 struct IsSymmetric< HermitianMatrix<MT,SO,DF> >
1150 :
public IsBuiltin< ElementType_t<MT> >
1166 template<
typename MT,
bool SO,
bool DF >
1167 struct IsHermitian< HermitianMatrix<MT,SO,DF> >
1184 template<
typename MT,
bool SO,
bool DF >
1185 struct IsStrictlyLower< HermitianMatrix<MT,SO,DF> >
1202 template<
typename MT,
bool SO,
bool DF >
1203 struct IsStrictlyUpper< HermitianMatrix<MT,SO,DF> >
1220 template<
typename MT,
bool SO,
bool DF >
1221 struct IsAdaptor< HermitianMatrix<MT,SO,DF> >
1238 template<
typename MT,
bool SO,
bool DF >
1239 struct IsRestricted< HermitianMatrix<MT,SO,DF> >
1256 template<
typename MT,
bool SO >
1257 struct HasConstDataAccess< HermitianMatrix<MT,SO,true> >
1274 template<
typename MT,
bool SO,
bool DF >
1275 struct IsAligned< HermitianMatrix<MT,SO,DF> >
1276 :
public IsAligned<MT>
1292 template<
typename MT,
bool SO,
bool DF >
1293 struct IsContiguous< HermitianMatrix<MT,SO,DF> >
1294 :
public IsContiguous<MT>
1310 template<
typename MT,
bool SO,
bool DF >
1311 struct IsPadded< HermitianMatrix<MT,SO,DF> >
1312 :
public IsPadded<MT>
1328 template<
typename MT,
bool SO,
bool DF >
1329 struct IsResizable< HermitianMatrix<MT,SO,DF> >
1330 :
public IsResizable<MT>
1346 template<
typename MT,
bool SO,
bool DF >
1347 struct IsShrinkable< HermitianMatrix<MT,SO,DF> >
1348 :
public IsShrinkable<MT>
1364 template<
typename MT,
bool SO,
bool DF >
1365 struct RemoveAdaptor< HermitianMatrix<MT,SO,DF> >
1383 template<
typename T1,
typename T2 >
1384 struct AddTraitEval1< T1, T2
1387 ( ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1388 IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ||
1389 ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1390 IsSymmetric_v<T2> && !
IsComplex_v< UnderlyingNumeric_t<T2> > ) ||
1391 ( IsSymmetric_v<T1> && !IsComplex_v< UnderlyingNumeric_t<T1> > &&
1392 IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ) &&
1393 !( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1394 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1396 using Type = HermitianMatrix< typename AddTraitEval2<T1,T2>::Type >;
1412 template<
typename T1,
typename T2 >
1413 struct SubTraitEval1< T1, T2
1416 ( ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1417 IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ||
1418 ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1419 IsSymmetric_v<T2> && !
IsComplex_v< UnderlyingNumeric_t<T2> > ) ||
1420 ( IsSymmetric_v<T1> && !IsComplex_v< UnderlyingNumeric_t<T1> > &&
1421 IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ) &&
1422 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1424 using Type = HermitianMatrix< typename SubTraitEval2<T1,T2>::Type >;
1440 template<
typename T1,
typename T2 >
1441 struct SchurTraitEval1< T1, T2
1444 ( IsHermitian_v<T1> && IsHermitian_v<T2> ) &&
1445 !( IsSymmetric_v<T1> && IsSymmetric_v<T2> ) &&
1446 !( IsDiagonal_v<T1> || IsZero_v<T1> ) &&
1447 !( IsDiagonal_v<T2> || IsZero_v<T2> ) > >
1449 using Type = HermitianMatrix< typename SchurTraitEval2<T1,T2>::Type >;
1465 template<
typename T1,
typename T2 >
1466 struct MultTraitEval1< T1, T2
1469 ( IsHermitian_v<T1> && !IsSymmetric_v<T1> && !IsUniform_v<T1> ) > >
1471 using Type = HermitianMatrix< typename MultTraitEval2<T1,T2>::Type >;
1474 template<
typename T1,
typename T2 >
1475 struct MultTraitEval1< T1, T2
1478 ( IsHermitian_v<T2> && !IsSymmetric_v<T2> && !IsUniform_v<T2> ) > >
1480 using Type = HermitianMatrix< typename MultTraitEval2<T1,T2>::Type >;
1496 template<
typename T1,
typename T2 >
1497 struct DivTraitEval1< T1, T2
1500 using Type = HermitianMatrix< typename DivTraitEval2<T1,T2>::Type >;
1516 template<
typename T,
typename OP >
1517 struct UnaryMapTraitEval1< T, OP
1519 !YieldsSymmetric_v<OP,T> &&
1520 !YieldsIdentity_v<OP,T> > >
1522 using Type = HermitianMatrix< typename UnaryMapTraitEval2<T,OP>::Type, StorageOrder_v<T> >;
1530 template<
typename T1,
typename T2,
typename OP >
1531 struct BinaryMapTraitEval1< T1, T2, OP
1533 !YieldsSymmetric_v<OP,T1,T2> &&
1534 !YieldsIdentity_v<OP,T1,T2> > >
1536 using Type = HermitianMatrix< typename BinaryMapTraitEval2<T1,T2,OP>::Type >;
1552 template<
typename MT,
bool SO,
bool DF >
1553 struct DeclSymTrait< HermitianMatrix<MT,SO,DF> >
1555 using Type = SymmetricMatrix<MT,SO,DF>;
1571 template<
typename MT,
bool SO,
bool DF >
1572 struct DeclHermTrait< HermitianMatrix<MT,SO,DF> >
1574 using Type = HermitianMatrix<MT,SO,DF>;
1590 template<
typename MT,
bool SO,
bool DF >
1591 struct DeclLowTrait< HermitianMatrix<MT,SO,DF> >
1593 using Type = DiagonalMatrix<MT,SO,DF>;
1609 template<
typename MT,
bool SO,
bool DF >
1610 struct DeclUppTrait< HermitianMatrix<MT,SO,DF> >
1612 using Type = DiagonalMatrix<MT,SO,DF>;
1628 template<
typename MT,
bool SO,
bool DF >
1629 struct DeclDiagTrait< HermitianMatrix<MT,SO,DF> >
1631 using Type = DiagonalMatrix<MT,SO,DF>;
1647 template<
typename MT1,
bool SO1,
bool DF1,
typename MT2,
bool SO2,
bool DF2 >
1648 struct HighType< HermitianMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1650 using Type = HermitianMatrix< typename HighType<MT1,MT2>::Type >;
1666 template<
typename MT1,
bool SO1,
bool DF1,
typename MT2,
bool SO2,
bool DF2 >
1667 struct LowType< HermitianMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1669 using Type = HermitianMatrix< typename LowType<MT1,MT2>::Type >;
1685 template<
typename MT,
size_t I,
size_t N >
1686 struct SubmatrixTraitEval1< MT, I, I, N, N
1688 !IsSymmetric_v<MT> > >
1690 using Type = HermitianMatrix< typename SubmatrixTraitEval2<MT,I,I,N,N>::Type >;
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:653
Header file for the UnderlyingNumeric type trait.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Headerfile for the generic min algorithm.
Header file for the decldiag trait.
Header file for the Schur product trait.
constexpr bool IsComplex_v
Auxiliary variable template for the IsComplex type trait.The IsComplex_v variable template provides a...
Definition: IsComplex.h:140
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Flag for the inversion of a diagonal matrix.
Definition: InversionFlag.h:115
Flag for the inversion of a general matrix (same as byLU).
Definition: InversionFlag.h:108
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:139
Header file for the declherm trait.
Flag for the inversion of a upper unitriangular matrix.
Definition: InversionFlag.h:114
Flag for the inversion of a lower unitriangular matrix.
Definition: InversionFlag.h:112
Header file for the IsDiagonal type trait.
Header file for the dense matrix inversion flags.
Flag for the Bunch-Kaufman-based inversion for Hermitian matrices.
Definition: InversionFlag.h:105
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
Header file for the YieldsIdentity type trait.
constexpr bool IsHermitian_v
Auxiliary variable template for the IsHermitian type trait.The IsHermitian_v variable template provid...
Definition: IsHermitian.h:171
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
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the MaxSize type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1644
Header file for the IsMatrix type trait.
Header file for the IsSquare type trait.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:775
Constraint on the data type.
Header file for the LowType type trait.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Flag for the LU-based matrix inversion.
Definition: InversionFlag.h:103
Header file for the IsShrinkable type trait.
Header file for all forward declarations of the math module.
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
Header file for the decllow trait.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Flag for the inversion of a Hermitian matrix (same as byLDLH).
Definition: InversionFlag.h:110
constexpr bool YieldsHermitian_v
Auxiliary variable template for the YieldsHermitian type trait.The YieldsHermitian_v variable templat...
Definition: YieldsHermitian.h:125
Header file for the IsAligned type trait.
Flag for the Bunch-Kaufman-based inversion for symmetric matrices.
Definition: InversionFlag.h:104
HermitianMatrix specialization for sparse matrices.
Header file for the exception macros of the math module.
Header file for the RemoveAdaptor type trait.
Header file for the implementation of the base template of the HeritianMatrix.
Constraint on the data type.
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:360
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the IsPadded type trait.
Header file for the IsAdaptor type trait.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
Header file for the declupp trait.
Flag for the inversion of a symmetric matrix (same as byLDLT).
Definition: InversionFlag.h:109
Header file for run time assertion macros.
Header file for the YieldsSymmetric type trait.
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
Header file for the IsContiguous type trait.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
Header file for the IsZero type trait.
Header file for the declsym trait.
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:617
Matrix adapter for Hermitian matrices.
Definition: BaseTemplate.h:611
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a BLAS compatible data type (i...
Definition: BLASCompatible.h:61
Flag for the Cholesky-based inversion for positive-definite matrices.
Definition: InversionFlag.h:106
#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
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the IsBuiltin type trait.
Header file for the isDivisor shim.
Header file for the StorageOrder type trait.
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
Header file for the IsComplex type trait.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
Header file for the YieldsHermitian type trait.
Header file for the IsHermitian type trait.
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
Header file for the Size type trait.
Header file for the isReal shim.
HermitianMatrix specialization for dense matrices.
InversionFlag
Inversion flag.The InversionFlag type enumeration represents the different types of matrix inversion ...
Definition: InversionFlag.h:101
#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 HighType type trait.
Header file for the TrueType type/value trait base class.