Commit e6732b8a authored by Reimar Leike's avatar Reimar Leike
Browse files

made energies scalable

parent f9ca9bad
Pipeline #67629 passed with stages
in 25 minutes and 42 seconds
......@@ -174,7 +174,10 @@ class LinearOperator(Operator):
return self.apply(x, self.TIMES)
from ..linearization import Linearization
if isinstance(x, Linearization):
return, self(x._jac))
res =, self(x._jac))
if x.metric is not None:
res = res.add_metric(self(x.metric))
return res
return self.__matmul__(x)
def times(self, x):
......@@ -98,5 +98,14 @@ class ScalingOperator(EndomorphicOperator):
return from_random(random_type="normal", domain=self._domain,
std=self._get_fct(from_inverse), dtype=dtype)
def __matmul__(self, other):
if np.isreal(self._factor) and self._factor > 0:
from .sandwich_operator import SandwichOperator
if isinstance(other, SandwichOperator):
sqrt_fac = np.sqrt(self._factor)
newop = ScalingOperator(other.domain, sqrt_fac)
return SandwichOperator.make(newop, other)
return EndomorphicOperator.__matmul__(self, other)
def __repr__(self):
return "ScalingOperator ({})".format(self._factor)
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