iterative-solver 0.0
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...
 

Functions

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 >
void construct_solution (const VecRef< R > &params, const std::vector< int > &roots, const subspace::Matrix< double > &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, double thresh=1.0e-14)
 
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. More...
 
template<typename value_type >
auto limit_qspace_size (const subspace::Dimensions &dims, const size_t max_size_qspace, const subspace::Matrix< value_type > &solutions, Logger &logger)
 Ensures that size Q space is within limit by proposing Q parameters for deletion. More...
 
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< int > &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. More...
 
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::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) More...
 
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. More...
 
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. More...
 
template<class R , class Q , class P , typename value_type_abs >
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, value_type_abs svd_thresh, value_type_abs res_norm_thresh, int max_size_qspace, molpro::profiler::Profiler &profiler)
 Proposes new parameters for the subspace from the preconditioned residuals. More...
 
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, int m_max_Qsize_after_reset, Logger &logger)
 Removes Q parameters that have smallest contribution to any solution until Q space size is within limit. More...
 
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. More...
 

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< int > &  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 >
void molpro::linalg::itsolv::detail::construct_solution ( const VecRef< R > &  params,
const std::vector< int > &  roots,
const subspace::Matrix< double > &  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 
)

◆ 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 >
auto molpro::linalg::itsolv::detail::limit_qspace_size ( const subspace::Dimensions dims,
const size_t  max_size_qspace,
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::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
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,
double  thresh = 1.0e-14 
)

◆ 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 , typename value_type_abs >
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,
value_type_abs  svd_thresh,
value_type_abs  res_norm_thresh,
int  max_size_qspace,
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. Linea 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,
int  m_max_Qsize_after_reset,
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 
)

◆ 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 
)