pnmatrix 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/nmatrix/binary_format.txt +53 -0
- data/ext/nmatrix/data/complex.h +388 -0
- data/ext/nmatrix/data/data.cpp +274 -0
- data/ext/nmatrix/data/data.h +651 -0
- data/ext/nmatrix/data/meta.h +64 -0
- data/ext/nmatrix/data/ruby_object.h +386 -0
- data/ext/nmatrix/extconf.rb +70 -0
- data/ext/nmatrix/math/asum.h +99 -0
- data/ext/nmatrix/math/cblas_enums.h +36 -0
- data/ext/nmatrix/math/cblas_templates_core.h +507 -0
- data/ext/nmatrix/math/gemm.h +241 -0
- data/ext/nmatrix/math/gemv.h +178 -0
- data/ext/nmatrix/math/getrf.h +255 -0
- data/ext/nmatrix/math/getrs.h +121 -0
- data/ext/nmatrix/math/imax.h +82 -0
- data/ext/nmatrix/math/laswp.h +165 -0
- data/ext/nmatrix/math/long_dtype.h +62 -0
- data/ext/nmatrix/math/magnitude.h +54 -0
- data/ext/nmatrix/math/math.h +751 -0
- data/ext/nmatrix/math/nrm2.h +165 -0
- data/ext/nmatrix/math/rot.h +117 -0
- data/ext/nmatrix/math/rotg.h +106 -0
- data/ext/nmatrix/math/scal.h +71 -0
- data/ext/nmatrix/math/trsm.h +336 -0
- data/ext/nmatrix/math/util.h +162 -0
- data/ext/nmatrix/math.cpp +1368 -0
- data/ext/nmatrix/nm_memory.h +60 -0
- data/ext/nmatrix/nmatrix.cpp +285 -0
- data/ext/nmatrix/nmatrix.h +476 -0
- data/ext/nmatrix/ruby_constants.cpp +151 -0
- data/ext/nmatrix/ruby_constants.h +106 -0
- data/ext/nmatrix/ruby_nmatrix.c +3130 -0
- data/ext/nmatrix/storage/common.cpp +77 -0
- data/ext/nmatrix/storage/common.h +183 -0
- data/ext/nmatrix/storage/dense/dense.cpp +1096 -0
- data/ext/nmatrix/storage/dense/dense.h +129 -0
- data/ext/nmatrix/storage/list/list.cpp +1628 -0
- data/ext/nmatrix/storage/list/list.h +138 -0
- data/ext/nmatrix/storage/storage.cpp +730 -0
- data/ext/nmatrix/storage/storage.h +99 -0
- data/ext/nmatrix/storage/yale/class.h +1139 -0
- data/ext/nmatrix/storage/yale/iterators/base.h +143 -0
- data/ext/nmatrix/storage/yale/iterators/iterator.h +131 -0
- data/ext/nmatrix/storage/yale/iterators/row.h +450 -0
- data/ext/nmatrix/storage/yale/iterators/row_stored.h +140 -0
- data/ext/nmatrix/storage/yale/iterators/row_stored_nd.h +169 -0
- data/ext/nmatrix/storage/yale/iterators/stored_diagonal.h +124 -0
- data/ext/nmatrix/storage/yale/math/transpose.h +110 -0
- data/ext/nmatrix/storage/yale/yale.cpp +2074 -0
- data/ext/nmatrix/storage/yale/yale.h +203 -0
- data/ext/nmatrix/types.h +55 -0
- data/ext/nmatrix/util/io.cpp +279 -0
- data/ext/nmatrix/util/io.h +115 -0
- data/ext/nmatrix/util/sl_list.cpp +627 -0
- data/ext/nmatrix/util/sl_list.h +144 -0
- data/ext/nmatrix/util/util.h +78 -0
- data/lib/nmatrix/blas.rb +378 -0
- data/lib/nmatrix/cruby/math.rb +744 -0
- data/lib/nmatrix/enumerate.rb +253 -0
- data/lib/nmatrix/homogeneous.rb +241 -0
- data/lib/nmatrix/io/fortran_format.rb +138 -0
- data/lib/nmatrix/io/harwell_boeing.rb +221 -0
- data/lib/nmatrix/io/market.rb +263 -0
- data/lib/nmatrix/io/point_cloud.rb +189 -0
- data/lib/nmatrix/jruby/decomposition.rb +24 -0
- data/lib/nmatrix/jruby/enumerable.rb +13 -0
- data/lib/nmatrix/jruby/error.rb +4 -0
- data/lib/nmatrix/jruby/math.rb +501 -0
- data/lib/nmatrix/jruby/nmatrix_java.rb +840 -0
- data/lib/nmatrix/jruby/operators.rb +283 -0
- data/lib/nmatrix/jruby/slice.rb +264 -0
- data/lib/nmatrix/lapack_core.rb +181 -0
- data/lib/nmatrix/lapack_plugin.rb +44 -0
- data/lib/nmatrix/math.rb +953 -0
- data/lib/nmatrix/mkmf.rb +100 -0
- data/lib/nmatrix/monkeys.rb +137 -0
- data/lib/nmatrix/nmatrix.rb +1172 -0
- data/lib/nmatrix/rspec.rb +75 -0
- data/lib/nmatrix/shortcuts.rb +1163 -0
- data/lib/nmatrix/version.rb +39 -0
- data/lib/nmatrix/yale_functions.rb +118 -0
- data/lib/nmatrix.rb +28 -0
- data/spec/00_nmatrix_spec.rb +892 -0
- data/spec/01_enum_spec.rb +196 -0
- data/spec/02_slice_spec.rb +407 -0
- data/spec/03_nmatrix_monkeys_spec.rb +80 -0
- data/spec/2x2_dense_double.mat +0 -0
- data/spec/4x4_sparse.mat +0 -0
- data/spec/4x5_dense.mat +0 -0
- data/spec/blas_spec.rb +215 -0
- data/spec/elementwise_spec.rb +311 -0
- data/spec/homogeneous_spec.rb +100 -0
- data/spec/io/fortran_format_spec.rb +88 -0
- data/spec/io/harwell_boeing_spec.rb +98 -0
- data/spec/io/test.rua +9 -0
- data/spec/io_spec.rb +159 -0
- data/spec/lapack_core_spec.rb +482 -0
- data/spec/leakcheck.rb +16 -0
- data/spec/math_spec.rb +1363 -0
- data/spec/nmatrix_yale_resize_test_associations.yaml +2802 -0
- data/spec/nmatrix_yale_spec.rb +286 -0
- data/spec/rspec_monkeys.rb +56 -0
- data/spec/rspec_spec.rb +35 -0
- data/spec/shortcuts_spec.rb +474 -0
- data/spec/slice_set_spec.rb +162 -0
- data/spec/spec_helper.rb +172 -0
- data/spec/stat_spec.rb +214 -0
- data/spec/test.pcd +20 -0
- data/spec/utm5940.mtx +83844 -0
- metadata +295 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
# = NMatrix
|
2
|
+
#
|
3
|
+
# A linear algebra library for scientific computation in Ruby.
|
4
|
+
# NMatrix is part of SciRuby.
|
5
|
+
#
|
6
|
+
# NMatrix was originally inspired by and derived from NArray, by
|
7
|
+
# Masahiro Tanaka: http://narray.rubyforge.org
|
8
|
+
#
|
9
|
+
# == Copyright Information
|
10
|
+
#
|
11
|
+
# SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
|
12
|
+
# NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
|
13
|
+
#
|
14
|
+
# Please see LICENSE.txt for additional copyright notices.
|
15
|
+
#
|
16
|
+
# == Contributing
|
17
|
+
#
|
18
|
+
# By contributing source code to SciRuby, you agree to be bound by
|
19
|
+
# our Contributor Agreement:
|
20
|
+
#
|
21
|
+
# * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
22
|
+
#
|
23
|
+
# == fortran_format_spec.rb
|
24
|
+
#
|
25
|
+
# Basic tests for NMatrix::IO::FortranFormat.
|
26
|
+
#
|
27
|
+
|
28
|
+
require './lib/nmatrix'
|
29
|
+
|
30
|
+
describe NMatrix::IO::FortranFormat do
|
31
|
+
it "parses integer FORTRAN formats" do
|
32
|
+
int_fmt = NMatrix::IO::FortranFormat::Reader.new('(16I5)').parse
|
33
|
+
|
34
|
+
expect(int_fmt[:format_code]).to eq "INT_ID"
|
35
|
+
expect(int_fmt[:repeat]) .to eq 16
|
36
|
+
expect(int_fmt[:field_width]).to eq 5
|
37
|
+
|
38
|
+
int_fmt = NMatrix::IO::FortranFormat::Reader.new('(I4)').parse
|
39
|
+
|
40
|
+
expect(int_fmt[:format_code]).to eq "INT_ID"
|
41
|
+
expect(int_fmt[:field_width]).to eq 4
|
42
|
+
end
|
43
|
+
|
44
|
+
it "parses floating point FORTRAN formats" do
|
45
|
+
fp_fmt = NMatrix::IO::FortranFormat::Reader.new('(10F7.1)').parse
|
46
|
+
|
47
|
+
expect(fp_fmt[:format_code]) .to eq "FP_ID"
|
48
|
+
expect(fp_fmt[:repeat]) .to eq 10
|
49
|
+
expect(fp_fmt[:field_width]) .to eq 7
|
50
|
+
expect(fp_fmt[:post_decimal_width]).to eq 1
|
51
|
+
|
52
|
+
fp_fmt = NMatrix::IO::FortranFormat::Reader.new('(F4.2)').parse
|
53
|
+
|
54
|
+
expect(fp_fmt[:format_code]) .to eq "FP_ID"
|
55
|
+
expect(fp_fmt[:field_width]) .to eq 4
|
56
|
+
expect(fp_fmt[:post_decimal_width]).to eq 2
|
57
|
+
end
|
58
|
+
|
59
|
+
it "parses exponential FORTRAN formats" do
|
60
|
+
exp_fmt = NMatrix::IO::FortranFormat::Reader.new('(2E8.3E3)').parse
|
61
|
+
|
62
|
+
expect(exp_fmt[:format_code]) .to eq "EXP_ID"
|
63
|
+
expect(exp_fmt[:repeat]) .to eq 2
|
64
|
+
expect(exp_fmt[:field_width]) .to eq 8
|
65
|
+
expect(exp_fmt[:post_decimal_width]).to eq 3
|
66
|
+
expect(exp_fmt[:exponent_width]) .to eq 3
|
67
|
+
|
68
|
+
exp_fmt = NMatrix::IO::FortranFormat::Reader.new('(3E3.6)').parse
|
69
|
+
|
70
|
+
expect(exp_fmt[:format_code]) .to eq "EXP_ID"
|
71
|
+
expect(exp_fmt[:repeat]) .to eq 3
|
72
|
+
expect(exp_fmt[:field_width]) .to eq 3
|
73
|
+
expect(exp_fmt[:post_decimal_width]).to eq 6
|
74
|
+
|
75
|
+
exp_fmt = NMatrix::IO::FortranFormat::Reader.new('(E4.5)').parse
|
76
|
+
expect(exp_fmt[:format_code]) .to eq "EXP_ID"
|
77
|
+
expect(exp_fmt[:field_width]) .to eq 4
|
78
|
+
expect(exp_fmt[:post_decimal_width]).to eq 5
|
79
|
+
end
|
80
|
+
|
81
|
+
['I3', '(F4)', '(E3.', '(E4.E5)'].each do |bad_format|
|
82
|
+
it "doesn't let bad input through : #{bad_format}" do
|
83
|
+
expect {
|
84
|
+
NMatrix::IO::FortranFormat::Reader.new(bad_format).parse
|
85
|
+
}.to raise_error(IOError)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# = NMatrix
|
2
|
+
#
|
3
|
+
# A linear algebra library for scientific computation in Ruby.
|
4
|
+
# NMatrix is part of SciRuby.
|
5
|
+
#
|
6
|
+
# NMatrix was originally inspired by and derived from NArray, by
|
7
|
+
# Masahiro Tanaka: http://narray.rubyforge.org
|
8
|
+
#
|
9
|
+
# == Copyright Information
|
10
|
+
#
|
11
|
+
# SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
|
12
|
+
# NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
|
13
|
+
#
|
14
|
+
# Please see LICENSE.txt for additional copyright notices.
|
15
|
+
#
|
16
|
+
# == Contributing
|
17
|
+
#
|
18
|
+
# By contributing source code to SciRuby, you agree to be bound by
|
19
|
+
# our Contributor Agreement:
|
20
|
+
#
|
21
|
+
# * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
22
|
+
#
|
23
|
+
# == io_spec.rb
|
24
|
+
#
|
25
|
+
# Basic tests for NMatrix::IO::HarwelBoeing.
|
26
|
+
|
27
|
+
# TODO : After the fortran format thing is done
|
28
|
+
require 'spec_helper'
|
29
|
+
require "./lib/nmatrix"
|
30
|
+
|
31
|
+
describe NMatrix::IO::HarwellBoeing do
|
32
|
+
def check_file_header header
|
33
|
+
expect(header[:title]) .to eq("Title")
|
34
|
+
expect(header[:key]) .to eq("Key")
|
35
|
+
|
36
|
+
expect(header[:totcrd]) .to eq(5)
|
37
|
+
expect(header[:ptrcrd]) .to eq(1)
|
38
|
+
expect(header[:indcrd]) .to eq(1)
|
39
|
+
expect(header[:valcrd]) .to eq(3)
|
40
|
+
expect(header[:rhscrd]) .to eq(0)
|
41
|
+
|
42
|
+
expect(header[:mxtype]) .to eq('RUA')
|
43
|
+
expect(header[:nrow]) .to eq(5)
|
44
|
+
expect(header[:ncol]) .to eq(5)
|
45
|
+
expect(header[:nnzero]) .to eq(13)
|
46
|
+
expect(header[:neltvl]) .to eq(0)
|
47
|
+
|
48
|
+
expect(header[:ptrfmt]) .to eq({
|
49
|
+
format_code: "INT_ID",
|
50
|
+
repeat: 6,
|
51
|
+
field_width: 3
|
52
|
+
})
|
53
|
+
expect(header[:indfmt]) .to eq({
|
54
|
+
format_code: "INT_ID",
|
55
|
+
repeat: 13,
|
56
|
+
field_width: 3
|
57
|
+
})
|
58
|
+
expect(header[:valfmt]) .to eq({
|
59
|
+
format_code: "EXP_ID",
|
60
|
+
repeat: 5,
|
61
|
+
field_width: 15,
|
62
|
+
post_decimal_width: 8
|
63
|
+
})
|
64
|
+
expect(header[:rhsfmt]) .to eq({
|
65
|
+
format_code: "EXP_ID",
|
66
|
+
repeat: 5,
|
67
|
+
field_width: 15,
|
68
|
+
post_decimal_width: 8
|
69
|
+
})
|
70
|
+
end
|
71
|
+
|
72
|
+
it "loads a Harwell Boeing file values and header (currently real only)" do
|
73
|
+
n, h = NMatrix::IO::HarwellBoeing.load("spec/io/test.rua")
|
74
|
+
|
75
|
+
expect(n.is_a? NMatrix).to eq(true)
|
76
|
+
expect(n.cols) .to eq(5)
|
77
|
+
expect(n.rows) .to eq(5)
|
78
|
+
|
79
|
+
expect(n[0,0]) .to eq(11)
|
80
|
+
expect(n[4,4]) .to eq(55)
|
81
|
+
|
82
|
+
expect(h.is_a? Hash).to eq(true)
|
83
|
+
check_file_header(h)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "loads only the header of the file when specified" do
|
87
|
+
h = NMatrix::IO::HarwellBoeing.load("spec/io/test.rua", header: true)
|
88
|
+
|
89
|
+
expect(h.is_a? Hash).to eq(true)
|
90
|
+
check_file_header(h)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "raises error for wrong Harwell Boeing file name" do
|
94
|
+
expect{
|
95
|
+
NMatrix::IO::HarwellBoeing.load("spec/io/wrong.afx")
|
96
|
+
}.to raise_error(IOError)
|
97
|
+
end
|
98
|
+
end
|
data/spec/io/test.rua
ADDED
data/spec/io_spec.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# = NMatrix
|
2
|
+
#
|
3
|
+
# A linear algebra library for scientific computation in Ruby.
|
4
|
+
# NMatrix is part of SciRuby.
|
5
|
+
#
|
6
|
+
# NMatrix was originally inspired by and derived from NArray, by
|
7
|
+
# Masahiro Tanaka: http://narray.rubyforge.org
|
8
|
+
#
|
9
|
+
# == Copyright Information
|
10
|
+
#
|
11
|
+
# SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
|
12
|
+
# NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
|
13
|
+
#
|
14
|
+
# Please see LICENSE.txt for additional copyright notices.
|
15
|
+
#
|
16
|
+
# == Contributing
|
17
|
+
#
|
18
|
+
# By contributing source code to SciRuby, you agree to be bound by
|
19
|
+
# our Contributor Agreement:
|
20
|
+
#
|
21
|
+
# * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
22
|
+
#
|
23
|
+
# == io_spec.rb
|
24
|
+
#
|
25
|
+
# Basic tests for NMatrix::IO.
|
26
|
+
#
|
27
|
+
require "tmpdir" # Used to avoid cluttering the repository.
|
28
|
+
require 'spec_helper'
|
29
|
+
require "./lib/nmatrix"
|
30
|
+
|
31
|
+
describe NMatrix::IO do
|
32
|
+
let(:tmp_dir) { Dir.mktmpdir }
|
33
|
+
let(:test_out) { File.join(tmp_dir, 'test-out') }
|
34
|
+
|
35
|
+
it "repacks a string" do
|
36
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
37
|
+
expect(NMatrix::IO::Matlab.repack("hello", :miUINT8, :byte)).to eq("hello")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "creates yale from internal byte-string function" do
|
41
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
42
|
+
ia = NMatrix::IO::Matlab.repack("\0\1\3\3\4", :miUINT8, :itype)
|
43
|
+
ja = NMatrix::IO::Matlab.repack("\0\1\3\0\0\0\0\0\0\0\0", :miUINT8, :itype)
|
44
|
+
n = NMatrix.new(:yale, [4,4], :byte, ia, ja, "\2\3\5\4", :byte)
|
45
|
+
expect(n[0,0]).to eq(2)
|
46
|
+
expect(n[1,1]).to eq(3)
|
47
|
+
expect(n[1,3]).to eq(5)
|
48
|
+
expect(n[3,0]).to eq(4)
|
49
|
+
expect(n[2,2]).to eq(0)
|
50
|
+
expect(n[3,3]).to eq(0)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "reads MATLAB .mat file containing a single square sparse matrix" do
|
54
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
55
|
+
n = NMatrix::IO::Matlab.load_mat("spec/4x4_sparse.mat")
|
56
|
+
expect(n[0,0]).to eq(2)
|
57
|
+
expect(n[1,1]).to eq(3)
|
58
|
+
expect(n[1,3]).to eq(5)
|
59
|
+
expect(n[3,0]).to eq(4)
|
60
|
+
expect(n[2,2]).to eq(0)
|
61
|
+
expect(n[3,3]).to eq(0)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "reads MATLAB .mat file containing a single dense integer matrix" do
|
65
|
+
n = NMatrix::IO::Matlab.load_mat("spec/4x5_dense.mat")
|
66
|
+
m = NMatrix.new([4,5], [16,17,18,19,20,15,14,13,12,11,6,7,8,9,10,5,4,3,2,1])
|
67
|
+
expect(n).to eq(m)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "reads MATLAB .mat file containing a single dense double matrix" do
|
71
|
+
n = NMatrix::IO::Matlab.load_mat("spec/2x2_dense_double.mat")
|
72
|
+
m = NMatrix.new(2, [1.1, 2.0, 3.0, 4.0], dtype: :float64)
|
73
|
+
expect(n).to eq(m)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "loads and saves MatrixMarket .mtx file containing a single large sparse double matrix" do
|
77
|
+
pending "spec disabled because it's so slow"
|
78
|
+
n = NMatrix::IO::Market.load("spec/utm5940.mtx")
|
79
|
+
NMatrix::IO::Market.save(n, "spec/utm5940.saved.mtx")
|
80
|
+
expect(`wc -l spec/utm5940.mtx`.split[0]).to eq(`wc -l spec/utm5940.saved.mtx`.split[0])
|
81
|
+
end
|
82
|
+
|
83
|
+
it "loads a Point Cloud Library PCD file" do
|
84
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
85
|
+
n = NMatrix::IO::PointCloud.load("spec/test.pcd")
|
86
|
+
expect(n.column(0).sort.uniq.size).to eq(1)
|
87
|
+
expect(n.column(0).sort.uniq.first).to eq(207.008)
|
88
|
+
expect(n[0,3]).to eq(0)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "raises an error when reading a non-existent file" do
|
92
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
93
|
+
fn = rand(10000000).to_i.to_s
|
94
|
+
while File.exist?(fn)
|
95
|
+
fn = rand(10000000).to_i.to_s
|
96
|
+
end
|
97
|
+
expect{ NMatrix.read(fn) }.to raise_error(Errno::ENOENT)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "reads and writes NMatrix dense" do
|
101
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
102
|
+
n = NMatrix.new(:dense, [4,3], [0,1,2,3,4,5,6,7,8,9,10,11], :int32)
|
103
|
+
n.write(test_out)
|
104
|
+
|
105
|
+
m = NMatrix.read(test_out)
|
106
|
+
expect(n).to eq(m)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "reads and writes NMatrix dense as symmetric" do
|
110
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
111
|
+
n = NMatrix.new(:dense, 3, [0,1,2,1,3,4,2,4,5], :int16)
|
112
|
+
n.write(test_out, :symmetric)
|
113
|
+
|
114
|
+
m = NMatrix.read(test_out)
|
115
|
+
expect(n).to eq(m)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "reads and writes NMatrix dense as skew" do
|
119
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
120
|
+
n = NMatrix.new(:dense, 3, [0,1,2,-1,3,4,-2,-4,5], :float64)
|
121
|
+
n.write(test_out, :skew)
|
122
|
+
|
123
|
+
m = NMatrix.read(test_out)
|
124
|
+
expect(n).to eq(m)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "reads and writes NMatrix dense as hermitian" do
|
128
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
129
|
+
n = NMatrix.new(:dense, 3, [0,1,2,1,3,4,2,4,5], :complex64)
|
130
|
+
n.write(test_out, :hermitian)
|
131
|
+
|
132
|
+
m = NMatrix.read(test_out)
|
133
|
+
expect(n).to eq(m)
|
134
|
+
end
|
135
|
+
|
136
|
+
it "reads and writes NMatrix dense as upper" do
|
137
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
138
|
+
n = NMatrix.new(:dense, 3, [-1,1,2,3,4,5,6,7,8], :int32)
|
139
|
+
n.write(test_out, :upper)
|
140
|
+
|
141
|
+
m = NMatrix.new(:dense, 3, [-1,1,2,0,4,5,0,0,8], :int32) # lower version of the same
|
142
|
+
|
143
|
+
o = NMatrix.read(test_out)
|
144
|
+
expect(o).to eq(m)
|
145
|
+
expect(o).not_to eq(n)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "reads and writes NMatrix dense as lower" do
|
149
|
+
pending("not yet implemented for NMatrix-JRuby") if jruby?
|
150
|
+
n = NMatrix.new(:dense, 3, [-1,1,2,3,4,5,6,7,8], :int32)
|
151
|
+
n.write(test_out, :lower)
|
152
|
+
|
153
|
+
m = NMatrix.new(:dense, 3, [-1,0,0,3,4,0,6,7,8], :int32) # lower version of the same
|
154
|
+
|
155
|
+
o = NMatrix.read(test_out)
|
156
|
+
expect(o).to eq(m)
|
157
|
+
expect(o).not_to eq(n)
|
158
|
+
end
|
159
|
+
end
|