~logan/ubuntu/trusty/suitesparse/4.2.1-3ubuntu1

« back to all changes in this revision

Viewing changes to CHOLMOD/MATLAB/Test/test6.m

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2007-05-29 09:36:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529093629-zowquo0b7slkk6nc
Tags: 3.0.0-2
* suitesparse builds properly twice in a row
* Bug fix: "suitesparse - FTBFS: Broken build depens: libgfortran1-dev",
  thanks to Bastian Blank (Closes: #426349).
* Bug fix: "suitesparse_3.0.0-1: FTBFS: build-depends on
  libgfortran1-dev", thanks to Steve Langasek (Closes: #426354).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
function test6
2
 
% test6: test sparse with large matrix, both real and complex
 
2
%TEST6 test sparse with large matrix, both real and complex
3
3
% compare times with MATLAB
 
4
% Example:
 
5
%   test6
 
6
% See also cholmod_test
 
7
 
 
8
% Copyright 2006-2007, Timothy A. Davis, University of Florida
 
9
 
4
10
fprintf ('=================================================================\n');
5
11
fprintf ('test6: test sparse with large matrix, both real and complex\n') ;
6
12
 
7
13
for do_complex = 0:1
8
14
 
9
 
    do_complex
10
 
 
 
15
    fprintf ('do_complex = %d\n', do_complex) ;
11
16
    randn ('state', 0) ;
12
17
    rand  ('state', 0) ;
13
18
 
14
19
    % Prob = UFget (437)
15
 
    Prob = UFget (750)
 
20
    Prob = UFget (750)                                                      %#ok
16
21
    A = Prob.A ;
17
 
    [m n] = size (A) ;
 
22
    [m n] = size (A) ;                                                      %#ok
18
23
 
19
24
    if (do_complex)
20
25
%       A = A + 1i*sprand(A) ;
51
56
    C = sparse (i,j,x,m,n) ;
52
57
    t2 = toc ;
53
58
 
54
 
    fprintf ('dtri time: cholmod %8.6f  matlab %8.6f\n', t1, t2) ;
 
59
    fprintf ('dtri time: cholmod2 %8.6f  matlab %8.6f\n', t1, t2) ;
55
60
 
56
61
    err = norm(A-B,1) ;
57
62
    if (err > 0)
68
73
 
69
74
    i2 = i(p) ;
70
75
    j2 = j(p) ;
71
 
    x2 = x(p) ;
 
76
    x2 = x(p) ;                                                     %#ok
72
77
 
73
78
    tic ;
74
79
    B = sparse2 (i,j,x,m,n) ;
77
82
    C = sparse (i,j,x,m,n) ;
78
83
    t2 = toc ;
79
84
 
80
 
    fprintf ('dtri time: cholmod %8.6f  matlab %8.6f (jumbled)\n', t1, t2) ;
 
85
    fprintf ('dtri time: cholmod2 %8.6f  matlab %8.6f (jumbled)\n', t1, t2) ;
81
86
 
82
87
    err = norm(A-B,1) ;
83
88
    if (err > 0)
106
111
    if (err > 0)
107
112
        error ('dtri2 3') ;
108
113
    end
109
 
    fprintf ('dtri time: cholmod %8.6f  matlab %8.6f (duplicates)\n', t1, t2) ;
 
114
    fprintf ('dtri time: cholmod2 %8.6f  matlab %8.6f (duplicates)\n', t1, t2) ;
110
115
 
111
116
    fprintf ('length %d nz %d\n', length (xx), nnz(D)) ;
112
117
 
119
124
    tic ;
120
125
    F = sparse (i2, j2, xx, n, n) ;
121
126
    t2 = toc ;
122
 
    err = norm (E-F,1)
 
127
    err = norm (E-F,1)                                                      %#ok
123
128
    if (err > 1e-13)
124
129
        error ('dtri2 4') ;
125
130
    end
126
 
    fprintf ('dtri time: cholmod %8.6f  matlab %8.6f (upper)\n', t1, t2) ;
 
131
    fprintf ('dtri time: cholmod2 %8.6f  matlab %8.6f (upper)\n', t1, t2) ;
127
132
 
128
133
    i2 = max (ii,jj) ;
129
134
    j2 = min (ii,jj) ;
134
139
    tic ;
135
140
    F = sparse (i2, j2, xx, n, n) ;
136
141
    t2 = toc ;
137
 
    err = norm (E-F,1)
 
142
    err = norm (E-F,1)                                                      %#ok
138
143
    if (err > 1e-13)
139
144
        error ('dtri2 5') ;
140
145
    end
141
 
    fprintf ('dtri time: cholmod %8.6f  matlab %8.6f (lower)\n', t1, t2) ;
 
146
    fprintf ('dtri time: cholmod2 %8.6f  matlab %8.6f (lower)\n', t1, t2) ;
142
147
 
143
148
    [ignore, i] = sort (ii) ;
144
149
    ii = ii (i) ;
155
160
    if (err > 0)
156
161
        error ('dtri2 6') ;
157
162
    end
158
 
    fprintf ('dtri time: cholmod %8.6f  matlab %8.6f (sorted, dupl)\n', t1, t2) ;
 
163
    fprintf ('dtri time: cholmod2 %8.6f  matlab %8.6f (sorted, dupl)\n', t1, t2) ;
159
164
 
160
165
end
161
166