Skip to content

xt::mean is very slow than numpy #2680

Open
@OUCyf

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.

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