-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathluimc_drv1.m
148 lines (112 loc) · 4.48 KB
/
luimc_drv1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
function luimc_drv1
% inital print statements
fprintf('\n... luimc tests ...\n');
% settings
n = 10; % number of rows
m1 = 5; % number of columns less than number of rows
m2 = 15; % number of columns great than number of rows
d = .2; % sparse matrix density
% set the rng stream
RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));
% test empty matrix
[test_flag rel_err] = luimc_test([]);
fprintf('empty matrix test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% column vector
A = rand(n,1);
[test_flag rel_err] = luimc_test(A);
fprintf('column vector test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% row vector
A = rand(1,m2);
[test_flag rel_err] = luimc_test(A);
fprintf('row vector test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% square matrix tests
A = rand(n,n);
opt = luimc('options');
opt.pivot = 'partial';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('square partial test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'complete';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('square complete test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'rook';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('square rook test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'none';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('square none test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% test pivot output
opt.pivot = 'complete';
opt.perm = 'sparse';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('sparse perm test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.perm = 'dense';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('dense perm test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% skinny matrix tests
A = rand(n,m1);
opt = luimc('options');
opt.pivot = 'partial';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('skinny partial test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'complete';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('skinny complete test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'rook';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('skinny rook test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'none';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('skinny none test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% fat matrix tests
A = rand(n,m2);
opt = luimc('options');
opt.pivot = 'partial';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('fat partial test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'complete';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('fat complete test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'rook';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('fat rook test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'none';
[test_flag rel_err] = luimc_test(A,opt);
fprintf('fat none test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% all zero matrix
opt.pivot = 'partial';
[test_flag rel_err] = luimc_test(zeros(n,n),opt);
fprintf('zeros partial test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'complete';
[test_flag rel_err] = luimc_test(zeros(n,n),opt);
fprintf('zeros complete test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'rook';
[test_flag rel_err] = luimc_test(zeros(n,n),opt);
fprintf('zeros rook test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% all ones matrix
opt.pivot = 'partial';
[test_flag rel_err] = luimc_test(ones(n,n),opt);
fprintf('ones partial test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'complete';
[test_flag rel_err] = luimc_test(ones(n,n),opt);
fprintf('ones complete test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'rook';
[test_flag rel_err] = luimc_test(ones(n,n),opt);
fprintf('ones rook test: %s, rel_err: %g\n',pf(test_flag),rel_err);
% sparse matrix
opt.pivot = 'partial';
[test_flag rel_err] = luimc_test(sprand(n,n,d),opt);
fprintf('sprand partial test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'complete';
[test_flag rel_err] = luimc_test(sprand(n,n,d),opt);
fprintf('sprand complete test: %s, rel_err: %g\n',pf(test_flag),rel_err);
opt.pivot = 'rook';
[test_flag rel_err] = luimc_test(sprand(n,n,d),opt);
fprintf('sprand rook test: %s, rel_err: %g\n',pf(test_flag),rel_err);
end
function pfstr = pf(x)
if x
pfstr = 'passed';
else
pfstr = 'FAILED';
end
end