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_cast_func.rb CHANGED
@@ -169,7 +169,7 @@ puts %{
169
169
  #include "carray.h"
170
170
 
171
171
  static void
172
- ca_cast_not_implemented(int32_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
172
+ ca_cast_not_implemented(ca_size_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
173
173
  {
174
174
  rb_raise(rb_eCADataTypeError,
175
175
  "can not cast data type from <%s> to <%s>",
@@ -187,12 +187,12 @@ FIXLEN.each do |type1|
187
187
  CA_CAST_TABLE[type1][type2] = "ca_cast_#{ctype1}_#{ctype2}"
188
188
  puts <<-END_DEF .gsub(/^ {6}/, '')
189
189
  static void
190
- ca_cast_#{ctype1}_#{ctype2}(int32_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
190
+ ca_cast_#{ctype1}_#{ctype2}(ca_size_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
191
191
  {
192
192
  char *p1 = ptr1;
193
- int32_t bytes1;
193
+ ca_size_t bytes1;
194
194
  char *p2 = ptr2;
195
- int32_t bytes2;
195
+ ca_size_t bytes2;
196
196
  if ( a1 == NULL || a2 == NULL ) {
197
197
  rb_raise(rb_eRuntimeError, "[BUG] failed to cast fixlen -> fixlen");
198
198
  }
@@ -240,10 +240,10 @@ FIXLEN.each do |type1|
240
240
  CA_CAST_TABLE[type1][type2] = "ca_cast_#{ctype1}_#{ctype2}"
241
241
  puts <<-END_DEF .gsub(/^ {6}/, '')
242
242
  static void
243
- ca_cast_#{ctype1}_#{ctype2}(int32_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
243
+ ca_cast_#{ctype1}_#{ctype2}(ca_size_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
244
244
  {
245
245
  char *p1 = ptr1;
246
- int32_t bytes;
246
+ ca_size_t bytes;
247
247
  VALUE *p2 = ptr2;
248
248
  if ( a1 == NULL ) {
249
249
  rb_raise(rb_eRuntimeError, "[BUG] failed to cast fixlen -> object");
@@ -278,7 +278,7 @@ puts
278
278
  CA_CAST_TABLE[type1][type2] = "ca_cast_#{ctype1}_#{ctype2}"
279
279
  puts <<-END_DEF .gsub(/^ {6}/, '')
280
280
  static void
281
- ca_cast_#{ctype1}_#{ctype2}(int32_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
281
+ ca_cast_#{ctype1}_#{ctype2}(ca_size_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
282
282
  {
283
283
  #{ctype1} *p1 = ptr1;
284
284
  #{ctype2} *p2 = ptr2;
@@ -325,13 +325,13 @@ puts
325
325
  CA_CAST_TABLE[type1][type2] = "ca_cast_#{ctype1}_#{ctype2}"
326
326
  puts <<-END_DEF .gsub(/^ {6}/, '')
327
327
  static void
328
- ca_cast_#{ctype1}_#{ctype2}(int32_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
328
+ ca_cast_#{ctype1}_#{ctype2}(ca_size_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
329
329
  {
330
330
  #{ctype1} *q1 = ptr1;
331
331
  #{ctype1} *p1 = q1;
332
332
  #{ctype2} *q2 = ptr2;
333
333
  #{ctype2} *p2 = q2;
334
- int32_t k;
334
+ ca_size_t k;
335
335
  if ( m ) {
336
336
  boolean8_t *pm = m;
337
337
  #ifdef _OPENMP
@@ -375,18 +375,18 @@ puts
375
375
  CA_CAST_TABLE[type1][type2] = "ca_cast_#{ctype1}_#{ctype2}"
376
376
  puts <<-END_DEF .gsub(/^ {6}/, '')
377
377
  static void
378
- ca_cast_#{ctype1}_#{ctype2}(int32_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
378
+ ca_cast_#{ctype1}_#{ctype2}(ca_size_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
379
379
  {
380
380
  #{ctype1} *p1 = ptr1;
381
381
  VALUE *p2 = ptr2;
382
382
  if ( m ) {
383
383
  while ( n-- ) {
384
- if ( !*m ) { *p2 = #{conv}(*p1); }
384
+ if ( !*m ) { *p2 = (VALUE) #{conv}(*p1); }
385
385
  p1++; p2++; m++;
386
386
  }
387
387
  }
388
388
  else {
389
- while ( n-- ) { *p2 = #{conv}(*p1); p1++; p2++; }
389
+ while ( n-- ) { *p2 = (VALUE) #{conv}(*p1); p1++; p2++; }
390
390
  }
391
391
  return;
392
392
  }
@@ -404,11 +404,11 @@ OBJECT.each do |type1|
404
404
  CA_CAST_TABLE[type1][type2] = "ca_cast_#{ctype1}_#{ctype2}"
405
405
  puts <<-END_DEF .gsub(/^ {6}/, '')
406
406
  static void
407
- ca_cast_#{ctype1}_#{ctype2}(int32_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
407
+ ca_cast_#{ctype1}_#{ctype2}(ca_size_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
408
408
  {
409
409
  VALUE *p1 = ptr1;
410
410
  char *p2 = ptr2;
411
- int32_t bytes;
411
+ ca_size_t bytes;
412
412
  if ( a2 == NULL ) {
413
413
  rb_raise(rb_eRuntimeError, "[BUG] failed to cast object -> fixlen");
414
414
  }
@@ -463,18 +463,18 @@ OBJECT.each do |type1|
463
463
  CA_CAST_TABLE[type1][type2] = "ca_cast_#{ctype1}_#{ctype2}"
464
464
  puts <<-END_DEF .gsub(/^ {6}/, '')
465
465
  static void
466
- ca_cast_#{ctype1}_#{ctype2}(int32_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
466
+ ca_cast_#{ctype1}_#{ctype2}(ca_size_t n, CArray *a1, void *ptr1, CArray *a2, void *ptr2, boolean8_t *m)
467
467
  {
468
468
  VALUE *p1 = ptr1;
469
469
  #{ctype2} *p2 = ptr2;
470
470
  if ( m ) {
471
471
  while ( n-- ) {
472
- if ( !*m ) { *p2 = #{conv}(*p1); }
472
+ if ( !*m ) { *p2 = (#{ctype2}) #{conv}(*p1); }
473
473
  p1++; p2++; m++;
474
474
  }
475
475
  }
476
476
  else {
477
- while ( n-- ) { *p2 = #{conv}(*p1); p1++; p2++; }
477
+ while ( n-- ) { *p2 = (#{ctype2}) #{conv}(*p1); p1++; p2++; }
478
478
  }
479
479
  return;
480
480
  }
data/carray_class.c CHANGED
@@ -70,9 +70,9 @@ static VALUE
70
70
  rb_ca_s_sizeof (VALUE klass, VALUE rtype)
71
71
  {
72
72
  int8_t data_type;
73
- int32_t bytes;
74
- rb_ca_guess_type_and_bytes(rtype, INT2FIX(0), &data_type, &bytes);
75
- return LONG2NUM(bytes);
73
+ ca_size_t bytes;
74
+ rb_ca_guess_type_and_bytes(rtype, INT2NUM(0), &data_type, &bytes);
75
+ return SIZE2NUM(bytes);
76
76
  }
77
77
 
78
78
 
data/carray_conversion.c CHANGED
@@ -19,11 +19,11 @@
19
19
  #endif
20
20
 
21
21
  static void
22
- rb_ca_to_a_loop (VALUE self, int32_t level, int32_t *idx, VALUE ary)
22
+ rb_ca_to_a_loop (VALUE self, int32_t level, ca_size_t *idx, VALUE ary)
23
23
  {
24
24
  volatile VALUE obj;
25
25
  CArray *ca;
26
- int32_t i;
26
+ ca_size_t i;
27
27
 
28
28
  Data_Get_Struct(self, CArray, ca);
29
29
 
@@ -57,7 +57,7 @@ rb_ca_to_a (VALUE self)
57
57
  {
58
58
  volatile VALUE ary;
59
59
  CArray *ca;
60
- int32_t idx[CA_RANK_MAX];
60
+ ca_size_t idx[CA_RANK_MAX];
61
61
  Data_Get_Struct(self, CArray, ca);
62
62
  ary = rb_ary_new2(ca->dim[0]);
63
63
  ca_attach(ca);
@@ -80,7 +80,7 @@ rb_ca_convert (int argc, VALUE *argv, VALUE self)
80
80
  {
81
81
  volatile VALUE obj;
82
82
  CArray *ca;
83
- int32_t i;
83
+ ca_size_t i;
84
84
 
85
85
  obj = rb_apply(self, rb_intern("template"), rb_ary_new4(argc, argv));
86
86
 
@@ -235,15 +235,15 @@ rb_ca_load_binary (VALUE self, VALUE io)
235
235
  case T_STRING:
236
236
  if ( ca_length(ca) > RSTRING_LEN(io) ) {
237
237
  rb_raise(rb_eRuntimeError,
238
- "data size mismatch (%li for %i)",
239
- RSTRING_LEN(io), ca_length(ca));
238
+ "data size mismatch (%lld for %lld)",
239
+ (ca_size_t) RSTRING_LEN(io), (ca_size_t) ca_length(ca));
240
240
  }
241
241
  memcpy(ca->ptr, StringValuePtr(io), ca_length(ca));
242
242
  OBJ_INFECT(self, io);
243
243
  break;
244
244
  default:
245
245
  if ( rb_respond_to(io, rb_intern("read") ) ) {
246
- VALUE buf = rb_funcall(io, rb_intern("read"), 1, INT2NUM(ca_length(ca)));
246
+ VALUE buf = rb_funcall(io, rb_intern("read"), 1, SIZE2NUM(ca_length(ca)));
247
247
  memcpy(ca->ptr, StringValuePtr(buf), ca_length(ca));
248
248
  OBJ_INFECT(self, io);
249
249
  }
@@ -271,10 +271,10 @@ ca_to_cptr (void *ap)
271
271
  CArray *ca = (CArray *) ap;
272
272
  void **ptr, **p, **r;
273
273
  char *q;
274
- int offset[CA_RANK_MAX];
275
- int count[CA_RANK_MAX];
276
- int32_t ptr_num;
277
- int32_t i, j;
274
+ ca_size_t offset[CA_RANK_MAX];
275
+ ca_size_t count[CA_RANK_MAX];
276
+ ca_size_t ptr_num;
277
+ ca_size_t i, j;
278
278
 
279
279
  if ( ! ca_is_attached(ca) ) {
280
280
  rb_raise(rb_eRuntimeError, "[BUG] ca_to_cptr called for detached array");
@@ -331,12 +331,12 @@ rb_ca_format (int argc, VALUE *argv, VALUE self)
331
331
  {
332
332
  volatile VALUE obj, elem, val;
333
333
  CArray *ca;
334
- int32_t i, j;
334
+ ca_size_t i, j;
335
335
  ID id_format = rb_intern("format");
336
336
 
337
337
  Data_Get_Struct(self, CArray, ca);
338
338
 
339
- obj = rb_ca_template_with_type(self, INT2FIX(CA_OBJECT), INT2FIX(0));
339
+ obj = rb_ca_template_with_type(self, INT2NUM(CA_OBJECT), INT2NUM(0));
340
340
 
341
341
  ca_attach(ca);
342
342
  if ( ca_has_mask(ca) ) {
@@ -379,7 +379,7 @@ rb_ca_strptime (VALUE self, VALUE rfmt)
379
379
  CArray *ca;
380
380
  char *fmt;
381
381
  struct tm tmv;
382
- int32_t i;
382
+ ca_size_t i;
383
383
 
384
384
  ca = ca_wrap_readonly(self, CA_OBJECT);
385
385
 
@@ -431,7 +431,7 @@ rb_ca_strftime (VALUE self, VALUE rfmt)
431
431
  {
432
432
  volatile VALUE obj, elem, val;
433
433
  CArray *ca;
434
- int32_t i;
434
+ ca_size_t i;
435
435
  ID id_strftime = rb_intern("strftime");
436
436
 
437
437
  ca = ca_wrap_readonly(self, CA_OBJECT);
data/carray_copy.c CHANGED
@@ -89,7 +89,7 @@ ca_template_safe (void *ap)
89
89
  }
90
90
 
91
91
  CArray *
92
- ca_template_safe2 (void *ap, int8_t data_type, int32_t bytes)
92
+ ca_template_safe2 (void *ap, int8_t data_type, ca_size_t bytes)
93
93
  {
94
94
  CArray *ca = (CArray *) ap;
95
95
  CA_CHECK_DATA_TYPE(data_type);
@@ -119,9 +119,9 @@ rb_ca_template_method (int argc, VALUE *argv, VALUE self)
119
119
  volatile VALUE obj, rtype, rbytes = Qnil;
120
120
  CArray *ca, *co;
121
121
  int8_t data_type;
122
- int32_t bytes;
122
+ ca_size_t bytes;
123
123
 
124
- rb_scan_args(argc, argv, "01", &rtype);
124
+ rb_scan_args(argc, argv, "01", (VALUE *) &rtype);
125
125
  rb_scan_options(ropt, "bytes", &rbytes);
126
126
 
127
127
  Data_Get_Struct(self, CArray, ca);
@@ -168,7 +168,7 @@ rb_ca_template_n (int n, ...)
168
168
  {
169
169
  volatile VALUE varg, obj;
170
170
  CArray *ca;
171
- int32_t elements = -1;
171
+ ca_size_t elements = -1;
172
172
  va_list vargs;
173
173
  int i;
174
174
 
@@ -204,11 +204,11 @@ rb_ca_template_n (int n, ...)
204
204
  /* ------------------------------------------------------------------- */
205
205
 
206
206
  static void
207
- ca_paste_loop (CArray *ca, int32_t *offset, int32_t *offset0,
208
- int32_t *size, CArray *cs,
209
- int32_t level, int32_t *idx, int32_t *idx0)
207
+ ca_paste_loop (CArray *ca, ca_size_t *offset, ca_size_t *offset0,
208
+ ca_size_t *size, CArray *cs,
209
+ int32_t level, ca_size_t *idx, ca_size_t *idx0)
210
210
  {
211
- int32_t i;
211
+ ca_size_t i;
212
212
  if ( level == ca->rank - 1 ) {
213
213
  idx[level] = offset[level];
214
214
  idx0[level] = offset0[level];
@@ -229,15 +229,15 @@ ca_paste_loop (CArray *ca, int32_t *offset, int32_t *offset0,
229
229
  /* ------------------------------------------------------------------- */
230
230
 
231
231
  void
232
- ca_paste (void *ap, int32_t *offset, void *sp)
232
+ ca_paste (void *ap, ca_size_t *offset, void *sp)
233
233
  {
234
234
  CArray *ca = (CArray *) ap;
235
235
  CArray *cs = (CArray *) sp;
236
- int32_t size[CA_RANK_MAX];
237
- int32_t offset0[CA_RANK_MAX];
238
- int32_t idx[CA_RANK_MAX];
239
- int32_t idx0[CA_RANK_MAX];
240
- int32_t i;
236
+ ca_size_t size[CA_RANK_MAX];
237
+ ca_size_t offset0[CA_RANK_MAX];
238
+ ca_size_t idx[CA_RANK_MAX];
239
+ ca_size_t idx0[CA_RANK_MAX];
240
+ int8_t i;
241
241
 
242
242
  ca_check_same_data_type(ca, cs);
243
243
  ca_check_same_rank(ca, cs);
@@ -298,7 +298,7 @@ static VALUE
298
298
  rb_ca_paste (VALUE self, VALUE roffset, VALUE rsrc)
299
299
  {
300
300
  CArray *ca, *cs;
301
- int32_t offset[CA_RANK_MAX];
301
+ ca_size_t offset[CA_RANK_MAX];
302
302
  int i;
303
303
 
304
304
  rb_ca_modify(self);
@@ -313,7 +313,7 @@ rb_ca_paste (VALUE self, VALUE roffset, VALUE rsrc)
313
313
  }
314
314
 
315
315
  for (i=0; i<ca->rank; i++) {
316
- offset[i] = NUM2INT(rb_ary_entry(roffset,i));
316
+ offset[i] = NUM2SIZE(rb_ary_entry(roffset,i));
317
317
  }
318
318
 
319
319
  cs = ca_wrap_readonly(rsrc, ca->data_type);
@@ -325,11 +325,11 @@ rb_ca_paste (VALUE self, VALUE roffset, VALUE rsrc)
325
325
 
326
326
 
327
327
  static void
328
- ca_clip_loop (CArray *ca, int32_t *offset, int32_t *offset0,
329
- int32_t *size, CArray *cs,
330
- int32_t level, int32_t *idx, int32_t *idx0)
328
+ ca_clip_loop (CArray *ca, ca_size_t *offset, ca_size_t *offset0,
329
+ ca_size_t *size, CArray *cs,
330
+ int32_t level, ca_size_t *idx, ca_size_t *idx0)
331
331
  {
332
- int32_t i;
332
+ ca_size_t i;
333
333
  if ( level == ca->rank - 1 ) {
334
334
  idx[level] = offset[level];
335
335
  idx0[level] = offset0[level];
@@ -347,14 +347,14 @@ ca_clip_loop (CArray *ca, int32_t *offset, int32_t *offset0,
347
347
  /* ------------------------------------------------------------------- */
348
348
 
349
349
  void
350
- ca_clip (void *ap, int32_t *offset, void *sp)
350
+ ca_clip (void *ap, ca_size_t *offset, void *sp)
351
351
  {
352
352
  CArray *ca = (CArray *) ap;
353
353
  CArray *cs = (CArray *) sp;
354
- int32_t size[CA_RANK_MAX];
355
- int32_t offset0[CA_RANK_MAX];
356
- int32_t idx[CA_RANK_MAX];
357
- int32_t idx0[CA_RANK_MAX];
354
+ ca_size_t size[CA_RANK_MAX];
355
+ ca_size_t offset0[CA_RANK_MAX];
356
+ ca_size_t idx[CA_RANK_MAX];
357
+ ca_size_t idx0[CA_RANK_MAX];
358
358
  int i;
359
359
 
360
360
  ca_check_same_data_type(ca, cs);
@@ -414,7 +414,7 @@ static VALUE
414
414
  rb_ca_clip (VALUE self, VALUE roffset, VALUE rsrc)
415
415
  {
416
416
  CArray *ca, *cs;
417
- int32_t offset[CA_RANK_MAX];
417
+ ca_size_t offset[CA_RANK_MAX];
418
418
  int i;
419
419
 
420
420
  Data_Get_Struct(self, CArray, ca);
@@ -427,7 +427,7 @@ rb_ca_clip (VALUE self, VALUE roffset, VALUE rsrc)
427
427
  }
428
428
 
429
429
  for (i=0; i<ca->rank; i++) {
430
- offset[i] = NUM2INT(rb_ary_entry(roffset, i));
430
+ offset[i] = NUM2SIZE(rb_ary_entry(roffset, i));
431
431
  }
432
432
 
433
433
  cs = ca_wrap_writable(rsrc, ca->data_type);
data/carray_core.c CHANGED
@@ -329,7 +329,7 @@ ca_mark (void *ap)
329
329
  if ( ca_is_object_type(ca) ) { /* object type array */
330
330
  if ( ca_is_attached(ca) ) { /* entity array */
331
331
  VALUE *p = (VALUE*) ca->ptr;
332
- int32_t n = ca->elements;
332
+ ca_size_t n = ca->elements;
333
333
  while ( n-- ) {
334
334
  rb_gc_mark(*p++);
335
335
  }
@@ -377,11 +377,11 @@ ca_wrap_struct (void *ap)
377
377
  /* calculate index from address */
378
378
 
379
379
  void
380
- ca_addr2index (void *ap, int32_t addr, int32_t *idx)
380
+ ca_addr2index (void *ap, ca_size_t addr, ca_size_t *idx)
381
381
  {
382
382
  CArray *ca = (CArray *) ap;
383
- int32_t *dim = ca->dim;
384
- int32_t i;
383
+ ca_size_t *dim = ca->dim;
384
+ int8_t i;
385
385
  for (i=ca->rank-1; i>=0; i--) {
386
386
  idx[i] = addr % dim[i];
387
387
  addr /= dim[i];
@@ -390,12 +390,13 @@ ca_addr2index (void *ap, int32_t addr, int32_t *idx)
390
390
 
391
391
  /* calculate address from index */
392
392
 
393
- int32_t
394
- ca_index2addr (void *ap, int32_t *idx)
393
+ ca_size_t
394
+ ca_index2addr (void *ap, ca_size_t *idx)
395
395
  {
396
396
  CArray *ca = (CArray *) ap;
397
- int32_t *dim = ca->dim;
398
- int32_t n, i;
397
+ ca_size_t *dim = ca->dim;
398
+ int8_t i;
399
+ ca_size_t n;
399
400
  n = idx[0];
400
401
  for (i=1; i<ca->rank; i++) {
401
402
  n = dim[i]*n+idx[i];
@@ -457,7 +458,7 @@ ca_test_cyclic_check(void *ap, void *ptr)
457
458
  /* return pointer of the element at given address */
458
459
 
459
460
  void *
460
- ca_ptr_at_addr (void *ap, int32_t addr)
461
+ ca_ptr_at_addr (void *ap, ca_size_t addr)
461
462
  {
462
463
  CArray *ca = (CArray *) ap;
463
464
 
@@ -478,7 +479,7 @@ ca_ptr_at_addr (void *ap, int32_t addr)
478
479
  /* return pointer of the element at given index */
479
480
 
480
481
  void *
481
- ca_ptr_at_index (void *ap, int32_t *idx)
482
+ ca_ptr_at_index (void *ap, ca_size_t *idx)
482
483
  {
483
484
  CArray *ca = (CArray *) ap;
484
485
  return ca_func[ca->obj_type].ptr_at_index(ca, idx);
@@ -487,7 +488,7 @@ ca_ptr_at_index (void *ap, int32_t *idx)
487
488
  /* fetch data of the element at given address to memory pointed by pval */
488
489
 
489
490
  void
490
- ca_fetch_addr (void *ap, int32_t addr, void *pval)
491
+ ca_fetch_addr (void *ap, ca_size_t addr, void *pval)
491
492
  {
492
493
  CArray *ca = (CArray *) ap;
493
494
  char *ptr = (char *)pval;
@@ -501,7 +502,7 @@ ca_fetch_addr (void *ap, int32_t addr, void *pval)
501
502
  ca_func[ca->obj_type].fetch_addr(ca, addr, ptr);
502
503
  }
503
504
  else if ( ca_func[ca->obj_type].fetch_index ) { /* delegate -> fetch_index */
504
- int32_t idx[CA_RANK_MAX];
505
+ ca_size_t idx[CA_RANK_MAX];
505
506
  ca_addr2index(ca, addr, idx);
506
507
  ca_func[ca->obj_type].fetch_index(ca, idx, ptr);
507
508
  }
@@ -520,7 +521,7 @@ ca_fetch_addr (void *ap, int32_t addr, void *pval)
520
521
  /* store value pointed by pval to the element at given address */
521
522
 
522
523
  void
523
- ca_store_addr (void *ap, int32_t addr, void *pval)
524
+ ca_store_addr (void *ap, ca_size_t addr, void *pval)
524
525
  {
525
526
  CArray *ca = (CArray *) ap;
526
527
  char *ptr = (char *)pval;
@@ -539,7 +540,7 @@ ca_store_addr (void *ap, int32_t addr, void *pval)
539
540
  ca_func[ca->obj_type].store_addr(ca, addr, ptr);
540
541
  }
541
542
  else if ( ca_func[ca->obj_type].store_index ) { /* delegate -> store_index */
542
- int32_t idx[CA_RANK_MAX];
543
+ ca_size_t idx[CA_RANK_MAX];
543
544
  ca_addr2index(ca, addr, idx);
544
545
  ca_func[ca->obj_type].store_index(ca, idx, ptr);
545
546
  }
@@ -558,7 +559,7 @@ ca_store_addr (void *ap, int32_t addr, void *pval)
558
559
  /* fetch data of the element at given index to memory pointed by pval */
559
560
 
560
561
  void
561
- ca_fetch_index (void *ap, int32_t *idx, void *pval)
562
+ ca_fetch_index (void *ap, ca_size_t *idx, void *pval)
562
563
  {
563
564
  CArray *ca = (CArray *) ap;
564
565
  char *ptr = (char *)pval;
@@ -569,7 +570,7 @@ ca_fetch_index (void *ap, int32_t *idx, void *pval)
569
570
  ca_func[ca->obj_type].fetch_index(ca, idx, ptr);
570
571
  }
571
572
  else if ( ca_func[ca->obj_type].fetch_addr ) { /* delegate -> fetch_addr */
572
- int32_t addr = ca_index2addr(ca, idx);
573
+ ca_size_t addr = ca_index2addr(ca, idx);
573
574
  ca_func[ca->obj_type].fetch_addr(ca, addr, ptr);
574
575
  }
575
576
  else {
@@ -588,7 +589,7 @@ ca_fetch_index (void *ap, int32_t *idx, void *pval)
588
589
  /* store value pointed by pval to the element at given index */
589
590
 
590
591
  void
591
- ca_store_index (void *ap, int32_t *idx, void *pval)
592
+ ca_store_index (void *ap, ca_size_t *idx, void *pval)
592
593
  {
593
594
  CArray *ca = (CArray *) ap;
594
595
  char *ptr = (char *) pval;
@@ -604,7 +605,7 @@ ca_store_index (void *ap, int32_t *idx, void *pval)
604
605
  ca_func[ca->obj_type].store_index(ca, idx, ptr);
605
606
  }
606
607
  else if ( ca_func[ca->obj_type].store_addr ) { /* delegate -> store_addr */
607
- int32_t addr = ca_index2addr(ca, idx);
608
+ ca_size_t addr = ca_index2addr(ca, idx);
608
609
  ca_func[ca->obj_type].store_addr(ca, addr, ptr);
609
610
  }
610
611
  else {
@@ -648,9 +649,9 @@ ca_allocate (void *ap)
648
649
  }
649
650
 
650
651
  if ( ca->data_type == CA_OBJECT ) { /* protection against GC */
651
- volatile VALUE rzero = INT2FIX(0);
652
+ volatile VALUE rzero = INT2NUM(0);
652
653
  VALUE *p = (VALUE*)ca->ptr;
653
- int32_t i;
654
+ ca_size_t i;
654
655
  for (i=0; i<ca->elements; i++) {
655
656
  *p++ = rzero;
656
657
  }
@@ -1205,7 +1206,7 @@ rb_ca_field_as_member (VALUE self, VALUE sym)
1205
1206
  }
1206
1207
  else if ( rb_obj_is_kind_of(sym, rb_cInteger) ) {
1207
1208
  VALUE member_names = rb_const_get(data_class, rb_intern("MEMBERS"));
1208
- sym = rb_ary_entry(member_names, NUM2INT(sym));
1209
+ sym = rb_ary_entry(member_names, NUM2SIZE(sym));
1209
1210
  }
1210
1211
 
1211
1212
  obj = rb_hash_aref(member, sym);