-
#include "tensorstore/index_space/dimension_identifier.h"
- struct tensorstore::DimRangeSpec;
Represents a range of dimension indices.
Equal to
*inclusive_start + i * step
fori = 0, 1, ...
, where*inclusive_start + i * step < *exclusive_stop
ifstep > 0
and*inclusive_start + i * step > *exclusive_stop
ifstep < 0
.A
DimRangeSpec
can be used to specify both existing dimensions as well as dimensions to be added. However, when specifying dimensions to be added and the final rank is to be inferred from the dimension selection itself, certain forms ofDimRangeSpec
are disallowed because they do not permit the final rank to be inferred. For example:DimRangeSpec{-3, std::nullopt, 1}
unambiguously specifies the last 3 dimensions, and can be used to add 3 new trailing dimensions.DimRangeSpec{std::nullopt, 4, 1}
unambiguously specifies the first 3 dimensions, and can be used to add 3 new leading dimensions.DimRangeSpec{1, -2, 1}
specifies dimensions 1 up to but not including the second from the last. It cannot be used to infer the final rank when adding new dimensions.
Data members¶
- std::optional<DimensionIndex> inclusive_start;
Inclusive start index.
- std::optional<DimensionIndex> exclusive_stop;
Exclusive stop index.
- DimensionIndex step = 1;
Step size, must not equal 0.
Friend functions¶
-
friend std::ostream&
operator<<(std::ostream& os, const DimRangeSpec& spec); Returns a Python-style
inclusive_start:inclusive_stop
orinclusive_start:exclusive_stop:step
slice expression, whereinclusive_start
andexclusive_stop
are omitted if equal tostd::nullopt
andstep
is omitted if equal to1
.
- friend bool operator==(const DimRangeSpec& a, const DimRangeSpec& b);
- friend bool operator!=(const DimRangeSpec& a, const DimRangeSpec& b);
Compares two
DimRangeSpec
objects for equality.
Related Functions¶
-
absl::Status
tensorstore::NormalizeDimRangeSpec(const DimRangeSpec& spec,
DimensionIndex rank,
DimensionIndexBuffer* result);