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
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/nmatrix/io/harwell_boeing.rb', line 89
def
return @header if !@header.empty?
@file = File.open @file_name, "r"
line = @file.gets
@header[:title] = line[0...72].strip
@header[:key] = line[72...80].strip
line = @file.gets
@header[:totcrd] = line[0...14] .strip.to_i
@header[:ptrcrd] = line[14...28].strip.to_i
@header[:indcrd] = line[28...42].strip.to_i
@header[:valcrd] = line[42...56].strip.to_i
@header[:rhscrd] = line[56...70].strip.to_i
raise(IOError, "Right hand sides not supported.") if @header[:rhscrd] > 0
line = @file.gets
@header[:mxtype] = line[0...3]
raise(IOError, "Currently supports only real, assembled, unsymmetric \
matrices.") if !@header[:mxtype].match(/RUA/)
@header[:nrow] = line[13...28].strip.to_i
@header[:ncol] = line[28...42].strip.to_i
@header[:nnzero] = line[42...56].strip.to_i
@header[:neltvl] = line[56...70].strip.to_i
line = @file.gets
fortran_reader = NMatrix::IO::FortranFormat::Reader
@header[:ptrfmt] = fortran_reader.new(line[0...16].strip) .parse
@header[:indfmt] = fortran_reader.new(line[16...32].strip).parse
@header[:valfmt] = fortran_reader.new(line[32...52].strip).parse
@header[:rhsfmt] = fortran_reader.new(line[52...72].strip).parse
@header
end
|