nmatrix-lapacke 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,7 @@ require 'spec_helper'
28
28
 
29
29
  describe "RSpec" do
30
30
  it "should permit #be_within to be used on a dense NMatrix" do
31
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
31
32
  expect(NMatrix.new([4,1], 1.0, dtype: :complex128, stype: :dense) / 10000.0).to be_within(0.00000001).of(NMatrix.new([4,1], 0.0001, dtype: :float64, stype: :dense))
32
33
  expect(NMatrix.new([4,1], 1.0, dtype: :complex128, stype: :dense) / 10000.0).not_to be_within(0.00000001).of(NMatrix.new([4,1], 1.0, dtype: :float64, stype: :dense))
33
34
  end
@@ -104,13 +104,14 @@ describe NMatrix do
104
104
  [:dense, :yale, :list].each do |stype|
105
105
  context "#block_diagonal #{dtype} #{stype}" do
106
106
  it "block_diagonal() creates a block-diagonal NMatrix" do
107
+ pending("not yet implemented for NMatrix-JRuby") if jruby? and dtype == :object
107
108
  a = NMatrix.new([2,2], [1,2,
108
109
  3,4])
109
110
  b = NMatrix.new([1,1], [123.0])
110
111
  c = NMatrix.new([3,3], [1,2,3,
111
112
  1,2,3,
112
113
  1,2,3])
113
- d = Array[ [1,1,1], [2,2,2], [3,3,3] ]
114
+ d = Array[ [1,1,1], [2,2,2], [3,3,3] ]
114
115
  e = 12
115
116
  m = NMatrix.block_diagonal(a, b, c, d, e, dtype: dtype, stype: stype)
116
117
  expect(m).to eq(NMatrix.new([10,10], [1, 2, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -136,6 +137,17 @@ describe NMatrix do
136
137
  expect(m.dtype).to eq(:float64)
137
138
  end
138
139
 
140
+ it "creates a matrix of random numbers with defined seed value" do
141
+ m1 = NMatrix.random(2,:seed => 62)
142
+ m2 = NMatrix.random(2,:seed => 62)
143
+ m3 = NMatrix.random(2,:seed => 65)
144
+
145
+
146
+ expect(m1).to eq(m2)
147
+ expect(m1).not_to eq(m3)
148
+
149
+ end
150
+
139
151
  it "creates a complex matrix of random numbers" do
140
152
  m = NMatrix.random(2, :dtype => :complex128)
141
153
  end
@@ -158,42 +170,44 @@ describe NMatrix do
158
170
  expect { NMatrix.random("not an array or integer") }.to raise_error
159
171
  end
160
172
  end
161
-
173
+
162
174
  context "::magic" do
163
-
175
+
164
176
  ALL_DTYPES.each do |dtype|
165
177
  context dtype do
166
178
  it "creates a matrix with numbers from 1 to n^n(n squared)" do
179
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
167
180
  a = NMatrix.magic(3, dtype: dtype)
168
- magic3 = NMatrix.new([3,3], [4, 9, 2, 3, 5, 7, 8, 1, 6], dtype: dtype)
181
+ magic3 = NMatrix.new([3,3], [4, 9, 2, 3, 5, 7, 8, 1, 6], dtype: dtype)
169
182
  expect(a).to eq magic3
170
-
183
+
171
184
  b = NMatrix.magic(4, dtype: dtype)
172
185
  magic4 = NMatrix.new([4,4], [1, 15, 14, 4, 12, 6, 7, 9, 8, 10, 11, 5, 13, 3, 2, 16], dtype: dtype)
173
186
  expect(b).to eq magic4
174
-
187
+
175
188
  c = NMatrix.magic(6, dtype: dtype)
176
189
  magic6 = NMatrix.new([6,6], [31, 9, 2, 22, 27, 20, 3, 32, 7, 21, 23, 25, 35, 1, 6, 26, 19, 24, 4, 36, 29, 13, 18, 11, 30, 5, 34, 12, 14, 16, 8, 28, 33, 17, 10, 15], dtype: dtype)
177
- expect(c).to eq magic6
190
+ expect(c).to eq magic6
178
191
  end
179
192
  end
180
193
  end
181
-
194
+
182
195
  it "shape of two is not allowed" do
183
196
  expect { NMatrix.magic(2) }.to raise_error(ArgumentError)
184
197
  end
185
-
186
- it "Only accepts an integer as dimension" do
198
+
199
+ it "Only accepts an integer as dimension" do
187
200
  expect { NMatrix.magic(3.0) }.to raise_error(ArgumentError)
188
201
  end
189
202
  end
190
-
203
+
191
204
  context "::linspace" do
192
205
  it "creates a row vector when given only one shape parameter" do
206
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
193
207
  v = NMatrix.linspace(1, 10, 4)
194
208
  #Expect a row vector only
195
209
  expect(v.shape.length).to eq(1)
196
-
210
+
197
211
  ans = [1.0,4.0,7.0,10.0]
198
212
 
199
213
  expect(v[0]).to be_within(0.000001).of(ans[0])
@@ -201,13 +215,14 @@ describe NMatrix do
201
215
  expect(v[2]).to be_within(0.000001).of(ans[2])
202
216
  expect(v[3]).to be_within(0.000001).of(ans[3])
203
217
  end
204
-
218
+
205
219
  it "creates a matrix of input shape with each entry linearly spaced in row major order" do
220
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
206
221
  v = NMatrix.linspace(1, Math::PI, [2,2])
207
222
  expect(v.dtype).to eq(:float64)
208
223
 
209
224
  ans = [1.0, 1.7138642072677612, 2.4277284145355225, 3.1415927410125732]
210
-
225
+
211
226
  expect(v[0,0]).to be_within(0.000001).of(ans[0])
212
227
  expect(v[0,1]).to be_within(0.000001).of(ans[1])
213
228
  expect(v[1,0]).to be_within(0.000001).of(ans[2])
@@ -217,13 +232,14 @@ describe NMatrix do
217
232
 
218
233
  context "::logspace" do
219
234
  it "creates a logarithmically spaced vector" do
235
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
220
236
  v = NMatrix.logspace(1, 2, 10)
221
-
237
+
222
238
  expect(v.shape.length).to eq(1)
223
-
239
+
224
240
  #Unit test taken from Matlab R2015b output of logspace(1,2,10)
225
241
  ans = [10.0000, 12.9155, 16.6810, 21.5443, 27.8256, 35.9381, 46.4159, 59.9484, 77.4264, 100.0000]
226
-
242
+
227
243
  expect(v[0].round(4)).to be_within(0.000001).of(ans[0])
228
244
  expect(v[1].round(4)).to be_within(0.000001).of(ans[1])
229
245
  expect(v[2].round(4)).to be_within(0.000001).of(ans[2])
@@ -235,13 +251,14 @@ describe NMatrix do
235
251
  expect(v[8].round(4)).to be_within(0.000001).of(ans[8])
236
252
  expect(v[9].round(4)).to be_within(0.000001).of(ans[9])
237
253
  end
238
-
254
+
239
255
  it "creates a logarithmically spaced vector bounded by Math::PI if :pi is pre-supplied" do
256
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
240
257
  v = NMatrix.logspace(1, :pi, 7)
241
-
258
+
242
259
  #Unit test taken from Matlab R2015b output of logspace(1,pi,10)
243
260
  ans = [10.0000, 8.2450, 6.7980, 5.6050, 4.6213, 3.8103, 3.1416]
244
-
261
+
245
262
  expect(v[0].round(4)).to be_within(0.000001).of(ans[0])
246
263
  expect(v[1].round(4)).to be_within(0.000001).of(ans[1])
247
264
  expect(v[2].round(4)).to be_within(0.000001).of(ans[2])
@@ -249,13 +266,14 @@ describe NMatrix do
249
266
  expect(v[4].round(4)).to be_within(0.000001).of(ans[4])
250
267
  expect(v[5].round(4)).to be_within(0.000001).of(ans[5])
251
268
  expect(v[6].round(4)).to be_within(0.000001).of(ans[6])
252
- end
269
+ end
253
270
 
254
271
  it "creates a matrix of input shape with each entry logarithmically spaced in row major order" do
272
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
255
273
  v = NMatrix.logspace(1, 2, [3,2])
256
-
274
+
257
275
  ans = [10.0, 15.8489, 25.1189, 39.8107, 63.0957, 100.0]
258
-
276
+
259
277
  expect(v[0,0].round(4)).to be_within(0.000001).of(ans[0])
260
278
  expect(v[0,1].round(4)).to be_within(0.000001).of(ans[1])
261
279
  expect(v[1,0].round(4)).to be_within(0.000001).of(ans[2])
@@ -360,6 +378,7 @@ describe NMatrix do
360
378
  end
361
379
 
362
380
  it "should create an nmatrix of ones with dimensions and type the same as its argument" do
381
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
363
382
  expect(NMatrix.ones_like(@nm_1d)).to eq NMatrix[1.0, 1.0, 1.0, 1.0, 1.0]
364
383
  expect(NMatrix.ones_like(@nm_2d)).to eq NMatrix[[1.0, 1.0], [1.0, 1.0]]
365
384
  end
@@ -383,6 +402,7 @@ describe "NVector" do
383
402
  end
384
403
 
385
404
  it "ones() creates a vector of ones" do
405
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
386
406
  v = NVector.ones(3)
387
407
 
388
408
  3.times do |i|
@@ -391,6 +411,7 @@ describe "NVector" do
391
411
  end
392
412
 
393
413
  it "random() creates a vector of random numbers" do
414
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
394
415
  v = NVector.random(4)
395
416
  expect(v.dtype).to eq(:float64)
396
417
  expect(v.stype).to eq(:dense)
@@ -424,16 +445,19 @@ describe "NVector" do
424
445
  end
425
446
 
426
447
  it "cindgen() creates a vector of complexes, sequentially" do
448
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
427
449
  v = NVector.cindgen(2)
428
450
  expect(v).to eq(NMatrix.new([2,1], [Complex(0.0, 0.0), Complex(1.0, 0.0)], dtype: :complex64))
429
451
  end
430
452
 
431
453
  it "linspace() creates a vector with n values equally spaced between a and b" do
454
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
432
455
  v = NVector.linspace(0, 2, 5)
433
456
  expect(v).to eq(NMatrix.new([5,1], [0.0, 0.5, 1.0, 1.5, 2.0]))
434
457
  end
435
458
 
436
459
  it "logspace() creates a vector with n values logarithmically spaced between decades 10^a and 10^b" do
460
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
437
461
  v = NVector.logspace(0, 3, 4)
438
462
  expect(v).to eq(NMatrix.new([4,1], [1.0, 10.0, 100.0, 1000.0]))
439
463
  end
@@ -40,8 +40,12 @@ describe "Set slice operation" do
40
40
 
41
41
  if stype == :yale
42
42
  step "verify correct arrangement of Yale IJA and A arrays" do
43
- @m.extend NMatrix::YaleFunctions
44
- expect(@m.yale_ija).to eq([4,6,8,10,1,2,0,2,0,1])
43
+ @m.extend NMatrix::YaleFunctions unless jruby?
44
+ if jruby?
45
+ pending("not yet implemented for NMatrix-JRuby")
46
+ else
47
+ expect(@m.yale_ija).to eq([4,6,8,10,1,2,0,2,0,1])
48
+ end
45
49
  expect(@m.yale_a).to eq([0,4,8,0, 1,2,3,5,6,7])
46
50
  end
47
51
  end
@@ -145,6 +149,7 @@ describe "Set slice operation" do
145
149
  end
146
150
 
147
151
  example "set a range of values to a matrix's contents" do
152
+ pending("not yet implemented for int dtype for NMatrix-JRuby") if jruby?
148
153
  x = NMatrix.new(4, stype: :yale, dtype: :int16)
149
154
  x.extend NMatrix::YaleFunctions if stype == :yale
150
155
  x[1..3,1..3] = @m
@@ -41,6 +41,7 @@ describe "Statistical functions" do
41
41
  end
42
42
 
43
43
  it "should calculate the mean along the specified dimension" do
44
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
44
45
  unless stype == :yale then
45
46
  puts nm_1d.mean
46
47
  expect(nm_1d.mean).to eq NMatrix.new([1], [2.2], stype: stype, dtype: :float64)
@@ -50,27 +51,32 @@ describe "Statistical functions" do
50
51
  end
51
52
 
52
53
  it "should calculate the minimum along the specified dimension" do
54
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
53
55
  expect(nm_1d.min).to eq 0.0 unless stype == :yale
54
56
  expect(nm_2d.min).to eq NMatrix[[0.0, 1.0], stype: stype]
55
57
  expect(nm_2d.min(1)).to eq NMatrix[[0.0], [2.0], stype: stype]
56
58
  end
57
59
 
58
60
  it "should calculate the maximum along the specified dimension" do
61
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
59
62
  expect(nm_1d.max).to eq 5.0 unless stype == :yale
60
63
  expect(nm_2d.max).to eq NMatrix[[2.0, 3.0], stype: stype]
61
64
  end
62
65
 
63
66
  it "should calculate the variance along the specified dimension" do
67
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
64
68
  expect(nm_1d.variance).to eq NMatrix[3.7, stype: stype] unless stype == :yale
65
69
  expect(nm_2d.variance(1)).to eq NMatrix[[0.5], [0.5], stype: stype]
66
70
  end
67
71
 
68
72
  it "should calculate the sum along the specified dimension" do
73
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
69
74
  expect(nm_1d.sum).to eq NMatrix[11.0, stype: stype] unless stype == :yale
70
75
  expect(nm_2d.sum).to eq NMatrix[[2.0, 4.0], stype: stype]
71
76
  end
72
77
 
73
78
  it "should calculate the standard deviation along the specified dimension" do
79
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
74
80
  expect(nm_1d.std).to eq NMatrix[Math.sqrt(3.7), stype: stype] unless stype == :yale
75
81
  expect(nm_2d.std(1)).to eq NMatrix[[Math.sqrt(0.5)], [Math.sqrt(0.5)], stype: stype]
76
82
  end
@@ -128,6 +134,7 @@ describe "Statistical functions" do
128
134
  end
129
135
 
130
136
  it "should iterate correctly for reduce without a block" do
137
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
131
138
  unless stype == :yale then
132
139
  en = nm_1d.reduce_along_dim(0, 1.0)
133
140
  expect(en.each { |a, e| a+e }.to_f).to eq 12
@@ -170,6 +177,7 @@ describe "Statistical functions" do
170
177
  end
171
178
 
172
179
  it "should allow overriding the dtype for reduce_along_dim" do
180
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
173
181
  m = NMatrix[[1,2,3], [3,4,5], dtype: :complex128]
174
182
  m.reduce_along_dim(1, 0.0, :float64) do |acc, sub_m|
175
183
  expect(acc.dtype).to eq :float64
@@ -184,16 +192,19 @@ describe "Statistical functions" do
184
192
  end
185
193
 
186
194
  it "should convert integer dtypes to float when calculating mean" do
195
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
187
196
  m = NMatrix[[1,2,3], [3,4,5], dtype: :int32, stype: stype]
188
197
  expect(m.mean(0).dtype).to eq :float64
189
198
  end
190
199
 
191
200
  it "should convert integer dtypes to float when calculating variance" do
201
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
192
202
  m = NMatrix[[1,2,3], [3,4,5], dtype: :int32, stype: stype]
193
203
  expect(m.variance(0).dtype).to eq :float64
194
204
  end
195
205
 
196
206
  it "should convert integer dtypes to float when calculating standard deviation" do
207
+ pending("not yet implemented for NMatrix-JRuby") if jruby?
197
208
  m = NMatrix[[1,2,3], [3,4,5], dtype: :int32, stype: stype]
198
209
  expect(m.std(0).dtype).to eq :float64
199
210
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nmatrix-lapacke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Levine
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-25 00:00:00.000000000 Z
12
+ date: 2017-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nmatrix
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.2.3
20
+ version: 0.2.4
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 0.2.3
27
+ version: 0.2.4
28
28
  description: For using linear algebra fuctions provided by LAPACK and BLAS
29
29
  email:
30
30
  - john.o.woods@gmail.com
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  version: '0'
258
258
  requirements: []
259
259
  rubyforge_project:
260
- rubygems_version: 2.5.1
260
+ rubygems_version: 2.6.13
261
261
  signing_key:
262
262
  specification_version: 4
263
263
  summary: general LAPACK backend for nmatrix using LAPACKE interface
@@ -266,27 +266,17 @@ test_files:
266
266
  - spec/01_enum_spec.rb
267
267
  - spec/02_slice_spec.rb
268
268
  - spec/03_nmatrix_monkeys_spec.rb
269
- - spec/2x2_dense_double.mat
270
- - spec/4x4_sparse.mat
271
- - spec/4x5_dense.mat
272
269
  - spec/blas_spec.rb
273
270
  - spec/elementwise_spec.rb
274
271
  - spec/homogeneous_spec.rb
275
272
  - spec/io/fortran_format_spec.rb
276
273
  - spec/io/harwell_boeing_spec.rb
277
- - spec/io/test.rua
278
274
  - spec/io_spec.rb
279
275
  - spec/lapack_core_spec.rb
280
- - spec/leakcheck.rb
281
276
  - spec/math_spec.rb
282
- - spec/nmatrix_yale_resize_test_associations.yaml
283
277
  - spec/nmatrix_yale_spec.rb
284
- - spec/rspec_monkeys.rb
285
278
  - spec/rspec_spec.rb
286
279
  - spec/shortcuts_spec.rb
287
280
  - spec/slice_set_spec.rb
288
- - spec/spec_helper.rb
289
281
  - spec/stat_spec.rb
290
- - spec/test.pcd
291
- - spec/utm5940.mtx
292
282
  - spec/plugins/lapacke/lapacke_spec.rb