Commit f6b56291 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

adjust to changes on NIFTy_5 branch

parent 3d526bfa
......@@ -93,12 +93,16 @@ class Linearization(object):
def __rsub__(self, other):
return (-self).__add__(other)
def __truediv__(self, other):
if isinstance(other, Linearization):
return self.__mul__(other.inverse())
return self.__mul__(1./other)
def __rtruediv__(self, other):
return (self.inverse()).__mul__(other)
return self.inverse().__mul__(other)
def inverse(self):
return Linearization(1./self._val,
return, makeOp(-1./(self._val**2))(self._jac))
def __mul__(self, other):
from .sugar import makeOp
......@@ -112,6 +112,7 @@ class PoissonianEnergy(EnergyOperator):
metric = SandwichOperator.make(x.jac, makeOp(1./x.val))
return res.add_metric(metric)
class InverseGammaLikelihood(EnergyOperator):
def __init__(self, op, d):
self._op, self._d = op, d
......@@ -122,11 +123,12 @@ class InverseGammaLikelihood(EnergyOperator):
res = 0.5*(x.log().sum() + (0.5/x).vdot(self._d))
if not isinstance(x, Linearization):
return Field.scalar(res)
if not x.want_metric:
return res
metric = SandwichOperator.make(x.jac, makeOp(0.5/(x.val**2)))
return res.add_metric(metric)
class BernoulliEnergy(EnergyOperator):
def __init__(self, p, d):
self._p = p
Supports Markdown
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