I am trying to increase the speed of code that works with large datasets. I need to execute the function out = sinc(x) , where x is the double matrix of 2048 by 37499. This is very expensive and is the bottleneck of my program (even when calculating on a GPU).
I am looking for any solution that improves the speed of this operation. I expect this to be achieved by precomputing the vector LookUp = sinc(y) , where y is the vector y = min(min(x)):dy:max(max(x)) , i.e. A vector covering the entire range of expected elements x .
How can I efficiently generate an approximation of sinc(x) from this LookUp vector?
I need to avoid creating a three-dimensional array, as this will consume more memory than I have.
Here is a test to solve interp1:
a = -15; b = 15; rands = (ba).*rand(1024,37499) + a; sincx = -15:0.000005:15; sincy = sinc(sincx); tic res1 = interp1(sincx,sincy,rands); toc tic res2 = sinc(rands); toc' sincx = gpuArray(sincx); sincy = gpuArray(sincy); r = gpuArray(rands); tic r = interp1(sincx,sincy,r); toc r = gpuArray(rands); tic r = sinc(r); toc
Elapsed time - 0.426091 seconds.
The elapsed time is 0.472551 seconds.
The elapsed time is 0.004311 seconds.
The elapsed time is 0.130904 seconds.
Corresponds to CPU interp1, CPU sinc, GPU interp1, GPU sinc respectively
source share