RealPart

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

Bases: Operator

Operator that extracts the real part of a vector.

Implements:

RealPart(x) == x.real
__init__(space)[source]

Initialize a new instance.

Parameters

spaceTensorSpace

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

Examples

Take the real part of complex vector:

>>> c3 = odl.cn(3)
>>> op = RealPart(c3)
>>> op([1 + 2j, 2, 3 - 1j])
rn(3).element([ 1.,  2.,  3.])

The operator is the identity on real spaces:

>>> r3 = odl.rn(3)
>>> op = RealPart(r3)
>>> op([1, 2, 3])
rn(3).element([ 1.,  2.,  3.])

The operator also works on other TensorSpace spaces such as DiscretizedSpace spaces:

>>> r3 = odl.uniform_discr(0, 1, 3, dtype=complex)
>>> op = RealPart(r3)
>>> op([1, 2, 3])
uniform_discr(0.0, 1.0, 3).element([ 1.,  2.,  3.])