Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
Matt J
Posts:
4,978
Registered:
11/28/09
|
|
Re: Computation efficiency: convolution or direct calculation
Posted:
Dec 5, 2012 6:52 PM
|
|
"Luca " <l.presottoRE@MOVE.campus.unimib.NOTit> wrote in message <k9ngvn$c9h$1@newscl01ah.mathworks.com>... > > It turns out using tic and toc that the ugly method using the for loops takes 5 ms while the convolution using conv take 220 ms. > How's that??? > (ok... maybe with the convolution I could go to much wider "time" frames to reduce the dimension of about 10-100 and become as fast or faster...) > > And... which method shall I be using? ===========
It seems pretty clear why implementing as a filter as opposed to a convolution is faster. The filtering operation is very sparse whereas conv(R,S) is very non-sparse. If R and/or S happen to be sparse, you might be able to exploit the sparsity by doing sparse convolution, e.g., using
http://www.mathworks.com/matlabcentral/fileexchange/29832-n-dimensional-sparse-arrays
Otherwise, the filter seems to be the thing to use. You might be able to accelerate the filter implementation somewhat, as compared to the for-loop, using the FILTER command.
|
|
|
|