File: hbo.m

package info (click to toggle)
superlu 4.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,100 kB
  • ctags: 6,351
  • sloc: ansic: 61,952; makefile: 398; csh: 141; fortran: 108; sh: 14
file content (119 lines) | stat: -rw-r--r-- 3,296 bytes parent folder | download | duplicates (9)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
function [A,xy,B,hbtype,rhstype] = hbo(file)
%HBO	Read and process a Harwell-Boeing sparse matrix file.
%	A = HBO('matfile') gets the sparse matrix from the specified .mat file.
%
%	[A,xy,B,hbtype,rhstype] = HBO('matfile') also gets:
%       xy: node coordinates (if present)
%       B:  right-hand sides, starting guesses, or exact solutions (if present)
%       hbtype: matrix type, which will be one of the following three-letter
%	        codes: CSA, PRA, PSA, PSE, PUA, RRA, RSA, RUA, RZA, UNK
%       rhstype: a description of B, for which see the user's guide.
%
%	In addition to reading the file, HBO assembles any unassembled matrices,
%	symmetrizes any symmetric matrices, and implicitizes any explicit zeros.
%
%	HBO .mat files are created from Harwell-Boeing data files by the
%	stand-alone Fortran process, HBO2MAT.  These .mat files contain:
%
%	    For assembled, type xxA, matrices:
%	        A       - the sparse matrix.
%	        hbtitle - The first 72 characters of the first "card".
%	        hbname  - The matrix name, same as file name without .mat.
%	        hbtype  - One of those three letter codes.
%	        hbfill  - If present, the value inserted in pattern matrices.
%	        hbzero  - If present, the value inserted for explicit zeros.
%	        rhstype - If present, the right hand side type.
%               xy      - If present, a matrix whose rows are node coordinates.
%               B       - If present, a matrix whose columns are right-hand
%                         sides, etc.
%
%	    For unassembled, xxE, matrices:
%	        hbtitle - The first 72 characters of the first "card".
%	        hbname  - The matrix name, same as file name without .mat.
%	        hbtype  - Only type PSE exists in current collection.
%	        varind and elptr - The indices specifying the locations
%	            of the constituent elements.
%
%  Say "help harwell" for more information about the collection.
%  See also HBOLIST, HBOFIND.

%	Cleve Moler, The MathWorks, 4/2/94.

load(file)

if ~exist('hbtype')
   hbtype = 'UNK';
   A = A;

% PSE  - Pattern symmetric unassembled
elseif strcmp(hbtype,'PSE')
   n1 = length(elptr);
   elptr(n1) = [];
   J = varind;
   I = zeros(size(J));
   I(elptr) = ones(size(elptr));
   I = cumsum(I);
   A = sparse(I,J,1);
   A = A'*A;

% RSA  - Real symmetric
elseif strcmp(hbtype,'RSA')
   A = A + A' - diag(diag(A));

% RZA  - Real skew symmetric
elseif strcmp(hbtype,'RZA')
   A = A - A';

% RUA  - Real unsymmetric
elseif strcmp(hbtype,'RUA')
   A = A;

% RRA  - Real rectangular
elseif strcmp(hbtype,'RRA')
   A = A;

% CSA  - Complex symmetric
elseif strcmp(hbtype,'CSA')
   A = A + A' - diag(diag(A));

% PSA  - Pattern symmetric
elseif strcmp(hbtype,'PSA')
   A = A + A' - diag(diag(A));

% PUA  - Pattern unsymmetric
elseif strcmp(hbtype,'PUA')
   A = A;

% PRA  - Pattern rectangular
elseif strcmp(hbtype,'PRA')
   A = A;

else
   error(['Harwell-Boeing type ' hbtype ' unexpected.'])
end

% Remove any explict zeros

if exist('hbzero')
   k = find(A == hbzero);
   A(k) = sparse(length(k),1);
end

% Get any right-hand side vectors or coordinates.

if exist('xyz')
    xy = xyz;
end;

if ~exist('xy')
    xy = [];
end;

if ~exist('B')
    B = [];
    rhstype = 'NON';
end;

if ~exist('rhstype')
    rhstype = 'UNK';
end;