iterative-solver 0.0
 
Loading...
Searching...
No Matches
molpro::linalg::itsolv::detail::MetricChecker< R, Q, P > Class Template Reference

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>

Detailed Description

template<class R, class Q, class P>
class molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >

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 > &params, 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 > &params, 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)
 

Member Typedef Documentation

◆ value_type

template<class R , class Q , class P >
using molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::value_type = typename array::ArrayHandler<R, R>::value_type

◆ value_type_abs

template<class R , class Q , class P >
using molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::value_type_abs = typename array::ArrayHandler<R, R>::value_type_abs

Member Function Documentation

◆ check_hermitian() [1/2]

template<class R , class Q , class P >
static void molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::check_hermitian ( const array::Span< value_type > &  matrix,
const size_t  n 
)
inlinestatic

Checks that the metric matrix in the P space is Hermitian.

Parameters
matrixthe matrix, with the second index running fastest
nits dimension

◆ check_hermitian() [2/2]

template<class R , class Q , class P >
void molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::check_hermitian ( const CVecRef< R > &  params,
const CVecRef< R > &  metric_actions,
const subspace::IXSpace< R, Q, P > &  xspace,
ArrayHandlers< R, Q, P > &  handlers 
) const
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().

Parameters
paramsthe new parameters x
metric_actionsthe actions of the metric on params
xspacethe subspace, before the update
handlersarray handlers

◆ check_positive()

template<class R , class Q , class P >
static void molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::check_positive ( const subspace::Matrix< value_type > &  metric,
const subspace::Matrix< value_type > &  overlap 
)
inlinestatic

◆ check_positive_subspace()

template<class R , class Q , class P >
void molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::check_positive_subspace ( const subspace::Matrix< value_type > &  metric,
const subspace::Matrix< value_type > &  overlap,
const size_t  nP 
)
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.

Parameters
metricthe metric matrix of the subspace
overlapthe 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.

◆ hermiticity_tolerance()

template<class R , class Q , class P >
static value_type_abs molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::hermiticity_tolerance ( )
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.

◆ positivity_tolerance()

template<class R , class Q , class P >
static value_type_abs molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::positivity_tolerance ( )
inlinestatic

The relative tolerance of the check of positivity, calibrated for double precision and rescaled to the working precision

◆ remember()

template<class R , class Q , class P >
void molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::remember ( const CVecRef< R > &  params,
const CVecRef< R > &  metric_actions,
const subspace::IXSpace< R, Q, P > &  xspace,
ArrayHandlers< R, Q, P > &  handlers 
)
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.

◆ reset()

template<class R , class Q , class P >
void molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::reset ( )
inline

Forgets the vectors kept for the check of Hermiticity and the factor of the P space, as when the subspace starts anew

◆ reset_pspace()

template<class R , class Q , class P >
void molpro::linalg::itsolv::detail::MetricChecker< R, Q, P >::reset_pspace ( )
inline

Forgets the factor of the metric matrix in the P space kept by check_positive_subspace(), for a new P space.