Closed phaustin closed 7 years ago
We provide adaptors for containers that provide an STL-container-like interface but not for pointers to contiguous memory yet. I'm adding this as a feature request.
When #313 is merged, you can do:
#include "xtensor/xadapt.hpp"
// If p is a dynamically allocated array of size s, and the memory is managed by Fortran:
auto adapted = xt::xadapt(p, s, no_ownership(), shape, layout_type::column_major);
// You can used adapted as any other xexpression ...
If shape is an std::array<std::size_t, N>
, xadapt
returns an xtensor_adaptor
, otherwise it returns an xarray_adaptor
.
@phaustin FYI the PR has been merged.
Excellent, will be able to use this in a shortcourse I'm teaching next month on multicore-python
There will be a release in the next few days with that. We are going to use it in xtensor-python
and xtensor-julia
.
xtensor 0.10.2 is out and contains this feature.
I'm forced to call c++ from a fortran main program and am wondering if there is there a way to construct an xview from a pointer to contiguous memory and a set of strides.