scream icon indicating copy to clipboard operation
scream copied to clipboard

Enable Subfield Slices Spanning a Range of indices (Issue #1312)

Open mjs271 opened this issue 3 months ago • 43 comments

This PR adds functionality that allows a user to create a "multi-slice" subfield and gain access to the underlying view. That is, a multi-slice subfield is in contrast to the previous capability that sliced a single entry of a chosen dimension--e.g., view(:, 7, :) to use notation common to fortran/matlab, and expands this capability to allow for slicing a chosen dimension across a range of values--e.g., view(:, 2:7, :).

Summary of changes and capabilities:

  • Added overloads for Field::subfield() that takes the extra argument(s) index_beg, index_end to indicate the bounds of the slicing range.
  • Added Field::get_multi_sliced_view() that provides the view underlying the subfield as a multi-dimensional view with the same number of dimensions as the parent's associated view (as opposed to a single-sliced view that is (N - 1)-dimensional.
    • Note: as implemented, this is only returned as a LayoutStride view, rather than LayoutRight.

I do need to add a few more tests and will push those changes soon, but I wanted to get this out there as a draft. Any feedback about my approach would be much-appreciated, since this is my first time doing a deep-dive into this code.

Closes #1312

mjs271 avatar Apr 04 '24 23:04 mjs271