function UFlist (what, group) %UFlist: create a web page index for the UF Sparse Matrix Collection % % Usage: UFlist (what) % % what: % 'group' sort by group, then filename % 'name' sort by name % 'dimension' sort by max row or col dimension % 'id' sort by id (default, if "what" is not present) % 'number of nonzeros' sort by number of nonzeros % 'type' sort by type, then dimension % 'symmetry' sort by symmetry. Rectangular matrices first, sorted by % min(nrow,ncol)-max(nrow,ncol), then numerical symmetry % 0 to just less than one. Then numerical symmetry = 1 % but not spd (sorted by dimension). Then spd sorted % by dimension. % % If two arguments are present, only that group is created. % In this case, "what" must be "group". % % Example: % % UFlist ('id') % UFlist ('group', 'HB') % % See also UFget, UFint. % Copyright 2006, Timothy A. Davis index = UFget ; if (nargin < 1) what = 'id' ; end by_group = (nargin > 1) ; % create the primary directory [url topdir] = UFlocation ; matrices = [topdir 'matrices'] ; if (~exist (matrices, 'dir')) mkdir (matrices) ; end if (by_group) fprintf ('group: %s\n', group) ; loc = '../' ; if (~exist ([matrices filesep group], 'dir')) mkdir ([matrices filesep group]) ; end f = fopen ([matrices filesep group filesep 'index.html'], 'w') ; else fprintf ('list: %s\n', what) ; f = fopen ([matrices filesep 'list_by_' what '.html'], 'w') ; loc = '' ; end if (f < 0) error ('unable to create html file\n') ; end nmat = length (index.nrows) ; % add the header fprintf (f, ... '\n') ; fprintf (f, '\n') ; fprintf (f, '') ; if (by_group) fprintf (f, 'UF Sparse Matrix Collection - %s group', group) ; else fprintf (f, '<title>UF Sparse Matrix Collection - sorted by ') ; if (strcmp (what, 'nnz')) fprintf (f, 'number of nonzeros') ; else fprintf (f, '%s', what) ; end end fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, ... '
  • UF Sparse Matrix Collection
    \n', loc) ; if (by_group) fprintf (f, '

    UF Sparse Matrix Collection: %s group.

    \n', group) ; else fprintf (f, '

    UF Sparse Matrix Collection, sorted by %s.\n', what) ; fprintf (f, ' Click on a column header to sort by that column.

    \n') ; end % add link to mat//README.txt if (by_group) fprintf (f, '

  • ', group) ; fprintf (f, 'Click here for a description of the %s group.\n', group) ; end fprintf (f, '
  • ', loc) ; fprintf (f, 'Click here for a list of all matrix groups.\n') ; fprintf (f, '
  • ', loc) ; fprintf (f, 'Click here for a list of all matrices.\n') ; fprintf (f, '

    \n') ; % sort by filename [ignore, iname] = sort (lower (index.Name)) ; if (by_group) list = [ ] ; for i = 1:nmat if (strcmp (group, index.Group {i})) list = [list i] ; %#ok end end [ignore i] = sort (lower (index.Name (list))) ; list = list (i) ; if (isempty (list)) error ('empty group!') ; end elseif (strcmp (what, 'group')) % sort by filename, then stable sort by group [ignore, i] = sort (lower (index.Group (iname))) ; list = iname (i) ; elseif (strcmp (what, 'name')) % sort by filename only list = iname' ; elseif (strcmp (what, 'dimension')) % sort by filename, then stable sort by max dimension [ignore, i] = sort (max (index.nrows (iname), index.ncols (iname))) ; list = iname (i) ; elseif (strcmp (what, 'id')) list = 1:nmat ; elseif (strcmp (what, 'nnz')) % sort by filename, then stable sort by nnz [ignore, i] = sort (index.nnz (iname)) ; list = iname (i) ; elseif (strcmp (what, 'symmetry')) % 'symmetry' sort by symmetry. Rectangular matrices first, sorted by % min(nrow,ncol)-max(nrow,ncol), then numerical symmetry % 0 to just less than one. Then numerical symmetry = 1 % but not spd (sorted by dimension). Then spd sorted % by dimension. s1 = min (index.nrows, index.ncols) - max (index.nrows, index.ncols) ; s2 = index.numerical_symmetry ; s2 (find (s2) == -1) = 1 ; s3 = index.posdef ; s3 (find (s3) == -1) = 2 ; s4 = max (index.nrows, index.ncols) ; [ignore list] = sortrows ([s1' s2' s3' s4'], [1 2 3 4]) ; elseif (strcmp (what, 'type')) [ignore i1] = sort (max (index.nrows, index.ncols)) ; s = index.RBtype (i1,:) ; [ignore i2] = sortrows (s) ; list = i1 (i2) ; else error ('unknown list') ; end % ensure list is a row vector list = list (:)' ; % print the header fprintf (f, '\n') ; if (by_group) fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, '\n') ; fprintf (f, '\n') ; else fprintf (f, '\n') ; fprintf (f, '\n', loc) ; fprintf (f, '\n', loc) ; fprintf (f, '\n') ; fprintf (f, '\n', loc) ; fprintf (f, '\n', loc) ; fprintf (f, '\n', loc) ; fprintf (f, '\n', loc) ; fprintf (f, '\n', loc) ; fprintf (f, '\n', loc) ; end for id = list group = index.Group {id} ; name = index.Name {id} ; nrows = index.nrows (id) ; ncols = index.ncols (id) ; nz = index.nnz (id) ; sym = index.numerical_symmetry (id) ; mtype = index.RBtype (id,:) ; s = index.posdef (id) ; if (s == 0) ss = '-' ; elseif (s == 1) ss = 'yes' ; else ss = '?' ; end fprintf (f, '\n') ; % thumbnail link to the matrix page fprintf (f, '\n') ; % group if (by_group) fprintf (f, '\n', name, name) ; else fprintf (f, '%s\n', group, name, name) ; end % id fprintf (f, '\n', id) ; % download links fprintf (f, '\n') ; % nrow fprintf (f, '\n', UFint (nrows)) ; % ncols fprintf (f, '\n', UFint (ncols)) ; % nz fprintf (f, '\n', UFint (nz)) ; % print the Rutherford/Boeing type mattype = '' ; if (mtype (1) == 'r') mattype = 'real' ; elseif (mtype (1) == 'c') mattype = 'complex' ; elseif (mtype (1) == 'i') mattype = 'integer' ; elseif (mtype (1) == 'p') mattype = 'binary' ; end if (mtype (2) == 'r') mattype = [mattype ' rectangular'] ; %#ok elseif (mtype (2) == 'u') mattype = [mattype ' unsymmetric'] ; %#ok elseif (mtype (2) == 's') mattype = [mattype ' symmetric'] ; %#ok elseif (mtype (2) == 'h') mattype = [mattype ' Hermitian'] ; %#ok elseif (mtype (2) == 'z') mattype = [mattype ' skew-symmetric'] ; %#ok end fprintf (f, '\n', mattype) ; % numerical symmetry (as a percentage) if (sym == -1) fprintf (f, '\n') ; elseif (sym == 1) fprintf (f, '\n') ; elseif (nrows ~= ncols) fprintf (f, '\n') ; else if (sym > 0 && sym < 0.01) fprintf (f, '\n', sym * 100) ; else fprintf (f, '\n', sym * 100) ; end end % positive definite? fprintf (f, '\n', ss) ; fprintf (f, '\n\n') ; end fprintf (f, '
    thumbnailGroup\n') ; fprintf (f, 'and Nameiddownload# rows# colsnonzerostypesymspd?thumbnailGroup\n', loc) ; fprintf (f, 'and Nameiddownload# rows# colsnonzerostypesymspd?
    \n') ; if (by_group) fprintf (f, '%s/%s\n', name) ; else fprintf (f, '%s/%s\n', group, name) ; end fprintf (f, '%s/', group) ; else fprintf (f, '%s/', group, group); end % name if (by_group) fprintf (f, '%s%d\n') ; fprintf (f, 'MAT', loc, group, name) ; fprintf (f, ', MM', loc, group, name) ; fprintf (f, ', RB', loc, group, name) ; fprintf (f, '%s%s%s%s?yes-%5.2f%%%5.0f%%%s
    \n\n') ; fprintf (f, '

    Maintained by '); fprintf (f, 'Tim Davis, last updated %s.', date) ; fprintf (f, '
    Matrix pictures by cspy, a MATLAB', ... url) ; fprintf (f, ' function in the CSparse package.\n', ... url) ; fprintf (f, '
    See UFget to download directly', ... url) ; fprintf (f, ' into MATLAB.') ; fprintf (f, '\n') ; fprintf (f, '\n') ; fclose (f) ;