Rough implementation of Moore-Penrose

This commit is contained in:
Nuwan Yapa 2025-01-15 20:29:56 -05:00
parent bc1d449bab
commit 14b7671f6a
4 changed files with 11 additions and 4 deletions

9
EC.jl
View File

@ -23,7 +23,7 @@ end
If a list is provided for ref_eval, they are used as reference values for picking the closest eigenvalues at each sampling point. If a list is provided for ref_eval, they are used as reference values for picking the closest eigenvalues at each sampling 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.
Set orthonormalize_threshold=0 to skip Gram-Schmidt orthonormalization and use GEVP. Otherwise this value is used as the threshold for dropping redundant vectors." Set orthonormalize_threshold=0 to skip Gram-Schmidt orthonormalization and use GEVP. Otherwise this value is used as the threshold for dropping redundant vectors."
function train!(EC::affine_EC, c_vals; ref_eval=-10.0, orthonormalize_threshold=1e-5, CAEC=false, verbose=true, tol=1e-5) function train!(EC::affine_EC, c_vals; ref_eval=-10.0, orthonormalize_threshold=1e-5, CAEC=false, verbose=true, tol=1e-5, pseudo_inv_rtol=0)
training_vecs = Vector{ComplexF64}[] training_vecs = Vector{ComplexF64}[]
for c in c_vals for c in c_vals
@ -59,6 +59,13 @@ function train!(EC::affine_EC, c_vals; ref_eval=-10.0, orthonormalize_threshold=
if orthonormalize_threshold == 0 if orthonormalize_threshold == 0
EC.N_EC = transpose(EC_basis) * weights_mat * EC_basis EC.N_EC = transpose(EC_basis) * weights_mat * EC_basis
if pseudo_inv_rtol > 0
inv_N_EC = pinv(EC.N_EC; rtol=pseudo_inv_rtol)
@time "Square root of N" sqrt_inv_N_EC = sqrt(inv_N_EC)
EC.H0_EC = sqrt_inv_N_EC * EC.H0_EC * sqrt_inv_N_EC
EC.H1_EC = sqrt_inv_N_EC * EC.H1_EC * sqrt_inv_N_EC
EC.N_EC = nothing
end
end end
EC.trained = true EC.trained = true

View File

@ -32,7 +32,7 @@ extrapolating_ref = [4.076662025307587-0.012709842443350328im,
1.233088227541505-0.0003070320106485624im] 1.233088227541505-0.0003070320106485624im]
EC = affine_EC(H0, Vp, weights) EC = affine_EC(H0, Vp, weights)
train!(EC, training_c; ref_eval=training_ref, CAEC=true) train!(EC, training_c; ref_eval=training_ref, CAEC=true, orthonormalize_threshold=0, pseudo_inv_rtol=1e-6)
extrapolate!(EC, extrapolating_c; ref_eval=extrapolating_ref) extrapolate!(EC, extrapolating_c; ref_eval=extrapolating_ref)
exportCSV(EC, "temp/Berggren_B2R.csv") exportCSV(EC, "temp/Berggren_B2R.csv")

View File

@ -32,7 +32,7 @@ exact_E = [4.077092809998592-0.01206085331850782im,
1.2329696647679096-0.00019879325231064393im] 1.2329696647679096-0.00019879325231064393im]
EC = affine_EC(H0, Vp, weights) EC = affine_EC(H0, Vp, weights)
train!(EC, training_c; ref_eval=training_ref, CAEC=true) train!(EC, training_c; ref_eval=training_ref, CAEC=true, orthonormalize_threshold=0, pseudo_inv_rtol=1e-6)
extrapolate!(EC, extrapolating_c; precalculated_exact_E=exact_E) extrapolate!(EC, extrapolating_c; precalculated_exact_E=exact_E)
exportCSV(EC, "temp/CSM_B2R.csv") exportCSV(EC, "temp/CSM_B2R.csv")

View File

@ -21,7 +21,7 @@ training_c = [2.0, 1.9, 1.8]
extrapolating_c = 0.0 : 0.2 : 1.2 extrapolating_c = 0.0 : 0.2 : 1.2
EC = affine_EC(H0, Vp) EC = affine_EC(H0, Vp)
train!(EC, training_c; ref_eval=training_ref, CAEC=true) train!(EC, training_c; ref_eval=training_ref, CAEC=true, orthonormalize_threshold=0, pseudo_inv_rtol=1e-6)
extrapolate!(EC, extrapolating_c; ref_eval=extrapolating_ref) extrapolate!(EC, extrapolating_c; ref_eval=extrapolating_ref)
exportCSV(EC, "temp/HO_B2R.csv") exportCSV(EC, "temp/HO_B2R.csv")