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
@@ -42,7 +42,7 @@ double ca_mem_count = 0.0;
42
42
 
43
43
  /* Threshold for forced garbage collection and its default value */
44
44
  double ca_gc_interval;
45
- const double ca_default_gc_interval = 40.0; /* 40MB */
45
+ const double ca_default_gc_interval = 100.0; /* 100MB */
46
46
 
47
47
  #define MB (1024*1024)
48
48
 
@@ -117,7 +117,7 @@ rb_ca_reset_gc_interval (VALUE self)
117
117
 
118
118
  static int
119
119
  carray_setup_i (CArray *ca,
120
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
120
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
121
121
  CArray *mask, int allocate, int use_calloc)
122
122
  {
123
123
  ca_size_t elements;
@@ -127,14 +127,14 @@ carray_setup_i (CArray *ca,
127
127
 
128
128
  /* check arguments */
129
129
  CA_CHECK_DATA_TYPE(data_type);
130
- CA_CHECK_RANK(rank);
131
- CA_CHECK_DIM(rank, dim);
130
+ CA_CHECK_RANK(ndim);
131
+ CA_CHECK_DIM(ndim, dim);
132
132
  CA_CHECK_BYTES(data_type, bytes);
133
133
 
134
134
  /* calculate total number of elements */
135
135
  elements = 1;
136
136
  length = bytes;
137
- for (i=0; i<rank; i++) {
137
+ for (i=0; i<ndim; i++) {
138
138
  elements *= dim[i];
139
139
  length *= dim[i];
140
140
  }
@@ -153,11 +153,11 @@ carray_setup_i (CArray *ca,
153
153
 
154
154
  ca->data_type = data_type;
155
155
  ca->flags = 0;
156
- ca->rank = rank;
156
+ ca->ndim = ndim;
157
157
  ca->bytes = bytes;
158
158
  ca->elements = elements;
159
- ca->dim = ALLOC_N(ca_size_t, rank);
160
- memcpy(ca->dim, dim, rank*sizeof(ca_size_t));
159
+ ca->dim = ALLOC_N(ca_size_t, ndim);
160
+ memcpy(ca->dim, dim, ndim*sizeof(ca_size_t));
161
161
 
162
162
  if ( allocate ) { /* allocate == true */
163
163
 
@@ -201,26 +201,26 @@ carray_setup_i (CArray *ca,
201
201
 
202
202
  int
203
203
  carray_setup (CArray *ca,
204
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask)
204
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask)
205
205
  {
206
- return carray_setup_i(ca, data_type, rank, dim, bytes, mask, 1, 0);
206
+ return carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 1, 0);
207
207
  }
208
208
 
209
209
  int
210
210
  carray_safe_setup (CArray *ca,
211
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask)
211
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask)
212
212
  {
213
- return carray_setup_i(ca, data_type, rank, dim, bytes, mask, 1, 1);
213
+ return carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 1, 1);
214
214
  }
215
215
 
216
216
  int
217
217
  ca_wrap_setup (CArray *ca,
218
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
218
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
219
219
  CArray *mask, char *ptr)
220
220
  {
221
221
  int ret;
222
222
 
223
- ret = carray_setup_i(ca, data_type, rank, dim, bytes, mask, 0, 0);
223
+ ret = carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 0, 0);
224
224
  if ( (!ptr) && (ca->elements != 0) ) {
225
225
  rb_raise(rb_eRuntimeError, "wrapping NULL pointer with an non-empty array");
226
226
  }
@@ -230,49 +230,49 @@ ca_wrap_setup (CArray *ca,
230
230
 
231
231
  int
232
232
  ca_wrap_setup_null (CArray *ca,
233
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
233
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
234
234
  CArray *mask)
235
235
  {
236
236
  int ret;
237
237
 
238
- ret = carray_setup_i(ca, data_type, rank, dim, bytes, mask, 0, 0);
238
+ ret = carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 0, 0);
239
239
  ca->ptr = NULL;
240
240
  return ret;
241
241
  }
242
242
 
243
243
  CArray *
244
- carray_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
244
+ carray_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
245
245
  CArray *mask)
246
246
  {
247
247
  CArray *ca = ALLOC(CArray);
248
- carray_setup(ca, data_type, rank, dim, bytes, mask);
248
+ carray_setup(ca, data_type, ndim, dim, bytes, mask);
249
249
  return ca;
250
250
  }
251
251
 
252
252
  CArray *
253
- carray_new_safe (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
253
+ carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
254
254
  CArray *mask)
255
255
  {
256
256
  CArray *ca = ALLOC(CArray);
257
- carray_safe_setup(ca, data_type, rank, dim, bytes, mask);
257
+ carray_safe_setup(ca, data_type, ndim, dim, bytes, mask);
258
258
  return ca;
259
259
  }
260
260
 
261
261
  CAWrap *
262
- ca_wrap_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
262
+ ca_wrap_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
263
263
  CArray *mask, char *ptr)
264
264
  {
265
265
  CAWrap *ca = ALLOC(CAWrap);
266
- ca_wrap_setup(ca, data_type, rank, dim, bytes, mask, ptr);
266
+ ca_wrap_setup(ca, data_type, ndim, dim, bytes, mask, ptr);
267
267
  return ca;
268
268
  }
269
269
 
270
270
  CAWrap *
271
- ca_wrap_new_null (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
271
+ ca_wrap_new_null (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
272
272
  CArray *mask)
273
273
  {
274
274
  CAWrap *ca = ALLOC(CAWrap);
275
- ca_wrap_setup_null(ca, data_type, rank, dim, bytes, mask);
275
+ ca_wrap_setup_null(ca, data_type, ndim, dim, bytes, mask);
276
276
  return ca;
277
277
  }
278
278
 
@@ -313,7 +313,7 @@ cscalar_setup (CScalar *ca,
313
313
  ca->obj_type = CA_OBJ_SCALAR;
314
314
  ca->data_type = data_type;
315
315
  ca->flags = 0;
316
- ca->rank = 1;
316
+ ca->ndim = 1;
317
317
  ca->bytes = bytes;
318
318
  ca->elements = 1;
319
319
  ca->dim = &(ca->_dim);
@@ -388,7 +388,7 @@ ca_array_func_clone (void *ap)
388
388
  {
389
389
  CArray *ca = (CArray *) ap;
390
390
  CArray *co;
391
- co = carray_new(ca->data_type, ca->rank, ca->dim, ca->bytes, ca->mask);
391
+ co = carray_new(ca->data_type, ca->ndim, ca->dim, ca->bytes, ca->mask);
392
392
  memcpy(co->ptr, ca->ptr, ca_length(ca));
393
393
  return co;
394
394
  }
@@ -407,9 +407,9 @@ ca_array_func_ptr_at_index (void *ap, ca_size_t *idx)
407
407
  ca_size_t *dim = ca->dim;
408
408
  int8_t i;
409
409
  ca_size_t n;
410
- n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[rank-1] */
411
- for (i=1; i<ca->rank; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[rank-1] */
412
- n = dim[i]*n+idx[i]; /* ... + idx[rank-2]*dim[1] + idx[rank-1] */
410
+ n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[ndim-1] */
411
+ for (i=1; i<ca->ndim; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[ndim-1] */
412
+ n = dim[i]*n+idx[i]; /* ... + idx[ndim-2]*dim[1] + idx[ndim-1] */
413
413
  }
414
414
  return ca->ptr + ca->bytes * n;
415
415
  }
@@ -429,7 +429,7 @@ ca_array_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
429
429
  int8_t i;
430
430
  ca_size_t n;
431
431
  n = idx[0];
432
- for (i=1; i<ca->rank; i++) {
432
+ for (i=1; i<ca->ndim; i++) {
433
433
  n = dim[i]*n+idx[i];
434
434
  }
435
435
  memcpy(ptr, ca->ptr + ca->bytes * n, ca->bytes);
@@ -450,7 +450,7 @@ ca_array_func_store_index (void *ap, ca_size_t *idx, void *ptr)
450
450
  int8_t i;
451
451
  ca_size_t n;
452
452
  n = idx[0];
453
- for (i=1; i<ca->rank; i++) {
453
+ for (i=1; i<ca->ndim; i++) {
454
454
  n = dim[i]*n+idx[i];
455
455
  }
456
456
  memcpy(ca->ptr + ca->bytes * n, ptr, ca->bytes);
@@ -547,7 +547,7 @@ void
547
547
  ca_array_func_create_mask (void *ap)
548
548
  {
549
549
  CArray *ca = (CArray *) ap;
550
- ca->mask = carray_new_safe(CA_BOOLEAN, ca->rank, ca->dim, 0, NULL);
550
+ ca->mask = carray_new_safe(CA_BOOLEAN, ca->ndim, ca->dim, 0, NULL);
551
551
  }
552
552
 
553
553
  ca_operation_function_t ca_array_func = {
@@ -654,18 +654,18 @@ ca_operation_function_t ca_scalar_func = {
654
654
  /* ------------------------------------------------------------------- */
655
655
 
656
656
  VALUE
657
- rb_carray_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
657
+ rb_carray_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
658
658
  CArray *mask)
659
659
  {
660
- CArray *ca = carray_new(data_type, rank, dim, bytes, mask);
660
+ CArray *ca = carray_new(data_type, ndim, dim, bytes, mask);
661
661
  return ca_wrap_struct(ca);
662
662
  }
663
663
 
664
664
  VALUE
665
- rb_carray_new_safe (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
665
+ rb_carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
666
666
  CArray *mask)
667
667
  {
668
- CArray *ca = carray_new_safe(data_type, rank, dim, bytes, mask);
668
+ CArray *ca = carray_new_safe(data_type, ndim, dim, bytes, mask);
669
669
  return ca_wrap_struct(ca);
670
670
  }
671
671
 
@@ -704,7 +704,7 @@ rb_ca_s_allocate (VALUE klass)
704
704
  # CArray.new(data_type, dim, bytes=0) { ... }
705
705
  #
706
706
  # Constructs a new CArray object of <i>data_type</i>, which has the
707
- # rank and the dimensions specified by an <code>Array</code> of
707
+ # ndim and the dimensions specified by an <code>Array</code> of
708
708
  # <code>Integer</code> or an argument list of <code>Integer</code>.
709
709
  # The byte size of each element for the fixed length data type
710
710
  # (<code>data_type == CA_FIXLEN</code>) is specified optional argument
@@ -720,7 +720,7 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
720
720
  {
721
721
  volatile VALUE rtype, rdim, ropt, rbytes = Qnil;
722
722
  CArray *ca;
723
- int8_t data_type, rank;
723
+ int8_t data_type, ndim;
724
724
  ca_size_t dim[CA_RANK_MAX];
725
725
  ca_size_t bytes;
726
726
  int8_t i;
@@ -732,13 +732,13 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
732
732
  rb_ca_data_type_import(self, rtype);
733
733
 
734
734
  Check_Type(rdim, T_ARRAY);
735
- rank = RARRAY_LEN(rdim);
736
- for (i=0; i<rank; i++) {
735
+ ndim = RARRAY_LEN(rdim);
736
+ for (i=0; i<ndim; i++) {
737
737
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
738
738
  }
739
739
 
740
740
  Data_Get_Struct(self, CArray, ca);
741
- carray_safe_setup(ca, data_type, rank, dim, bytes, NULL);
741
+ carray_safe_setup(ca, data_type, ndim, dim, bytes, NULL);
742
742
 
743
743
  if ( rb_block_given_p() ) {
744
744
  volatile VALUE rval = rb_yield(self);
@@ -759,13 +759,18 @@ rb_ca_s_fixlen (int argc, VALUE *argv, VALUE klass)
759
759
  return rb_class_new_instance(3, args, klass);
760
760
  }
761
761
 
762
- #define rb_ca_s_type(type, code) \
763
- rb_ca_s_## type (int argc, VALUE *argv, VALUE klass) \
764
- { \
765
- volatile VALUE ropt = rb_pop_options(&argc, &argv); \
766
- volatile VALUE rdim = rb_ary_new4(argc, argv); \
767
- VALUE args[3] = { INT2NUM(code), rdim, ropt }; \
768
- return rb_class_new_instance(3, args, klass); \
762
+ #define rb_ca_s_type(type, code) \
763
+ rb_ca_s_## type (int argc, VALUE *argv, VALUE klass) \
764
+ { \
765
+ if ( argc == 0 ) { \
766
+ return ca_data_type_class(code); \
767
+ } \
768
+ else { \
769
+ volatile VALUE ropt = rb_pop_options(&argc, &argv); \
770
+ volatile VALUE rdim = rb_ary_new4(argc, argv); \
771
+ VALUE args[3] = { INT2NUM(code), rdim, ropt }; \
772
+ return rb_class_new_instance(3, args, klass); \
773
+ } \
769
774
  }
770
775
 
771
776
  /*
@@ -820,7 +825,7 @@ rb_ca_initialize_copy (VALUE self, VALUE other)
820
825
  Data_Get_Struct(other, CArray, cs);
821
826
 
822
827
  ca_update_mask(cs);
823
- carray_setup(ca, cs->data_type, cs->rank, cs->dim, cs->bytes, cs->mask);
828
+ carray_setup(ca, cs->data_type, cs->ndim, cs->dim, cs->bytes, cs->mask);
824
829
 
825
830
  memcpy(ca->ptr, cs->ptr, ca_length(cs));
826
831
 
@@ -837,7 +842,7 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
837
842
  {
838
843
  volatile VALUE obj, target, rtype, rdim, ropt, rbytes = Qnil;
839
844
  CArray *ca;
840
- int8_t data_type, rank;
845
+ int8_t data_type, ndim;
841
846
  ca_size_t dim[CA_RANK_MAX];
842
847
  ca_size_t bytes;
843
848
  int8_t i;
@@ -848,15 +853,15 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
848
853
  rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
849
854
 
850
855
  Check_Type(rdim, T_ARRAY);
851
- rank = RARRAY_LEN(rdim);
852
- for (i=0; i<rank; i++) {
856
+ ndim = RARRAY_LEN(rdim);
857
+ for (i=0; i<ndim; i++) {
853
858
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
854
859
  }
855
860
 
856
861
  target = rb_yield_values(0);
857
862
 
858
863
  obj = Data_Make_Struct(rb_cCAWrap, CAWrap, ca_mark, ca_free, ca);
859
- ca_wrap_setup_null(ca, data_type, rank, dim, bytes, NULL);
864
+ ca_wrap_setup_null(ca, data_type, ndim, dim, bytes, NULL);
860
865
 
861
866
  rb_funcall(target, rb_intern("wrap_as_carray"), 1, obj);
862
867
  rb_ivar_set(obj, rb_intern("referred_object"), target);
@@ -865,13 +870,13 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
865
870
  }
866
871
 
867
872
  VALUE
868
- rb_carray_wrap_ptr (int8_t data_type, int8_t rank, ca_size_t *dim,
873
+ rb_carray_wrap_ptr (int8_t data_type, int8_t ndim, ca_size_t *dim,
869
874
  ca_size_t bytes, CArray *mask, char *ptr, VALUE refer)
870
875
  {
871
876
  volatile VALUE obj;
872
877
  CArray *ca;
873
878
 
874
- ca = ca_wrap_new(data_type, rank, dim, bytes, mask, ptr);
879
+ ca = ca_wrap_new(data_type, ndim, dim, bytes, mask, ptr);
875
880
  obj = ca_wrap_struct(ca);
876
881
 
877
882
  rb_ivar_set(obj, rb_intern("referred_object"), refer);
@@ -15,7 +15,7 @@
15
15
  typedef struct {
16
16
  int16_t obj_type;
17
17
  int8_t data_type;
18
- int8_t rank;
18
+ int8_t ndim;
19
19
  int32_t flags;
20
20
  ca_size_t bytes;
21
21
  ca_size_t elements;
@@ -55,7 +55,7 @@ static uint8_t bits[8] = {
55
55
  int
56
56
  ca_bitarray_setup (CABitarray *ca, CArray *parent)
57
57
  {
58
- int8_t rank;
58
+ int8_t ndim;
59
59
  ca_size_t bitlen, elements;
60
60
 
61
61
  /* check arguments */
@@ -64,19 +64,19 @@ ca_bitarray_setup (CABitarray *ca, CArray *parent)
64
64
  rb_raise(rb_eCADataTypeError, "invalid data_type for bitarray");
65
65
  }
66
66
 
67
- rank = parent->rank + 1;
67
+ ndim = parent->ndim + 1;
68
68
  bitlen = 8 * parent->bytes;
69
69
  elements = bitlen * parent->elements;
70
70
 
71
71
  ca->obj_type = CA_OBJ_BITARRAY;
72
72
  ca->data_type = CA_BOOLEAN;
73
73
  ca->flags = 0;
74
- ca->rank = rank;
74
+ ca->ndim = ndim;
75
75
  ca->bytes = 1;
76
76
  ca->elements = elements;
77
77
  ca->ptr = NULL;
78
78
  ca->mask = NULL;
79
- ca->dim = ALLOC_N(ca_size_t, rank);
79
+ ca->dim = ALLOC_N(ca_size_t, ndim);
80
80
 
81
81
  ca->parent = parent;
82
82
  ca->attach = 0;
@@ -85,8 +85,8 @@ ca_bitarray_setup (CABitarray *ca, CArray *parent)
85
85
  ca->bytelen = parent->bytes;
86
86
  ca->bitlen = bitlen;
87
87
 
88
- memcpy(ca->dim, parent->dim, (rank-1) * sizeof(ca_size_t));
89
- ca->dim[rank-1] = bitlen;
88
+ memcpy(ca->dim, parent->dim, (ndim-1) * sizeof(ca_size_t));
89
+ ca->dim[ndim-1] = bitlen;
90
90
 
91
91
  if ( ca_has_mask(parent) ) {
92
92
  ca_create_mask(ca);
@@ -158,7 +158,7 @@ ca_bitarray_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
158
158
  {
159
159
  CABitarray *ca = (CABitarray *) ap;
160
160
  ca_size_t bytes = ca->parent->bytes;
161
- ca_size_t offset = idx[ca->rank-1];
161
+ ca_size_t offset = idx[ca->ndim-1];
162
162
  ca_size_t major, minor;
163
163
 
164
164
  if ( ca_endian == CA_BIG_ENDIAN &&
@@ -190,7 +190,7 @@ ca_bitarray_func_store_index (void *ap, ca_size_t *idx, void *ptr)
190
190
  {
191
191
  CABitarray *ca = (CABitarray *) ap;
192
192
  uint8_t test = *(uint8_t *) ptr;
193
- ca_size_t offset = idx[ca->rank-1];
193
+ ca_size_t offset = idx[ca->ndim-1];
194
194
  ca_size_t bytes = ca->parent->bytes;
195
195
  ca_size_t major, minor;
196
196
 
@@ -310,16 +310,16 @@ ca_bitarray_func_create_mask (void *ap)
310
310
  ca_size_t count[CA_RANK_MAX];
311
311
  int8_t i;
312
312
 
313
- for (i=0; i<ca->rank-1; i++) {
313
+ for (i=0; i<ca->ndim-1; i++) {
314
314
  count[i] = 0;
315
315
  }
316
- count[ca->rank-1] = ca->bitlen;
316
+ count[ca->ndim-1] = ca->bitlen;
317
317
 
318
318
  ca_update_mask(ca->parent);
319
319
  if ( ! ca->parent->mask ) {
320
320
  ca_create_mask(ca->parent);
321
321
  }
322
- ca->mask = (CArray *) ca_repeat_new(ca->parent->mask, ca->rank, count);
322
+ ca->mask = (CArray *) ca_repeat_new(ca->parent->mask, ca->ndim, count);
323
323
 
324
324
  ca_unset_flag(ca->mask, CA_FLAG_READ_ONLY);
325
325
  }
@@ -15,7 +15,7 @@
15
15
  typedef struct {
16
16
  int16_t obj_type;
17
17
  int8_t data_type;
18
- int8_t rank;
18
+ int8_t ndim;
19
19
  int32_t flags;
20
20
  ca_size_t bytes;
21
21
  ca_size_t elements;
@@ -211,7 +211,7 @@ int
211
211
  ca_bitfield_setup (CABitfield *ca, CArray *parent,
212
212
  ca_size_t offset, ca_size_t bitlen)
213
213
  {
214
- int8_t rank;
214
+ int8_t ndim;
215
215
  int8_t data_type;
216
216
  ca_size_t bytes = 0, elements;
217
217
  ca_size_t bitsize;
@@ -228,7 +228,7 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
228
228
  }
229
229
  */
230
230
 
231
- rank = parent->rank;
231
+ ndim = parent->ndim;
232
232
  bitsize = parent->bytes * 8;
233
233
  elements = parent->elements;
234
234
 
@@ -293,12 +293,12 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
293
293
  ca->obj_type = CA_OBJ_BITFIELD;
294
294
  ca->data_type = data_type;
295
295
  ca->flags = 0;
296
- ca->rank = rank;
296
+ ca->ndim = ndim;
297
297
  ca->bytes = bytes;
298
298
  ca->elements = elements;
299
299
  ca->ptr = NULL;
300
300
  ca->mask = NULL;
301
- ca->dim = ALLOC_N(ca_size_t, rank);
301
+ ca->dim = ALLOC_N(ca_size_t, ndim);
302
302
 
303
303
  ca->parent = parent;
304
304
  ca->attach = 0;
@@ -308,7 +308,7 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
308
308
  ca->bit_offset = bit_offset;
309
309
  ca->bit_mask = bit_mask;
310
310
 
311
- memcpy(ca->dim, parent->dim, rank * sizeof(ca_size_t));
311
+ memcpy(ca->dim, parent->dim, ndim * sizeof(ca_size_t));
312
312
 
313
313
  if ( ca_has_mask(parent) ) {
314
314
  ca_create_mask(ca);
@@ -484,7 +484,7 @@ ca_bitfield_func_create_mask (void *ap)
484
484
  }
485
485
 
486
486
  ca->mask = (CArray *) ca_refer_new(ca->parent->mask,
487
- CA_BOOLEAN, ca->rank, ca->dim, 0, 0);
487
+ CA_BOOLEAN, ca->ndim, ca->dim, 0, 0);
488
488
  }
489
489
 
490
490
  ca_operation_function_t ca_bitfield_func = {