numo-narray 0.9.0.4 → 0.9.0.5

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 (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
@@ -0,0 +1,37 @@
1
+ static void
2
+ <%=c_iter%>(na_loop_t *const lp)
3
+ {
4
+ size_t i;
5
+ char *p1, *p2, *p3;
6
+ ssize_t s1, s2, s3;
7
+ dtype x;
8
+ int y;
9
+ INIT_COUNTER(lp, i);
10
+ INIT_PTR(lp, 0, p1, s1);
11
+ INIT_PTR(lp, 1, p2, s2);
12
+ INIT_PTR(lp, 2, p3, s3);
13
+ for (; i--;) {
14
+ GET_DATA_STRIDE(p1,s1,dtype,x);
15
+ x = m_<%=name%>(x,&y);
16
+ SET_DATA_STRIDE(p2,s2,dtype,x);
17
+ SET_DATA_STRIDE(p3,s3,int32_t,y);
18
+ }
19
+ }
20
+
21
+ /*
22
+ split the number x into a normalized fraction and an exponent.
23
+ Returns [mantissa, exponent], where x = mantissa * 2**exponent.
24
+
25
+ @overload <%=name%>(x)
26
+ @param [Numo::NArray,Numeric] x
27
+ @return [Numo::<%=class_name%>,Numo::Int32] mantissa and exponent.
28
+
29
+ */
30
+ static VALUE
31
+ <%=c_func(1)%>(VALUE mod, VALUE a1)
32
+ {
33
+ ndfunc_arg_in_t ain[1] = {{cT,0}};
34
+ ndfunc_arg_out_t aout[2] = {{cT,0},{numo_cInt32,0}};
35
+ ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP, 1,2, ain,aout };
36
+ return na_ndloop(&ndf, 1, a1);
37
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ Document-class: <%= full_class_name %>
3
+ <%= description %>
4
+ */
5
+ cT = rb_define_class_under(<%=ns_var%>, "<%=class_name%>", cNArray);
6
+
7
+ <% for x in class_alias %>
8
+ // alias of <%=class_name%>
9
+ rb_define_const(<%=ns_var%>, "<%=x%>", <%=type_var%>);
10
+ <% end %>
11
+
12
+ hCast = rb_hash_new();
13
+ rb_define_const(cT, "UPCAST", hCast);
14
+ rb_hash_aset(hCast, rb_cArray, cT);
15
+ <% for x in upcast %>
16
+ <%= x %><% end %>
17
+
18
+ <% @children.each do |m| %>
19
+ <%= m.init_def %><% end %>
20
+ rb_define_singleton_method(cT, "[]", <%=find("cast").c_func%>, -2);
@@ -0,0 +1,12 @@
1
+ /*
2
+ Document-module: <%= full_module_name %>
3
+ <%= description %>
4
+ */
5
+ <% if module_var != ns_var %>
6
+ <%=module_var%> = rb_define_module_under(<%=ns_var%>, "<%=module_name%>");
7
+ <% end %>
8
+ <% @children.each do |m| %>
9
+ <%= m.init_def %><% end %>
10
+
11
+ // how to do this?
12
+ //rb_extend_object(cT, mTM);
@@ -4,7 +4,7 @@ static VALUE
4
4
  <% if is_object %>
5
5
  return rb_inspect(*(VALUE*)(ptr+pos));
6
6
  <% else %>
7
- return format_<%=tp%>(fmt, (dtype*)(ptr+pos));
7
+ return format_<%=type_name%>(fmt, (dtype*)(ptr+pos));
8
8
  <% end %>
9
9
  }
10
10
 
@@ -14,7 +14,7 @@ static VALUE
14
14
  @return [String]
15
15
  */
16
16
  VALUE
17
- <%=c_func%>(VALUE ary)
17
+ <%=c_func(0)%>(VALUE ary)
18
18
  {
19
19
  return na_ndloop_inspect(ary, <%=c_iter%>, Qnil);
20
20
  }
@@ -0,0 +1,45 @@
1
+ /*
2
+ <%= file_name %>
3
+ Ruby/Numo::GSL - GSL wrapper for Ruby/Numo::NArray
4
+
5
+ created on: 2017-03-11
6
+ Copyright (C) 2017 Masahiro Tanaka
7
+ */
8
+
9
+ #include <ruby.h>
10
+ #include <assert.h>
11
+ #include "numo/narray.h"
12
+ #include "numo/template.h"
13
+ #include "SFMT.h"
14
+
15
+ #define m_map(x) m_num_to_data(rb_yield(m_data_to_num(x)))
16
+
17
+ <% id_decl.each do |x| %>
18
+ <%= x %>
19
+ <% end %>
20
+
21
+ <% include_files.each do |f| %>
22
+ #include <<%=f%>>
23
+ <% end %>
24
+
25
+ VALUE cT;
26
+ extern VALUE cRT;
27
+
28
+ <% children.each do |c|%>
29
+ <%= c.result+"\n\n" %>
30
+ <% end %>
31
+
32
+ void
33
+ Init_<%=lib_name%>(void)
34
+ {
35
+ VALUE hCast, <%=ns_var%>;
36
+
37
+ <%=ns_var%> = rb_define_module("Numo");
38
+
39
+ <% id_assign.each do |x| %>
40
+ <%= x %><% end %>
41
+
42
+ <% children.each do |c| %>
43
+ <%= c.init_def %>
44
+ <% end %>
45
+ }
@@ -61,7 +61,7 @@ static void
61
61
  [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
62
62
  */
63
63
  static VALUE
64
- <%=c_func%>(int argc, VALUE *args, VALUE self)
64
+ <%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
65
65
  {
66
66
  logseq_opt_t *g;
67
67
  VALUE vbeg, vstep, vbase;
@@ -75,7 +75,7 @@ void
75
75
  Creates a new NArray containing the values returned by the block.
76
76
  Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
77
77
 
78
- @overload <%=method%>
78
+ @overload <%=name%>
79
79
 
80
80
  For a block {|x,i,j,...| ... }
81
81
  @yield [x,i,j,...] x is an element, i,j,... are multidimensional indices.
@@ -84,7 +84,7 @@ void
84
84
 
85
85
  */
86
86
  static VALUE
87
- <%=c_func%>(VALUE self)
87
+ <%=c_func(0)%>(VALUE self)
88
88
  {
89
89
  ndfunc_arg_in_t ain[1] = {{Qnil,0}};
90
90
  ndfunc_arg_out_t aout[1] = {{cT,0}};
@@ -1,5 +1,6 @@
1
+ <% (is_float ? ["_ignan","_prnan"] : [""]).each do |j| %>
1
2
  static void
2
- <%=c_iter%>(na_loop_t *const lp)
3
+ <%=c_iter%><%=j%>(na_loop_t *const lp)
3
4
  {
4
5
  size_t n;
5
6
  char *p1, *p2;
@@ -10,7 +11,7 @@ static void
10
11
  p2 = (lp->args[1]).ptr + (lp->args[1].iter[0]).pos;
11
12
  buf = (dtype*)p1;
12
13
 
13
- <%=tp%>_qsort(buf, n, sizeof(dtype));
14
+ <%=type_name%>_qsort<%=j%>(buf, n, sizeof(dtype));
14
15
 
15
16
  <% if is_float %>
16
17
  for (; n; n--) {
@@ -28,17 +29,39 @@ static void
28
29
  *(dtype*)p2 = buf[(n-1)/2];
29
30
  }
30
31
  }
32
+ <% end %>
33
+
34
+ /*
35
+ <%=name%> of self.
36
+ <% if is_float %>
37
+ @overload <%=name%>(axis:nil, nan:false)
38
+ @param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
39
+ <% else %>
40
+ @overload <%=name%>(axis:nil)
41
+ <% end %>
42
+ @param [Numeric,Array,Range] axis Affected dimensions.
43
+ @return [Numo::<%=class_name%>] returns <%=name%> of self.
44
+ */
31
45
 
32
46
  static VALUE
33
- <%=c_func%>(int argc, VALUE *argv, VALUE self)
47
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
34
48
  {
49
+ int nan = 0;
35
50
  VALUE reduce;
36
- ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
51
+ ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
37
52
  ndfunc_arg_out_t aout[1] = {{INT2FIX(0),0}};
38
- ndfunc_t ndf = {<%=c_iter%>, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2,1, ain,aout};
39
-
40
- self = na_copy(self);
41
- reduce = na_reduce_dimension(argc, argv, 1, &self); // v[0] = self
53
+ ndfunc_t ndf = {0, NDF_HAS_LOOP|NDF_FLAT_REDUCE, 2,1, ain,aout};
42
54
 
55
+ self = na_copy(self); // as temporary buffer
56
+ reduce = na_reduce_dimension(argc, argv, 1, &self, &nan); // v[0] = self
57
+ <% if is_float %>
58
+ if (nan) {
59
+ ndf.func = <%=c_iter%>_prnan;
60
+ } else {
61
+ ndf.func = <%=c_iter%>_ignan;
62
+ }
63
+ <% else %>
64
+ ndf.func = <%=c_iter%>;
65
+ <% end %>
43
66
  return na_ndloop(&ndf, 2, self, reduce);
44
67
  }
@@ -1,47 +1,47 @@
1
+ <% (is_float ? ["","_nan"] : [""]).each do |j| %>
1
2
  static void
2
- <%=c_iter%>(na_loop_t *const lp)
3
+ <%=c_iter%><%=j%>(na_loop_t *const lp)
3
4
  {
4
- size_t i;
5
+ size_t n;
5
6
  char *p1;
6
7
  ssize_t s1;
7
- dtype x,xmin,xmax;
8
+ dtype xmin,xmax;
8
9
 
9
- INIT_COUNTER(lp, i);
10
+ INIT_COUNTER(lp, n);
10
11
  INIT_PTR(lp, 0, p1, s1);
11
12
 
12
- xmin = xmax = *(dtype*)p1;
13
- p1 += s1;
14
- i--;
15
- for (; i--;) {
16
- x = *(dtype*)p1;
17
- if (!m_isnan(x)) {
18
- if (m_isnan(xmax) || m_gt(x,xmax)) {
19
- xmax = x;
20
- }
21
- if (m_isnan(xmin) || m_lt(x,xmin)) {
22
- xmin = x;
23
- }
24
- }
25
- p1 += s1;
26
- }
13
+ f_<%=name%><%=j%>(n,p1,s1,&xmin,&xmax);
14
+
27
15
  *(dtype*)(lp->args[1].ptr + lp->args[1].iter[0].pos) = xmin;
28
16
  *(dtype*)(lp->args[2].ptr + lp->args[2].iter[0].pos) = xmax;
29
17
  }
18
+ <% end %>
30
19
 
31
20
  /*
32
- <%=method.capitalize%> of self.
33
- @overload <%=method%>(*args)
34
- @param [Array of Numeric,Range] args Affected dimensions.
21
+ <%=name%> of self.
22
+ <% if is_float %>
23
+ @overload <%=name%>(axis:nil, nan:false)
24
+ @param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
25
+ <% else %>
26
+ @overload <%=name%>(axis:nil)
27
+ <% end %>
28
+ @param [Numeric,Array,Range] axis Affected dimensions.
35
29
  @return [Numo::<%=class_name%>,Numo::<%=class_name%>] min and max of self.
36
30
  */
37
31
  static VALUE
38
- <%=c_func%>(int argc, VALUE *argv, VALUE self)
32
+ <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
39
33
  {
34
+ int ignore_nan = 0;
40
35
  VALUE reduce;
41
36
  ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
42
37
  ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
43
38
  ndfunc_t ndf = {<%=c_iter%>, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,2, ain,aout};
44
39
 
45
- reduce = na_reduce_dimension(argc, argv, 1, &self);
40
+ reduce = na_reduce_dimension(argc, argv, 1, &self, &ignore_nan);
41
+ <% if is_float %>
42
+ if (ignore_nan) {
43
+ ndf.func = <%=c_iter%>_nan;
44
+ }
45
+ <% end %>
46
46
  return na_ndloop(&ndf, 2, self, reduce);
47
47
  }
@@ -0,0 +1,9 @@
1
+ /*
2
+ module definition: <%= full_module_name %>
3
+ */
4
+
5
+ <% if module_var != ns_var %>
6
+ VALUE <%=module_var%>;
7
+ <% end %>
8
+
9
+ <%= method_code %>
@@ -0,0 +1,12 @@
1
+ static VALUE
2
+ <%=c_func(:nodef)%>(dtype x)
3
+ {
4
+ VALUE v;
5
+ dtype *ptr;
6
+
7
+ v = nary_new(cT, 0, NULL);
8
+ ptr = (dtype*)(char*)na_get_pointer_for_write(v);
9
+ *ptr = x;
10
+ na_release_lock(v);
11
+ return v;
12
+ }
@@ -18,13 +18,13 @@ static void
18
18
 
19
19
  /*
20
20
  Polynomial.: a0 + a1*x + a2*x**2 + a3*x**3 + ... + an*x**n
21
- @overload <%=method%> a0, a1, ...
21
+ @overload <%=name%> a0, a1, ...
22
22
  @param [Numo::NArray,Numeric] a0
23
23
  @param [Numo::NArray,Numeric] a1 , ...
24
24
  @return [Numo::<%=class_name%>]
25
25
  */
26
26
  static VALUE
27
- <%=c_func%>(VALUE self, VALUE args)
27
+ <%=c_func(-2)%>(VALUE self, VALUE args)
28
28
  {
29
29
  int argc, i;
30
30
  VALUE *argv;
@@ -45,5 +45,5 @@ static VALUE
45
45
  }
46
46
  a = rb_ary_new4(argc+1, argv);
47
47
  v = na_ndloop2(&ndf, a);
48
- return numo_<%=tp%>_extract(v);
48
+ return <%=type_name%>_extract(v);
49
49
  }
@@ -61,7 +61,7 @@ static VALUE
61
61
  @return [Numo::NArray] self to the other-th power.
62
62
  */
63
63
  static VALUE
64
- <%=c_func%>(VALUE self, VALUE other)
64
+ <%=c_func(1)%>(VALUE self, VALUE other)
65
65
  {
66
66
  <% if is_object %>
67
67
  return <%=c_func%>_self(self,other);
@@ -1,4 +1,4 @@
1
- static dtype pow_<%=tp%>(dtype x, int p)
1
+ static dtype pow_<%=type_name%>(dtype x, int p)
2
2
  {
3
3
  dtype r = m_one;
4
4
  switch(p) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  qsort.c
3
3
  Numerical Array Extension for Ruby
4
- (C) Copyright 2007-2016 by Masahiro TANAKA
4
+ (C) Copyright 2007-2017 by Masahiro TANAKA
5
5
  */
6
6
 
7
7
  /*
@@ -68,9 +68,16 @@
68
68
  #define qsort_dtype <%=dtype%>
69
69
  #undef qsort_cast
70
70
  #define qsort_cast <%=dcast%>
71
+ <% if "#{suffix}" != "" %>
72
+ #undef cmp
73
+ #undef cmpgt
74
+ #define cmp(a,b) cmp<%=suffix%>(a,b)
75
+ #define cmpgt(a,b) cmpgt<%=suffix%>(a,b)
76
+ <% end %>
77
+ <% c_func(:nodef)%>
71
78
 
72
79
  void
73
- <%=tp%>_qsort(void *a, size_t n, ssize_t es)
80
+ <%=type_name%>_qsort<%=suffix%>(void *a, size_t n, ssize_t es)
74
81
  {
75
82
  char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
76
83
  int d, r, presorted;
@@ -134,7 +141,7 @@ void
134
141
  r = Min(pd - pc, pn - pd - es);
135
142
  vecswap(qsort_dtype, pb, pn - r, r);
136
143
  if ((r = pb - pa) > es)
137
- <%=tp%>_qsort(a, r / es, es);
144
+ <%=type_name%>_qsort<%=suffix%>(a, r / es, es);
138
145
  if ((r = pd - pc) > es) {
139
146
  a = pn - r;
140
147
  n = r / es;
@@ -123,7 +123,7 @@ static void
123
123
  [4, 3, 3, 2, 4, 2]
124
124
  */
125
125
  static VALUE
126
- <%=c_func%>(int argc, VALUE *args, VALUE self)
126
+ <%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
127
127
  {
128
128
  rand_opt_t g;
129
129
  VALUE v1=Qnil, v2=Qnil;
@@ -95,7 +95,7 @@ static void
95
95
  [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
96
96
  */
97
97
  static VALUE
98
- <%=c_func%>(int argc, VALUE *args, VALUE self)
98
+ <%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
99
99
  {
100
100
  int n;
101
101
  randn_opt_t g;
@@ -67,7 +67,7 @@ static void
67
67
  [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
68
68
  */
69
69
  static VALUE
70
- <%=c_func%>(int argc, VALUE *args, VALUE self)
70
+ <%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
71
71
  {
72
72
  seq_opt_t *g;
73
73
  VALUE vbeg=Qnil, vstep=Qnil;
@@ -15,14 +15,14 @@ static void
15
15
  for (; i--;) {
16
16
  GET_DATA_INDEX(p1,idx1,dtype,x);
17
17
  GET_DATA_INDEX(p2,idx2,<%=dtype%>,y);
18
- x = m_<%=method%>(x,y);
18
+ x = m_<%=name%>(x,y);
19
19
  SET_DATA_INDEX(p1,idx1,dtype,x);
20
20
  }
21
21
  } else {
22
22
  for (; i--;) {
23
23
  GET_DATA_INDEX(p1,idx1,dtype,x);
24
24
  GET_DATA_STRIDE(p2,s2,<%=dtype%>,y);
25
- x = m_<%=method%>(x,y);
25
+ x = m_<%=name%>(x,y);
26
26
  SET_DATA_INDEX(p1,idx1,dtype,x);
27
27
  }
28
28
  }
@@ -31,14 +31,14 @@ static void
31
31
  for (; i--;) {
32
32
  GET_DATA(p1,dtype,x);
33
33
  GET_DATA_INDEX(p2,idx2,<%=dtype%>,y);
34
- x = m_<%=method%>(x,y);
34
+ x = m_<%=name%>(x,y);
35
35
  SET_DATA_STRIDE(p1,s1,dtype,x);
36
36
  }
37
37
  } else {
38
38
  for (; i--;) {
39
39
  GET_DATA(p1,dtype,x);
40
40
  GET_DATA_STRIDE(p2,s2,<%=dtype%>,y);
41
- x = m_<%=method%>(x,y);
41
+ x = m_<%=name%>(x,y);
42
42
  SET_DATA_STRIDE(p1,s1,dtype,x);
43
43
  }
44
44
  }
@@ -46,7 +46,7 @@ static void
46
46
  }
47
47
 
48
48
  static VALUE
49
- <%=c_func%>(VALUE self, VALUE a1)
49
+ <%=c_func(1)%>(VALUE self, VALUE a1)
50
50
  {
51
51
  ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{<%=tpclass%>,0}};
52
52
  ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP, 2, 0, ain, 0 };