#include "tensorstore/index_space/index_domain.h"
template <DimensionIndex InputRank,
         
 DimensionIndex OutputRank,
         
 ContainerKind OtherCKind>
Result<IndexTransform<InputRank, OutputRank, container>>
tensorstore::IndexDomain<Rank, CKind>::operator()(
    
IndexTransform<InputRank, OutputRank, OtherCKind> transform)
   
 const;

Slices an index transform by this index domain.

Equivalent to applying Dims(dims).SizedInterval(this->origin(), this->shape()) to transform, where dims is a dimension index vector of length this->rank() computed according to one of two cases:

M1. At least one of this or transform is entirely unlabeled (all

dimension labels are empty). In this case, dims[i] = i for all i. It is an error if this->rank() != transform.input_rank(). If transform is entirely unlabeled, the returned transform has the labels of this->labels(), which is equivalent to chaining a call to .Label(this->labels()) after the call to DimExpression::SizedInterval.

M2. Both this and transform have at least one labeled dimension. In

this case, each corresponding dimension dims[i] of transform is determined as follows:

  1. If dimension i of this has a non-empty label, dims[i] = k, where k is the dimension of transform for which transform.input_labels()[k] == labels()[i]. It is an error if no such dimension exists.

  2. Otherwise, i is the j th unlabeled dimension of *this (left to right), and dims[i] = k, where k is the j th unlabeled dimension of transform (left to right). It is an error if no such dimension exists.

If any dimensions of *this are unlabeled, then it is an error if this->rank() != transform.input_rank(). This condition is not strictly necessary but serves to avoid a discrepancy in behavior with AlignDomainTo.

The bounds of this index domain must be contained within the existing domain of transform.

All unlabeled dimensions example

  • transform: [0, 5), [1, 7)

  • domain: [2, 4), [3, 6)

  • result: [2, 4), [3, 6)

Fully labeled dimensions example

  • transform: "x": [0, 5), "y": [1, 7), "z": [2, 8)

  • domain: "y": [2, 6), "x": [3, 4)

  • result: "x": [3, 4), "y": [2, 6), "z": [2, 8)

Mixed labeled and unlabeled dimensions example

  • transform: "x": [0, 10), "": [0, 10), "": [0, 10), "y": [0, 10)

  • domain: "y": [1, 6), "": [2, 7), "x": [3, 8), "": [4, 9)

  • result: "x": [3, 8), "": [2, 7), "": [4, 9), "y": [1, 6)

Parameters:
IndexTransform<InputRank, OutputRank, OtherCKind> transform

The transform to slice..

Returns:

The sliced transform.

Error absl::StatusCode::kInvalidArgument:

if dimension matching fails.

Error absl::StatusCode::kOutOfRange:

if the bounds of dimension i of this are not contained within the effective bounds (ignoring implicit bounds) of the corresponding dimension j of transform.