Commit 698bc932 authored by Reimar Leike's avatar Reimar Leike
Browse files

added .sum and .vdot method to operator and used them in

parent 76568d69
Pipeline #70351 passed with stages
in 15 minutes and 32 seconds
......@@ -134,10 +134,8 @@ class VariableCovarianceGaussianEnergy(EnergyOperator):
lin = isinstance(x, Linearization)
r = FieldAdapter(self._domain[self._r], self._r)
icov = FieldAdapter(self._domain[self._icov], self._icov)
res0 = r.conjugate()*r*icov
sum_it = ContractionOperator(, None)
res0 = sum_it(res0).real
res1 = sum_it(icov.log())
res0 = r.vdot(r*icov).real
res1 = icov.log().sum()
res = 0.5*(res0-res1)
res = res(x)
if not lin:
......@@ -66,6 +66,13 @@ class Operator(metaclass=NiftyMeta):
from .simple_linear_operators import ConjugationOperator
return ConjugationOperator(
def sum(self, spaces=None):
from .contraction_operator import ContractionOperator
return ContractionOperator(, spaces)(self)
def vdot(self, other):
return (self.conjugate()*other).sum()
def real(self):
from .simple_linear_operators import Realizer
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