File: test_functions.m

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (64 lines) | stat: -rw-r--r-- 1,824 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function err = test_functions
%TEST_FUNCTIONS test various functions applied to a factorize object
% on a set of matrices
%
% Example:
%   test_functions
%
% See also test_all, factorize, inverse, mldivide

% Factorize, Copyright (c) 2011-2012, Timothy A Davis. All Rights Reserved.
% SPDX-License-Identifier: BSD-3-clause

fprintf ('\n----- Test functions:\n') ;
reset_rand ;
err = 0 ;

err = max (err, test_function ([ ])) ;
err = max (err, test_function ([ ], 'ldl', 1)) ;
err = max (err, test_function (eye (4))) ;
err = max (err, test_function (eye (4,3))) ;
err = max (err, test_function (eye (3,4))) ;

err = max (err, test_function (inf*eye (4))) ;
err = max (err, test_function (inf*eye (4,3))) ;
err = max (err, test_function (inf*eye (3,4))) ;

err = max (err, test_function (nan*eye (4))) ;
err = max (err, test_function (nan*eye (4,3))) ;
err = max (err, test_function (nan*eye (3,4))) ;

A = rand (3) ;
err = max (err, test_function (A'*A, [ ], 1)) ;
err = max (err, test_function (A, 'svd', 1)) ;
err = max (err, test_function) ;

A = rand (10) ;
A = A' + A + 20*eye(10) ;
err = max (err, test_function (A, 'svd', 1)) ;
err = max (err, test_function (A, 'chol', 1)) ;

for imaginary = 0:1
    for m = 1:6
        for n = 1:6
            fprintf ('.') ;
            A = rand (m,n) ;
            if (imaginary)
                A = A + 1i * rand (m,n) ;
            end
            err = max (err, test_function (A)) ;
            A = sparse (A) ;
            err = max (err, test_function (A)) ;
            if (m < n)
                A = A*A'  ;
            else
                A = A'*A  ;
            end
            err = max (err, test_function (A)) ;
            A = full (A) ;
            err = max (err, test_function (A)) ;
        end
    end
end

fprintf ('\ntest_functions, max error: %g\n', err) ;