1function test26 (do_metis)
2%TEST26 test logical full and sparse matrices
3% Example:
4%   test26
5% See also cholmod_test
6
7% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com
8
9fprintf ('=================================================================\n');
10fprintf ('test26: test logical full and sparse matrices\n') ;
11
12if (nargin < 1)
13    do_metis = 1 ;
14end
15
16Prob = ssget ('HB/bcsstk01') ;
17A = Prob.A ;
18p = amd2 (A) ;
19n = size (A,1) ;
20A = A (p,p) + 10*speye (n) ;
21C = logical (A ~= 0) ;
22
23test26b (A,C,do_metis) ;
24test26b (full (A),C,do_metis) ;
25test26b (full (A), full (C),do_metis) ;
26test26b (A, full(C),do_metis) ;
27
28A = A + 0.001 * (spones (tril (A,-1) + triu (A,1))) * 1i ;
29
30test26b (A,C,do_metis) ;
31test26b (full (A),C,do_metis) ;
32test26b (full (A), full (C),do_metis) ;
33test26b (A, full(C),do_metis) ;
34fprintf ('test26 passed\n') ;
35
36%-------------------------------------------------------------------------------
37
38function test26b (A,C,do_metis)
39% test26b test bisect, analyze, etree2, metis, nesdis, symbfact2, and resymbol
40
41p1 = analyze (A) ;
42p2 = analyze (C) ;
43if (any (p1 ~= p2))
44    error ('test 26 failed (analyze)!') ;
45end
46
47p1 = etree2 (A) ;
48p2 = etree2 (C) ;
49if (any (p1 ~= p2))
50    error ('test 26 failed (etree2)!') ;
51end
52
53if (do_metis)
54
55    s1 = bisect (A) ;
56    s2 = bisect (C) ;
57    if (any (s1 ~= s2))
58	error ('test 26 failed (bisect)!') ;
59    end
60
61    p1 = metis (A) ;
62    p2 = metis (C) ;
63    if (any (p1 ~= p2))
64	error ('test 26 failed (metis)!') ;
65    end
66
67    p1 = nesdis (A) ;
68    p2 = nesdis (C) ;
69    if (any (p1 ~= p2))
70	error ('test 26 failed (nesdis)!') ;
71    end
72
73end
74
75c1 = symbfact2 (A) ;
76c2 = symbfact2 (C) ;
77if (any (c1 ~= c2))
78    error ('test 26 failed (symbfact2)!') ;
79end
80
81A (1,2) = 0 ;
82A (2,1) = 0 ;
83C = logical (A ~= 0) ;
84
85L = chol (sparse (A))' ;
86L1 = resymbol (L, A) ;
87L2 = resymbol (L, C) ;
88if (norm (L1 - L2, 1) ~= 0)
89    error ('test 26 failed (resymbol)!') ;
90end
91