File: test1.m

package info (click to toggle)
suitesparse 1%3A5.12.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 176,720 kB
  • sloc: ansic: 1,193,914; cpp: 31,704; makefile: 6,638; fortran: 1,927; java: 1,826; csh: 765; ruby: 725; sh: 529; python: 333; perl: 225; sed: 164; awk: 35
file content (84 lines) | stat: -rw-r--r-- 2,178 bytes parent folder | download | duplicates (5)
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
79
80
81
82
83
84
function test1 (wait)
%TEST1 test sparse2
% Example:
%   test1
% See also cholmod_test

% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com

fprintf ('=================================================================\n');
fprintf ('test1: test sparse2\n') ;

if (nargin == 0)
    wait = 0 ;
end

m = 3 ;
n = 4 ;

ii = { 1, [2 3]', 2, [ ] } ;
jj = { 1, [2 3]', 3, [ ] } ;
ss = { 1, [2 3]', pi, [ ] } ;

for ki = 1:length (ii)
    for kj = 1:length (jj)
        for ks = 1:length (ss)

            fprintf ('\n-----------------------------------------------\n') ;
            i = ii {ki}	    %#ok
            j = jj {kj}	    %#ok
            s = ss {ks}	    %#ok
	    m		    %#ok
	    n		    %#ok
	    clear A1 A2 B1 B2

	    fprintf ('\nA1 = sparse (i,j,s,m,n)\n') ;
            try % sparse, possibly with invalid inputs
                A1 = sparse (i,j,s,m,n)			    %#ok
		fprintf ('size A1: %d %d\n', size (A1)) ;
            catch
		A1 = 'A failed' ;
                fprintf ('sparse failed\n') ;
            end

	    fprintf ('\nA2 = sparse2 (i,j,s,m,n)\n') ;
            try % sparse2, possibly with invalid inputs
                A2 = sparse2 (i,j,s,m,n)			%#ok
		fprintf ('size A2: %d %d\n', size (A2)) ;
            catch
		A2 = 'A failed' ;
                fprintf ('sparse2 failed\n') ;
            end

	    fprintf ('\nB1 = sparse (i,j,s)\n') ;
            try % sparse, possibly with invalid inputs
                B1 = sparse (i,j,s)			%#ok
		fprintf ('size B1: %d %d\n', size (B1)) ;
            catch
                B1 = 'B failed' ;
                fprintf ('sparse failed\n') ;
            end

	    fprintf ('\nB2 = sparse2 (i,j,s)\n') ;
            try % sparse2, possibly with invalid inputs
                B2 = sparse2 (i,j,s)			    %#ok
		fprintf ('size B2: %d %d\n', size (B2)) ;
            catch
		B2 = 'B failed' ;
                fprintf ('sparse2 failed\n') ;
            end

	    if (wait)
		pause
	    end

	    if (~isequal (A1,A2) | ~isequal (B1,B2))			    %#ok
		fprintf (...
		'========================== SPARSE AND SPARSE2 DIFFER\n') ;
	    end

        end
    end
end

fprintf ('test1 passed (review the above results)\n') ;