Prev: Fortran Ex. (Outputs 2 vectors to Matlab) with Mex file
Next: Seasonal adjustment in ML (Census X-12)
From: David Romero-Antequera on 4 Aug 2010 14:50 "Andy " <myfakeemailaddress(a)gmail.com> wrote in message <i3c9jl$2c7$1(a)fred.mathworks.com>... > > % from > > psi=zeros(size(y)); > > % to > > psi=zeros(size(y),'double'); > > % Slightly faster: > > m = 50000; > n = 5000; > tic > a=zeros(m,n); > timea = toc > clear a > > tic > b=zeros([m,n],'double'); > timeb = toc > clear b > > tic > c(m,n) = 0; > timec = toc > > % displays: > timea = > 0.873374775 > timeb = > 9.3843e-005 > timec = > 4.9347e-005 This helped a little. Thanks!
From: David Romero-Antequera on 4 Aug 2010 14:52 Walter Roberson <roberson(a)hushmail.com> wrote in message <i3cce8$cbf$2(a)canopus.cc.umanitoba.ca>... > David Romero-Antequera wrote: > > > That's something that it is not in my hands. On the other hand, the user > > provided function, can be something that can't be optimized anymore, like > > > > @(t,f) abs(f).^2; > > > > I just want to make sure that there's nothing else that I can do. > > Would f be real or complex? If it would be real, then > > @(t,f) f.^2 > > would be more efficient. > > > Profile first, _then_ worry. Probably that is something that I did not mention. Y is a complex valued function. Even if it is not, I do some Fourier transforms to it, so there is always some complex components around.
From: David Romero-Antequera on 4 Aug 2010 16:02
Walter Roberson <roberson(a)hushmail.com> wrote in message <i3cce8$cbf$2(a)canopus.cc.umanitoba.ca>... > David Romero-Antequera wrote: > > > That's something that it is not in my hands. On the other hand, the user > > provided function, can be something that can't be optimized anymore, like > > > > @(t,f) abs(f).^2; > > > > I just want to make sure that there's nothing else that I can do. > > Would f be real or complex? If it would be real, then > > @(t,f) f.^2 > > would be more efficient. > > > Profile first, _then_ worry. Thanks for the suggestion (actually, double suggestion) of profile. Here are a piece of the results: SpectralBPM>NLF 139 4.905 s 0.850 s ifft2 140 1.979 s 1.979 s fft2 140 1.586 s 1.586 s @(t,f)V.*f 139 0.584 s 0.584 s Most of the time is spent in computing the fft2 and ifft2. So I guess there is not much that I can do here :( On the other hand, there's another part where I compute something like: exp(1i*t*M); where t is an scalar and M, in the worst case, is a complex matrix (relatively big). So, is there any way to speed this computing? Can I compute the value of the matrix faster based on some previous state? (because t will vary monotonically). Thanks, again |