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
@@ -51,20 +51,20 @@ rb_ca_data_type (VALUE self)
51
51
  /* rdoc
52
52
  class CArray
53
53
  # use CArray#ndims instead of this methods after carray-1.3.0
54
- def rank
54
+ def ndim
55
55
  end
56
- # returns the rank (e.g. 1 for 1D array, 3 for 3D array, ...).
56
+ # returns the ndim (e.g. 1 for 1D array, 3 for 3D array, ...).
57
57
  def ndims
58
58
  end
59
59
  end
60
60
  */
61
61
 
62
62
  VALUE
63
- rb_ca_rank (VALUE self)
63
+ rb_ca_ndim (VALUE self)
64
64
  {
65
65
  CArray *ca;
66
66
  Data_Get_Struct(self, CArray, ca);
67
- return INT2NUM(ca->rank);
67
+ return INT2NUM(ca->ndim);
68
68
  }
69
69
 
70
70
  /* rdoc
@@ -147,8 +147,8 @@ rb_ca_dim (VALUE self)
147
147
  CArray *ca;
148
148
  int i;
149
149
  Data_Get_Struct(self, CArray, ca);
150
- dim = rb_ary_new2(ca->rank);
151
- for (i=0; i<ca->rank; i++) {
150
+ dim = rb_ary_new2(ca->ndim);
151
+ for (i=0; i<ca->ndim; i++) {
152
152
  rb_ary_store(dim, i, SIZE2NUM(ca->dim[i]));
153
153
  }
154
154
  return dim;
@@ -167,7 +167,7 @@ rb_ca_dim1 (VALUE self)
167
167
  {
168
168
  CArray *ca;
169
169
  Data_Get_Struct(self, CArray, ca);
170
- return ( ca->rank >= 2 ) ? SIZE2NUM(ca->dim[1]) : Qnil;
170
+ return ( ca->ndim >= 2 ) ? SIZE2NUM(ca->dim[1]) : Qnil;
171
171
  }
172
172
 
173
173
  VALUE
@@ -175,7 +175,7 @@ rb_ca_dim2 (VALUE self)
175
175
  {
176
176
  CArray *ca;
177
177
  Data_Get_Struct(self, CArray, ca);
178
- return ( ca->rank >= 3 ) ? SIZE2NUM(ca->dim[2]) : Qnil;
178
+ return ( ca->ndim >= 3 ) ? SIZE2NUM(ca->dim[2]) : Qnil;
179
179
  }
180
180
 
181
181
  VALUE
@@ -183,7 +183,7 @@ rb_ca_dim3 (VALUE self)
183
183
  {
184
184
  CArray *ca;
185
185
  Data_Get_Struct(self, CArray, ca);
186
- return ( ca->rank >= 4 ) ? SIZE2NUM(ca->dim[3]) : Qnil;
186
+ return ( ca->ndim >= 4 ) ? SIZE2NUM(ca->dim[3]) : Qnil;
187
187
  }
188
188
 
189
189
  /* rdoc:
@@ -868,9 +868,9 @@ Init_carray_attribute ()
868
868
  rb_define_method(rb_cCArray, "obj_type", rb_ca_obj_type, 0);
869
869
  rb_define_method(rb_cCArray, "data_type", rb_ca_data_type, 0);
870
870
  rb_define_method(rb_cCArray, "bytes", rb_ca_bytes, 0);
871
- rb_define_method(rb_cCArray, "rank", rb_ca_rank, 0);
872
- rb_define_method(rb_cCArray, "ndim", rb_ca_rank, 0); /* after carray-1.3.0 */
873
- rb_define_method(rb_cCArray, "shape", rb_ca_dim, 0); /* after carray-1.3.0 */
871
+ rb_define_method(rb_cCArray, "ndim", rb_ca_ndim, 0);
872
+ rb_define_method(rb_cCArray, "rank", rb_ca_ndim, 0); /* after carray-1.5.0 */
873
+ rb_define_method(rb_cCArray, "shape", rb_ca_dim, 0); /* after carray-1.5.0 */
874
874
  rb_define_method(rb_cCArray, "dim", rb_ca_dim, 0);
875
875
  rb_define_method(rb_cCArray, "dim0", rb_ca_dim0, 0);
876
876
  rb_define_method(rb_cCArray, "dim1", rb_ca_dim1, 0);
@@ -240,7 +240,7 @@ rb_ca_data_class_to_object (VALUE self)
240
240
  obj = rb_cscalar_new(CA_OBJECT, 0, ca->mask);
241
241
  }
242
242
  else {
243
- obj = rb_carray_new(CA_OBJECT, ca->rank, ca->dim, 0, ca->mask);
243
+ obj = rb_carray_new(CA_OBJECT, ca->ndim, ca->dim, 0, ca->mask);
244
244
  }
245
245
 
246
246
  for (i=0; i<ca->elements; i++) {
@@ -264,7 +264,7 @@ rb_ca_object_to_data_class (VALUE self, VALUE rtype, ca_size_t bytes)
264
264
  obj = rb_cscalar_new(CA_FIXLEN, bytes, ca->mask);
265
265
  }
266
266
  else {
267
- obj = rb_carray_new(CA_FIXLEN, ca->rank, ca->dim, bytes, ca->mask);
267
+ obj = rb_carray_new(CA_FIXLEN, ca->ndim, ca->dim, bytes, ca->mask);
268
268
  }
269
269
  rb_ca_data_type_import(obj, rtype);
270
270
 
@@ -312,7 +312,7 @@ rb_ca_to_type_internal (int argc, VALUE *argv, VALUE self)
312
312
  obj = rb_cscalar_new(data_type, bytes, ca->mask);
313
313
  }
314
314
  else {
315
- obj = rb_carray_new(data_type, ca->rank, ca->dim, bytes, ca->mask);
315
+ obj = rb_carray_new(data_type, ca->ndim, ca->dim, bytes, ca->mask);
316
316
  }
317
317
 
318
318
  rb_ca_data_type_import(obj, rtype);
@@ -1065,7 +1065,7 @@ rb_ca_cast_other (VALUE *self, volatile VALUE *other)
1065
1065
  */
1066
1066
 
1067
1067
  VALUE
1068
- rb_ca_s_cast_other (VALUE klass, VALUE self, VALUE other)
1068
+ rb_ca_cast_with (VALUE self, VALUE other)
1069
1069
  {
1070
1070
  if ( rb_obj_is_carray(self) ) {
1071
1071
  rb_ca_cast_self_or_other(&self, &other);
@@ -1145,7 +1145,7 @@ Init_carray_cast ()
1145
1145
  "cast", rb_ca_s_cast, 1);
1146
1146
  rb_define_singleton_method(rb_cCArray,
1147
1147
  "cast_self_or_other", rb_ca_s_cast_self_or_other, 2);
1148
- rb_define_singleton_method(rb_cCArray,
1149
- "cast_other", rb_ca_s_cast_other, 2);
1148
+
1149
+ rb_define_method(rb_cCArray, "cast_with", rb_ca_cast_with, 1);
1150
1150
  }
1151
1151
 
File without changes
@@ -27,7 +27,7 @@ rb_ca_to_a_loop (VALUE self, int32_t level, ca_size_t *idx, VALUE ary)
27
27
 
28
28
  Data_Get_Struct(self, CArray, ca);
29
29
 
30
- if ( level == ca->rank - 1 ) {
30
+ if ( level == ca->ndim - 1 ) {
31
31
  for (i=0; i<ca->dim[level]; i++) {
32
32
  idx[level] = i;
33
33
  rb_ary_store(ary, i, rb_ca_fetch_index(self, idx));
@@ -46,7 +46,7 @@ rb_ca_to_a_loop (VALUE self, int32_t level, ca_size_t *idx, VALUE ary)
46
46
  /* rdoc:
47
47
  class CArray
48
48
  # Converts the array to Ruby's array. For higher dimension,
49
- # the array is nested rank-1 times.
49
+ # the array is nested ndim-1 times.
50
50
  def to_a
51
51
  end
52
52
  end
@@ -149,7 +149,6 @@ rb_ca_dump_binary (int argc, VALUE *argv, VALUE self)
149
149
  case T_FILE: {
150
150
  volatile VALUE str;
151
151
  rb_io_t *iop;
152
- rb_secure(4);
153
152
  GetOpenFile(io, iop);
154
153
  rb_io_check_writable(iop);
155
154
  ca_attach(ca);
@@ -162,7 +161,6 @@ rb_ca_dump_binary (int argc, VALUE *argv, VALUE self)
162
161
  case T_FILE: {
163
162
  OpenFile *iop;
164
163
  size_t total;
165
- rb_secure(4);
166
164
  GetOpenFile(io, iop);
167
165
  rb_io_check_writable(iop);
168
166
  ca_attach(ca);
@@ -280,14 +278,14 @@ ca_to_cptr (void *ap)
280
278
  rb_raise(rb_eRuntimeError, "[BUG] ca_to_cptr called for detached array");
281
279
  }
282
280
 
283
- if ( ca->rank == 1 ) {
284
- rb_raise(rb_eRuntimeError, "[BUG] ca_to_cptr called for rank-1 array");
281
+ if ( ca->ndim == 1 ) {
282
+ rb_raise(rb_eRuntimeError, "[BUG] ca_to_cptr called for ndim-1 array");
285
283
  }
286
284
 
287
285
  offset[0] = 0;
288
286
  count[0] = ca->dim[0];
289
287
  ptr_num = count[0];
290
- for (i=1; i<ca->rank-1; i++) {
288
+ for (i=1; i<ca->ndim-1; i++) {
291
289
  offset[i] = ptr_num;
292
290
  count[i] = count[i-1] * ca->dim[i];
293
291
  ptr_num += count[i];
@@ -295,15 +293,15 @@ ca_to_cptr (void *ap)
295
293
 
296
294
  ptr = malloc(sizeof(void*)*ptr_num);
297
295
 
298
- i = ca->rank-2;
296
+ i = ca->ndim-2;
299
297
  p = ptr + offset[i];
300
298
  q = (char *)ca->ptr;
301
299
  for (j=0; j<count[i]; j++) {
302
300
  *p = (void*)q;
303
- p++; q += ca->dim[ca->rank-1] * ca->bytes;
301
+ p++; q += ca->dim[ca->ndim-1] * ca->bytes;
304
302
  }
305
303
 
306
- for (i=ca->rank-3; i>=0; i--) {
304
+ for (i=ca->ndim-3; i>=0; i--) {
307
305
  p = ptr + offset[i];
308
306
  r = ptr + offset[i+1];
309
307
  for (j=0; j<count[i]; j++) {
@@ -508,10 +506,10 @@ Init_carray_conversion ()
508
506
  /* DO NOT define CArray#to_ary, it makes trouble with various situations */
509
507
  /* rb_define_method(rb_cCArray, "to_ary", rb_ca_to_a, 0); */
510
508
 
511
- rb_define_method(rb_cCArray, "frmt", rb_ca_format, -1);
509
+ rb_define_method(rb_cCArray, "str_format", rb_ca_format, -1);
512
510
 
513
- rb_define_method(rb_cCArray, "strptime", rb_ca_strptime, 1);
514
- rb_define_method(rb_cCArray, "strftime", rb_ca_strftime, 1);
511
+ rb_define_method(rb_cCArray, "str_strptime", rb_ca_strptime, 1);
512
+ rb_define_method(rb_cCArray, "str_strftime", rb_ca_strftime, 1);
515
513
 
516
514
  rb_define_method(rb_cCArray, "test_ca_to_cptr", rb_test_ca_to_cptr, 0);
517
515
 
@@ -25,7 +25,7 @@ ca_copy (void *ap)
25
25
  co = (CArray *) cscalar_new(ca->data_type, ca->bytes, 0);
26
26
  }
27
27
  else { /* create array without mask */
28
- co = carray_new(ca->data_type, ca->rank, ca->dim, ca->bytes, 0);
28
+ co = carray_new(ca->data_type, ca->ndim, ca->dim, ca->bytes, 0);
29
29
  }
30
30
 
31
31
  if ( ca_is_attached(ca) ) {
@@ -72,7 +72,7 @@ ca_template (void *ap)
72
72
  return (CArray*) cscalar_new(ca->data_type, ca->bytes, NULL);
73
73
  }
74
74
  else { /* create array without mask */
75
- return carray_new(ca->data_type, ca->rank, ca->dim, ca->bytes, NULL);
75
+ return carray_new(ca->data_type, ca->ndim, ca->dim, ca->bytes, NULL);
76
76
  }
77
77
  }
78
78
 
@@ -84,7 +84,7 @@ ca_template_safe (void *ap)
84
84
  return (CArray*) cscalar_new(ca->data_type, ca->bytes, NULL);
85
85
  }
86
86
  else { /* create array filled with 0, without mask */
87
- return carray_new_safe(ca->data_type, ca->rank, ca->dim, ca->bytes, NULL);
87
+ return carray_new_safe(ca->data_type, ca->ndim, ca->dim, ca->bytes, NULL);
88
88
  }
89
89
  }
90
90
 
@@ -97,7 +97,7 @@ ca_template_safe2 (void *ap, int8_t data_type, ca_size_t bytes)
97
97
  return (CArray*) cscalar_new(data_type, bytes, NULL);
98
98
  }
99
99
  else { /* create array filled with 0, without mask */
100
- return carray_new_safe(data_type, ca->rank, ca->dim, bytes, NULL);
100
+ return carray_new_safe(data_type, ca->ndim, ca->dim, bytes, NULL);
101
101
  }
102
102
  }
103
103
 
@@ -209,7 +209,7 @@ ca_paste_loop (CArray *ca, ca_size_t *offset, ca_size_t *offset0,
209
209
  int32_t level, ca_size_t *idx, ca_size_t *idx0)
210
210
  {
211
211
  ca_size_t i;
212
- if ( level == ca->rank - 1 ) {
212
+ if ( level == ca->ndim - 1 ) {
213
213
  idx[level] = offset[level];
214
214
  idx0[level] = offset0[level];
215
215
  memcpy(ca_ptr_at_index(ca, idx), ca_ptr_at_index(cs, idx0), size[level]*ca->bytes);
@@ -240,9 +240,9 @@ ca_paste (void *ap, ca_size_t *offset, void *sp)
240
240
  int8_t i;
241
241
 
242
242
  ca_check_same_data_type(ca, cs);
243
- ca_check_same_rank(ca, cs);
243
+ ca_check_same_ndim(ca, cs);
244
244
 
245
- for (i=0; i<ca->rank; i++) {
245
+ for (i=0; i<ca->ndim; i++) {
246
246
  if ( offset[i] >= 0 ) {
247
247
  if ( ca->dim[i] <= cs->dim[i] + offset[i] ) {
248
248
  size[i] = ca->dim[i] - offset[i];
@@ -264,7 +264,7 @@ ca_paste (void *ap, ca_size_t *offset, void *sp)
264
264
  }
265
265
  }
266
266
 
267
- for (i=0; i<ca->rank; i++) {
267
+ for (i=0; i<ca->ndim; i++) {
268
268
  CA_CHECK_INDEX(offset[i], ca->dim[i]);
269
269
  }
270
270
 
@@ -287,7 +287,7 @@ ca_paste (void *ap, ca_size_t *offset, void *sp)
287
287
  /* rdoc:
288
288
  class CArray
289
289
  # pastes `ary` to `self` at the index `idx`.
290
- # `idx` should be Array object with the length same as `self.rank`.
290
+ # `idx` should be Array object with the length same as `self.ndim`.
291
291
  # `ary` should have same shape with `self`.
292
292
  def paste (idx, ary)
293
293
  end
@@ -307,12 +307,12 @@ rb_ca_paste (VALUE self, VALUE roffset, VALUE rsrc)
307
307
 
308
308
  Check_Type(roffset, T_ARRAY);
309
309
 
310
- if ( RARRAY_LEN(roffset) != ca->rank ) {
310
+ if ( RARRAY_LEN(roffset) != ca->ndim ) {
311
311
  rb_raise(rb_eArgError,
312
- "# of arguments should equal to the rank");
312
+ "# of arguments should equal to the ndim");
313
313
  }
314
314
 
315
- for (i=0; i<ca->rank; i++) {
315
+ for (i=0; i<ca->ndim; i++) {
316
316
  offset[i] = NUM2SIZE(rb_ary_entry(roffset,i));
317
317
  }
318
318
 
@@ -330,7 +330,7 @@ ca_clip_loop (CArray *ca, ca_size_t *offset, ca_size_t *offset0,
330
330
  int32_t level, ca_size_t *idx, ca_size_t *idx0)
331
331
  {
332
332
  ca_size_t i;
333
- if ( level == ca->rank - 1 ) {
333
+ if ( level == ca->ndim - 1 ) {
334
334
  idx[level] = offset[level];
335
335
  idx0[level] = offset0[level];
336
336
  memcpy(ca_ptr_at_index(cs, idx0), ca_ptr_at_index(ca, idx), size[level]*ca->bytes);
@@ -358,9 +358,9 @@ ca_clip (void *ap, ca_size_t *offset, void *sp)
358
358
  int i;
359
359
 
360
360
  ca_check_same_data_type(ca, cs);
361
- ca_check_same_rank(ca, cs);
361
+ ca_check_same_ndim(ca, cs);
362
362
 
363
- for (i=0; i<ca->rank; i++) {
363
+ for (i=0; i<ca->ndim; i++) {
364
364
  if ( offset[i] >= 0 ) {
365
365
  if ( ca->dim[i] <= cs->dim[i] + offset[i] ) {
366
366
  size[i] = ca->dim[i] - offset[i];
@@ -382,7 +382,7 @@ ca_clip (void *ap, ca_size_t *offset, void *sp)
382
382
  }
383
383
  }
384
384
 
385
- for (i=0; i<ca->rank; i++) {
385
+ for (i=0; i<ca->ndim; i++) {
386
386
  CA_CHECK_INDEX(offset[i], ca->dim[i]);
387
387
  }
388
388
 
@@ -421,12 +421,12 @@ rb_ca_clip (VALUE self, VALUE roffset, VALUE rsrc)
421
421
 
422
422
  Check_Type(roffset, T_ARRAY);
423
423
 
424
- if ( RARRAY_LEN(roffset) != ca->rank ) {
424
+ if ( RARRAY_LEN(roffset) != ca->ndim ) {
425
425
  rb_raise(rb_eArgError,
426
- "# of arguments should equal to the rank");
426
+ "# of arguments should equal to the ndim");
427
427
  }
428
428
 
429
- for (i=0; i<ca->rank; i++) {
429
+ for (i=0; i<ca->ndim; i++) {
430
430
  offset[i] = NUM2SIZE(rb_ary_entry(roffset, i));
431
431
  }
432
432
 
@@ -382,7 +382,7 @@ ca_addr2index (void *ap, ca_size_t addr, ca_size_t *idx)
382
382
  CArray *ca = (CArray *) ap;
383
383
  ca_size_t *dim = ca->dim;
384
384
  int8_t i;
385
- for (i=ca->rank-1; i>=0; i--) {
385
+ for (i=ca->ndim-1; i>=0; i--) {
386
386
  idx[i] = addr % dim[i];
387
387
  addr /= dim[i];
388
388
  }
@@ -398,7 +398,7 @@ ca_index2addr (void *ap, ca_size_t *idx)
398
398
  int8_t i;
399
399
  ca_size_t n;
400
400
  n = idx[0];
401
- for (i=1; i<ca->rank; i++) {
401
+ for (i=1; i<ca->ndim; i++) {
402
402
  n = dim[i]*n+idx[i];
403
403
  }
404
404
  return n;
@@ -0,0 +1,66 @@
1
+ #include "carray.h"
2
+
3
+ VALUE rb_cCArrayBoolean;
4
+ VALUE rb_cCArrayUInt8;
5
+ VALUE rb_cCArrayUInt16;
6
+ VALUE rb_cCArrayUInt32;
7
+ VALUE rb_cCArrayUInt64;
8
+ VALUE rb_cCArrayInt8;
9
+ VALUE rb_cCArrayInt16;
10
+ VALUE rb_cCArrayInt32;
11
+ VALUE rb_cCArrayInt64;
12
+ VALUE rb_cCArrayFloat32;
13
+ VALUE rb_cCArrayFloat64;
14
+ VALUE rb_cCArrayFloat128;
15
+ VALUE rb_cCArrayCmplx64;
16
+ VALUE rb_cCArrayCmplx128;
17
+ VALUE rb_cCArrayCmplx256;
18
+ VALUE rb_cCArrayObject;
19
+ VALUE rb_cCArrayFixlen;
20
+
21
+ VALUE
22
+ ca_data_type_class (int8_t data_type)
23
+ {
24
+ switch ( data_type ) {
25
+ case CA_BOOLEAN: return rb_cCArrayBoolean; break;
26
+ case CA_INT8: return rb_cCArrayInt8; break;
27
+ case CA_UINT8: return rb_cCArrayUInt8; break;
28
+ case CA_INT16: return rb_cCArrayInt16; break;
29
+ case CA_UINT16: return rb_cCArrayUInt16; break;
30
+ case CA_INT32: return rb_cCArrayInt32; break;
31
+ case CA_UINT32: return rb_cCArrayUInt32; break;
32
+ case CA_INT64: return rb_cCArrayInt64; break;
33
+ case CA_UINT64: return rb_cCArrayUInt64; break;
34
+ case CA_FLOAT32: return rb_cCArrayFloat32; break;
35
+ case CA_FLOAT64: return rb_cCArrayFloat64; break;
36
+ case CA_FLOAT128: return rb_cCArrayFloat128; break;
37
+ case CA_CMPLX64: return rb_cCArrayCmplx64; break;
38
+ case CA_CMPLX128: return rb_cCArrayCmplx128; break;
39
+ case CA_CMPLX256: return rb_cCArrayCmplx256; break;
40
+ case CA_OBJECT: return rb_cCArrayObject; break;
41
+ default: rb_raise(rb_eRuntimeError, "invalid data type");
42
+ }
43
+
44
+ }
45
+
46
+ void
47
+ Init_carray_data_type ()
48
+ {
49
+ rb_cCArrayBoolean = rb_define_class_under(rb_cCArray, "Boolean", rb_cObject);
50
+ rb_cCArrayUInt8 = rb_define_class_under(rb_cCArray, "UInt8", rb_cObject);
51
+ rb_cCArrayUInt16 = rb_define_class_under(rb_cCArray, "UInt16", rb_cObject);
52
+ rb_cCArrayUInt32 = rb_define_class_under(rb_cCArray, "UInt32", rb_cObject);
53
+ rb_cCArrayUInt64 = rb_define_class_under(rb_cCArray, "UInt64", rb_cObject);
54
+ rb_cCArrayInt8 = rb_define_class_under(rb_cCArray, "Int8", rb_cObject);
55
+ rb_cCArrayInt16 = rb_define_class_under(rb_cCArray, "Int16", rb_cObject);
56
+ rb_cCArrayInt32 = rb_define_class_under(rb_cCArray, "Int32", rb_cObject);
57
+ rb_cCArrayInt64 = rb_define_class_under(rb_cCArray, "Int64", rb_cObject);
58
+ rb_cCArrayFloat32 = rb_define_class_under(rb_cCArray, "Float32", rb_cObject);
59
+ rb_cCArrayFloat64 = rb_define_class_under(rb_cCArray, "Float64", rb_cObject);
60
+ rb_cCArrayFloat128 = rb_define_class_under(rb_cCArray, "Float128", rb_cObject);
61
+ rb_cCArrayCmplx64 = rb_define_class_under(rb_cCArray, "Cmplx64", rb_cObject);
62
+ rb_cCArrayCmplx128 = rb_define_class_under(rb_cCArray, "Cmplx128", rb_cObject);
63
+ rb_cCArrayCmplx256 = rb_define_class_under(rb_cCArray, "Cmplx256", rb_cObject);
64
+ rb_cCArrayObject = rb_define_class_under(rb_cCArray, "Object", rb_cObject);
65
+ rb_cCArrayFixlen = rb_define_class_under(rb_cCArray, "Fixlen", rb_cObject);
66
+ }
@@ -48,7 +48,7 @@ rb_ca_elem_swap (VALUE self, VALUE ridx1, VALUE ridx2)
48
48
  }
49
49
 
50
50
  if ( TYPE(ridx1) == T_ARRAY ) {
51
- for (i=0; i<ca->rank; i++) {
51
+ for (i=0; i<ca->ndim; i++) {
52
52
  k = NUM2SIZE(rb_ary_entry(ridx1, i));
53
53
  CA_CHECK_INDEX(k, ca->dim[i]);
54
54
  idx1[i] = k;
@@ -71,7 +71,7 @@ rb_ca_elem_swap (VALUE self, VALUE ridx1, VALUE ridx2)
71
71
  }
72
72
 
73
73
  if ( TYPE(ridx2) == T_ARRAY ) {
74
- for (i=0; i<ca->rank; i++) {
74
+ for (i=0; i<ca->ndim; i++) {
75
75
  k = NUM2SIZE(rb_ary_entry(ridx2, i));
76
76
  CA_CHECK_INDEX(k, ca->dim[i]);
77
77
  idx2[i] = k;
@@ -159,7 +159,7 @@ rb_ca_elem_copy (VALUE self, VALUE ridx1, VALUE ridx2)
159
159
  }
160
160
 
161
161
  if ( TYPE(ridx1) == T_ARRAY ) {
162
- for (i=0; i<ca->rank; i++) {
162
+ for (i=0; i<ca->ndim; i++) {
163
163
  k = NUM2SIZE(rb_ary_entry(ridx1, i));
164
164
  CA_CHECK_INDEX(k, ca->dim[i]);
165
165
  idx1[i] = k;
@@ -180,7 +180,7 @@ rb_ca_elem_copy (VALUE self, VALUE ridx1, VALUE ridx2)
180
180
  }
181
181
 
182
182
  if ( TYPE(ridx2) == T_ARRAY ) {
183
- for (i=0; i<ca->rank; i++) {
183
+ for (i=0; i<ca->ndim; i++) {
184
184
  k = NUM2SIZE(rb_ary_entry(ridx2, i));
185
185
  CA_CHECK_INDEX(k, ca->dim[i]);
186
186
  idx2[i] = k;
@@ -228,7 +228,7 @@ rb_ca_elem_store (VALUE self, VALUE ridx, VALUE obj)
228
228
  Data_Get_Struct(self, CArray, ca);
229
229
 
230
230
  if ( TYPE(ridx) == T_ARRAY ) {
231
- for (i=0; i<ca->rank; i++) {
231
+ for (i=0; i<ca->ndim; i++) {
232
232
  k = NUM2SIZE(rb_ary_entry(ridx, i));
233
233
  CA_CHECK_INDEX(k, ca->dim[i]);
234
234
  idx[i] = k;
@@ -264,7 +264,7 @@ rb_ca_elem_fetch (VALUE self, VALUE ridx)
264
264
  Data_Get_Struct(self, CArray, ca);
265
265
 
266
266
  if ( TYPE(ridx) == T_ARRAY ) {
267
- for (i=0; i<ca->rank; i++) {
267
+ for (i=0; i<ca->ndim; i++) {
268
268
  k = NUM2SIZE(rb_ary_entry(ridx, i));
269
269
  CA_CHECK_INDEX(k, ca->dim[i]);
270
270
  idx[i] = k;
@@ -314,7 +314,7 @@ rb_ca_elem_incr (VALUE self, VALUE ridx1)
314
314
  has_mask = ( ca->mask ) ? 1 : 0;
315
315
 
316
316
  if ( TYPE(ridx1) == T_ARRAY ) {
317
- for (i=0; i<ca->rank; i++) {
317
+ for (i=0; i<ca->ndim; i++) {
318
318
  k = NUM2SIZE(rb_ary_entry(ridx1, i));
319
319
  CA_CHECK_INDEX(k, ca->dim[i]);
320
320
  idx1[i] = k;
@@ -401,7 +401,7 @@ rb_ca_elem_decr (VALUE self, VALUE ridx1)
401
401
  has_mask = ( ca->mask ) ? 1 : 0;
402
402
 
403
403
  if ( TYPE(ridx1) == T_ARRAY ) {
404
- for (i=0; i<ca->rank; i++) {
404
+ for (i=0; i<ca->ndim; i++) {
405
405
  k = NUM2SIZE(rb_ary_entry(ridx1, i));
406
406
  CA_CHECK_INDEX(k, ca->dim[i]);
407
407
  idx1[i] = k;
@@ -475,7 +475,7 @@ rb_ca_elem_test_masked (VALUE self, VALUE ridx1)
475
475
  ca_update_mask(ca);
476
476
 
477
477
  if ( TYPE(ridx1) == T_ARRAY ) {
478
- for (i=0; i<ca->rank; i++) {
478
+ for (i=0; i<ca->ndim; i++) {
479
479
  k = NUM2SIZE(rb_ary_entry(ridx1, i));
480
480
  CA_CHECK_INDEX(k, ca->dim[i]);
481
481
  idx1[i] = k;