Commit 18f6524
added a mapper that maps the indexes of a view to the indices of a container (#2880)
# Checklist
- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.
# Description
The `index_mapper` class provides functionality to convert indices from
a view's coordinate system
to the corresponding indices in the underlying container. This is
particularly useful for views
that contain integral slices (fixed indices), as these slices reduce the
dimensionality of the view.
Example:
```cpp
xt::xarray<double> a = xt::arange(24).reshape({2, 3, 4});
auto view1 = xt::view(a, 1, xt::all(), xt::all()); // Fixed first dimension
index_mapper<decltype(view1)> mapper;
// Map view indices (i,j) to container indices (1,i,j)
double val = mapper.map(a, view1, 0, 0); // Returns a(1, 0, 0)
double val2 = mapper.map(a, view1, 1, 2); // Returns a(1, 1, 2)
```
---------
Co-authored-by: Alexandre Hoffmann <alexandre.hoffmann@polytechnique.edu>1 parent 0c4ca0d commit 18f6524
File tree
3 files changed
+670
-0
lines changed- include/xtensor/views
- test
3 files changed
+670
-0
lines changed
0 commit comments