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,32 +0,0 @@
1
- /*
2
- Store elements to Numo::<%=class_name%> from other.
3
- @overload store(other)
4
- @param [Object] other
5
- @return [Numo::<%=class_name%>] self
6
- */
7
- static VALUE
8
- <%=c_func%>(VALUE self, VALUE obj)
9
- {
10
-
11
- VALUE r;
12
-
13
- <% Store.definitions.each do |x| %>
14
- if (<%=x.condition%>) {
15
- <%=x.c_func%>(self,obj);
16
- return self;
17
- }
18
- <% end %>
19
-
20
- if (IsNArray(obj)) {
21
- r = rb_funcall(obj, rb_intern("coerce_cast"), 1, cT);
22
- if (CLASS_OF(r)==cT) {
23
- <%=c_func%>(self,r);
24
- return self;
25
- }
26
- }
27
-
28
- rb_raise(nary_eCastError, "unknown conversion from %s to %s",
29
- rb_class2name(CLASS_OF(obj)),
30
- rb_class2name(CLASS_OF(self)));
31
- return self;
32
- }
@@ -1,22 +0,0 @@
1
- static VALUE
2
- numo_<%=tp%>_new_dim0(dtype x)
3
- {
4
- VALUE v;
5
- dtype *ptr;
6
-
7
- v = rb_narray_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
- }
13
-
14
- static VALUE
15
- <%=c_func%>(VALUE self, VALUE obj)
16
- {
17
- dtype x;
18
- x = m_num_to_data(obj);
19
- obj = numo_<%=tp%>_new_dim0(x);
20
- <%=find_tmpl("store").c_func%>(self,obj);
21
- return self;
22
- }