nmatrix-fftw 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/ext/nmatrix/data/complex.h +388 -0
  3. data/ext/nmatrix/data/data.h +652 -0
  4. data/ext/nmatrix/data/meta.h +64 -0
  5. data/ext/nmatrix/data/ruby_object.h +389 -0
  6. data/ext/nmatrix/math/asum.h +120 -0
  7. data/ext/nmatrix/math/cblas_enums.h +36 -0
  8. data/ext/nmatrix/math/cblas_templates_core.h +507 -0
  9. data/ext/nmatrix/math/gemm.h +241 -0
  10. data/ext/nmatrix/math/gemv.h +178 -0
  11. data/ext/nmatrix/math/getrf.h +255 -0
  12. data/ext/nmatrix/math/getrs.h +121 -0
  13. data/ext/nmatrix/math/imax.h +79 -0
  14. data/ext/nmatrix/math/laswp.h +165 -0
  15. data/ext/nmatrix/math/long_dtype.h +49 -0
  16. data/ext/nmatrix/math/math.h +745 -0
  17. data/ext/nmatrix/math/nrm2.h +160 -0
  18. data/ext/nmatrix/math/rot.h +117 -0
  19. data/ext/nmatrix/math/rotg.h +106 -0
  20. data/ext/nmatrix/math/scal.h +71 -0
  21. data/ext/nmatrix/math/trsm.h +332 -0
  22. data/ext/nmatrix/math/util.h +148 -0
  23. data/ext/nmatrix/nm_memory.h +60 -0
  24. data/ext/nmatrix/nmatrix.h +438 -0
  25. data/ext/nmatrix/ruby_constants.h +106 -0
  26. data/ext/nmatrix/storage/common.h +177 -0
  27. data/ext/nmatrix/storage/dense/dense.h +129 -0
  28. data/ext/nmatrix/storage/list/list.h +138 -0
  29. data/ext/nmatrix/storage/storage.h +99 -0
  30. data/ext/nmatrix/storage/yale/class.h +1139 -0
  31. data/ext/nmatrix/storage/yale/iterators/base.h +143 -0
  32. data/ext/nmatrix/storage/yale/iterators/iterator.h +131 -0
  33. data/ext/nmatrix/storage/yale/iterators/row.h +450 -0
  34. data/ext/nmatrix/storage/yale/iterators/row_stored.h +140 -0
  35. data/ext/nmatrix/storage/yale/iterators/row_stored_nd.h +169 -0
  36. data/ext/nmatrix/storage/yale/iterators/stored_diagonal.h +124 -0
  37. data/ext/nmatrix/storage/yale/math/transpose.h +110 -0
  38. data/ext/nmatrix/storage/yale/yale.h +203 -0
  39. data/ext/nmatrix/types.h +55 -0
  40. data/ext/nmatrix/util/io.h +115 -0
  41. data/ext/nmatrix/util/sl_list.h +144 -0
  42. data/ext/nmatrix/util/util.h +78 -0
  43. data/ext/nmatrix_fftw/extconf.rb +122 -0
  44. data/ext/nmatrix_fftw/nmatrix_fftw.cpp +274 -0
  45. data/lib/nmatrix/fftw.rb +343 -0
  46. data/spec/00_nmatrix_spec.rb +736 -0
  47. data/spec/01_enum_spec.rb +190 -0
  48. data/spec/02_slice_spec.rb +389 -0
  49. data/spec/03_nmatrix_monkeys_spec.rb +78 -0
  50. data/spec/2x2_dense_double.mat +0 -0
  51. data/spec/4x4_sparse.mat +0 -0
  52. data/spec/4x5_dense.mat +0 -0
  53. data/spec/blas_spec.rb +193 -0
  54. data/spec/elementwise_spec.rb +303 -0
  55. data/spec/homogeneous_spec.rb +99 -0
  56. data/spec/io/fortran_format_spec.rb +88 -0
  57. data/spec/io/harwell_boeing_spec.rb +98 -0
  58. data/spec/io/test.rua +9 -0
  59. data/spec/io_spec.rb +149 -0
  60. data/spec/lapack_core_spec.rb +482 -0
  61. data/spec/leakcheck.rb +16 -0
  62. data/spec/math_spec.rb +807 -0
  63. data/spec/nmatrix_yale_resize_test_associations.yaml +2802 -0
  64. data/spec/nmatrix_yale_spec.rb +286 -0
  65. data/spec/plugins/fftw/fftw_spec.rb +348 -0
  66. data/spec/rspec_monkeys.rb +56 -0
  67. data/spec/rspec_spec.rb +34 -0
  68. data/spec/shortcuts_spec.rb +310 -0
  69. data/spec/slice_set_spec.rb +157 -0
  70. data/spec/spec_helper.rb +149 -0
  71. data/spec/stat_spec.rb +203 -0
  72. data/spec/test.pcd +20 -0
  73. data/spec/utm5940.mtx +83844 -0
  74. metadata +151 -0
@@ -0,0 +1,99 @@
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
+ # == homogeneous_spec.rb
24
+ #
25
+ # Specs for the homogeneous transformation matrix methods.
26
+ #
27
+
28
+ require 'spec_helper'
29
+ require "./lib/nmatrix/homogeneous.rb"
30
+
31
+ require 'pry'
32
+
33
+ describe 'NMatrix' do
34
+ context ".x_rotation" do
35
+ it "should generate a matrix representing a rotation about the x axis" do
36
+ x = NMatrix.x_rotation(Math::PI/6)
37
+ expect(x).to be_within(1e-8).of(NMatrix.new([4,4], [1.0, 0.0, 0.0, 0.0,
38
+ 0.0, Math.cos(Math::PI/6), -0.5, 0.0,
39
+ 0.0, 0.5, Math.cos(Math::PI/6), 0.0,
40
+ 0.0, 0.0, 0.0, 1.0] ))
41
+ end
42
+ end
43
+
44
+
45
+ context ".y_rotation" do
46
+ it "should generate a matrix representing a rotation about the y axis" do
47
+ y = NMatrix.y_rotation(Math::PI/6)
48
+ expect(y).to be_within(1e-8).of(NMatrix.new([4,4], [Math.cos(Math::PI/6), 0.0, 0.5, 0.0,
49
+ 0.0, 1.0, 0.0, 0.0,
50
+ -0.5, 0.0, Math.cos(Math::PI/6), 0.0,
51
+ 0.0, 0.0, 0.0, 1.0] ))
52
+ end
53
+ end
54
+
55
+ context ".z_rotation" do
56
+ it "should generate a matrix representing a rotation about the z axis" do
57
+ z = NMatrix.z_rotation(Math::PI/6)
58
+ expect(z).to be_within(1e-8).of(NMatrix.new([4,4], [Math.cos(Math::PI/6), -0.5, 0.0, 0.0,
59
+ 0.5, Math.cos(Math::PI/6), 0.0, 0.0,
60
+ 0.0, 0.0, 1.0, 0.0,
61
+ 0.0, 0.0, 0.0, 1.0] ))
62
+ end
63
+ end
64
+
65
+ context ".translation" do
66
+ it "should generate a translation matrix from an Array" do
67
+ t = NMatrix.translation([4,5,6])
68
+ expect(t).to be_within(1e-8).of(NMatrix.new([4,4], [1, 0, 0, 4,
69
+ 0, 1, 0, 5,
70
+ 0, 0, 1, 6,
71
+ 0, 0, 0, 1] ))
72
+ end
73
+
74
+ it "should generate a translation matrix from x, y, and z values" do
75
+ t = NMatrix.translation(4,5,6)
76
+ expect(t).to be_within(1e-8).of(NMatrix.new([4,4], [1, 0, 0, 4,
77
+ 0, 1, 0, 5,
78
+ 0, 0, 1, 6,
79
+ 0, 0, 0, 1] ))
80
+ end
81
+
82
+ it "should generate a translation matrix from an NMatrix with correctly inferred dtype" do
83
+ t = NMatrix.translation(NMatrix.new([3,1], [4,5,6], dtype: :float64) )
84
+ expect(t).to be_within(1e-8).of(NMatrix.new([4,4], [1, 0, 0, 4,
85
+ 0, 1, 0, 5,
86
+ 0, 0, 1, 6,
87
+ 0, 0, 0, 1] ))
88
+ expect(t.dtype).to be(:float64)
89
+ end
90
+ end
91
+
92
+ context "#quaternion" do
93
+ it "should generate a singularity-free quaternion" do
94
+ transform = NMatrix.new([4,4], [-0.9995825,-0.02527934,-0.0139845,50.61761,-0.02732551,0.9844284,0.1736463,-22.95566,0.009376526,0.1739562,-0.9847089,7.1521,0,0,0,1])
95
+ q = transform.quaternion
96
+ expect(Math.sqrt(q[0]**2 + q[1]**2 + q[2]**2 + q[3]**2)).to be_within(1e-6).of(1.0)
97
+ end
98
+ end
99
+ end
@@ -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
@@ -0,0 +1,9 @@
1
+ Title Key
2
+ 5 1 1 3 0
3
+ RUA 5 5 13 0
4
+ (6I3) (13I3) (5E15.8) (5E15.8)
5
+ 1 4 7 8 11 14
6
+ 1 3 5 2 3 5 3 1 3 4 3 4 5
7
+ 11.0 31.0 51.0 22.0 32.0
8
+ 52.0 33.0 14.0 34.0 44.0
9
+ 35.0 45.0 55.0
data/spec/io_spec.rb ADDED
@@ -0,0 +1,149 @@
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
+ expect(NMatrix::IO::Matlab.repack("hello", :miUINT8, :byte)).to eq("hello")
37
+ end
38
+
39
+ it "creates yale from internal byte-string function" do
40
+ ia = NMatrix::IO::Matlab.repack("\0\1\3\3\4", :miUINT8, :itype)
41
+ ja = NMatrix::IO::Matlab.repack("\0\1\3\0\0\0\0\0\0\0\0", :miUINT8, :itype)
42
+ n = NMatrix.new(:yale, [4,4], :byte, ia, ja, "\2\3\5\4", :byte)
43
+ expect(n[0,0]).to eq(2)
44
+ expect(n[1,1]).to eq(3)
45
+ expect(n[1,3]).to eq(5)
46
+ expect(n[3,0]).to eq(4)
47
+ expect(n[2,2]).to eq(0)
48
+ expect(n[3,3]).to eq(0)
49
+ end
50
+
51
+ it "reads MATLAB .mat file containing a single square sparse matrix" do
52
+ # Note: same matrix as above
53
+ n = NMatrix::IO::Matlab.load_mat("spec/4x4_sparse.mat")
54
+ expect(n[0,0]).to eq(2)
55
+ expect(n[1,1]).to eq(3)
56
+ expect(n[1,3]).to eq(5)
57
+ expect(n[3,0]).to eq(4)
58
+ expect(n[2,2]).to eq(0)
59
+ expect(n[3,3]).to eq(0)
60
+ end
61
+
62
+ it "reads MATLAB .mat file containing a single dense integer matrix" do
63
+ n = NMatrix::IO::Matlab.load_mat("spec/4x5_dense.mat")
64
+ 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])
65
+ expect(n).to eq(m)
66
+ end
67
+
68
+ it "reads MATLAB .mat file containing a single dense double matrix" do
69
+ n = NMatrix::IO::Matlab.load_mat("spec/2x2_dense_double.mat")
70
+ m = NMatrix.new(2, [1.1, 2.0, 3.0, 4.0], dtype: :float64)
71
+ expect(n).to eq(m)
72
+ end
73
+
74
+ it "loads and saves MatrixMarket .mtx file containing a single large sparse double matrix" do
75
+ pending "spec disabled because it's so slow"
76
+ n = NMatrix::IO::Market.load("spec/utm5940.mtx")
77
+ NMatrix::IO::Market.save(n, "spec/utm5940.saved.mtx")
78
+ expect(`wc -l spec/utm5940.mtx`.split[0]).to eq(`wc -l spec/utm5940.saved.mtx`.split[0])
79
+ end
80
+
81
+ it "loads a Point Cloud Library PCD file" do
82
+ n = NMatrix::IO::PointCloud.load("spec/test.pcd")
83
+ expect(n.column(0).sort.uniq.size).to eq(1)
84
+ expect(n.column(0).sort.uniq.first).to eq(207.008)
85
+ expect(n[0,3]).to eq(0)
86
+ end
87
+
88
+ it "raises an error when reading a non-existent file" do
89
+ fn = rand(10000000).to_i.to_s
90
+ while File.exist?(fn)
91
+ fn = rand(10000000).to_i.to_s
92
+ end
93
+ expect{ NMatrix.read(fn) }.to raise_error(Errno::ENOENT)
94
+ end
95
+
96
+ it "reads and writes NMatrix dense" do
97
+ n = NMatrix.new(:dense, [4,3], [0,1,2,3,4,5,6,7,8,9,10,11], :int32)
98
+ n.write(test_out)
99
+
100
+ m = NMatrix.read(test_out)
101
+ expect(n).to eq(m)
102
+ end
103
+
104
+ it "reads and writes NMatrix dense as symmetric" do
105
+ n = NMatrix.new(:dense, 3, [0,1,2,1,3,4,2,4,5], :int16)
106
+ n.write(test_out, :symmetric)
107
+
108
+ m = NMatrix.read(test_out)
109
+ expect(n).to eq(m)
110
+ end
111
+
112
+ it "reads and writes NMatrix dense as skew" do
113
+ n = NMatrix.new(:dense, 3, [0,1,2,-1,3,4,-2,-4,5], :float64)
114
+ n.write(test_out, :skew)
115
+
116
+ m = NMatrix.read(test_out)
117
+ expect(n).to eq(m)
118
+ end
119
+
120
+ it "reads and writes NMatrix dense as hermitian" do
121
+ n = NMatrix.new(:dense, 3, [0,1,2,1,3,4,2,4,5], :complex64)
122
+ n.write(test_out, :hermitian)
123
+
124
+ m = NMatrix.read(test_out)
125
+ expect(n).to eq(m)
126
+ end
127
+
128
+ it "reads and writes NMatrix dense as upper" do
129
+ n = NMatrix.new(:dense, 3, [-1,1,2,3,4,5,6,7,8], :int32)
130
+ n.write(test_out, :upper)
131
+
132
+ m = NMatrix.new(:dense, 3, [-1,1,2,0,4,5,0,0,8], :int32) # lower version of the same
133
+
134
+ o = NMatrix.read(test_out)
135
+ expect(o).to eq(m)
136
+ expect(o).not_to eq(n)
137
+ end
138
+
139
+ it "reads and writes NMatrix dense as lower" do
140
+ n = NMatrix.new(:dense, 3, [-1,1,2,3,4,5,6,7,8], :int32)
141
+ n.write(test_out, :lower)
142
+
143
+ m = NMatrix.new(:dense, 3, [-1,0,0,3,4,0,6,7,8], :int32) # lower version of the same
144
+
145
+ o = NMatrix.read(test_out)
146
+ expect(o).to eq(m)
147
+ expect(o).not_to eq(n)
148
+ end
149
+ end