numo-narray 0.9.0.1-x86-mingw32 → 0.9.0.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -7
- data/Rakefile +21 -6
- data/ext/numo/narray/array.c +3 -3
- data/ext/numo/narray/data.c +102 -81
- data/ext/numo/narray/depend.erb +9 -7
- data/ext/numo/narray/extconf.rb +5 -24
- data/ext/numo/narray/gen/cogen.rb +19 -4
- data/ext/numo/narray/gen/def/bit.rb +31 -0
- data/ext/numo/narray/gen/def/robject.rb +1 -1
- data/ext/numo/narray/gen/dtype.erb.c +11 -257
- data/ext/numo/narray/gen/spec.rb +294 -0
- data/ext/numo/narray/gen/tmpl/aset.c +1 -1
- data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl/eye.c +5 -5
- data/ext/numo/narray/gen/tmpl/logseq.c +82 -0
- data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl/rand.c +126 -5
- data/ext/numo/narray/gen/tmpl/seq.c +43 -12
- data/ext/numo/narray/gen/tmpl/store_bit.c +55 -0
- data/ext/numo/narray/gen/tmpl_bit/allocate.c +28 -0
- data/ext/numo/narray/gen/tmpl_bit/aref.c +53 -0
- data/ext/numo/narray/gen/tmpl_bit/aset.c +63 -0
- data/ext/numo/narray/gen/{tmpl/bit_binary.c → tmpl_bit/binary.c} +1 -1
- data/ext/numo/narray/gen/{tmpl → tmpl_bit}/bit_count.c +5 -3
- data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +128 -0
- data/ext/numo/narray/gen/tmpl_bit/cast.c +37 -0
- data/ext/numo/narray/gen/tmpl_bit/cast_array.c +80 -0
- data/ext/numo/narray/gen/tmpl_bit/cast_numeric.c +22 -0
- data/ext/numo/narray/gen/tmpl_bit/coerce_cast.c +8 -0
- data/ext/numo/narray/gen/tmpl_bit/each.c +44 -0
- data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +66 -0
- data/ext/numo/narray/gen/tmpl_bit/extract.c +25 -0
- data/ext/numo/narray/gen/tmpl_bit/fill.c +65 -0
- data/ext/numo/narray/gen/tmpl_bit/format.c +61 -0
- data/ext/numo/narray/gen/tmpl_bit/format_to_a.c +48 -0
- data/ext/numo/narray/gen/tmpl_bit/inspect.c +18 -0
- data/ext/numo/narray/gen/tmpl_bit/map_with_index.c +94 -0
- data/ext/numo/narray/gen/tmpl_bit/mask.c +117 -0
- data/ext/numo/narray/gen/tmpl_bit/none_p.c +14 -0
- data/ext/numo/narray/gen/tmpl_bit/store.c +32 -0
- data/ext/numo/narray/gen/tmpl_bit/store_array.c +5 -0
- data/ext/numo/narray/gen/tmpl_bit/store_bit.c +66 -0
- data/ext/numo/narray/gen/tmpl_bit/store_from.c +56 -0
- data/ext/numo/narray/gen/tmpl_bit/store_numeric.c +22 -0
- data/ext/numo/narray/gen/tmpl_bit/to_a.c +43 -0
- data/ext/numo/narray/gen/{tmpl/bit_unary.c → tmpl_bit/unary.c} +1 -1
- data/ext/numo/narray/gen/tmpl_bit/where.c +102 -0
- data/ext/numo/narray/gen/tmpl_bit/where2.c +37 -0
- data/ext/numo/narray/index.c +9 -7
- data/ext/numo/narray/math.c +6 -1
- data/ext/numo/narray/narray.c +307 -103
- data/ext/numo/narray/ndloop.c +21 -36
- data/ext/numo/narray/numo/intern.h +3 -3
- data/ext/numo/narray/numo/narray.h +5 -41
- data/ext/numo/narray/numo/template.h +2 -2
- data/ext/numo/narray/numo/types/bit.h +27 -13
- data/ext/numo/narray/numo/types/complex.h +2 -2
- data/ext/numo/narray/numo/types/complex_macro.h +19 -7
- data/ext/numo/narray/numo/types/dcomplex.h +9 -0
- data/ext/numo/narray/numo/types/dfloat.h +6 -0
- data/ext/numo/narray/numo/types/float_macro.h +9 -2
- data/ext/numo/narray/numo/types/int16.h +0 -1
- data/ext/numo/narray/numo/types/int32.h +0 -1
- data/ext/numo/narray/numo/types/int64.h +0 -1
- data/ext/numo/narray/numo/types/int8.h +0 -1
- data/ext/numo/narray/numo/types/int_macro.h +2 -1
- data/ext/numo/narray/numo/types/robj_macro.h +9 -2
- data/ext/numo/narray/numo/types/robject.h +6 -0
- data/ext/numo/narray/numo/types/scomplex.h +9 -0
- data/ext/numo/narray/numo/types/sfloat.h +6 -0
- data/ext/numo/narray/numo/types/uint16.h +0 -1
- data/ext/numo/narray/numo/types/uint32.h +0 -1
- data/ext/numo/narray/numo/types/uint64.h +0 -1
- data/ext/numo/narray/numo/types/uint8.h +0 -1
- data/ext/numo/narray/numo/types/uint_macro.h +2 -1
- data/ext/numo/narray/numo/types/xint_macro.h +6 -1
- data/ext/numo/narray/rand.c +2 -2
- data/ext/numo/narray/step.c +7 -7
- data/ext/numo/narray/struct.c +11 -12
- data/lib/2.0/numo/narray.so +0 -0
- data/lib/2.1/numo/narray.so +0 -0
- data/lib/2.2/numo/narray.so +0 -0
- data/lib/2.3/numo/narray.so +0 -0
- data/lib/2.4/numo/narray.so +0 -0
- data/lib/erbpp.rb +6 -2
- data/lib/erbpp/line_number.rb +1 -1
- data/lib/erbpp/narray_def.rb +23 -19
- data/numo-narray.gemspec +2 -2
- metadata +45 -10
- data/ext/numo/narray/gen/bit.erb.c +0 -811
@@ -20,11 +20,13 @@
|
|
20
20
|
|
21
21
|
#define m_abs(x) rb_funcall(x,id_abs,0)
|
22
22
|
#define m_minus(x) rb_funcall(x,id_minus,0)
|
23
|
-
#define
|
23
|
+
#define m_reciprocal(x) rb_funcall(x,id_reciprocal,0)
|
24
24
|
#define m_square(x) rb_funcall(x,'*',1,x)
|
25
25
|
#define m_floor(x) rb_funcall(x,id_floor,0)
|
26
26
|
#define m_round(x) rb_funcall(x,id_round,0)
|
27
27
|
#define m_ceil(x) rb_funcall(x,id_ceil,0)
|
28
|
+
#define m_trunc(x) rb_funcall(x,id_truncate,0)
|
29
|
+
#define m_sign(x) rb_funcall(x,id_op_ufo,1,INT2FIX(0))
|
28
30
|
|
29
31
|
#define m_eq(x,y) RTEST(rb_funcall(x,id_eq,1,y))
|
30
32
|
#define m_ne(x,y) RTEST(rb_funcall(x,id_ne,1,y))
|
@@ -45,7 +47,6 @@
|
|
45
47
|
#define m_mulsum(x,y,z) {z = m_add(m_mul(x,y),z);}
|
46
48
|
#define m_mulsum_init INT2FIX(0)
|
47
49
|
|
48
|
-
#define m_rand to_res53(gen_rand64())
|
49
50
|
#define m_rand_norm(a) rand_norm(a)
|
50
51
|
|
51
52
|
#define m_sprintf(s,x) robj_sprintf(s,x)
|
@@ -216,3 +217,9 @@ static inline size_t f_max_index(size_t n, char *p, ssize_t stride)
|
|
216
217
|
}
|
217
218
|
return j;
|
218
219
|
}
|
220
|
+
|
221
|
+
static inline dtype f_seq(dtype x, dtype y, size_t c)
|
222
|
+
{
|
223
|
+
y = m_mul(y,SIZET2NUM(c));
|
224
|
+
return m_add(x,y);
|
225
|
+
}
|
@@ -19,3 +19,9 @@ inline static int robj_nearly_eq(VALUE vx, VALUE vy)
|
|
19
19
|
y = NUM2DBL(vy);
|
20
20
|
return (fabs(x-y)<=(fabs(x)+fabs(y))*DBL_EPSILON*2);
|
21
21
|
}
|
22
|
+
|
23
|
+
/* generates a random number on [0,1)-real-interval */
|
24
|
+
inline static dtype m_rand(dtype max)
|
25
|
+
{
|
26
|
+
return DBL2NUM(genrand_res53_mix() * max);
|
27
|
+
}
|
@@ -9,3 +9,12 @@ typedef float rtype;
|
|
9
9
|
static inline bool c_nearly_eq(dtype x, dtype y) {
|
10
10
|
return c_abs(c_sub(x,y)) <= (c_abs(x)+c_abs(y))*FLT_EPSILON*2;
|
11
11
|
}
|
12
|
+
|
13
|
+
/* generates a random number on [0,1)-real-interval */
|
14
|
+
inline static dtype m_rand(dtype max)
|
15
|
+
{
|
16
|
+
dtype z;
|
17
|
+
REAL(z) = to_real2(gen_rand32()) * REAL(max);
|
18
|
+
IMAG(z) = to_real2(gen_rand32()) * IMAG(max);
|
19
|
+
return z;
|
20
|
+
}
|
@@ -6,6 +6,12 @@ typedef float rtype;
|
|
6
6
|
|
7
7
|
#include "float_macro.h"
|
8
8
|
|
9
|
+
/* generates a random number on [0,1)-real-interval */
|
10
|
+
inline static dtype m_rand(dtype max)
|
11
|
+
{
|
12
|
+
return to_real2(gen_rand32()) * max;
|
13
|
+
}
|
14
|
+
|
9
15
|
#define m_min_init numo_sfloat_new_dim0(0.0/0.0)
|
10
16
|
#define m_max_init numo_sfloat_new_dim0(0.0/0.0)
|
11
17
|
|
@@ -19,7 +19,7 @@
|
|
19
19
|
#define m_bit_not(x) (~(x))
|
20
20
|
|
21
21
|
#define m_minus(x) (-(x))
|
22
|
-
#define
|
22
|
+
#define m_reciprocal(x) int_reciprocal(x)
|
23
23
|
#define m_square(x) ((x)*(x))
|
24
24
|
|
25
25
|
#define m_eq(x,y) ((x)==(y))
|
@@ -131,3 +131,8 @@ static inline size_t f_max_index(size_t n, char *p, ssize_t stride)
|
|
131
131
|
}
|
132
132
|
return j;
|
133
133
|
}
|
134
|
+
|
135
|
+
static inline double f_seq(double x, double y, double c)
|
136
|
+
{
|
137
|
+
return x + y * c;
|
138
|
+
}
|
data/ext/numo/narray/rand.c
CHANGED
@@ -41,9 +41,9 @@ void rand_norm(double *a)
|
|
41
41
|
{
|
42
42
|
double x1, x2, w;
|
43
43
|
do {
|
44
|
-
x1 =
|
44
|
+
x1 = genrand_res53_mix();
|
45
45
|
x1 = x1*2-1;
|
46
|
-
x2 =
|
46
|
+
x2 = genrand_res53_mix();
|
47
47
|
x2 = x2*2-1;
|
48
48
|
w = x1 * x1 + x2 * x2;
|
49
49
|
} while (w>=1);
|
data/ext/numo/narray/step.c
CHANGED
@@ -230,13 +230,13 @@ nary_step_array_index(VALUE self, size_t ary_size,
|
|
230
230
|
//vstep = rb_funcall(self, id_step, 0);
|
231
231
|
|
232
232
|
if (RTEST(vbeg)) {
|
233
|
-
beg =
|
233
|
+
beg = NUM2SSIZET(vbeg);
|
234
234
|
if (beg<0) {
|
235
235
|
beg += ary_size;
|
236
236
|
}
|
237
237
|
}
|
238
238
|
if (RTEST(vend)) {
|
239
|
-
end =
|
239
|
+
end = NUM2SSIZET(vend);
|
240
240
|
if (end<0) {
|
241
241
|
end += ary_size;
|
242
242
|
}
|
@@ -245,10 +245,10 @@ nary_step_array_index(VALUE self, size_t ary_size,
|
|
245
245
|
//puts("pass 1");
|
246
246
|
|
247
247
|
if (RTEST(vlen)) {
|
248
|
-
len =
|
248
|
+
len = NUM2SIZET(vlen);
|
249
249
|
if (len>0) {
|
250
250
|
if (RTEST(vstep)) {
|
251
|
-
step =
|
251
|
+
step = NUM2SSIZET(step);
|
252
252
|
if (RTEST(vbeg)) {
|
253
253
|
if (RTEST(vend)) {
|
254
254
|
rb_raise( rb_eStandardError, "verbose Step object" );
|
@@ -295,7 +295,7 @@ nary_step_array_index(VALUE self, size_t ary_size,
|
|
295
295
|
}
|
296
296
|
} else { // no len
|
297
297
|
if (RTEST(vstep)) {
|
298
|
-
step =
|
298
|
+
step = NUM2SSIZET(vstep);
|
299
299
|
} else {
|
300
300
|
step = 1;
|
301
301
|
}
|
@@ -368,7 +368,7 @@ nary_step_sequence( VALUE self, size_t *plen, double *pbeg, double *pstep )
|
|
368
368
|
//vstep = rb_funcall(self, id_step,0);
|
369
369
|
|
370
370
|
if (RTEST(vlen)) {
|
371
|
-
size =
|
371
|
+
size = NUM2SIZET(vlen);
|
372
372
|
|
373
373
|
if (!RTEST(vstep)) {
|
374
374
|
if (RTEST(vend)) {
|
@@ -429,7 +429,7 @@ step_each( VALUE self )
|
|
429
429
|
a = nary_step_parameters( self, Qnil );
|
430
430
|
beg = NUM2DBL(RARRAY_PTR(a)[0]);
|
431
431
|
step = NUM2DBL(RARRAY_PTR(a)[1]);
|
432
|
-
size =
|
432
|
+
size = NUM2SIZET(RARRAY_PTR(a)[2]);
|
433
433
|
|
434
434
|
for (i=0; i<size; i++) {
|
435
435
|
rb_yield(rb_float_new(beg+i*step));
|
data/ext/numo/narray/struct.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
nstrut.c
|
3
3
|
Numerical Array Extension for Ruby
|
4
|
-
(C) Copyright 1999-
|
4
|
+
(C) Copyright 1999-2016 by Masahiro TANAKA
|
5
5
|
|
6
6
|
This program is free software.
|
7
7
|
You can distribute/modify this program
|
@@ -29,7 +29,7 @@ nst_allocate(VALUE self)
|
|
29
29
|
ptr = NA_DATA_PTR(na);
|
30
30
|
if (na->size > 0 && ptr == NULL) {
|
31
31
|
velmsz = rb_const_get(CLASS_OF(self), rb_intern("element_byte_size"));
|
32
|
-
ptr = xmalloc(
|
32
|
+
ptr = xmalloc(NUM2SIZET(velmsz) * na->size);
|
33
33
|
NA_DATA_PTR(na) = ptr;
|
34
34
|
}
|
35
35
|
break;
|
@@ -70,7 +70,7 @@ nst_definition(VALUE nst, VALUE idx)
|
|
70
70
|
} else if (rb_obj_is_kind_of(idx,rb_cNumeric)) {
|
71
71
|
i = NUM2LONG(idx);
|
72
72
|
if (i<-len || i>=len) {
|
73
|
-
rb_raise(rb_eIndexError,"offset %
|
73
|
+
rb_raise(rb_eIndexError,"offset %ld out of range of struct(size:%ld)", i, len);
|
74
74
|
}
|
75
75
|
return RARRAY_AREF(def,i);
|
76
76
|
}
|
@@ -170,7 +170,7 @@ na_make_view_struct(VALUE self, VALUE dtype, VALUE offset)
|
|
170
170
|
}
|
171
171
|
|
172
172
|
if (RTEST(offset)) {
|
173
|
-
na2->offset +=
|
173
|
+
na2->offset += NUM2SIZET(offset);
|
174
174
|
}
|
175
175
|
|
176
176
|
return view;
|
@@ -273,9 +273,8 @@ nst_s_new(int argc, VALUE *argv, VALUE klass)
|
|
273
273
|
}
|
274
274
|
|
275
275
|
if (NIL_P(name)) {
|
276
|
-
st =
|
277
|
-
|
278
|
-
rb_class_inherited(klass, st);
|
276
|
+
st = rb_define_class_id(name, klass);
|
277
|
+
rb_funcall(klass, rb_intern("inherited"), 1, st);
|
279
278
|
}
|
280
279
|
else {
|
281
280
|
char *cname = StringValuePtr(name);
|
@@ -374,7 +373,7 @@ nstruct_add_type(VALUE type, int argc, VALUE *argv, VALUE nst)
|
|
374
373
|
}
|
375
374
|
|
376
375
|
ofs = rb_iv_get(nst, "__offset__");
|
377
|
-
nt->offset =
|
376
|
+
nt->offset = NUM2SIZET(ofs);
|
378
377
|
|
379
378
|
size = rb_funcall(type, rb_intern("byte_size"), 0);
|
380
379
|
rb_iv_set(nst, "__offset__", rb_funcall(ofs,'+',1,size));
|
@@ -410,8 +409,8 @@ iter_nstruct_to_a(na_loop_t *const lp)
|
|
410
409
|
|
411
410
|
for (i=0; i<len; i++) {
|
412
411
|
def = RARRAY_AREF(defs,i);
|
413
|
-
ofs =
|
414
|
-
//ofs =
|
412
|
+
ofs = NUM2SIZET(RARRAY_AREF(def,2));
|
413
|
+
//ofs = NUM2SIZET(RARRAY_AREF(ofsts,i));
|
415
414
|
elmt = RARRAY_AREF(types,i);
|
416
415
|
GetNArrayView(elmt,ne);
|
417
416
|
ne->offset = pos + ofs;
|
@@ -593,7 +592,7 @@ iter_nstruct_from_a(na_loop_t *const lp)
|
|
593
592
|
|
594
593
|
for (i=0; i<len; i++) {
|
595
594
|
def = RARRAY_AREF(defs,i);
|
596
|
-
ofs =
|
595
|
+
ofs = NUM2SIZET(RARRAY_AREF(def,2));
|
597
596
|
elmt = RARRAY_AREF(types,i);
|
598
597
|
GetNArrayView(elmt,ne);
|
599
598
|
ne->offset = lp->args[1].iter[0].pos + ofs;
|
@@ -748,7 +747,7 @@ iter_struct_inspect(char *ptr, size_t pos, VALUE opt)
|
|
748
747
|
for (i=0; i<len; i++) {
|
749
748
|
def = RARRAY_AREF(defs,i);
|
750
749
|
name = RARRAY_AREF(def,0);
|
751
|
-
ofs =
|
750
|
+
ofs = NUM2SIZET(RARRAY_AREF(def,2));
|
752
751
|
elmt = RARRAY_AREF(types,i);
|
753
752
|
GetNArrayView(elmt,ne);
|
754
753
|
ne->offset = pos + ofs;
|
Binary file
|
data/lib/2.1/numo/narray.so
CHANGED
Binary file
|
data/lib/2.2/numo/narray.so
CHANGED
Binary file
|
data/lib/2.3/numo/narray.so
CHANGED
Binary file
|
Binary file
|
data/lib/erbpp.rb
CHANGED
@@ -148,7 +148,7 @@ class Function < ErbPP
|
|
148
148
|
|
149
149
|
attrs = %w[
|
150
150
|
singleton
|
151
|
-
|
151
|
+
meth
|
152
152
|
n_arg
|
153
153
|
]
|
154
154
|
define_attrs attrs
|
@@ -161,6 +161,10 @@ class Function < ErbPP
|
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
+
def method
|
165
|
+
meth.gsub(/\?/,"_p").gsub(/\!/,"_bang")
|
166
|
+
end
|
167
|
+
|
164
168
|
def initialize(parent,tmpl,**opts)
|
165
169
|
super
|
166
170
|
@aliases = opts[:aliases] || []
|
@@ -195,7 +199,7 @@ class Function < ErbPP
|
|
195
199
|
alias c_instance_method c_func
|
196
200
|
|
197
201
|
def op_map
|
198
|
-
@op ||
|
202
|
+
@op || meth
|
199
203
|
end
|
200
204
|
|
201
205
|
def code
|
data/lib/erbpp/line_number.rb
CHANGED
@@ -115,7 +115,7 @@ class ERB
|
|
115
115
|
# skip
|
116
116
|
elsif num==1
|
117
117
|
f = @filename.dump
|
118
|
-
line.sub!(/_erbout = '';/, "_erbout = CountLnString.new(#{f});")
|
118
|
+
line.sub!(/_erbout = (''|String\.new);/, "_erbout = CountLnString.new(#{f});")
|
119
119
|
elsif /^; _erbout\.force_encoding/ =~ line
|
120
120
|
line.sub!(/^;/,";_erbout.ln(#{num});")
|
121
121
|
end
|
data/lib/erbpp/narray_def.rb
CHANGED
@@ -7,7 +7,7 @@ module DefMethod
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def def_method(meth, n_arg, tmpl=nil, opts={})
|
10
|
-
h = {:
|
10
|
+
h = {:meth => meth, :n_arg => n_arg}
|
11
11
|
h.merge!(opts)
|
12
12
|
tmpl ||= meth
|
13
13
|
Function.new(self, tmpl, h)
|
@@ -22,7 +22,7 @@ module DefMethod
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def def_allocate(tmpl)
|
25
|
-
h = {:
|
25
|
+
h = {:meth => "allocate", :singleton => true}
|
26
26
|
Allocate.new(self, tmpl, h)
|
27
27
|
end
|
28
28
|
|
@@ -62,22 +62,15 @@ module DefMethod
|
|
62
62
|
def_method(meth, 0, "cond_unary")
|
63
63
|
end
|
64
64
|
|
65
|
-
def bit_binary(meth, op=nil)
|
66
|
-
h = {:op=>op}
|
67
|
-
h[:aliases] = [meth] if op
|
68
|
-
def_method(meth, 1, "bit_binary", h)
|
69
|
-
end
|
70
|
-
|
71
|
-
def bit_unary(meth, op=nil)
|
72
|
-
h = {:op=>op}
|
73
|
-
h[:aliases] = [meth] if op
|
74
|
-
def_method(meth, 0, "bit_unary", h)
|
75
|
-
end
|
76
|
-
|
77
65
|
def bit_count(meth)
|
78
66
|
def_method(meth, -1, "bit_count")
|
79
67
|
end
|
80
68
|
|
69
|
+
def bit_reduce(meth, init_bit)
|
70
|
+
h = {:init_bit=>init_bit}
|
71
|
+
def_method(meth, -1, "bit_reduce", h)
|
72
|
+
end
|
73
|
+
|
81
74
|
def accum(meth, dtype, tpclass)
|
82
75
|
h = {:dtype => dtype, :tpclass => tpclass}
|
83
76
|
def_method(meth, -1, "accum", h)
|
@@ -102,7 +95,7 @@ module DefMethod
|
|
102
95
|
end
|
103
96
|
|
104
97
|
def math(meth, n=1)
|
105
|
-
h = {:
|
98
|
+
h = {:meth => meth, :mod_var => 'mTM', :n_arg => n}
|
106
99
|
case n
|
107
100
|
when 1
|
108
101
|
ModuleFunction.new(self, "unary_s", h)
|
@@ -131,12 +124,16 @@ module DefMethod
|
|
131
124
|
Store.new(self,"store_from",cname.downcase,dtype,"numo_c"+cname,macro)
|
132
125
|
end
|
133
126
|
|
127
|
+
def store_bit(cname)
|
128
|
+
Store.new(self,"store_bit",cname.downcase,nil,"numo_c"+cname,nil)
|
129
|
+
end
|
130
|
+
|
134
131
|
def store
|
135
132
|
Function.new(self,"store","store")
|
136
133
|
end
|
137
134
|
|
138
135
|
def find_method(meth)
|
139
|
-
Function::DEFS.find{|x| x.kind_of?(Function) and meth == x.
|
136
|
+
Function::DEFS.find{|x| x.kind_of?(Function) and meth == x.meth }
|
140
137
|
end
|
141
138
|
|
142
139
|
def find_tmpl(meth)
|
@@ -158,8 +155,9 @@ class DataType < ErbPP
|
|
158
155
|
@class_alias = []
|
159
156
|
@upcast = []
|
160
157
|
@mod_var = "cT"
|
161
|
-
@tmpl_dir = File.join(File.dirname(erb_path),"tmpl")
|
162
158
|
load_type(type_file) if type_file
|
159
|
+
dir = template_dir || "tmpl"
|
160
|
+
@tmpl_dir = File.join(File.dirname(erb_path),dir)
|
163
161
|
end
|
164
162
|
|
165
163
|
attr_reader :tmpl_dir
|
@@ -171,6 +169,7 @@ class DataType < ErbPP
|
|
171
169
|
attrs = %w[
|
172
170
|
class_name
|
173
171
|
ctype
|
172
|
+
template_dir
|
174
173
|
blas_char
|
175
174
|
complex_class_name
|
176
175
|
complex_type
|
@@ -249,8 +248,13 @@ class DataType < ErbPP
|
|
249
248
|
t = "cT"
|
250
249
|
end
|
251
250
|
if c=="Integer"
|
252
|
-
|
253
|
-
|
251
|
+
if defined?(Fixnum) && Fixnum != Integer
|
252
|
+
@upcast << "rb_hash_aset(hCast, rb_cFixnum, #{t});"
|
253
|
+
@upcast << "rb_hash_aset(hCast, rb_cBignum, #{t});"
|
254
|
+
else
|
255
|
+
# RUBY_VERSION >= "2.4.0"
|
256
|
+
@upcast << "rb_hash_aset(hCast, rb_cInteger, #{t});"
|
257
|
+
end
|
254
258
|
else
|
255
259
|
@upcast << "rb_hash_aset(hCast, rb_c#{c}, #{t});"
|
256
260
|
end
|