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/ca_obj_bitarray.c CHANGED
@@ -17,17 +17,17 @@ typedef struct {
17
17
  int8_t data_type;
18
18
  int8_t rank;
19
19
  int32_t flags;
20
- int32_t bytes;
21
- int32_t elements;
22
- int32_t *dim;
20
+ ca_size_t bytes;
21
+ ca_size_t elements;
22
+ ca_size_t *dim;
23
23
  char *ptr;
24
24
  CArray *mask;
25
25
  CArray *parent;
26
26
  uint32_t attach;
27
27
  uint8_t nosync;
28
28
  /* -------------*/
29
- int32_t bytelen;
30
- int32_t bitlen;
29
+ ca_size_t bytelen;
30
+ ca_size_t bitlen;
31
31
  } CABitarray;
32
32
 
33
33
  static int8_t CA_OBJ_BITARRAY;
@@ -56,7 +56,7 @@ int
56
56
  ca_bitarray_setup (CABitarray *ca, CArray *parent)
57
57
  {
58
58
  int8_t rank;
59
- int32_t bitlen, elements;
59
+ ca_size_t bitlen, elements;
60
60
 
61
61
  /* check arguments */
62
62
 
@@ -76,7 +76,7 @@ ca_bitarray_setup (CABitarray *ca, CArray *parent)
76
76
  ca->elements = elements;
77
77
  ca->ptr = NULL;
78
78
  ca->mask = NULL;
79
- ca->dim = ALLOC_N(int32_t, rank);
79
+ ca->dim = ALLOC_N(ca_size_t, rank);
80
80
 
81
81
  ca->parent = parent;
82
82
  ca->attach = 0;
@@ -85,7 +85,7 @@ ca_bitarray_setup (CABitarray *ca, CArray *parent)
85
85
  ca->bytelen = parent->bytes;
86
86
  ca->bitlen = bitlen;
87
87
 
88
- memcpy(ca->dim, parent->dim, (rank-1) * sizeof(int32_t));
88
+ memcpy(ca->dim, parent->dim, (rank-1) * sizeof(ca_size_t));
89
89
  ca->dim[rank-1] = bitlen;
90
90
 
91
91
  if ( ca_has_mask(parent) ) {
@@ -128,7 +128,7 @@ ca_bitarray_func_clone (void *ap)
128
128
  }
129
129
 
130
130
  static char *
131
- ca_bitarray_func_ptr_at_addr (void *ap, int32_t addr)
131
+ ca_bitarray_func_ptr_at_addr (void *ap, ca_size_t addr)
132
132
  {
133
133
  CABitarray *ca = (CABitarray *) ap;
134
134
  if ( ! ca->ptr ) {
@@ -141,7 +141,7 @@ ca_bitarray_func_ptr_at_addr (void *ap, int32_t addr)
141
141
  }
142
142
 
143
143
  static char *
144
- ca_bitarray_func_ptr_at_index (void *ap, int32_t *idx)
144
+ ca_bitarray_func_ptr_at_index (void *ap, ca_size_t *idx)
145
145
  {
146
146
  CABitarray *ca = (CABitarray *) ap;
147
147
  if ( ! ca->ptr ) {
@@ -154,13 +154,13 @@ ca_bitarray_func_ptr_at_index (void *ap, int32_t *idx)
154
154
  }
155
155
 
156
156
  static void
157
- ca_bitarray_func_fetch_index (void *ap, int32_t *idx, void *ptr)
157
+ ca_bitarray_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
158
158
  {
159
159
  CABitarray *ca = (CABitarray *) ap;
160
- int32_t bytes = ca->parent->bytes;
161
- int32_t offset = idx[ca->rank-1];
162
- int32_t major, minor;
163
-
160
+ ca_size_t bytes = ca->parent->bytes;
161
+ ca_size_t offset = idx[ca->rank-1];
162
+ ca_size_t major, minor;
163
+
164
164
  if ( ca_endian == CA_BIG_ENDIAN &&
165
165
  ca->parent->bytes != 1 &&
166
166
  ( ! ca_is_fixlen_type(ca->parent) ) ) {
@@ -186,13 +186,13 @@ ca_bitarray_func_fetch_index (void *ap, int32_t *idx, void *ptr)
186
186
  }
187
187
 
188
188
  static void
189
- ca_bitarray_func_store_index (void *ap, int32_t *idx, void *ptr)
189
+ ca_bitarray_func_store_index (void *ap, ca_size_t *idx, void *ptr)
190
190
  {
191
191
  CABitarray *ca = (CABitarray *) ap;
192
192
  uint8_t test = *(uint8_t *) ptr;
193
- int32_t offset = idx[ca->rank-1];
194
- int32_t bytes = ca->parent->bytes;
195
- int32_t major, minor;
193
+ ca_size_t offset = idx[ca->rank-1];
194
+ ca_size_t bytes = ca->parent->bytes;
195
+ ca_size_t major, minor;
196
196
 
197
197
  if ( ca_endian == CA_BIG_ENDIAN &&
198
198
  ca->parent->bytes != 1 &&
@@ -307,8 +307,8 @@ static void
307
307
  ca_bitarray_func_create_mask (void *ap)
308
308
  {
309
309
  CABitarray *ca = (CABitarray *) ap;
310
- int32_t count[CA_RANK_MAX];
311
- int32_t i;
310
+ ca_size_t count[CA_RANK_MAX];
311
+ int8_t i;
312
312
 
313
313
  for (i=0; i<ca->rank-1; i++) {
314
314
  count[i] = 0;
@@ -354,9 +354,9 @@ ca_bitarray_attach (CABitarray *ca)
354
354
  uint8_t *q = (uint8_t *)ca_ptr_at_addr(ca->parent, 0);
355
355
  uint8_t *r;
356
356
  uint8_t rr;
357
- int32_t elements = ca->parent->elements;
358
- int32_t bytes = ca->parent->bytes;
359
- int32_t n, m;
357
+ ca_size_t elements = ca->parent->elements;
358
+ ca_size_t bytes = ca->parent->bytes;
359
+ ca_size_t n, m;
360
360
  if ( ca_endian == CA_BIG_ENDIAN &&
361
361
  ca->parent->bytes != 1 &&
362
362
  ( ! ca_is_fixlen_type(ca->parent) ) ) {
@@ -401,9 +401,9 @@ ca_bitarray_sync (CABitarray *ca)
401
401
  boolean8_t *p = (boolean8_t *)ca_ptr_at_addr(ca, 0);
402
402
  uint8_t *q = (uint8_t *)ca_ptr_at_addr(ca->parent, 0);
403
403
  uint8_t *r;
404
- int32_t elements = ca->parent->elements;
405
- int32_t bytes = ca->parent->bytes;
406
- int32_t n, m, i;
404
+ ca_size_t elements = ca->parent->elements;
405
+ ca_size_t bytes = ca->parent->bytes;
406
+ ca_size_t n, m, i;
407
407
  if ( ca_endian == CA_BIG_ENDIAN &&
408
408
  ca->parent->bytes != 1 &&
409
409
  ( ! ca_is_fixlen_type(ca->parent) ) ) {
data/ca_obj_bitfield.c CHANGED
@@ -17,18 +17,18 @@ typedef struct {
17
17
  int8_t data_type;
18
18
  int8_t rank;
19
19
  int32_t flags;
20
- int32_t bytes;
21
- int32_t elements;
22
- int32_t *dim;
20
+ ca_size_t bytes;
21
+ ca_size_t elements;
22
+ ca_size_t *dim;
23
23
  char *ptr;
24
24
  CArray *mask;
25
25
  CArray *parent;
26
26
  uint32_t attach;
27
27
  uint8_t nosync;
28
28
  /* -------------*/
29
- int32_t byte_offset;
30
- int32_t bit_offset;
31
- uint32_t bit_mask;
29
+ ca_size_t byte_offset;
30
+ ca_size_t bit_offset;
31
+ uint64_t bit_mask;
32
32
  } CABitfield;
33
33
 
34
34
  static int8_t CA_OBJ_BITFIELD;
@@ -40,12 +40,12 @@ static VALUE rb_cCABitfield;
40
40
  end
41
41
  */
42
42
 
43
- static int
44
- bitfield_bitlen (uint32_t bit_mask, int32_t bytes)
43
+ static ca_size_t
44
+ bitfield_bitlen (uint64_t bit_mask, ca_size_t bytes)
45
45
  {
46
- int bitsize = bytes * 8;
47
- int count = 0;
48
- int i;
46
+ ca_size_t bitsize = bytes * 8;
47
+ ca_size_t count = 0;
48
+ ca_size_t i;
49
49
  for (i=0; i<bitsize; i++) {
50
50
  if ( ( bit_mask >> i ) & 1 ) {
51
51
  count++;
@@ -55,12 +55,12 @@ bitfield_bitlen (uint32_t bit_mask, int32_t bytes)
55
55
  }
56
56
 
57
57
  static void
58
- bitfield_fetch(char *dst, int dbytes,
59
- char *src, int sbytes,
60
- int32_t byte_offset, int32_t bit_offset, uint32_t bit_mask,
61
- int32_t elements)
58
+ bitfield_fetch(char *dst, ca_size_t dbytes,
59
+ char *src, ca_size_t sbytes,
60
+ ca_size_t byte_offset, ca_size_t bit_offset, uint64_t bit_mask,
61
+ ca_size_t elements)
62
62
  {
63
- int k;
63
+ ca_size_t k;
64
64
  switch ( dbytes ) {
65
65
  case 1: {
66
66
  char *p;
@@ -128,12 +128,12 @@ bitfield_fetch(char *dst, int dbytes,
128
128
  }
129
129
 
130
130
  static void
131
- bitfield_store(char *src, int sbytes,
132
- char *dst, int dbytes,
133
- int32_t byte_offset, int32_t bit_offset, uint32_t bit_mask,
134
- int32_t elements)
131
+ bitfield_store(char *src, ca_size_t sbytes,
132
+ char *dst, ca_size_t dbytes,
133
+ ca_size_t byte_offset, ca_size_t bit_offset, uint64_t bit_mask,
134
+ ca_size_t elements)
135
135
  {
136
- int k;
136
+ ca_size_t k;
137
137
  switch ( dbytes ) {
138
138
  case 1: {
139
139
  char *q;
@@ -209,16 +209,16 @@ bitfield_store(char *src, int sbytes,
209
209
 
210
210
  int
211
211
  ca_bitfield_setup (CABitfield *ca, CArray *parent,
212
- int offset, int bitlen)
212
+ ca_size_t offset, ca_size_t bitlen)
213
213
  {
214
214
  int8_t rank;
215
215
  int8_t data_type;
216
- int32_t bytes = 0, elements;
217
- int bitsize;
218
- int32_t byte_offset;
219
- int32_t bit_offset;
220
- uint32_t bit_mask;
221
- int i;
216
+ ca_size_t bytes = 0, elements;
217
+ ca_size_t bitsize;
218
+ ca_size_t byte_offset;
219
+ ca_size_t bit_offset;
220
+ uint64_t bit_mask;
221
+ ca_size_t i;
222
222
 
223
223
  /* check arguments */
224
224
 
@@ -298,7 +298,7 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
298
298
  ca->elements = elements;
299
299
  ca->ptr = NULL;
300
300
  ca->mask = NULL;
301
- ca->dim = ALLOC_N(int32_t, rank);
301
+ ca->dim = ALLOC_N(ca_size_t, rank);
302
302
 
303
303
  ca->parent = parent;
304
304
  ca->attach = 0;
@@ -308,7 +308,7 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
308
308
  ca->bit_offset = bit_offset;
309
309
  ca->bit_mask = bit_mask;
310
310
 
311
- memcpy(ca->dim, parent->dim, rank * sizeof(int32_t));
311
+ memcpy(ca->dim, parent->dim, rank * sizeof(ca_size_t));
312
312
 
313
313
  if ( ca_has_mask(parent) ) {
314
314
  ca_create_mask(ca);
@@ -318,7 +318,7 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
318
318
  }
319
319
 
320
320
  CABitfield *
321
- ca_bitfield_new (CArray *parent, int offset, int bitlen)
321
+ ca_bitfield_new (CArray *parent, ca_size_t offset, ca_size_t bitlen)
322
322
  {
323
323
  CABitfield *ca = ALLOC(CABitfield);
324
324
  ca_bitfield_setup(ca, parent, offset, bitlen);
@@ -352,7 +352,7 @@ ca_bitfield_func_clone (void *ap)
352
352
  }
353
353
 
354
354
  static char *
355
- ca_bitfield_func_ptr_at_addr (void *ap, int32_t addr)
355
+ ca_bitfield_func_ptr_at_addr (void *ap, ca_size_t addr)
356
356
  {
357
357
  CABitfield *ca = (CABitfield *) ap;
358
358
  if ( ! ca->ptr ) {
@@ -365,7 +365,7 @@ ca_bitfield_func_ptr_at_addr (void *ap, int32_t addr)
365
365
  }
366
366
 
367
367
  static char *
368
- ca_bitfield_func_ptr_at_index (void *ap, int32_t *idx)
368
+ ca_bitfield_func_ptr_at_index (void *ap, ca_size_t *idx)
369
369
  {
370
370
  CABitfield *ca = (CABitfield *) ap;
371
371
  if ( ! ca->ptr ) {
@@ -378,7 +378,7 @@ ca_bitfield_func_ptr_at_index (void *ap, int32_t *idx)
378
378
  }
379
379
 
380
380
  static void
381
- ca_bitfield_func_fetch_index (void *ap, int32_t *idx, void *ptr)
381
+ ca_bitfield_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
382
382
  {
383
383
  CABitfield *ca = (CABitfield *) ap;
384
384
  char *v = xmalloc(ca->parent->bytes);
@@ -390,7 +390,7 @@ ca_bitfield_func_fetch_index (void *ap, int32_t *idx, void *ptr)
390
390
  }
391
391
 
392
392
  static void
393
- ca_bitfield_func_store_index (void *ap, int32_t *idx, void *ptr)
393
+ ca_bitfield_func_store_index (void *ap, ca_size_t *idx, void *ptr)
394
394
  {
395
395
  CABitfield *ca = (CABitfield *) ap;
396
396
  char *v = xmalloc(ca->parent->bytes);
@@ -529,12 +529,12 @@ static void
529
529
  ca_bitfield_fill (CABitfield *ca, char *ptr)
530
530
  {
531
531
  char *q = ca->parent->ptr;
532
- int32_t bytesp = ca->bytes;
533
- int32_t bytesq = ca->parent->bytes;
534
- int32_t byte_offset = ca->byte_offset;
535
- int32_t bit_offset = ca->bit_offset;
536
- uint32_t bit_mask = ca->bit_mask;
537
- int32_t i;
532
+ ca_size_t bytesp = ca->bytes;
533
+ ca_size_t bytesq = ca->parent->bytes;
534
+ ca_size_t byte_offset = ca->byte_offset;
535
+ ca_size_t bit_offset = ca->bit_offset;
536
+ uint64_t bit_mask = ca->bit_mask;
537
+ ca_size_t i;
538
538
 
539
539
  for (i=0; i<ca->elements; i++) {
540
540
  bitfield_store(ptr, bytesp, q, bytesq,
@@ -546,7 +546,7 @@ ca_bitfield_fill (CABitfield *ca, char *ptr)
546
546
  /* ------------------------------------------------------------------- */
547
547
 
548
548
  VALUE
549
- rb_ca_bitfield_new (VALUE cary, int offset, int bitlen)
549
+ rb_ca_bitfield_new (VALUE cary, ca_size_t offset, ca_size_t bitlen)
550
550
  {
551
551
  volatile VALUE obj;
552
552
  CArray *parent;
@@ -571,10 +571,11 @@ rb_ca_bitfield (int argc, VALUE *argv, VALUE self)
571
571
  {
572
572
  volatile VALUE rrange, rtype;
573
573
  CArray *ca;
574
- int offset, bitlen, step, data_type = CA_NONE;
575
- int bitsize;
574
+ ca_size_t offset, bitlen, step;
575
+ int data_type = CA_NONE;
576
+ ca_size_t bitsize;
576
577
 
577
- rb_scan_args(argc, argv, "11", &rrange, &rtype);
578
+ rb_scan_args(argc, argv, "11", (VALUE *) &rrange, (VALUE *) &rtype);
578
579
 
579
580
  Data_Get_Struct(self, CArray, ca);
580
581
 
data/ca_obj_block.c CHANGED
@@ -20,13 +20,13 @@ VALUE rb_cCABlock;
20
20
  */
21
21
 
22
22
  static int
23
- ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, int32_t *dim,
24
- int32_t *start, int32_t *step, int32_t *count, int32_t offset)
23
+ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, ca_size_t *dim,
24
+ ca_size_t *start, ca_size_t *step, ca_size_t *count, ca_size_t offset)
25
25
  {
26
26
  int8_t data_type;
27
27
  int8_t maxdim_index;
28
- int32_t maxdim_step, maxdim_step0;
29
- int32_t elements, bytes;
28
+ ca_size_t maxdim_step, maxdim_step0;
29
+ ca_size_t elements, bytes;
30
30
  int i;
31
31
 
32
32
  data_type = parent->data_type;
@@ -67,10 +67,10 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, int32_t *dim,
67
67
  ca->attach = 0;
68
68
  ca->nosync = 0;
69
69
  ca->offset = offset;
70
- ca->start = ALLOC_N(int32_t, rank);
71
- ca->step = ALLOC_N(int32_t, rank);
72
- ca->count = ALLOC_N(int32_t, rank);
73
- ca->size0 = ALLOC_N(int32_t, rank);
70
+ ca->start = ALLOC_N(ca_size_t, rank);
71
+ ca->step = ALLOC_N(ca_size_t, rank);
72
+ ca->count = ALLOC_N(ca_size_t, rank);
73
+ ca->size0 = ALLOC_N(ca_size_t, rank);
74
74
 
75
75
  ca->maxdim_index = maxdim_index;
76
76
  ca->maxdim_step = maxdim_step;
@@ -80,10 +80,10 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, int32_t *dim,
80
80
 
81
81
  ca->dim = ca->count; /* ca->dim should not be free */
82
82
 
83
- memcpy(ca->start, start, rank * sizeof(int32_t));
84
- memcpy(ca->step, step, rank * sizeof(int32_t));
85
- memcpy(ca->count, count, rank * sizeof(int32_t));
86
- memcpy(ca->size0, dim, rank * sizeof(int32_t));
83
+ memcpy(ca->start, start, rank * sizeof(ca_size_t));
84
+ memcpy(ca->step, step, rank * sizeof(ca_size_t));
85
+ memcpy(ca->count, count, rank * sizeof(ca_size_t));
86
+ memcpy(ca->size0, dim, rank * sizeof(ca_size_t));
87
87
 
88
88
  if ( ca_has_mask(parent) ) {
89
89
  ca_create_mask(ca);
@@ -93,8 +93,8 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, int32_t *dim,
93
93
  }
94
94
 
95
95
  CABlock *
96
- ca_block_new (CArray *parent, int8_t rank, int32_t *dim,
97
- int32_t *start, int32_t *step, int32_t *count, int32_t offset)
96
+ ca_block_new (CArray *parent, int8_t rank, ca_size_t *dim,
97
+ ca_size_t *start, ca_size_t *step, ca_size_t *count, ca_size_t offset)
98
98
  {
99
99
  CABlock *ca = ALLOC(CABlock);
100
100
  ca_block_setup(ca, parent, rank, dim, start, step, count, offset);
@@ -131,24 +131,24 @@ ca_block_func_clone (void *ap)
131
131
  }
132
132
 
133
133
  static char *
134
- ca_block_func_ptr_at_index (void *ap, int32_t *idx) ;
134
+ ca_block_func_ptr_at_index (void *ap, ca_size_t *idx) ;
135
135
 
136
136
  static char *
137
- ca_block_func_ptr_at_addr (void *ap, int32_t addr)
137
+ ca_block_func_ptr_at_addr (void *ap, ca_size_t addr)
138
138
  {
139
139
  CABlock *ca = (CABlock *) ap;
140
140
  if ( ca->ptr ) {
141
141
  return ca->ptr + ca->bytes * addr;
142
142
  }
143
143
  else {
144
- int32_t idx[CA_RANK_MAX];
144
+ ca_size_t idx[CA_RANK_MAX];
145
145
  ca_addr2index(ca, addr, idx);
146
146
  return ca_block_func_ptr_at_index(ca, idx);
147
147
  }
148
148
  }
149
149
 
150
150
  static char *
151
- ca_block_func_ptr_at_index (void *ap, int32_t *idx)
151
+ ca_block_func_ptr_at_index (void *ap, ca_size_t *idx)
152
152
  {
153
153
  CABlock *ca = (CABlock *) ap;
154
154
 
@@ -156,10 +156,11 @@ ca_block_func_ptr_at_index (void *ap, int32_t *idx)
156
156
  return ca_array_func_ptr_at_index(ca, idx);
157
157
  }
158
158
  else {
159
- int32_t *start = ca->start;
160
- int32_t *step = ca->step;
161
- int32_t *size0 = ca->size0;
162
- int32_t n, i;
159
+ ca_size_t *start = ca->start;
160
+ ca_size_t *step = ca->step;
161
+ ca_size_t *size0 = ca->size0;
162
+ int8_t i;
163
+ ca_size_t n;
163
164
  n = start[0] + idx[0]*step[0];
164
165
  for (i=1; i<ca->rank; i++) {
165
166
  n *= size0[i];
@@ -176,13 +177,14 @@ ca_block_func_ptr_at_index (void *ap, int32_t *idx)
176
177
  }
177
178
 
178
179
  static void
179
- ca_block_func_fetch_index (void *ap, int32_t *idx, void *ptr)
180
+ ca_block_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
180
181
  {
181
182
  CABlock *ca = (CABlock *) ap;
182
- int32_t *start = ca->start;
183
- int32_t *step = ca->step;
184
- int32_t *size0 = ca->size0;
185
- int32_t n, i;
183
+ ca_size_t *start = ca->start;
184
+ ca_size_t *step = ca->step;
185
+ ca_size_t *size0 = ca->size0;
186
+ int8_t i;
187
+ ca_size_t n;
186
188
  n = start[0] + idx[0]*step[0];
187
189
  for (i=1; i<ca->rank; i++) {
188
190
  n *= size0[i];
@@ -193,13 +195,14 @@ ca_block_func_fetch_index (void *ap, int32_t *idx, void *ptr)
193
195
  }
194
196
 
195
197
  static void
196
- ca_block_func_store_index (void *ap, int32_t *idx, void *ptr)
198
+ ca_block_func_store_index (void *ap, ca_size_t *idx, void *ptr)
197
199
  {
198
200
  CABlock *ca = (CABlock *) ap;
199
- int32_t *start = ca->start;
200
- int32_t *step = ca->step;
201
- int32_t *size0 = ca->size0;
202
- int32_t n, i;
201
+ ca_size_t *start = ca->start;
202
+ ca_size_t *step = ca->step;
203
+ ca_size_t *size0 = ca->size0;
204
+ int8_t i;
205
+ ca_size_t n;
203
206
  n = start[0] + idx[0]*step[0];
204
207
  for (i=1; i<ca->rank; i++) {
205
208
  n *= size0[i];
@@ -317,8 +320,8 @@ ca_operation_function_t ca_block_func = {
317
320
  /* ------------------------------------------------------------------- */
318
321
 
319
322
  VALUE
320
- rb_ca_block_new (VALUE cary, int8_t rank, int32_t *dim,
321
- int32_t *start, int32_t *step, int32_t *count, int32_t offset)
323
+ rb_ca_block_new (VALUE cary, int8_t rank, ca_size_t *dim,
324
+ ca_size_t *start, ca_size_t *step, ca_size_t *count, ca_size_t offset)
322
325
  {
323
326
  volatile VALUE obj;
324
327
  CArray *parent;
@@ -343,10 +346,10 @@ static void *mfill_step(void *dest,
343
346
  size_t bytes, size_t n, size_t dstep, const void *src);
344
347
 
345
348
  static void
346
- ca_block_attach_loop2 (CABlock *ca, int8_t level, int32_t saddr, int32_t saddr0)
349
+ ca_block_attach_loop2 (CABlock *ca, int8_t level, ca_size_t saddr, ca_size_t saddr0)
347
350
  {
348
- int32_t count = ca->count[level];
349
- int32_t addr, addr0, i;
351
+ ca_size_t count = ca->count[level];
352
+ ca_size_t addr, addr0, i;
350
353
 
351
354
  if ( level == ca->rank - 1 ) {
352
355
  if ( ca->parent->ptr ) {
@@ -378,10 +381,10 @@ ca_block_attach_loop2 (CABlock *ca, int8_t level, int32_t saddr, int32_t saddr0)
378
381
  }
379
382
 
380
383
  static void
381
- ca_block_attach_loop (CABlock *ca, int32_t level, int32_t saddr, int32_t saddr0)
384
+ ca_block_attach_loop (CABlock *ca, ca_size_t level, ca_size_t saddr, ca_size_t saddr0)
382
385
  {
383
- int32_t count = ca->count[level];
384
- int32_t addr, addr0, i;
386
+ ca_size_t count = ca->count[level];
387
+ ca_size_t addr, addr0, i;
385
388
 
386
389
  if ( level == ca->rank - 1 ) {
387
390
  if ( level == ca->maxdim_index ) {
@@ -395,8 +398,8 @@ ca_block_attach_loop (CABlock *ca, int32_t level, int32_t saddr, int32_t saddr0)
395
398
  char *p = ca_ptr_at_addr(ca, saddr* ca->dim[level]);
396
399
  char *q = ca_ptr_at_addr(ca->parent,
397
400
  saddr0*ca->size0[level]+ca->start[level]+ca->offset);
398
- int32_t pstep = ca->bytes;
399
- int32_t qstep = ca->bytes*ca->step[level];
401
+ ca_size_t pstep = ca->bytes;
402
+ ca_size_t qstep = ca->bytes*ca->step[level];
400
403
  for (i=0; i<count; i++) {
401
404
  mcopy_step(p,
402
405
  q,
@@ -427,7 +430,7 @@ ca_block_attach_loop (CABlock *ca, int32_t level, int32_t saddr, int32_t saddr0)
427
430
  static void
428
431
  ca_block_attach (CABlock *ca)
429
432
  {
430
- int32_t addr = 0, addr0 = 0;
433
+ ca_size_t addr = 0, addr0 = 0;
431
434
  if ( ca->rank <= 2 ) {
432
435
  ca_block_attach_loop2(ca, 0, addr, addr0);
433
436
  }
@@ -437,10 +440,10 @@ ca_block_attach (CABlock *ca)
437
440
  }
438
441
 
439
442
  static void
440
- ca_block_sync_loop2 (CABlock *ca, int32_t level, int32_t saddr, int32_t saddr0)
443
+ ca_block_sync_loop2 (CABlock *ca, int8_t level, ca_size_t saddr, ca_size_t saddr0)
441
444
  {
442
- int32_t count = ca->count[level];
443
- int32_t addr, addr0, i;
445
+ ca_size_t count = ca->count[level];
446
+ ca_size_t addr, addr0, i;
444
447
 
445
448
  if ( level == ca->rank - 1 ) {
446
449
  if ( ca->parent->ptr ) {
@@ -471,10 +474,10 @@ ca_block_sync_loop2 (CABlock *ca, int32_t level, int32_t saddr, int32_t saddr0)
471
474
  }
472
475
 
473
476
  static void
474
- ca_block_sync_loop (CABlock *ca, int32_t level, int32_t saddr, int32_t saddr0)
477
+ ca_block_sync_loop (CABlock *ca, int8_t level, ca_size_t saddr, ca_size_t saddr0)
475
478
  {
476
- int32_t count = ca->count[level];
477
- int32_t addr, addr0, i;
479
+ ca_size_t count = ca->count[level];
480
+ ca_size_t addr, addr0, i;
478
481
 
479
482
  if ( level == ca->rank - 1 ) {
480
483
  if ( level == ca->maxdim_index ) {
@@ -516,7 +519,7 @@ ca_block_sync_loop (CABlock *ca, int32_t level, int32_t saddr, int32_t saddr0)
516
519
  static void
517
520
  ca_block_sync (CABlock *cb)
518
521
  {
519
- int32_t addr = 0, addr0 = 0;
522
+ ca_size_t addr = 0, addr0 = 0;
520
523
  if ( cb->rank <= 2 ) {
521
524
  ca_block_sync_loop2(cb, 0, addr, addr0);
522
525
  }
@@ -526,10 +529,10 @@ ca_block_sync (CABlock *cb)
526
529
  }
527
530
 
528
531
  static void
529
- ca_block_fill_loop2 (CABlock *ca, int32_t level, int32_t saddr, char *val)
532
+ ca_block_fill_loop2 (CABlock *ca, int8_t level, ca_size_t saddr, char *val)
530
533
  {
531
- int32_t count = ca->count[level];
532
- int32_t addr, i;
534
+ ca_size_t count = ca->count[level];
535
+ ca_size_t addr, i;
533
536
  if ( level == ca->rank - 1 ) {
534
537
  addr = saddr * ca->dim[level];
535
538
  mfill_step(ca_ptr_at_addr(ca, addr),
@@ -544,10 +547,10 @@ ca_block_fill_loop2 (CABlock *ca, int32_t level, int32_t saddr, char *val)
544
547
  }
545
548
 
546
549
  static void
547
- ca_block_fill_loop (CABlock *ca, int32_t level, int32_t saddr, char *val)
550
+ ca_block_fill_loop (CABlock *ca, int8_t level, ca_size_t saddr, char *val)
548
551
  {
549
- int32_t count = ca->count[level];
550
- int32_t addr, i;
552
+ ca_size_t count = ca->count[level];
553
+ ca_size_t addr, i;
551
554
  if ( level == ca->rank - 1 ) {
552
555
  if ( level == ca->maxdim_index ) {
553
556
  addr = saddr * ca->dim[level];
@@ -582,7 +585,7 @@ ca_block_fill_loop (CABlock *ca, int32_t level, int32_t saddr, char *val)
582
585
  static void
583
586
  ca_block_fill (CABlock *ca, char *val)
584
587
  {
585
- int32_t addr = 0;
588
+ ca_size_t addr = 0;
586
589
  if ( ca->rank <= 2 ) {
587
590
  ca_block_fill_loop2(ca, 0, addr, val);
588
591
  }
@@ -605,7 +608,7 @@ mcopy_step (void *dest, const void *src,
605
608
  int *dp = (int*) dest;
606
609
  char *scp;
607
610
  char *dcp;
608
- int32_t i;
611
+ ca_size_t i;
609
612
  for (i=words; i; i--) {
610
613
  *dp++ = *sp++;
611
614
  }
@@ -698,8 +701,8 @@ static VALUE
698
701
  rb_cb_initialize_copy (VALUE self, VALUE other)
699
702
  {
700
703
  CABlock *ca, *cs;
701
- int32_t shrink[CA_RANK_MAX];
702
- int32_t i;
704
+ ca_size_t shrink[CA_RANK_MAX];
705
+ int8_t i;
703
706
 
704
707
  Data_Get_Struct(self, CABlock, ca);
705
708
  Data_Get_Struct(other, CABlock, cs);
@@ -723,7 +726,7 @@ rb_cb_initialize_copy (VALUE self, VALUE other)
723
726
  { \
724
727
  volatile VALUE ary; \
725
728
  CABlock *cb; \
726
- int32_t i; \
729
+ int8_t i; \
727
730
  Data_Get_Struct(self, CABlock, cb); \
728
731
  ary = rb_ary_new2(cb->rank); \
729
732
  for (i=0; i<cb->rank; i++) { \
@@ -757,7 +760,7 @@ rb_cb_offset (VALUE self)
757
760
  {
758
761
  CABlock *cb;
759
762
  Data_Get_Struct(self, CABlock, cb);
760
- return INT2NUM(cb->offset);
763
+ return SIZE2NUM(cb->offset);
761
764
  }
762
765
 
763
766
  /* rdoc:
@@ -771,8 +774,9 @@ static VALUE
771
774
  rb_cb_idx2addr0 (int argc, VALUE *argv, VALUE self)
772
775
  {
773
776
  CABlock *cb;
774
- int32_t addr;
775
- int32_t i, idxi;
777
+ ca_size_t addr;
778
+ int8_t i;
779
+ ca_size_t idxi;
776
780
 
777
781
  Data_Get_Struct(self, CABlock, cb);
778
782
 
@@ -783,12 +787,12 @@ rb_cb_idx2addr0 (int argc, VALUE *argv, VALUE self)
783
787
 
784
788
  addr = 0;
785
789
  for (i=0; i<cb->rank; i++) {
786
- idxi = NUM2INT(argv[i]);
790
+ idxi = NUM2SIZE(argv[i]);
787
791
  CA_CHECK_INDEX(idxi, cb->dim[i]);
788
792
  addr = cb->size0[i] * addr + cb->start[i] + idxi * cb->step[i];
789
793
  }
790
794
 
791
- return INT2NUM(addr + cb->offset);
795
+ return SIZE2NUM(addr + cb->offset);
792
796
  }
793
797
 
794
798
  /* rdoc:
@@ -802,9 +806,9 @@ static VALUE
802
806
  rb_cb_addr2addr0 (VALUE self, VALUE raddr)
803
807
  {
804
808
  CABlock *cb;
805
- int32_t addr = NUM2INT(raddr);
806
- int32_t idx[CA_RANK_MAX];
807
- int32_t i;
809
+ ca_size_t addr = NUM2SIZE(raddr);
810
+ ca_size_t idx[CA_RANK_MAX];
811
+ int8_t i;
808
812
 
809
813
  Data_Get_Struct(self, CABlock, cb);
810
814
 
@@ -816,7 +820,7 @@ rb_cb_addr2addr0 (VALUE self, VALUE raddr)
816
820
  addr += cb->start[i] + idx[i] * cb->step[i];
817
821
  }
818
822
 
819
- return INT2NUM(addr + cb->offset);
823
+ return SIZE2NUM(addr + cb->offset);
820
824
  }
821
825
 
822
826
 
@@ -831,7 +835,8 @@ static VALUE
831
835
  rb_cb_move (int argc, VALUE *argv, VALUE self)
832
836
  {
833
837
  CABlock *cb;
834
- int32_t start, i;
838
+ ca_size_t start;
839
+ int8_t i;
835
840
 
836
841
  Data_Get_Struct(self, CABlock, cb);
837
842
 
@@ -842,7 +847,7 @@ rb_cb_move (int argc, VALUE *argv, VALUE self)
842
847
  ca_update_mask(cb);
843
848
 
844
849
  for (i=0; i<cb->rank; i++) {
845
- start = NUM2LONG(argv[i]);
850
+ start = NUM2SIZE(argv[i]);
846
851
  if ( start < 0 ) {
847
852
  start += cb->size0[i];
848
853
  }