-
#include "tensorstore/index_interval.h"
- class tensorstore::IndexInterval;
Represents an interval of index values, with support for +/-inf bounds.
Constructors¶
- constexpr IndexInterval();
Constructs an interval corresponding to
(-inf, +inf)
.
- static constexpr IndexInterval Infinite() noexcept;
Returns an interval corresponding to
(-inf, +inf)
.
-
static constexpr IndexInterval
UncheckedClosed(Index inclusive_min, Index inclusive_max) noexcept; Constructs an interval from inclusive lower and upper bounds.
-
static Result<IndexInterval>
Closed(Index inclusive_min, Index inclusive_max); Tries to construct an interval from inclusive lower and upper bounds.
-
static constexpr IndexInterval
UncheckedHalfOpen(Index inclusive_min, Index exclusive_max) noexcept; Constructs an interval from an inclusive lower bound and exclusive upper bound.
-
static Result<IndexInterval>
HalfOpen(Index inclusive_min, Index exclusive_max); Tries to construct an interval from an inclusive lower bound and exclusive upper bound.
-
static constexpr IndexInterval
UncheckedSized(Index inclusive_min, Index size); Constructs an interval from the specified inclusive lower bound and size.
- static Result<IndexInterval> Sized(Index inclusive_min, Index size);
Tries to construct an interval from the specified inclusive lower bound and size.
Methods¶
-
static constexpr bool
ValidClosed(Index inclusive_min, Index inclusive_max); Returns
true
ifinclusive_min
andinclusive_max
specify a valid closed interval.
-
static constexpr bool
ValidHalfOpen(Index inclusive_min, Index exclusive_max); Returns
true
ifinclusive_min
andexclusive_max
specify a valid interval.
- static constexpr bool ValidSized(Index inclusive_min, Index size);
Returns
true
ifinclusive_min
andsize
specify a valid interval.
- static constexpr IndexInterval FiniteRange();
Returns the full range of all valid finite index values.
- constexpr IndexInterval operator-() const;
Returns the negated interval.
Accessors¶
- constexpr Index inclusive_min() const;
Returns the inclusive lower bound of the interval.
- constexpr Index exclusive_min() const;
Returns the exclusive lower bound.
- constexpr Index exclusive_max() const;
Returns the inclusive upper bound of the interval.
- constexpr Index inclusive_max() const;
Returns the inclusive upper bound of the interval.
Friend functions¶
- friend std::ostream& operator<<(std::ostream& os, IndexInterval x);
Writes a string representation of an interval to an ostream.
- friend constexpr bool operator==(IndexInterval a, IndexInterval b);
Compares two intervals for equality.
Related Functions¶
-
constexpr bool
tensorstore::Contains(IndexInterval interval, Index index);
-
constexpr bool
tensorstore::Contains(IndexInterval outer, IndexInterval inner);
- constexpr bool tensorstore::IsFinite(IndexInterval interval);
Returns
true
ifinterval
is bounded below and above.
- IndexInterval tensorstore::Hull(IndexInterval a, IndexInterval b);
-
IndexInterval
tensorstore::Intersect(IndexInterval a, IndexInterval b); Returns the intersection of two intervals.
- IndexInterval tensorstore::FiniteSubset(IndexInterval interval);
Returns
Intersect(interval, IndexInterval::FiniteRange())
.
-
bool tensorstore::AreCompatibleOrUnbounded(IndexInterval a,
IndexInterval b); Returns
true
if the lower and upper bounds ofa
“match” the lower and upper bounds ofb
.
-
bool tensorstore::ContainsOrUnbounded(IndexInterval outer,
IndexInterval inner); Returns
true
if the lower and upper bound ofinner
is either unbounded or contained with the lower and upper bound, respectively, ofouter
.
-
Result<IndexInterval>
tensorstore::ShiftInterval(IndexInterval interval,
Index min_offset,
Index max_offset); -
Result<IndexInterval>
tensorstore::ShiftInterval(IndexInterval interval, Index offset); Adds an offset to the min and max bounds of an interval.
-
Result<IndexInterval>
tensorstore::ShiftIntervalBackward(IndexInterval interval,
Index min_offset,
Index max_offset); -
Result<IndexInterval>
tensorstore::ShiftIntervalBackward(IndexInterval interval,
Index offset); Subtracts an offset from the min and max bounds of an interval.
-
Result<IndexInterval>
tensorstore::ShiftIntervalTo(IndexInterval interval, Index origin);
-
absl::Status
tensorstore::CheckContains(IndexInterval interval, Index index);
-
Result<IndexInterval>
tensorstore::GetAffineTransformDomain(IndexInterval interval,
Index offset,
Index divisor); Computes the largest possible domain such that the affine-transformed range is contained within
interval
.
-
Result<OptionallyImplicitIndexInterval>
tensorstore::GetAffineTransformDomain(
OptionallyImplicitIndexInterval interval,
Index offset,
Index divisor); Same as above, but also propagates
interval.implicit_lower()
andinterval.implicit_upper()
to the input space.
-
Result<IndexInterval>
tensorstore::GetAffineTransformRange(IndexInterval interval,
Index offset,
Index multiplier); Computes the range of the affine-transformed domain
interval
.
-
Result<IndexInterval>
tensorstore::GetAffineTransformInverseDomain(IndexInterval interval,
Index offset,
Index divisor); Computes the interval containing all indices
x
for which(x - offset) / divisor
is ininterval
, where/
rounds towards 0.
-
constexpr IndexInterval
tensorstore::DividePositiveRoundOut(IndexInterval interval,
Index divisor); Divides the lower and upper bounds of
interval
bydivisor
, rounding out (expanding the interval) to the nearest integer.
Related Types¶
- class tensorstore::IndexIntervalRef;
Represents a mutable reference to an index interval stored as an
inclusive_min
,size
pair.
- enum class tensorstore::IntervalForm;
Indicates how the interval bounds are specified to slicing operations.