ComplexModulusSquared

class odl.ComplexModulusSquared(*args, **kwargs)

Bases: Operator

Operator that computes the squared complex modulus (absolute value).

__init__(space)[source]

Initialize a new instance.

Parameters

spaceTensorSpace

Space in which the modulus should be taken, needs to implement space.real_space.

Examples

Take the squared modulus of a complex vector:

>>> c2 = odl.cn(2)
>>> op = odl.ComplexModulusSquared(c2)
>>> op([3 + 4j, 2])
rn(2).element([ 25.,   4.])

On a real space, this is the same as squaring:

>>> r2 = odl.rn(2)
>>> op = odl.ComplexModulusSquared(r2)
>>> op([1, -2])
rn(2).element([ 1.,  4.])

The operator also works on other TensorSpace’s such as DiscretizedSpace:

>>> space = odl.uniform_discr(0, 1, 2, dtype=complex)
>>> op = odl.ComplexModulusSquared(space)
>>> op([3 + 4j, 2])
uniform_discr(0.0, 1.0, 2).element([ 25.,   4.])