xtensor
xtensor copied to clipboard
xt::variance crashes
Hello everyone. Thank you very much for your awesome project!
I am currently trying to compute the variance over some tensors but if I supply an axis to calculate the variance for, the program crashes. The following code reproduces this issue:
#include <iostream>
#include <xtensor/xarray.hpp>
#include <xtensor/xio.hpp>
#include <xtensor/xview.hpp>
int main(void) {
xt::xarray<float> arr = {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f}, {7.0f, 8.0f, 9.0f}};
std::cout << xt::variance(arr, {0}) << std::endl;
// terminate called after throwing an instance of 'std::bad_array_new_length'
// what(): std::bad_array_new_length
std::cout << xt::variance(arr, {1}) << std::endl;
// terminate called after throwing an instance of 'std::bad_array_new_length'
// what(): std::bad_array_new_length
}
Am I missing something?
What compiler are you using? I get the following output when using MSVC 2022 and Intel 2024
{ 6., 6., 6.}
{ 0.666667, 0.666667, 0.666667}
I am using g++13 within an Ubuntu 24.04 Docker image on an Intel CPU from around 2015 to 2016