carray 1.4.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSES +22 -0
  3. data/README.md +18 -14
  4. data/Rakefile +1 -1
  5. data/carray.gemspec +5 -13
  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} +73 -51
  28. data/{carray_access.c → ext/carray_access.c} +83 -83
  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} +8 -10
  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} +0 -0
  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} +3 -3
  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} +9 -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} +0 -0
  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 +48 -37
  62. data/lib/carray/{base/autoload.rb → autoload.rb} +1 -1
  63. data/lib/carray/autoload/autoload_base.rb +1 -1
  64. data/lib/carray/autoload/autoload_gem_numo_narray.rb +4 -3
  65. data/lib/carray/autoload/autoload_gem_random.rb +8 -0
  66. data/lib/carray/basic.rb +193 -0
  67. data/lib/carray/compose.rb +291 -0
  68. data/lib/carray/construct.rb +445 -0
  69. data/lib/carray/convert.rb +115 -0
  70. data/lib/carray/{base/inspect.rb → inspect.rb} +6 -6
  71. data/lib/carray/io/imagemagick.rb +1 -1
  72. data/lib/carray/{base/iterator.rb → iterator.rb} +3 -3
  73. data/lib/carray/mask.rb +91 -0
  74. data/lib/carray/{base/math.rb → math.rb} +16 -46
  75. data/lib/carray/math/histogram.rb +7 -7
  76. data/lib/carray/mkmf.rb +8 -0
  77. data/lib/carray/object/ca_obj_pack.rb +8 -8
  78. data/lib/carray/obsolete.rb +272 -0
  79. data/lib/carray/ordering.rb +157 -0
  80. data/lib/carray/{base/serialize.rb → serialize.rb} +28 -53
  81. data/lib/carray/{base/string.rb → string.rb} +12 -64
  82. data/lib/carray/{base/struct.rb → struct.rb} +16 -16
  83. data/lib/carray/{io/table.rb → table.rb} +1 -10
  84. data/lib/carray/testing.rb +56 -0
  85. data/lib/carray/time.rb +78 -0
  86. data/lib/carray/transform.rb +100 -0
  87. data/misc/Methods.ja.md +182 -0
  88. data/{NOTE → misc/NOTE} +0 -0
  89. data/test/test_ALL.rb +0 -2
  90. data/test/test_order.rb +7 -7
  91. data/test/test_ref_store.rb +13 -13
  92. data/test/test_stat.rb +7 -15
  93. data/{devel → utils}/guess_shape.rb +0 -0
  94. data/utils/{diff_method.rb → monkey_patch_methods.rb} +17 -7
  95. metadata +88 -151
  96. data/COPYING +0 -56
  97. data/GPL +0 -340
  98. data/LEGAL +0 -50
  99. data/TODO +0 -5
  100. data/carray_random.c +0 -531
  101. data/devel/im2col.rb +0 -17
  102. data/ext/calculus/carray_calculus.c +0 -931
  103. data/ext/calculus/carray_interp.c +0 -358
  104. data/ext/calculus/extconf.rb +0 -12
  105. data/ext/calculus/lib/math/calculus.rb +0 -119
  106. data/ext/calculus/lib/math/interp/adapter_interp1d.rb +0 -31
  107. data/ext/mathfunc/extconf.rb +0 -18
  108. data/ext/mathfunc/test/test_hypot.rb +0 -5
  109. data/ext/mathfunc/test/test_j0.rb +0 -22
  110. data/ext/mathfunc/test/test_jn.rb +0 -8
  111. data/ext/mathfunc/test/test_sph.rb +0 -9
  112. data/lib/carray/autoload/autoload_io_table.rb +0 -1
  113. data/lib/carray/autoload/autoload_math_interp.rb +0 -4
  114. data/lib/carray/base/basic.rb +0 -1146
  115. data/lib/carray/base/obsolete.rb +0 -131
  116. data/lib/carray/math/interp.rb +0 -57
  117. data/lib/carray/math/interp/adapter_gsl_spline.rb +0 -47
  118. data/mt19937ar.c +0 -182
  119. data/mt19937ar.h +0 -86
  120. data/rdoc_main.rb +0 -27
  121. data/rdoc_math.rb +0 -5
  122. data/rdoc_stat.rb +0 -31
  123. data/test/test_narray.rb +0 -64
  124. data/test/test_random.rb +0 -15
  125. data/utils/create_rdoc.sh +0 -9
  126. data/utils/make_tgz.sh +0 -3
@@ -15,19 +15,19 @@
15
15
  VALUE rb_cCAIterator;
16
16
 
17
17
  int8_t
18
- ca_iter_rank (VALUE self)
18
+ ca_iter_ndim (VALUE self)
19
19
  {
20
- int8_t rank;
20
+ int8_t ndim;
21
21
  if ( TYPE(self) == T_DATA ) {
22
22
  CAIterator *it;
23
23
  Data_Get_Struct(self, CAIterator, it);
24
- rank = it->rank;
24
+ ndim = it->ndim;
25
25
  }
26
26
  else {
27
- VALUE rrank = rb_ivar_get(self, rb_intern("@rank"));
28
- rank = (int8_t) NUM2LONG(rrank);
27
+ VALUE rndim = rb_ivar_get(self, rb_intern("@ndim"));
28
+ ndim = (int8_t) NUM2LONG(rndim);
29
29
  }
30
- return rank;
30
+ return ndim;
31
31
  }
32
32
 
33
33
  void
@@ -37,16 +37,16 @@ ca_iter_dim (VALUE self, ca_size_t *dim)
37
37
  if ( TYPE(self) == T_DATA ) {
38
38
  CAIterator *it;
39
39
  Data_Get_Struct(self, CAIterator, it);
40
- for (i=0; i<it->rank; i++) {
40
+ for (i=0; i<it->ndim; i++) {
41
41
  dim[i] = it->dim[i];
42
42
  }
43
43
  }
44
44
  else {
45
- VALUE rrank = rb_ivar_get(self, rb_intern("@rank"));
45
+ VALUE rndim = rb_ivar_get(self, rb_intern("@ndim"));
46
46
  VALUE rdim = rb_ivar_get(self, rb_intern("@dim"));
47
- int8_t rank;
48
- rank = (int8_t) NUM2INT(rrank);
49
- for (i=0; i<rank; i++) {
47
+ int8_t ndim;
48
+ ndim = (int8_t) NUM2INT(rndim);
49
+ for (i=0; i<ndim; i++) {
50
50
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
51
51
  }
52
52
  }
@@ -60,16 +60,16 @@ ca_iter_elements (VALUE self)
60
60
  CAIterator *it;
61
61
  Data_Get_Struct(self, CAIterator, it);
62
62
  elements = 1;
63
- for (i=0; i<it->rank; i++) {
63
+ for (i=0; i<it->ndim; i++) {
64
64
  elements *= it->dim[i];
65
65
  }
66
66
  }
67
67
  else {
68
- VALUE rrank = rb_ivar_get(self, rb_intern("@rank"));
68
+ VALUE rndim = rb_ivar_get(self, rb_intern("@ndim"));
69
69
  VALUE rdim = rb_ivar_get(self, rb_intern("@dim"));
70
- int8_t rank = (int8_t) NUM2INT(rrank);
70
+ int8_t ndim = (int8_t) NUM2INT(rndim);
71
71
  elements = 1;
72
- for (i=0; i<rank; i++) {
72
+ for (i=0; i<ndim; i++) {
73
73
  elements *= NUM2SIZE(rb_ary_entry(rdim, i));
74
74
  }
75
75
  }
@@ -119,10 +119,10 @@ ca_iter_kernel_at_index (VALUE self, ca_size_t *idx, VALUE rref)
119
119
  }
120
120
  else {
121
121
  VALUE vidx;
122
- int8_t rank = ca_iter_rank(self);
122
+ int8_t ndim = ca_iter_ndim(self);
123
123
  int i;
124
- vidx = rb_ary_new2(rank);
125
- for (i=0; i<rank; i++) {
124
+ vidx = rb_ary_new2(ndim);
125
+ for (i=0; i<ndim; i++) {
126
126
  rb_ary_store(vidx, i, SIZE2NUM(idx[i]));
127
127
  }
128
128
  rker = rb_funcall(self, rb_intern("kernel_at_index"), 2,
@@ -161,10 +161,10 @@ ca_iter_kernel_move_to_index (VALUE self, ca_size_t *idx, VALUE rref)
161
161
  }
162
162
  else {
163
163
  VALUE vidx;
164
- int8_t rank = ca_iter_rank(self);
164
+ int8_t ndim = ca_iter_ndim(self);
165
165
  int i;
166
- vidx = rb_ary_new2(rank);
167
- for (i=0; i<rank; i++) {
166
+ vidx = rb_ary_new2(ndim);
167
+ for (i=0; i<ndim; i++) {
168
168
  rb_ary_store(vidx, i, SIZE2NUM(idx[i]));
169
169
  }
170
170
  rker = rb_funcall(self, rb_intern("kernel_move_to_index"), 2,
@@ -188,17 +188,17 @@ ca_iter_prepare_output (VALUE self, VALUE rtype, VALUE rbytes)
188
188
  if ( TYPE(self) == T_DATA ) {
189
189
  CAIterator *it;
190
190
  Data_Get_Struct(self, CAIterator, it);
191
- co = carray_new_safe(data_type, it->rank, it->dim, bytes, NULL);
191
+ co = carray_new_safe(data_type, it->ndim, it->dim, bytes, NULL);
192
192
  }
193
193
  else {
194
- VALUE rrank = rb_ivar_get(self, rb_intern("@rank"));
194
+ VALUE rndim = rb_ivar_get(self, rb_intern("@ndim"));
195
195
  VALUE rdim = rb_ivar_get(self, rb_intern("@dim"));
196
- int8_t rank = NUM2LONG(rrank);
196
+ int8_t ndim = NUM2LONG(rndim);
197
197
  ca_size_t dim[CA_RANK_MAX];
198
- for (i=0; i<rank; i++) {
198
+ for (i=0; i<ndim; i++) {
199
199
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
200
200
  }
201
- co = carray_new_safe(data_type, rank, dim, bytes, NULL);
201
+ co = carray_new_safe(data_type, ndim, dim, bytes, NULL);
202
202
  }
203
203
 
204
204
  obj = ca_wrap_struct(co);
@@ -211,16 +211,16 @@ ca_iter_prepare_output (VALUE self, VALUE rtype, VALUE rbytes)
211
211
 
212
212
  /* rdoc:
213
213
  class CAIterator
214
- def rank
214
+ def ndim
215
215
  end
216
216
  end
217
217
  */
218
218
 
219
219
 
220
220
  VALUE
221
- rb_ca_iter_rank (VALUE self)
221
+ rb_ca_iter_ndim (VALUE self)
222
222
  {
223
- return LONG2NUM(ca_iter_rank(self));
223
+ return LONG2NUM(ca_iter_ndim(self));
224
224
  }
225
225
 
226
226
  /* rdoc:
@@ -235,11 +235,11 @@ rb_ca_iter_dim (VALUE self)
235
235
  {
236
236
  VALUE rdim;
237
237
  ca_size_t dim[CA_RANK_MAX];
238
- int8_t rank = ca_iter_rank(self);
238
+ int8_t ndim = ca_iter_ndim(self);
239
239
  int i;
240
240
  ca_iter_dim(self, dim);
241
- rdim = rb_ary_new2(rank);
242
- for (i=0; i<rank; i++) {
241
+ rdim = rb_ary_new2(ndim);
242
+ for (i=0; i<ndim; i++) {
243
243
  rb_ary_store(rdim, i, SIZE2NUM(dim[i]));
244
244
  }
245
245
  return rdim;
@@ -301,7 +301,7 @@ rb_ca_iter_kernel_at_index (int argc, VALUE *argv, VALUE self)
301
301
  {
302
302
  volatile VALUE rindex, rcarray;
303
303
  ca_size_t idx[CA_RANK_MAX];
304
- int8_t rank = ca_iter_rank(self);
304
+ int8_t ndim = ca_iter_ndim(self);
305
305
  int i;
306
306
 
307
307
  rb_scan_args(argc, argv, "11", (VALUE *) &rindex, (VALUE *) &rcarray);
@@ -310,7 +310,7 @@ rb_ca_iter_kernel_at_index (int argc, VALUE *argv, VALUE self)
310
310
  rcarray = rb_ca_iter_reference(self);
311
311
  }
312
312
 
313
- for (i=0; i<rank; i++) {
313
+ for (i=0; i<ndim; i++) {
314
314
  idx[i] = NUM2SIZE(rb_ary_entry(rindex, i));
315
315
  }
316
316
 
@@ -341,10 +341,10 @@ VALUE
341
341
  rb_ca_iter_kernel_move_to_index (VALUE self, VALUE rindex, VALUE rker)
342
342
  {
343
343
  ca_size_t idx[CA_RANK_MAX];
344
- int8_t rank = ca_iter_rank(self);
344
+ int8_t ndim = ca_iter_ndim(self);
345
345
  int i;
346
346
 
347
- for (i=0; i<rank; i++) {
347
+ for (i=0; i<ndim; i++) {
348
348
  idx[i] = NUM2SIZE(rb_ary_entry(rindex, i));
349
349
  }
350
350
 
@@ -501,7 +501,7 @@ rb_ca_iter_filter (int argc, VALUE *argv, VALUE self)
501
501
  argc--;
502
502
  argv++;
503
503
 
504
- co = carray_new(data_type, cr->rank, cr->dim, 0, NULL);
504
+ co = carray_new(data_type, cr->ndim, cr->dim, 0, NULL);
505
505
  routput = ca_wrap_struct(co);
506
506
 
507
507
  if ( NIL_P(argv[0]) ) {
@@ -606,8 +606,10 @@ Init_carray_iterator ()
606
606
  {
607
607
  rb_cCAIterator = rb_define_class("CAIterator", rb_cObject);
608
608
 
609
- rb_define_method(rb_cCAIterator, "rank", rb_ca_iter_rank, 0);
609
+ rb_define_method(rb_cCAIterator, "ndim", rb_ca_iter_ndim, 0);
610
+ rb_define_method(rb_cCAIterator, "rank", rb_ca_iter_ndim, 0); /* alias */
610
611
  rb_define_method(rb_cCAIterator, "dim", rb_ca_iter_dim, 0);
612
+ rb_define_method(rb_cCAIterator, "shape", rb_ca_iter_dim, 0); /* alias */
611
613
  rb_define_method(rb_cCAIterator, "elements", rb_ca_iter_elements, 0);
612
614
  rb_define_method(rb_cCAIterator, "reference", rb_ca_iter_reference, 0);
613
615
 
@@ -13,29 +13,29 @@
13
13
  #include "carray.h"
14
14
 
15
15
  static VALUE
16
- rb_ca_s_each_index_internal (int rank, VALUE *dim, uint8_t irank, VALUE ridx)
16
+ rb_ca_s_each_index_internal (int ndim, VALUE *dim, uint8_t indim, VALUE ridx)
17
17
  {
18
18
  volatile VALUE ret = Qnil;
19
- int32_t is_leaf = (irank == rank - 1);
19
+ int32_t is_leaf = (indim == ndim - 1);
20
20
  ca_size_t i;
21
21
 
22
- if ( NIL_P(dim[irank]) ) {
23
- rb_ary_store(ridx, irank, Qnil);
22
+ if ( NIL_P(dim[indim]) ) {
23
+ rb_ary_store(ridx, indim, Qnil);
24
24
  if ( is_leaf ) {
25
25
  ret = rb_yield_splat(rb_obj_clone(ridx));
26
26
  }
27
27
  else {
28
- ret = rb_ca_s_each_index_internal(rank, dim, irank+1, ridx);
28
+ ret = rb_ca_s_each_index_internal(ndim, dim, indim+1, ridx);
29
29
  }
30
30
  }
31
31
  else {
32
- for (i=0; i<NUM2SIZE(dim[irank]); i++) {
33
- rb_ary_store(ridx, irank, SIZE2NUM(i));
32
+ for (i=0; i<NUM2SIZE(dim[indim]); i++) {
33
+ rb_ary_store(ridx, indim, SIZE2NUM(i));
34
34
  if ( is_leaf ) {
35
35
  ret = rb_yield_splat(rb_obj_clone(ridx));
36
36
  }
37
37
  else {
38
- ret = rb_ca_s_each_index_internal(rank, dim, irank+1, ridx);
38
+ ret = rb_ca_s_each_index_internal(ndim, dim, indim+1, ridx);
39
39
  }
40
40
  }
41
41
  }
@@ -58,13 +58,13 @@ rb_ca_s_each_index_internal (int rank, VALUE *dim, uint8_t irank, VALUE ridx)
58
58
  */
59
59
 
60
60
  static VALUE
61
- rb_ca_s_each_index (int rank, VALUE *dim, VALUE self)
61
+ rb_ca_s_each_index (int ndim, VALUE *dim, VALUE self)
62
62
  {
63
- volatile VALUE ridx = rb_ary_new2(rank);
63
+ volatile VALUE ridx = rb_ary_new2(ndim);
64
64
  #if RUBY_VERSION_CODE >= 190
65
- RETURN_ENUMERATOR(self, rank, dim);
65
+ RETURN_ENUMERATOR(self, ndim, dim);
66
66
  #endif
67
- return rb_ca_s_each_index_internal(rank, dim, 0, ridx);
67
+ return rb_ca_s_each_index_internal(ndim, dim, 0, ridx);
68
68
  }
69
69
 
70
70
  /* ------------------------------------------------------------------- */
@@ -145,7 +145,7 @@ rb_ca_each_index_internal (VALUE self, int8_t level, VALUE ridx)
145
145
  CArray *ca;
146
146
  ca_size_t i;
147
147
  Data_Get_Struct(self, CArray, ca);
148
- if ( level == ca->rank - 1 ) {
148
+ if ( level == ca->ndim - 1 ) {
149
149
  for (i=0; i<ca->dim[level]; i++) {
150
150
  rb_ary_store(ridx, level, SIZE2NUM(i));
151
151
  ret = rb_yield_splat(rb_obj_clone(ridx));
@@ -179,8 +179,8 @@ static VALUE
179
179
  rb_ca_each_index (VALUE self)
180
180
  {
181
181
  volatile VALUE ridx;
182
- int8_t rank = NUM2INT(rb_ca_rank(self));
183
- ridx = rb_ary_new2(rank);
182
+ int8_t ndim = NUM2INT(rb_ca_ndim(self));
183
+ ridx = rb_ary_new2(ndim);
184
184
  #if RUBY_VERSION_CODE >= 190
185
185
  RETURN_ENUMERATOR(self, 0, 0);
186
186
  #endif
@@ -225,7 +225,7 @@ rb_ca_each_with_index_internal (VALUE self,
225
225
  CArray *ca;
226
226
  ca_size_t i;
227
227
  Data_Get_Struct(self, CArray, ca);
228
- if ( level == ca->rank - 1 ) {
228
+ if ( level == ca->ndim - 1 ) {
229
229
  for (i=0; i<ca->dim[level]; i++) {
230
230
  idx[level] = i;
231
231
  rb_ary_store(ridx, level, SIZE2NUM(i));
@@ -256,12 +256,12 @@ rb_ca_each_with_index (VALUE self)
256
256
  {
257
257
  volatile VALUE ridx, ret;
258
258
  ca_size_t idx[CA_RANK_MAX];
259
- int8_t rank = NUM2INT(rb_ca_rank(self));
259
+ int8_t ndim = NUM2INT(rb_ca_ndim(self));
260
260
  #if RUBY_VERSION_CODE >= 190
261
261
  RETURN_ENUMERATOR(self, 0, 0);
262
262
  #endif
263
263
  rb_ca_modify(self);
264
- ridx = rb_ary_new2(rank);
264
+ ridx = rb_ary_new2(ndim);
265
265
  ret = rb_ca_each_with_index_internal(self, 0, idx, ridx);
266
266
  return ret;
267
267
  }
@@ -274,7 +274,7 @@ rb_ca_map_with_index_bang_internal (VALUE self,
274
274
  CArray *ca;
275
275
  ca_size_t i;
276
276
  Data_Get_Struct(self, CArray, ca);
277
- if ( level == ca->rank - 1 ) {
277
+ if ( level == ca->ndim - 1 ) {
278
278
  volatile VALUE obj;
279
279
  for (i=0; i<ca->dim[level]; i++) {
280
280
  idx[level] = i;
@@ -307,14 +307,14 @@ rb_ca_map_with_index_bang (VALUE self)
307
307
  volatile VALUE ridx;
308
308
  CArray *ca;
309
309
  ca_size_t idx[CA_RANK_MAX];
310
- int8_t rank = NUM2INT(rb_ca_rank(self));
310
+ int8_t ndim = NUM2INT(rb_ca_ndim(self));
311
311
  #if RUBY_VERSION_CODE >= 190
312
312
  RETURN_ENUMERATOR(self, 0, 0);
313
313
  #endif
314
314
  rb_ca_modify(self);
315
315
  Data_Get_Struct(self, CArray, ca);
316
316
  ca_attach(ca);
317
- ridx = rb_ary_new2(rank);
317
+ ridx = rb_ary_new2(ndim);
318
318
  rb_ca_map_with_index_bang_internal(self, 0, idx, ridx);
319
319
  ca_sync(ca);
320
320
  ca_detach(ca);
@@ -329,7 +329,7 @@ rb_ca_map_index_bang_internal (VALUE self,
329
329
  CArray *ca;
330
330
  ca_size_t i;
331
331
  Data_Get_Struct(self, CArray, ca);
332
- if ( level == ca->rank - 1 ) {
332
+ if ( level == ca->ndim - 1 ) {
333
333
  volatile VALUE obj;
334
334
  for (i=0; i<ca->dim[level]; i++) {
335
335
  idx[level] = i;
@@ -361,14 +361,14 @@ rb_ca_map_index_bang (VALUE self)
361
361
  volatile VALUE ridx;
362
362
  CArray *ca;
363
363
  ca_size_t idx[CA_RANK_MAX];
364
- int8_t rank = NUM2INT(rb_ca_rank(self));
364
+ int8_t ndim = NUM2INT(rb_ca_ndim(self));
365
365
  #if RUBY_VERSION_CODE >= 190
366
366
  RETURN_ENUMERATOR(self, 0, 0);
367
367
  #endif
368
368
  rb_ca_modify(self);
369
369
  Data_Get_Struct(self, CArray, ca);
370
370
  ca_attach(ca);
371
- ridx = rb_ary_new2(rank);
371
+ ridx = rb_ary_new2(ndim);
372
372
  rb_ca_map_index_bang_internal(self, 0, idx, ridx);
373
373
  ca_sync(ca);
374
374
  ca_detach(ca);
@@ -668,7 +668,7 @@ rb_ca_value_array (VALUE self)
668
668
 
669
669
  Data_Get_Struct(self, CArray, ca);
670
670
 
671
- obj = rb_ca_refer_new(self, ca->data_type, ca->rank, ca->dim, ca->bytes, 0);
671
+ obj = rb_ca_refer_new(self, ca->data_type, ca->ndim, ca->dim, ca->bytes, 0);
672
672
  Data_Get_Struct(obj, CArray, co);
673
673
 
674
674
  ca_set_flag(co, CA_FLAG_VALUE_ARRAY);
@@ -777,7 +777,7 @@ rb_ca_is_masked (VALUE self)
777
777
 
778
778
  Data_Get_Struct(self, CArray, ca);
779
779
 
780
- co = carray_new(CA_BOOLEAN, ca->rank, ca->dim, ca->bytes, NULL);
780
+ co = carray_new(CA_BOOLEAN, ca->ndim, ca->dim, ca->bytes, NULL);
781
781
 
782
782
  ca_update_mask(ca);
783
783
  if ( ! ca->mask ) {
@@ -820,7 +820,7 @@ rb_ca_is_not_masked (VALUE self)
820
820
 
821
821
  Data_Get_Struct(self, CArray, ca);
822
822
 
823
- co = carray_new(CA_BOOLEAN, ca->rank, ca->dim, ca->bytes, NULL);
823
+ co = carray_new(CA_BOOLEAN, ca->ndim, ca->dim, ca->bytes, NULL);
824
824
 
825
825
  ca_update_mask(ca);
826
826
  if ( ! ca->mask ) {
@@ -874,6 +874,17 @@ rb_ca_count_not_masked (VALUE self)
874
874
  return SIZE2NUM(ca_count_not_masked(ca));
875
875
  }
876
876
 
877
+ /* rdoc:
878
+ class CArray
879
+ # Unmask all elements of the object.
880
+ # If the optional argument <code>fill_value</code> is given,
881
+ # the masked elements are filled by <code>fill_value</code>.
882
+ # The returned array doesn't have the mask array.
883
+ def unmask (fill_value=nil)
884
+ end
885
+ end
886
+ */
887
+
877
888
  static VALUE
878
889
  rb_ca_unmask_method (int argc, VALUE *argv, VALUE self)
879
890
  {
@@ -1168,9 +1179,9 @@ Init_carray_mask ()
1168
1179
  rb_define_method(rb_cCArray, "inherit_mask_replace",
1169
1180
  rb_ca_inherit_mask_replace_method, -1);
1170
1181
 
1171
- /* These methods go to lib/carray/base.rb. */
1172
- /* rb_define_method(rb_cCArray, "count_masked", rb_ca_count_masked, 0); */
1173
- /* rb_define_method(rb_cCArray, "count_not_masked", rb_ca_count_not_masked, 0); */
1182
+ /* These methods go to lib/carray/mask.rb. */
1183
+ /* def count_masked (*axis); end */
1184
+ /* def count_not_masked (*axis); end */
1174
1185
 
1175
1186
  }
1176
1187
 
@@ -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
  /* ---------------------------------------------------------------------------
@@ -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;
@@ -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;
@@ -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;
@@ -197,13 +197,13 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
197
197
  /* unresolved unbound repeat array generates unbound repeat array again */
198
198
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
199
199
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
200
- 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);
201
201
  }
202
202
 
203
203
  /* unresolved unbound repeat array generates unbound repeat array again */
204
204
  if ( ca2->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
205
205
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca2;
206
- 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);
207
207
  }
208
208
 
209
209
  return out;
@@ -287,7 +287,7 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
287
287
  out = rb_cscalar_new(CA_BOOLEAN, 0, NULL);
288
288
  }
289
289
  else {
290
- 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);
291
291
  }
292
292
 
293
293
  Data_Get_Struct(out, CArray, ca2);
@@ -302,7 +302,7 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
302
302
  /* unresolved unbound repeat array generates unbound repeat array again */
303
303
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
304
304
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
305
- 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);
306
306
  }
307
307
 
308
308
  return out;
@@ -353,7 +353,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
353
353
  ca3->ptr, ca3->bytes, 0);
354
354
  }
355
355
  else { /* scalar vs array */
356
- 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);
357
357
  Data_Get_Struct(out, CArray, ca3);
358
358
 
359
359
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
@@ -365,7 +365,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
365
365
  }
366
366
  else {
367
367
  if ( rb_obj_is_cscalar(other) ) { /* array vs scalar */
368
- 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);
369
369
  Data_Get_Struct(out, CArray, ca3);
370
370
 
371
371
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
@@ -379,7 +379,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
379
379
  rb_raise(rb_eRuntimeError, "elements mismatch in bincmp (%lld <-> %lld)",
380
380
  (ca_size_t) ca1->elements, (ca_size_t) ca2->elements);
381
381
  }
382
- 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);
383
383
  Data_Get_Struct(out, CArray, ca3);
384
384
 
385
385
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
@@ -395,7 +395,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
395
395
  /* unresolved unbound repeat array generates unbound repeat array again */
396
396
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
397
397
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
398
- 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);
399
399
  }
400
400
 
401
401
  return out;