xtensor

Defined in xtensor/xtensor.hpp

template<class EC, std::size_t N, layout_type L = ::xt::layout_type::row_major, class Tag = xtensor_expression_tag>
class xtensor_container : public xt::xstrided_container<xtensor_container<EC, N, ::xt::layout_type::row_major, xtensor_expression_tag>>, public xt::xcontainer_semantic<xtensor_container<EC, N, ::xt::layout_type::row_major, xtensor_expression_tag>>, public extension::xtensor_container_base_t<EC, N, ::xt::layout_type::row_major, xtensor_expression_tag>

Dense multidimensional container with tensor semantic and fixed dimension.

The xtensor_container class implements a dense multidimensional container with tensor semantics and fixed dimension

Template Parameters:
  • EC – The type of the container holding the elements.

  • N – The dimension of the container.

  • L – The layout_type of the tensor.

  • Tag – The expression tag.

Constructors

inline xtensor_container()

Allocates an uninitialized xtensor_container that holds 0 elements.

inline xtensor_container(nested_initializer_list_t<value_type, N> t)

Allocates an xtensor_container with nested initializer lists.

inline explicit xtensor_container(const shape_type &shape, layout_type l = L)

Allocates an uninitialized xtensor_container with the specified shape and layout_type.

Parameters:
inline explicit xtensor_container(const shape_type &shape, const_reference value, layout_type l = L)

Allocates an xtensor_container with the specified shape and layout_type.

Elements are initialized to the specified value.

Parameters:
inline explicit xtensor_container(const shape_type &shape, const strides_type &strides)

Allocates an uninitialized xtensor_container with the specified shape and strides.

Parameters:
inline explicit xtensor_container(const shape_type &shape, const strides_type &strides, const_reference value)

Allocates an uninitialized xtensor_container with the specified shape and strides.

Elements are initialized to the specified value.

Parameters:
inline explicit xtensor_container(storage_type &&storage, inner_shape_type &&shape, inner_strides_type &&strides)

Allocates an xtensor_container by moving specified data, shape and strides.

Parameters:

Extended copy semantic

template<class E>
inline xtensor_container(const xexpression<E> &e)

The extended copy constructor.

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

The extended assignment operator.

template<class T, std::size_t N, layout_type L = ::xt::layout_type::row_major, class A = std::allocator<T>>
using xt::xtensor = xtensor_container<uvector<T, A>, N, L>

Alias template on xtensor_container with default parameters for data container type.

This allows to write

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

instead of the heavier syntax

xt::xtensor_container<std::vector<double>, 2> a = ...
Template Parameters:
  • T – The value type of the elements.

  • N – The dimension of the tensor.

  • L – The layout_type of the tensor (default: XTENSOR_DEFAULT_LAYOUT).

  • A – The allocator of the containers holding the elements.

template<class T, std::size_t N, layout_type L = ::xt::layout_type::row_major, class A = std::allocator<T>, class BC = xtl::xdynamic_bitset<std::size_t>>
using xt::xtensor_optional = xtensor_container<xtl::xoptional_vector<T, A, BC>, N, L, xoptional_expression_tag>

Alias template on xtensor_container for handling missing values.

Template Parameters:
  • T – The value type of the elements.

  • N – The dimension of the tensor.

  • L – The layout_type of the container (default: XTENSOR_DEFAULT_LAYOUT).

  • A – The allocator of the containers holding the elements.

  • BA – The allocator of the container holding the missing flags.

template<class T>
inline auto xt::from_indices(const std::vector<T> &idx)

Converts std::vector<index_type> (returned e.g.

from xt::argwhere) to xtensor.

Parameters:

idx – vector of indices

Returns:

xt::xtensor<typename index_type::value_type, 2> (e.g. xt::xtensor<size_t, 2>)

template<class T>
inline auto xt::flatten_indices(const std::vector<T> &idx)

Converts std::vector<index_type> (returned e.g.

from xt::argwhere) to a flattened xtensor.

Parameters:

idx – a vector of indices

Returns:

xt::xtensor<typename index_type::value_type, 1> (e.g. xt::xtensor<size_t, 1>)

template<class Tag = ravel_tensor_tag, class C, class S>
ravel_return_type_t<C, Tag> xt::ravel_indices(const C &idx, const S &shape, layout_type l = layout_type::row_major)

Converts std::vector<index_type> (returned e.g.

from xt::argwhere) to xtensor whereby the indices are ravelled. For 1-d input there is no conversion.

Parameters:
  • idx – vector of indices

  • shape – the shape of the original array

  • l – the layout type (row-major or column-major)

Returns:

xt::xtensor<typename index_type::value_type, 1> (e.g. xt::xtensor<size_t, 1>)