Skip to content

Incorrect cos/sin on arrays with more than 2 elements with ffast-math #1281

@gftabor

Description

@gftabor

Minimal reproducible example. https://github.com/gftabor/xtensor-test


#include <iostream>
#include <xtensor/xarray.hpp>
#include <xtensor/xio.hpp>
#include <xtensor/xview.hpp>

int main(int argc, char* argv[])
{
    xt::xarray<double> array = xt::eval(xt::zeros<double>({2,2}));
    auto res_incorrect = xt::eval(xt::cos(array));
    std::cout << res_incorrect << std::endl;
    xt::xarray<double> small_array = xt::eval(xt::zeros<double>({2}));
    auto res_correct = xt::eval(xt::cos(small_array));
    std::cout << res_correct << std::endl;
    return 0;
}


(mqp) tabor@taborwork:~/Documents/mqp/xtensor-demo/build$ ./xtest 
{{-1., -1.},
 {-1., -1.}}
{ 1.,  1.}

Specifically this is with xtensor 0.25 and xsimd 11.2. It works correctly with xtensor 0.25 xsimd 12.1.1 .

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