Checks that the metric of a generalised problem has the properties that its kind declares, as far as the subspace shows them. More...
#include <MetricChecker.h>
Checks that the metric of a generalised problem has the properties that its kind declares, as far as the subspace shows them.
All checks throw std::runtime_error if they fail. They compare against hermiticity_tolerance() or positivity_tolerance() relative to the size of the quantities involved.
Public Types | |
| using | value_type = typename array::ArrayHandler< R, R >::value_type |
| using | value_type_abs = typename array::ArrayHandler< R, R >::value_type_abs |
Public Member Functions | |
| void | reset () |
| void | reset_pspace () |
| Forgets the factor of the metric matrix in the P space kept by check_positive_subspace(), for a new P space. | |
| void | check_hermitian (const CVecRef< R > ¶ms, const CVecRef< R > &metric_actions, const subspace::IXSpace< R, Q, P > &xspace, ArrayHandlers< R, Q, P > &handlers) const |
| Checks that the metric is Hermitian on new parameters before they are added to the subspace. | |
| void | remember (const CVecRef< R > ¶ms, const CVecRef< R > &metric_actions, const subspace::IXSpace< R, Q, P > &xspace, ArrayHandlers< R, Q, P > &handlers) |
| Keeps the first new parameter and its action of the metric for the next check_hermitian(), if the subspace does not keep the actions of the metric, in the same Q vectors in every call. | |
| void | check_positive_subspace (const subspace::Matrix< value_type > &metric, const subspace::Matrix< value_type > &overlap, const size_t nP) |
| Checks that the metric matrix of the subspace is consistent with a positive (semi)definite metric. | |
Static Public Member Functions | |
| static value_type_abs | hermiticity_tolerance () |
| The relative tolerance of the checks of Hermiticity, calibrated for double precision and rescaled to the working precision. It is loose enough for actions of a metric that are only approximate, e.g. from screened integrals, but catches a metric that is not Hermitian at all. | |
| static value_type_abs | positivity_tolerance () |
| static void | check_hermitian (const array::Span< value_type > &matrix, const size_t n) |
| Checks that the metric matrix in the P space is Hermitian. | |
| static void | check_positive (const subspace::Matrix< value_type > &metric, const subspace::Matrix< value_type > &overlap) |
| using molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::value_type = typename array::ArrayHandler<R, R>::value_type |
| using molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::value_type_abs = typename array::ArrayHandler<R, R>::value_type_abs |
|
inlinestatic |
Checks that the metric matrix in the P space is Hermitian.
| matrix | the matrix, with the second index running fastest |
| n | its dimension |
|
inline |
Checks that the metric is Hermitian on new parameters before they are added to the subspace.
The metric matrix is calculated from the actions of the metric on new parameters only, assuming that it is Hermitian. This compares <x|M q> with <M x|q> for the new parameters x and a vector q of an earlier update: the most recent Q vector if the subspace keeps the actions of the metric, otherwise the first parameter of the previous update, kept by remember().
| params | the new parameters x |
| metric_actions | the actions of the metric on params |
| xspace | the subspace, before the update |
| handlers | array handlers |
|
inlinestatic |
|
inline |
Checks that the metric matrix of the subspace is consistent with a positive (semi)definite metric.
The metric matrix M_ij = <b_i|M b_j> of a positive definite metric M is positive definite for linearly independent subspace vectors b_i, which a Cholesky factorisation confirms cheaply. Where it fails, which nearly linearly dependent subspace vectors can cause as well, the Rayleigh quotients of M on the span of the subspace vectors decide. They are the eigenvalues of the metric matrix in the basis orthonormalised with the overlap S_ij = <b_i|b_j>, leaving out nearly linearly dependent directions. Orthonormalising amplifies the rounding errors of the metric matrix by up to the inverse of the smallest eigenvalue of the overlap that is kept, so the metric fails the check only if a Rayleigh quotient is negative by more than positivity_tolerance() times the largest plus these amplified rounding errors.
An indefinite metric is noticed only once one of its negative directions enters the subspace.
| metric | the metric matrix of the subspace |
| overlap | the overlap matrix of the subspace vectors |
Like check_positive(), for the metric matrix of the subspace, whose first nP rows and columns, those of the P space, do not change between calls until reset_pspace()
The Cholesky factor of the P-space block is kept, so that only the Schur complement of the other vectors has to be factorised, at a cost of nP^2 times their number, rather than the whole matrix. If that fails, check_positive() decides.
|
inlinestatic |
The relative tolerance of the checks of Hermiticity, calibrated for double precision and rescaled to the working precision. It is loose enough for actions of a metric that are only approximate, e.g. from screened integrals, but catches a metric that is not Hermitian at all.
|
inlinestatic |
The relative tolerance of the check of positivity, calibrated for double precision and rescaled to the working precision
|
inline |
Keeps the first new parameter and its action of the metric for the next check_hermitian(), if the subspace does not keep the actions of the metric, in the same Q vectors in every call.
|
inline |
Forgets the vectors kept for the check of Hermiticity and the factor of the P space, as when the subspace starts anew
|
inline |
Forgets the factor of the metric matrix in the P space kept by check_positive_subspace(), for a new P space.