Prev: Really need help to speed up piece of code
Next: Looking for an efficient way to find whether a path intersects with a volume
From: us on 4 Aug 2010 13:37 "David Romero-Antequera" <dromero_fisica(a)yahoo.es> wrote in message <i3c7i1$adm$1(a)fred.mathworks.com>... > Hello, everyone. > > I need some suggestion to make the following function faster. > > function psi=NLF(z,y,funvector,orig_size) > psi=zeros(size(y)); > Y=ifft2(reshape(y,orig_size)); > for fun=funvector > fY=feval(fun{2},z,Y); > kY=fun{1}.*fft2(fY); > kY=kY(:); > psi=psi+kY; > end > end > > where z is a double scalar, y is a complex matrix, funvector is a cell array with double scalars in the first column and function handles in the second, and orig_size is a 2x1 matrix. > > As you can see, I need to compute the inverse Fourier transform of the vector Y, then evaluate it into several user-provided functions and compute the Fourier transform and add all of that together. This is part of an ODE, so you might expect that this is going to be evaluated THOUSANDS of times, and every second counts. > > Any suggestions? > Thanks in advance. just minor thoughts... % from psi=zeros(size(y)); % to psi=zeros(size(y),'double'); % from fY=feval(fun{2},z,Y); % to fY=fun{2}(z,Y); us |