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

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): ...@@ -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 and the second entry are a list of samples from D_inv.inverse
""" """
# MR FIXME: this should be synchronized with the "official" Nifty CG # 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 j = S.draw_sample(from_inverse=True) if j is None else j
x = j*0. x = j*0.
energy = QuadraticEnergy(x, D_inv, j) energy = QuadraticEnergy(x, D_inv, j)
...@@ -66,13 +67,13 @@ def generate_krylov_samples(D_inv, S, j, N_samps, controller): ...@@ -66,13 +67,13 @@ def generate_krylov_samples(D_inv, S, j, N_samps, controller):
p = r.copy() p = r.copy()
d = p.vdot(D_inv(p)) d = p.vdot(D_inv(p))
while True: while True:
gamma = r.vdot(r)/d gamma = r.vdot(r) / d
if gamma == 0.: if gamma == 0.:
break break
x = x + gamma*p x = x + gamma*p
Dip = D_inv(p) Dip = D_inv(p)
for samp in y: 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) energy = energy.at(x)
status = controller.check(energy) status = controller.check(energy)
if status != controller.CONTINUE: 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