arrayfun can be significantly slower than an explicit loop in matlab. Why?

前端 未结 2 1998
后悔当初
后悔当初 2020-11-22 03:35

Consider the following simple speed test for arrayfun:

T = 4000;
N = 500;
x = randn(T, N);
Func1 = @(a) (3*a^2 + 2*a - 1);

tic
Soln1 = ones(T,          


        
2条回答
  •  孤街浪徒
    2020-11-22 04:28

    That because!!!!

    x = randn(T, N); 
    

    is not gpuarray type;

    All you need to do is

    x = randn(T, N,'gpuArray');
    

提交回复
热议问题