narray 0.6.0.5 → 0.6.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/src/ChangeLog +13 -0
- data/src/SPEC.en +10 -2
- data/src/SPEC.ja +10 -2
- data/src/lib/narray_ext.rb +22 -3
- data/src/mkmath.rb +5 -5
- data/src/mknafunc.rb +2 -0
- data/src/mkop.rb +7 -7
- data/src/na_linalg.c +2 -2
- data/src/na_random.c +1 -1
- data/src/narray.h +2 -2
- metadata +2 -2
data/src/ChangeLog
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
2013-02-01 Masahiro TANAKA <masa16.tanaka@gmail.com>
|
2
|
+
|
3
|
+
* lib/narray_ext.rb: eql? hash methods implemented.
|
4
|
+
* ver 0.6.0.7
|
5
|
+
|
6
|
+
2013-01-31 Masahiro TANAKA <masa16.tanaka@gmail.com>
|
7
|
+
|
8
|
+
* na_raondom.c: unuse u_int16_t
|
9
|
+
* mknafunc.rb, mkmath.rb, mkop.rb, na_linalg.c:
|
10
|
+
bug: duplicated definition of asinh/acosh/atanh,
|
11
|
+
typecast warning (mingw/mswin)
|
12
|
+
* ver 0.6.0.6
|
13
|
+
|
1
14
|
2013-01-30 Masahiro TANAKA <masa16.tanaka@gmail.com>
|
2
15
|
|
3
16
|
* narray.c (na_check_class_narray):
|
data/src/SPEC.en
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
Ruby/NArray ver 0.6.0.
|
2
|
+
Ruby/NArray ver 0.6.0.7 (2013-02-01) by Masahiro TANAKA
|
3
3
|
|
4
4
|
|
5
5
|
Class method:
|
@@ -136,7 +136,7 @@ Bitwise operator (only for integers)
|
|
136
136
|
Comparison
|
137
137
|
-- element-wise comparison, results in BYTE-type NArray;
|
138
138
|
Note that not true nor false is returned.
|
139
|
-
self.eq other ( == operator
|
139
|
+
self.eq other (distinguish from == operator; see below )
|
140
140
|
self.ne other
|
141
141
|
self.gt other
|
142
142
|
self > other
|
@@ -161,6 +161,14 @@ Comparison
|
|
161
161
|
|
162
162
|
e.g.: idx_t,idx_f = (a>12).where2
|
163
163
|
|
164
|
+
Equivalence
|
165
|
+
NArray[1] == NArray[1] #=> true
|
166
|
+
NArray[1] == NArray[1.0] #=> true
|
167
|
+
NArray[1].eql? NArray[1] #=> true
|
168
|
+
NArray[1].eql? NArray[1.0] #=> false
|
169
|
+
NArray[1].equal? NArray[1] #=> false
|
170
|
+
a=b=NArray[1]; a.equal? b #=> true
|
171
|
+
|
164
172
|
Statistics
|
165
173
|
self.sum(dim,..) Summation
|
166
174
|
self.cumsum Cumulative Summation (for 1-d array)
|
data/src/SPEC.ja
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
Ruby/NArray ver 0.6.0.
|
2
|
+
Ruby/NArray ver 0.6.0.7 (2013-02-01) by Masahiro TANAKA
|
3
3
|
|
4
4
|
|
5
5
|
クラスメソッド:
|
@@ -127,7 +127,7 @@
|
|
127
127
|
比較
|
128
128
|
-- 要素ごとに値を比較し、結果をBYTE型 NArrayを返す。
|
129
129
|
true/falseでないことに注意。
|
130
|
-
self.eq other
|
130
|
+
self.eq other ( == とは異なることに注意)
|
131
131
|
self.ne other
|
132
132
|
self.gt other
|
133
133
|
self > other
|
@@ -151,6 +151,14 @@
|
|
151
151
|
|
152
152
|
例: idx_t,idx_f = (a>12).where2
|
153
153
|
|
154
|
+
同値性
|
155
|
+
NArray[1] == NArray[1] #=> true
|
156
|
+
NArray[1] == NArray[1.0] #=> true
|
157
|
+
NArray[1].eql? NArray[1] #=> true
|
158
|
+
NArray[1].eql? NArray[1.0] #=> false
|
159
|
+
NArray[1].equal? NArray[1] #=> false
|
160
|
+
a=b=NArray[1]; a.equal? b #=> true
|
161
|
+
|
154
162
|
統計
|
155
163
|
self.sum(dim,..) 指定した次元の和
|
156
164
|
self.cumsum 累積和(1次元配列のみ)
|
data/src/lib/narray_ext.rb
CHANGED
@@ -31,10 +31,29 @@ class NArray
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def ==(other)
|
34
|
-
|
35
|
-
|
34
|
+
other.kind_of?(NArray) &&
|
35
|
+
shape == other.shape &&
|
36
|
+
eq(other).all?
|
37
|
+
end
|
38
|
+
|
39
|
+
def eql?(other)
|
40
|
+
self.class == other.class &&
|
41
|
+
typecode == other.typecode &&
|
42
|
+
shape == other.shape &&
|
43
|
+
case typecode
|
44
|
+
when NArray::OBJECT
|
45
|
+
to_a.eql? other.to_a
|
46
|
+
else
|
47
|
+
to_s.eql? other.to_s
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def hash
|
52
|
+
case typecode
|
53
|
+
when NArray::OBJECT
|
54
|
+
[self.class, to_a].hash
|
36
55
|
else
|
37
|
-
|
56
|
+
[self.class, typecode, shape, to_s].hash
|
38
57
|
end
|
39
58
|
end
|
40
59
|
|
data/src/mkmath.rb
CHANGED
@@ -38,7 +38,6 @@ void sincos(double x, double *s, double *c)
|
|
38
38
|
{
|
39
39
|
*s=sin(x); *c=cos(x);
|
40
40
|
}
|
41
|
-
#endif
|
42
41
|
|
43
42
|
#ifndef HAVE_ACOSH
|
44
43
|
static double rb_log1p (const double x)
|
@@ -108,6 +107,7 @@ static double atanh(double x)
|
|
108
107
|
return a;
|
109
108
|
}
|
110
109
|
#endif
|
110
|
+
#endif
|
111
111
|
|
112
112
|
static void squareX(scomplex *x) {
|
113
113
|
float r=x->r;
|
@@ -398,8 +398,8 @@ data = [
|
|
398
398
|
["{ *p1 = log10(*p2); }"]*2 +
|
399
399
|
["{
|
400
400
|
log#code(p1,p2);
|
401
|
-
p1->r *= M_LOG10E;
|
402
|
-
p1->i *= M_LOG10E;
|
401
|
+
p1->r *= (typer)M_LOG10E;
|
402
|
+
p1->i *= (typer)M_LOG10E;
|
403
403
|
}"]*2 +
|
404
404
|
[nil] ],
|
405
405
|
|
@@ -409,8 +409,8 @@ data = [
|
|
409
409
|
["{ *p1 = log(*p2)*M_LOG2E; }"]*2 +
|
410
410
|
["{
|
411
411
|
log#code(p1,p2);
|
412
|
-
p1->r *= M_LOG2E;
|
413
|
-
p1->i *= M_LOG2E;
|
412
|
+
p1->r *= (typer)M_LOG2E;
|
413
|
+
p1->i *= (typer)M_LOG2E;
|
414
414
|
}"]*2 +
|
415
415
|
[nil] ],
|
416
416
|
|
data/src/mknafunc.rb
CHANGED
@@ -61,6 +61,7 @@ def mksetfuncs(name,op,id,funcs)
|
|
61
61
|
gsub(/p2->/,"((#{td[j]}*)p2)->").
|
62
62
|
gsub(/\*p1/,"*(#{td[i]}*)p1").
|
63
63
|
gsub(/\*p2/,"*(#{td[j]}*)p2").
|
64
|
+
gsub(/ = /," = (#{tr[i]})").
|
64
65
|
gsub(/#id/,id).
|
65
66
|
gsub(/#op/,op).
|
66
67
|
gsub(/typed/,td[i]).
|
@@ -118,6 +119,7 @@ def mkfuncs(name,t1,t2,func)
|
|
118
119
|
gsub(/\*p2/,"*(#{t2[i]}*)p2").
|
119
120
|
gsub(/\*p3/,"*(#{t2[i]}*)p3").
|
120
121
|
gsub(/type1/,td[i]).
|
122
|
+
gsub(/typec/,t1[i]).
|
121
123
|
gsub(/typef/,tr[i])
|
122
124
|
puts $func_body.
|
123
125
|
gsub(/#name/,name).
|
data/src/mkop.rb
CHANGED
@@ -206,28 +206,28 @@ mkfuncs('ImgSet',$data_types,$real_types,
|
|
206
206
|
|
207
207
|
mkfuncs('Floor',$int_types,$data_types,[nil] +
|
208
208
|
['copy']*3 +
|
209
|
-
["*p1 = floor(*p2);"]*2 +
|
209
|
+
["*p1 = (typec)floor(*p2);"]*2 +
|
210
210
|
[nil]*3
|
211
211
|
)
|
212
212
|
|
213
213
|
mkfuncs('Ceil',$int_types,$data_types,[nil] +
|
214
214
|
['copy']*3 +
|
215
|
-
["*p1 = ceil(*p2);"]*2 +
|
215
|
+
["*p1 = (typec)ceil(*p2);"]*2 +
|
216
216
|
[nil]*3
|
217
217
|
)
|
218
218
|
|
219
219
|
mkfuncs('Round',$int_types,$data_types,[nil] +
|
220
220
|
['copy']*3 +
|
221
221
|
# ["*p1 = floor(*p2+0.5);"]*2 +
|
222
|
-
["if (*p2 >= 0) *p1 = floor(*p2+0.5);
|
223
|
-
else *p1 = ceil(*p2-0.5);"]*2 +
|
222
|
+
["if (*p2 >= 0) *p1 = (typec)floor(*p2+0.5);
|
223
|
+
else *p1 = (typec)ceil(*p2-0.5);"]*2 +
|
224
224
|
[nil]*3
|
225
225
|
)
|
226
226
|
|
227
227
|
mkfuncs('Abs',$real_types,$data_types,[nil] +
|
228
228
|
["*p1 = *p2;"] +
|
229
229
|
["*p1 = (*p2<0) ? -*p2 : *p2;"]*4 +
|
230
|
-
["*p1 = hypot(p2->r, p2->i);"]*2 +
|
230
|
+
["*p1 = (typec)hypot(p2->r, p2->i);"]*2 +
|
231
231
|
["*p1 = rb_funcall(*p2,na_id_abs,0);"]
|
232
232
|
)
|
233
233
|
|
@@ -324,8 +324,8 @@ $func_body =
|
|
324
324
|
"
|
325
325
|
mkfuncs('IndGen',$data_types,[$data_types[3]]*8,
|
326
326
|
[nil] +
|
327
|
-
["*p1 = p2;"]*5 +
|
328
|
-
["p1->r = p2;
|
327
|
+
["*p1 = (typef)p2;"]*5 +
|
328
|
+
["p1->r = (typef)p2;
|
329
329
|
p1->i = 0;"]*2 +
|
330
330
|
["*p1 = INT2FIX(p2);"]
|
331
331
|
)
|
data/src/na_linalg.c
CHANGED
@@ -565,8 +565,8 @@ na_lu_init(VALUE self, VALUE lu, VALUE piv)
|
|
565
565
|
|
566
566
|
void Init_na_linalg()
|
567
567
|
{
|
568
|
-
static double tiny_d=1e-15;
|
569
|
-
static float tiny_f=1e-7;
|
568
|
+
static double tiny_d = 1e-15;
|
569
|
+
static float tiny_f = (float)1e-7;
|
570
570
|
int i, sz;
|
571
571
|
int32_t one=1, zero=0;
|
572
572
|
static VALUE zerov = INT2FIX(0);
|
data/src/na_random.c
CHANGED
data/src/narray.h
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: narray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0.
|
4
|
+
version: 0.6.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Numerical N-dimensional Array class
|
15
15
|
email: masa16.tanaka@gmail.com
|