-
#include "tensorstore/index_space/dim_expression.h" -
template <typename Origins>
auto tensorstore::DimExpression<Op...>::TranslateTo(
const Origins& origins) const; Translates the domain of the selected input dimensions to the specified origin vector without affecting the output range.
Given an
existingtransform with input rankmand the selecteddimsvector, the new index transform maps aninputvector of sizemto:existing(input - full_offsets)where
full_offsetsis a vector of sizemwithfull_offsets[i] = origins[j] - existing.input_origin(i)ifdims[j] = i, andfull_offsets[i] = 0ifiis not indims. As a special case, an origin ofkImplicitspecifies no translation of the corresponding dimension.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 extent of the
originsvector.For example:
Dims(0, 2).TranslateTo({10, 20})has the following effects:Before
After
Dimension selection
{0, 2}{0, 2}Input domain
[1, 3], [2, 5], [3, 4][10, 12], [2, 5], [20, 21]Labels
{"x", "y", "z"}{"x", "y", "z"}Equivalent input indices
{2, 3, 3}{11, 3, 20}Equivalent input indices
{x, y, z}{x + 9, y, z + 17}where
xis any index in[1, 3],yis any index in[2, 5], andzis any index in[3, 4].- Requires:¶
Originssatisfies the IsIndexVectorOrScalar concept with a static extent compatible with the static rank of the dimension selection.- Parameters:¶
- const Origins &origins¶
The origin vector to which to shift the input domains of the selected dimensions. May be a braced list, e.g.
TranslateTo({1, 2, 3}). May also be a scalar, e.g.TranslateTo(5), in which case the same origin is used for all selected dimensions.
- Error absl::StatusCode::kInvalidArgument:¶
if the extent of the
originsvector is not equal to the number of selected dimensions.- Error absl::StatusCode::kInvalidArgument:¶
if the input domain of any selected dimension has an
IndexInterval::inclusive_minvalue of-kInfIndex.- Error absl::StatusCode::kOutOfRange:¶
if any origin value is outside
[kMinFiniteIndex, kMaxFiniteIndex].- Error absl::StatusCode::kInvalidArgument:¶
if a shifted interval is outside the valid range.