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

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

Added original make3d

File size: 2.0 KB
Line 
1% Test code for the discrete quaternion Fourier transform.
2% This code tests the following functions:
3%
4%  qdft  qdft2
5% iqdft iqdft2
6%
7% It also verifies indirectly many of the basic quaternion operations
8% since the qdft depends on them.
9
10% Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan.
11% See the file : Copyright.m for further details.
12
13% Since the two-dimensional qdft code calls the one-dimensional
14% code, we need only to test the two dimensionsal code in what
15% follows.
16
17% Define one real and one complex quaternion array.
18
19q = quaternion(randn(10,10), randn(10,10), randn(10,10), randn(10,10));
20b = quaternion(complex(randn(10,10)),complex(randn(10,10)),...
21               complex(randn(10,10)),complex(randn(10,10)));
22T = 1e-12;
23
24RA =        unit(quaternion(1,1,1));  % Real axis.
25CA = complex(RA, quaternion(1,0,-1)); % Complex axis.
26
27if  isreal(CA) error('Complex axis is not complex.'); end
28if ~isreal(RA) error('Real axis is complex.'); end
29
30% Test 1. Verify correct transform and inverse for a real quaternion
31% array with a real quaternion axis.
32
33compare(q, iqdft2(qdft2(q, RA, 'L'), RA, 'L'), T, 'qdft failed test 1L.');
34compare(q, iqdft2(qdft2(q, RA, 'R'), RA, 'R'), T, 'qdft failed test 1R.');
35
36% Test 2. Verify correct transform and inverse for a real quaternion
37% array with a complex axis.
38
39compare(q, iqdft2(qdft2(q, CA, 'L'), CA, 'L'), T, 'qdft failed test 2L.');
40compare(q, iqdft2(qdft2(q, CA, 'R'), CA, 'R'), T, 'qdft failed test 2R.');
41
42% Test 3. Verify correct transform and inverse for a complex quaternion
43% array with a complex axis.
44
45compare(b, iqdft2(qdft2(b, CA, 'L'), CA, 'L'), T, 'qdft failed test 3L.');
46compare(b, iqdft2(qdft2(b, CA, 'R'), CA, 'R'), T, 'qdft failed test 3R.');
47
48% Test 4. Verify correct transform and inverse for a complex quaternion
49% array with a real axis.
50
51compare(b, iqdft2(qdft2(b, RA, 'L'), RA, 'L'), T, 'qdft failed test 4L.');
52compare(b, iqdft2(qdft2(b, RA, 'R'), RA, 'R'), T, 'qdft failed test 4R.');
53
54clear q b T RA CA
Note: See TracBrowser for help on using the repository browser.