1function cholmod_test (nmat, do_diary) 2%CHOLMOD_TEST test the CHOLMOD mexFunctions 3% 4% Example: 5% cholmod_test(nmat,do_diary) 6% 7% The ssget interface to the SuiteSparse matrix collection is required. 8% See sparse.tamu.edu. 9% 10% nmat is optional. If present, it is the # of matrices used in 11% tests 0, 8, 10, 11, 12, and 12. tests 14 and 15 use 2*nmat matrices. 12% default nmat is 50. 13% 14% do_diary: 1 to save results in a diary, 0 otherwise. Default 0. 15% 16% cholmod_demo: run tests on a few random matrices 17% graph_demo: graph partitioning demo 18% test0: test most CHOLMOD functions 19% test1: test sparse2 20% test2: test sparse2 21% test3: test sparse on int8, int16, and logical 22% test4: test cholmod2 with multiple and sparse right-hand-sides 23% test5: test sparse2 24% test6: test sparse with large matrix, both real and complex, compare w/MATLAB 25% test7: test sparse2 26% test8: order many sparse matrices, test symbfact2, compare amd and metis 27% test9: test metis, etree, bisect, nesdis 28% test10: test cholmod2's backslash on real and complex matrices 29% test11: test analyze, compare CHOLMOD and MATLAB, save results in Results.mat 30% test12: test etree2 and compare with etree 31% test13: test cholmod2 and MATLAB on large tridiagonal matrices 32% test14: test metis, symbfact2, and etree2 33% test15: test symbfact2 vs MATLAB 34% test16: test cholmod2 on a large matrix 35% test17: test lchol on a few large matrices 36% test18: test cholmod2 on a few large matrices 37% test19: look for NaN's from lchol (caused by Intel MKL 7.x bug) 38% test20: test symbfact2, cholmod2, and lu on a few large matrices 39% test21: test cholmod2 on diagonal or ill-conditioned matrices 40% test22: test chol and chol2 and singular and indefinite matrices 41% test23: test chol and cholmod2 on the sparse matrix used in "bench" 42% test24: test sdmult 43% test25: test sdmult on a large matrix 44% test26: test logical full and sparse matrices 45% test27: test nesdis 46% ltest: test lxbpattern 47% lxtest: test lsubsolve 48% 49% See also test0, test1, ... test28. 50 51% This extensive test is not included: 52% test28: test nesdis 53 54% Copyright 2006-2020, Timothy A. Davis, http://www.suitesparse.com 55 56if (nargin < 2) 57 do_diary = 0 ; 58end 59 60if (do_diary) 61 diary off 62 s = date ; 63 t = clock ; 64 s = sprintf ('diary cholmod_test_%s_%d-%d-%d.txt\n', s, t (4), t(5), fix(t(6))); 65 eval (s) ; 66end 67 68fprintf ('Running CHOLMOD tests.\n') ; 69help cholmod_test 70mex -O -R2018a GB_spones_mex.c 71 72test_path = pwd ; 73% addpath (test_path) ; 74cd ('..') ; 75cholmod_path = pwd ; 76addpath (cholmod_path) 77cd ('../../AMD/MATLAB') ; 78amd_path = pwd ; 79addpath (amd_path) 80cd ('../../COLAMD') ; 81colamd_path = pwd ; 82addpath (colamd_path) 83cd ('../CCOLAMD') ; 84ccolamd_path = pwd ; 85addpath (ccolamd_path) 86cd ('../CAMD/MATLAB') ; 87camd_path = pwd ; 88addpath (camd_path) 89 90cd (test_path) 91fprintf ('Added the following paths. You may wish to add them\n') ; 92fprintf ('permanently using the MATLAB pathtool command.\n') ; 93fprintf ('%s\n', cholmod_path) ; 94fprintf ('%s\n', amd_path) ; 95fprintf ('%s\n', colamd_path) ; 96fprintf ('%s\n', ccolamd_path) ; 97fprintf ('%s\n', camd_path) ; 98 99if (nargin < 1) 100 nmat = 50 ; 101end 102 103try 104 s = metis (sparse (1)) ; 105 do_metis = 1 ; 106catch 107 fprintf ('METIS not installed\n') ; 108 do_metis = 0 ; 109end 110 111tt = 35 ; 112 113h = waitbar (0.5/tt, 'CHOLMOD demo:') ; 114 115try 116 117 cholmod_demo ; waitbar ( 2/tt, h, 'CHOLMOD graph demo'); 118 if (do_metis) 119 graph_demo ; 120 end 121 waitbar ( 2/tt, h, 'CHOLMOD test0') ; 122 test0 (nmat) ; waitbar ( 3/tt, h, 'CHOLMOD test1') ; 123 test1 ; waitbar ( 4/tt, h, 'CHOLMOD test2') ; 124 test2 ; waitbar ( 5/tt, h, 'CHOLMOD test3') ; 125 test3 ; waitbar ( 6/tt, h, 'CHOLMOD test4') ; 126 test4 ; waitbar ( 7/tt, h, 'CHOLMOD test5') ; 127 test5 ; waitbar ( 8/tt, h, 'CHOLMOD test6') ; 128 test6 ; waitbar ( 9/tt, h, 'CHOLMOD test7') ; 129 test7 ; waitbar (10/tt, h, 'CHOLMOD test8') ; 130 131 if (do_metis) 132 % these tests require METIS 133 test8 (nmat) ; waitbar (11/tt, h, 'CHOLMOD test9') ; 134 test9 ; 135 end 136 137 waitbar (12/tt, h, 'CHOLMOD test10') ; 138 test10 (nmat) ; waitbar (13/tt, h, 'CHOLMOD test11') ; 139 test11 (nmat) ; waitbar (14/tt, h, 'CHOLMOD test12') ; 140 test12 (nmat) ; waitbar (15/tt, h, 'CHOLMOD test13') ; 141 test13 ; waitbar (16/tt, h, 'CHOLMOD test14') ; 142 143 if (do_metis) 144 % this test requires METIS 145 test14 (2*nmat) ; 146 end 147 148 waitbar (17/tt, h, 'CHOLMOD test15') ; 149 test15 (2*nmat) ; waitbar (18/tt, h, 'CHOLMOD test16') ; 150 test16 ; waitbar (19/tt, h, 'CHOLMOD test17') ; 151 test17 ; waitbar (20/tt, h, 'CHOLMOD test18') ; 152 test18 ; waitbar (21/tt, h, 'CHOLMOD test19') ; 153 test19 ; waitbar (22/tt, h, 'CHOLMOD test20') ; 154 test20 ; waitbar (23/tt, h, 'CHOLMOD test21') ; 155 test21 ; waitbar (24/tt, h, 'CHOLMOD test22a') ; 156 test22 (nmat) ; waitbar (25/tt, h, 'CHOLMOD test22b') ; 157 test22 (0) ; waitbar (26/tt, h, 'CHOLMOD test23') ; 158 test23 ; waitbar (27/tt, h, 'CHOLMOD test24') ; 159 test24 ; waitbar (28/tt, h, 'CHOLMOD test25') ; 160 test25 ; waitbar (29/tt, h, 'CHOLMOD test26') ; 161 test26 (do_metis) ; waitbar (31/tt, h, 'CHOLMOD test27') ; 162 163 if (do_metis) 164 test27 ; 165 end 166 167 % this test requires METIS 168 % test28 ; % (disabled) 169 170 ltest ; waitbar (32/tt, h, 'CHOLMOD ltest') ; 171 lxtest ; waitbar (33/tt, h, 'CHOLMOD lxtest') ; 172 test29 ; waitbar (34/tt, h, 'CHOLMOD test29') ; 173 174 waitbar (tt/tt, h, 'CHOLMOD test done') ; 175 fprintf ('=============================================================\n'); 176 fprintf ('all tests passed\n') ; 177 178catch 179 % out-of-memory is OK, other errors are not 180 disp (lasterr) ; 181 if (isempty (strfind (lasterr, 'Out of memory'))) 182 error (lasterr) ; %#ok 183 else 184 fprintf ('test terminated early, but otherwise OK\n') ; 185 end 186end 187 188close (h) ; 189if (do_diary) 190 diary off 191end 192