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

« back to all changes in this revision

Viewing changes to CHOLMOD/MATLAB/Test/testsolve.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
 
function [x1,x2,e1,e2] = testsolve (A,b) ;
 
1
function [x1,x2,e1,e2] = testsolve (A,b)
 
2
%TESTSOLVE test CHOLMOD and compare with x=A\b 
2
3
% [x1,x2,e1,e2] = testsolve (A,b) ;
3
4
% Compare CHOLMOD and MATLAB's x=A\b
4
 
% x1 = A\b, x2 = cholmod(A,b), e1 = norm(A*x1-b), e2 = norm(A*x2-b)
 
5
% x1 = A\b, x2 = cholmod2(A,b), e1 = norm(A*x1-b), e2 = norm(A*x2-b)
 
6
% Example:
 
7
%   [x1,x2,e1,e2] = testsolve (A,b) ;
 
8
% See also cholmod_test
 
9
 
 
10
% Copyright 2006-2007, Timothy A. Davis, University of Florida
 
11
 
5
12
fprintf ('A: [n %6d real %d]    B: [sp:%d nrhs %d real %d]  ', ...
6
13
    size(A,1), isreal(A), issparse(b), size(b,2), isreal(b)) ;
7
14
tic
8
15
x1 = A\b ;
9
16
t1 = toc ;
10
17
tic
11
 
x2 = cholmod(A,b) ;
 
18
x2 = cholmod2(A,b) ;
12
19
t2 = toc ;
13
20
tic
14
21
e1 = norm (A*x1-b,1) ;
15
22
t3 = toc ;
16
23
e2 = norm (A*x2-b,1) ;
17
 
if (e2 == 0 | e1 == 0)
 
24
if (e2 == 0 | e1 == 0)                                                      %#ok
18
25
    e12 = 0 ;
19
26
else
20
27
    e12 = log2 (e1/e2) ;
25
32
    t12 = t1 / t2 ;
26
33
end
27
34
if (t2 == 0)
28
 
    t32 = 1 ;
 
35
    t32 = 1 ;                                                               %#ok
29
36
else
30
 
    t32 = t3 / t2 ;
 
37
    t32 = t3 / t2 ;                                                         %#ok
31
38
end
32
39
fprintf (' [e1: %5.0e : %5.1f] [t1: %8.2f t2 %8.2f : %5.1f]\n', ...
33
40
    e1, e12, t1, t2, t12) ;
34
41
if (e2 > max (1e-8, 1e3*e1))
35
 
    e1
36
 
    e2
37
42
    error ('!') ;
38
43
end