|
kusano |
7d535a |
function [A,xy,B,hbtype,rhstype] = hbo(file)
|
|
kusano |
7d535a |
%HBO Read and process a Harwell-Boeing sparse matrix file.
|
|
kusano |
7d535a |
% A = HBO('matfile') gets the sparse matrix from the specified .mat file.
|
|
kusano |
7d535a |
%
|
|
kusano |
7d535a |
% [A,xy,B,hbtype,rhstype] = HBO('matfile') also gets:
|
|
kusano |
7d535a |
% xy: node coordinates (if present)
|
|
kusano |
7d535a |
% B: right-hand sides, starting guesses, or exact solutions (if present)
|
|
kusano |
7d535a |
% hbtype: matrix type, which will be one of the following three-letter
|
|
kusano |
7d535a |
% codes: CSA, PRA, PSA, PSE, PUA, RRA, RSA, RUA, RZA, UNK
|
|
kusano |
7d535a |
% rhstype: a description of B, for which see the user's guide.
|
|
kusano |
7d535a |
%
|
|
kusano |
7d535a |
% In addition to reading the file, HBO assembles any unassembled matrices,
|
|
kusano |
7d535a |
% symmetrizes any symmetric matrices, and implicitizes any explicit zeros.
|
|
kusano |
7d535a |
%
|
|
kusano |
7d535a |
% HBO .mat files are created from Harwell-Boeing data files by the
|
|
kusano |
7d535a |
% stand-alone Fortran process, HBO2MAT. These .mat files contain:
|
|
kusano |
7d535a |
%
|
|
kusano |
7d535a |
% For assembled, type xxA, matrices:
|
|
kusano |
7d535a |
% A - the sparse matrix.
|
|
kusano |
7d535a |
% hbtitle - The first 72 characters of the first "card".
|
|
kusano |
7d535a |
% hbname - The matrix name, same as file name without .mat.
|
|
kusano |
7d535a |
% hbtype - One of those three letter codes.
|
|
kusano |
7d535a |
% hbfill - If present, the value inserted in pattern matrices.
|
|
kusano |
7d535a |
% hbzero - If present, the value inserted for explicit zeros.
|
|
kusano |
7d535a |
% rhstype - If present, the right hand side type.
|
|
kusano |
7d535a |
% xy - If present, a matrix whose rows are node coordinates.
|
|
kusano |
7d535a |
% B - If present, a matrix whose columns are right-hand
|
|
kusano |
7d535a |
% sides, etc.
|
|
kusano |
7d535a |
%
|
|
kusano |
7d535a |
% For unassembled, xxE, matrices:
|
|
kusano |
7d535a |
% hbtitle - The first 72 characters of the first "card".
|
|
kusano |
7d535a |
% hbname - The matrix name, same as file name without .mat.
|
|
kusano |
7d535a |
% hbtype - Only type PSE exists in current collection.
|
|
kusano |
7d535a |
% varind and elptr - The indices specifying the locations
|
|
kusano |
7d535a |
% of the constituent elements.
|
|
kusano |
7d535a |
%
|
|
kusano |
7d535a |
% Say "help harwell" for more information about the collection.
|
|
kusano |
7d535a |
% See also HBOLIST, HBOFIND.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% Cleve Moler, The MathWorks, 4/2/94.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
load(file)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ~exist('hbtype')
|
|
kusano |
7d535a |
hbtype = 'UNK';
|
|
kusano |
7d535a |
A = A;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% PSE - Pattern symmetric unassembled
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'PSE')
|
|
kusano |
7d535a |
n1 = length(elptr);
|
|
kusano |
7d535a |
elptr(n1) = [];
|
|
kusano |
7d535a |
J = varind;
|
|
kusano |
7d535a |
I = zeros(size(J));
|
|
kusano |
7d535a |
I(elptr) = ones(size(elptr));
|
|
kusano |
7d535a |
I = cumsum(I);
|
|
kusano |
7d535a |
A = sparse(I,J,1);
|
|
kusano |
7d535a |
A = A'*A;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% RSA - Real symmetric
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'RSA')
|
|
kusano |
7d535a |
A = A + A' - diag(diag(A));
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% RZA - Real skew symmetric
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'RZA')
|
|
kusano |
7d535a |
A = A - A';
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% RUA - Real unsymmetric
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'RUA')
|
|
kusano |
7d535a |
A = A;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% RRA - Real rectangular
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'RRA')
|
|
kusano |
7d535a |
A = A;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% CSA - Complex symmetric
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'CSA')
|
|
kusano |
7d535a |
A = A + A' - diag(diag(A));
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% PSA - Pattern symmetric
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'PSA')
|
|
kusano |
7d535a |
A = A + A' - diag(diag(A));
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% PUA - Pattern unsymmetric
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'PUA')
|
|
kusano |
7d535a |
A = A;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% PRA - Pattern rectangular
|
|
kusano |
7d535a |
elseif strcmp(hbtype,'PRA')
|
|
kusano |
7d535a |
A = A;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
else
|
|
kusano |
7d535a |
error(['Harwell-Boeing type ' hbtype ' unexpected.'])
|
|
kusano |
7d535a |
end
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% Remove any explict zeros
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if exist('hbzero')
|
|
kusano |
7d535a |
k = find(A == hbzero);
|
|
kusano |
7d535a |
A(k) = sparse(length(k),1);
|
|
kusano |
7d535a |
end
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
% Get any right-hand side vectors or coordinates.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if exist('xyz')
|
|
kusano |
7d535a |
xy = xyz;
|
|
kusano |
7d535a |
end;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ~exist('xy')
|
|
kusano |
7d535a |
xy = [];
|
|
kusano |
7d535a |
end;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ~exist('B')
|
|
kusano |
7d535a |
B = [];
|
|
kusano |
7d535a |
rhstype = 'NON';
|
|
kusano |
7d535a |
end;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ~exist('rhstype')
|
|
kusano |
7d535a |
rhstype = 'UNK';
|
|
kusano |
7d535a |
end;
|