Commit 453cb030 authored by Philipp Frank's avatar Philipp Frank

numpy hotfix for krylov sampling

parent c305952a
Pipeline #27925 passed with stages
in 19 minutes and 33 seconds
......@@ -53,6 +53,7 @@ def generate_krylov_samples(D_inv, S, j, N_samps, controller):
and the second entry are a list of samples from D_inv.inverse
"""
# MR FIXME: this should be synchronized with the "official" Nifty CG
# RL FIXME: make consistent with complex numbers
j = S.draw_sample(from_inverse=True) if j is None else j
x = j*0.
energy = QuadraticEnergy(x, D_inv, j)
......@@ -66,13 +67,13 @@ def generate_krylov_samples(D_inv, S, j, N_samps, controller):
p = r.copy()
d = p.vdot(D_inv(p))
while True:
gamma = r.vdot(r)/d
gamma = r.vdot(r) / d
if gamma == 0.:
break
x = x + gamma*p
Dip = D_inv(p)
for samp in y:
samp += (randn() * sqrt(d) - samp.vdot(Dip)) / d * p
samp += (np.random.randn() * np.sqrt(d) - samp.vdot(Dip)) / d * p
energy = energy.at(x)
status = controller.check(energy)
if status != controller.CONTINUE:
......
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