Commit c8b1159d by Alejandro Saez

### Merge branch 'javier' into alejandro

parents 7f6a1be6 5eb61b12
 Home · juobs Documentation
Home · juobs Documentation
 ... ... @@ -78,4 +78,4 @@ evals = getall_eigvals(matrices, 5) #where t_0=5 Julia>source
juobs.getall_eigvecsFunction
getall_eigvecs(a::Vector{Matrix}, delta_t; iter=30 )

This function solves a GEVP problem, returning the eigenvectors, for a list of matrices.

$C(t_i)v_i = λ_i C(t_i-\delta_t) v_i$, with i=1:lenght(a)

Here delta_t is the time shift within the two matrices of the problem, and is kept fixed. It takes as input:

• a::Vector{Matrix} : a vector of matrices

• delta_t::Int64 : the fixed time shift t-t_0

• iter=30 : the number of iterations of the qr algorithm used to extract the eigenvalues

It returns:

• res = Vector{Matrix{uwreal}}

where each res[i] is a matrix with the eigenvectors as columns Examples:

mat_array = get_matrix(diag, upper_diag)
evecs = getall_eigvecs(mat_array, 5)
source
evecs = getall_eigvecs(mat_array, 5)source
This diff is collapsed.
 ... ... @@ -24,4 +24,4 @@ truncate_data!(Y, nc) dat = read_mesons([path1, path2], "G5", "G5") Y = read_ms.([path1_ms, path2_ms]) truncate_data!(dat, [nc1, nc2]) truncate_data!(Y, [nc1, nc2])source truncate_data!(Y, [nc1, nc2])source
 Search · juobs Documentation

Search · juobs Documentation

 ... ... @@ -4,8 +4,8 @@ function apply_rw(data::Array{Float64}, W::Matrix{Float64}) W1 = W[1, 1:nc] W2 = W[2, 1:nc] data_r = data .* W1 .* W2 / mean(W1 .* W2) return data_r data_r = data .* W1 .* W2 return (data_r, W1 .* W2) end function apply_rw(data::Vector{<:Array{Float64}}, W::Vector{Matrix{Float64}}) ... ... @@ -16,17 +16,9 @@ function apply_rw(data::Vector{<:Array{Float64}}, W::Vector{Matrix{Float64}}) rw1 = [W[k][1, 1:nc[k]] for k=1:length(W)] rw2 = [W[k][2, 1:nc[k]] for k=1:length(W)] rw1_cat = rw1[1] rw2_cat = rw2[1] for k = 2:length(W) rw1_cat = cat(rw1_cat, rw1[k], dims=1) rw2_cat = cat(rw2_cat, rw2[k], dims=1) end rw_mean = mean(rw1_cat .* rw2_cat) data_r = [data[k] .* rw1[k].* rw2[k] / rw_mean for k=1:length(data)] return data_r rw = [rw1[k] .* rw2[k] for k=1:length(W)] data_r = [data[k] .* rw[k] for k=1:length(data)] return (data_r, rw) end function check_corr_der(obs::Corr, derm::Vector{Corr}) ... ... @@ -89,20 +81,30 @@ corr_pp = corr_obs.(data) corr_pp_r = corr_obs.(data, rw=[rw1, rw2])  """ function corr_obs(cdata::CData; real::Bool=true, rw::Union{Array{Float64, 2}, Nothing}=nothing, L::Int64=1) function corr_obs(cdata::CData; real::Bool=true, rw::Union{Array{Float64, 2}, Nothing}=nothing, L::Int64=1, rw_info::Bool=false) real ? data = cdata.re_data ./ L^3 : data = cdata.im_data ./ L^3 data_r = isnothing(rw) ? data : apply_rw(data, rw) nt = size(data)[2] obs = Vector{uwreal}(undef, nt) [obs[x0] = uwreal(data_r[:, x0], cdata.id) for x0 = 1:nt] return Corr(obs, cdata) if isnothing(rw) obs = [uwreal(data[:, x0], cdata.id) for x0 = 1:nt] else data_r, W = apply_rw(data, rw) ow = [uwreal(data_r[:, x0], cdata.id) for x0 = 1:nt] W_obs = uwreal(W, cdata.id) obs = [ow[x0] / W_obs for x0 = 1:nt] end if rw_info && !isnothing(rw) return (Corr(obs, cdata), ow, W_obs) else return Corr(obs, cdata) end end #function corr_obs for R != 1 #TODO: vcfg with gaps function corr_obs(cdata::Array{CData, 1}; real::Bool=true, rw::Union{Array{Array{Float64, 2}, 1}, Nothing}=nothing, L::Int64=1) function corr_obs(cdata::Array{CData, 1}; real::Bool=true, rw::Union{Array{Array{Float64, 2}, 1}, Nothing}=nothing, L::Int64=1, rw_info::Bool=false) nr = length(cdata) id = getfield.(cdata, :id) vcfg = getfield.(cdata, :vcfg) ... ... @@ -113,17 +115,29 @@ function corr_obs(cdata::Array{CData, 1}; real::Bool=true, rw::Union{Array{Array end real ? data = getfield.(cdata, :re_data) ./ L^3 : data = getfield.(cdata, :im_data) ./ L^3 data_r = isnothing(rw) ? data : apply_rw(data, rw) tmp = data_r[1] [tmp = cat(tmp, data_r[k], dims=1) for k = 2:nr] nt = size(data[1])[2] obs = Vector{uwreal}(undef, nt) [obs[x0] = uwreal(tmp[:, x0], id[1], replica) for x0 = 1:nt] return Corr(obs, cdata) if isnothing(rw) tmp = data[1] [tmp = cat(tmp, data[k], dims=1) for k = 2:nr] obs = [uwreal(tmp[:, x0], id[1], replica) for x0 = 1:nt] else data_r, W = apply_rw(data, rw) tmp = data_r[1] tmp_W = W[1] [tmp = cat(tmp, data_r[k], dims=1) for k = 2:nr] [tmp_W = cat(tmp_W, W[k], dims=1) for k = 2:nr] ow = [uwreal(tmp[:, x0], id[1], replica) for x0 = 1:nt] W_obs = uwreal(tmp_W, id[1], replica) obs = [ow[x0] / W_obs for x0 = 1:nt] end if rw_info && !isnothing(rw) return (Corr(obs, cdata), ow, W_obs) else return Corr(obs, cdata) end end @doc raw""" corr_sym(corrL::Corr, corrR::Corr, parity::Int64=1) ... ... @@ -196,7 +210,7 @@ m_mdl, m_mds = md_sea(m, [md1, md2], ADerrors.wsg) m_shifted = m + 2 * dml * m_mdl + dms * m_mds  """ function md_sea(a::uwreal, md::Vector{Matrix{Float64}}, ws::ADerrors.wspace=ADerrors.wsg) function md_sea(a::uwreal, md::Vector{Matrix{Float64}}, ow::uwreal, w::Union{uwreal, Nothing}=nothing, ws::ADerrors.wspace=ADerrors.wsg) nid = neid(a) p = findall(t-> t==1, a.prop) ... ... @@ -226,24 +240,41 @@ function md_sea(a::uwreal, md::Vector{Matrix{Float64}}, ws::ADerrors.wspace=ADer for k = 2:length(md) md_aux = cat(md_aux, md[k][:, 1:ivrep[k]], dims=2) end nrw = size(md_aux, 1) uwerr(ow) ow_data = ow.mean .+ mchist(ow, id) fluc_obs = getfield.(ws.fluc[p], :delta) fluc_md = md_aux .- mean(md_aux, dims=2) uwerr(a) fluc_obs = mchist(a, id) nrw = size(fluc_md, 1) if nrw == 1 der1 = uwreal(-fluc_md[1, :] .* fluc_obs, id, ivrep) return (der1, der1) elseif nrw == 2 der1 = uwreal(-fluc_md[1, :] .* fluc_obs, id, ivrep) der2 = uwreal(-fluc_md[2, :] .* fluc_obs, id, ivrep) return (der1, der2) if isnothing(w) der = derivative(a, ow) d1 = der * (ow * uwreal(md_aux[1, :], id, ivrep) - uwreal(ow_data .* md_aux[1, :], id, ivrep)) if nrw == 1 return (d1, d1) elseif nrw == 2 d2 = der * (ow * uwreal(md_aux[2, :], id, ivrep) - uwreal(ow_data .* md_aux[2, :], id, ivrep)) return (d1, d2) end else return nothing uwerr(w) der = derivative(a, ow) * w.mean w_data = w.mean .+ mchist(w, id) d1 = der * (ow * uwreal(w_data .* md_aux[1, :], id, ivrep) / w^2 - uwreal(ow_data .* md_aux[1, :], id, ivrep) / w) if nrw == 1 return (d1, d1) elseif nrw == 2 d2 = der * (ow * uwreal(w_data .* md_aux[2, :], id, ivrep) / w^2 - uwreal(ow_data .* md_aux[2, :], id, ivrep) / w) return (d1, d2) end end return nothing end function md_sea(a::uwreal, md::Vector{Matrix{Float64}}, ow::Array{uwreal}, w::Union{uwreal, Nothing}=nothing, ws::ADerrors.wspace=ADerrors.wsg) d = [md_sea(a, md, ow_, w, ws) for ow_ in ow] return (sum(getindex.(d, 1)), sum(getindex.(d, 2))) end @doc raw""" ... ... @@ -277,7 +308,7 @@ derm = [[corr_pp_d1[k], corr_pp_d2[k]] for k = 1:length(pp_d1)] m = meff(corr_pp[1], plat) m_md1, m_md2 = md_val(m, corr_pp[1], derm[1]) m_shifted = m + 2 * dm1 * m_md1 + dm2 * m_md2 m_shifted = m + dm1 * m_md1 + dm2 * m_md2  """ function md_val(a::uwreal, obs::Corr, derm::Vector{Corr}) ... ... @@ -293,14 +324,40 @@ function md_val(a::uwreal, obs::Corr, derm::Vector{Corr}) end corr = getfield(obs, :obs) der = [derivative(a, corr[k]) for k = 1:length(corr)] prop = getfield.(corr, :prop) if all(count.(prop) .== 1) der = [derivative(a, corr[k]) for k = 1:length(corr)] elseif all(count.(prop) .== 2) corr_der = getfield.(corr, :der) n = findall.(t-> t==1, prop) n = vcat(n'...) if all(n[:, 1] .== n[1, 1]) # find ow and w n_w = n[1, 1] n_ow = n[:, 2] else n_w = n[1, 2] n_ow = n[:, 1] end w_mean = 1 / getindex.(corr_der, n_ow)[1] #= Extra information (ow, w) ws = ADerrors.wsg ow_mean = - getindex.(corr_der, n_w) .* w_mean^2 w_data = w_mean .+ ws.fluc[n_w].delta fluc_ow = getfield.(ws.fluc[n_ow], :delta) fluc_ow = vcat(fluc_ow'...) ow_data = ow_mean .+ ws.fluc[n_ow] =# der = a.der[n_ow] * w_mean else return nothing end derm1, derm2 = derm return (sum(der .* derm1.obs), sum(der .* derm2.obs)) end function plat_av(obs::Vector{uwreal}, plat::Vector{Int64}, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing) isnothing(wpm) ? uwerr.(obs) : uwerr.(obs, wpm) isnothing(wpm) ? uwerr.(obs) : [uwerr(obs_aux, wpm) for obs_aux in obs] w = 1 ./ err.(obs)[plat[1]:plat[2]].^2 av = sum(w .* obs[plat[1]:plat[2]]) / sum(w) return av ... ... @@ -629,7 +686,7 @@ m2_phys = fitp[1] + fitp[2] * phi2_phys  """ function lin_fit(x::Vector{<:Real}, y::Vector{uwreal}; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing) isnothing(wpm) ? uwerr.(y) : uwerr.(y, wpm) isnothing(wpm) ? uwerr.(y) : [uwerr(yaux, wpm) for yaux in y] par = lin_fit(x, value.(y), err.(y)) chisq(p, d) = sum((d .- p[1] .- p[2].*x).^2 ./ err.(y) .^2) (fitp, csqexp) = fit_error(chisq, par, y) ... ... @@ -683,7 +740,7 @@ fit_routine(model, xdata, ydata, param=3, covar=true) ` """ function fit_routine(model::Function, xdata::Array{<:Real}, ydata::Array{uwreal}, param::Int64=3; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing) #isnothing(wpm) ? uwerr.(ydata) : uwerr.(ydata, wpm) isnothing(wpm) ? uwerr.(ydata) : [uwerr(yaux, wpm) for yaux in ydata] yval = value.(ydata) yer = err.(ydata) ... ... @@ -711,8 +768,8 @@ function fit_routine(model::Function, xdata::Array{uwreal}, ydata::Array{uwreal} uwerr.(ydata) uwerr.(xdata) else uwerr.(ydata, wpm) uwerr.(xdata, wpm) [uwerr(yaux, wpm) for yaux in ydata] [uwerr(xaux, wpm) for xaux in xdata] end yval = value.(ydata) ... ...