diff --git a/EC.jl b/EC.jl index 4dbdfc0..de38c14 100644 --- a/EC.jl +++ b/EC.jl @@ -94,8 +94,8 @@ resample(n::Int) = rand(1:n, n) |> unique |> sort If a list is provided for ref_eval, they are used as reference values for picking the closest eigenvalues at each point. If a single number is provided for ref_eval, it is used as a reference for the first point, and the previous eigenvalue is used as the reference for each successive point. If precalculated_exact_E is provided, ref_eval is ignored. -If pseudo_inv_rtol > 0, the GEVP is avoided using Moore-Penrose psuedoinverse, using this value as the relative tolerance for dropping redundant vectors." -function extrapolate!(EC::affine_EC, c_vals; ref_eval=EC.training_E[end], pseudo_inv_rtol=1e-6, verbose=true, tol=1e-5, precalculated_exact_E=nothing) +If pseudo_inv_tol > 0, the GEVP is avoided using Moore-Penrose psuedoinverse, using this value as the relative tolerance for dropping redundant vectors." +function extrapolate!(EC::affine_EC, c_vals; ref_eval=EC.training_E[end], pseudo_inv_tol=1e-6, verbose=true, tol=1e-5, precalculated_exact_E=nothing) @assert EC.trained "EC model must be trained using train() before extrapolation" for c in c_vals @@ -122,13 +122,13 @@ function extrapolate!(EC::affine_EC, c_vals; ref_eval=EC.training_E[end], pseudo verbose && println("Extrapolating for c = $c") - evals = get_extrapolated_evals(EC.H0_EC, EC.H1_EC, EC.N_EC, c, pseudo_inv_rtol) + evals = get_extrapolated_evals(EC.H0_EC, EC.H1_EC, EC.N_EC, c, pseudo_inv_tol) push!(EC.extrapolated_E, nearest(evals, current_E)) if EC.ensemble_size > 0 E_ensemble = zeros(ComplexF64, EC.ensemble_size) for i in 1:EC.ensemble_size - evals = get_extrapolated_evals(EC.H0_EC_ensemble[i], EC.H1_EC_ensemble[i], EC.N_EC_ensemble[i], c, pseudo_inv_rtol) + evals = get_extrapolated_evals(EC.H0_EC_ensemble[i], EC.H1_EC_ensemble[i], EC.N_EC_ensemble[i], c, pseudo_inv_tol) E_ensemble[i] = nearest(evals, current_E) end re_CI = std(real.(E_ensemble)) @@ -139,10 +139,10 @@ function extrapolate!(EC::affine_EC, c_vals; ref_eval=EC.training_E[end], pseudo end "Solve the GEVP with or without Moore-Penrose psuedoinverse" -function get_extrapolated_evals(H0_EC, H1_EC, N_EC, c, pseudo_inv_rtol) +function get_extrapolated_evals(H0_EC, H1_EC, N_EC, c, pseudo_inv_tol) H_EC = H0_EC + c .* H1_EC - if pseudo_inv_rtol > 0 - inv_N_EC = pinv(N_EC; rtol=pseudo_inv_rtol) + if pseudo_inv_tol > 0 + inv_N_EC = pinv(N_EC; atol=pseudo_inv_tol) H_EC = inv_N_EC * H_EC return eigvals(H_EC) else