Suppose I'm trying to shift (not bitwise) a tensor of values up by n
and then add NaNs at the bottom to fill the shift offset.
int n = 2;
xt::xtensor_fixed<float, xt::xshape<1, 4>, xt::layout_type::column_major> original = {{ 1., 2., 3., 4. } };
n
{{3., 4. } }auto shiftvalues = xt::view(original, xt::all(), xt::range(n, original.size()));
(?)shiftvalues.appendBottom(std::numeric_limits<double>::quiet_NaN());
(?)shiftvalues.appendBottom(std::numeric_limits<double>::quiet_NaN());
int n = 2;
xt::xtensor_fixed<float, xt::xshape<1, 4>, xt::layout_type::column_major> original = {{ 1., 2., 3., 4. } };
auto shiftvalues = xt::view(original, xt::all(), xt::range(n, original.size()));
How would I go about inserting the NaN values into the tensor following steps 1 and 2? I haven't been able to find any methods in the documentation to append values to the bottom of a tensor.
Or would it be better to create a tensor of the same size as original
, fill it with NaNs, then set the values at appropriate indexes to shiftvalues
?
Thanks
Nevermind figured it out
int n = 2;
xt::xtensor_fixed<float, xt::xshape<1, 4>, xt::layout_type::column_major> original = {{ 1., 2., 3., 4. } };
xt::xtensor<float, 2>::shape_type sh1 = {1, n};
auto offsetfill = xt::full_like(xt::empty<float>(sh1), std::numeric_limits<double>::quiet_NaN());
auto shiftvalues = xt::view(original, xt::all(), xt::range(n, original.size()));
auto result = xt::concatenate(xt::xtuple(shiftvalues, offsetfill), 1);
std::cout << result << std::endl;
{{ 3., 4., nan., nan.}}
Its a bit of a workaround I suppose, there's no appending values in the traditional way.
n