~ubuntu-branches/ubuntu/natty/suitesparse/natty

« back to all changes in this revision

Viewing changes to CHOLMOD/MATLAB/Test/cholmod_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:
1
 
function cholmod_test (nmat)
 
1
function cholmod_test (nmat, do_diary)
2
2
%CHOLMOD_TEST test the CHOLMOD mexFunctions
3
3
%
4
4
% Example:
5
 
% cholmod_test(nmat)
 
5
% cholmod_test(nmat,do_diary)
6
6
%
7
7
% The UFget interface to the UF sparse matrix collection is required.
8
8
%
10
10
%   tests 0, 8, 10, 11, 12, and 12.  tests 14 and 15 use 2*nmat matrices.
11
11
%   default nmat is 50.
12
12
%
 
13
% do_diary: 1 to save results in a diary, 0 otherwise.  Default 0.
 
14
%
13
15
% cholmod_demo: run tests on a few random matrices
14
16
% graph_demo: graph partitioning demo
15
17
% test0:  test most CHOLMOD functions
48
50
 
49
51
% Copyright 2006-2007, Timothy A. Davis, University of Florida
50
52
 
51
 
diary off
52
 
s = date ;
53
 
t = clock ;
54
 
s = sprintf ('diary cholmod_test_%s_%d-%d-%d.txt\n', s, t (4), t(5), fix(t(6)));
55
 
eval (s) ;
56
 
fprintf ('Running CHOLMOD tests.\n%s\n', s) ;
57
 
 
 
53
if (nargin < 2)
 
54
    do_diary = 0 ;
 
55
end
 
56
 
 
57
if (do_diary)
 
58
    diary off
 
59
    s = date ;
 
60
    t = clock ;
 
61
    s = sprintf ('diary cholmod_test_%s_%d-%d-%d.txt\n', s, t (4), t(5), fix(t(6)));
 
62
    eval (s) ;
 
63
end
 
64
 
 
65
fprintf ('Running CHOLMOD tests.\n') ;
58
66
help cholmod_test
59
67
 
60
68
test_path = pwd ;
84
92
fprintf ('%s\n', ccolamd_path) ;
85
93
fprintf ('%s\n', camd_path) ;
86
94
 
87
 
input ('\n\n--------- Hit enter to contine: ') ;
88
 
 
89
95
if (nargin < 1)
90
96
    nmat = 50 ;
91
97
end
92
98
 
93
 
do_metis = (nargin < 2) ;
94
 
 
95
 
cholmod_demo
96
 
graph_demo
97
 
test0 (nmat)
98
 
test1
99
 
test2
100
 
test3
101
 
test4
102
 
test5
103
 
test6
104
 
test7
105
 
 
106
 
if (do_metis)
107
 
    % these tests require METIS
108
 
    test8 (nmat)
109
 
    test9
 
99
try
 
100
    s = metis (sparse (1)) ;
 
101
    do_metis = 1 ;
 
102
catch
 
103
    fprintf ('METIS not installed\n') ;
 
104
    do_metis = 0 ;
110
105
end
111
106
 
112
 
test10 (nmat)
113
 
test11 (nmat)
114
 
test12 (nmat)
115
 
test13
116
 
 
117
 
if (do_metis)
 
107
h = waitbar (0.5/32, 'CHOLMOD demo:') ;
 
108
 
 
109
try
 
110
 
 
111
    cholmod_demo                    ; waitbar ( 1/32, h, 'CHOLMOD graph demo');
 
112
    if (do_metis)
 
113
        graph_demo ;
 
114
    end
 
115
    waitbar ( 2/32, h, 'CHOLMOD test0') ;
 
116
    test0 (nmat)                    ; waitbar ( 3/32, h, 'CHOLMOD test1') ;
 
117
    test1                           ; waitbar ( 4/32, h, 'CHOLMOD test2') ;
 
118
    test2                           ; waitbar ( 5/32, h, 'CHOLMOD test3') ;
 
119
    test3                           ; waitbar ( 6/32, h, 'CHOLMOD test4') ;
 
120
    test4                           ; waitbar ( 7/32, h, 'CHOLMOD test5') ;
 
121
    test5                           ; waitbar ( 8/32, h, 'CHOLMOD test6') ;
 
122
    test6                           ; waitbar ( 9/32, h, 'CHOLMOD test7') ;
 
123
    test7                           ; waitbar (10/32, h, 'CHOLMOD test8') ;
 
124
 
 
125
    if (do_metis)
 
126
        % these tests require METIS
 
127
        test8 (nmat)                ; waitbar (11/32, h, 'CHOLMOD test9') ;
 
128
        test9 ;
 
129
    end
 
130
 
 
131
    waitbar (12/32, h, 'CHOLMOD test10') ;
 
132
    test10 (nmat)                   ; waitbar (13/32, h, 'CHOLMOD test11') ;
 
133
    test11 (nmat)                   ; waitbar (14/32, h, 'CHOLMOD test12') ;
 
134
    test12 (nmat)                   ; waitbar (15/32, h, 'CHOLMOD test13') ;
 
135
    test13                          ; waitbar (16/32, h, 'CHOLMOD test14') ;
 
136
 
 
137
    if (do_metis)
 
138
        % this test requires METIS
 
139
        test14 (2*nmat) ;
 
140
    end
 
141
 
 
142
    waitbar (17/32, h, 'CHOLMOD test15') ;
 
143
    test15 (2*nmat)                 ; waitbar (18/32, h, 'CHOLMOD test16') ;
 
144
    test16                          ; waitbar (19/32, h, 'CHOLMOD test17') ;
 
145
    test17                          ; waitbar (20/32, h, 'CHOLMOD test18') ;
 
146
    test18                          ; waitbar (21/32, h, 'CHOLMOD test19') ;
 
147
    test19                          ; waitbar (22/32, h, 'CHOLMOD test20') ;
 
148
    test20                          ; waitbar (23/32, h, 'CHOLMOD test21') ;
 
149
    test21                          ; waitbar (24/32, h, 'CHOLMOD test22a') ;
 
150
    test22 (nmat)                   ; waitbar (25/32, h, 'CHOLMOD test22b') ;
 
151
    test22 (0)                      ; waitbar (26/32, h, 'CHOLMOD test23') ;
 
152
    test23                          ; waitbar (27/32, h, 'CHOLMOD test24') ;
 
153
    test24                          ; waitbar (28/32, h, 'CHOLMOD test25') ;
 
154
    test25                          ; waitbar (29/32, h, 'CHOLMOD test26') ;
 
155
    test26 (do_metis)               ; waitbar (31/32, h, 'CHOLMOD test27') ;
 
156
 
 
157
    if (do_metis)
 
158
        test27 ;
 
159
    end
 
160
 
118
161
    % this test requires METIS
119
 
    test14 (2*nmat)
120
 
end
121
 
 
122
 
test15 (2*nmat)
123
 
test16
124
 
test17
125
 
test18
126
 
test19
127
 
test20
128
 
test21
129
 
test22 (nmat)
130
 
test22 (0)
131
 
test23
132
 
test24
133
 
test25
134
 
test26 (do_metis)
135
 
test27
136
 
% test28
137
 
 
138
 
fprintf ('=================================================================\n');
139
 
fprintf ('all tests passed\n') ;
140
 
 
141
 
diary off
 
162
    % test28 ;                      % (disabled)
 
163
 
 
164
    waitbar (32/32, h, 'CHOLMOD test done') ;
 
165
    fprintf ('=============================================================\n');
 
166
    fprintf ('all tests passed\n') ;
 
167
 
 
168
catch
 
169
    % out-of-memory is OK, other errors are not
 
170
    disp (lasterr) ;
 
171
    if (isempty (strfind (lasterr, 'Out of memory')))
 
172
        error (lasterr) ;                                                   %#ok
 
173
    else
 
174
        fprintf ('test terminated early, but otherwise OK\n') ;
 
175
    end
 
176
end
 
177
 
 
178
close (h) ;
 
179
if (do_diary)
 
180
    diary off
 
181
end