-
#include "tensorstore/index_space/dim_expression.h" -
template <typename Offsets>
auto tensorstore::DimExpression<Op...>::TranslateBy(
const Offsets& offsets) const; Translates (shifts) the domains of the selected input dimensions by the specified
offsetsvector; the output range remains the same.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] = offsets[j]ifdims[j] == i, andfull_offsets[i] = 0ifiis not indims. An offset ofkImplicitis treated as0.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
offsetsvector.The input domain for each selected dimension is shifted by calling ShiftInterval.
For example:
Dims(0, 2).TranslateBy({10, 20})has the following effects:Before
After
Dimension selection
{0, 2}{0, 2}Input domain
[1, 3], [2, 5], [3, 4][11, 13], [2, 5], [23, 24]Labels
{"x", "y", "z"}{"x", "y", "z"}Equivalent input indices
{2, 3, 3}{12, 3, 23}Equivalent input indices
{x, y, z}{x + 10, y, z + 20}where
xis any index in[1, 3],yis any index in[2, 5], andzis any index in[3, 4].- Requires:¶
Offsetssatisfies theIsIndexVectorOrScalarconcept with a static extent compatible with the static rank of the dimension selection.- Parameters:¶
- const Offsets &offsets¶
The offset vector by which to shift the input domains of the selected dimensions. May be a braced list, e.g.
TranslateBy({1, 2, 3}). May also be a scalar, e.g.TranslateBy(5), in which case the same offset is used for all selected dimensions.
- Error absl::StatusCode::kInvalidArgument:¶
if the extent of the
offsetsvector is not equal to the number of selected dimensions.- Error absl::StatusCode::kOutOfRange:¶
if the shift offset is outside
[kMinFiniteIndex, kMaxFiniteIndex].- Error absl::StatusCode::kInvalidArgument:¶
if a shifted interval is outside the valid range.