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

« back to all changes in this revision

Viewing changes to CXSparse_newfiles/MATLAB/Test/test13.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 test13
 
2
%TEST13 test cs_counts, cs_etree
 
3
%
 
4
% Example:
 
5
%   test13
 
6
% See also: testall
 
7
 
 
8
%   Copyright 2006-2007, Timothy A. Davis.
 
9
%   http://www.cise.ufl.edu/research/sparse
 
10
 
 
11
 
 
12
clear functions
 
13
randn ('state',0) ;
 
14
rand ('state',0) ;
 
15
 
 
16
for trial = 1:100
 
17
    m = fix (100 * rand (1)) ;
 
18
    n = fix (100 * rand (1)) ;
 
19
    d = .1 * rand (1) ;
 
20
    A = sprandn (n,n,d) ;
 
21
    C = sprandn (m,n,d) ;
 
22
    A = A+A' ;
 
23
    fprintf ('m %4d n %4d nnz(A) %6d nnz(C) %6d\n', m, n, nnz(A), nnz(C)) ;
 
24
 
 
25
    if (rand ( ) > .5)
 
26
        A = A + 1i * sprand (A) ;
 
27
    end
 
28
 
 
29
    [p1,po1] = etree (A) ;
 
30
 
 
31
    [p2,po2] = cs_etree (A) ;
 
32
    [p3,po3] = cs_etree (A, 'sym') ;
 
33
    % po2 = cs_post (p2) ;
 
34
 
 
35
    check_if_same (p1,p2) ;
 
36
    check_if_same (po1,po2) ;
 
37
 
 
38
    check_if_same (p1,p3) ;
 
39
    check_if_same (po1,po3) ;
 
40
 
 
41
    c1 = symbfact (A) ;
 
42
    c2 = cs_counts (A) ;
 
43
 
 
44
    % A-A'
 
45
 
 
46
    check_if_same (c1,c2) ;
 
47
 
 
48
    c2 = cs_counts (triu (A)) ;
 
49
    check_if_same (c1,c2) ;
 
50
    % pause
 
51
 
 
52
    p0 = etree (A, 'col') ;
 
53
    % p1 = etree2 (A, 'col') ;  % CHOLMOD
 
54
    p2 = cs_etree (A, 'col') ;
 
55
 
 
56
    if (~isempty (A))
 
57
        check_if_same (p0,p2) ;
 
58
    end
 
59
 
 
60
    p0 = etree (C, 'col') ;
 
61
    % p1 = etree2 (C, 'col') ;  % CHOLMOD
 
62
    p2 = cs_etree (C, 'col') ;
 
63
 
 
64
    if (~isempty (C))
 
65
        check_if_same (p0,p2) ;
 
66
    end
 
67
 
 
68
    % find etree of A'A, and postorder it
 
69
    [m n] = size (A) ;                                                      %#ok
 
70
    % full (A)
 
71
 
 
72
    [cp0 cpo0] = etree (A, 'col') ;
 
73
    % [cp1 cpo1] = etree2 (A, 'col') ;  % CHOLMOD
 
74
    [cp2 cpo2] = cs_etree (A, 'col') ;
 
75
    % cpo2 = cs_post (cp2) ;
 
76
 
 
77
    check_if_same (cp0, cp2) ;
 
78
    check_if_same (cpo0, cpo2) ;
 
79
 
 
80
    c0 = symbfact (A, 'col') ;
 
81
    % c1 = symbfact2 (A, 'col') ;   % CHOLMOD
 
82
    c2 = cs_counts (A, 'col') ;
 
83
 
 
84
    check_if_same (c0, c2) ;
 
85
 
 
86
end