carray 1.3.5 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSES +22 -0
  3. data/README.md +18 -21
  4. data/Rakefile +31 -0
  5. data/carray.gemspec +13 -26
  6. data/{ca_iter_block.c → ext/ca_iter_block.c} +13 -13
  7. data/{ca_iter_dimension.c → ext/ca_iter_dimension.c} +16 -16
  8. data/{ca_iter_window.c → ext/ca_iter_window.c} +10 -10
  9. data/{ca_obj_array.c → ext/ca_obj_array.c} +60 -55
  10. data/{ca_obj_bitarray.c → ext/ca_obj_bitarray.c} +12 -12
  11. data/{ca_obj_bitfield.c → ext/ca_obj_bitfield.c} +7 -7
  12. data/{ca_obj_block.c → ext/ca_obj_block.c} +42 -42
  13. data/{ca_obj_fake.c → ext/ca_obj_fake.c} +7 -7
  14. data/{ca_obj_farray.c → ext/ca_obj_farray.c} +18 -18
  15. data/{ca_obj_field.c → ext/ca_obj_field.c} +15 -15
  16. data/{ca_obj_grid.c → ext/ca_obj_grid.c} +27 -27
  17. data/{ca_obj_mapping.c → ext/ca_obj_mapping.c} +9 -9
  18. data/{ca_obj_object.c → ext/ca_obj_object.c} +37 -37
  19. data/{ca_obj_reduce.c → ext/ca_obj_reduce.c} +1 -1
  20. data/{ca_obj_refer.c → ext/ca_obj_refer.c} +33 -33
  21. data/{ca_obj_repeat.c → ext/ca_obj_repeat.c} +43 -43
  22. data/{ca_obj_select.c → ext/ca_obj_select.c} +2 -2
  23. data/{ca_obj_shift.c → ext/ca_obj_shift.c} +23 -23
  24. data/{ca_obj_transpose.c → ext/ca_obj_transpose.c} +23 -23
  25. data/{ca_obj_unbound_repeat.c → ext/ca_obj_unbound_repeat.c} +55 -55
  26. data/{ca_obj_window.c → ext/ca_obj_window.c} +26 -26
  27. data/{carray.h → ext/carray.h} +77 -51
  28. data/{carray_access.c → ext/carray_access.c} +133 -91
  29. data/{carray_attribute.c → ext/carray_attribute.c} +12 -12
  30. data/{carray_call_cfunc.c → ext/carray_call_cfunc.c} +0 -0
  31. data/{carray_cast.c → ext/carray_cast.c} +6 -6
  32. data/{carray_cast_func.rb → ext/carray_cast_func.rb} +0 -0
  33. data/{carray_class.c → ext/carray_class.c} +0 -0
  34. data/{carray_conversion.c → ext/carray_conversion.c} +11 -13
  35. data/{carray_copy.c → ext/carray_copy.c} +19 -19
  36. data/{carray_core.c → ext/carray_core.c} +2 -2
  37. data/ext/carray_data_type.c +66 -0
  38. data/{carray_element.c → ext/carray_element.c} +9 -9
  39. data/{carray_generate.c → ext/carray_generate.c} +67 -1
  40. data/{carray_iterator.c → ext/carray_iterator.c} +40 -38
  41. data/{carray_loop.c → ext/carray_loop.c} +24 -24
  42. data/{carray_mask.c → ext/carray_mask.c} +17 -6
  43. data/{carray_math.rb → ext/carray_math.rb} +25 -25
  44. data/ext/{mathfunc/carray_mathfunc.c → carray_mathfunc.c} +0 -0
  45. data/{carray_numeric.c → ext/carray_numeric.c} +1 -1
  46. data/{carray_operator.c → ext/carray_operator.c} +32 -9
  47. data/{carray_order.c → ext/carray_order.c} +2 -153
  48. data/{carray_sort_addr.c → ext/carray_sort_addr.c} +0 -0
  49. data/{carray_stat.c → ext/carray_stat.c} +5 -5
  50. data/{carray_stat_proc.rb → ext/carray_stat_proc.rb} +23 -23
  51. data/{carray_test.c → ext/carray_test.c} +22 -21
  52. data/{carray_undef.c → ext/carray_undef.c} +0 -0
  53. data/{carray_utils.c → ext/carray_utils.c} +0 -0
  54. data/{extconf.rb → ext/extconf.rb} +0 -5
  55. data/{mkmath.rb → ext/mkmath.rb} +12 -2
  56. data/{ruby_carray.c → ext/ruby_carray.c} +9 -2
  57. data/{ruby_ccomplex.c → ext/ruby_ccomplex.c} +0 -0
  58. data/{ruby_float_func.c → ext/ruby_float_func.c} +0 -0
  59. data/{version.h → ext/version.h} +5 -5
  60. data/{version.rb → ext/version.rb} +0 -0
  61. data/lib/carray.rb +49 -7
  62. data/lib/carray/{base/autoload.rb → autoload.rb} +48 -6
  63. data/lib/carray/autoload/autoload_base.rb +1 -5
  64. data/lib/carray/autoload/autoload_gem_cairo.rb +9 -0
  65. data/lib/carray/autoload/autoload_gem_ffi.rb +9 -0
  66. data/lib/carray/autoload/autoload_gem_gnuplot.rb +2 -0
  67. data/lib/carray/autoload/autoload_gem_io_csv.rb +14 -0
  68. data/lib/carray/autoload/autoload_gem_io_pg.rb +6 -0
  69. data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +12 -0
  70. data/lib/carray/autoload/autoload_gem_narray.rb +10 -0
  71. data/lib/carray/autoload/autoload_gem_numo_narray.rb +15 -0
  72. data/lib/carray/autoload/autoload_gem_opencv.rb +16 -0
  73. data/lib/carray/autoload/autoload_gem_random.rb +8 -0
  74. data/lib/carray/autoload/autoload_gem_rmagick.rb +23 -0
  75. data/lib/carray/autoload/{autoload_graphics_zimg.rb → autoload_gem_zimg.rb} +0 -0
  76. data/lib/carray/basic.rb +193 -0
  77. data/lib/carray/compose.rb +291 -0
  78. data/lib/carray/construct.rb +445 -0
  79. data/lib/carray/convert.rb +115 -0
  80. data/lib/carray/{base/inspect.rb → inspect.rb} +6 -6
  81. data/lib/carray/io/imagemagick.rb +1 -1
  82. data/lib/carray/{base/iterator.rb → iterator.rb} +3 -3
  83. data/lib/carray/mask.rb +91 -0
  84. data/lib/carray/{base/math.rb → math.rb} +17 -47
  85. data/lib/carray/math/histogram.rb +7 -7
  86. data/lib/carray/mkmf.rb +8 -0
  87. data/lib/carray/object/ca_obj_pack.rb +8 -8
  88. data/lib/carray/obsolete.rb +272 -0
  89. data/lib/carray/ordering.rb +157 -0
  90. data/lib/carray/{base/serialize.rb → serialize.rb} +28 -53
  91. data/lib/carray/string.rb +190 -0
  92. data/lib/carray/{base/struct.rb → struct.rb} +20 -20
  93. data/lib/carray/{io/table.rb → table.rb} +1 -9
  94. data/lib/carray/testing.rb +56 -0
  95. data/lib/carray/time.rb +78 -0
  96. data/lib/carray/transform.rb +100 -0
  97. data/misc/Methods.ja.md +182 -0
  98. data/{NOTE → misc/NOTE} +0 -0
  99. data/test/test_ALL.rb +0 -2
  100. data/test/test_order.rb +7 -7
  101. data/test/test_ref_store.rb +13 -13
  102. data/test/test_stat.rb +7 -15
  103. data/{devel → utils}/guess_shape.rb +0 -0
  104. data/utils/{diff_method.rb → monkey_patch_methods.rb} +17 -7
  105. metadata +100 -254
  106. data/COPYING +0 -56
  107. data/GPL +0 -340
  108. data/Gemfile +0 -8
  109. data/Gemfile.lock +0 -33
  110. data/LEGAL +0 -50
  111. data/TODO +0 -5
  112. data/carray_random.c +0 -531
  113. data/ext/calculus/carray_calculus.c +0 -931
  114. data/ext/calculus/carray_interp.c +0 -358
  115. data/ext/calculus/extconf.rb +0 -12
  116. data/ext/calculus/lib/autoload/autoload_math_calculus.rb +0 -2
  117. data/ext/calculus/lib/math/calculus.rb +0 -119
  118. data/ext/calculus/lib/math/interp/adapter_interp1d.rb +0 -31
  119. data/ext/fortio/extconf.rb +0 -3
  120. data/ext/fortio/lib/carray/autoload/autoload_fortran_format.rb +0 -5
  121. data/ext/fortio/lib/carray/io/fortran_format.rb +0 -43
  122. data/ext/fortio/lib/fortio.rb +0 -3
  123. data/ext/fortio/lib/fortio/fortran_format.rb +0 -605
  124. data/ext/fortio/lib/fortio/fortran_format.tab.rb +0 -536
  125. data/ext/fortio/lib/fortio/fortran_format.y +0 -215
  126. data/ext/fortio/lib/fortio/fortran_namelist.rb +0 -151
  127. data/ext/fortio/lib/fortio/fortran_namelist.tab.rb +0 -470
  128. data/ext/fortio/lib/fortio/fortran_namelist.y +0 -213
  129. data/ext/fortio/lib/fortio/fortran_sequential.rb +0 -345
  130. data/ext/fortio/ruby_fortio.c +0 -182
  131. data/ext/fortio/test/test_H.rb +0 -5
  132. data/ext/fortio/test/test_T.rb +0 -7
  133. data/ext/fortio/test/test_fortran_format.rb +0 -86
  134. data/ext/fortio/test/test_namelist.rb +0 -25
  135. data/ext/fortio/test/test_namelist_write.rb +0 -10
  136. data/ext/fortio/test/test_sequential.rb +0 -13
  137. data/ext/fortio/test/test_sequential2.rb +0 -13
  138. data/ext/fortio/work/test.rb +0 -10
  139. data/ext/fortio/work/test_e.rb +0 -19
  140. data/ext/fortio/work/test_ep.rb +0 -10
  141. data/ext/fortio/work/test_parse.rb +0 -12
  142. data/ext/imagemap/carray_imagemap.c +0 -495
  143. data/ext/imagemap/doc/call_graph.dot +0 -28
  144. data/ext/imagemap/draw.c +0 -567
  145. data/ext/imagemap/extconf.rb +0 -13
  146. data/ext/imagemap/lib/autoload/autoload_graphics_imagemap.rb +0 -1
  147. data/ext/imagemap/lib/graphics/imagemap.rb +0 -273
  148. data/ext/imagemap/lib/image_map.rb +0 -4
  149. data/ext/imagemap/test/swath_index.rb +0 -83
  150. data/ext/imagemap/test/swath_warp.rb +0 -99
  151. data/ext/imagemap/test/test.rb +0 -23
  152. data/ext/imagemap/test/test_image.rb +0 -42
  153. data/ext/imagemap/test/test_line.rb +0 -14
  154. data/ext/imagemap/test/test_rotate.rb +0 -17
  155. data/ext/imagemap/test/test_triangle.rb +0 -20
  156. data/ext/imagemap/test/test_warp.rb +0 -26
  157. data/ext/mathfunc/extconf.rb +0 -18
  158. data/ext/mathfunc/lib/autoload/autoload_math_mathfunc.rb +0 -1
  159. data/ext/mathfunc/lib/math/mathfunc.rb +0 -15
  160. data/ext/mathfunc/test/test_hypot.rb +0 -5
  161. data/ext/mathfunc/test/test_j0.rb +0 -22
  162. data/ext/mathfunc/test/test_jn.rb +0 -8
  163. data/ext/mathfunc/test/test_sph.rb +0 -9
  164. data/ext/narray/README +0 -22
  165. data/ext/narray/ca_wrap_narray.c +0 -500
  166. data/ext/narray/carray_narray.c +0 -21
  167. data/ext/narray/extconf.rb +0 -57
  168. data/ext/narray/lib/autoload/autoload_math_narray.rb +0 -1
  169. data/ext/narray/lib/autoload/autoload_math_narray_miss.rb +0 -11
  170. data/ext/narray/lib/math/narray.rb +0 -17
  171. data/ext/narray/lib/math/narray_miss.rb +0 -45
  172. data/lib/carray/autoload/autoload_graphics_gnuplot.rb +0 -2
  173. data/lib/carray/autoload/autoload_io_csv.rb +0 -14
  174. data/lib/carray/autoload/autoload_io_pg.rb +0 -6
  175. data/lib/carray/autoload/autoload_io_sqlite3.rb +0 -12
  176. data/lib/carray/autoload/autoload_io_table.rb +0 -1
  177. data/lib/carray/autoload/autoload_math_interp.rb +0 -4
  178. data/lib/carray/base/basic.rb +0 -1090
  179. data/lib/carray/base/obsolete.rb +0 -131
  180. data/lib/carray/graphics/gnuplot.rb +0 -2131
  181. data/lib/carray/graphics/zimg.rb +0 -296
  182. data/lib/carray/io/csv.rb +0 -572
  183. data/lib/carray/io/pg.rb +0 -101
  184. data/lib/carray/io/sqlite3.rb +0 -215
  185. data/lib/carray/math/interp.rb +0 -57
  186. data/lib/carray/math/interp/adapter_gsl_spline.rb +0 -47
  187. data/mt19937ar.c +0 -182
  188. data/mt19937ar.h +0 -86
  189. data/rdoc_main.rb +0 -27
  190. data/rdoc_math.rb +0 -5
  191. data/rdoc_stat.rb +0 -31
  192. data/test/test_narray.rb +0 -64
  193. data/test/test_random.rb +0 -15
  194. data/utils/create_rdoc.sh +0 -9
  195. data/utils/make_tgz.sh +0 -3
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # ----------------------------------------------------------------------------
12
12
 
13
- require './mkmath.rb'
13
+ require_relative './mkmath'
14
14
 
15
15
  HEADERS << <<HERE_END
16
16
  /* ---------------------------------------------------------------------------
@@ -228,22 +228,22 @@ binop("pmin", "pmin",
228
228
  CMPLX_TYPES => nil,
229
229
  OBJ_TYPES =>'(#3) = rb_funcall(rb_assoc_new((#1),(#2)), rb_intern("min"), 0);')
230
230
 
231
- binop("add", "add",
231
+ binop("+", "add",
232
232
  ALL_TYPES =>"(#3) = (#1) + (#2);",
233
233
  CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) + (#2);" : nil,
234
234
  OBJ_TYPES =>'(#3) = rb_funcall((#1), id_plus, 1, (#2));')
235
235
 
236
- binop("sub", "sub",
236
+ binop("-", "sub",
237
237
  ALL_TYPES => "(#3) = (#1) - (#2);",
238
238
  CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) - (#2);" : nil,
239
239
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_minus, 1, (#2));')
240
240
 
241
- binop("mul", "mul",
241
+ binop("*", "mul",
242
242
  ALL_TYPES => "(#3) = (#1) * (#2);",
243
243
  CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) * (#2);" : nil,
244
244
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_star, 1, (#2));')
245
245
 
246
- binop("div", "div",
246
+ binop("/", "div",
247
247
  INT_TYPES => "if ((#2)==0) {ca_zerodiv();}; (#3) = (#1) / (#2);",
248
248
  FLOAT_TYPES => "(#3) = (#1) / (#2);",
249
249
  CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) / (#2);" : nil,
@@ -258,21 +258,21 @@ binop("rcp_mul", "rcp_mul",
258
258
  CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#2) / (#1);" : nil,
259
259
  OBJ_TYPES => '(#3) = rb_funcall((#2), id_slash, 1, (#1));')
260
260
 
261
- binop("mod", "mod",
261
+ binop("%", "mod",
262
262
  INT_TYPES => "if ((#2)==0) {ca_zerodiv();}; (#3) = (#1) % (#2);",
263
263
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_percent, 1, (#2));')
264
264
 
265
- binop("bit_and", "bit_and_i",
265
+ binop("&", "bit_and_i",
266
266
  BOOL_TYPES => "(#3) = (#1) & (#2);",
267
267
  INT_TYPES => "(#3) = (#1) & (#2);",
268
268
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_and, 1, (#2));')
269
269
 
270
- binop("bit_or", "bit_or_i",
270
+ binop("|", "bit_or_i",
271
271
  BOOL_TYPES => "(#3) = (#1) | (#2);",
272
272
  INT_TYPES => "(#3) = (#1) | (#2);",
273
273
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_or, 1, (#2));')
274
274
 
275
- binop("bit_xor", "bit_xor_i",
275
+ binop("^", "bit_xor_i",
276
276
  BOOL_TYPES => "(#3) = ((#1) != (#2)) ? 1 : 0;",
277
277
  INT_TYPES => "(#3) = (#1) ^ (#2);",
278
278
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_xor, 1, (#2));')
@@ -329,11 +329,11 @@ METHODS << %{
329
329
  rb_define_method(rb_cCArray, "bit_xor", rb_ca_bit_xor, 1);
330
330
  }
331
331
 
332
- binop("bit_lshift", "bit_lshift",
332
+ binop("<<", "bit_lshift",
333
333
  INT_TYPES => "(#3) = (#1) << (#2);",
334
334
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_lshift, 1, (#2));')
335
335
 
336
- binop("bit_rshift", "bit_rshift",
336
+ binop(">>", "bit_rshift",
337
337
  INT_TYPES => "(#3) = (#1) >> (#2);",
338
338
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_rshift, 1, (#2));')
339
339
 
@@ -461,16 +461,16 @@ METHODS << %{
461
461
  rb_define_method(rb_cCArray, "xor", rb_ca_xor, 1);
462
462
  }
463
463
 
464
- alias_op("+", "add")
465
- alias_op("-", "sub")
466
- alias_op("*", "mul")
467
- alias_op("/", "div")
468
- alias_op("%", "mod")
469
- alias_op("&", "bit_and")
470
- alias_op("|", "bit_or")
471
- alias_op("^", "bit_xor")
472
- alias_op("<<", "bit_lshift")
473
- alias_op(">>", "bit_rshift")
464
+ alias_op("add", "+")
465
+ alias_op("sub", "-")
466
+ alias_op("mul", "*")
467
+ alias_op("div", "/")
468
+ alias_op("mod", "%")
469
+ alias_op("bit_and", "&")
470
+ alias_op("bit_or", "|")
471
+ alias_op("bit_xor", "^")
472
+ alias_op("bit_lshift", "<<")
473
+ alias_op("bit_rshift", ">>")
474
474
 
475
475
  #alias_op("==", "eq")
476
476
  #alias_op("!=", "ne")
@@ -697,7 +697,7 @@ rb_ca_ipower (VALUE self, VALUE other)
697
697
  /* unresolved unbound repeat array generates unbound repeat array again */
698
698
  if ( ca->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
699
699
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca;
700
- obj = rb_ca_ubrep_new(obj, cx->rep_rank, cx->rep_dim);
700
+ obj = rb_ca_ubrep_new(obj, cx->rep_ndim, cx->rep_dim);
701
701
  }
702
702
 
703
703
  return obj;
@@ -752,7 +752,7 @@ rb_ca_ipower_bang (VALUE self, VALUE other)
752
752
 
753
753
  }
754
754
 
755
- binop("power", "power",
755
+ binop("**", "power",
756
756
  INT_TYPES => "(#3) = op_powi_<type>((#1), (#2));",
757
757
  FLOAT_TYPES => "(#3) = pow((#1), (#2));",
758
758
  CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = cpow((#1), (#2));" : nil,
@@ -776,7 +776,7 @@ static VALUE rb_ca_pow (VALUE self, VALUE other)
776
776
  /* unresolved unbound repeat array generates unbound repeat array again */
777
777
  if ( ca->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
778
778
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca;
779
- obj = rb_ca_ubrep_new(obj, cx->rep_rank, cx->rep_dim);
779
+ obj = rb_ca_ubrep_new(obj, cx->rep_ndim, cx->rep_dim);
780
780
  }
781
781
 
782
782
  return obj;
@@ -803,7 +803,7 @@ METHODS << %{
803
803
  rb_define_method(rb_cCArray, "pow!", rb_ca_pow_bang, 1);
804
804
  }
805
805
 
806
- alias_op("**", "pow")
806
+ alias_op("pow", "**")
807
807
 
808
808
  METHODS << %{
809
809
  id_equal = rb_intern("==");
@@ -168,7 +168,7 @@ rb_ca_arg (VALUE self)
168
168
 
169
169
  Data_Get_Struct(self, CArray, ca);
170
170
 
171
- co = carray_new(CA_FLOAT64, ca->rank, ca->dim, 0, NULL);
171
+ co = carray_new(CA_FLOAT64, ca->ndim, ca->dim, 0, NULL);
172
172
  obj = ca_wrap_struct(co);
173
173
 
174
174
  if ( ca_has_mask(ca) ) {
@@ -58,7 +58,7 @@ rb_ca_call_monop (VALUE self, ca_monop_func_t func[])
58
58
  /* unresolved unbound repeat array generates unbound repeat array again */
59
59
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
60
60
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
61
- out = rb_ca_ubrep_new(out, cx->rep_rank, cx->rep_dim);
61
+ out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
62
62
  }
63
63
 
64
64
  return out;
@@ -84,6 +84,29 @@ rb_ca_call_monop_bang (VALUE self, ca_monop_func_t func[])
84
84
  return self;
85
85
  }
86
86
 
87
+ int
88
+ rb_ca_test_castable (VALUE other)
89
+ {
90
+ volatile VALUE retval;
91
+ if ( rb_respond_to(other, rb_intern("castable_to_carray?")) ) {
92
+ retval = rb_funcall(other, rb_intern("castable_to_carray?"), 0);
93
+ return RTEST(retval);
94
+ }
95
+ else {
96
+ return 1;
97
+ }
98
+ }
99
+
100
+ VALUE
101
+ rb_ca_binop_pass_to_other (VALUE self, VALUE other, ID method)
102
+ {
103
+ volatile VALUE pair;
104
+ pair = rb_funcall(other, rb_intern("coerce"), 1, self);
105
+ self = rb_ary_entry(pair, 0);
106
+ other = rb_ary_entry(pair, 1);
107
+ return rb_funcall(self, method, 1, other);
108
+ }
109
+
87
110
  VALUE
88
111
  rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
89
112
  ca_binop_func_t func[])
@@ -174,13 +197,13 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
174
197
  /* unresolved unbound repeat array generates unbound repeat array again */
175
198
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
176
199
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
177
- out = rb_ca_ubrep_new(out, cx->rep_rank, cx->rep_dim);
200
+ out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
178
201
  }
179
202
 
180
203
  /* unresolved unbound repeat array generates unbound repeat array again */
181
204
  if ( ca2->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
182
205
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca2;
183
- out = rb_ca_ubrep_new(out, cx->rep_rank, cx->rep_dim);
206
+ out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
184
207
  }
185
208
 
186
209
  return out;
@@ -264,7 +287,7 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
264
287
  out = rb_cscalar_new(CA_BOOLEAN, 0, NULL);
265
288
  }
266
289
  else {
267
- out = rb_carray_new(CA_BOOLEAN, ca1->rank, ca1->dim, 0, NULL);
290
+ out = rb_carray_new(CA_BOOLEAN, ca1->ndim, ca1->dim, 0, NULL);
268
291
  }
269
292
 
270
293
  Data_Get_Struct(out, CArray, ca2);
@@ -279,7 +302,7 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
279
302
  /* unresolved unbound repeat array generates unbound repeat array again */
280
303
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
281
304
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
282
- out = rb_ca_ubrep_new(out, cx->rep_rank, cx->rep_dim);
305
+ out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
283
306
  }
284
307
 
285
308
  return out;
@@ -330,7 +353,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
330
353
  ca3->ptr, ca3->bytes, 0);
331
354
  }
332
355
  else { /* scalar vs array */
333
- out = rb_carray_new(CA_BOOLEAN, ca2->rank, ca2->dim, 0, NULL);
356
+ out = rb_carray_new(CA_BOOLEAN, ca2->ndim, ca2->dim, 0, NULL);
334
357
  Data_Get_Struct(out, CArray, ca3);
335
358
 
336
359
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
@@ -342,7 +365,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
342
365
  }
343
366
  else {
344
367
  if ( rb_obj_is_cscalar(other) ) { /* array vs scalar */
345
- out = rb_carray_new(CA_BOOLEAN, ca1->rank, ca1->dim, 0, NULL);
368
+ out = rb_carray_new(CA_BOOLEAN, ca1->ndim, ca1->dim, 0, NULL);
346
369
  Data_Get_Struct(out, CArray, ca3);
347
370
 
348
371
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
@@ -356,7 +379,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
356
379
  rb_raise(rb_eRuntimeError, "elements mismatch in bincmp (%lld <-> %lld)",
357
380
  (ca_size_t) ca1->elements, (ca_size_t) ca2->elements);
358
381
  }
359
- out = rb_carray_new(CA_BOOLEAN, ca1->rank, ca1->dim, 0, NULL);
382
+ out = rb_carray_new(CA_BOOLEAN, ca1->ndim, ca1->dim, 0, NULL);
360
383
  Data_Get_Struct(out, CArray, ca3);
361
384
 
362
385
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
@@ -372,7 +395,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
372
395
  /* unresolved unbound repeat array generates unbound repeat array again */
373
396
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
374
397
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
375
- out = rb_ca_ubrep_new(out, cx->rep_rank, cx->rep_dim);
398
+ out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
376
399
  }
377
400
 
378
401
  return out;
@@ -132,7 +132,7 @@ ca_project (CArray *ca, CArray *ci, char *lfill, char *ufill)
132
132
 
133
133
  ca_attach_n(2, ca, ci); /* ATTACH */
134
134
 
135
- co = carray_new(ca->data_type, ci->rank, ci->dim, ca->bytes, NULL);
135
+ co = carray_new(ca->data_type, ci->ndim, ci->dim, ca->bytes, NULL);
136
136
  ca_project_loop(co, ca, ci, lfill, ufill);
137
137
 
138
138
  ca_detach_n(2, ca, ci); /* DETACH */
@@ -449,154 +449,6 @@ rb_ca_sorted_copy (VALUE self)
449
449
  return rb_ca_sort_bang(out);
450
450
  }
451
451
 
452
- /* --------------------------------------------------------------- */
453
-
454
- /*
455
- Fisher-Yates method
456
-
457
- # [ruby-list:41356]
458
- # From: Shin-ichiro HARA <sinara blade.nagaokaut.ac.jp>
459
- def shuffle!
460
- array = self
461
- array.each_index do |idx|
462
- jdx = rand(idx + 1)
463
- array[idx], array[jdx] = array[jdx], array[idx]
464
- end
465
- self
466
- end
467
- */
468
-
469
- #define proc_shuffle(type) \
470
- { \
471
- ca_size_t idx, jdx; \
472
- type *ptr, *p, *q; \
473
- type t1; \
474
- ptr = (type *) ca->ptr; \
475
- if ( ca->mask ) { \
476
- boolean8_t *mptr, *mp, *mq; \
477
- boolean8_t mt1; \
478
- mptr = (boolean8_t *)ca->mask->ptr; \
479
- for (idx=0; idx<ca->elements; idx++) { \
480
- jdx = ca_rand((double)(idx+1)); \
481
- p = ptr + idx; \
482
- q = ptr + jdx; \
483
- mp = mptr + idx; \
484
- mq = mptr + jdx; \
485
- t1 = *p; *p = *q; *q = t1; \
486
- mt1 = *mp; *mp = *mq; *mq = mt1; \
487
- } \
488
- } \
489
- else { \
490
- for (idx=0; idx<ca->elements; idx++) { \
491
- jdx = ca_rand((double)(idx+1)); \
492
- p = ptr + idx; \
493
- q = ptr + jdx; \
494
- t1 = *p; *p = *q; *q = t1; \
495
- } \
496
- } \
497
- }
498
-
499
- #define proc_shuffle_fixlen() \
500
- { \
501
- ca_size_t idx, jdx; \
502
- char *ptr, *p, *q; \
503
- char *t = (char*) malloc_with_check(ca->bytes); \
504
- ca_size_t bytes = ca->bytes; \
505
- ptr = ca->ptr; \
506
- if ( ca->mask ) { \
507
- boolean8_t *mptr, *mp, *mq; \
508
- boolean8_t mt1; \
509
- mptr = (boolean8_t *)ca->mask->ptr; \
510
- for (idx=0; idx<ca->elements; idx++) { \
511
- jdx = ca_rand((double)(idx+1)); \
512
- p = ca->ptr + idx*bytes; \
513
- q = ca->ptr + jdx*bytes; \
514
- mp = mptr + idx; \
515
- mq = mptr + jdx; \
516
- memcpy(t, p, bytes); memcpy(p, q, bytes); memcpy(q, t, bytes); \
517
- mt1 = *mp; *mp = *mq; *mq = mt1; \
518
- } \
519
- free(t); \
520
- } \
521
- else { \
522
- for (idx=0; idx<ca->elements; idx++) { \
523
- jdx = ca_rand((double)(idx+1)); \
524
- p = ca->ptr + idx*bytes; \
525
- q = ca->ptr + jdx*bytes; \
526
- memcpy(t, p, bytes); memcpy(p, q, bytes); memcpy(q, t, bytes); \
527
- } \
528
- free(t); \
529
- } \
530
- }
531
-
532
- void ca_check_rand_init ();
533
-
534
- /* rdoc:
535
- class CArray
536
- # shuffles the elements.
537
- # If `self` has mask, the masked elements are also moved by shuffling.
538
- def shuffle!
539
- end
540
- end
541
- */
542
-
543
- static VALUE
544
- rb_ca_shuffle_bang (VALUE self)
545
- {
546
- CArray *ca;
547
-
548
- rb_ca_modify(self);
549
-
550
- Data_Get_Struct(self, CArray, ca);
551
-
552
- ca_check_rand_init();
553
-
554
- ca_attach(ca);
555
-
556
- switch ( ca->data_type ) {
557
- case CA_BOOLEAN:
558
- case CA_INT8: proc_shuffle(int8_t); break;
559
- case CA_UINT8: proc_shuffle(uint8_t); break;
560
- case CA_INT16: proc_shuffle(int16_t); break;
561
- case CA_UINT16: proc_shuffle(uint16_t); break;
562
- case CA_INT32: proc_shuffle(int32_t); break;
563
- case CA_UINT32: proc_shuffle(uint32_t); break;
564
- case CA_INT64: proc_shuffle(int64_t); break;
565
- case CA_UINT64: proc_shuffle(uint64_t); break;
566
- case CA_FLOAT32: proc_shuffle(float32_t); break;
567
- case CA_FLOAT64: proc_shuffle(float64_t); break;
568
- case CA_FLOAT128: proc_shuffle(float128_t); break;
569
- #ifdef HAVE_COMPLEX_H
570
- case CA_CMPLX64: proc_shuffle(cmplx64_t); break;
571
- case CA_CMPLX128: proc_shuffle(cmplx128_t); break;
572
- case CA_CMPLX256: proc_shuffle(cmplx256_t); break;
573
- #endif
574
- case CA_FIXLEN: proc_shuffle_fixlen(); break;
575
- case CA_OBJECT: proc_shuffle(VALUE); break;
576
- default:
577
- rb_raise(rb_eCADataTypeError, "[BUG] array has an unknown data type");
578
- }
579
-
580
- ca_sync(ca);
581
- ca_detach(ca);
582
-
583
- return self;
584
- }
585
-
586
- /* rdoc:
587
- class CArray
588
- def shuffle
589
- end
590
- end
591
- */
592
-
593
- static VALUE
594
- rb_ca_shuffled_copy (VALUE self)
595
- {
596
- volatile VALUE out = rb_ca_copy(self);
597
- rb_ca_data_type_inherit(out, self);
598
- return rb_ca_shuffle_bang(out);
599
- }
600
452
 
601
453
  /* --------------------------------------------------------------- */
602
454
 
@@ -641,7 +493,7 @@ rb_ca_binary_search (VALUE self, volatile VALUE rval)
641
493
  if ( ca->data_type != cv->data_type ) {
642
494
  cv = ca_wrap_readonly(rval, ca->data_type);
643
495
  }
644
- co = carray_new(CA_SIZE, cv->rank, cv->dim, 0, NULL);
496
+ co = carray_new(CA_SIZE, cv->ndim, cv->dim, 0, NULL);
645
497
  out = ca_wrap_struct(co);
646
498
  ca_attach(cv);
647
499
  if ( ca_is_fixlen_type(ca) ) {
@@ -1024,9 +876,6 @@ Init_carray_order ()
1024
876
  rb_define_method(rb_cCArray, "sort!", rb_ca_sort_bang, 0);
1025
877
  rb_define_method(rb_cCArray, "sort", rb_ca_sorted_copy, 0);
1026
878
 
1027
- rb_define_method(rb_cCArray, "shuffle!", rb_ca_shuffle_bang, 0);
1028
- rb_define_method(rb_cCArray, "shuffle", rb_ca_shuffled_copy, 0);
1029
-
1030
879
  rb_define_method(rb_cCArray, "search", rb_ca_linear_search, -1);
1031
880
  rb_define_method(rb_cCArray, "search_index", rb_ca_linear_search_index, -1);
1032
881
 
@@ -293,10 +293,10 @@ rb_ca_cumprod (int argc, VALUE *argv, VALUE self)
293
293
  Data_Get_Struct(self, CArray, ca);
294
294
 
295
295
  if ( ca_is_complex_type(ca) ) {
296
- co = carray_new(CA_CMPLX128, ca->rank, ca->dim, 0, NULL);
296
+ co = carray_new(CA_CMPLX128, ca->ndim, ca->dim, 0, NULL);
297
297
  }
298
298
  else {
299
- co = carray_new(CA_FLOAT64, ca->rank, ca->dim, 0, NULL);
299
+ co = carray_new(CA_FLOAT64, ca->ndim, ca->dim, 0, NULL);
300
300
  }
301
301
 
302
302
  min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
@@ -504,10 +504,10 @@ rb_ca_cumwsum (int argc, VALUE *argv, VALUE self)
504
504
  }
505
505
 
506
506
  if ( ca_is_complex_type(ca) ) {
507
- co = carray_new(CA_CMPLX128, ca->rank, ca->dim, 0, NULL);
507
+ co = carray_new(CA_CMPLX128, ca->ndim, ca->dim, 0, NULL);
508
508
  }
509
509
  else {
510
- co = carray_new(CA_FLOAT64, ca->rank, ca->dim, 0, NULL);
510
+ co = carray_new(CA_FLOAT64, ca->ndim, ca->dim, 0, NULL);
511
511
  }
512
512
 
513
513
  min_count = ( NIL_P(rmin_count) || ( ! ca_has_mask(ca) ) ) ?
@@ -2029,7 +2029,7 @@ rb_ca_grade (int argc, VALUE *argv, VALUE self)
2029
2029
  rb_raise(rb_eArgError, "bin number must be larger than 1");
2030
2030
  }
2031
2031
 
2032
- out = rb_carray_new_safe(CA_SIZE, ca->rank, ca->dim, 0, NULL);
2032
+ out = rb_carray_new_safe(CA_SIZE, ca->ndim, ca->dim, 0, NULL);
2033
2033
  Data_Get_Struct(out, CArray, sa);
2034
2034
 
2035
2035
  ca_attach(ca);