tensor_space¶
-
odl.space.space_utils.
tensor_space
(shape, dtype=None, impl='numpy', \*\*kwargs)[source]¶ Return a tensor space with arbitrary scalar data type.
- Parameters
- shapepositive int or sequence of positive ints
Number of entries per axis for elements in this space. A single integer results in a space with 1 axis.
- dtypeoptional
Data type of each element. Can be provided in any way the
numpy.dtype
function understands, e.g. as built-in type or as a string. ForNone
, theTensorSpace.default_dtype
of the created space is used.- implstr, optional
Impmlementation back-end for the space. See tensor_space_impl_names for available options.
- kwargs :
Extra keyword arguments passed to the space constructor.
- Returns
- space
TensorSpace
- space
Examples
Space of 3-tuples with
uint64
entries (although not strictly a vector space):>>> odl.tensor_space(3, dtype='uint64') tensor_space(3, dtype='uint64')
2x3 tensors with same data type:
>>> odl.tensor_space((2, 3), dtype='uint64') tensor_space((2, 3), dtype='uint64')
The default data type depends on the implementation. For
impl='numpy'
, it is'float64'
:>>> ts = odl.tensor_space((2, 3)) >>> ts rn((2, 3)) >>> ts.dtype dtype('float64')