Skip to content

xt::variance crashes #2785

Open
Open

Description

@TheMrSheldon

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?

Activity

  1. spectre-ns commented on May 13, 2024

    @spectre-ns
    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}
    
  2. TheMrSheldon commented on May 14, 2024

    @TheMrSheldon
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions