xtensor_fixed

Defined in xtensor/xfixed.hpp

template <class ET, class S, layout_type L, class Tag>
class xfixed_container : public xt::xcontainer<xfixed_container<ET, S, L, Tag>>, public xt::xcontainer_semantic<xfixed_container<ET, S, L, Tag>>

Dense multidimensional container with tensor semantic and fixed dimension.

The xfixed_container class implements a dense multidimensional container with tensor semantic and fixed dimension

See
xtensor_fixed
Template Parameters
  • ET: The type of the elements.
  • S: The xshape template paramter of the container.
  • L: The layout_type of the tensor.
  • Tag: The expression tag.

Constructors

xfixed_container(const inner_shape_type &shape, layout_type l = L)

Create an uninitialized xfixed_container.

Note this function is only provided for homogenity, and the shape & layout argument is disregarded (the template shape is always used).

Parameters

xfixed_container(const inner_shape_type &shape, value_type v, layout_type l = L)

Create an xfixed_container, and initialize with the value of v.

Note, the shape argument to this function is only provided for homogenity, and the shape argument is disregarded (the template shape is always used).

Parameters

template <class IX = std::integral_constant<std::size_t, N>, class EN = std::enable_if_t<IX::value != 0, int>>
xfixed_container(nested_initializer_list_t<value_type, N> t)

Allocates an xfixed_container with shape S with values from a C array.

The type returned by get_init_type_t is raw C array value_type[X][Y][Z] for xt::xshape<X, Y, Z>. C arrays can be initialized with the initializer list syntax, but the size is checked at compile time to prevent errors. Note: for clang < 3.8 this is an initializer_list and the size is not checked at compile-or runtime.

Extended copy semantic

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

The extended copy constructor.

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

The extended assignment operator.

Public Functions

template <class ST = std::array<std::size_t, N>>
void resize(ST &&shape, bool force = false) const

Note that the xfixed_container cannot be resized.

Attempting to resize with a different size throws an assert in debug mode.

template <class ST = shape_type>
void resize(ST &&shape, layout_type l) const

Note that the xfixed_container cannot be resized.

Attempting to resize with a different size throws an assert in debug mode.

template <class ST = shape_type>
void resize(ST &&shape, const strides_type &strides) const

Note that the xfixed_container cannot be resized.

Attempting to resize with a different size throws an assert in debug mode.

template <class ST = std::array<std::size_t, N>>
void reshape(ST &&shape, layout_type layout = L) const

Note that the xfixed_container cannot be reshaped to a shape different from S.

typedef xt::xtensor_fixed

Alias template on xfixed_container with default parameters for layout type.

This allows to write

xt::xtensor_fixed<double, xt::xshape<2, 2>> a = {{1., 2.}, {3., 4.}};

instead of the syntax

xt::xfixed_container<double, xt::xshape<2, 2>, xt::layout_type::row_major> a = ...

Template Parameters
  • T: The value type of the elements.
  • FSH: A xshape template shape.
  • L: The layout_type of the tensor (default: row_major).
  • A: The allocator of the containers holding the elements.