xtensor-stack / xtensor

C++ tensors with broadcasting and lazy computing
BSD 3-Clause "New" or "Revised" License
3.33k stars 398 forks source link

Dynamic xview's #41

Closed wolfv closed 7 years ago

wolfv commented 7 years ago

Currently xview is implemented using tuple as holder for the slices. As far as I understand this necessitates that all slices are known at compile time. .....

But for example when creating a view from python, it's not possible to know the slices at compile time. It would also make writing the xreducer functionality easier (as e.dimension() is not a constexpr and cannot be used as template parameter etc.) (or that's at least how I tried doing it).

So I am wondering whether it would be a good idea to either create a separate, dynamic xview class or exchange the tuple in xview for a std::vector holding an std::variant<xall, xrange, size_t> or similar.

SylvainCorlay commented 7 years ago

@wolfv thanks for opening this. I agree that there is room for another xview-like xexpression that would take a vector of such variants.

Similarly, all expressions have two access operators () which takes a compile-time known number of argument and [] which takes a single multi-index of dynamic size....

Since std::variant is a C++17 only feature, we will probably need to polyfill it in xtensor.

SylvainCorlay commented 7 years ago

The newaxis functionality might be easier to implement in the case of dynamic xviews.

wolfv commented 7 years ago

Just FYI i prototyped something here: https://github.com/wolfv/xtensor/tree/xdynview (https://github.com/wolfv/xtensor/blob/xdynview/include/xtensor/xdynview.hpp)

JohanMabille commented 7 years ago

Implemented in #269.