Skip to content

xt::mean is very slow than numpy #2680

Description

@OUCyf

Hey,
I have tested some code with xt::mean, and find it very slow than numpy with hundreds of times difference. The data is a 2-d array.

xtensor version

xt::pyarray<double> mean(xt::pyarray<double> &data) 
{
    int samples_num = data.shape(1);
    int channels_num = data.shape(0);

    for(int i=0; i<channels_num; i++)
    {
        auto dd = xt::view(data, i, xt::all());
        auto trend = xt::mean(dd);
        xt::view(data, i, xt::all()) -= trend;
    }

    return data;
}

numpy version

data -= np.mean(data)

Does anybody know what is wrong with my code? I use m1-max, clang++ compiler.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions