The image object is initialised with a vector of size 1, a shape vector {1} and a strides vector of {1} . Затем, когда я загружаю вектор точек, который больше, он изменяет размер вектор данных, копирует значения и устанавливает новую форму адаптера Xtensor. < /P>
Это код, я использую G ++ 14.2 на машине Ubunt
Код: Выделить всё
// compile with
// g++ -I../../xtensor-stack test-xtensor3.cpp -o test-xtensor3
// from directory test-xtensor
//
// this should be the directory structure from the parent dir:
// .
// ├── bis
// │ └── test-xtensor
// └── xtensor-stack
// ├── xframe
// ├── xsimd
// ├── xsimd-algorithm
// ├── xtensor
// ├── xtensor-blas
// ├── xtensor-fftw
// ├── xtensor-io
// ├── xtensor-python
// ├── xtensor-r
// ├── xtensor-signal
// ├── xtensor-sparse
// └── xtl
#include
#include
#include
#include
#include
#include
template
class bisimage { // image with a data buffer and xtensor access
public:
using self = bisimage; // always good to know your type
using buffer_type = std::vector; // type of the underlying buffer of data points
// Ensuring that strides and shape types match the expected types for xtensor
using shape_type = std::vector; // std::size_t is typically used for shape
using strides_type = std::vector; // std::ptrdiff_t for strides
protected:
buffer_type _datavec = { 0 }; // data buffer
shape_type datashape = { 1 }; // shape for initialisation
strides_type datastrides = { 1 }; // strides for initialisation
public:
using data_type = xt::xarray_adaptor;
data_type data; // this is what the data looks like to the outside world
bisimage()
: data( _datavec, datashape, datastrides ) {} // default constructor: 1 data point, shape and strides as expected
void data_info () {
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79471185/does-an-xtensor-adaptor-of-a-stdvector-store-its-own-copy-of-the-data[/url]
Мобильная версия