nmatrix 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CONTRIBUTING.md +66 -0
- data/Gemfile +1 -1
- data/History.txt +68 -10
- data/LICENSE.txt +2 -2
- data/Manifest.txt +2 -0
- data/README.rdoc +90 -69
- data/Rakefile +18 -9
- data/ext/nmatrix/data/complex.h +7 -7
- data/ext/nmatrix/data/data.cpp +2 -7
- data/ext/nmatrix/data/data.h +7 -4
- data/ext/nmatrix/data/rational.h +2 -2
- data/ext/nmatrix/data/ruby_object.h +3 -10
- data/ext/nmatrix/extconf.rb +79 -54
- data/ext/nmatrix/new_extconf.rb +11 -12
- data/ext/nmatrix/nmatrix.cpp +94 -125
- data/ext/nmatrix/nmatrix.h +38 -17
- data/ext/nmatrix/ruby_constants.cpp +2 -15
- data/ext/nmatrix/ruby_constants.h +2 -14
- data/ext/nmatrix/storage/common.cpp +2 -2
- data/ext/nmatrix/storage/common.h +2 -2
- data/ext/nmatrix/storage/dense.cpp +206 -31
- data/ext/nmatrix/storage/dense.h +5 -2
- data/ext/nmatrix/storage/list.cpp +52 -4
- data/ext/nmatrix/storage/list.h +3 -2
- data/ext/nmatrix/storage/storage.cpp +6 -6
- data/ext/nmatrix/storage/storage.h +2 -2
- data/ext/nmatrix/storage/yale.cpp +202 -49
- data/ext/nmatrix/storage/yale.h +5 -4
- data/ext/nmatrix/ttable_helper.rb +108 -108
- data/ext/nmatrix/types.h +2 -15
- data/ext/nmatrix/util/io.cpp +2 -2
- data/ext/nmatrix/util/io.h +2 -2
- data/ext/nmatrix/util/lapack.h +2 -2
- data/ext/nmatrix/util/math.cpp +14 -14
- data/ext/nmatrix/util/math.h +2 -2
- data/ext/nmatrix/util/sl_list.cpp +2 -2
- data/ext/nmatrix/util/sl_list.h +2 -2
- data/ext/nmatrix/util/util.h +2 -2
- data/lib/nmatrix.rb +13 -35
- data/lib/nmatrix/blas.rb +182 -56
- data/lib/nmatrix/io/market.rb +38 -14
- data/lib/nmatrix/io/mat5_reader.rb +393 -278
- data/lib/nmatrix/io/mat_reader.rb +121 -107
- data/lib/nmatrix/lapack.rb +59 -14
- data/lib/nmatrix/monkeys.rb +32 -30
- data/lib/nmatrix/nmatrix.rb +204 -100
- data/lib/nmatrix/nvector.rb +166 -57
- data/lib/nmatrix/shortcuts.rb +364 -231
- data/lib/nmatrix/version.rb +8 -4
- data/nmatrix.gemspec +5 -3
- data/scripts/mac-brew-gcc.sh +1 -1
- data/spec/blas_spec.rb +80 -2
- data/spec/math_spec.rb +78 -32
- data/spec/nmatrix_list_spec.rb +55 -55
- data/spec/nmatrix_spec.rb +60 -117
- data/spec/nmatrix_yale_resize_test_associations.yaml +2802 -0
- data/spec/nmatrix_yale_spec.rb +214 -198
- data/spec/nvector_spec.rb +58 -2
- data/spec/shortcuts_spec.rb +156 -32
- data/spec/slice_spec.rb +229 -178
- data/spec/spec_helper.rb +2 -2
- metadata +71 -21
data/spec/nmatrix_yale_spec.rb
CHANGED
@@ -28,230 +28,246 @@ require "./lib/nmatrix"
|
|
28
28
|
|
29
29
|
describe NMatrix do
|
30
30
|
context :yale do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
it "calculates itype" do
|
32
|
+
NMatrix.itype_by_shape([4,4]).should == :uint8
|
33
|
+
NMatrix.itype_by_shape(4).should == :uint8
|
34
|
+
## FIXME: Check larger shapes for correct itype
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
it "compares two empty matrices" do
|
38
|
+
n = NMatrix.new(:yale, [4,4], :float64)
|
39
|
+
m = NMatrix.new(:yale, [4,4], :float64)
|
40
|
+
n.should == m
|
41
|
+
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
it "compares two matrices following basic assignments" do
|
44
|
+
n = NMatrix.new(:yale, [2,2], :float64)
|
45
|
+
m = NMatrix.new(:yale, [2,2], :float64)
|
46
|
+
m[0,0] = 1
|
47
|
+
m[0,1] = 1
|
48
|
+
n.should_not == m
|
49
|
+
n[0,0] = 1
|
50
|
+
n.should_not == m
|
51
|
+
n[0,1] = 1
|
52
|
+
n.should == m
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
55
|
+
it "compares two matrices following elementwise operations" do
|
56
|
+
n = NMatrix.new(:yale, [2,2], :float64)
|
57
|
+
n[0,1] = 1
|
58
|
+
m = NMatrix.new(:yale, [2,2], :float64)
|
59
|
+
m[0,1] = -1
|
60
|
+
r = NMatrix.new(:yale, [2,2], :float64)
|
61
|
+
r[0,1] = 0
|
62
|
+
(n+m).should == r
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
65
|
+
it "sets diagonal values" do
|
66
|
+
n = NMatrix.new(:yale, [2,3], :float64)
|
67
|
+
n.extend(NMatrix::YaleFunctions)
|
68
|
+
n[1,1] = 0.1
|
69
|
+
n[0,0] = 0.2
|
70
|
+
n.yale_d.should == [0.2, 0.1]
|
71
|
+
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
73
|
+
it "does not resize until necessary" do
|
74
|
+
n = NMatrix.new(:yale, [2,3], :float64)
|
75
|
+
n.extend(NMatrix::YaleFunctions)
|
76
|
+
n.yale_size.should == 3
|
77
|
+
n.capacity.should == 5
|
78
|
+
n[0,0] = 0.1
|
79
|
+
n[0,1] = 0.2
|
80
|
+
n[1,0] = 0.3
|
81
|
+
n.yale_size.should == 5
|
82
|
+
n.capacity.should == 5
|
83
|
+
end
|
84
84
|
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
86
|
+
it "sets when not resizing" do
|
87
|
+
n = NMatrix.new(:yale, [2,3], :float64)
|
88
|
+
n.extend(NMatrix::YaleFunctions)
|
89
|
+
n[0,0] = 0.1
|
90
|
+
n[0,1] = 0.2
|
91
|
+
n[1,0] = 0.3
|
92
|
+
n.yale_a == [0.1, 0.0, 0.0, 0.2, 0.3]
|
93
|
+
n.yale_ija == [3,4,5,1,0]
|
94
|
+
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
96
|
+
it "sets when resizing" do
|
97
|
+
n = NMatrix.new(:yale, [2,3], :float64)
|
98
|
+
n.extend(NMatrix::YaleFunctions)
|
99
|
+
n[0,0] = 0.01
|
100
|
+
n[1,1] = 0.1
|
101
|
+
n[0,1] = 0.2
|
102
|
+
n[1,0] = 0.3
|
103
|
+
n[1,2] = 0.4
|
104
|
+
n.yale_d.should == [0.01, 0.1]
|
105
|
+
n.yale_ia.should == [3,4,6]
|
106
|
+
n.yale_ja.should == [1,0,2,nil]
|
107
|
+
n.yale_lu.should == [0.2, 0.3, 0.4, nil]
|
108
|
+
end
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
n.extend(NMatrix::YaleFunctions)
|
113
|
-
n[2,1] = 1.0
|
114
|
-
n[2,0] = 1.5
|
115
|
-
n[2,15] = 2.0
|
116
|
-
n.yale_lu.should == [1.5, 1.0, 2.0]
|
117
|
-
n.yale_ja.should == [0, 1, 15]
|
118
|
-
end
|
110
|
+
it "resizes without erasing values" do
|
111
|
+
require 'yaml'
|
119
112
|
|
120
|
-
|
121
|
-
n = NMatrix.new(:yale, [3,20], :float64)
|
122
|
-
n[2,1] = 1.0
|
123
|
-
n[2,0] = 1.5
|
124
|
-
n[2,15] = 2.0
|
125
|
-
n[2,1].should == 1.0
|
126
|
-
n[2,0].should == 1.5
|
127
|
-
n[2,15].should == 2.0
|
128
|
-
end
|
113
|
+
associations = File.open('spec/nmatrix_yale_resize_test_associations.yaml') { |y| YAML::load(y) }
|
129
114
|
|
130
|
-
|
131
|
-
n = NMatrix.new(:yale, [10,300], :float64)
|
132
|
-
n.extend(NMatrix::YaleFunctions)
|
133
|
-
n[5,1] = 1.0
|
134
|
-
n[5,0] = 1.5
|
135
|
-
n[5,15] = 2.0
|
136
|
-
n[5,291] = 3.0
|
137
|
-
n[5,292] = 4.0
|
138
|
-
n[5,289] = 5.0
|
139
|
-
n[5,290] = 6.0
|
140
|
-
n[5,293] = 2.0
|
141
|
-
n[5,299] = 7.0
|
142
|
-
n[5,100] = 8.0
|
143
|
-
n.yale_lu.should == [1.5, 1.0, 2.0, 8.0, 5.0, 6.0, 3.0, 4.0, 2.0, 7.0]
|
144
|
-
n.yale_ja.should == [0, 1, 15, 100, 289, 290, 291, 292, 293, 299]
|
145
|
-
end
|
115
|
+
n = NMatrix.new(:yale, [618, 2801], associations.size, :byte)
|
146
116
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
n[5,0] = 1.5
|
152
|
-
n[5,15] = 2.0
|
153
|
-
n[5,291] = 3.0
|
154
|
-
n[5,292] = 4.0
|
155
|
-
n[5,289] = 5.0
|
156
|
-
n[5,290] = 6.0
|
157
|
-
n[5,293] = 2.0
|
158
|
-
n[5,299] = 7.0
|
159
|
-
n[5,100] = 8.0
|
117
|
+
associations.each_pair do |j,i|
|
118
|
+
n[i,j] = 1
|
119
|
+
n[i,j].should be(1), "Value at #{i},#{j} not inserted correctly!"
|
120
|
+
end
|
160
121
|
|
161
|
-
|
162
|
-
|
163
|
-
|
122
|
+
associations.each_pair do |j,i|
|
123
|
+
n[i,j].should be(1), "Value at #{i},#{j} erased during resize!"
|
124
|
+
end
|
164
125
|
end
|
165
|
-
end
|
166
126
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
127
|
+
it "sets values within rows" do
|
128
|
+
n = NMatrix.new(:yale, [3,20], :float64)
|
129
|
+
n.extend(NMatrix::YaleFunctions)
|
130
|
+
n[2,1] = 1.0
|
131
|
+
n[2,0] = 1.5
|
132
|
+
n[2,15] = 2.0
|
133
|
+
n.yale_lu.should == [1.5, 1.0, 2.0]
|
134
|
+
n.yale_ja.should == [0, 1, 15]
|
135
|
+
end
|
173
136
|
|
174
|
-
|
175
|
-
|
137
|
+
it "gets values within rows" do
|
138
|
+
n = NMatrix.new(:yale, [3,20], :float64)
|
139
|
+
n[2,1] = 1.0
|
140
|
+
n[2,0] = 1.5
|
141
|
+
n[2,15] = 2.0
|
142
|
+
n[2,1].should == 1.0
|
143
|
+
n[2,0].should == 1.5
|
144
|
+
n[2,15].should == 2.0
|
145
|
+
end
|
176
146
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
end
|
147
|
+
it "sets values within large rows" do
|
148
|
+
n = NMatrix.new(:yale, [10,300], :float64)
|
149
|
+
n.extend(NMatrix::YaleFunctions)
|
150
|
+
n[5,1] = 1.0
|
151
|
+
n[5,0] = 1.5
|
152
|
+
n[5,15] = 2.0
|
153
|
+
n[5,291] = 3.0
|
154
|
+
n[5,292] = 4.0
|
155
|
+
n[5,289] = 5.0
|
156
|
+
n[5,290] = 6.0
|
157
|
+
n[5,293] = 2.0
|
158
|
+
n[5,299] = 7.0
|
159
|
+
n[5,100] = 8.0
|
160
|
+
n.yale_lu.should == [1.5, 1.0, 2.0, 8.0, 5.0, 6.0, 3.0, 4.0, 2.0, 7.0]
|
161
|
+
n.yale_ja.should == [0, 1, 15, 100, 289, 290, 291, 292, 293, 299]
|
162
|
+
end
|
194
163
|
|
195
|
-
|
196
|
-
|
164
|
+
it "gets values within large rows" do
|
165
|
+
n = NMatrix.new(:yale, [10,300], :float64)
|
166
|
+
n.extend(NMatrix::YaleFunctions)
|
167
|
+
n[5,1] = 1.0
|
168
|
+
n[5,0] = 1.5
|
169
|
+
n[5,15] = 2.0
|
170
|
+
n[5,291] = 3.0
|
171
|
+
n[5,292] = 4.0
|
172
|
+
n[5,289] = 5.0
|
173
|
+
n[5,290] = 6.0
|
174
|
+
n[5,293] = 2.0
|
175
|
+
n[5,299] = 7.0
|
176
|
+
n[5,100] = 8.0
|
197
177
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
a[3,3] = 4.0
|
178
|
+
n.yale_ja.each_index do |idx|
|
179
|
+
j = n.yale_ja[idx]
|
180
|
+
n[5,j].should == n.yale_lu[idx]
|
181
|
+
end
|
182
|
+
end
|
204
183
|
|
205
|
-
|
206
|
-
|
184
|
+
it "dots two identical matrices" do
|
185
|
+
a = NMatrix.new(:yale, 4, :float64)
|
186
|
+
a[0,1] = 4.0
|
187
|
+
a[1,2] = 1.0
|
188
|
+
a[1,3] = 1.0
|
189
|
+
a[3,1] = 2.0
|
207
190
|
|
208
|
-
|
209
|
-
|
210
|
-
#c[0,2].should == 8.0
|
211
|
-
#c[0,3].should == -16.0
|
212
|
-
#c[1,0].should == 0.0
|
213
|
-
#c[1,1].should == -16.0
|
214
|
-
#c[1,2].should == 0.0
|
215
|
-
#c[1,3].should == -16.0
|
216
|
-
#c[2,0].should == 0.0
|
217
|
-
#c[2,1].should == 0.0
|
218
|
-
#c[2,2].should == 0.0
|
219
|
-
#c[2,3].should == 0.0
|
220
|
-
#c[3,0].should == 0.0
|
221
|
-
#c[3,1].should == 0.0
|
222
|
-
#c[3,2].should == 8.0
|
223
|
-
#c[3,3].should == 0.0 # this is the positive and negative partial sum cancel
|
191
|
+
b = a.dup
|
192
|
+
c = a.dot b
|
224
193
|
|
225
|
-
|
194
|
+
c[0,0].should == 0.0
|
195
|
+
c[0,1].should == 0.0
|
196
|
+
c[0,2].should == 4.0
|
197
|
+
c[0,3].should == 4.0
|
198
|
+
c[1,0].should == 0.0
|
199
|
+
c[1,1].should == 2.0
|
200
|
+
c[1,2].should == 0.0
|
201
|
+
c[1,3].should == 0.0
|
202
|
+
c[2,0].should == 0.0
|
203
|
+
c[2,1].should == 0.0
|
204
|
+
c[2,2].should == 0.0
|
205
|
+
c[2,3].should == 0.0
|
206
|
+
c[3,0].should == 0.0
|
207
|
+
c[3,1].should == 0.0
|
208
|
+
c[3,2].should == 2.0
|
209
|
+
c[3,3].should == 2.0
|
210
|
+
end
|
226
211
|
|
227
|
-
|
228
|
-
|
212
|
+
it "dots two identical matrices where a positive and negative partial sum cancel on the diagonal" do
|
213
|
+
a = NMatrix.new(:yale, 4, :float64)
|
229
214
|
|
230
|
-
|
215
|
+
a[0,0] = 1.0
|
216
|
+
a[0,1] = 4.0
|
217
|
+
a[1,2] = 2.0
|
218
|
+
a[1,3] = -4.0
|
219
|
+
a[3,1] = 4.0
|
220
|
+
a[3,3] = 4.0
|
231
221
|
|
232
|
-
|
233
|
-
|
234
|
-
a[0,0] = 1.0
|
235
|
-
a[0,1] = 4.0
|
236
|
-
a[1,2] = 2.0
|
237
|
-
a[1,3] = -4.0
|
238
|
-
a[3,1] = 5.0
|
239
|
-
a[3,3] = 6.0
|
240
|
-
b = a.transpose
|
222
|
+
b = a.dup
|
223
|
+
c = a.dot b
|
241
224
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
225
|
+
#c[0,0].should == 1.0
|
226
|
+
#c[0,1].should == 4.0
|
227
|
+
#c[0,2].should == 8.0
|
228
|
+
#c[0,3].should == -16.0
|
229
|
+
#c[1,0].should == 0.0
|
230
|
+
#c[1,1].should == -16.0
|
231
|
+
#c[1,2].should == 0.0
|
232
|
+
#c[1,3].should == -16.0
|
233
|
+
#c[2,0].should == 0.0
|
234
|
+
#c[2,1].should == 0.0
|
235
|
+
#c[2,2].should == 0.0
|
236
|
+
#c[2,3].should == 0.0
|
237
|
+
#c[3,0].should == 0.0
|
238
|
+
#c[3,1].should == 0.0
|
239
|
+
#c[3,2].should == 8.0
|
240
|
+
#c[3,3].should == 0.0 # this is the positive and negative partial sum cancel
|
241
|
+
|
242
|
+
c.extend(NMatrix::YaleFunctions)
|
243
|
+
|
244
|
+
c.yale_ija.reject { |i| i.nil? }.should == [5,8,9,9,11,1,2,3,3,1,2]
|
245
|
+
c.yale_a.reject { |i| i.nil? }.should == [1.0, -16.0, 0.0, 0.0, 0.0, 4.0, 8.0, -16.0, -16.0, 16.0, 8.0]
|
255
246
|
|
247
|
+
end
|
248
|
+
|
249
|
+
it "transposes" do
|
250
|
+
a = NMatrix.new(:yale, 4, :float64)
|
251
|
+
a[0,0] = 1.0
|
252
|
+
a[0,1] = 4.0
|
253
|
+
a[1,2] = 2.0
|
254
|
+
a[1,3] = -4.0
|
255
|
+
a[3,1] = 5.0
|
256
|
+
a[3,3] = 6.0
|
257
|
+
b = a.transpose
|
258
|
+
|
259
|
+
b[0,0].should == 1.0
|
260
|
+
b[1,0].should == 4.0
|
261
|
+
b[2,0].should == 0.0
|
262
|
+
b[3,0].should == 0.0
|
263
|
+
b[0,1].should == 0.0
|
264
|
+
b[1,1].should == 0.0
|
265
|
+
b[2,1].should == 2.0
|
266
|
+
b[3,1].should == -4.0
|
267
|
+
b[0,3].should == 0.0
|
268
|
+
b[1,3].should == 5.0
|
269
|
+
b[2,3].should == 0.0
|
270
|
+
b[3,3].should == 6.0
|
271
|
+
end
|
256
272
|
end
|
257
273
|
end
|
data/spec/nvector_spec.rb
CHANGED
@@ -29,15 +29,71 @@ require "./lib/nmatrix"
|
|
29
29
|
|
30
30
|
describe NVector do
|
31
31
|
it "initializes" do
|
32
|
-
v = NVector.new
|
32
|
+
v = NVector.new(5, 0, :float64)
|
33
33
|
v.shape[0].should == 5
|
34
34
|
v.shape[1].should == 1
|
35
35
|
end
|
36
36
|
|
37
37
|
it "permits setting and getting contents" do
|
38
|
+
v = NVector.new(5, 0, :float64)
|
39
|
+
v[0] = 1.555
|
40
|
+
v[0].should == 1.555
|
41
|
+
end
|
42
|
+
|
43
|
+
it "transpose() changes raw and column stored structure" do
|
38
44
|
v = NVector.new 5, :float64
|
45
|
+
v = v.transpose
|
46
|
+
v.shape[0].should == 1
|
47
|
+
v.shape[1].should == 5
|
39
48
|
v[0] = 1.555
|
40
49
|
v[0].should == 1.555
|
41
50
|
end
|
42
51
|
|
43
|
-
|
52
|
+
it "transpose!() changes destructively its raw and column stored structure" do
|
53
|
+
v = NVector.new 5, :float64
|
54
|
+
v.transpose!
|
55
|
+
v.shape[0].should == 1
|
56
|
+
v.shape[1].should == 5
|
57
|
+
end
|
58
|
+
|
59
|
+
it "multiply() multiples itself by another NVector" do
|
60
|
+
v1 = NVector.new 2, :float64
|
61
|
+
v2 = NVector.new 2, :float64
|
62
|
+
v1[0] = 1.5
|
63
|
+
v1[1] = 2.3
|
64
|
+
v2[0] = 1.3
|
65
|
+
v2[1] = 2.5
|
66
|
+
v1.multiply(v2).should == 12.0
|
67
|
+
end
|
68
|
+
|
69
|
+
it "multiply!() multiples destructively itself by another NVector" do
|
70
|
+
v1 = NVector.new 2, :float64
|
71
|
+
v2 = NVector.new 2, :float64
|
72
|
+
v1[0] = 1.5
|
73
|
+
v1[1] = 2.3
|
74
|
+
v2[0] = 1.3
|
75
|
+
v2[1] = 2.5
|
76
|
+
v1.multiply!(v2)
|
77
|
+
v1.should == 12.0
|
78
|
+
end
|
79
|
+
|
80
|
+
it "pretty_print() prints values to standard output with a pretty format" do
|
81
|
+
pending "pretty_print formatting is finalized"
|
82
|
+
v = NVector.new(5, 0)
|
83
|
+
$stdout = StringIO.new
|
84
|
+
v.pretty_print
|
85
|
+
out = $stdout.string
|
86
|
+
$stdout = STDOUT
|
87
|
+
out.should == "0 0 0 0 0\n"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "inspect() formats the output with inspected, namely human readable format" do
|
91
|
+
pending "inspect output is finalized"
|
92
|
+
v = NVector.new(5, 0)
|
93
|
+
$stdout = StringIO.new
|
94
|
+
p v
|
95
|
+
out = $stdout.string
|
96
|
+
$stdout = STDOUT
|
97
|
+
out.should == "0 0 0 0 0\n"
|
98
|
+
end
|
99
|
+
end
|