Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xt::variance crashes #2785

Open
TheMrSheldon opened this issue May 13, 2024 · 2 comments
Open

xt::variance crashes #2785

TheMrSheldon opened this issue May 13, 2024 · 2 comments

Comments

@TheMrSheldon
Copy link

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?

@spectre-ns
Copy link
Contributor

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}

@TheMrSheldon
Copy link
Author

I am using g++13 within an Ubuntu 24.04 Docker image on an Intel CPU from around 2015 to 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants