File: test_all_svd.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 (78 lines) | stat: -rw-r--r-- 2,186 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function err = test_all_svd
%TEST_ALL_SVD tests the svd factorization method for a range of problems.
%
% Example
%   test_all_svd
%
% See also test_all.

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

reset_rand ;
err = test_svd ;

err = max (err, test_svd (ones (3))) ;
A = zeros (3) ;
F = factorize (A, 'svd') ;
nrm = norm (F) ;
err = max (err, nrm) ;
nrm = norm (inverse (F)) ;
c = cond (F,1) ;
if (~isequal (nrm, inf) || ~isequal (c, inf))
    error ('svd test failure') ;
end

for sp = 0:1
    for n = 0:6
        for m = 0:6
            for im = 0:1
                A = rand (m,n) ;
                if (im)
                    A = A + 1i*rand (m,n) ;
                end
                if (sp)
                    A = sparse (A) ;
                end
                err = max (err, test_svd (A)) ;
            end
        end
        fprintf ('\n') ;
    end
end

for n = 2:7
    A = gallery ('chow', n, pi, 2) ;
    err = max (err, test_svd (A)) ;
    err = max (err, test_svd (A')) ;
    err = max (err, test_svd (gallery ('clement', n, 0))) ;
    err = max (err, test_svd (gallery ('clement', n, 1))) ;
    A = sprandn (n, 2*n, 0.2) ;
    err = max (err, test_svd (A)) ;
    err = max (err, test_svd (A')) ;
end
fprintf ('\n') ;
err = max (err, test_svd (gallery ('condex', 4, 1))) ;
err = max (err, test_svd (gallery ('condex', 3, 2))) ;
err = max (err, test_svd (gallery ('condex', 7, 3))) ;
err = max (err, test_svd (gallery ('condex', 8, 4))) ;
err = max (err, test_svd (gallery ('dorr', 20))) ;
err = max (err, test_svd (gallery ('frank', 20))) ;
err = max (err, test_svd (gallery ('gearmat', 20))) ;
err = max (err, test_svd (gallery ('lauchli', 20))) ;
err = max (err, test_svd (gallery ('neumann', 6^2))) ;
fprintf ('\ntest_all_svd error so far: %g\n', err) ;

if (err > 1e-6)
    error ('error too high') ;
end

fprintf ('Testing on gallery (''randsvd'',50) matrices:\n') ;
err = max (err, test_svd (gallery ('randsvd', 50))) ;
err = max (err, test_svd (gallery ('randsvd', 50, 10/eps))) ;
fprintf ('\nFinal test_all_svd error: %g\n', err) ;

if (err > 1e-6)
    error ('error too high') ;
end