~ubuntu-branches/ubuntu/trusty/fftw/trusty

« back to all changes in this revision

Viewing changes to matlab/README

  • Committer: Bazaar Package Importer
  • Author(s): James A. Treacy
  • Date: 2002-03-05 00:28:49 UTC
  • Revision ID: james.westby@ubuntu.com-20020305002849-q0grqhlbeugn4y5j
Tags: upstream-2.1.3
ImportĀ upstreamĀ versionĀ 2.1.3

Show diffs side-by-side

added added

removed removed

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