Commit 57dc6c42 authored by Jakob Knollmueller's avatar Jakob Knollmueller
Browse files


parent 713a86b0
......@@ -16,7 +16,7 @@
# Starblade is being developed at the Max-Planck-Institut fuer Astrophysik
from nifty4 import Energy, Field, DiagonalOperator, InversionEnabler, full
from nifty4 import Energy, Field, DiagonalOperator, InversionEnabler, full, ScalingOperator
from starblade_energy import StarbladeEnergy
......@@ -57,6 +57,8 @@ class StarbladeKL(Energy):
energy = StarbladeEnergy(position+sample,parameters)
self.ScaleOp = ScalingOperator(1./len(self.energy_list),self.position.domain)
def at(self, position):
return self.__class__(position, samples=self.samples, parameters=self.parameters)
......@@ -73,13 +75,12 @@ class StarbladeKL(Energy):
gradient = full(self.position.domain, 0.)
for energy in self.energy_list:
gradient += energy.gradient
gradient /= len(self.energy_list)
return gradient
return self.ScaleOp(gradient)
def curvature(self):
curvature = DiagonalOperator(full(self.position.domain, 0.))
for energy in self.energy_list:
curvature += energy.curvature
curvature *= Field(self.position.domain, val=1./len(self.energy_list))
curvature = self.ScaleOp(curvature)
return InversionEnabler(curvature, self.parameters['inverter'])
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