-
#include "tensorstore/index_space/dim_expression.h"
-
template <typename Start, typename Stop, typename Strides = Index>
auto tensorstore::DimExpression<Op...>::HalfOpenInterval(
const Start& start,
const Stop& stop,
const Strides& strides = 1) const; Extracts a half-open interval from the selected dimensions with optional striding.
The domain of each selected dimension is transformed by ExtractHalfOpenStridedSlice using the corresponding components of the
start
,stop
, andstrides
vectors. In the simple case that the stride component is1
, the new domain is simply restricted to the specified interval, with the new origin equal to the specifiedstart
component. In the general case with a stide component not equal to1
, the new origin is equal to thestart
component divided by thestrides
component, rounded towards zero; in this case, theTranslateHalfOpenInterval
operation, which ensures an origin of 0, may be more convenient.The new dimension selection is the same as the prior dimension selection, with a static rank equal to the merged static rank of the prior dimension selection and the static extents of the
start
,stop
, andstrides
vectors.For example:
Dims(0, 2).HalfOpenInterval({1, 8}, {4, 3}, {1, -2})
has the following effects:Before
After
Dimension selection
{0, 2}
{0, 2}
Input domain
[0, 6], [2, 5], [0, 9]
[1, 3], [2, 5], [-4, -2]
Labels
{"x", "y", "z"}
{"x", "y", "z"}
Equivalent input indices
{2, 3, 6}
{2, 3, -3}
Equivalent input indices
{x, y, z * -2}
{x, y, z}
where
x
is any index in[1, 4]
,y
is any index in[2, 5]
, andz
is any index in[-4, -2]
.- Requires:¶
Start
,Stop
, andStrides
satisfy the IsIndexVectorOrScalar concept with static extents compatible with each other and with the static rank of the dimension selection.- Parameters:¶
- const Start &start¶
The index vector specifying the start indices for each selected dimension. May be a braced list, e.g.
{1, 2, 3}
. May also be a scalar, e.g.5
, in which case the same start index is used for all selected dimensions.- const Stop &stop¶
The index vector specifying the stop indices for each selected dimension. May be a braced list or scalar.
- const Strides &strides = 1¶
The index vector specifying the stride value for each selected dimension. May be a braced list or scalar. If not specified, defaults to 1.
- Error absl::StatusCode::kInvalidArgument:¶
if the extents of the
start
,stop
, orstrides
vectors do not match the number of selected dimensions.- Error absl::StatusCode::kInvalidArgument:¶
or
absl::StatusCode::kOutOfRange
if thestart
,stop
, andstrides
values are invalid or specify a slice outside the effective bounds for a given dimension (implicit lower/upper bounds are treated as -/+inf).- Error absl::StatusCode::kInvalidArgument:¶
if integer overflow occurs when computing the resultant transform.