mrpro.operators.Operator

class mrpro.operators.Operator[source]

Bases: Generic[Unpack[Tin], Tout], ABC, TensorAttributeMixin, Module

The general Operator class.

An operator is a function that maps one or more input tensors to one or more output tensors. Operators always return a tuple of tensors. Operators can be composed, added, multiplied, and applied to tensors. The forward method must be implemented by the subclasses.

__call__(*args: Unpack) Tout[source]

Apply the forward operator.

For more information, see forward.

Note

Prefer using operator_instance(*parameters), i.e. using __call__ over using forward.

abstract forward(*args: Unpack) Tout[source]

Apply forward operator.

__add__(other: Operator[Unpack, Tout]) Operator[Unpack, Tout][source]
__add__(other: Tensor) Operator[Unpack, tuple[Unpack]]

Operator addition.

Returns lambda x: self(x) + other(x) if other is a operator, lambda x: self(x) + other*x if other is a tensor

__matmul__(other: Operator[Unpack, tuple[Unpack]]) Operator[Unpack, Tout][source]

Operator composition.

Returns lambda x: self(other(x))

__mul__(other: Tensor | complex) Operator[Unpack, Tout][source]

Operator multiplication with tensor.

Returns lambda x: self(x*other)

__radd__(other: Tensor) Operator[Unpack, tuple[Unpack]][source]

Operator right addition.

Returns lambda x: other*x + self(x)

__rmul__(other: Tensor | complex) Operator[Unpack, Tout][source]

Operator multiplication with tensor.

Returns lambda x: other*self(x)