carray 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/ca_iter_block.c +32 -30
  4. data/ca_iter_dimension.c +24 -22
  5. data/ca_iter_window.c +25 -23
  6. data/ca_obj_array.c +58 -56
  7. data/ca_obj_bitarray.c +27 -27
  8. data/ca_obj_bitfield.c +46 -45
  9. data/ca_obj_block.c +77 -72
  10. data/ca_obj_fake.c +20 -20
  11. data/ca_obj_farray.c +22 -22
  12. data/ca_obj_field.c +31 -30
  13. data/ca_obj_grid.c +63 -62
  14. data/ca_obj_mapping.c +35 -32
  15. data/ca_obj_object.c +54 -54
  16. data/ca_obj_reduce.c +13 -13
  17. data/ca_obj_refer.c +42 -39
  18. data/ca_obj_repeat.c +50 -47
  19. data/ca_obj_select.c +24 -24
  20. data/ca_obj_shift.c +61 -58
  21. data/ca_obj_transpose.c +52 -51
  22. data/ca_obj_unbound_repeat.c +28 -27
  23. data/ca_obj_window.c +77 -72
  24. data/carray.gemspec +0 -2
  25. data/carray.h +190 -163
  26. data/carray_access.c +137 -136
  27. data/carray_attribute.c +24 -13
  28. data/carray_call_cfunc.c +21 -21
  29. data/carray_cast.c +106 -110
  30. data/carray_cast_func.rb +17 -17
  31. data/carray_class.c +3 -3
  32. data/carray_conversion.c +15 -15
  33. data/carray_copy.c +27 -27
  34. data/carray_core.c +22 -21
  35. data/carray_element.c +55 -47
  36. data/carray_generate.c +32 -32
  37. data/carray_iterator.c +36 -35
  38. data/carray_loop.c +37 -37
  39. data/carray_mask.c +21 -21
  40. data/carray_math.rb +18 -18
  41. data/carray_numeric.c +1 -1
  42. data/carray_operator.c +19 -18
  43. data/carray_order.c +30 -30
  44. data/carray_random.c +34 -32
  45. data/carray_sort_addr.c +12 -12
  46. data/carray_stat.c +127 -127
  47. data/carray_stat_proc.rb +152 -141
  48. data/carray_test.c +16 -16
  49. data/carray_utils.c +58 -56
  50. data/ext/calculus/carray_calculus.c +19 -20
  51. data/ext/calculus/carray_interp.c +12 -11
  52. data/ext/fortio/lib/fortio/fortran_sequential.rb +2 -2
  53. data/ext/fortio/ruby_fortio.c +1 -1
  54. data/ext/imagemap/carray_imagemap.c +14 -14
  55. data/ext/narray/ca_wrap_narray.c +30 -21
  56. data/extconf.rb +5 -0
  57. data/lib/carray/base/basic.rb +4 -3
  58. data/lib/carray/base/serialize.rb +3 -3
  59. data/lib/carray/graphics/gnuplot.rb +10 -7
  60. data/lib/carray/io/csv.rb +14 -9
  61. data/lib/carray/io/imagemagick.rb +7 -0
  62. data/lib/carray/io/sqlite3.rb +6 -4
  63. data/mkmath.rb +20 -20
  64. data/ruby_carray.c +2 -0
  65. data/ruby_ccomplex.c +3 -3
  66. data/test/test_130.rb +23 -0
  67. data/test/test_ALL.rb +2 -1
  68. data/test/test_order.rb +3 -3
  69. data/test/test_stat.rb +2 -2
  70. data/version.h +4 -4
  71. metadata +4 -37
  72. data/examples/ex001.rb +0 -10
  73. data/examples/test-int.rb +0 -13
  74. data/lib/carray/autoload/autoload_io_excel.rb +0 -5
  75. data/lib/carray/io/excel.rb +0 -26
data/carray_access.c CHANGED
@@ -47,7 +47,7 @@ static VALUE sym_star, sym_perc;
47
47
  static VALUE S_CAInfo;
48
48
 
49
49
  VALUE
50
- rb_ca_store_index (VALUE self, int32_t *idx, VALUE rval)
50
+ rb_ca_store_index (VALUE self, ca_size_t *idx, VALUE rval)
51
51
  {
52
52
  CArray *ca;
53
53
  boolean8_t zero = 0, one = 1;
@@ -75,8 +75,8 @@ rb_ca_store_index (VALUE self, int32_t *idx, VALUE rval)
75
75
  }
76
76
 
77
77
  /* store value */
78
- if ( ca->bytes <= 32) {
79
- char v[32];
78
+ if ( ca->bytes <= 64) {
79
+ char v[64];
80
80
  rb_ca_obj2ptr(self, rval, v);
81
81
  ca_store_index(ca, idx, v);
82
82
  }
@@ -92,7 +92,7 @@ rb_ca_store_index (VALUE self, int32_t *idx, VALUE rval)
92
92
  }
93
93
 
94
94
  VALUE
95
- rb_ca_fetch_index (VALUE self, int32_t *idx)
95
+ rb_ca_fetch_index (VALUE self, ca_size_t *idx)
96
96
  {
97
97
  volatile VALUE out;
98
98
  CArray *ca;
@@ -103,8 +103,8 @@ rb_ca_fetch_index (VALUE self, int32_t *idx)
103
103
  }
104
104
 
105
105
  /* fetch value from the element */
106
- if ( ca->bytes <= 32) {
107
- char v[32];
106
+ if ( ca->bytes <= 64) {
107
+ char v[64];
108
108
  ca_fetch_index(ca, idx, v);
109
109
  out = rb_ca_ptr2obj(self, v);
110
110
  }
@@ -129,7 +129,7 @@ rb_ca_fetch_index (VALUE self, int32_t *idx)
129
129
  }
130
130
 
131
131
  VALUE
132
- rb_ca_store_addr (VALUE self, int32_t addr, VALUE rval)
132
+ rb_ca_store_addr (VALUE self, ca_size_t addr, VALUE rval)
133
133
  {
134
134
  CArray *ca;
135
135
  boolean8_t zero = 0, one = 1;
@@ -155,8 +155,8 @@ rb_ca_store_addr (VALUE self, int32_t addr, VALUE rval)
155
155
  }
156
156
 
157
157
  /* store value */
158
- if ( ca->bytes <= 32) {
159
- char v[32];
158
+ if ( ca->bytes <= 64) {
159
+ char v[64];
160
160
  rb_ca_obj2ptr(self, rval, v);
161
161
  ca_store_addr(ca, addr, v);
162
162
  }
@@ -172,7 +172,7 @@ rb_ca_store_addr (VALUE self, int32_t addr, VALUE rval)
172
172
  }
173
173
 
174
174
  VALUE
175
- rb_ca_fetch_addr (VALUE self, int32_t addr)
175
+ rb_ca_fetch_addr (VALUE self, ca_size_t addr)
176
176
  {
177
177
  volatile VALUE out;
178
178
  CArray *ca;
@@ -183,8 +183,8 @@ rb_ca_fetch_addr (VALUE self, int32_t addr)
183
183
  }
184
184
 
185
185
  /* fetch value from the element */
186
- if ( ca->bytes <= 32) {
187
- char v[32];
186
+ if ( ca->bytes <= 64) {
187
+ char v[64];
188
188
  ca_fetch_addr(ca, addr, v);
189
189
  out = rb_ca_ptr2obj(self, v);
190
190
  }
@@ -261,7 +261,7 @@ rb_ca_fill_copy (VALUE self, VALUE rval)
261
261
  /* -------------------------------------------------------------------- */
262
262
 
263
263
  static void
264
- ary_guess_shape (VALUE ary, int level, int *max_level, int32_t *dim)
264
+ ary_guess_shape (VALUE ary, int level, int *max_level, ca_size_t *dim)
265
265
  {
266
266
  volatile VALUE ary0;
267
267
  if ( level > CA_RANK_MAX ) {
@@ -278,8 +278,8 @@ ary_guess_shape (VALUE ary, int level, int *max_level, int32_t *dim)
278
278
  dim[level] = RARRAY_LEN(ary);
279
279
  ary0 = rb_ary_entry(ary, 0);
280
280
  if ( TYPE(ary0) == T_ARRAY ) {
281
- int32_t dim0 = RARRAY_LEN(ary0);
282
- int32_t i;
281
+ ca_size_t dim0 = RARRAY_LEN(ary0);
282
+ ca_size_t i;
283
283
  int flag = 0;
284
284
  for (i=0; i<dim[level]; i++) {
285
285
  VALUE x = rb_ary_entry(ary, i);
@@ -302,13 +302,13 @@ static VALUE
302
302
  rb_ca_s_guess_array_shape (VALUE self, VALUE ary)
303
303
  {
304
304
  volatile VALUE out;
305
- int32_t dim[CA_RANK_MAX];
305
+ ca_size_t dim[CA_RANK_MAX];
306
306
  int max_level = -1;
307
307
  int i;
308
308
  ary_guess_shape(ary, 0, &max_level, dim);
309
309
  out = rb_ary_new2(max_level);
310
310
  for (i=0; i<max_level+1; i++) {
311
- rb_ary_store(out, i, INT2NUM(dim[i]));
311
+ rb_ary_store(out, i, SIZE2NUM(dim[i]));
312
312
  }
313
313
  return out;
314
314
  }
@@ -338,11 +338,11 @@ ary_flatten_upto_level (VALUE ary, int max_level, int level,
338
338
  }
339
339
 
340
340
  static VALUE
341
- rb_ary_flatten_for_elements (VALUE ary, int32_t elements, void *ap)
341
+ rb_ary_flatten_for_elements (VALUE ary, ca_size_t elements, void *ap)
342
342
  {
343
343
  CArray *ca = (CArray *) ap;
344
- int32_t dim[CA_RANK_MAX];
345
- int32_t total;
344
+ ca_size_t dim[CA_RANK_MAX];
345
+ ca_size_t total;
346
346
  int max_level = -1, level = -1;
347
347
  int same_shape, is_object = ( ca_is_object_type(ca) );
348
348
  int i;
@@ -438,13 +438,13 @@ rb_ary_flatten_for_elements (VALUE ary, int32_t elements, void *ap)
438
438
  } \
439
439
  if ( index < 0 || index >= (dim) ) { \
440
440
  rb_raise(rb_eIndexError, \
441
- "index out of range at %i-dim ( %i <=> 0..%i )", \
442
- i, index, dim-1); \
441
+ "index out of range at %i-dim ( %lld <=> 0..%lld )", \
442
+ i, (ca_size_t) index, (ca_size_t) (dim-1)); \
443
443
  }
444
444
 
445
445
  void
446
- rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
447
- int argc, VALUE *argv, CAIndexInfo *info)
446
+ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
447
+ long argc, VALUE *argv, CAIndexInfo *info)
448
448
  {
449
449
  int32_t i;
450
450
 
@@ -495,8 +495,8 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
495
495
  /* ca[selector] -> CA_REG_SELECT */
496
496
  if ( ca_elements != cs->elements ) {
497
497
  rb_raise(rb_eRuntimeError,
498
- "mismatch of # of elements ( %i <=> %i ) in reference by selection",
499
- cs->elements, ca_elements);
498
+ "mismatch of # of elements ( %lld <=> %lld ) in reference by selection",
499
+ (ca_size_t) cs->elements, (ca_size_t) ca_elements);
500
500
  }
501
501
  info->type = CA_REG_SELECT;
502
502
  info->select = cs;
@@ -523,10 +523,10 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
523
523
 
524
524
  if ( ca_rank > 1 ) { /* ca.rank > 1 */
525
525
  if ( rb_obj_is_kind_of(arg, rb_cInteger) ) { /* ca[n] -> CA_REG_ADDRESS */
526
- int32_t addr;
526
+ ca_size_t addr;
527
527
  info->type = CA_REG_ADDRESS;
528
528
  info->rank = 1;
529
- addr = NUM2INT(arg);
529
+ addr = NUM2SIZE(arg);
530
530
  CA_CHECK_INDEX(addr, ca_elements);
531
531
  info->index[0].scalar = addr;
532
532
  return;
@@ -545,8 +545,8 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
545
545
  /* continue to next section */
546
546
 
547
547
  if ( argc >= 1 ) {
548
- int32_t is_point = 0, is_all = 0, is_iterator = 0, is_repeat=0, is_grid=0;
549
- int32_t has_rubber = 0;
548
+ int8_t is_point = 0, is_all = 0, is_iterator = 0, is_repeat=0, is_grid=0;
549
+ int8_t has_rubber = 0;
550
550
  int32_t *index_type = info->index_type;
551
551
  CAIndex *index = info->index;
552
552
 
@@ -574,7 +574,7 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
574
574
  if ( ! has_rubber && ca_rank != argc ) {
575
575
  rb_raise(rb_eIndexError,
576
576
  "number of indices exceeds the rank of carray (%i > %i)",
577
- argc, ca_rank);
577
+ (int) argc, ca_rank);
578
578
  }
579
579
 
580
580
  info->rank = argc;
@@ -585,9 +585,9 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
585
585
  retry:
586
586
 
587
587
  if ( rb_obj_is_kind_of(arg, rb_cInteger) ) { /* ca[--,i,--] */
588
- int32_t scalar;
588
+ ca_size_t scalar;
589
589
  index_type[i] = CA_IDX_SCALAR;
590
- scalar = NUM2INT(arg);
590
+ scalar = NUM2SIZE(arg);
591
591
  CA_CHECK_INDEX_AT(scalar, ca_dim[i], i);
592
592
  index[i].scalar = scalar;
593
593
  }
@@ -595,8 +595,8 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
595
595
  index_type[i] = CA_IDX_ALL;
596
596
  }
597
597
  else if ( arg == Qfalse ) { /* ca[--,false,--] */
598
- int32_t rrank = ca_rank - argc + 1;
599
- int32_t j;
598
+ int8_t rrank = ca_rank - argc + 1;
599
+ int8_t j;
600
600
  for (j=0; j<rrank; j++) {
601
601
  index_type[i+j] = CA_IDX_ALL;
602
602
  }
@@ -606,14 +606,14 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
606
606
  info->rank = ca_rank;
607
607
  }
608
608
  else if ( rb_obj_is_kind_of(arg, rb_cRange) ) { /* ca[--,i..j,--] */
609
- int32_t first, last, excl, count, step;
609
+ ca_size_t first, last, excl, count, step;
610
610
  volatile VALUE iv_beg, iv_end, iv_excl;
611
611
  iv_beg = RANGE_BEG(arg);
612
612
  iv_end = RANGE_END(arg);
613
613
  iv_excl = RANGE_EXCL(arg);
614
614
  index_type[i] = CA_IDX_BLOCK; /* convert to block */
615
- first = NUM2INT(iv_beg);
616
- last = NUM2INT(iv_end);
615
+ first = NUM2SIZE(iv_beg);
616
+ last = NUM2SIZE(iv_end);
617
617
  excl = RTEST(iv_excl);
618
618
  CA_CHECK_INDEX_AT(first, ca_dim[i], i);
619
619
 
@@ -631,11 +631,11 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
631
631
  }
632
632
  if ( last < 0 || last >= ca_dim[i] ) {
633
633
  rb_raise(rb_eIndexError,
634
- "index %i is out of range (0..%i) at %i-dim",
635
- last, ca_dim[i]-1, i);
634
+ "index %lld is out of range (0..%lld) at %i-dim",
635
+ (ca_size_t) last, (ca_size_t) (ca_dim[i]-1), i);
636
636
  }
637
637
  index[i].block.start = first;
638
- index[i].block.count = count = abs(last - first) + 1;
638
+ index[i].block.count = count = llabs(last - first) + 1;
639
639
  index[i].block.step = step = ( last >= first ) ? 1 : -1;
640
640
  }
641
641
  }
@@ -651,8 +651,8 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
651
651
  goto retry;
652
652
  }
653
653
  else { /* ca[--,[i],--]*/
654
- int32_t start;
655
- start = NUM2INT(arg0);
654
+ ca_size_t start;
655
+ start = NUM2SIZE(arg0);
656
656
  CA_CHECK_INDEX_AT(start, ca_dim[i], i);
657
657
  index_type[i] = CA_IDX_BLOCK;
658
658
  index[i].block.start = start;
@@ -664,8 +664,8 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
664
664
  VALUE arg0 = rb_ary_entry(arg, 0);
665
665
  VALUE arg1 = rb_ary_entry(arg, 1);
666
666
  if ( NIL_P(arg0) ) { /* ca[--,[nil,k],--]*/
667
- int32_t start, last, count, step, bound;
668
- step = NUM2INT(arg1);
667
+ ca_size_t start, last, count, step, bound;
668
+ step = NUM2SIZE(arg1);
669
669
  if ( step == 0 ) {
670
670
  rb_raise(rb_eRuntimeError,
671
671
  "step in index equals to 0 in block reference");
@@ -686,11 +686,11 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
686
686
  index[i].block.step = step;
687
687
  }
688
688
  else if ( rb_obj_is_kind_of(arg0, rb_cRange) ) { /* ca[--,[i..j,k],--]*/
689
- int32_t start, last, excl, count, step, bound;
690
- start = NUM2INT(RANGE_BEG(arg0));
691
- last = NUM2INT(RANGE_END(arg0));
689
+ ca_size_t start, last, excl, count, step, bound;
690
+ start = NUM2SIZE(RANGE_BEG(arg0));
691
+ last = NUM2SIZE(RANGE_END(arg0));
692
692
  excl = RTEST(RANGE_EXCL(arg0));
693
- step = NUM2INT(arg1);
693
+ step = NUM2SIZE(arg1);
694
694
  if ( step == 0 ) {
695
695
  rb_raise(rb_eRuntimeError,
696
696
  "step in index equals to 0 in block reference");
@@ -711,14 +711,14 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
711
711
  }
712
712
  if ( last < 0 || last >= ca_dim[i] ) {
713
713
  rb_raise(rb_eIndexError,
714
- "index %i is out of range (0..%i) at %i-dim",
715
- last, ca_dim[i]-1, i);
714
+ "index %lld is out of range (0..%lld) at %i-dim",
715
+ (ca_size_t) last, (ca_size_t) (ca_dim[i]-1), i);
716
716
  }
717
717
  if ( (last - start) * step < 0 ) {
718
718
  count = 1;
719
719
  }
720
720
  else {
721
- count = abs(last - start)/abs(step) + 1;
721
+ count = llabs(last - start)/llabs(step) + 1;
722
722
  }
723
723
  bound = start + (count - 1)*step;
724
724
  CA_CHECK_INDEX_AT(bound, ca_dim[i], i);
@@ -728,9 +728,9 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
728
728
  }
729
729
  }
730
730
  else { /* ca[--,[i,j],--]*/
731
- int32_t start, count, bound;
732
- start = NUM2INT(arg0);
733
- count = NUM2INT(arg1);
731
+ ca_size_t start, count, bound;
732
+ start = NUM2SIZE(arg0);
733
+ count = NUM2SIZE(arg1);
734
734
  bound = start + (count - 1);
735
735
  CA_CHECK_INDEX_AT(start, ca_dim[i], i);
736
736
  CA_CHECK_INDEX_AT(bound, ca_dim[i], i);
@@ -741,10 +741,10 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
741
741
  }
742
742
  }
743
743
  else if ( RARRAY_LEN(arg) == 3 ) { /* ca[--,[i,j,k],--]*/
744
- int32_t start, count, step, bound;
745
- start = NUM2INT(rb_ary_entry(arg, 0));
746
- count = NUM2INT(rb_ary_entry(arg, 1));
747
- step = NUM2INT(rb_ary_entry(arg, 2));
744
+ ca_size_t start, count, step, bound;
745
+ start = NUM2SIZE(rb_ary_entry(arg, 0));
746
+ count = NUM2SIZE(rb_ary_entry(arg, 1));
747
+ step = NUM2SIZE(rb_ary_entry(arg, 2));
748
748
  if ( step == 0 ) {
749
749
  rb_raise(rb_eRuntimeError,
750
750
  "step in index equals to 0 in block reference");
@@ -852,7 +852,7 @@ rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t ca_elements,
852
852
  if ( info->type == CA_REG_ITERATOR ) {
853
853
  for (i=0; i<info->rank; i++) {
854
854
  if ( info->index_type[i] == CA_IDX_SCALAR ) {
855
- int32_t start = info->index[i].scalar;
855
+ ca_size_t start = info->index[i].scalar;
856
856
  info->index_type[i] = CA_IDX_BLOCK;
857
857
  info->index[i].block.start = start;
858
858
  info->index[i].block.step = 1;
@@ -871,7 +871,7 @@ static VALUE
871
871
  rb_ca_ref_address (VALUE self, CAIndexInfo *info)
872
872
  {
873
873
  CArray *ca;
874
- int32_t addr;
874
+ ca_size_t addr;
875
875
  Data_Get_Struct(self, CArray, ca);
876
876
  addr = info->index[0].scalar;
877
877
  return rb_ca_fetch_addr(self, addr);
@@ -881,7 +881,7 @@ static VALUE
881
881
  rb_ca_store_address (VALUE self, CAIndexInfo *info, volatile VALUE rval)
882
882
  {
883
883
  CArray *ca;
884
- int32_t addr;
884
+ ca_size_t addr;
885
885
  Data_Get_Struct(self, CArray, ca);
886
886
  addr = info->index[0].scalar;
887
887
  if ( rb_obj_is_cscalar(rval) ) {
@@ -895,8 +895,8 @@ static VALUE
895
895
  rb_ca_ref_point (VALUE self, CAIndexInfo *info)
896
896
  {
897
897
  CArray *ca;
898
- int32_t idx[CA_RANK_MAX];
899
- int32_t i;
898
+ ca_size_t idx[CA_RANK_MAX];
899
+ int8_t i;
900
900
  Data_Get_Struct(self, CArray, ca);
901
901
  for (i=0; i<ca->rank; i++) {
902
902
  idx[i] = info->index[i].scalar;
@@ -908,8 +908,8 @@ static VALUE
908
908
  rb_ca_store_point (VALUE self, CAIndexInfo *info, volatile VALUE val)
909
909
  {
910
910
  CArray *ca;
911
- int32_t idx[CA_RANK_MAX];
912
- int32_t i;
911
+ ca_size_t idx[CA_RANK_MAX];
912
+ int8_t i;
913
913
  Data_Get_Struct(self, CArray, ca);
914
914
  for (i=0; i<ca->rank; i++) {
915
915
  idx[i] = info->index[i].scalar;
@@ -957,8 +957,8 @@ rb_ca_store_all (VALUE self, VALUE rval)
957
957
 
958
958
  if ( ca->elements != cv->elements ) {
959
959
  rb_raise(rb_eRuntimeError,
960
- "mismatch in data size (%i <-> %i) for storing to carray",
961
- ca->elements, cv->elements);
960
+ "mismatch in data size (%lld <-> %lld) for storing to carray",
961
+ (ca_size_t) ca->elements, (ca_size_t) cv->elements);
962
962
  }
963
963
 
964
964
  ca_attach(cv);
@@ -984,7 +984,7 @@ rb_ca_store_all (VALUE self, VALUE rval)
984
984
  else if ( TYPE(rval) == T_ARRAY ) {
985
985
  volatile VALUE list =
986
986
  rb_ary_flatten_for_elements(rval, ca->elements, ca);
987
- int32_t i;
987
+ ca_size_t i;
988
988
  if ( NIL_P(list) ) {
989
989
  rb_raise(rb_eRuntimeError,
990
990
  "failed to guess data size of given array");
@@ -1041,28 +1041,28 @@ rb_ca_store_all (VALUE self, VALUE rval)
1041
1041
  }
1042
1042
 
1043
1043
  static void
1044
- rb_ca_index_restruct_block (int16_t *rankp, int32_t *shrink, int32_t *dim,
1045
- int32_t *start, int32_t *step, int32_t *count,
1046
- int32_t *offsetp)
1044
+ rb_ca_index_restruct_block (int16_t *rankp, ca_size_t *shrink, ca_size_t *dim,
1045
+ ca_size_t *start, ca_size_t *step, ca_size_t *count,
1046
+ ca_size_t *offsetp)
1047
1047
  {
1048
- int32_t dim0[CA_RANK_MAX];
1049
- int32_t start0[CA_RANK_MAX];
1050
- int32_t step0[CA_RANK_MAX];
1051
- int32_t count0[CA_RANK_MAX];
1052
- int32_t idx[CA_RANK_MAX];
1048
+ ca_size_t dim0[CA_RANK_MAX];
1049
+ ca_size_t start0[CA_RANK_MAX];
1050
+ ca_size_t step0[CA_RANK_MAX];
1051
+ ca_size_t count0[CA_RANK_MAX];
1052
+ ca_size_t idx[CA_RANK_MAX];
1053
1053
  int16_t rank0, rank;
1054
- int32_t offset0, offset, length;
1055
- int32_t k, n;
1056
- int32_t i, j, m;
1054
+ ca_size_t offset0, offset, length;
1055
+ ca_size_t k, n;
1056
+ ca_size_t i, j, m;
1057
1057
 
1058
1058
  rank0 = *rankp;
1059
1059
  offset0 = *offsetp;
1060
1060
 
1061
1061
  /* store original start, step, count to start0, step0, count0 */
1062
- memcpy(dim0, dim, sizeof(int32_t) * rank0);
1063
- memcpy(start0, start, sizeof(int32_t) * rank0);
1064
- memcpy(step0, step, sizeof(int32_t) * rank0);
1065
- memcpy(count0, count, sizeof(int32_t) * rank0);
1062
+ memcpy(dim0, dim, sizeof(ca_size_t) * rank0);
1063
+ memcpy(start0, start, sizeof(ca_size_t) * rank0);
1064
+ memcpy(step0, step, sizeof(ca_size_t) * rank0);
1065
+ memcpy(count0, count, sizeof(ca_size_t) * rank0);
1066
1066
 
1067
1067
  /* classify and calc rank */
1068
1068
  n = -1;
@@ -1137,16 +1137,16 @@ rb_ca_ref_block (VALUE self, CAIndexInfo *info)
1137
1137
  {
1138
1138
  volatile VALUE refer;
1139
1139
  CArray *ca;
1140
- int32_t dim[CA_RANK_MAX];
1141
- int32_t start[CA_RANK_MAX];
1142
- int32_t step[CA_RANK_MAX];
1143
- int32_t count[CA_RANK_MAX];
1144
- int32_t shrink[CA_RANK_MAX];
1140
+ ca_size_t dim[CA_RANK_MAX];
1141
+ ca_size_t start[CA_RANK_MAX];
1142
+ ca_size_t step[CA_RANK_MAX];
1143
+ ca_size_t count[CA_RANK_MAX];
1144
+ ca_size_t shrink[CA_RANK_MAX];
1145
1145
  int16_t rank = 0;
1146
- int32_t offset = 0;
1147
- int32_t flag = 0;
1148
- int32_t elements;
1149
- int32_t i;
1146
+ ca_size_t offset = 0;
1147
+ ca_size_t flag = 0;
1148
+ ca_size_t elements;
1149
+ ca_size_t i;
1150
1150
 
1151
1151
  Data_Get_Struct(self, CArray, ca);
1152
1152
 
@@ -1217,7 +1217,7 @@ static VALUE
1217
1217
  rb_ca_refer_new_flatten (VALUE self)
1218
1218
  {
1219
1219
  CArray *ca;
1220
- int32_t dim0;
1220
+ ca_size_t dim0;
1221
1221
 
1222
1222
  Data_Get_Struct(self, CArray, ca);
1223
1223
  dim0 = ca->elements;
@@ -1272,7 +1272,7 @@ rb_ca_fetch_method (int argc, VALUE *argv, VALUE self)
1272
1272
  obj = rb_ca_repeat(argc, argv, self);
1273
1273
  break;
1274
1274
  case CA_REG_UNBOUND_REPEAT:
1275
- obj = rb_funcall2(self, rb_intern("unbound_repeat"), argc, argv);
1275
+ obj = rb_funcall2(self, rb_intern("unbound_repeat"), (int) argc, argv);
1276
1276
  break;
1277
1277
  case CA_REG_MAPPING:
1278
1278
  obj = rb_ca_mapping(argc, argv, self);
@@ -1369,7 +1369,7 @@ rb_ca_store_method (int argc, VALUE *argv, VALUE self)
1369
1369
  break;
1370
1370
  }
1371
1371
  case CA_REG_UNBOUND_REPEAT:
1372
- obj = rb_funcall2(self, rb_intern("unbound_repeat"), argc, argv);
1372
+ obj = rb_funcall2(self, rb_intern("unbound_repeat"), (int) argc, argv);
1373
1373
  obj = rb_ca_store_all(obj, rval);
1374
1374
  break;
1375
1375
  case CA_REG_MAPPING: {
@@ -1386,7 +1386,7 @@ rb_ca_store_method (int argc, VALUE *argv, VALUE self)
1386
1386
  volatile VALUE idx;
1387
1387
  Data_Get_Struct(self, CArray, ca);
1388
1388
  ca_attach(ca);
1389
- idx = rb_funcall2(self, SYM2ID(info.symbol), argc-1, argv+1);
1389
+ idx = rb_funcall2(self, SYM2ID(info.symbol), (int)(argc-1), argv+1);
1390
1390
  obj = rb_ca_store(self, idx, rval);
1391
1391
  ca_detach(ca);
1392
1392
  break;
@@ -1412,7 +1412,7 @@ rb_ca_fetch (VALUE self, VALUE index)
1412
1412
  {
1413
1413
  switch ( TYPE(index) ) {
1414
1414
  case T_ARRAY:
1415
- return rb_ca_fetch_method(RARRAY_LEN(index), RARRAY_PTR(index), self);
1415
+ return rb_ca_fetch_method((int) RARRAY_LEN(index), RARRAY_PTR(index), self);
1416
1416
  default:
1417
1417
  return rb_ca_fetch_method(1, &index, self);
1418
1418
  }
@@ -1431,7 +1431,7 @@ rb_ca_store (VALUE self, VALUE index, VALUE rval)
1431
1431
  case T_ARRAY:
1432
1432
  index = rb_obj_clone(index);
1433
1433
  rb_ary_push(index, rval);
1434
- return rb_ca_store_method(RARRAY_LEN(index), RARRAY_PTR(index), self);
1434
+ return rb_ca_store_method((int)RARRAY_LEN(index), RARRAY_PTR(index), self);
1435
1435
  default: {
1436
1436
  VALUE rindex[2] = { index, rval };
1437
1437
  return rb_ca_store_method(2, rindex, self);
@@ -1444,7 +1444,7 @@ rb_ca_store2 (VALUE self, int n, VALUE *rindex, VALUE rval)
1444
1444
  {
1445
1445
  VALUE index = rb_ary_new4(n, rindex);
1446
1446
  rb_ary_push(index, rval);
1447
- return rb_ca_store_method(RARRAY_LEN(index), RARRAY_PTR(index), self);
1447
+ return rb_ca_store_method((int)RARRAY_LEN(index), RARRAY_PTR(index), self);
1448
1448
  }
1449
1449
 
1450
1450
  /* rdoc:
@@ -1458,17 +1458,17 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
1458
1458
  volatile VALUE rtype, rrank, rindex;
1459
1459
  CAIndexInfo info;
1460
1460
  int rank;
1461
- int32_t dim[CA_RANK_MAX];
1462
- int32_t elements;
1461
+ ca_size_t dim[CA_RANK_MAX];
1462
+ ca_size_t elements;
1463
1463
  int i;
1464
1464
 
1465
1465
  Check_Type(rdim, T_ARRAY);
1466
1466
  Check_Type(ridx, T_ARRAY);
1467
1467
 
1468
1468
  elements = 1;
1469
- rank = RARRAY_LEN(rdim);
1469
+ rank = (int) RARRAY_LEN(rdim);
1470
1470
  for (i=0; i<rank; i++) {
1471
- dim[i] = NUM2LONG(rb_ary_entry(rdim, i));
1471
+ dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
1472
1472
  elements *= dim[i];
1473
1473
  }
1474
1474
 
@@ -1487,22 +1487,22 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
1487
1487
  case CA_REG_ALL:
1488
1488
  break;
1489
1489
  case CA_REG_ADDRESS:
1490
- rb_ary_store(rindex, 0, LONG2NUM(info.index[0].scalar));
1490
+ rb_ary_store(rindex, 0, SIZE2NUM(info.index[0].scalar));
1491
1491
  break;
1492
1492
  case CA_REG_ADDRESS_COMPLEX: {
1493
1493
  volatile VALUE rinfo;
1494
- int32_t elements = 1;
1494
+ ca_size_t elements = 1;
1495
1495
  for (i=0; i<rank; i++) {
1496
1496
  elements *= dim[i];
1497
1497
  }
1498
- rinfo = rb_ca_s_scan_index(self, rb_ary_new3(1, LONG2NUM(elements)), ridx);
1499
- rtype = LONG2NUM(CA_REG_ADDRESS_COMPLEX);
1498
+ rinfo = rb_ca_s_scan_index(self, rb_ary_new3(1, SIZE2NUM(elements)), ridx);
1499
+ rtype = INT2NUM(CA_REG_ADDRESS_COMPLEX);
1500
1500
  rindex = rb_struct_aref(rinfo, rb_str_new2("index"));
1501
1501
  break;
1502
1502
  }
1503
1503
  case CA_REG_POINT:
1504
1504
  for (i=0; i<rank; i++) {
1505
- rb_ary_store(rindex, i, LONG2NUM(info.index[i].scalar));
1505
+ rb_ary_store(rindex, i, SIZE2NUM(info.index[i].scalar));
1506
1506
  }
1507
1507
  break;
1508
1508
  case CA_REG_SELECT:
@@ -1512,21 +1512,21 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
1512
1512
  for (i=0; i<rank; i++) {
1513
1513
  switch ( info.index_type[i] ) {
1514
1514
  case CA_IDX_SCALAR:
1515
- rb_ary_store(rindex, i, LONG2NUM(info.index[i].scalar));
1515
+ rb_ary_store(rindex, i, SIZE2NUM(info.index[i].scalar));
1516
1516
  break;
1517
1517
  case CA_IDX_ALL:
1518
1518
  rb_ary_store(rindex, i,
1519
1519
  rb_ary_new3(3,
1520
- LONG2NUM(0),
1520
+ INT2NUM(0),
1521
1521
  rb_ary_entry(rdim, i),
1522
- LONG2NUM(1)));
1522
+ INT2NUM(1)));
1523
1523
  break;
1524
1524
  case CA_IDX_BLOCK:
1525
1525
  rb_ary_store(rindex, i,
1526
1526
  rb_ary_new3(3,
1527
- LONG2NUM(info.index[i].block.start),
1528
- LONG2NUM(info.index[i].block.count),
1529
- LONG2NUM(info.index[i].block.step)));
1527
+ SIZE2NUM(info.index[i].block.start),
1528
+ SIZE2NUM(info.index[i].block.count),
1529
+ SIZE2NUM(info.index[i].block.step)));
1530
1530
  break;
1531
1531
  case CA_IDX_SYMBOL:
1532
1532
  rb_ary_store(rindex, i,
@@ -1579,12 +1579,12 @@ rb_ca_normalize_index (VALUE self, VALUE ridx)
1579
1579
  case CA_REG_SELECT:
1580
1580
  case CA_REG_ADDRESS:
1581
1581
  rindex = rb_ary_new2(info.rank);
1582
- rb_ary_store(rindex, 0, LONG2NUM(info.index[0].scalar));
1582
+ rb_ary_store(rindex, 0, SIZE2NUM(info.index[0].scalar));
1583
1583
  return rindex;
1584
1584
  case CA_REG_POINT:
1585
1585
  rindex = rb_ary_new2(info.rank);
1586
1586
  for (i=0; i<ca->rank; i++) {
1587
- rb_ary_store(rindex, i, LONG2NUM(info.index[i].scalar));
1587
+ rb_ary_store(rindex, i, SIZE2NUM(info.index[i].scalar));
1588
1588
  }
1589
1589
  return rindex;
1590
1590
  case CA_REG_BLOCK:
@@ -1593,7 +1593,7 @@ rb_ca_normalize_index (VALUE self, VALUE ridx)
1593
1593
  for (i=0; i<ca->rank; i++) {
1594
1594
  switch ( info.index_type[i] ) {
1595
1595
  case CA_IDX_SCALAR:
1596
- rb_ary_store(rindex, i, LONG2NUM(info.index[i].scalar));
1596
+ rb_ary_store(rindex, i, SIZE2NUM(info.index[i].scalar));
1597
1597
  break;
1598
1598
  case CA_IDX_ALL:
1599
1599
  rb_ary_store(rindex, i, Qnil);
@@ -1601,9 +1601,9 @@ rb_ca_normalize_index (VALUE self, VALUE ridx)
1601
1601
  case CA_IDX_BLOCK:
1602
1602
  rb_ary_store(rindex, i,
1603
1603
  rb_ary_new3(3,
1604
- LONG2NUM(info.index[i].block.start),
1605
- LONG2NUM(info.index[i].block.count),
1606
- LONG2NUM(info.index[i].block.step)));
1604
+ SIZE2NUM(info.index[i].block.start),
1605
+ SIZE2NUM(info.index[i].block.count),
1606
+ SIZE2NUM(info.index[i].block.step)));
1607
1607
  break;
1608
1608
  case CA_IDX_SYMBOL:
1609
1609
  rb_ary_store(rindex, i, ID2SYM(info.index[i].symbol.id));
@@ -1638,22 +1638,22 @@ rb_ca_addr2index (VALUE self, VALUE raddr)
1638
1638
  {
1639
1639
  volatile VALUE out;
1640
1640
  CArray *ca;
1641
- int32_t *dim;
1642
- int32_t addr;
1641
+ ca_size_t *dim;
1642
+ ca_size_t addr;
1643
1643
  int i;
1644
1644
 
1645
1645
  Data_Get_Struct(self, CArray, ca);
1646
1646
 
1647
- addr = NUM2INT(raddr);
1647
+ addr = NUM2SIZE(raddr);
1648
1648
  if ( addr < 0 || addr >= ca->elements ) {
1649
1649
  rb_raise(rb_eArgError,
1650
- "address %i is out of range (0..%i)",
1651
- addr, ca->elements-1);
1650
+ "address %lld is out of range (0..%lld)",
1651
+ (ca_size_t) addr, (ca_size_t) (ca->elements-1));
1652
1652
  }
1653
1653
  dim = ca->dim;
1654
1654
  out = rb_ary_new2(ca->rank);
1655
1655
  for (i=ca->rank-1; i>=0; i--) { /* in descending order */
1656
- rb_ary_store(out, i, LONG2NUM(addr % dim[i]));
1656
+ rb_ary_store(out, i, SIZE2NUM(addr % dim[i]));
1657
1657
  addr /= dim[i];
1658
1658
  }
1659
1659
 
@@ -1672,10 +1672,11 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1672
1672
  {
1673
1673
  volatile VALUE obj;
1674
1674
  CArray *ca, *co, *cidx[CA_RANK_MAX];
1675
- int32_t *q, *p[CA_RANK_MAX], s[CA_RANK_MAX];
1676
- int32_t *dim;
1677
- int32_t addr, elements = 0;
1678
- int32_t i, k, n;
1675
+ ca_size_t *q, *p[CA_RANK_MAX], s[CA_RANK_MAX];
1676
+ ca_size_t *dim;
1677
+ ca_size_t addr, elements = 0;
1678
+ int8_t i;
1679
+ ca_size_t k, n;
1679
1680
  boolean8_t *m;
1680
1681
  int all_number = 1;
1681
1682
 
@@ -1696,16 +1697,16 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1696
1697
  dim = ca->dim;
1697
1698
  addr = 0;
1698
1699
  for (i=0; i<ca->rank; i++) {
1699
- k = NUM2INT(argv[i]);
1700
+ k = NUM2SIZE(argv[i]);
1700
1701
  CA_CHECK_INDEX(k, dim[i]);
1701
1702
  addr = dim[i] * addr + k;
1702
1703
  }
1703
- return LONG2NUM(addr);
1704
+ return SIZE2NUM(addr);
1704
1705
  }
1705
1706
 
1706
1707
  elements = 1;
1707
1708
  for (i=0; i<ca->rank; i++) {
1708
- cidx[i] = ca_wrap_readonly(argv[i], CA_INT32);
1709
+ cidx[i] = ca_wrap_readonly(argv[i], CA_SIZE);
1709
1710
  if ( ! ca_is_scalar(cidx[i]) ) {
1710
1711
  if ( elements == 1 ) {
1711
1712
  elements = cidx[i]->elements;
@@ -1721,10 +1722,10 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
1721
1722
  ca_set_iterator(1, cidx[i], &p[i], &s[i]);
1722
1723
  }
1723
1724
 
1724
- obj = rb_carray_new(CA_INT32, 1, &elements, 0, NULL);
1725
+ obj = rb_carray_new(CA_SIZE, 1, &elements, 0, NULL);
1725
1726
  Data_Get_Struct(obj, CArray, co);
1726
1727
 
1727
- q = (int32_t *) co->ptr;
1728
+ q = (ca_size_t *) co->ptr;
1728
1729
 
1729
1730
  ca_copy_mask_overwrite_n(co, elements, ca->rank, cidx);
1730
1731
  m = ( co->mask ) ? (boolean8_t *) co->mask->ptr : NULL;