ProductSpace.element

ProductSpace.element(inp=None, copy=True)[source]

Create an element in the product space.

Parameters

inpoptional

If inp is None, a new element is created from scratch by allocation in the spaces. If inp is already an element of this space, it is re-wrapped. Otherwise, a new element is created from the components by calling the element() methods in the component spaces.

copybool, optional

If True, data may be copied from one representation to another in order to satisfy the requirements of the space and its subspaces. This is flexible but can cause poor performance. If False, a TypeError is

Returns

elementProductSpaceElement

The new element

Examples

>>> r2, r3 = odl.rn(2), odl.rn(3)
>>> vec_2, vec_3 = r2.element(), r3.element()
>>> r2x3 = ProductSpace(r2, r3)
>>> vec_2x3 = r2x3.element()
>>> vec_2.space == vec_2x3[0].space
True
>>> vec_3.space == vec_2x3[1].space
True

Create an element of the product space

>>> r2, r3 = odl.rn(2), odl.rn(3)
>>> prod = ProductSpace(r2, r3)
>>> x2 = r2.element([1, 2])
>>> x3 = r3.element([1, 2, 3])
>>> x = prod.element([x2, x3])
>>> x
ProductSpace(rn(2), rn(3)).element([
    [ 1.,  2.],
    [ 1.,  2.,  3.]
])