numo-narray 0.9.0.1 → 0.9.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/ext/numo/narray/array.c +3 -3
  4. data/ext/numo/narray/data.c +102 -81
  5. data/ext/numo/narray/depend.erb +9 -7
  6. data/ext/numo/narray/extconf.rb +4 -24
  7. data/ext/numo/narray/gen/cogen.rb +19 -4
  8. data/ext/numo/narray/gen/def/bit.rb +31 -0
  9. data/ext/numo/narray/gen/def/robject.rb +1 -1
  10. data/ext/numo/narray/gen/dtype.erb.c +11 -257
  11. data/ext/numo/narray/gen/spec.rb +294 -0
  12. data/ext/numo/narray/gen/tmpl/aset.c +1 -1
  13. data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
  14. data/ext/numo/narray/gen/tmpl/eye.c +5 -5
  15. data/ext/numo/narray/gen/tmpl/logseq.c +82 -0
  16. data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
  17. data/ext/numo/narray/gen/tmpl/rand.c +126 -5
  18. data/ext/numo/narray/gen/tmpl/seq.c +43 -12
  19. data/ext/numo/narray/gen/tmpl/store_bit.c +55 -0
  20. data/ext/numo/narray/gen/tmpl_bit/allocate.c +28 -0
  21. data/ext/numo/narray/gen/tmpl_bit/aref.c +53 -0
  22. data/ext/numo/narray/gen/tmpl_bit/aset.c +63 -0
  23. data/ext/numo/narray/gen/{tmpl/bit_binary.c → tmpl_bit/binary.c} +1 -1
  24. data/ext/numo/narray/gen/{tmpl → tmpl_bit}/bit_count.c +5 -3
  25. data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +128 -0
  26. data/ext/numo/narray/gen/tmpl_bit/cast.c +37 -0
  27. data/ext/numo/narray/gen/tmpl_bit/cast_array.c +80 -0
  28. data/ext/numo/narray/gen/tmpl_bit/cast_numeric.c +22 -0
  29. data/ext/numo/narray/gen/tmpl_bit/coerce_cast.c +8 -0
  30. data/ext/numo/narray/gen/tmpl_bit/each.c +44 -0
  31. data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +66 -0
  32. data/ext/numo/narray/gen/tmpl_bit/extract.c +25 -0
  33. data/ext/numo/narray/gen/tmpl_bit/fill.c +65 -0
  34. data/ext/numo/narray/gen/tmpl_bit/format.c +61 -0
  35. data/ext/numo/narray/gen/tmpl_bit/format_to_a.c +48 -0
  36. data/ext/numo/narray/gen/tmpl_bit/inspect.c +18 -0
  37. data/ext/numo/narray/gen/tmpl_bit/map_with_index.c +94 -0
  38. data/ext/numo/narray/gen/tmpl_bit/mask.c +117 -0
  39. data/ext/numo/narray/gen/tmpl_bit/none_p.c +14 -0
  40. data/ext/numo/narray/gen/tmpl_bit/store.c +32 -0
  41. data/ext/numo/narray/gen/tmpl_bit/store_array.c +5 -0
  42. data/ext/numo/narray/gen/tmpl_bit/store_bit.c +66 -0
  43. data/ext/numo/narray/gen/tmpl_bit/store_from.c +56 -0
  44. data/ext/numo/narray/gen/tmpl_bit/store_numeric.c +22 -0
  45. data/ext/numo/narray/gen/tmpl_bit/to_a.c +43 -0
  46. data/ext/numo/narray/gen/{tmpl/bit_unary.c → tmpl_bit/unary.c} +1 -1
  47. data/ext/numo/narray/gen/tmpl_bit/where.c +102 -0
  48. data/ext/numo/narray/gen/tmpl_bit/where2.c +37 -0
  49. data/ext/numo/narray/index.c +9 -7
  50. data/ext/numo/narray/math.c +4 -1
  51. data/ext/numo/narray/narray.c +302 -100
  52. data/ext/numo/narray/ndloop.c +21 -36
  53. data/ext/numo/narray/numo/intern.h +3 -3
  54. data/ext/numo/narray/numo/narray.h +5 -41
  55. data/ext/numo/narray/numo/template.h +2 -2
  56. data/ext/numo/narray/numo/types/bit.h +27 -13
  57. data/ext/numo/narray/numo/types/complex.h +2 -2
  58. data/ext/numo/narray/numo/types/complex_macro.h +19 -7
  59. data/ext/numo/narray/numo/types/dcomplex.h +9 -0
  60. data/ext/numo/narray/numo/types/dfloat.h +6 -0
  61. data/ext/numo/narray/numo/types/float_macro.h +9 -2
  62. data/ext/numo/narray/numo/types/int16.h +0 -1
  63. data/ext/numo/narray/numo/types/int32.h +0 -1
  64. data/ext/numo/narray/numo/types/int64.h +0 -1
  65. data/ext/numo/narray/numo/types/int8.h +0 -1
  66. data/ext/numo/narray/numo/types/int_macro.h +2 -1
  67. data/ext/numo/narray/numo/types/robj_macro.h +9 -2
  68. data/ext/numo/narray/numo/types/robject.h +6 -0
  69. data/ext/numo/narray/numo/types/scomplex.h +9 -0
  70. data/ext/numo/narray/numo/types/sfloat.h +6 -0
  71. data/ext/numo/narray/numo/types/uint16.h +0 -1
  72. data/ext/numo/narray/numo/types/uint32.h +0 -1
  73. data/ext/numo/narray/numo/types/uint64.h +0 -1
  74. data/ext/numo/narray/numo/types/uint8.h +0 -1
  75. data/ext/numo/narray/numo/types/uint_macro.h +2 -1
  76. data/ext/numo/narray/numo/types/xint_macro.h +6 -1
  77. data/ext/numo/narray/rand.c +2 -2
  78. data/ext/numo/narray/step.c +7 -7
  79. data/ext/numo/narray/struct.c +9 -9
  80. data/lib/erbpp.rb +6 -2
  81. data/lib/erbpp/narray_def.rb +21 -21
  82. metadata +35 -6
  83. data/ext/numo/narray/gen/bit.erb.c +0 -811
@@ -7,6 +7,5 @@ typedef int16_t rtype;
7
7
  #define m_data_to_num(x) INT2NUM((int)(x))
8
8
  #define m_extract(x) INT2NUM((int)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%d",(int)(x))
10
- #define m_rand ((dtype)gen_rand32())
11
10
 
12
11
  #include "int_macro.h"
@@ -7,6 +7,5 @@ typedef int32_t rtype;
7
7
  #define m_data_to_num(x) INT322NUM((int32_t)(x))
8
8
  #define m_extract(x) INT322NUM((int32_t)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%"PRId32,(int32_t)(x))
10
- #define m_rand ((dtype)gen_rand32())
11
10
 
12
11
  #include "int_macro.h"
@@ -7,6 +7,5 @@ typedef int64_t rtype;
7
7
  #define m_data_to_num(x) INT642NUM((int64_t)(x))
8
8
  #define m_extract(x) INT642NUM((int64_t)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%"PRId64,(int64_t)(x))
10
- #define m_rand ((dtype)gen_rand64())
11
10
 
12
11
  #include "int_macro.h"
@@ -7,6 +7,5 @@ typedef int8_t rtype;
7
7
  #define m_data_to_num(x) INT2NUM((int)(x))
8
8
  #define m_extract(x) INT2NUM((int)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%d",(int)(x))
10
- #define m_rand ((dtype)gen_rand32())
11
10
 
12
11
  #include "int_macro.h"
@@ -1,8 +1,9 @@
1
1
  #include "xint_macro.h"
2
2
 
3
3
  #define m_abs(x) ((x<0)?-x:x)
4
+ #define m_sign(x) (((x)==0) ? 0 : (((x)>0) ? 1 : -1))
4
5
 
5
- static inline dtype int_inverse(dtype x) {
6
+ static inline dtype int_reciprocal(dtype x) {
6
7
  switch (x) {
7
8
  case 1:
8
9
  return 1;
@@ -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 m_inverse(x) rb_funcall(x,id_inverse,0)
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
 
@@ -7,6 +7,5 @@ typedef u_int16_t rtype;
7
7
  #define m_data_to_num(x) UINT2NUM((unsigned int)(x))
8
8
  #define m_extract(x) UINT2NUM((unsigned int)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%u",(unsigned int)(x))
10
- #define m_rand ((dtype)gen_rand32())
11
10
 
12
11
  #include "uint_macro.h"
@@ -7,6 +7,5 @@ typedef u_int32_t rtype;
7
7
  #define m_data_to_num(x) UINT322NUM((u_int32_t)(x))
8
8
  #define m_extract(x) UINT322NUM((u_int32_t)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%"PRIu32,(u_int32_t)(x))
10
- #define m_rand ((dtype)gen_rand32())
11
10
 
12
11
  #include "uint_macro.h"
@@ -7,6 +7,5 @@ typedef u_int64_t rtype;
7
7
  #define m_data_to_num(x) UINT642NUM((u_int64_t)(x))
8
8
  #define m_extract(x) UINT642NUM((u_int64_t)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%"PRIu64,(u_int64_t)(x))
10
- #define m_rand ((dtype)gen_rand64())
11
10
 
12
11
  #include "uint_macro.h"
@@ -7,6 +7,5 @@ typedef u_int8_t rtype;
7
7
  #define m_data_to_num(x) UINT2NUM((unsigned int)(x))
8
8
  #define m_extract(x) UINT2NUM((unsigned int)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%u",(unsigned int)(x))
10
- #define m_rand ((dtype)gen_rand32())
11
10
 
12
11
  #include "uint_macro.h"
@@ -1,8 +1,9 @@
1
1
  #include "xint_macro.h"
2
2
 
3
3
  #define m_abs(x) (x)
4
+ #define m_sign(x) (((x)==0) ? 0:1)
4
5
 
5
- static inline dtype int_inverse(dtype x) {
6
+ static inline dtype int_reciprocal(dtype x) {
6
7
  switch (x) {
7
8
  case 1:
8
9
  return 1;
@@ -19,7 +19,7 @@
19
19
  #define m_bit_not(x) (~(x))
20
20
 
21
21
  #define m_minus(x) (-(x))
22
- #define m_inverse(x) int_inverse(x)
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
+ }
@@ -41,9 +41,9 @@ void rand_norm(double *a)
41
41
  {
42
42
  double x1, x2, w;
43
43
  do {
44
- x1 = to_res53(gen_rand64());
44
+ x1 = genrand_res53_mix();
45
45
  x1 = x1*2-1;
46
- x2 = to_res53(gen_rand64());
46
+ x2 = genrand_res53_mix();
47
47
  x2 = x2*2-1;
48
48
  w = x1 * x1 + x2 * x2;
49
49
  } while (w>=1);
@@ -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 = NUM2SSIZE(vbeg);
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 = NUM2SSIZE(vend);
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 = NUM2SIZE(vlen);
248
+ len = NUM2SIZET(vlen);
249
249
  if (len>0) {
250
250
  if (RTEST(vstep)) {
251
- step = NUM2SSIZE(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 = NUM2SSIZE(vstep);
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 = NUM2SIZE(vlen);
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 = NUM2SIZE(RARRAY_PTR(a)[2]);
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));
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  nstrut.c
3
3
  Numerical Array Extension for Ruby
4
- (C) Copyright 1999-2007,2013 by Masahiro TANAKA
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(NUM2SIZE(velmsz) * na->size);
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 %"SZF"u out of range of struct(size:%ld)", i, len);
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 += NUM2SIZE(offset);
173
+ na2->offset += NUM2SIZET(offset);
174
174
  }
175
175
 
176
176
  return view;
@@ -373,7 +373,7 @@ nstruct_add_type(VALUE type, int argc, VALUE *argv, VALUE nst)
373
373
  }
374
374
 
375
375
  ofs = rb_iv_get(nst, "__offset__");
376
- nt->offset = NUM2SIZE(ofs);
376
+ nt->offset = NUM2SIZET(ofs);
377
377
 
378
378
  size = rb_funcall(type, rb_intern("byte_size"), 0);
379
379
  rb_iv_set(nst, "__offset__", rb_funcall(ofs,'+',1,size));
@@ -409,8 +409,8 @@ iter_nstruct_to_a(na_loop_t *const lp)
409
409
 
410
410
  for (i=0; i<len; i++) {
411
411
  def = RARRAY_AREF(defs,i);
412
- ofs = NUM2SIZE(RARRAY_AREF(def,2));
413
- //ofs = NUM2SIZE(RARRAY_AREF(ofsts,i));
412
+ ofs = NUM2SIZET(RARRAY_AREF(def,2));
413
+ //ofs = NUM2SIZET(RARRAY_AREF(ofsts,i));
414
414
  elmt = RARRAY_AREF(types,i);
415
415
  GetNArrayView(elmt,ne);
416
416
  ne->offset = pos + ofs;
@@ -592,7 +592,7 @@ iter_nstruct_from_a(na_loop_t *const lp)
592
592
 
593
593
  for (i=0; i<len; i++) {
594
594
  def = RARRAY_AREF(defs,i);
595
- ofs = NUM2SIZE(RARRAY_AREF(def,2));
595
+ ofs = NUM2SIZET(RARRAY_AREF(def,2));
596
596
  elmt = RARRAY_AREF(types,i);
597
597
  GetNArrayView(elmt,ne);
598
598
  ne->offset = lp->args[1].iter[0].pos + ofs;
@@ -747,7 +747,7 @@ iter_struct_inspect(char *ptr, size_t pos, VALUE opt)
747
747
  for (i=0; i<len; i++) {
748
748
  def = RARRAY_AREF(defs,i);
749
749
  name = RARRAY_AREF(def,0);
750
- ofs = NUM2SIZE(RARRAY_AREF(def,2));
750
+ ofs = NUM2SIZET(RARRAY_AREF(def,2));
751
751
  elmt = RARRAY_AREF(types,i);
752
752
  GetNArrayView(elmt,ne);
753
753
  ne->offset = pos + ofs;
@@ -148,7 +148,7 @@ class Function < ErbPP
148
148
 
149
149
  attrs = %w[
150
150
  singleton
151
- method
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 || method
202
+ @op || meth
199
203
  end
200
204
 
201
205
  def code
@@ -7,7 +7,7 @@ module DefMethod
7
7
  end
8
8
 
9
9
  def def_method(meth, n_arg, tmpl=nil, opts={})
10
- h = {:method => meth, :n_arg => n_arg}
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 = {:method => "allocate", :singleton => true}
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 = {:method => meth, :mod_var => 'mTM', :n_arg => n}
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.method }
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,12 +248,13 @@ class DataType < ErbPP
249
248
  t = "cT"
250
249
  end
251
250
  if c=="Integer"
252
- if RUBY_VERSION >= "2.4.0"
253
- @upcast << "rb_hash_aset(hCast, rb_cInteger, #{t});"
254
- else
251
+ if defined?(Fixnum) && Fixnum != Integer
255
252
  @upcast << "rb_hash_aset(hCast, rb_cFixnum, #{t});"
256
253
  @upcast << "rb_hash_aset(hCast, rb_cBignum, #{t});"
257
- end
254
+ else
255
+ # RUBY_VERSION >= "2.4.0"
256
+ @upcast << "rb_hash_aset(hCast, rb_cInteger, #{t});"
257
+ end
258
258
  else
259
259
  @upcast << "rb_hash_aset(hCast, rb_c#{c}, #{t});"
260
260
  end