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... | |
| class | MetricChecker |
| Checks that the metric of a generalised problem has the properties that its kind declares, as far as the subspace shows them. More... | |
| struct | MetricSolutions |
| The actions of a metric applied on the fly on solutions, in R vectors or, if there are not enough of them, Q vectors. More... | |
| struct | orthogonalised_subspace |
| A generalised eigenproblem reduced to a standard one by symmetric orthogonalisation of the metric. More... | |
| class | ScopedFpeSuspend |
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 > | |
| int | eigensolver_hermitian_lowest_kernel (std::false_type, std::span< value_type > a, std::span< value_type > z, std::span< real_type_t< value_type > > w, size_t dimension, size_t nroots) |
The lowest nroots eigenpairs of a hermitian matrix: without a partial kernel, the whole decomposition, truncated. | |
| 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 , typename matrix_type , typename vector_type > | |
| bool | hermitian_lowest_by_cholesky (const std::vector< value_type > &matrix, const std::vector< value_type > &metric, size_t dimension, size_t nroots, real_type_t< value_type > svdThreshold, matrix_type &eigenvectors, vector_type &eigenvalues) |
The lowest nroots eigenpairs of a hermitian H C = S C E by Cholesky reduction, where that is safe. | |
| 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 , class P , typename value_type , typename Index > | |
| void | erase_qspace (subspace::IXSpace< R, Q, P > &xspace, subspace::Matrix< value_type > &solutions, std::vector< Index > indices) |
| Erases Q parameters with the given indices together with the corresponding columns of a solutions matrix. | |
| 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<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 , 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 > ¶ms, 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 Index > | |
| void | erase_qspace (subspace::IXSpace< R, Q, P > &xspace, std::vector< Index > indices) |
| Erases Q parameters with the given indices, in descending order so that the remaining indices stay valid. | |
| template<class R , class Q , class P , typename value_type > | |
| auto | append_overlap_with_r (const subspace::Matrix< value_type > &overlap, const CVecRef< R > ¶ms, 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<class R , class Q , class P , typename value_type > | |
| subspace::Matrix< value_type > | contribution_solutions (const subspace::Matrix< value_type > &solutions, const subspace::IXSpace< R, Q, P > &xspace) |
| The solutions scaled to unit length, as needed wherever thresholds apply to their coefficients or to norms of their projections (limit_qspace_size(), construct_dspace(), D space resets): with a metric, the solutions are normalised in it, and the thresholds would otherwise depend on the scale of the metric. | |
| 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 | project_out_and_orthonormalise (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) |
| Projects R parameters out of the P+Q+D subspace and orthonormalises them among themselves. | |
| template<class R > | |
| auto | get_new_working_set (const std::vector< int > &working_set, const CVecRef< R > ¶ms, 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 > ¶meters, 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. | |
| template<typename T , typename S , typename = std::enable_if_t<std::is_base_of<molpro::linalg::array::DistrArray, T>::value>> | |
| void | precondition_default (const VecRef< T > &action, const std::vector< S > &shift, const T &diagonals, const T *metric_diagonals, const bool regularise) |
| template<class T , typename S > | |
| void | precondition_default (const VecRef< T > &action, const std::vector< S > &shift, const T &diagonals, const T *metric_diagonals, const bool regularise, typename T::iterator *=nullptr) |
| template<typename T , typename S , typename = std::enable_if_t<!std::is_base_of<molpro::linalg::array::DistrArray, T>::value>, class = void> | |
| void | precondition_default (const VecRef< T > &action, const std::vector< S > &shift, const T &diagonals, const T *metric_diagonals, const bool regularise, typename std::enable_if<!has_iterator< T >::value, void * >::type=nullptr) |
| 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.
| ov | overlap of P+Q+D |
| params | new parameters |
| pparams | P space parameters |
| qparams | Q space parameters |
| dparams | D space parameters |
| handlers | array handlers |
| logger | logger |
| 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.
| xspace | X space container |
| q_delete | Q parameters marked for deletion |
| norm_thresh | norm threshold for parameters to be considered null |
| svd_thresh | svd threshold for marking the null space |
| handler | array handler |
| logger | logger |
| 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 | ||
| ) |
| subspace::Matrix< value_type > molpro::linalg::itsolv::detail::contribution_solutions | ( | const subspace::Matrix< value_type > & | solutions, |
| const subspace::IXSpace< R, Q, P > & | xspace | ||
| ) |
The solutions scaled to unit length, as needed wherever thresholds apply to their coefficients or to norms of their projections (limit_qspace_size(), construct_dspace(), D space resets): with a metric, the solutions are normalised in it, and the thresholds would otherwise depend on the scale of the metric.
| 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.
| [in,out] | a | on entry the matrix in column-major order, on exit the eigenvectors as its columns |
| [out] | w | the eigenvalues in ascending order |
| [in] | dimension | length of one axis of the matrix |
| int molpro::linalg::itsolv::detail::eigensolver_hermitian_lowest_kernel | ( | std::false_type | , |
| std::span< value_type > | a, | ||
| std::span< value_type > | z, | ||
| std::span< real_type_t< value_type > > | w, | ||
| size_t | dimension, | ||
| size_t | nroots | ||
| ) |
The lowest nroots eigenpairs of a hermitian matrix: without a partial kernel, the whole decomposition, truncated.
| [in,out] | a | on entry the matrix in column-major order; overwritten |
| [out] | z | the eigenvectors as the columns of a column-major dimension x nroots matrix |
| [out] | w | the eigenvalues in ascending order, nroots of them |
| void molpro::linalg::itsolv::detail::erase_qspace | ( | subspace::IXSpace< R, Q, P > & | xspace, |
| std::vector< Index > | indices | ||
| ) |
Erases Q parameters with the given indices, in descending order so that the remaining indices stay valid.
| void molpro::linalg::itsolv::detail::erase_qspace | ( | subspace::IXSpace< R, Q, P > & | xspace, |
| subspace::Matrix< value_type > & | solutions, | ||
| std::vector< Index > | indices | ||
| ) |
Erases Q parameters with the given indices together with the corresponding columns of a solutions matrix.
| 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.
| bool molpro::linalg::itsolv::detail::hermitian_lowest_by_cholesky | ( | const std::vector< value_type > & | matrix, |
| const std::vector< value_type > & | metric, | ||
| size_t | dimension, | ||
| size_t | nroots, | ||
| real_type_t< value_type > | svdThreshold, | ||
| matrix_type & | eigenvectors, | ||
| vector_type & | eigenvalues | ||
| ) |
The lowest nroots eigenpairs of a hermitian H C = S C E by Cholesky reduction, where that is safe.
orthogonalise_subspace() decomposes the whole metric and transforms H with it, then the whole reduced matrix is diagonalized, all to O(dimension^3) work, even though the solvers want only a few roots. When S is comfortably positive definite, symmetric orthogonalisation would keep every one of its directions, so the Cholesky reduction of LAPACK's ?sygvx/?hegvx solves the same problem, computing only the wanted eigenvectors. That holds when the estimated reciprocal condition number of S, which is at most the ratio of its extreme eigenvalues (bounded below by the true one, and estimated to within a modest factor), exceeds the rank threshold with a wide margin; it is also held well above the working precision, so the factorisation stays accurate.
Applies only to the scalar types LAPACK covers, and only when fewer roots than the dimension are wanted, so a caller asking for the whole spectrum keeps the behaviour it had.
| matrix | H, row-major, as subspace::Matrix stores it |
| metric | S, row-major, as subspace::Matrix stores it |
eigenvectors (dimension x wanted, S-orthonormal) and eigenvalues (ascending) were computed | 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.
| dims | dimensions of current P+Q+D subspace |
| max_size_qspace | maximum size of Q space |
| solutions | solutions matrix |
| logger | logger |
| 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.
| rparams | R parameters |
| qparams | Q parameters to calculate maximum overlap of with R |
| handler | array handler |
| logger | logger |
| 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() |
||
| ) |
| 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.
| matrix | H, row-major, as subspace::Matrix stores it |
| metric | S, row-major, as subspace::Matrix stores it |
|
inline |
| void molpro::linalg::itsolv::detail::precondition_default | ( | const VecRef< T > & | action, |
| const std::vector< S > & | shift, | ||
| const T & | diagonals, | ||
| const T * | metric_diagonals, | ||
| const bool | regularise | ||
| ) |
| void molpro::linalg::itsolv::detail::precondition_default | ( | const VecRef< T > & | action, |
| const std::vector< S > & | shift, | ||
| const T & | diagonals, | ||
| const T * | metric_diagonals, | ||
| const bool | regularise, | ||
| typename std::enable_if<!has_iterator< T >::value, void * >::type | = nullptr |
||
| ) |
| void molpro::linalg::itsolv::detail::precondition_default | ( | const VecRef< T > & | action, |
| const std::vector< S > & | shift, | ||
| const T & | diagonals, | ||
| const T * | metric_diagonals, | ||
| const bool | regularise, | ||
| typename T::iterator * | = nullptr |
||
| ) |
| auto molpro::linalg::itsolv::detail::project_out_and_orthonormalise | ( | 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 | ||
| ) |
Projects R parameters out of the P+Q+D subspace and orthonormalises them among themselves.
The projection subtracts V S^{-1} V^dagger r in one step, with S the overlap matrix of the P+Q+D vectors V, which therefore need not be orthonormal. The projected parameters are then Gram-Schmidt orthonormalised among themselves. New vectors with norm less than threshold are considered null and are not normalised. Their indices in params are returned.
| rparams | R space parameters |
| overlap | overlap of P+Q+D subspace |
| rx_overlap | overlaps <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() |
| dims | dimensions of P+Q+D subspace |
| pparams | P space parameters |
| qparams | Q space parameters |
| dparams | D space parameters |
| handlers | array handlers |
| norm_thresh | parameters with norm less than threshold are considered null and won't be orthogonalised against |
| 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.
| solver | solver providing the current working set |
| parameters | output new parameters for the subspace |
| residuals | preconditioned residuals, which are modified |
| xspace | X space container |
| subspace_solver | solver of the subspace problem |
| handlers | array handlers |
| logger | logger |
| r_opts | thresholds for screening the new parameters |
| q_opts | options limiting the size of the Q space |
| profiler | profiler |
| 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.
| overlap | overlap matrix of the full subspace |
| oR | offset to the start of parameter block |
| nR | number of parameters to consider for removal |
| svd_thresh | singular value threshold for choosing the null space |
| logger | logger |
| 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.
| solutions | the solutions whose coefficients measure the contributions (see contribution_solutions()), with columns for the current subspace |
| 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 | ||
| ) |
| 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.
| 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.
| 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 ?syevd/?heevd or to Eigen depending on the scalar type.