Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Out of memory when I am doing 3D FFT
Date: Sat, 10 Jan 2009 08:06:03 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 29
Message-ID: <gk9ktb$63p$1@fred.mathworks.com>
References: <gk7vku$naj$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1231574763 6265 172.30.248.38 (10 Jan 2009 08:06:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 10 Jan 2009 08:06:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:510750


"David " <david2008.w@gmail.com> wrote in message <gk7vku$naj$1@fred.mathworks.com>...

> 
> FFT1=fftn(double(Vol));
> FFT2=fftn(double(smoothcell));
> CPXARR2=FFT1.*conj(FFT2);
> MFout=fftshift(ifftn(CPXARR2));
> 

Few tips:
- use SINGLE instead of DOUBLE
- Inplace fft by slice:

  FFT1=zeros(size(Vol),class(Vol));
  for k=1:size(Vol,3)
     FFT1(:,:,k)=fftn(Vol(:,:,k));
  end
  for i=1:size(Vol,1)
     for j=1:size(Vol,2)
        FFT1(i,j,:)=fft(squeeze(Vol(i,j,:)));
     end
  end
  
  % Same for FFT2

- Clear intermediate variables or reuse the same variables at different steps
- As someone has pointed out: because the kernel is tensorial of 1d kernels, Do the convolution in 1D separately.

Bruno