• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

MakefileH A D24-Mar-2003177 94

READMEH A D24-Mar-20033.6 KiB8966

fftw.cH A D24-Mar-200310.4 KiB375228

fftw.mH A D24-Mar-20031 KiB2726

README

1			   FFTW for MATLAB
2			 http://www.fftw.org
3
4This directory contains files that allow you to call FFTW from MATLAB
5(instead of MATLAB's own FFT functions).  This is accomplished by
6means of a "MEX" program--a MATLAB external function--that wraps
7around the FFTW library.
8
9NOTE: you must have MATLAB 5.0 or later to use these routines.
10
11Once you have compiled and installed the MEX (see below), using FFTW
12from within MATLAB is simple:
13
14The forward transform:
15	b = fftw(a,-1)
16
17The backwards transform:
18	c = fftw(b,+1)
19
20Note that FFTW computes the unnormalized DFT, so "c" in the above code
21is a scaled version of the original "a".  (To get back the original
22"a", you would compute: c / prod(size(c)).)
23
24To get help on using FFTW in MATLAB, simply type "help fftw" at the
25MATLAB prompt.
26
27There are a few points that you should be aware of:
28
29* The first call is expensive:
30
31The first time you call FFTW from within MATLAB, it performs
32expensive one-time computations.  (It is figuring out a "plan"--see
33the FFTW manual for more information on what is happening.)  So, the
34first FFT you compute is slow (it probably takes several seconds).
35However, subsequent transforms of the same size will reuse the initial
36computations, and will be quite fast (often 2-3 times as fast as
37MATLAB's built-in FFT).  So, you should use FFTW within MATLAB when
38you are computing many FFTs of the same size and the initial cost is
39unimportant.  If you just need a single FFT, use MATLAB's built-in
40routines.
41
42To reduce the startup cost, at some slight penalty in performance,
43replace FFTW_MEASURE in fftw.c with FFTW_ESTIMATE.
44
45* Small transforms are inefficient:
46
47There is a certain amount of overhead involved in calling FFTW from
48MATLAB, and this makes small transforms relatively inefficient.  So,
49if you are doing very small transforms in MATLAB, you might be better
50off with the built-in routines.  (The exact point at which FFTW begins
51to win will depend upon your machine.  It is simple for you to use
52MATLAB's timing routines to find out what is best in your
53application.)
54
55(One of the major costs is in translating the array from MATLAB's
56representation, in which real and imaginary parts are stored
57separately, to FFTW's representation, in which complex numbers are
58stored as adjacent real/imaginary pairs.)
59
60* FFTW computes multi-dimensional transforms:
61
62The FFTW call in MATLAB computes a transform of the same
63dimensionality as the matrix that you give it.  Thus, it is analogous
64to the "fftn" routine in MATLAB, rather than the "fft" routine.
65
66* All transforms are out-of-place:
67
68Although the FFTW library is capable of performing in-place
69multi-dimensional transforms, the MATLAB routine is out-of-place.
70This is simply a restriction of the environment--as far as we can
71tell, we are not allowed to modify the inputs that are passed to us,
72and must return our results in a separate array.
73
74**********************************************************************
75
76			     Installation
77
78Installation of the FFTW MEX routines is straightforward.  First, you
79have to compile the FFTW library (see the FFTW manual).  Then, you must
80compile the file fftw.c in this directory using the MEX compilation
81procedure on your machine.  Finally, you take the MEX file that is
82produced, along with the fftw.m file in this directory, and install
83them wherever you typically put your MATLAB scripts.
84
85The method for compiling MEX files should be described in your MATLAB
86manual.  (You will need to link with the FFTW library that you had
87compiled earlier.)  On UNIX systems, you can simply type "make", and
88the Makefile in this directory should do the right thing.
89