Commit f849faf6 authored by Philipp Arras's avatar Philipp Arras
Browse files

Fixup gig energy

parent d37dc659
Pipeline #70300 passed with stages
in 15 minutes and 28 seconds
......@@ -133,6 +133,10 @@ class VariableCovarianceGaussianEnergy(EnergyOperator):
res0 = x[self._r].vdot(x[self._r]*x[self._icov]).real
res1 = x[self._icov].log().sum()
res = 0.5*(res0-res1)
if not isinstance(x, Linearization):
return Field.scalar(res)
if not x.want_metric:
return res
mf = {self._r: x.val[self._icov], self._icov: .5*x.val[self._icov]**(-2)}
metric = makeOp(MultiField.from_dict(mf))
return res.add_metric(SandwichOperator.make(x.jac, metric))
......
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