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

Namespaces

namespace  detail
 

Functions

template<typename T >
std::vector< T > gram_schmidt (const Matrix< T > &s, Matrix< T > &l, T norm_thresh=precision_scaled< T >(1e-14))
 Performs Gram-Schmidt orthogonalisation without normalisation.
 
template<typename value_type , typename value_type_abs >
Matrix< value_type > construct_lin_trans_in_orthogonal_set (const Matrix< value_type > &overlap, const Matrix< value_type > &lin_trans, const std::vector< value_type_abs > &norm)
 Construct Gram-Schmidt linear transformation in orthogonal vectors.
 
template<class R , typename value_type_abs >
auto modified_gram_schmidt (VecRef< R > &params, array::ArrayHandler< R, R > &handler, value_type_abs null_thresh)
 Apply modified Gram-Schmidt procedure to orthonormalise parameters.
 
template<class R , class Q , class Z , class W >
auto overlap (const CVecRef< R > &left, const CVecRef< Q > &right, array::ArrayHandler< Z, W > &handler) -> std::enable_if_t< detail::Z_and_W_are_one_of_R_and_Q< R, Q, Z, W >, Matrix< typename array::ArrayHandler< Z, W >::value_type > >
 Calculates overlap matrix between left and right vectors.
 
template<class R >
Matrix< typename array::ArrayHandler< R, R >::value_type > overlap (const CVecRef< R > &params, array::ArrayHandler< R, R > &handler)
 Calculates overlap matrix for a parameter set. Matrix is hermitian by construction.
 
template<typename T >
std::vector< real_type_t< T > > solution_norms (const Matrix< T > &solutions, const Matrix< T > &overlap)
 The Euclidean norms of the solutions x_i = sum_j c_ij b_j, from their subspace coefficients c (one row per solution) and the overlap matrix S_jk = <b_j|b_k> of the subspace vectors, as sqrt((c S c^dagger)_ii), calculated together with one matrix product.
 
template<typename T >
Matrix< T > unit_length_solutions (const Matrix< T > &solutions, const Matrix< T > &overlap)
 The subspace coefficients of the solutions scaled to unit Euclidean length, so that their sizes can be compared with thresholds whatever the normalisation of the solutions (e.g. in the metric of a generalised eigenproblem)
 
template<typename T >
void matrix_symmetrize (Matrix< T > &mat)
 Replaces a matrix by its hermitian part, which for a real element type is its symmetric part.
 
template<typename T >
Matrix< T >::coord_type max_element_index (const std::list< size_t > &rows, const std::list< size_t > &cols, const Matrix< T > &mat)
 Return maximum element in a matrix along specified rows and columns.
 
template<typename Slice >
std::vector< size_t > eye_order (const Slice &mat)
 Returns order of rows in a matrix slice that brings it closest to identity.
 

Function Documentation

◆ construct_lin_trans_in_orthogonal_set()

template<typename value_type , typename value_type_abs >
Matrix< value_type > molpro::linalg::itsolv::subspace::util::construct_lin_trans_in_orthogonal_set ( const Matrix< value_type > &  overlap,
const Matrix< value_type > &  lin_trans,
const std::vector< value_type_abs > &  norm 
)

Construct Gram-Schmidt linear transformation in orthogonal vectors.

Let {v} be the original vectors, and {u} their orthogonal set.

We can construct {u} from {v} using lower triangular linear transformation matrix L u_0 = v_0 u_1 = v_1 + L_{1,0} v_0 u_i = \sum_{j=0}^i L_{i,j} v_j

However, we can also construct u_i using v_i and previous {u}, using a lower triangular transformation matrix T, u_i = v_i - \sum_{j=0}^{i-1} <v_i,u_j> / <u_j, u_j> u_j = v_i + \sum_j=0^{i-1} T_{i,j} u_j

T_{i,j} = - <v_i,u_j> / <u_j, u_j> = - \sum_{k=0}^{j} L_{j,k} <v_i,v_k> / <u_j, u_j>

T_{i,j} = 0 if i >= j

Parameters
overlapOverlap matrix of original non-orthogonal vectors
lin_transGram-Schmidt linear transformation to an orthogonal set in terms of original vectors
normnorms of orthogonal vectors constructed from lin_trans @Returns linear transformation set
Returns

◆ eye_order()

template<typename Slice >
std::vector< size_t > molpro::linalg::itsolv::subspace::util::eye_order ( const Slice &  mat)

Returns order of rows in a matrix slice that brings it closest to identity.

auto order = eye_order(mat);
for( size_t i = 0; i < n_rows; ++i){
mat_new.row(i) = mat.row(order[i]);
}
std::vector< size_t > eye_order(const Slice &mat)
Returns order of rows in a matrix slice that brings it closest to identity.
Definition util.h:158
std::unique_ptr< LinearEigensystem< R, Q, P > > create_LinearEigensystem(const LinearEigensystemOptions &options, const std::shared_ptr< ArrayHandlers< R, Q, P > > &handlers=std::make_shared< molpro::linalg::itsolv::ArrayHandlers< R, Q, P > >())
Definition SolverFactory.h:111
Template Parameters
SliceSlice type
Parameters
matsquare matrix

◆ gram_schmidt()

template<typename T >
std::vector< T > molpro::linalg::itsolv::subspace::util::gram_schmidt ( const Matrix< T > &  s,
Matrix< T > &  l,
T  norm_thresh = precision_scaled<T>(1e-14) 
)

Performs Gram-Schmidt orthogonalisation without normalisation.

Any orthogonal vector with a norm less than threshold is not orthogonalised against.

For a vector set {v} with overlap matrix $ S_{ij}= v_i . v_j $, generate a linear transformation L to a new orthogonal vector set $ u_i = \sum_j L_{ij} v_j $.

u_0 = v_0 u_1 = v_1 - <v_1, u_0> / <u_0, u_0> u_i = v_i -\sum_j=0^{i-1} <v_i, u_j> / <u_j, u_j> u_j = v_i -\sum_j=0^{i-1} <v_i, u_j> / <u_j, u_j> \sum_{k=0}^j L_{jk} v_k = v_i -\sum_j=0^{i-1} (\sum_{k=0}^{j} W_{ij} / N_{jj} L_{jk}) v_k

Let the overlap between u and v be, $ W_{ij} = <v_i, u_j> $

W_{ij} = <v_i, u_j> = \sum_{k=0}^{j} S_{ik} L_{jk} N_{ii} = <u_i, u_i> = \sum_{k} L_{ik} <v_k, u_i> = \sum_{km} L_{ik} L_{im} S_{km}

L_{0,j} = \delta_{i,j} L_{i,k} = \delta_{i,k} - (1 + \delta_{i,k})(\sum_{j=0}^{k} W_{ij} / N_{jj} L_{jk})

Parameters
soverlap matrix
lrow matrix with linear transformation into orthonormal basis. Upper triangular component is zero.
norm_threshgenerated vector with norm less than threshold is not used for subsequent orthogonalisation
Returns
norms of transformed vectors

◆ matrix_symmetrize()

template<typename T >
void molpro::linalg::itsolv::subspace::util::matrix_symmetrize ( Matrix< T > &  mat)

Replaces a matrix by its hermitian part, which for a real element type is its symmetric part.

◆ max_element_index()

template<typename T >
Matrix< T >::coord_type molpro::linalg::itsolv::subspace::util::max_element_index ( const std::list< size_t > &  rows,
const std::list< size_t > &  cols,
const Matrix< T > &  mat 
)

Return maximum element in a matrix along specified rows and columns.

◆ modified_gram_schmidt()

template<class R , typename value_type_abs >
auto molpro::linalg::itsolv::subspace::util::modified_gram_schmidt ( VecRef< R > &  params,
array::ArrayHandler< R, R > &  handler,
value_type_abs  null_thresh 
)

Apply modified Gram-Schmidt procedure to orthonormalise parameters.

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

Template Parameters
R
value_type_abs
Parameters
params
handler
null_thresh
Returns
indices of parameters that became null after GS procedure

◆ overlap() [1/2]

template<class R , class Q , class Z , class W >
auto molpro::linalg::itsolv::subspace::util::overlap ( const CVecRef< R > &  left,
const CVecRef< Q > &  right,
array::ArrayHandler< Z, W > &  handler 
) -> std::enable_if_t<detail::Z_and_W_are_one_of_R_and_Q<R, Q, Z, W>, Matrix<typename array::ArrayHandler<Z, W>::value_type>>

Calculates overlap matrix between left and right vectors.

◆ overlap() [2/2]

template<class R >
Matrix< typename array::ArrayHandler< R, R >::value_type > molpro::linalg::itsolv::subspace::util::overlap ( const CVecRef< R > &  params,
array::ArrayHandler< R, R > &  handler 
)

Calculates overlap matrix for a parameter set. Matrix is hermitian by construction.

◆ solution_norms()

template<typename T >
std::vector< real_type_t< T > > molpro::linalg::itsolv::subspace::util::solution_norms ( const Matrix< T > &  solutions,
const Matrix< T > &  overlap 
)

The Euclidean norms of the solutions x_i = sum_j c_ij b_j, from their subspace coefficients c (one row per solution) and the overlap matrix S_jk = <b_j|b_k> of the subspace vectors, as sqrt((c S c^dagger)_ii), calculated together with one matrix product.

◆ unit_length_solutions()

template<typename T >
Matrix< T > molpro::linalg::itsolv::subspace::util::unit_length_solutions ( const Matrix< T > &  solutions,
const Matrix< T > &  overlap 
)

The subspace coefficients of the solutions scaled to unit Euclidean length, so that their sizes can be compared with thresholds whatever the normalisation of the solutions (e.g. in the metric of a generalised eigenproblem)

Parameters
solutionscoefficients of the solutions, one row per solution
overlapoverlap matrix of the subspace vectors