iterative-solver 0.0
 
Loading...
Searching...
No Matches
molpro::linalg::itsolv::detail Namespace Reference

Namespaces

namespace  dspace
 

Classes

class  DSpaceResetter
 Resets D space constructing full solutions as the new working set, removing instabilities from Q space, and clearing D space. More...
 
struct  eigenvalue_order
 Orders eigenvalues by non-descending real part, then by imaginary part. More...
 
struct  orthogonalised_subspace
 A generalised eigenproblem reduced to a standard one by symmetric orthogonalisation of the metric. More...
 

Functions

template<typename value_type >
int eigensolver_hermitian_kernel (std::false_type, std::span< value_type > a, std::span< real_type_t< value_type > > w, size_t dimension)
 Eigen implementation of the hermitian eigenproblem, used for every scalar type LAPACK does not cover.
 
template<typename value_type >
std::list< SVD< value_type > > svd_system_impl (size_t nrows, size_t ncols, const array::Span< value_type > &m, real_type_t< value_type > threshold, bool hermitian, bool reduce_to_rank)
 Implementation of svd_system(), shared by its real and complex overloads.
 
template<typename value_type >
orthogonalised_subspace< value_type > orthogonalise_subspace (const std::vector< value_type > &matrix, const std::vector< value_type > &metric, size_t dimension, real_type_t< value_type > svdThreshold, int verbosity)
 Reduce H C = S C E to the standard eigenproblem Hbar U = U E, whose solution is C = X U.
 
template<typename value_type >
void solve_LinearEquations_impl (std::vector< value_type > &solution, std::vector< value_type > &eigenvalues, const std::vector< value_type > &matrix, const std::vector< value_type > &metric, const std::vector< value_type > &rhs, const size_t dimension, size_t nroot, real_type_t< value_type > augmented_hessian, real_type_t< value_type > svdThreshold, int verbosity)
 Implementation of solve_LinearEquations(), shared by its real and complex overloads.
 
template<typename value_type >
void solve_DIIS_impl (std::vector< value_type > &solution, const std::vector< value_type > &matrix, const size_t dimension, real_type_t< value_type > svdThreshold, int verbosity)
 Implementation of solve_DIIS(), shared by its real and complex overloads.
 
template<typename value_type , typename value_type_abs >
auto redundant_parameters (const subspace::Matrix< value_type > &overlap, const size_t oR, const size_t nR, const value_type_abs svd_thresh, Logger &logger)
 Deduces a set of parameters that are redundant due to linear dependencies.
 
template<class R , class Q , class P , typename value_type >
void resize_qspace (subspace::IXSpace< R, Q, P > &xspace, const subspace::Matrix< value_type > &solutions, std::size_t max_size, Logger &logger)
 Removes Q parameters that have smallest contribution to any solution until Q space size is within limit.
 
template<class R , class Q >
auto max_overlap_with_R (const CVecRef< R > &rparams, const CVecRef< Q > &qparams, array::ArrayHandler< R, Q > &handler, Logger &logger)
 Returns list of Q indices with maximum overlap to R parameters, sorted in descending order.
 
std::vector< std::pair< size_t, size_t > > parameter_batches (const size_t nsol, const size_t nparam)
 
template<class R , class Q , class P , typename value_type >
void construct_solution (const VecRef< R > &params, const std::vector< int > &roots, const subspace::Matrix< value_type > &solutions, const std::vector< std::reference_wrapper< P > > &pparams, const std::vector< std::reference_wrapper< Q > > &qparams, const std::vector< std::reference_wrapper< Q > > &dparams, size_t oP, size_t oQ, size_t oD, ArrayHandlers< R, Q, P > &handlers)
 
template<typename T >
std::vector< std::vector< T > > construct_vectorP (const std::vector< int > &roots, const subspace::Matrix< T > &solutions, const size_t oP, const size_t nP)
 
template<class R >
void normalise (const size_t n_roots, const VecRef< R > &params, const VecRef< R > &actions, array::ArrayHandler< R, R > &handler, Logger &logger)
 
template<class R , typename T >
void update_errors (std::vector< T > &errors, const CVecRef< R > &residual, array::ArrayHandler< R, R > &handler)
 
template<typename T >
std::vector< int > select_working_set (const size_t nw, const std::vector< T > &errors, const T threshold, const std::vector< T > &value_errors, const T value_threshold)
 
template<class R >
void normalise (VecRef< R > &params, array::ArrayHandler< R, R > &handler, Logger &logger, typename array::ArrayHandler< R, R >::value_type_abs thresh=1/std::numeric_limits< typename array::ArrayHandler< R, R >::value_type_abs >::max())
 
template<class R , class Q , class P , typename value_type >
auto append_overlap_with_r (const subspace::Matrix< value_type > &overlap, const CVecRef< R > &params, const CVecRef< P > &pparams, const CVecRef< Q > &qparams, const CVecRef< Q > &dparams, ArrayHandlers< R, Q, P > &handlers, Logger &logger)
 Constructs overlap of the full subspace by appending overlap with new parameters to the overlap of previous subspace.
 
template<typename value_type >
std::vector< std::size_t > limit_qspace_size (const subspace::Dimensions &dims, const QSpaceOptions &opts, const subspace::Matrix< value_type > &solutions, Logger &logger)
 Ensures that size Q space is within limit by proposing Q parameters for deletion.
 
template<class R , class Q , class P , typename value_type , typename value_type_abs >
auto construct_dspace (const subspace::Matrix< value_type > &solutions, const subspace::IXSpace< R, Q, P > &xspace, const std::vector< std::size_t > &q_delete, const value_type_abs norm_thresh, const value_type_abs svd_thresh, array::ArrayHandler< Q, Q > &handler, Logger &logger)
 Constructs the new D space by projecting the solutions onto Qd+D subspace and ensuring they are well conditioned.
 
template<class R , class Q , class P , typename value_type , typename value_type_abs >
auto modified_gram_schmidt (const VecRef< R > &rparams, const subspace::Matrix< value_type > &overlap, const subspace::Matrix< value_type > &rx_overlap, const subspace::Dimensions &dims, const CVecRef< P > &pparams, const CVecRef< Q > &qparams, const CVecRef< Q > &dparams, const value_type_abs norm_thresh, ArrayHandlers< R, Q, P > &handlers, Logger &logger)
 Orthogonalises R parameters against P+Q+D subspace (and themselves)
 
template<class R >
auto get_new_working_set (const std::vector< int > &working_set, const CVecRef< R > &params, const CVecRef< R > &wparams)
 Returns new working set based on parameters included in wparams.
 
template<class R , class Q , class P >
auto propose_rspace (IterativeSolver< R, Q, P > &solver, const VecRef< R > &parameters, const VecRef< R > &residuals, subspace::IXSpace< R, Q, P > &xspace, subspace::ISubspaceSolver< R, Q, P > &subspace_solver, ArrayHandlers< R, Q, P > &handlers, Logger &logger, const RSpaceOptions< typename array::ArrayHandler< R, R >::value_type_abs > &r_opts, const QSpaceOptions &q_opts, molpro::profiler::Profiler &profiler)
 Proposes new parameters for the subspace from the preconditioned residuals.
 

Function Documentation

◆ append_overlap_with_r()

template<class R , class Q , class P , typename value_type >
auto molpro::linalg::itsolv::detail::append_overlap_with_r ( const subspace::Matrix< value_type > &  overlap,
const CVecRef< R > &  params,
const CVecRef< P > &  pparams,
const CVecRef< Q > &  qparams,
const CVecRef< Q > &  dparams,
ArrayHandlers< R, Q, P > &  handlers,
Logger &  logger 
)

Constructs overlap of the full subspace by appending overlap with new parameters to the overlap of previous subspace.

Parameters
ovoverlap of P+Q+D
paramsnew parameters
pparamsP space parameters
qparamsQ space parameters
dparamsD space parameters
handlersarray handlers
loggerlogger

◆ construct_dspace()

template<class R , class Q , class P , typename value_type , typename value_type_abs >
auto molpro::linalg::itsolv::detail::construct_dspace ( const subspace::Matrix< value_type > &  solutions,
const subspace::IXSpace< R, Q, P > &  xspace,
const std::vector< std::size_t > &  q_delete,
const value_type_abs  norm_thresh,
const value_type_abs  svd_thresh,
array::ArrayHandler< Q, Q > &  handler,
Logger &  logger 
)

Constructs the new D space by projecting the solutions onto Qd+D subspace and ensuring they are well conditioned.

Parameters
xspaceX space container
q_deleteQ parameters marked for deletion
norm_threshnorm threshold for parameters to be considered null
svd_threshsvd threshold for marking the null space
handlerarray handler
loggerlogger
Returns
D space parameters and actions

◆ construct_solution()

template<class R , class Q , class P , typename value_type >
void molpro::linalg::itsolv::detail::construct_solution ( const VecRef< R > &  params,
const std::vector< int > &  roots,
const subspace::Matrix< value_type > &  solutions,
const std::vector< std::reference_wrapper< P > > &  pparams,
const std::vector< std::reference_wrapper< Q > > &  qparams,
const std::vector< std::reference_wrapper< Q > > &  dparams,
size_t  oP,
size_t  oQ,
size_t  oD,
ArrayHandlers< R, Q, P > &  handlers 
)

◆ construct_vectorP()

template<typename T >
std::vector< std::vector< T > > molpro::linalg::itsolv::detail::construct_vectorP ( const std::vector< int > &  roots,
const subspace::Matrix< T > &  solutions,
const size_t  oP,
const size_t  nP 
)

◆ eigensolver_hermitian_kernel()

template<typename value_type >
int molpro::linalg::itsolv::detail::eigensolver_hermitian_kernel ( std::false_type  ,
std::span< value_type >  a,
std::span< real_type_t< value_type > >  w,
size_t  dimension 
)

Eigen implementation of the hermitian eigenproblem, used for every scalar type LAPACK does not cover.

Parameters
[in,out]aon entry the matrix in column-major order, on exit the eigenvectors as its columns
[out]wthe eigenvalues in ascending order
[in]dimensionlength of one axis of the matrix
Returns
0 on success, 1 if the decomposition did not converge

◆ get_new_working_set()

template<class R >
auto molpro::linalg::itsolv::detail::get_new_working_set ( const std::vector< int > &  working_set,
const CVecRef< R > &  params,
const CVecRef< R > &  wparams 
)

Returns new working set based on parameters included in wparams.

◆ limit_qspace_size()

template<typename value_type >
std::vector< std::size_t > molpro::linalg::itsolv::detail::limit_qspace_size ( const subspace::Dimensions &  dims,
const QSpaceOptions &  opts,
const subspace::Matrix< value_type > &  solutions,
Logger &  logger 
)

Ensures that size Q space is within limit by proposing Q parameters for deletion.

Parameters
dimsdimensions of current P+Q+D subspace
max_size_qspacemaximum size of Q space
solutionssolutions matrix
loggerlogger
Returns
q parameters marked for deletions

◆ max_overlap_with_R()

template<class R , class Q >
auto molpro::linalg::itsolv::detail::max_overlap_with_R ( const CVecRef< R > &  rparams,
const CVecRef< Q > &  qparams,
array::ArrayHandler< R, Q > &  handler,
Logger &  logger 
)

Returns list of Q indices with maximum overlap to R parameters, sorted in descending order.

Parameters
rparamsR parameters
qparamsQ parameters to calculate maximum overlap of with R
handlerarray handler
loggerlogger

◆ modified_gram_schmidt()

template<class R , class Q , class P , typename value_type , typename value_type_abs >
auto molpro::linalg::itsolv::detail::modified_gram_schmidt ( const VecRef< R > &  rparams,
const subspace::Matrix< value_type > &  overlap,
const subspace::Matrix< value_type > &  rx_overlap,
const subspace::Dimensions &  dims,
const CVecRef< P > &  pparams,
const CVecRef< Q > &  qparams,
const CVecRef< Q > &  dparams,
const value_type_abs  norm_thresh,
ArrayHandlers< R, Q, P > &  handlers,
Logger &  logger 
)

Orthogonalises R parameters against P+Q+D subspace (and themselves)

New vectors with norm less than threshold are considered null and are not normalised. Their indices in params are returned.

Parameters
rparamsR space parameters
overlapoverlap of P+Q+D subspace
rx_overlapoverlaps <r_j|x_i> of the R space parameters (rows) with the P+Q+D parameters (columns), as already calculated by append_overlap_with_r()
dimsdimensions of P+Q+D subspace
pparamsP space parameters
qparamsQ space parameters
dparamsD space parameters
handlersarray handlers
norm_threshparameters with norm less than threshold are considered null and won't be orthogonalised against
Returns
indices of null parameters

◆ normalise() [1/2]

template<class R >
void molpro::linalg::itsolv::detail::normalise ( const size_t  n_roots,
const VecRef< R > &  params,
const VecRef< R > &  actions,
array::ArrayHandler< R, R > &  handler,
Logger &  logger 
)

◆ normalise() [2/2]

template<class R >
void molpro::linalg::itsolv::detail::normalise ( VecRef< R > &  params,
array::ArrayHandler< R, R > &  handler,
Logger &  logger,
typename array::ArrayHandler< R, R >::value_type_abs  thresh = 1 / std::numeric_limits<typename array::ArrayHandler<R, R>::value_type_abs>::max() 
)

◆ orthogonalise_subspace()

template<typename value_type >
orthogonalised_subspace< value_type > molpro::linalg::itsolv::detail::orthogonalise_subspace ( const std::vector< value_type > &  matrix,
const std::vector< value_type > &  metric,
size_t  dimension,
real_type_t< value_type >  svdThreshold,
int  verbosity 
)

Reduce H C = S C E to the standard eigenproblem Hbar U = U E, whose solution is C = X U.

The metric is hermitian and positive semi-definite, so its eigendecomposition is also its SVD. Directions whose singular value falls below svdThreshold relative to the largest are discarded; that is how a rank-deficient metric is handled, and it is why the reduced problem can be smaller than the subspace.

Parameters
matrixH, row-major, as subspace::Matrix stores it
metricS, row-major, as subspace::Matrix stores it

◆ parameter_batches()

std::vector< std::pair< size_t, size_t > > molpro::linalg::itsolv::detail::parameter_batches ( const size_t  nsol,
const size_t  nparam 
)
inline

◆ propose_rspace()

template<class R , class Q , class P >
auto molpro::linalg::itsolv::detail::propose_rspace ( IterativeSolver< R, Q, P > &  solver,
const VecRef< R > &  parameters,
const VecRef< R > &  residuals,
subspace::IXSpace< R, Q, P > &  xspace,
subspace::ISubspaceSolver< R, Q, P > &  subspace_solver,
ArrayHandlers< R, Q, P > &  handlers,
Logger &  logger,
const RSpaceOptions< typename array::ArrayHandler< R, R >::value_type_abs > &  r_opts,
const QSpaceOptions &  q_opts,
molpro::profiler::Profiler &  profiler 
)

Proposes new parameters for the subspace from the preconditioned residuals.

Outline

Basic procedure:

  • Gram-schmidt orthonormalise residuals amongst themselves
  • Gram-schmidt orthogonalise residuals against the old Q space and current solutions
  • Ensure that the resultant Q space is not linearly dependent by removing Q parameters with large overlap
  • Ensure that the size of Q space is within limit, by removing Q parameters with smallest contributions to current solutions
  • Reconstruct C space

Various possibilities:

  1. Residuals are linearly dependent among themselves, worst case scenario there could be duplicates.
  2. Residuals are linearly dependent with the old Q space, orthonormalisation against Q would result in almost null vectors.

Case 1 is handled at the start by normalising residuals and orthogonalising them among themselves. If it results in vectors with norm less then threshold than they are discarded and their action does not need to be evaluated.

Case 2 is handled during Gram-Schmidt procedure. Residuals are orthogonalised against the old Q space, if one of them has a small norm than an old q vector with largest overlap is deleted.

Parameters
parametersoutput new parameters for the subspace.
residualpreconditioned residuals.
Returns
number of significant parameters to calculate the action for

◆ redundant_parameters()

template<typename value_type , typename value_type_abs >
auto molpro::linalg::itsolv::detail::redundant_parameters ( const subspace::Matrix< value_type > &  overlap,
const size_t  oR,
const size_t  nR,
const value_type_abs  svd_thresh,
Logger &  logger 
)

Deduces a set of parameters that are redundant due to linear dependencies.

Only the last nR parameters are considered for removal. Linear dependencies are discovered by performing SVD of the overlap matrix.

Parameters
overlapoverlap matrix of the full subspace
oRoffset to the start of parameter block
nRnumber of parameters to consider for removal
svd_threshsingular value threshold for choosing the null space
loggerlogger
Returns
indices of the last nR parameters that are considered redundant.

◆ resize_qspace()

template<class R , class Q , class P , typename value_type >
void molpro::linalg::itsolv::detail::resize_qspace ( subspace::IXSpace< R, Q, P > &  xspace,
const subspace::Matrix< value_type > &  solutions,
std::size_t  max_size,
Logger &  logger 
)

Removes Q parameters that have smallest contribution to any solution until Q space size is within limit.

◆ select_working_set()

template<typename T >
std::vector< int > molpro::linalg::itsolv::detail::select_working_set ( const size_t  nw,
const std::vector< T > &  errors,
const T  threshold,
const std::vector< T > &  value_errors,
const T  value_threshold 
)

◆ solve_DIIS_impl()

template<typename value_type >
void molpro::linalg::itsolv::detail::solve_DIIS_impl ( std::vector< value_type > &  solution,
const std::vector< value_type > &  matrix,
const size_t  dimension,
real_type_t< value_type >  svdThreshold,
int  verbosity 
)

Implementation of solve_DIIS(), shared by its real and complex overloads.

The extrapolation coefficients solve the DIIS equations augmented with the Lagrange multiplier that constrains them to sum to one; the algebra is the same whatever the scalar type.

◆ solve_LinearEquations_impl()

template<typename value_type >
void molpro::linalg::itsolv::detail::solve_LinearEquations_impl ( std::vector< value_type > &  solution,
std::vector< value_type > &  eigenvalues,
const std::vector< value_type > &  matrix,
const std::vector< value_type > &  metric,
const std::vector< value_type > &  rhs,
const size_t  dimension,
size_t  nroot,
real_type_t< value_type >  augmented_hessian,
real_type_t< value_type >  svdThreshold,
int  verbosity 
)

Implementation of solve_LinearEquations(), shared by its real and complex overloads.

Only the augmented-Hessian branch differs between them, and only because Eigen's GeneralizedEigenSolver handles real matrices alone.

◆ svd_system_impl()

template<typename value_type >
std::list< SVD< value_type > > molpro::linalg::itsolv::detail::svd_system_impl ( size_t  nrows,
size_t  ncols,
const array::Span< value_type > &  m,
real_type_t< value_type >  threshold,
bool  hermitian,
bool  reduce_to_rank 
)

Implementation of svd_system(), shared by its real and complex overloads.

The two overloads exist only to give the public declarations distinct signatures; the algorithm is the same for both, and the hermitian branch dispatches to ?syev/?heev or to Eigen depending on the scalar type.

◆ update_errors()

template<class R , typename T >
void molpro::linalg::itsolv::detail::update_errors ( std::vector< T > &  errors,
const CVecRef< R > &  residual,
array::ArrayHandler< R, R > &  handler 
)