pytensor

template <class T, std::size_t N>
class xt::pytensor

Multidimensional container providing the xtensor container semantics wrapping a numpy array.

pytensor is similar to the xtensor container in that it has a static dimensionality.

Unlike with the pyarray container, pytensor cannot be reshaped with a different number of dimensions and reshapes are not reflected on the Python side. However, pytensor has benefits compared to pyarray in terms of performances. pytensor shapes are stack-allocated which makes iteration upon pytensor faster than with pyarray.

See
pyarray
Template Parameters
  • T: The type of the element stored in the pyarray.

Inherits from xt::pycontainer< pytensor< T, N > >, xcontainer_semantic< pytensor< T, N > >

Constructors

pytensor()

Allocates an uninitialized pytensor that holds 1 element.

pytensor(nested_initializer_list_t<T, N> t)

Allocates a pytensor with a nested initializer list.

pytensor(const shape_type &shape, layout l = layout::row_major)

Allocates an uninitialized pytensor with the specified shape and layout.

Parameters
  • shape: the shape of the pytensor
  • l: the layout of the pytensor

pytensor(const shape_type &shape, const_reference value, layout l = layout::row_major)

Allocates a pytensor with the specified shape and layout.

Elements are initialized to the specified value.

Parameters
  • shape: the shape of the pytensor
  • value: the value of the elements
  • l: the layout of the pytensor

pytensor(const shape_type &shape, const strides_type &strides, const_reference value)

Allocates an uninitialized pytensor with the specified shape and strides.

Elements are initialized to the specified value.

Parameters
  • shape: the shape of the pytensor
  • strides: the strides of the pytensor
  • value: the value of the elements

pytensor(const shape_type &shape, const strides_type &strides)

Allocates an uninitialized pytensor with the specified shape and strides.

Parameters
  • shape: the shape of the pytensor
  • strides: the strides of the pytensor

Copy semantic

pytensor(const self_type &rhs)

The copy constructor.

auto operator=(const self_type &rhs)

The assignment operator.

Extended copy semantic

template <class E>
pytensor(const xexpression<E> &e)

The extended copy constructor.

template <class E>
auto operator=(const xexpression<E> &e)

The extended assignment operator.