Commit 170fe8ec authored by Philipp Arras's avatar Philipp Arras
Browse files

Add .imag to Operator

parent a56d26bc
Pipeline #73812 passed with stages
in 19 minutes and 37 seconds
......@@ -133,6 +133,10 @@ class Linearization(Operator):
def real(self):
return, self._jac.real)
def imag(self):
return, self._jac.imag)
def _myadd(self, other, neg):
if np.isscalar(other) or other.jac is None:
return if neg else self._val+other,
......@@ -143,6 +143,11 @@ class Operator(metaclass=NiftyMeta):
from .simple_linear_operators import Realizer
return Realizer(
def imag(self):
from .simple_linear_operators import Imaginizer
return Imaginizer(
def __neg__(self):
return self.scale(-1)
......@@ -112,6 +112,24 @@ class Realizer(EndomorphicOperator):
return x.real
class Imaginizer(EndomorphicOperator):
"""Operator returning the imaginary component of its input.
domain: Domain, tuple of domains or DomainTuple
domain of the input field
def __init__(self, domain):
self._domain = DomainTuple.make(domain)
self._capability = self.TIMES | self.ADJOINT_TIMES
def apply(self, x, mode):
self._check_input(x, mode)
return x.imag
class FieldAdapter(LinearOperator):
"""Operator for conversion between Fields and MultiFields.
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