Commit 2add9edd authored by Reimar H Leike's avatar Reimar H Leike

added preconditioning to sampling enabler

parent 5512b99a
......@@ -46,7 +46,7 @@ def WienerFilterCurvature(R, N, S, inverter, sampling_inverter=None):
"""
M = SandwichOperator.make(R, N.inverse)
if sampling_inverter is not None:
op = SamplingEnabler(M, S.inverse, sampling_inverter)
op = SamplingEnabler(M, S.inverse, sampling_inverter, approximation=S.inverse)
else:
op = M + S.inverse
return InversionEnabler(op, inverter, S.inverse)
......@@ -50,6 +50,7 @@ class SamplingEnabler(EndomorphicOperator):
self._likelihood = likelihood
self._prior = prior
self._sampling_inverter = sampling_inverter
self._approximation = approximation
def draw_sample(self, from_inverse=False, dtype=np.float64):
try:
......@@ -60,7 +61,7 @@ class SamplingEnabler(EndomorphicOperator):
nj = self._likelihood.draw_sample()
energy = QuadraticEnergy(s, self._op, sp + nj,
_grad=self._likelihood(s) - nj)
energy, convergence = self._sampling_inverter(energy)
energy, convergence = self._sampling_inverter(energy, preconditioner=self._approximation.inverse)
return energy.position
@property
......
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