#include "tensorstore/index_space/dim_expression.h"
template <typename... IndexArray>
auto tensorstore::DimExpression<Op...>::OuterIndexArraySlice(
    
const IndexArray&... index_arrays) const;
auto tensorstore::DimExpression<Op...>::OuterIndexArraySlice(
    
span<const SharedArrayView<const Index>> index_arrays) const;

Independently slices the selected dimensions using index arrays.

Each of the k = sizeof...(IndexArray) selected_dimensions correspond to an index_array. Given an existing_transform with input rank m, the new index transform has an input rank p = m + sum((index_array.rank() - 1)...) - 1, there is a list identity_dims of input dimensions and for each selected_dimensions[i], a separate list array_dims.[i] of index_array.[i].rank() consecutive input dimensions such that:

flatten(interleave(identity_dims,
                   selected_dimensions, {array_dims...})) == 0:p.

The new transform maps input vectors of size p to:

existing_transform(
    interleave(
        input[identity_dims],
        selected_dimensions,
        {index_array(input[array_dims])...}))

The domain of the new input dimension array_dims.[i][j] is [0, index_array.[i].size(j)). The new dimension selection is flatten({array_dims...}).

For example:

Dims(2, 0).OuterIndexArraySlice(MakeArray<Index>({{2, 3}, {4, 5}}),
                                MakeArray<Index>({6, 7}))

has the following effects:

Before

After

Dim. selection

{2, 0}

{2, 3, 0}

Input domain

[4, 8], [2, 5], [0, 9]

[0, 1], [2, 5], [0, 1], [0, 1]

Labels

{"x", "y", "z"}

{"", "y", "", ""}

Equivalent inputs

{6, 3, 3}

{0, 3, 0, 1}

Equivalent inputs

{7, 3, 4}

{1, 3, 1, 0}

Equivalent inputs

{xi(a), y, zi(b,c)}

{a, y, b, c}

where y is any index in [2, 5], a is any index in [0, 1], b is any index in [0, 1], c is any index in [0, 1], xi = MakeArray<Index>({6, 7} and zi = MakeArray<Index>({{2, 3}, {4, 5}}).

Requires:

(IsIndexArray<IndexArray> && ...)

Requires:

sizeof...(IndexArray) must be compatible with the static rank of the dimension selection.

Parameters:
const IndexArray&... index_arrays
span<const SharedArrayView<const Index>> index_arrays

The index arrays used to index into each selected dimension. The new transform may share ownership of the supplied index arrays. The index arrays should not be modified after being passed to this function. The index values contained in the index arrays may be bounds-checked lazily. May also be specified as a span.

Error absl::StatusCode::kInvalidArgument:

if sizeof...(IndexArray) is not equal to the number of selected dimensions.

Error absl::StatusCode::kOutOfRange:

if an out-of-bounds index is detected. error absl::StatusCode::kInvalidArgument if integer overflow occurs when computing the resultant transform.