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
@@ -380,11 +380,11 @@ rb_ary_flatten_for_elements (VALUE ary, ca_size_t elements, void *ap)
380
380
  }
381
381
  else {
382
382
  same_shape = 1;
383
- if ( max_level+1 < ca->rank ) {
383
+ if ( max_level+1 < ca->ndim ) {
384
384
  same_shape = 0;
385
385
  }
386
386
  else {
387
- for (i=0; i<ca->rank; i++) {
387
+ for (i=0; i<ca->ndim; i++) {
388
388
  if ( ca->dim[i] != dim[i] ) {
389
389
  same_shape = 0;
390
390
  break;
@@ -395,7 +395,7 @@ rb_ary_flatten_for_elements (VALUE ary, ca_size_t elements, void *ap)
395
395
  if ( same_shape ) {
396
396
  VALUE out = rb_ary_new2(0);
397
397
  int len = 0;
398
- ary_flatten_upto_level(ary, ca->rank-1, 0, out, &len);
398
+ ary_flatten_upto_level(ary, ca->ndim-1, 0, out, &len);
399
399
 
400
400
  if ( len != elements ) {
401
401
  return Qnil;
@@ -443,12 +443,12 @@ rb_ary_flatten_for_elements (VALUE ary, ca_size_t elements, void *ap)
443
443
  }
444
444
 
445
445
  void
446
- rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
446
+ rb_ca_scan_index (int ca_ndim, ca_size_t *ca_dim, ca_size_t ca_elements,
447
447
  long argc, VALUE *argv, CAIndexInfo *info)
448
448
  {
449
449
  int32_t i;
450
450
 
451
- info->rank = 0;
451
+ info->ndim = 0;
452
452
  info->select = NULL;
453
453
 
454
454
  if ( argc == 0 ) { /* ca[] -> CA_REG_ALL */
@@ -481,7 +481,7 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
481
481
  Data_Get_Struct(arg, CArray, cs);
482
482
  if ( ca_is_integer_type(cs) ) {
483
483
  #if 0
484
- if ( ca_rank == 1 && cs->rank == 1 ) { /* ca[g] -> CA_REG_GRID (1d) */
484
+ if ( ca_ndim == 1 && cs->ndim == 1 ) { /* ca[g] -> CA_REG_GRID (1d) */
485
485
  info->type = CA_REG_GRID;
486
486
  }
487
487
  else { /* ca[m] -> CA_REG_MAPPER (2d...) */
@@ -527,11 +527,11 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
527
527
  return;
528
528
  }
529
529
 
530
- if ( ca_rank > 1 ) { /* ca.rank > 1 */
530
+ if ( ca_ndim > 1 ) { /* ca.ndim > 1 */
531
531
  if ( rb_obj_is_kind_of(arg, rb_cInteger) ) { /* ca[n] -> CA_REG_ADDRESS */
532
532
  ca_size_t addr;
533
533
  info->type = CA_REG_ADDRESS;
534
- info->rank = 1;
534
+ info->ndim = 1;
535
535
  addr = NUM2SIZE(arg);
536
536
  CA_CHECK_INDEX(addr, ca_elements);
537
537
  info->index[0].scalar = addr;
@@ -569,21 +569,21 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
569
569
 
570
570
  if ( argv[i] == Qfalse ) { /* ca[--,false,--] (rubber dimension) */
571
571
  has_rubber = 1;
572
- if ( argc > ca_rank + 1 ) {
572
+ if ( argc > ca_ndim + 1 ) {
573
573
  rb_raise(rb_eIndexError,
574
- "index specification exceeds the rank of carray (%i)",
575
- ca_rank);
574
+ "index specification exceeds the ndim of carray (%i)",
575
+ ca_ndim);
576
576
  }
577
577
  }
578
578
  }
579
579
 
580
- if ( ! has_rubber && ca_rank != argc ) {
580
+ if ( ! has_rubber && ca_ndim != argc ) {
581
581
  rb_raise(rb_eIndexError,
582
- "number of indices exceeds the rank of carray (%i > %i)",
583
- (int) argc, ca_rank);
582
+ "number of indices exceeds the ndim of carray (%i > %i)",
583
+ (int) argc, ca_ndim);
584
584
  }
585
585
 
586
- info->rank = argc;
586
+ info->ndim = argc;
587
587
 
588
588
  for (i=0; i<argc; i++) {
589
589
  volatile VALUE arg = argv[i];
@@ -601,15 +601,15 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
601
601
  index_type[i] = CA_IDX_ALL;
602
602
  }
603
603
  else if ( arg == Qfalse ) { /* ca[--,false,--] */
604
- int8_t rrank = ca_rank - argc + 1;
604
+ int8_t rndim = ca_ndim - argc + 1;
605
605
  int8_t j;
606
- for (j=0; j<rrank; j++) {
606
+ for (j=0; j<rndim; j++) {
607
607
  index_type[i+j] = CA_IDX_ALL;
608
608
  }
609
- i += rrank-1;
610
- argv -= rrank-1;
611
- argc = ca_rank;
612
- info->rank = ca_rank;
609
+ i += rndim-1;
610
+ argv -= rndim-1;
611
+ argc = ca_ndim;
612
+ info->ndim = ca_ndim;
613
613
  }
614
614
  else if ( rb_obj_is_kind_of(arg, rb_cRange) ) { /* ca[--,i..j,--] */
615
615
  ca_size_t first, last, excl, count, step;
@@ -827,10 +827,10 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
827
827
  }
828
828
  }
829
829
 
830
- if ( ca_rank != info->rank ) {
830
+ if ( ca_ndim != info->ndim ) {
831
831
  rb_raise(rb_eIndexError,
832
- "number of indices does not equal to the rank (%i != %i)",
833
- info->rank, ca_rank);
832
+ "number of indices does not equal to the ndim (%i != %i)",
833
+ info->ndim, ca_ndim);
834
834
  }
835
835
 
836
836
  is_point = 1;
@@ -838,7 +838,7 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
838
838
  is_iterator = 0;
839
839
  is_grid = 0;
840
840
 
841
- for (i=0; i<info->rank; i++) {
841
+ for (i=0; i<info->ndim; i++) {
842
842
  switch ( info->index_type[i] ) {
843
843
  case CA_IDX_SCALAR:
844
844
  is_all = 0;
@@ -880,7 +880,7 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
880
880
  }
881
881
 
882
882
  if ( info->type == CA_REG_ITERATOR ) {
883
- for (i=0; i<info->rank; i++) {
883
+ for (i=0; i<info->ndim; i++) {
884
884
  if ( info->index_type[i] == CA_IDX_SCALAR ) {
885
885
  ca_size_t start = info->index[i].scalar;
886
886
  info->index_type[i] = CA_IDX_BLOCK;
@@ -928,7 +928,7 @@ rb_ca_ref_point (VALUE self, CAIndexInfo *info)
928
928
  ca_size_t idx[CA_RANK_MAX];
929
929
  int8_t i;
930
930
  Data_Get_Struct(self, CArray, ca);
931
- for (i=0; i<ca->rank; i++) {
931
+ for (i=0; i<ca->ndim; i++) {
932
932
  idx[i] = info->index[i].scalar;
933
933
  }
934
934
  return rb_ca_fetch_index(self, idx);
@@ -941,7 +941,7 @@ rb_ca_store_point (VALUE self, CAIndexInfo *info, volatile VALUE val)
941
941
  ca_size_t idx[CA_RANK_MAX];
942
942
  int8_t i;
943
943
  Data_Get_Struct(self, CArray, ca);
944
- for (i=0; i<ca->rank; i++) {
944
+ for (i=0; i<ca->ndim; i++) {
945
945
  idx[i] = info->index[i].scalar;
946
946
  }
947
947
  if ( rb_obj_is_cscalar(val) ) {
@@ -1071,7 +1071,7 @@ rb_ca_store_all (VALUE self, VALUE rval)
1071
1071
  }
1072
1072
 
1073
1073
  static void
1074
- rb_ca_index_restruct_block (int16_t *rankp, ca_size_t *shrink, ca_size_t *dim,
1074
+ rb_ca_index_restruct_block (int16_t *ndimp, ca_size_t *shrink, ca_size_t *dim,
1075
1075
  ca_size_t *start, ca_size_t *step, ca_size_t *count,
1076
1076
  ca_size_t *offsetp)
1077
1077
  {
@@ -1080,31 +1080,31 @@ rb_ca_index_restruct_block (int16_t *rankp, ca_size_t *shrink, ca_size_t *dim,
1080
1080
  ca_size_t step0[CA_RANK_MAX];
1081
1081
  ca_size_t count0[CA_RANK_MAX];
1082
1082
  ca_size_t idx[CA_RANK_MAX];
1083
- int16_t rank0, rank;
1083
+ int16_t ndim0, ndim;
1084
1084
  ca_size_t offset0, offset, length;
1085
1085
  ca_size_t k, n;
1086
1086
  ca_size_t i, j, m;
1087
1087
 
1088
- rank0 = *rankp;
1088
+ ndim0 = *ndimp;
1089
1089
  offset0 = *offsetp;
1090
1090
 
1091
1091
  /* store original start, step, count to start0, step0, count0 */
1092
- memcpy(dim0, dim, sizeof(ca_size_t) * rank0);
1093
- memcpy(start0, start, sizeof(ca_size_t) * rank0);
1094
- memcpy(step0, step, sizeof(ca_size_t) * rank0);
1095
- memcpy(count0, count, sizeof(ca_size_t) * rank0);
1092
+ memcpy(dim0, dim, sizeof(ca_size_t) * ndim0);
1093
+ memcpy(start0, start, sizeof(ca_size_t) * ndim0);
1094
+ memcpy(step0, step, sizeof(ca_size_t) * ndim0);
1095
+ memcpy(count0, count, sizeof(ca_size_t) * ndim0);
1096
1096
 
1097
- /* classify and calc rank */
1097
+ /* classify and calc ndim */
1098
1098
  n = -1;
1099
- for (i=0; i<rank0; i++) {
1099
+ for (i=0; i<ndim0; i++) {
1100
1100
  if ( ! shrink[i] ) {
1101
1101
  n += 1;
1102
1102
  }
1103
1103
  idx[i] = n;
1104
1104
  }
1105
- rank = n + 1;
1105
+ ndim = n + 1;
1106
1106
 
1107
- *rankp = rank;
1107
+ *ndimp = ndim;
1108
1108
 
1109
1109
  /* calc offset */
1110
1110
 
@@ -1122,7 +1122,7 @@ rb_ca_index_restruct_block (int16_t *rankp, ca_size_t *shrink, ca_size_t *dim,
1122
1122
  }
1123
1123
 
1124
1124
  length = 1;
1125
- for (i=j; i<rank0; i++) {
1125
+ for (i=j; i<ndim0; i++) {
1126
1126
  length *= dim0[i];
1127
1127
  }
1128
1128
 
@@ -1133,13 +1133,13 @@ rb_ca_index_restruct_block (int16_t *rankp, ca_size_t *shrink, ca_size_t *dim,
1133
1133
 
1134
1134
  /* calc dim, start, step, count */
1135
1135
 
1136
- for (i=0; i<rank0; i++) {
1136
+ for (i=0; i<ndim0; i++) {
1137
1137
  n = idx[i];
1138
1138
  if ( n == -1) {
1139
1139
  continue;
1140
1140
  }
1141
1141
 
1142
- for (j=i+1, m=i; j<rank0 && (idx[j] == n); j++) {
1142
+ for (j=i+1, m=i; j<ndim0 && (idx[j] == n); j++) {
1143
1143
  ;
1144
1144
  }
1145
1145
 
@@ -1172,7 +1172,7 @@ rb_ca_ref_block (VALUE self, CAIndexInfo *info)
1172
1172
  ca_size_t step[CA_RANK_MAX];
1173
1173
  ca_size_t count[CA_RANK_MAX];
1174
1174
  ca_size_t shrink[CA_RANK_MAX];
1175
- int16_t rank = 0;
1175
+ int16_t ndim = 0;
1176
1176
  ca_size_t offset = 0;
1177
1177
  ca_size_t flag = 0;
1178
1178
  ca_size_t elements;
@@ -1180,10 +1180,10 @@ rb_ca_ref_block (VALUE self, CAIndexInfo *info)
1180
1180
 
1181
1181
  Data_Get_Struct(self, CArray, ca);
1182
1182
 
1183
- rank = info->rank;
1183
+ ndim = info->ndim;
1184
1184
 
1185
1185
  elements = 1;
1186
- for (i=0; i<info->rank; i++) {
1186
+ for (i=0; i<info->ndim; i++) {
1187
1187
  dim[i] = ca->dim[i];
1188
1188
  switch ( info->index_type[i] ) {
1189
1189
  case CA_IDX_SCALAR:
@@ -1200,7 +1200,7 @@ rb_ca_ref_block (VALUE self, CAIndexInfo *info)
1200
1200
  }
1201
1201
  }
1202
1202
 
1203
- for (i=0; i<info->rank; i++) {
1203
+ for (i=0; i<info->ndim; i++) {
1204
1204
  switch ( info->index_type[i] ) {
1205
1205
  case CA_IDX_SCALAR:
1206
1206
  start[i] = info->index[i].scalar;
@@ -1223,7 +1223,7 @@ rb_ca_ref_block (VALUE self, CAIndexInfo *info)
1223
1223
  }
1224
1224
  }
1225
1225
 
1226
- for (i=0; i<rank; i++) {
1226
+ for (i=0; i<ndim; i++) {
1227
1227
  if ( shrink[i] ) {
1228
1228
  flag = 1;
1229
1229
  break;
@@ -1231,16 +1231,16 @@ rb_ca_ref_block (VALUE self, CAIndexInfo *info)
1231
1231
  }
1232
1232
 
1233
1233
  refer = self;
1234
- rank = ca->rank;
1234
+ ndim = ca->ndim;
1235
1235
 
1236
1236
  offset = 0;
1237
1237
 
1238
1238
  if ( flag ) {
1239
- rb_ca_index_restruct_block(&rank, shrink,
1239
+ rb_ca_index_restruct_block(&ndim, shrink,
1240
1240
  dim, start, step, count, &offset);
1241
1241
  }
1242
1242
 
1243
- return rb_ca_block_new(refer, rank, dim, start, step, count, offset);
1243
+ return rb_ca_block_new(refer, ndim, dim, start, step, count, offset);
1244
1244
  }
1245
1245
 
1246
1246
  static VALUE
@@ -1271,7 +1271,7 @@ rb_ca_fetch_method (int argc, VALUE *argv, VALUE self)
1271
1271
  retry:
1272
1272
 
1273
1273
  Data_Get_Struct(self, CArray, ca);
1274
- rb_ca_scan_index(ca->rank, ca->dim, ca->elements, argc, argv, &info);
1274
+ rb_ca_scan_index(ca->ndim, ca->dim, ca->elements, argc, argv, &info);
1275
1275
 
1276
1276
  switch ( info.type ) {
1277
1277
  case CA_REG_ADDRESS_COMPLEX:
@@ -1363,7 +1363,7 @@ rb_ca_store_method (int argc, VALUE *argv, VALUE self)
1363
1363
 
1364
1364
  Data_Get_Struct(self, CArray, ca);
1365
1365
 
1366
- rb_ca_scan_index(ca->rank, ca->dim, ca->elements, argc, argv, &info);
1366
+ rb_ca_scan_index(ca->ndim, ca->dim, ca->elements, argc, argv, &info);
1367
1367
 
1368
1368
  switch ( info.type ) {
1369
1369
  case CA_REG_ADDRESS_COMPLEX:
@@ -1495,9 +1495,9 @@ rb_ca_store2 (VALUE self, int n, VALUE *rindex, VALUE rval)
1495
1495
  static VALUE
1496
1496
  rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
1497
1497
  {
1498
- volatile VALUE rtype, rrank, rindex;
1498
+ volatile VALUE rtype, rndim, rindex;
1499
1499
  CAIndexInfo info;
1500
- int rank;
1500
+ int ndim;
1501
1501
  ca_size_t dim[CA_RANK_MAX];
1502
1502
  ca_size_t elements;
1503
1503
  int i;
@@ -1506,21 +1506,21 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
1506
1506
  Check_Type(ridx, T_ARRAY);
1507
1507
 
1508
1508
  elements = 1;
1509
- rank = (int) RARRAY_LEN(rdim);
1510
- for (i=0; i<rank; i++) {
1509
+ ndim = (int) RARRAY_LEN(rdim);
1510
+ for (i=0; i<ndim; i++) {
1511
1511
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
1512
1512
  elements *= dim[i];
1513
1513
  }
1514
1514
 
1515
- CA_CHECK_RANK(rank);
1516
- CA_CHECK_DIM(rank, dim);
1515
+ CA_CHECK_RANK(ndim);
1516
+ CA_CHECK_DIM(ndim, dim);
1517
1517
 
1518
- rb_ca_scan_index(rank, dim, elements,
1518
+ rb_ca_scan_index(ndim, dim, elements,
1519
1519
  RARRAY_LEN(ridx), RARRAY_PTR(ridx), &info);
1520
1520
 
1521
1521
  rtype = INT2NUM(info.type);
1522
- rrank = INT2NUM(info.rank);
1523
- rindex = rb_ary_new2(info.rank);
1522
+ rndim = INT2NUM(info.ndim);
1523
+ rindex = rb_ary_new2(info.ndim);
1524
1524
 
1525
1525
  switch ( info.type ) {
1526
1526
  case CA_REG_NONE:
@@ -1534,7 +1534,7 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
1534
1534
  case CA_REG_ADDRESS_COMPLEX: {
1535
1535
  volatile VALUE rinfo;
1536
1536
  ca_size_t elements = 1;
1537
- for (i=0; i<rank; i++) {
1537
+ for (i=0; i<ndim; i++) {
1538
1538
  elements *= dim[i];
1539
1539
  }
1540
1540
  rinfo = rb_ca_s_scan_index(self, rb_ary_new3(1, SIZE2NUM(elements)), ridx);
@@ -1543,7 +1543,7 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
1543
1543
  break;
1544
1544
  }
1545
1545
  case CA_REG_POINT:
1546
- for (i=0; i<rank; i++) {
1546
+ for (i=0; i<ndim; i++) {
1547
1547
  rb_ary_store(rindex, i, SIZE2NUM(info.index[i].scalar));
1548
1548
  }
1549
1549
  break;
@@ -1551,7 +1551,7 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
1551
1551
  break;
1552
1552
  case CA_REG_BLOCK:
1553
1553
  case CA_REG_ITERATOR:
1554
- for (i=0; i<rank; i++) {
1554
+ for (i=0; i<ndim; i++) {
1555
1555
  switch ( info.index_type[i] ) {
1556
1556
  case CA_IDX_SCALAR:
1557
1557
  rb_ary_store(rindex, i, SIZE2NUM(info.index[i].scalar));
@@ -1614,26 +1614,26 @@ rb_ca_normalize_index (VALUE self, VALUE ridx)
1614
1614
  Data_Get_Struct(self, CArray, ca);
1615
1615
  Check_Type(ridx, T_ARRAY);
1616
1616
 
1617
- rb_ca_scan_index(ca->rank, ca->dim, ca->elements,
1617
+ rb_ca_scan_index(ca->ndim, ca->dim, ca->elements,
1618
1618
  RARRAY_LEN(ridx), RARRAY_PTR(ridx), &info);
1619
1619
 
1620
1620
  switch ( info.type ) {
1621
1621
  case CA_REG_ALL:
1622
1622
  case CA_REG_SELECT:
1623
1623
  case CA_REG_ADDRESS:
1624
- rindex = rb_ary_new2(info.rank);
1624
+ rindex = rb_ary_new2(info.ndim);
1625
1625
  rb_ary_store(rindex, 0, SIZE2NUM(info.index[0].scalar));
1626
1626
  return rindex;
1627
1627
  case CA_REG_POINT:
1628
- rindex = rb_ary_new2(info.rank);
1629
- for (i=0; i<ca->rank; i++) {
1628
+ rindex = rb_ary_new2(info.ndim);
1629
+ for (i=0; i<ca->ndim; i++) {
1630
1630
  rb_ary_store(rindex, i, SIZE2NUM(info.index[i].scalar));
1631
1631
  }
1632
1632
  return rindex;
1633
1633
  case CA_REG_BLOCK:
1634
1634
  case CA_REG_ITERATOR:
1635
- rindex = rb_ary_new2(info.rank);
1636
- for (i=0; i<ca->rank; i++) {
1635
+ rindex = rb_ary_new2(info.ndim);
1636
+ for (i=0; i<ca->ndim; i++) {
1637
1637
  switch ( info.index_type[i] ) {
1638
1638
  case CA_IDX_SCALAR:
1639
1639
  rb_ary_store(rindex, i, SIZE2NUM(info.index[i].scalar));
@@ -1694,8 +1694,8 @@ rb_ca_addr2index (VALUE self, VALUE raddr)
1694
1694
  (ca_size_t) addr, (ca_size_t) (ca->elements-1));
1695
1695
  }
1696
1696
  dim = ca->dim;
1697
- out = rb_ary_new2(ca->rank);
1698
- for (i=ca->rank-1; i>=0; i--) { /* in descending order */
1697
+ out = rb_ary_new2(ca->ndim);
1698
+ for (i=ca->ndim-1; i>=0; i--) { /* in descending order */
1699
1699
  rb_ary_store(out, i, SIZE2NUM(addr % dim[i]));
1700
1700
  addr /= dim[i];
1701
1701
  }
@@ -1725,11 +1725,11 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1725
1725
 
1726
1726
  Data_Get_Struct(self, CArray, ca);
1727
1727
 
1728
- if ( argc != ca->rank ) {
1729
- rb_raise(rb_eRuntimeError, "invalid rank of index");
1728
+ if ( argc != ca->ndim ) {
1729
+ rb_raise(rb_eRuntimeError, "invalid ndim of index");
1730
1730
  }
1731
1731
 
1732
- for (i=0; i<ca->rank; i++) {
1732
+ for (i=0; i<ca->ndim; i++) {
1733
1733
  if ( ! rb_obj_is_kind_of(argv[i], rb_cInteger) ) {
1734
1734
  all_number = 0;
1735
1735
  break;
@@ -1739,7 +1739,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1739
1739
  if ( all_number ) {
1740
1740
  dim = ca->dim;
1741
1741
  addr = 0;
1742
- for (i=0; i<ca->rank; i++) {
1742
+ for (i=0; i<ca->ndim; i++) {
1743
1743
  k = NUM2SIZE(argv[i]);
1744
1744
  CA_CHECK_INDEX(k, dim[i]);
1745
1745
  addr = dim[i] * addr + k;
@@ -1748,7 +1748,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1748
1748
  }
1749
1749
 
1750
1750
  elements = 1;
1751
- for (i=0; i<ca->rank; i++) {
1751
+ for (i=0; i<ca->ndim; i++) {
1752
1752
  cidx[i] = ca_wrap_readonly(argv[i], CA_SIZE);
1753
1753
  if ( ! ca_is_scalar(cidx[i]) ) {
1754
1754
  if ( elements == 1 ) {
@@ -1760,7 +1760,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1760
1760
  }
1761
1761
  }
1762
1762
 
1763
- for (i=0; i<ca->rank; i++) {
1763
+ for (i=0; i<ca->ndim; i++) {
1764
1764
  ca_attach(cidx[i]);
1765
1765
  ca_set_iterator(1, cidx[i], &p[i], &s[i]);
1766
1766
  }
@@ -1770,7 +1770,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1770
1770
 
1771
1771
  q = (ca_size_t *) co->ptr;
1772
1772
 
1773
- ca_copy_mask_overwrite_n(co, elements, ca->rank, cidx);
1773
+ ca_copy_mask_overwrite_n(co, elements, ca->ndim, cidx);
1774
1774
  m = ( co->mask ) ? (boolean8_t *) co->mask->ptr : NULL;
1775
1775
 
1776
1776
  dim = ca->dim;
@@ -1780,7 +1780,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1780
1780
  while ( n-- ) {
1781
1781
  if ( !*m ) {
1782
1782
  addr = 0;
1783
- for (i=0; i<ca->rank; i++) {
1783
+ for (i=0; i<ca->ndim; i++) {
1784
1784
  k = *(p[i]);
1785
1785
  p[i]+=s[i];
1786
1786
  CA_CHECK_INDEX(k, dim[i]);
@@ -1789,7 +1789,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1789
1789
  *q = addr;
1790
1790
  }
1791
1791
  else {
1792
- for (i=0; i<ca->rank; i++) {
1792
+ for (i=0; i<ca->ndim; i++) {
1793
1793
  p[i]+=s[i];
1794
1794
  }
1795
1795
  }
@@ -1800,7 +1800,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1800
1800
  n = elements;
1801
1801
  while ( n-- ) {
1802
1802
  addr = 0;
1803
- for (i=0; i<ca->rank; i++) {
1803
+ for (i=0; i<ca->ndim; i++) {
1804
1804
  k = *(p[i]);
1805
1805
  p[i]+=s[i];
1806
1806
  CA_CHECK_INDEX(k, dim[i]);
@@ -1811,7 +1811,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1811
1811
  }
1812
1812
  }
1813
1813
 
1814
- for (i=0; i<ca->rank; i++) {
1814
+ for (i=0; i<ca->ndim; i++) {
1815
1815
  ca_detach(cidx[i]);
1816
1816
  }
1817
1817