xtensor
xtensor copied to clipboard
C++ 20 Ubuntu axis_slice_iterator bad alloc exception
The following code compiled with GCC 11.3 using C++20 throws on the following code snippet
xt::xarray<double> savgol_filter(xt::xarray<double> x, size_t window_length, size_t polyorder, std::ptrdiff_t axis = -1)
{
xt::xarray<double> out = xt::empty_like(x);
auto saxis = xt::normalize_axis(x.dimension(), axis);
auto begin = xt::axis_slice_begin(x, saxis);
auto end = xt::axis_slice_end(x, saxis);
auto iter_out = xt::axis_slice_begin(out, saxis);
SavGolTransform filter(x.shape(saxis), window_length, polyorder);
std::vector<xt::xarray<double>> res;
for (auto iter = begin; iter != end; iter++)
{
*iter_out = filter.Transform(*iter);
}
return out;
}
The same code runs in windows and macos in CI. Oddly only fails in Ubuntu. The following line appears to be the culprit:
*iter_out = filter.Transform(*iter);
I'm trying to apply a function along a particular axis and hopefully this is not a dumb way to do it.