-
#include "tensorstore/index_space/dim_expression.h"
-
template <typename Start, typename Stop, typename Strides = Index>
auto tensorstore::DimExpression<Op...>::ClosedInterval(
const Start& start,
const Stop& stop,
const Strides& strides = 1) const; Extracts a closed interval from the selected dimensions with optional striding.
The domain of each selected dimension is transformed by ExtractClosedStridedSlice 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, theTranslateClosedInterval
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).ClosedInterval({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, 4], [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]
.Note that in the case of a stride component not equal to
1
or-1
, if thestart
component is not evenly divisible by the stride, the transformation involves an additional offset.For example:
Dims(0, 2).ClosedInterval({1, 9}, {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, 4], [2, 5], [-4, -1]
Labels
{"x", "y", "z"}
{"x", "y", "z"}
Equivalent input indices
{2, 3, 7}
{2, 3, -3}
Equivalent input indices
{x, y, z * -2 + 1}
{x, y, z}
where
x
is any index in[1, 4]
,y
is any index in[2, 5]
, andz
is any index in[-4, -1]
.- 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.