narray 0.6.0.1 → 0.6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/src/ChangeLog +15 -0
- data/src/SPEC.en +9 -0
- data/src/SPEC.ja +9 -0
- data/src/lib/narray_ext.rb +38 -1
- data/src/narray.c +4 -5
- data/src/narray.h +2 -2
- metadata +22 -31
data/src/ChangeLog
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
2012-12-07 geoffyoungs
|
2
|
+
|
3
|
+
* narray.c (na_check_class_narray):
|
4
|
+
Use ruby methods to check class ancestors,
|
5
|
+
instead of m_tbl directly
|
6
|
+
* ver 0.6.0.2
|
7
|
+
|
8
|
+
2012-09-20 Masahiro TANAKA <masa16.tanaka@gmail.com>
|
9
|
+
|
10
|
+
* lib/narray_ext.rb (reverse,rot90): new method
|
11
|
+
|
12
|
+
2012-09-01 ohai
|
13
|
+
|
14
|
+
* lib/narray_ext.rb: Change NMath#recip into a module function.
|
15
|
+
|
1
16
|
2011-08-29 Masahiro TANAKA <masa16.tanaka@gmail.com>
|
2
17
|
|
3
18
|
* narray.c (na_alloc_struct): check array size (zero/negative).
|
data/src/SPEC.en
CHANGED
@@ -86,6 +86,11 @@ Replacing Elements -- Same rule as slicing
|
|
86
86
|
a[0..2,0..3] = b[0..2,1] Storing repetitively
|
87
87
|
( a[0,0]=b[0,1],..,a[0,3]=b[0,1] )
|
88
88
|
|
89
|
+
Delete row/columns -- Complement of slice
|
90
|
+
|
91
|
+
self.delete_at(...) Arguments are the same as the [] and slice methods
|
92
|
+
see https://github.com/masa16/narray/issues/5
|
93
|
+
|
89
94
|
Filling values
|
90
95
|
self.indgen!([start[,step]]) Generate index;
|
91
96
|
Set values from 'start' with 'step' increment
|
@@ -196,6 +201,10 @@ Reference to another NArray
|
|
196
201
|
self.reshape(size,...) same as self.refer.reshape!
|
197
202
|
self.newdim(dim,...) same as self.refer.newdim!
|
198
203
|
|
204
|
+
Reverse and Rotate
|
205
|
+
self.reverse([dim,...]) Reverse array at axes
|
206
|
+
self.rot90([k]) Rotate array by 90 degrees k times
|
207
|
+
|
199
208
|
Type conversion
|
200
209
|
self.floor Return integer NArray whose elements processed 'floor'
|
201
210
|
self.ceil
|
data/src/SPEC.ja
CHANGED
@@ -75,6 +75,11 @@
|
|
75
75
|
a[0..2,0..3] = b[0..2,1] 繰り返し代入。
|
76
76
|
( a[0,0]=b[0,1],..,a[0,3]=b[0,1] )
|
77
77
|
|
78
|
+
行・列の削除 -- インデックス取り出しの逆
|
79
|
+
|
80
|
+
self.delete_at(...) 引数はインデクス参照と同じ。
|
81
|
+
参照: https://github.com/masa16/narray/issues/5
|
82
|
+
|
78
83
|
値のセット。
|
79
84
|
self.indgen!([start[,step]]) startからstepづつ増加した値をセット。
|
80
85
|
self.fill!(value) すべての要素にvalueをセット。
|
@@ -181,6 +186,10 @@
|
|
181
186
|
self.reshape(size,...) self.refer.reshape! と同様。
|
182
187
|
self.newdim(dim,...) self.refer.newdim! と同様。
|
183
188
|
|
189
|
+
反転・回転
|
190
|
+
self.reverse([dim,...]) 指定した次元を逆順にする
|
191
|
+
self.rot90([k]) 2次元配列の90度の回転をk回行う
|
192
|
+
|
184
193
|
型変換
|
185
194
|
self.floor selfより小さい最大の整数を返す。
|
186
195
|
self.ceil selfより大きい最小の整数を返す。
|
data/src/lib/narray_ext.rb
CHANGED
@@ -78,7 +78,7 @@ class NArray
|
|
78
78
|
when Array
|
79
79
|
x = (0...n).to_a
|
80
80
|
x -= a.map do |j|
|
81
|
-
raise IndexError, "contains non-integer" unless
|
81
|
+
raise IndexError, "contains non-integer" unless Integer===j
|
82
82
|
(j<0) ? n+j : j
|
83
83
|
end
|
84
84
|
else
|
@@ -208,6 +208,42 @@ class NArray
|
|
208
208
|
self
|
209
209
|
end
|
210
210
|
|
211
|
+
def reverse(*ranks)
|
212
|
+
if self.rank==0
|
213
|
+
return self.dup
|
214
|
+
elsif ranks.size==0
|
215
|
+
idx = (0...self.rank).map{-1..0}
|
216
|
+
else
|
217
|
+
idx = [true]*self.rank
|
218
|
+
ranks.each do |i|
|
219
|
+
if !i.kind_of?(Integer)
|
220
|
+
raise ArgumentError, "Argument must be Integer"
|
221
|
+
end
|
222
|
+
if i >= self.rank
|
223
|
+
raise ArgumentError, "dimension(%s) out of range"%[i]
|
224
|
+
end
|
225
|
+
idx[i] = -1..0
|
226
|
+
end
|
227
|
+
end
|
228
|
+
self[*idx]
|
229
|
+
end
|
230
|
+
|
231
|
+
def rot90(n_times=1)
|
232
|
+
if self.rank < 2
|
233
|
+
raise "must be >= 2 dimensional array"
|
234
|
+
end
|
235
|
+
case n_times%4
|
236
|
+
when 0
|
237
|
+
self.dup
|
238
|
+
when 1
|
239
|
+
self.transpose(1,0).reverse(0)
|
240
|
+
when 2
|
241
|
+
self.reverse(0,1)
|
242
|
+
when 3
|
243
|
+
self.transpose(1,0).reverse(1)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
211
247
|
#SFloatOne = NArray.sfloat(1).fill!(1)
|
212
248
|
end
|
213
249
|
|
@@ -272,6 +308,7 @@ module NMath
|
|
272
308
|
((x-xm)*(y-ym)).sum(*ranks) / (n-1)
|
273
309
|
end
|
274
310
|
|
311
|
+
module_function :recip
|
275
312
|
module_function :csc,:sec,:cot,:csch,:sech,:coth
|
276
313
|
module_function :acsc,:asec,:acot,:acsch,:asech,:acoth
|
277
314
|
module_function :covariance
|
data/src/narray.c
CHANGED
@@ -181,11 +181,10 @@ static void
|
|
181
181
|
if (TYPE(v) != T_CLASS) {
|
182
182
|
rb_raise(rb_eRuntimeError, "class required");
|
183
183
|
}
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
}
|
184
|
+
|
185
|
+
if(RTEST(rb_ary_includes(rb_mod_ancestors(v), cNArray)))
|
186
|
+
return;
|
187
|
+
|
189
188
|
rb_raise(rb_eRuntimeError, "need NArray or its subclass");
|
190
189
|
}
|
191
190
|
|
data/src/narray.h
CHANGED
metadata
CHANGED
@@ -1,27 +1,23 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: narray
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Masahiro Tanaka
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
date: 2011-08-27
|
13
|
-
default_executable:
|
12
|
+
date: 2012-12-26 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
|
-
|
16
14
|
description: Numerical N-dimensional Array class
|
17
15
|
email: masa16.tanaka@gmail.com
|
18
16
|
executables: []
|
19
|
-
|
20
|
-
extensions:
|
17
|
+
extensions:
|
21
18
|
- src/extconf.rb
|
22
19
|
extra_rdoc_files: []
|
23
|
-
|
24
|
-
files:
|
20
|
+
files:
|
25
21
|
- src/ChangeLog
|
26
22
|
- src/MANIFEST
|
27
23
|
- src/README.en
|
@@ -44,33 +40,28 @@ files:
|
|
44
40
|
- src/narray_local.h
|
45
41
|
- src/lib/narray_ext.rb
|
46
42
|
- src/lib/nmatrix.rb
|
47
|
-
has_rdoc: false
|
48
43
|
homepage: http://narray.rubyforge.org/
|
49
44
|
licenses: []
|
50
|
-
|
51
45
|
post_install_message:
|
52
46
|
rdoc_options: []
|
53
|
-
|
54
|
-
require_paths:
|
47
|
+
require_paths:
|
55
48
|
- .
|
56
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
68
61
|
requirements: []
|
69
|
-
|
70
62
|
rubyforge_project: narray
|
71
|
-
rubygems_version: 1.
|
63
|
+
rubygems_version: 1.8.23
|
72
64
|
signing_key:
|
73
65
|
specification_version: 2
|
74
66
|
summary: N-dimensional Numerical Array class for Ruby
|
75
67
|
test_files: []
|
76
|
-
|