Commit e261c64e authored by Javier's avatar Javier

md more efficient

if der==0 -> do not call uwreal
parent f5454718
......@@ -265,24 +265,24 @@ function md_sea(a::uwreal, md::Vector{Matrix{Float64}}, ow::uwreal, w::Union{uwr
if isnothing(w)
der = derivative(a, ow)
d1 = der * (ow * uwreal(md_aux[1, :], id, ivrep) - uwreal(ow_data .* md_aux[1, :], id, ivrep))
d1 = der != 0.0 ? der * (ow * uwreal(md_aux[1, :], id, ivrep) - uwreal(ow_data .* md_aux[1, :], id, ivrep)) : 0.0
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))
d2 = der != 0.0 ? der * (ow * uwreal(md_aux[2, :], id, ivrep) - uwreal(ow_data .* md_aux[2, :], id, ivrep)) : 0.0
return (d1, d2)
end
else
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)
d1 = der != 0.0 ? der * (ow * uwreal(w_data .* md_aux[1, :], id, ivrep) / w^2 - uwreal(ow_data .* md_aux[1, :], id, ivrep) / w) : 0.0
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)
d2 = der != 0.0 ? der * (ow * uwreal(w_data .* md_aux[2, :], id, ivrep) / w^2 - uwreal(ow_data .* md_aux[2, :], id, ivrep) / w) : 0.0
return (d1, d2)
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment