1function err = test_functions 2%TEST_FUNCTIONS test various functions applied to a factorize object 3% on a set of matrices 4% 5% Example: 6% test_functions 7% 8% See also test_all, factorize, inverse, mldivide 9 10% Copyright 2011-2012, Timothy A. Davis, http://www.suitesparse.com 11 12fprintf ('\n----- Test functions:\n') ; 13reset_rand ; 14err = 0 ; 15 16err = max (err, test_function ([ ])) ; 17err = max (err, test_function ([ ], 'ldl', 1)) ; 18err = max (err, test_function (eye (4))) ; 19err = max (err, test_function (eye (4,3))) ; 20err = max (err, test_function (eye (3,4))) ; 21 22err = max (err, test_function (inf*eye (4))) ; 23err = max (err, test_function (inf*eye (4,3))) ; 24err = max (err, test_function (inf*eye (3,4))) ; 25 26err = max (err, test_function (nan*eye (4))) ; 27err = max (err, test_function (nan*eye (4,3))) ; 28err = max (err, test_function (nan*eye (3,4))) ; 29 30A = rand (3) ; 31err = max (err, test_function (A'*A, [ ], 1)) ; 32err = max (err, test_function (A, 'svd', 1)) ; 33err = max (err, test_function) ; 34 35A = rand (10) ; 36A = A' + A + 20*eye(10) ; 37err = max (err, test_function (A, 'svd', 1)) ; 38err = max (err, test_function (A, 'chol', 1)) ; 39 40for imaginary = 0:1 41 for m = 1:6 42 for n = 1:6 43 fprintf ('.') ; 44 A = rand (m,n) ; 45 if (imaginary) 46 A = A + 1i * rand (m,n) ; 47 end 48 err = max (err, test_function (A)) ; 49 A = sparse (A) ; 50 err = max (err, test_function (A)) ; 51 if (m < n) 52 A = A*A' ; 53 else 54 A = A'*A ; 55 end 56 err = max (err, test_function (A)) ; 57 A = full (A) ; 58 err = max (err, test_function (A)) ; 59 end 60 end 61end 62 63fprintf ('\ntest_functions, max error: %g\n', err) ; 64