source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/qtfm/test/test_fft.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.7 KB
Line 
1% Test code for the fast quaternion Fourier transform.
2% This code tests the following functions:
3%
4%  fft  fft2
5% ifft ifft2
6
7% Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan.
8% See the file : Copyright.m for further details.
9
10% We have to test the 1D and 2D functions separately because they do not
11% call each other. In addition, we need to verify the results of the FFTs
12% against the DFT code in the corresponding qdft functions.
13
14% Test 1. Real data, and therefore real axis, 1D and 2D.
15% Check that the transform inverts correctly and then that it agrees with
16% the DFT code.
17
18T = 1e-12;
19
20q = quaternion(randn(10,10), randn(10,10), randn(10,10), randn(10,10));
21
22RA = unit(quaternion(1,1,1)); % Real axis.
23
24compare(q,  ifft(fft(q)),            T, 'fft/ifft failed test 1.');
25compare(q, iqdft(fft(q), RA, 'L'),   T, 'fft/iqdft failed test 1.');
26compare(q, ifft2(fft2(q)),           T, 'fft2/ifft2 failed test 1.');
27compare(q, iqdft2(fft2(q), RA, 'L'), T, 'fft2/iqfft2 failed test 1.');
28
29clear q RA
30
31% Test 2. Complex data, and therefore complex axis, 1D and 2D.
32% Check that the transform inverts correctly and then that it agrees with
33% the DFT code.
34
35b = quaternion(complex(randn(10,10),randn(10,10)),...
36               complex(randn(10,10),randn(10,10)),...
37               complex(randn(10,10),randn(10,10)),...
38               complex(randn(10,10),randn(10,10)));
39
40CA = quaternion(1,1,1) + quaternion(0,1,-1).*i; % Complex axis.
41
42compare(b, ifft(fft(b)),             T, 'fft/ifft failed test 2.');
43compare(b, iqdft(fft(b), CA, 'L'),   T, 'fft/iqdft failed test 2.');
44compare(b, ifft2(fft2(b)),           T, 'fft2/ifft2 failed test 2.');
45compare(b, iqdft2(fft2(b), CA, 'L'), T, 'fft2/iqfft2 failed test 2.');
46
47clear CA b T
Note: See TracBrowser for help on using the repository browser.