Point xt::xtensor container and xt::xarray container to same memory location.

Hello everyone,

I am working in an optimization project which uses xtensor library to deal with large amounts of data. The problem I currently have is that I want to modify the data using instance functions from both containers xt::xarray and xt::xtensor. However, I want to avoid copying the data twice and creating a new memory location for each container.

Since both containers have the same "data structure" (correct me if I'm wrong) I wanted to know if it was possible to have a xtensor pointer xt::xtensor* a and a xarray pointer xt::xarray* b pointing to the same memory location. The other possibility would be to access instances of xtensor from xarray or the other way around but again I am unsure if I can do that.

Thank you for your help!
Last edited on
What is it that can be done in xtensor that can't be done in xarray, or vice versa? The only difference seems to be whether or not they can be dynamically "reshaped". It's also possible that xtensor is faster.

xtensor wrote:
xarray<T>: tensor that can be reshaped to any number of dimensions.
xtensor<T, N>: tensor with a number of dimensions set to N at compile time.
xtensor_fixed<T, xshape<I, J, K>: tensor whose shape is fixed at compile time.
Last edited on
Topic archived. No new replies allowed.