numo-narray 0.9.0.4 → 0.9.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -8
  3. data/Rakefile +9 -0
  4. data/ext/numo/narray/array.c +178 -47
  5. data/ext/numo/narray/data.c +105 -97
  6. data/ext/numo/narray/depend.erb +6 -7
  7. data/ext/numo/narray/gen/cogen.rb +30 -7
  8. data/ext/numo/narray/gen/def/bit.rb +17 -14
  9. data/ext/numo/narray/gen/def/dcomplex.rb +19 -15
  10. data/ext/numo/narray/gen/def/dfloat.rb +17 -13
  11. data/ext/numo/narray/gen/def/int16.rb +16 -12
  12. data/ext/numo/narray/gen/def/int32.rb +16 -12
  13. data/ext/numo/narray/gen/def/int64.rb +16 -12
  14. data/ext/numo/narray/gen/def/int8.rb +16 -12
  15. data/ext/numo/narray/gen/def/robject.rb +18 -14
  16. data/ext/numo/narray/gen/def/scomplex.rb +19 -15
  17. data/ext/numo/narray/gen/def/sfloat.rb +17 -13
  18. data/ext/numo/narray/gen/def/uint16.rb +16 -12
  19. data/ext/numo/narray/gen/def/uint32.rb +16 -12
  20. data/ext/numo/narray/gen/def/uint64.rb +16 -12
  21. data/ext/numo/narray/gen/def/uint8.rb +16 -12
  22. data/ext/numo/narray/gen/erbpp2.rb +324 -0
  23. data/ext/numo/narray/gen/narray_def.rb +252 -0
  24. data/ext/numo/narray/gen/spec.rb +141 -71
  25. data/ext/numo/narray/gen/tmpl/accum.c +22 -9
  26. data/ext/numo/narray/gen/tmpl/accum_binary.c +29 -13
  27. data/ext/numo/narray/gen/tmpl/accum_index.c +38 -16
  28. data/ext/numo/narray/gen/tmpl/alloc_func.c +107 -0
  29. data/ext/numo/narray/gen/tmpl/allocate.c +1 -1
  30. data/ext/numo/narray/gen/tmpl/aref.c +1 -1
  31. data/ext/numo/narray/gen/tmpl/aset.c +4 -2
  32. data/ext/numo/narray/gen/tmpl/binary.c +4 -4
  33. data/ext/numo/narray/gen/tmpl/binary2.c +5 -5
  34. data/ext/numo/narray/gen/tmpl/binary_s.c +5 -5
  35. data/ext/numo/narray/gen/tmpl/bincount.c +4 -4
  36. data/ext/numo/narray/gen/tmpl/cast.c +9 -6
  37. data/ext/numo/narray/gen/tmpl/cast_array.c +4 -9
  38. data/ext/numo/narray/gen/tmpl/class.c +9 -0
  39. data/ext/numo/narray/gen/tmpl/clip.c +118 -0
  40. data/ext/numo/narray/gen/tmpl/coerce_cast.c +4 -2
  41. data/ext/numo/narray/gen/tmpl/cond_binary.c +5 -5
  42. data/ext/numo/narray/gen/tmpl/cond_unary.c +6 -6
  43. data/ext/numo/narray/gen/tmpl/cum.c +18 -9
  44. data/ext/numo/narray/gen/tmpl/each.c +2 -2
  45. data/ext/numo/narray/gen/tmpl/each_with_index.c +2 -2
  46. data/ext/numo/narray/gen/tmpl/extract.c +2 -2
  47. data/ext/numo/narray/gen/tmpl/extract_data.c +48 -0
  48. data/ext/numo/narray/gen/tmpl/eye.c +3 -3
  49. data/ext/numo/narray/gen/tmpl/fill.c +2 -2
  50. data/ext/numo/narray/gen/tmpl/format.c +5 -5
  51. data/ext/numo/narray/gen/tmpl/format_to_a.c +4 -4
  52. data/ext/numo/narray/gen/tmpl/frexp.c +37 -0
  53. data/ext/numo/narray/gen/tmpl/init_class.c +20 -0
  54. data/ext/numo/narray/gen/tmpl/init_module.c +12 -0
  55. data/ext/numo/narray/gen/tmpl/inspect.c +2 -2
  56. data/ext/numo/narray/gen/tmpl/lib.c +45 -0
  57. data/ext/numo/narray/gen/tmpl/logseq.c +1 -1
  58. data/ext/numo/narray/gen/tmpl/map_with_index.c +2 -2
  59. data/ext/numo/narray/gen/tmpl/median.c +31 -8
  60. data/ext/numo/narray/gen/tmpl/minmax.c +24 -24
  61. data/ext/numo/narray/gen/tmpl/module.c +9 -0
  62. data/ext/numo/narray/gen/tmpl/new_dim0.c +12 -0
  63. data/ext/numo/narray/gen/tmpl/poly.c +3 -3
  64. data/ext/numo/narray/gen/tmpl/pow.c +1 -1
  65. data/ext/numo/narray/gen/tmpl/powint.c +1 -1
  66. data/ext/numo/narray/gen/tmpl/qsort.c +10 -3
  67. data/ext/numo/narray/gen/tmpl/rand.c +1 -1
  68. data/ext/numo/narray/gen/tmpl/rand_norm.c +1 -1
  69. data/ext/numo/narray/gen/tmpl/seq.c +1 -1
  70. data/ext/numo/narray/gen/tmpl/set2.c +5 -5
  71. data/ext/numo/narray/gen/tmpl/sort.c +29 -14
  72. data/ext/numo/narray/gen/tmpl/sort_index.c +41 -20
  73. data/ext/numo/narray/gen/tmpl/store.c +11 -5
  74. data/ext/numo/narray/gen/tmpl/store_array.c +1 -1
  75. data/ext/numo/narray/gen/tmpl/store_bit.c +1 -1
  76. data/ext/numo/narray/gen/tmpl/store_from.c +1 -1
  77. data/ext/numo/narray/gen/tmpl/store_numeric.c +3 -16
  78. data/ext/numo/narray/gen/tmpl/to_a.c +2 -2
  79. data/ext/numo/narray/gen/tmpl/unary.c +7 -7
  80. data/ext/numo/narray/gen/tmpl/unary2.c +8 -8
  81. data/ext/numo/narray/gen/tmpl/unary_ret2.c +33 -0
  82. data/ext/numo/narray/gen/tmpl/unary_s.c +8 -8
  83. data/ext/numo/narray/gen/tmpl_bit/allocate.c +1 -5
  84. data/ext/numo/narray/gen/tmpl_bit/aref.c +1 -1
  85. data/ext/numo/narray/gen/tmpl_bit/aset.c +2 -2
  86. data/ext/numo/narray/gen/tmpl_bit/binary.c +8 -8
  87. data/ext/numo/narray/gen/tmpl_bit/bit_count.c +8 -8
  88. data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +6 -6
  89. data/ext/numo/narray/gen/tmpl_bit/each.c +2 -2
  90. data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +2 -2
  91. data/ext/numo/narray/gen/tmpl_bit/extract.c +1 -1
  92. data/ext/numo/narray/gen/tmpl_bit/fill.c +2 -2
  93. data/ext/numo/narray/gen/tmpl_bit/format.c +5 -5
  94. data/ext/numo/narray/gen/tmpl_bit/format_to_a.c +2 -2
  95. data/ext/numo/narray/gen/tmpl_bit/inspect.c +2 -2
  96. data/ext/numo/narray/gen/tmpl_bit/mask.c +5 -5
  97. data/ext/numo/narray/gen/tmpl_bit/none_p.c +4 -4
  98. data/ext/numo/narray/gen/tmpl_bit/store_array.c +2 -2
  99. data/ext/numo/narray/gen/tmpl_bit/store_bit.c +1 -1
  100. data/ext/numo/narray/gen/tmpl_bit/store_from.c +1 -1
  101. data/ext/numo/narray/gen/tmpl_bit/to_a.c +2 -2
  102. data/ext/numo/narray/gen/tmpl_bit/unary.c +9 -9
  103. data/ext/numo/narray/gen/tmpl_bit/where.c +6 -6
  104. data/ext/numo/narray/gen/tmpl_bit/where2.c +8 -8
  105. data/ext/numo/narray/index.c +46 -30
  106. data/ext/numo/narray/math.c +12 -6
  107. data/ext/numo/narray/narray.c +242 -218
  108. data/ext/numo/narray/ndloop.c +17 -24
  109. data/ext/numo/narray/numo/intern.h +63 -67
  110. data/ext/numo/narray/numo/narray.h +38 -13
  111. data/ext/numo/narray/numo/ndloop.h +1 -1
  112. data/ext/numo/narray/numo/template.h +1 -1
  113. data/ext/numo/narray/numo/types/complex.h +8 -4
  114. data/ext/numo/narray/numo/types/complex_macro.h +118 -1
  115. data/ext/numo/narray/numo/types/float_macro.h +283 -6
  116. data/ext/numo/narray/numo/types/robj_macro.h +261 -9
  117. data/ext/numo/narray/numo/types/xint_macro.h +35 -0
  118. data/ext/numo/narray/struct.c +34 -15
  119. data/lib/erbpp.rb +5 -1
  120. data/lib/erbpp/line_number.rb +10 -3
  121. data/lib/erbpp/narray_def.rb +55 -25
  122. data/lib/numo/narray/extra.rb +638 -219
  123. data/numo-narray.gemspec +1 -0
  124. data/spec/narray_spec.rb +2 -2
  125. metadata +17 -14
  126. data/ext/numo/narray/gen/dtype.erb.c +0 -82
  127. data/ext/numo/narray/gen/tmpl/cast_numeric.c +0 -22
  128. data/ext/numo/narray/gen/tmpl/robj_allocate.c +0 -32
  129. data/ext/numo/narray/gen/tmpl_bit/cast.c +0 -37
  130. data/ext/numo/narray/gen/tmpl_bit/cast_array.c +0 -18
  131. data/ext/numo/narray/gen/tmpl_bit/cast_numeric.c +0 -22
  132. data/ext/numo/narray/gen/tmpl_bit/coerce_cast.c +0 -8
  133. data/ext/numo/narray/gen/tmpl_bit/map_with_index.c +0 -94
  134. data/ext/numo/narray/gen/tmpl_bit/store.c +0 -32
  135. data/ext/numo/narray/gen/tmpl_bit/store_numeric.c +0 -22
@@ -1,5 +1,5 @@
1
1
  static VALUE
2
- <%=c_func%>(VALUE self)
2
+ <%=c_func(0)%>(VALUE self)
3
3
  {
4
4
  narray_t *na;
5
5
  char *ptr;
@@ -14,10 +14,6 @@ static VALUE
14
14
  NA_DATA_PTR(na) = ptr;
15
15
  }
16
16
  break;
17
- //case NARRAY_FILEMAP_T:
18
- // to be implemented
19
- // ptr = ((narray_filemap_t*)na)->ptr;
20
- // break;
21
17
  case NARRAY_VIEW_T:
22
18
  rb_funcall(NA_VIEW_DATA(na), rb_intern("allocate"), 0);
23
19
  break;
@@ -37,7 +37,7 @@
37
37
  [15, 16, 99, 18, 19]]
38
38
  */
39
39
  static VALUE
40
- <%=c_func%>(int argc, VALUE *argv, VALUE self)
40
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
41
41
  {
42
42
  int nd;
43
43
  size_t pos;
@@ -38,7 +38,7 @@
38
38
 
39
39
  */
40
40
  static VALUE
41
- <%=c_func%>(int argc, VALUE *argv, VALUE self)
41
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
42
42
  {
43
43
  int nd;
44
44
  size_t pos;
@@ -55,8 +55,8 @@ static VALUE
55
55
  a = na_aref_main(argc, argv, self, 0, nd);
56
56
  <%=c_func.sub(/_aset/,"_store")%>(a, argv[argc]);
57
57
  } else {
58
+ x = <%=type_name%>_extract_data(argv[argc]);
58
59
  ptr = na_get_pointer_for_read_write(self);
59
- x = m_num_to_data(argv[argc]);
60
60
  STORE_BIT(ptr,pos,x);
61
61
  }
62
62
 
@@ -17,7 +17,7 @@ static void
17
17
  for (; n--;) {
18
18
  LOAD_BIT_STEP(a1, p1, s1, idx1, x);
19
19
  LOAD_BIT_STEP(a2, p2, s2, idx2, y);
20
- x = m_<%=method%>(x,y);
20
+ x = m_<%=name%>(x,y);
21
21
  STORE_BIT_STEP(a3, p3, s3, idx3, x);
22
22
  }
23
23
  } else {
@@ -40,7 +40,7 @@ static void
40
40
  else y = *a2<<-o2;
41
41
  if (p2+len>NB) y |= *(a2+1)<<r2;
42
42
  a2++;
43
- x = m_<%=method%>(x,y);
43
+ x = m_<%=name%>(x,y);
44
44
  *a3 = (x & (SLB(len)<<p3)) | (*a3 & ~(SLB(len)<<p3));
45
45
  a3++;
46
46
  n -= len;
@@ -49,7 +49,7 @@ static void
49
49
  for (; n>=NB; n-=NB) {
50
50
  x = *(a1++);
51
51
  y = *(a2++);
52
- x = m_<%=method%>(x,y);
52
+ x = m_<%=name%>(x,y);
53
53
  *(a3++) = x;
54
54
  }
55
55
  } else {
@@ -62,7 +62,7 @@ static void
62
62
  if (o2<0) y |= *(a2-1)>>l2;
63
63
  if (o2>0) y |= *(a2+1)<<r2;
64
64
  a2++;
65
- x = m_<%=method%>(x,y);
65
+ x = m_<%=name%>(x,y);
66
66
  *(a3++) = x;
67
67
  }
68
68
  }
@@ -71,20 +71,20 @@ static void
71
71
  if (o1<0) x |= *(a1-1)>>l1;
72
72
  y = *a2>>o2;
73
73
  if (o2<0) y |= *(a2-1)>>l2;
74
- x = m_<%=method%>(x,y);
74
+ x = m_<%=name%>(x,y);
75
75
  *a3 = (x & SLB(n)) | (*a3 & BALL<<n);
76
76
  }
77
77
  }
78
78
  }
79
79
 
80
80
  /*
81
- Binary <%=method%>.
81
+ Binary <%=name%>.
82
82
  @overload <%=op_map%> other
83
83
  @param [Numo::NArray,Numeric] other
84
- @return [Numo::NArray] <%=method%> of self and other.
84
+ @return [Numo::NArray] <%=name%> of self and other.
85
85
  */
86
86
  static VALUE
87
- <%=c_func%>(VALUE self, VALUE other)
87
+ <%=c_func(1)%>(VALUE self, VALUE other)
88
88
  {
89
89
  ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
90
90
  ndfunc_arg_out_t aout[1] = {{cT,0}};
@@ -22,7 +22,7 @@ static void
22
22
  for (; i--;) {
23
23
  LOAD_BIT(a1, p1+*idx1, x);
24
24
  idx1++;
25
- if (m_<%=method%>(x)) {
25
+ if (m_<%=name%>(x)) {
26
26
  y++;
27
27
  }
28
28
  }
@@ -30,7 +30,7 @@ static void
30
30
  for (; i--;) {
31
31
  LOAD_BIT(a1, p1, x);
32
32
  p1 += s1;
33
- if (m_<%=method%>(x)) {
33
+ if (m_<%=name%>(x)) {
34
34
  y++;
35
35
  }
36
36
  }
@@ -41,7 +41,7 @@ static void
41
41
  for (; i--;) {
42
42
  LOAD_BIT(a1, p1+*idx1, x);
43
43
  idx1++;
44
- if (m_<%=method%>(x)) {
44
+ if (m_<%=name%>(x)) {
45
45
  GET_DATA(p2, int_t, y);
46
46
  y++;
47
47
  SET_DATA(p2, int_t, y);
@@ -52,7 +52,7 @@ static void
52
52
  for (; i--;) {
53
53
  LOAD_BIT(a1, p1, x);
54
54
  p1+=s1;
55
- if (m_<%=method%>(x)) {
55
+ if (m_<%=name%>(x)) {
56
56
  GET_DATA(p2, int_t, y);
57
57
  y++;
58
58
  SET_DATA(p2, int_t, y);
@@ -66,19 +66,19 @@ static void
66
66
  /*
67
67
  Returns the number of bits.
68
68
  If argument is supplied, return Int-array counted along the axes.
69
- @overload <%=op_map%>([axis,..])
70
- @param [Integer] axis axes to be counted.
69
+ @overload <%=op_map%>(axis:nil)
70
+ @param [Integer,Array,Range] axis axes to be counted.
71
71
  @return [Numo::Int64]
72
72
  */
73
73
  static VALUE
74
- <%=c_func%>(int argc, VALUE *argv, VALUE self)
74
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
75
75
  {
76
76
  VALUE v, reduce;
77
77
  ndfunc_arg_in_t ain[3] = {{cT,0},{sym_reduce,0},{sym_init,0}};
78
78
  ndfunc_arg_out_t aout[1] = {{numo_cInt64,0}};
79
79
  ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP_NIP, 3, 1, ain, aout };
80
80
 
81
- reduce = na_reduce_dimension(argc, argv, 1, &self);
81
+ reduce = na_reduce_dimension(argc, argv, 1, &self, 0);
82
82
  v = na_ndloop(&ndf, 3, self, reduce, INT2FIX(0));
83
83
  return rb_funcall(v,rb_intern("extract"),0);
84
84
  }
@@ -91,31 +91,31 @@ static void
91
91
  }
92
92
 
93
93
  /*
94
- <% case method
94
+ <% case name
95
95
  when /^any/ %>
96
96
  Return true if any of bits is one (true).
97
97
  <% when /^all/ %>
98
98
  Return true if all of bits are one (true).
99
99
  <% end %>
100
100
  If argument is supplied, return Bit-array reduced along the axes.
101
- @overload <%=op_map%>([axis,..])
102
- @param [Integer] axis axes to be reduced.
101
+ @overload <%=op_map%>(axis:nil)
102
+ @param [Integer,Array,Range] axis axes to be reduced.
103
103
  @return [Numo::Bit] .
104
104
  */
105
105
  static VALUE
106
- <%=c_func%>(int argc, VALUE *argv, VALUE self)
106
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
107
107
  {
108
108
  VALUE v, reduce;
109
109
  ndfunc_arg_in_t ain[3] = {{cT,0},{sym_reduce,0},{sym_init,0}};
110
110
  ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
111
111
  ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP_NIP, 3,1, ain,aout};
112
112
 
113
- reduce = na_reduce_dimension(argc, argv, 1, &self);
113
+ reduce = na_reduce_dimension(argc, argv, 1, &self, 0);
114
114
  v = na_ndloop(&ndf, 3, self, reduce, INT2FIX(<%=init_bit%>));
115
115
  if (argc > 0) {
116
116
  return v;
117
117
  }
118
- v = numo_bit_extract(v);
118
+ v = <%=find_tmpl("extract").c_func%>(v);
119
119
  switch (v) {
120
120
  case INT2FIX(0):
121
121
  return Qfalse;
@@ -28,13 +28,13 @@ void
28
28
  /*
29
29
  Calls the given block once for each element in self,
30
30
  passing that element as a parameter.
31
- @overload <%=method%>
31
+ @overload <%=name%>
32
32
  @return [Numo::NArray] self
33
33
  For a block {|x| ... }
34
34
  @yield [x] x is element of NArray.
35
35
  */
36
36
  static VALUE
37
- <%=c_func%>(VALUE self)
37
+ <%=c_func(0)%>(VALUE self)
38
38
  {
39
39
  ndfunc_arg_in_t ain[1] = {{Qnil,0}};
40
40
  ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP_NIP, 1,0, ain,0};
@@ -50,13 +50,13 @@ void
50
50
  /*
51
51
  Invokes the given block once for each element of self,
52
52
  passing that element and indices along each axis as parameters.
53
- @overload <%=method%>
53
+ @overload <%=name%>
54
54
  @return [Numo::NArray] self
55
55
  For a block {|x,i,j,...| ... }
56
56
  @yield [x,i,j,...] x is an element, i,j,... are multidimensional indices.
57
57
  */
58
58
  static VALUE
59
- <%=c_func%>(VALUE self)
59
+ <%=c_func(0)%>(VALUE self)
60
60
  {
61
61
  ndfunc_arg_in_t ain[1] = {{Qnil,0}};
62
62
  ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP_NIP, 1,0, ain,0};
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  static VALUE
10
- numo_bit_extract(VALUE self)
10
+ <%=c_func(0)%>(VALUE self)
11
11
  {
12
12
  BIT_DIGIT *ptr, val;
13
13
  size_t pos;
@@ -50,12 +50,12 @@ static void
50
50
 
51
51
  /*
52
52
  Fill elements with other.
53
- @overload <%=method%> other
53
+ @overload <%=name%> other
54
54
  @param [Numeric] other
55
55
  @return [Numo::<%=class_name%>] self.
56
56
  */
57
57
  static VALUE
58
- <%=c_func%>(VALUE self, VALUE val)
58
+ <%=c_func(1)%>(VALUE self, VALUE val)
59
59
  {
60
60
  ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_option}};
61
61
  ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2,0, ain,0};
@@ -1,5 +1,5 @@
1
1
  static VALUE
2
- format_<%=tp%>(VALUE fmt, dtype x)
2
+ format_<%=type_name%>(VALUE fmt, dtype x)
3
3
  {
4
4
  if (NIL_P(fmt)) {
5
5
  char s[4];
@@ -29,13 +29,13 @@ static void
29
29
  if (idx1) {
30
30
  for (; i--;) {
31
31
  LOAD_BIT(a1, p1+*idx1, x); idx1++;
32
- y = format_<%=tp%>(fmt, x);
32
+ y = format_<%=type_name%>(fmt, x);
33
33
  SET_DATA_STRIDE(p2, s2, VALUE, y);
34
34
  }
35
35
  } else {
36
36
  for (; i--;) {
37
37
  LOAD_BIT(a1, p1, x); p1+=s1;
38
- y = format_<%=tp%>(fmt, x);
38
+ y = format_<%=type_name%>(fmt, x);
39
39
  SET_DATA_STRIDE(p2, s2, VALUE, y);
40
40
  }
41
41
  }
@@ -43,12 +43,12 @@ static void
43
43
 
44
44
  /*
45
45
  Format elements into strings.
46
- @overload <%=method%> format
46
+ @overload <%=name%> format
47
47
  @param [String] format
48
48
  @return [Numo::RObject] array of formated strings.
49
49
  */
50
50
  static VALUE
51
- <%=c_func%>(int argc, VALUE *argv, VALUE self)
51
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
52
52
  {
53
53
  VALUE fmt=Qnil;
54
54
 
@@ -31,12 +31,12 @@ static void
31
31
 
32
32
  /*
33
33
  Format elements into strings.
34
- @overload <%=method%> format
34
+ @overload <%=name%> format
35
35
  @param [String] format
36
36
  @return [Array] array of formated strings.
37
37
  */
38
38
  static VALUE
39
- <%=c_func%>(int argc, VALUE *argv, VALUE self)
39
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
40
40
  {
41
41
  volatile VALUE fmt=Qnil;
42
42
  ndfunc_arg_in_t ain[3] = {{Qnil,0},{sym_loop_opt},{sym_option}};
@@ -3,7 +3,7 @@ static VALUE
3
3
  {
4
4
  dtype x;
5
5
  LOAD_BIT(ptr,pos,x);
6
- return format_<%=tp%>(fmt, x);
6
+ return format_<%=type_name%>(fmt, x);
7
7
  }
8
8
 
9
9
  /*
@@ -12,7 +12,7 @@ static VALUE
12
12
  @return [String]
13
13
  */
14
14
  VALUE
15
- <%=c_func%>(VALUE ary)
15
+ <%=c_func(0)%>(VALUE ary)
16
16
  {
17
17
  return na_ndloop_inspect(ary, <%=c_iter%>, Qnil);
18
18
  }
@@ -1,5 +1,5 @@
1
1
  static void
2
- iter_bit_pointer(na_loop_t *const lp)
2
+ <%=c_iter%>(na_loop_t *const lp)
3
3
  {
4
4
  size_t i;
5
5
  BIT_DIGIT *a;
@@ -82,7 +82,7 @@ iter_bit_pointer(na_loop_t *const lp)
82
82
  @return [Numo::NArray] view of masked array.
83
83
  */
84
84
  static VALUE
85
- numo_bit_mask(VALUE mask, VALUE val)
85
+ <%=c_func(1)%>(VALUE mask, VALUE val)
86
86
  {
87
87
  volatile VALUE idx_1, view;
88
88
  narray_data_t *nidx;
@@ -93,10 +93,10 @@ static VALUE
93
93
  size_t n_1;
94
94
  where_opt_t g;
95
95
  ndfunc_arg_in_t ain[2] = {{cT,0},{Qnil,0}};
96
- ndfunc_t ndf = {iter_bit_pointer, FULL_LOOP, 2, 0, ain, 0};
96
+ ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2, 0, ain, 0};
97
97
 
98
- n_1 = NUM2SIZET(numo_bit_count_true(0, NULL, mask));
99
- idx_1 = rb_narray_new(cIndex, 1, &n_1);
98
+ n_1 = NUM2SIZET(<%=find_tmpl("count_true").c_func%>(0, NULL, mask));
99
+ idx_1 = nary_new(cIndex, 1, &n_1);
100
100
  g.count = 0;
101
101
  g.elmsz = SIZEOF_VOIDP;
102
102
  g.idx1 = na_get_pointer_for_write(idx_1);
@@ -1,14 +1,14 @@
1
- VALUE
2
- numo_bit_none_p(int argc, VALUE *argv, VALUE self)
1
+ static VALUE
2
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
3
3
  {
4
4
  VALUE v;
5
5
 
6
- v = numo_bit_any_p(argc,argv,self);
6
+ v = <%=find_tmpl("any?").c_func%>(argc,argv,self);
7
7
 
8
8
  if (v==Qtrue) {
9
9
  return Qfalse;
10
10
  } else if (v==Qfalse) {
11
11
  return Qtrue;
12
12
  }
13
- return numo_bit_not(v);
13
+ return <%=find_tmpl("not").c_func%>(v);
14
14
  }
@@ -20,7 +20,7 @@ static void
20
20
 
21
21
  if (lp->args[1].ptr) {
22
22
  if (v1 == Qtrue) {
23
- iter_<%=tp%>_store_<%=tp%>(lp);
23
+ iter_<%=type_name%>_store_<%=type_name%>(lp);
24
24
  i = lp->args[1].shape[0];
25
25
  if (idx1) {
26
26
  idx1 += i;
@@ -94,7 +94,7 @@ static void
94
94
  }
95
95
 
96
96
  static VALUE
97
- <%=c_func%>(VALUE self, VALUE rary)
97
+ <%=c_func(:nodef)%>(VALUE self, VALUE rary)
98
98
  {
99
99
  ndfunc_arg_in_t ain[2] = {{OVERWRITE,0}, {rb_cArray,0}};
100
100
  ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2, 0, ain, 0};
@@ -56,7 +56,7 @@ static void
56
56
  }
57
57
 
58
58
  static VALUE
59
- <%=c_func%>(VALUE self, VALUE obj)
59
+ <%=c_func(:nodef)%>(VALUE self, VALUE obj)
60
60
  {
61
61
  ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{Qnil,0}};
62
62
  ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2,0, ain,0};
@@ -46,7 +46,7 @@ static void
46
46
 
47
47
 
48
48
  static VALUE
49
- <%=c_func%>(VALUE self, VALUE obj)
49
+ <%=c_func(:nodef)%>(VALUE self, VALUE obj)
50
50
  {
51
51
  ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{Qnil,0}};
52
52
  ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2,0, ain,0};
@@ -30,11 +30,11 @@ void
30
30
 
31
31
  /*
32
32
  Convert self to Array.
33
- @overload <%=method%>
33
+ @overload <%=name%>
34
34
  @return [Array]
35
35
  */
36
36
  static VALUE
37
- <%=c_func%>(VALUE self)
37
+ <%=c_func(0)%>(VALUE self)
38
38
  {
39
39
  ndfunc_arg_in_t ain[3] = {{Qnil,0},{sym_loop_opt},{sym_option}};
40
40
  ndfunc_arg_out_t aout[1] = {{rb_cArray,0}}; // dummy?
@@ -16,7 +16,7 @@ static void
16
16
  if (s1!=1 || s3!=1 || idx1 || idx3) {
17
17
  for (; n--;) {
18
18
  LOAD_BIT_STEP(a1, p1, s1, idx1, x);
19
- y = m_<%=method%>(x);
19
+ y = m_<%=name%>(x);
20
20
  STORE_BIT_STEP(a3, p3, s3, idx3, y);
21
21
  }
22
22
  } else {
@@ -31,7 +31,7 @@ static void
31
31
  else x = *a1<<-o1;
32
32
  if (p1+len>NB) x |= *(a1+1)<<r1;
33
33
  a1++;
34
- y = m_<%=method%>(x);
34
+ y = m_<%=name%>(x);
35
35
  *a3 = (y & (SLB(len)<<p3)) | (*a3 & ~(SLB(len)<<p3));
36
36
  a3++;
37
37
  n -= len;
@@ -39,7 +39,7 @@ static void
39
39
  if (o1==0) {
40
40
  for (; n>=NB; n-=NB) {
41
41
  x = *(a1++);
42
- y = m_<%=method%>(x);
42
+ y = m_<%=name%>(x);
43
43
  *(a3++) = y;
44
44
  }
45
45
  } else {
@@ -48,26 +48,26 @@ static void
48
48
  if (o1<0) x |= *(a1-1)>>l1;
49
49
  if (o1>0) x |= *(a1+1)<<r1;
50
50
  a1++;
51
- y = m_<%=method%>(x);
51
+ y = m_<%=name%>(x);
52
52
  *(a3++) = y;
53
53
  }
54
54
  }
55
55
  if (n>0) {
56
56
  x = *a1>>o1;
57
57
  if (o1<0) x |= *(a1-1)>>l1;
58
- y = m_<%=method%>(x);
58
+ y = m_<%=name%>(x);
59
59
  *a3 = (y & SLB(n)) | (*a3 & BALL<<n);
60
60
  }
61
61
  }
62
62
  }
63
63
 
64
64
  /*
65
- Unary <%=method%>.
66
- @overload <%=method%>
67
- @return [Numo::<%=class_name%>] <%=method%> of self.
65
+ Unary <%=name%>.
66
+ @overload <%=name%>
67
+ @return [Numo::<%=class_name%>] <%=name%> of self.
68
68
  */
69
69
  static VALUE
70
- <%=c_func%>(VALUE self)
70
+ <%=c_func(0)%>(VALUE self)
71
71
  {
72
72
  ndfunc_arg_in_t ain[1] = {{cT,0}};
73
73
  ndfunc_arg_out_t aout[1] = {{cT,0}};