group xt_xeval

Evaluation functions.

Defined in xtensor/xeval.hpp


template<class T>
inline auto eval(T &&t) -> std::enable_if_t<detail::is_container<std::decay_t<T>>::value, T&&>

Force evaluation of xexpression.

xt::xarray<double> a = {1, 2, 3, 4};
auto&& b = xt::eval(a); // b is a reference to a, no copy!
auto&& c = xt::eval(a + b); // c is xarray<double>, not an xexpression

xt::xarray or xt::xtensor depending on shape type

template<layout_type L = layout_type::any, class E>
inline auto as_strided(E &&e) -> std::enable_if_t<has_data_interface<std::decay_t<E>>::value && detail::has_same_layout<L, E>(), E&&>

Force evaluation of xexpression not providing a data interface and convert to the required layout.

xt::xarray<double, xt::layout_type::row_major> a = {1, 2, 3, 4};

// take reference to a (no copy!)
auto&& b = xt::as_strided(a);

// xarray<double> with the required layout
auto&& c = xt::as_strided<xt::layout_type::column_major>(a);

// xexpression
auto&& a_cast = xt::cast<int>(a);

// xarray<int>, not an xexpression
auto&& d = xt::as_strided(a_cast);

// xarray<int> with the required layout
auto&& e = xt::as_strided<xt::layout_type::column_major>(a_cast);


This function should be used in a local context only. Returning the value returned by this function could lead to a dangling reference.


The expression when it already provides a data interface with the correct layout, an evaluated xt::xarray or xt::xtensor depending on shape type otherwise.