1function stats = SJweb (matrix, opts)
2%SJWEB opens the URL for a matrix.
3%
4%   SJweb(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 = SJget ('HB/ash292'), the first four examples display
12%   the same thing, the web page for the HB/ash292 matrix:
13%
14%       SJweb (6)
15%       SJweb ('HB/ash292')
16%       stats = SJweb (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%       SJweb ('HB')
22%
23%   To display the home page for the SJSU Singular matrix collection:
24%
25%       SJweb
26%       SJweb (0)
27%       SJweb ('')
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 SJweb ('HB/ash292', '-browser').
33%
34%   See also web, SJget, SJget_defaults.
35
36%   Derived from the ssget toolbox on March 18, 2008.
37%   Copyright 2007, Tim Davis, University of Florida.
38
39params = SJget_defaults ;
40SJ_Index = SJget ;
41
42if (nargin < 1)
43    matrix = '' ;
44end
45if (nargin < 2)
46    opts = '' ;
47end
48
49% get the matrix group, name, and id
50[group name id] = SJget_lookup (matrix, SJ_Index) ;
51
52url = params.url ;
53len = length (url) ;
54if (strcmp (url ((len-3):len), '/mat'))
55    % remove the trailing '/mat'
56    url = url (1:(len-4)) ;
57end
58
59% open the web page for the matrix, group, or whole collection
60if (id == 0)
61    if (isempty (group))
62	eval (['web ' url '/index.html ' opts])
63    else
64	eval (['web ' url '/html/' group '/index.html ' opts])
65    end
66else
67    eval (['web ' url '/html/' group '/' name '.html ' opts])
68end
69
70% return stats
71if (nargout > 0)
72
73    if (id == 0)
74
75	if (isempty (group))
76
77	    % return stats about the whole collection
78	    stats.nmatrices = length (SJ_Index.nrows) ;
79	    stats.LastRevisionDate = SJ_Index.LastRevisionDate ;
80	    stats.DownloadTime = datestr (SJ_Index.DownloadTimeStamp) ;
81
82	else
83
84	    % return stats about one matrix group
85	    nmat = length (SJ_Index.nrows) ;
86	    ngroup = 0 ;
87	    for i = 1:nmat
88		if (strcmp (group, SJ_Index.Group {i}))
89		    ngroup = ngroup + 1 ;
90		end
91	    end
92	    stats.nmatrices = ngroup ;
93	    stats.LastRevisionDate = SJ_Index.LastRevisionDate ;
94	    stats.DownloadTime = datestr (SJ_Index.DownloadTimeStamp) ;
95
96	end
97    else
98
99	% look up the matrix statistics
100	stats.Group = group ;
101	stats.Name = name ;
102	stats.nrows = SJ_Index.nrows (id) ;
103	stats.ncols = SJ_Index.ncols (id) ;
104	stats.nnz = SJ_Index.nnz (id) ;
105	stats.nzero = SJ_Index.nzero (id) ;
106	stats.pattern_symmetry = SJ_Index.pattern_symmetry (id) ;
107	stats.numerical_symmetry = SJ_Index.numerical_symmetry (id) ;
108	stats.isBinary = SJ_Index.isBinary (id) ;
109	stats.isReal = SJ_Index.isReal (id) ;
110
111	stats.nnzdiag = SJ_Index.nnzdiag (id) ;
112	stats.posdef = SJ_Index.posdef (id) ;
113
114	stats.amd_lnz = SJ_Index.amd_lnz (id) ;
115	stats.amd_flops = SJ_Index.amd_flops (id) ;
116	stats.amd_vnz = SJ_Index.amd_vnz (id) ;
117	stats.amd_rnz = SJ_Index.amd_rnz (id) ;
118	stats.metis_lnz = SJ_Index.metis_lnz (id) ;
119	stats.metis_flops = SJ_Index.metis_flops (id) ;
120	stats.metis_vnz = SJ_Index.metis_vnz (id) ;
121	stats.metis_rnz = SJ_Index.metis_rnz (id) ;
122	stats.nblocks = SJ_Index.nblocks (id) ;
123	stats.sprank = SJ_Index.sprank (id) ;
124	stats.nzoff = SJ_Index.nzoff (id) ;
125	stats.dmperm_lnz = SJ_Index.dmperm_lnz (id) ;
126	stats.dmperm_unz = SJ_Index.dmperm_unz (id) ;
127	stats.dmperm_flops = SJ_Index.dmperm_flops (id) ;
128	stats.dmperm_vnz = SJ_Index.dmperm_vnz (id) ;
129	stats.dmperm_rnz = SJ_Index.dmperm_rnz (id) ;
130
131	stats.RBtype = SJ_Index.RBtype (id,:) ;
132	stats.cholcand = SJ_Index.cholcand (id) ;
133	stats.ncc = SJ_Index.ncc (id) ;
134
135    end
136end
137