rtol -> atol

This commit is contained in:
Nuwan Yapa 2025-01-30 14:32:52 -05:00
parent 6a387e9301
commit b3cad61a15
1 changed files with 7 additions and 7 deletions

14
EC.jl
View File

@ -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 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 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 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." 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_rtol=1e-6, verbose=true, tol=1e-5, precalculated_exact_E=nothing) 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" @assert EC.trained "EC model must be trained using train() before extrapolation"
for c in c_vals 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") 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)) push!(EC.extrapolated_E, nearest(evals, current_E))
if EC.ensemble_size > 0 if EC.ensemble_size > 0
E_ensemble = zeros(ComplexF64, EC.ensemble_size) E_ensemble = zeros(ComplexF64, EC.ensemble_size)
for i in 1: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) E_ensemble[i] = nearest(evals, current_E)
end end
re_CI = std(real.(E_ensemble)) 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 end
"Solve the GEVP with or without Moore-Penrose psuedoinverse" "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 H_EC = H0_EC + c .* H1_EC
if pseudo_inv_rtol > 0 if pseudo_inv_tol > 0
inv_N_EC = pinv(N_EC; rtol=pseudo_inv_rtol) inv_N_EC = pinv(N_EC; atol=pseudo_inv_tol)
H_EC = inv_N_EC * H_EC H_EC = inv_N_EC * H_EC
return eigvals(H_EC) return eigvals(H_EC)
else else