Skip to content
Snippets Groups Projects
Commit 83c74e7b authored by Martin Reinecke's avatar Martin Reinecke
Browse files

allow QuadraticEnergy without 'b' term

parent f44ec28a
Branches
Tags
No related merge requests found
Pipeline #
...@@ -31,12 +31,14 @@ class QuadraticEnergy(Energy): ...@@ -31,12 +31,14 @@ class QuadraticEnergy(Energy):
self._b = b self._b = b
if _grad is not None: if _grad is not None:
self._grad = _grad self._grad = _grad
Ax = _grad + self._b Ax = _grad if b is None else _grad + b
else: else:
Ax = self._A(self.position) Ax = self._A(self.position)
self._grad = Ax - self._b self._grad = Ax if b is None else Ax - b
self._grad.lock() self._grad.lock()
self._value = 0.5*self.position.vdot(Ax) - b.vdot(self.position) self._value = 0.5*self.position.vdot(Ax)
if b is not None:
self._value -= b.vdot(self.position)
def at(self, position): def at(self, position):
return QuadraticEnergy(position=position, A=self._A, b=self._b) return QuadraticEnergy(position=position, A=self._A, b=self._b)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment