1function stats = ssweb (matrix, opts)
2%SSWEB opens the URL for a matrix in the SuiteSparse Matrix Collection.
3%
4%   ssweb(matrix) opens the URL for a matrix.  This parameter can be a string,
5%   or an integer.  If it is a string with no "/" character, the web page for a
6%   matrix group is displayed.  With no arguments, a list of all the matrix
7%   groups is displayed.
8%
9%   Example:
10%
11%   If Problem = ssget ('HB/arc130'), the first four examples display
12%   the same thing, the web page for the HB/arc130 matrix:
13%
14%       ssweb (6)
15%       ssweb ('HB/arc130')
16%       stats = ssweb (6)
17%
18%   The latter also returns statistics about the matrix or matrix group.
19%   To display the web page for the HB (Harwell-Boeing) group:
20%
21%       ssweb ('HB')
22%
23%   To display the home page for the ss sparse matrix collection:
24%
25%       ssweb
26%       ssweb (0)
27%       ssweb ('')
28%
29%   The latter two are useful if a second optional parameter is specified.
30%   The second optional argument is a string passed as additional parameters to
31%   the MATLAB web command.  To use the system web browser instead of the MATLAB
32%   browser, for example, use ssweb ('HB/arc130', '-browser').
33%
34%   See also web, ssget, ssget_defaults.
35
36% Copyright 2009-2019, Timothy A. Davis, http://www.suitesparse.com
37
38params = ssget_defaults ;
39ss_index = ssget ;
40
41if (nargin < 1)
42    matrix = '' ;
43end
44if (nargin < 2)
45    opts = '' ;
46end
47opts = [' ' opts] ;
48
49% get the matrix group, name, and id
50[group, name, id] = ssget_lookup (matrix, ss_index) ;
51
52url = params.topurl ;
53
54% open the web page for the matrix, group, or whole collection
55if (id == 0)
56    if (isempty (group))
57        eval (['web ' url opts])
58    else
59        eval (['web ' url '/' group opts])
60    end
61else
62    eval (['web ' url '/' group '/' name opts])
63end
64
65% return stats
66if (nargout > 0)
67
68    if (id == 0)
69
70        if (isempty (group))
71
72            % return stats about the whole collection
73            stats.nmatrices = length (ss_index.nrows) ;
74            stats.LastRevisionDate = ss_index.LastRevisionDate ;
75
76        else
77
78            % return stats about one matrix group
79            nmat = length (ss_index.nrows) ;
80            ngroup = 0 ;
81            for i = 1:nmat
82                if (strcmp (group, ss_index.Group {i}))
83                    ngroup = ngroup + 1 ;
84                end
85            end
86            stats.nmatrices = ngroup ;
87            stats.LastRevisionDate = ss_index.LastRevisionDate ;
88
89        end
90    else
91
92        % look up the matrix statistics
93        stats.Group = group ;
94        stats.Name = name ;
95        stats.nrows = ss_index.nrows (id) ;
96        stats.ncols = ss_index.ncols (id) ;
97        stats.nnz = ss_index.nnz (id) ;
98        stats.nzero = ss_index.nzero (id) ;
99        stats.pattern_symmetry = ss_index.pattern_symmetry (id) ;
100        stats.numerical_symmetry = ss_index.numerical_symmetry (id) ;
101        stats.isBinary = ss_index.isBinary (id) ;
102        stats.isReal = ss_index.isReal (id) ;
103        stats.nnzdiag = ss_index.nnzdiag (id) ;
104        stats.posdef = ss_index.posdef (id) ;
105        stats.amd_lnz = ss_index.amd_lnz (id) ;
106        stats.amd_flops = ss_index.amd_flops (id) ;
107        stats.amd_vnz = ss_index.amd_vnz (id) ;
108        stats.amd_rnz = ss_index.amd_rnz (id) ;
109        stats.nblocks = ss_index.nblocks (id) ;
110        stats.sprank = ss_index.sprank (id) ;
111        stats.RBtype = ss_index.RBtype (id,:) ;
112        stats.cholcand = ss_index.cholcand (id) ;
113        stats.ncc = ss_index.ncc (id) ;
114        stats.isND = ss_index.isND (id) ;
115        stats.isGraph = ss_index.isGraph (id) ;
116
117    end
118end
119