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

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

Added original make3d

File size: 2.6 KB
Line 
1% Test code for the svdj function. This function works on real,
2% complex and quaternion matrices, so we need to test it on more
3% than just quaternions.
4
5% Copyright © 2006 Stephen J. Sangwine and Nicolas Le Bihan.
6% See the file : Copyright.m for further details.
7
8T = 1e-10;
9
10% This is quite a long script because of the need to test the
11% function with square, wide and tall arrays, and with 1 or 3
12% output parameters.
13
14% Square array.
15
16display('svdj on real matrices ...')
17display('svdj on square array ...')
18
19A = randn(5,5);
20
21% Normal decomposition.
22
23[U, B, V] = svdj(A);
24compare(U*B*V', A, T,  'svdj failed test 1A')
25
26S = svdj(A);
27compare(S, diag(B), T, 'svdj failed test 1B')
28
29% Wide array.
30
31display('svdj on wide   array ...')
32
33A = randn(5,7);
34
35% Normal decomposition.
36
37[U, B, V] = svdj(A);
38compare(U*B*V', A, T,  'svdj failed test 2A')
39
40S = diag(B);
41compare(svdj(A), S(1:5), T, 'svdj failed test 2B')
42
43% Tall array.
44
45display('svdj on tall   array ...')
46
47A = A.';
48
49% Normal decomposition.
50
51[U, B, V] = svdj(A);
52compare(U*B*V', A, T,  'svdj failed test 3A')
53
54S = diag(B);
55compare(svdj(A), S(1:5), T, 'svdj failed test 3B')
56
57
58% Square array.
59
60display('svdj on complex matrices ...')
61display('svdj on square array ...')
62
63A = complex(randn(5,5),randn(5,5));
64
65% Normal decomposition.
66
67[U, B, V] = svdj(A);
68compare(U*B*V', A, T,  'svdj failed test 1A')
69
70S = svdj(A);
71compare(S, diag(B), T, 'svdj failed test 1B')
72
73% Wide array.
74
75display('svdj on wide   array ...')
76
77A = complex(randn(5,7),randn(5,7));
78
79% Normal decomposition.
80
81[U, B, V] = svdj(A);
82compare(U*B*V', A, T,  'svdj failed test 2A')
83
84S = diag(B);
85compare(svdj(A), S(1:5), T, 'svdj failed test 2B')
86
87% Tall array.
88
89display('svdj on tall   array ...')
90
91A = A.';
92
93% Normal decomposition.
94
95[U, B, V] = svdj(A);
96compare(U*B*V', A, T,  'svdj failed test 3A')
97
98S = diag(B);
99compare(svdj(A), S(1:5), T, 'svdj failed test 3B')
100
101
102% Square array.
103
104display('svdj on quaternion matrices ...')
105display('svdj on square array ...')
106
107A = quaternion(randn(5,5),randn(5,5),randn(5,5),randn(5,5));
108
109% Normal decomposition.
110
111[U, B, V] = svdj(A);
112compare(U*B*V', A, T,  'svdj failed test 1A')
113
114S = svdj(A);
115compare(S, diag(B), T, 'svdj failed test 1B')
116
117% Wide array.
118
119display('svdj on wide   array ...')
120
121A = quaternion(randn(5,7),randn(5,7),randn(5,7),randn(5,7));
122
123% Normal decomposition.
124
125[U, B, V] = svdj(A);
126compare(U*B*V', A, T,  'svdj failed test 2A')
127
128S = diag(B);
129compare(svdj(A), S(1:5), T, 'svdj failed test 2B')
130
131% Tall array.
132
133display('svdj on tall   array ...')
134
135A = A.';
136
137% Normal decomposition.
138
139[U, B, V] = svdj(A);
140compare(U*B*V', A, T,  'svdj failed test 3A')
141
142S = diag(B);
143compare(svdj(A), S(1:5), T, 'svdj failed test 3B')
144
145clear A U B V S
Note: See TracBrowser for help on using the repository browser.