-
#include "tensorstore/index_space/index_domain.h"
-
template <DimensionIndex Rank, ContainerKind CKind>
class tensorstore::IndexDomain; Represents an index domain.
Index domains specify the bounds, implicit indicators, and optional labels for a list of dimensions. They are logically immutable and are inexpensive to copy.
- Template Parameters:¶
- DimensionIndex Rank¶
Specifies the rank at compile time, or
dynamic_rank
to indicate that the rank is determined at run time.- ContainerKind CKind¶
Specifies whether this owns an index domain (
container
), or merely holds an unowned reference to one (view
).
Data members¶
- constexpr const DimensionIndex static_rank = Rank;
Compile-time rank, or
dynamic_rank
if the rank is specified at run time.
- constexpr const ContainerKind container_kind = CKind;
Specifies whether this owns an index domain (
container
), or merely holds an unowned reference to one (view
).
Types¶
- using RankType = StaticOrDynamicRank<Rank>;
Type that represents the static or dynamic rank.
Constructors¶
- IndexDomain();
Constructs an invalid index domain.
- explicit IndexDomain(RankType rank);
Constructs an unbounded domain with the specified rank.
- explicit IndexDomain(span<const Index, Rank> shape);
- explicit IndexDomain(const Index (&shape)[N]);
Constructs a domain with the specified shape.
- explicit IndexDomain(BoxView<Rank> box);
Constructs a domain with the specified box.
- explicit IndexDomain(const std::string_view (&labels)[N]);
- explicit IndexDomain(span<const std::string_view, Rank> labels);
- explicit IndexDomain(span<const std::string, Rank> labels);
- explicit IndexDomain(span<const char*, Rank> labels);
Constructs an unbounded domain with the specified labels.
- IndexDomain(const IndexDomain<OtherRank, OtherCKind>& other);
- IndexDomain(IndexDomain<OtherRank, OtherCKind>&& other);
Converts from another compatible domain.
-
explicit IndexDomain(unchecked_t,
const IndexDomain<OtherRank, OtherCKind>& other); -
explicit IndexDomain(unchecked_t,
IndexDomain<OtherRank, OtherCKind>&& other); Converts from another domain (unchecked).
Methods¶
- bool valid() const;
Returns
true
if this refers to a valid index domain.
- span<const Index, Rank> origin() const;
Returns the vector of length
rank()
specifying the inclusive lower bound of each dimension.
- span<const Index, Rank> shape() const;
Returns the vector of length
rank()
specifying the extent of each dimension.
- span<const std::string, Rank> labels() const;
Returns the vector of length
rank()
specifying the dimension labels.
- DimensionSet implicit_lower_bounds() const;
Returns the bit vector specifying for each dimension whether its lower bound is “implicit” (1) or “explicit” (0).
- DimensionSet implicit_upper_bounds() const;
Returns the bit vector specifying for each dimension whether its upper bound is “implicit” (1) or “explicit” (0).
- IndexDomainDimension<view> operator[](DimensionIndex i) const;
Returns the domain of dimension
i
.
-
IndexDomain<SubRank, container>
operator[](span<const DimensionIndex, SubRank> dims) const; -
IndexDomain<SubRank, container>
operator[](const DimensionIndex (&dims)[SubRank]) const; Returns a new domain in which dimension
i
is equal to dimensiondims[i]
of this domain.
- Index num_elements() const;
Returns the number of elements in the domain.
- IndexDomain<Rank> Transpose() const&;
- IndexDomain<Rank> Transpose() &&;
Returns a new domain with the dimension order reversed.
-
IndexDomain<Rank>
Transpose(span<const DimensionIndex, Rank> permutation) const&; -
IndexDomain<Rank>
Transpose(span<const DimensionIndex, Rank> permutation) &&; Returns a new domain with the dimension order permuted.
-
Result<IndexTransform<InputRank, OutputRank, container>>
operator()(IndexTransform<InputRank, OutputRank, OtherCKind>
transform) const; Slices an index transform by this index domain.
- auto operator()(Transformable&& transformable) const;
Applies the slicing operation defined by the overload of
operator()
defined above to an object with an associated index space that supportsApplyIndexTransform
.
Friend functions¶
-
friend bool
operator==(const IndexDomain& a, const IndexDomain<RankB, CKindB>& b); -
friend bool
operator!=(const IndexDomain& a, const IndexDomain<RankB, CKindB>& b); Compares two index domains for equality.
-
friend PipelineResultType<IndexDomain&&, Func>
operator|(IndexDomain domain, Func&& func); “Pipeline” operator.
-
friend Result<IndexDomain<RankConstraint::And(Rank, OtherRank)>>
ApplyIndexTransform(BoxView<OtherRank> box, IndexDomain domain); Restricts an index domain by a box of the same rank.
Related Types¶
- using tensorstore::IndexDomainView<Rank> = IndexDomain<Rank, view>;
Unowned view of an index domain.
Related Constants¶
- constexpr bool tensorstore::IsIndexDomain<T>;
Bool-valued metafunction that evaluates to
true
ifT
is an instance ofIndexDomain
.
Related Functions¶
-
BoxView<Rank>
tensorstore::GetBoxDomainOf(const IndexDomain<Rank, CKind>& domain); Implements the HasBoxDomain concept for
IndexDomain
.
- bool tensorstore::IsFinite(IndexDomainView<> domain);
Returns
true
if all dimensions ofdomain
have finite bounds.
-
IndexDomain<Rank> tensorstore::WithImplicitDimensions(
IndexDomain<Rank, CKind> domain,
DimensionSet implicit_lower_bounds,
DimensionSet implicit_upper_bounds); Returns a copy of
domain
withimplicit_lower_bounds
andimplicit_upper_bounds
set to the specified values.
Composition¶
-
Result<IndexDomain<>>
tensorstore::MergeIndexDomains(IndexDomainView<> a,
IndexDomainView<> b); Merges two index domains.
-
Result<IndexDomain<>>
tensorstore::HullIndexDomains(IndexDomainView<> a,
IndexDomainView<> b); Computes the hull of two index domains.
-
Result<IndexDomain<>>
tensorstore::IntersectIndexDomains(IndexDomainView<> a,
IndexDomainView<> b); Intersects two index domains.
-
Result<IndexDomain<>>
tensorstore::ConstrainIndexDomain(IndexDomainView<> a,
IndexDomainView<> b);