~ubuntu-branches/ubuntu/hardy/suitesparse/hardy

« back to all changes in this revision

Viewing changes to CCOLAMD/MATLAB/ccolamd_test.m

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere, Rafael Laboissiere, Ondrej Certik
  • Date: 2008-02-21 14:46:50 UTC
  • mfrom: (1.1.2 upstream) (5.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080221144650-tgeppgj0t7s759i8
Tags: 3.1.0-3
[ Rafael Laboissiere ]
* Upload to unstable

[ Ondrej Certik ]
* XS-DM-Upload-Allowed: yes field added
* Ondrej Certik added to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
ccolamd_default_knobs = [0 10 10 1 0] ;
16
16
csymamd_default_knobs = [10 1 0] ;
17
17
 
18
 
s = input (...
19
 
'Compile ccolamd, csymand, and the test codes? (y/n, default is yes): ', 's') ;
20
 
 
21
 
do_compile = 1 ;
22
 
if (~isempty (s))
23
 
    if (s (1) == 'n' | s (1) == 'N')                                        %#ok
24
 
        do_compile = 0 ;
25
 
    end
26
 
end
27
 
 
28
 
if (do_compile)
29
18
    fprintf ('Compiling ccolamd, csymamd, and test mexFunctions.\n') ;
30
19
    ccolamd_make ;
31
20
 
39
28
    eval ([cmd 'csymamdtestmex.c ' src]) ;
40
29
    fprintf ('Done compiling.\n') ; 
41
30
 
42
 
end
43
31
 
44
32
fprintf ('\nThe following codes will be tested:\n') ;
45
33
which ccolamd 
49
37
 
50
38
fprintf ('\nStarting the tests.  Please be patient.\n') ;
51
39
 
 
40
h = waitbar (0, 'COLAMD test') ;
 
41
 
52
42
rand ('state', 0) ;
53
43
randn ('state', 0) ;
54
44
 
88
78
fprintf ('Matrices with a few dense row/cols\n') ;
89
79
for trial = 1:20
90
80
 
 
81
    waitbar (trial/20, h, 'CCOLAMD: dense rows/cols') ;
 
82
 
91
83
    % random square unsymmetric matrix
92
84
    A = rand_matrix (1000, 1000, 1, 10, 20) ;
93
85
    [m n] = size (A) ;
135
127
        p = ccolamd (A, [0 tol -1 1], [ ]) ;   check_perm (p, A) ;
136
128
        p = ccolamd (A, [0 -1 tol 1], [ ]) ;   check_perm (p, A) ;
137
129
 
138
 
        fprintf ('.') ;
139
 
 
140
130
    end
141
131
end
142
132
fprintf (' OK\n') ;
144
134
fprintf ('General matrices\n') ;
145
135
for trial = 1:400
146
136
 
 
137
    waitbar (trial/400, h, 'CCOLAMD: with dense rows/cols') ;
 
138
 
147
139
    % matrix of random mtype
148
140
    mtype = irand (3) ;
149
141
    A = rand_matrix (2000, 2000, mtype, 0, 0) ;
155
147
        check_perm (p, A) ;
156
148
    end
157
149
 
158
 
    fprintf ('.') ;
159
150
end
160
151
fprintf (' OK\n') ;
161
152
 
166
157
% Check different erroneous input.
167
158
for trial = 1:30
168
159
 
 
160
    waitbar (trial/30, h, 'CCOLAMD: error handling') ;
 
161
 
169
162
    A = rand_matrix (1000, 1000, 2, 0, 0) ;
170
163
 
171
164
    for err = 1:13
201
194
            end
202
195
        end
203
196
 
204
 
        fprintf ('.') ;
205
197
    end
206
198
 
207
199
end
211
203
 
212
204
for trial = 1:400
213
205
 
 
206
    waitbar (trial/400, h, 'CCOLAMD: with empty rows/cols') ;
 
207
 
214
208
    % some are square, some are rectangular
215
209
    n = 0 ;
216
210
    while (n < 5)
233
227
        error ('ccolamd: Null cols are not ordered last in natural order') ;
234
228
    end
235
229
 
236
 
    fprintf ('.') ;
237
 
 
238
230
end
239
231
fprintf (' OK\n') ;
240
232
 
242
234
 
243
235
for trial = 1:400
244
236
 
 
237
    waitbar (trial/400, h, 'CCOLAMD: with empty rows/cols') ;
 
238
 
245
239
    % symmetric matrices
246
240
    n = 0 ;
247
241
    while (n < 5)
267
261
        error ('csymamd: Null cols are not ordered last in natural order') ;
268
262
    end
269
263
 
270
 
    fprintf ('.') ;
271
 
 
272
264
end
273
265
fprintf (' OK\n') ;
274
266
 
278
270
 
279
271
for trial = 1:400
280
272
 
 
273
    waitbar (trial/400, h, 'CCOLAMD: with null rows') ;
281
274
    m = 0 ;
282
275
    while (m < 5)
283
276
        A = rand_matrix (1000, 1000, 2, 0, 0) ;
291
284
 
292
285
    p = ccolamd (A) ;
293
286
    check_perm (p, A) ;
294
 
    fprintf ('.') ;
 
287
 
295
288
end
296
289
fprintf (' OK\n') ;
297
290
 
298
291
fprintf ('\nccolamd and csymamd:  all tests passed\n\n') ;
 
292
close (h) ;
299
293
 
300
294
%-------------------------------------------------------------------------------
301
295