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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86cecb4433272ac917562bf243d29b1e8aa3a29b
4
- data.tar.gz: 36bb32592e1397ad672a64ca422e6c5e061fda64
3
+ metadata.gz: a9d973497b72643e3eff0ba9fe6f27d1c1551b30
4
+ data.tar.gz: 4d498ed02138ef9003d36ffa9b22e1e1d970923b
5
5
  SHA512:
6
- metadata.gz: 4ac1417a702843bc61302022870872bbb353e8f0cd3408cd3d152bbb77cd08d62f78566f28a1f7b1d589624eb539322d24d94222435dad3defd741ea9d2b39e8
7
- data.tar.gz: ad3f7f25ff4b2bd8122b36ba97d93b0b09c82298b729aa83c8647fa3a90380ed7c8fe4566023849542acb0772bd105197117a9c15184dfee6dbe9161e87a0b61
6
+ metadata.gz: 79ed70d463d345e8ddec07d9742054bd85d9fcaf4645d4f9f40ee5f872ce85b99b5cc92e5743ca2b3949cf530497762d45d1651ba365e22024a64819ea102b83
7
+ data.tar.gz: de527fdb98be83795c552c69fe350581f0b4773bff013a5d68947c5fb46305a369d48cba9aedeaa76b426bb372c048f8433a6f4a2969bc7f0a99b9ef34371d75
data/Gemfile CHANGED
@@ -4,6 +4,5 @@ source "https://rubygems.org"
4
4
  # gem "rails"
5
5
  gem "narray"
6
6
  gem "narray_miss"
7
- gem "axlsx"
8
7
  gem "spreadsheet"
9
8
  gem "sqlite3"
data/ca_iter_block.c CHANGED
@@ -25,9 +25,9 @@ typedef struct {
25
25
  int8_t data_type;
26
26
  int8_t rank;
27
27
  int32_t flags;
28
- int32_t bytes;
29
- int32_t elements;
30
- int32_t *dim;
28
+ ca_size_t bytes;
29
+ ca_size_t elements;
30
+ ca_size_t *dim;
31
31
  char *ptr;
32
32
  CArray *mask;
33
33
  CArray *parent;
@@ -35,24 +35,24 @@ typedef struct {
35
35
  uint8_t nosync;
36
36
  // ----------
37
37
  int8_t maxdim_index;
38
- int32_t maxdim_step;
39
- int32_t maxdim_step0;
40
- int32_t offset;
41
- int32_t *start;
42
- int32_t *step;
43
- int32_t *count;
44
- int32_t *size0;
38
+ ca_size_t maxdim_step;
39
+ ca_size_t maxdim_step0;
40
+ ca_size_t offset;
41
+ ca_size_t *start;
42
+ ca_size_t *step;
43
+ ca_size_t *count;
44
+ ca_size_t *size0;
45
45
  } CABlock; // 68 + 20*(rank) (bytes)
46
46
  */
47
47
 
48
48
  typedef struct {
49
49
  int8_t rank;
50
- int32_t dim[CA_RANK_MAX];
50
+ ca_size_t dim[CA_RANK_MAX];
51
51
  CArray *reference;
52
- CArray * (*kernel_at_addr)(void *, int32_t, CArray *);
53
- CArray * (*kernel_at_index)(void *, int32_t *, CArray *);
54
- CArray * (*kernel_move_to_addr)(void *, int32_t, CArray *);
55
- CArray * (*kernel_move_to_index)(void *, int32_t *, CArray *);
52
+ CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
53
+ CArray * (*kernel_at_index)(void *, ca_size_t *, CArray *);
54
+ CArray * (*kernel_move_to_addr)(void *, ca_size_t, CArray *);
55
+ CArray * (*kernel_move_to_index)(void *, ca_size_t *, CArray *);
56
56
  /* ----------- */
57
57
  CABlock *kernel;
58
58
  } CABlockIterator;
@@ -60,11 +60,12 @@ typedef struct {
60
60
  /* ----------------------------------------------------------------- */
61
61
 
62
62
  static CArray *
63
- ca_bi_kernel_at_index (void *it, int32_t *idx, CArray *ref)
63
+ ca_bi_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
64
64
  {
65
65
  CABlockIterator *bit = (CABlockIterator *) it;
66
66
  CABlock *kernel;
67
- int32_t i, j;
67
+ int8_t i;
68
+ ca_size_t j;
68
69
 
69
70
  if ( ref == bit->reference ) {
70
71
  kernel = (CABlock *)ca_clone(bit->kernel);
@@ -92,12 +93,12 @@ ca_bi_kernel_at_index (void *it, int32_t *idx, CArray *ref)
92
93
  }
93
94
 
94
95
  static CArray *
95
- ca_bi_kernel_at_addr (void *it, int32_t addr, CArray *ref)
96
+ ca_bi_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
96
97
  {
97
98
  CABlockIterator *bit = (CABlockIterator *) it;
98
- int32_t *dim = bit->dim;
99
- int32_t idx[CA_RANK_MAX];
100
- int32_t i;
99
+ ca_size_t *dim = bit->dim;
100
+ ca_size_t idx[CA_RANK_MAX];
101
+ int8_t i;
101
102
  for (i=bit->rank-1; i>=0; i--) {
102
103
  idx[i] = addr % dim[i];
103
104
  addr /= dim[i];
@@ -107,11 +108,12 @@ ca_bi_kernel_at_addr (void *it, int32_t addr, CArray *ref)
107
108
 
108
109
 
109
110
  static CArray *
110
- ca_bi_kernel_move_to_index (void *it, int32_t *idx, CArray *kern)
111
+ ca_bi_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
111
112
  {
112
113
  CABlockIterator *bit = (CABlockIterator *) it;
113
114
  CABlock *kernel = (CABlock *) kern;
114
- int32_t i, j;
115
+ int8_t i;
116
+ ca_size_t j;
115
117
 
116
118
  ca_update_mask(kernel);
117
119
 
@@ -128,12 +130,12 @@ ca_bi_kernel_move_to_index (void *it, int32_t *idx, CArray *kern)
128
130
  }
129
131
 
130
132
  static CArray *
131
- ca_bi_kernel_move_to_addr (void *it, int32_t addr, CArray *ref)
133
+ ca_bi_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
132
134
  {
133
135
  CABlockIterator *bit = (CABlockIterator *) it;
134
- int32_t *dim = bit->dim;
135
- int32_t idx[CA_RANK_MAX];
136
- int32_t i;
136
+ ca_size_t *dim = bit->dim;
137
+ ca_size_t idx[CA_RANK_MAX];
138
+ int8_t i;
137
139
  for (i=bit->rank-1; i>=0; i--) {
138
140
  idx[i] = addr % dim[i];
139
141
  addr /= dim[i];
@@ -147,8 +149,8 @@ ca_bi_setup (VALUE self, VALUE rref, VALUE rker)
147
149
  CABlockIterator *it;
148
150
  CArray *ref;
149
151
  CABlock *ker;
150
- int32_t dim[CA_RANK_MAX];
151
- int32_t i;
152
+ ca_size_t dim[CA_RANK_MAX];
153
+ int8_t i;
152
154
 
153
155
  rker = rb_obj_clone(rker);
154
156
 
@@ -173,7 +175,7 @@ ca_bi_setup (VALUE self, VALUE rref, VALUE rker)
173
175
  }
174
176
 
175
177
  it->rank = ref->rank;
176
- memcpy(it->dim, dim, it->rank * sizeof(int32_t));
178
+ memcpy(it->dim, dim, it->rank * sizeof(ca_size_t));
177
179
  it->reference = ref;
178
180
  it->kernel = ker;
179
181
  it->kernel_at_addr = ca_bi_kernel_at_addr;
data/ca_iter_dimension.c CHANGED
@@ -22,12 +22,12 @@ VALUE rb_cCADimIterator;
22
22
 
23
23
  typedef struct {
24
24
  int8_t rank;
25
- int32_t dim[CA_RANK_MAX];
25
+ ca_size_t dim[CA_RANK_MAX];
26
26
  CArray *reference;
27
- CArray * (*kernel_at_addr)(void *, int32_t, CArray *);
28
- CArray * (*kernel_at_index)(void *, int32_t *, CArray *);
29
- CArray * (*kernel_move_to_addr)(void *, int32_t, CArray *);
30
- CArray * (*kernel_move_to_index)(void *, int32_t *, CArray *);
27
+ CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
28
+ CArray * (*kernel_at_index)(void *, ca_size_t *, CArray *);
29
+ CArray * (*kernel_move_to_addr)(void *, ca_size_t, CArray *);
30
+ CArray * (*kernel_move_to_index)(void *, ca_size_t *, CArray *);
31
31
  /* ----------- */
32
32
  CArray *kernel;
33
33
  int8_t symflag[CA_RANK_MAX];
@@ -37,11 +37,12 @@ typedef struct {
37
37
  /* -------------------------------------------------------------------- */
38
38
 
39
39
  static CArray *
40
- ca_di_kernel_at_index (void *it, int32_t *idx, CArray *ref)
40
+ ca_di_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
41
41
  {
42
42
  CADimIterator *dit = (CADimIterator *)it;
43
43
  CABlock *kernel;
44
- int32_t i, val;
44
+ int8_t i;
45
+ ca_size_t val;
45
46
 
46
47
  if ( ref == dit->reference ) {
47
48
  kernel = ca_clone(dit->kernel);
@@ -70,12 +71,12 @@ ca_di_kernel_at_index (void *it, int32_t *idx, CArray *ref)
70
71
  }
71
72
 
72
73
  static CArray *
73
- ca_di_kernel_at_addr (void *it, int32_t addr, CArray *ref)
74
+ ca_di_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
74
75
  {
75
76
  CADimIterator *dit = (CADimIterator *) it;
76
- int32_t *dim = dit->dim;
77
- int32_t idx[CA_RANK_MAX];
78
- int32_t i;
77
+ ca_size_t *dim = dit->dim;
78
+ ca_size_t idx[CA_RANK_MAX];
79
+ int8_t i;
79
80
  for (i=dit->rank-1; i>=0; i--) {
80
81
  idx[i] = addr % dim[i];
81
82
  addr /= dim[i];
@@ -84,11 +85,12 @@ ca_di_kernel_at_addr (void *it, int32_t addr, CArray *ref)
84
85
  }
85
86
 
86
87
  static CArray *
87
- ca_di_kernel_move_to_index (void *it, int32_t *idx, CArray *kern)
88
+ ca_di_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
88
89
  {
89
90
  CADimIterator *dit = (CADimIterator *)it;
90
91
  CABlock *kernel = (CABlock *) kern;
91
- int32_t i, val;
92
+ int8_t i;
93
+ ca_size_t val;
92
94
 
93
95
  ca_update_mask(kernel);
94
96
 
@@ -106,12 +108,12 @@ ca_di_kernel_move_to_index (void *it, int32_t *idx, CArray *kern)
106
108
  }
107
109
 
108
110
  static CArray *
109
- ca_di_kernel_move_to_addr (void *it, int32_t addr, CArray *ref)
111
+ ca_di_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
110
112
  {
111
113
  CADimIterator *dit = (CADimIterator *) it;
112
- int32_t *dim = dit->dim;
113
- int32_t idx[CA_RANK_MAX];
114
- int32_t i;
114
+ ca_size_t *dim = dit->dim;
115
+ ca_size_t idx[CA_RANK_MAX];
116
+ int8_t i;
115
117
  for (i=dit->rank-1; i>=0; i--) {
116
118
  idx[i] = addr % dim[i];
117
119
  addr /= dim[i];
@@ -157,11 +159,11 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
157
159
 
158
160
  for (i=0; i<info->rank; i++) {
159
161
  if ( info->index_type[i] == CA_IDX_SCALAR ) {
160
- rb_ary_store(rindex, i, INT2NUM(info->index[i].scalar));
162
+ rb_ary_store(rindex, i, SIZE2NUM(info->index[i].scalar));
161
163
  continue; /* escape from j++ */
162
164
  }
163
165
  else if ( info->index_type[i] == CA_IDX_SYMBOL ) {
164
- rb_ary_store(rindex, i, rb_ary_new3(1,INT2NUM(0)));
166
+ rb_ary_store(rindex, i, rb_ary_new3(1, SIZE2NUM(0)));
165
167
  it->symflag[j] = 1;
166
168
  it->symindex[rank] = j;
167
169
  rank++;
@@ -172,9 +174,9 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
172
174
  }
173
175
  else if ( info->index_type[i] == CA_IDX_BLOCK ) {
174
176
  rb_ary_store(rindex, i,
175
- rb_ary_new3(3, INT2NUM(0),
176
- INT2NUM(info->index[i].block.count),
177
- INT2NUM(1)));
177
+ rb_ary_new3(3, SIZE2NUM(0),
178
+ SIZE2NUM(info->index[i].block.count),
179
+ SIZE2NUM(1)));
178
180
  it->symflag[j] = 0;
179
181
  }
180
182
  j++;
data/ca_iter_window.c CHANGED
@@ -14,15 +14,15 @@
14
14
 
15
15
  typedef struct {
16
16
  int8_t rank;
17
- int32_t dim[CA_RANK_MAX];
17
+ ca_size_t dim[CA_RANK_MAX];
18
18
  CArray *reference;
19
- CArray * (*kernel_at_addr)(void *, int32_t, CArray *);
20
- CArray * (*kernel_at_index)(void *, int32_t *, CArray *);
21
- CArray * (*kernel_move_to_addr)(void *, int32_t, CArray *);
22
- CArray * (*kernel_move_to_index)(void *, int32_t *, CArray *);
19
+ CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
20
+ CArray * (*kernel_at_index)(void *, ca_size_t *, CArray *);
21
+ CArray * (*kernel_move_to_addr)(void *, ca_size_t, CArray *);
22
+ CArray * (*kernel_move_to_index)(void *, ca_size_t *, CArray *);
23
23
  /* ----------- */
24
24
  CArray *kernel;
25
- int32_t offset[CA_RANK_MAX];
25
+ ca_size_t offset[CA_RANK_MAX];
26
26
  } CAWindowIterator;
27
27
 
28
28
  VALUE rb_cCAWindowIterator;
@@ -38,15 +38,16 @@ extern int8_t CA_OBJ_WINDOW;
38
38
 
39
39
  CAWindow *
40
40
  ca_window_new (CArray *carray,
41
- int32_t *start, int32_t *count, int8_t bounds, char *fill);
41
+ ca_size_t *start, ca_size_t *count, int8_t bounds, char *fill);
42
42
 
43
43
 
44
44
  static CArray *
45
- ca_vi_kernel_at_index (void *it, int32_t *idx, CArray *ref)
45
+ ca_vi_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
46
46
  {
47
47
  CAWindowIterator *vit = (CAWindowIterator *) it;
48
48
  CAWindow *kernel;
49
- int32_t i, j;
49
+ int8_t i;
50
+ ca_size_t j;
50
51
 
51
52
  if ( ref == vit->reference ) {
52
53
  kernel = (CAWindow *)ca_clone(vit->kernel);
@@ -71,12 +72,12 @@ ca_vi_kernel_at_index (void *it, int32_t *idx, CArray *ref)
71
72
  }
72
73
 
73
74
  static CArray *
74
- ca_vi_kernel_at_addr (void *it, int32_t addr, CArray *ref)
75
+ ca_vi_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
75
76
  {
76
77
  CAWindowIterator *vit = (CAWindowIterator *) it;
77
- int32_t *dim = vit->dim;
78
- int32_t idx[CA_RANK_MAX];
79
- int32_t i;
78
+ ca_size_t *dim = vit->dim;
79
+ ca_size_t idx[CA_RANK_MAX];
80
+ int8_t i;
80
81
  for (i=vit->rank-1; i>=0; i--) {
81
82
  idx[i] = addr % dim[i];
82
83
  addr /= dim[i];
@@ -85,13 +86,14 @@ ca_vi_kernel_at_addr (void *it, int32_t addr, CArray *ref)
85
86
  }
86
87
 
87
88
  static CArray *
88
- ca_vi_kernel_move_to_index (void *it, int32_t *idx, CArray *kern)
89
+ ca_vi_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
89
90
  {
90
91
  CAWindowIterator *vit = (CAWindowIterator *) it;
91
92
  CAWindow *kernel = (CAWindow *) kern;
92
- int32_t *dim = vit->dim;
93
- int32_t *offset = vit->offset;
94
- int32_t i, j;
93
+ ca_size_t *dim = vit->dim;
94
+ ca_size_t *offset = vit->offset;
95
+ int8_t i;
96
+ ca_size_t j;
95
97
 
96
98
  ca_update_mask(kernel);
97
99
 
@@ -108,12 +110,12 @@ ca_vi_kernel_move_to_index (void *it, int32_t *idx, CArray *kern)
108
110
  }
109
111
 
110
112
  static CArray *
111
- ca_vi_kernel_move_to_addr (void *it, int32_t addr, CArray *ref)
113
+ ca_vi_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
112
114
  {
113
115
  CAWindowIterator *vit = (CAWindowIterator *) it;
114
- int32_t *dim = vit->dim;
115
- int32_t idx[CA_RANK_MAX];
116
- int32_t i;
116
+ ca_size_t *dim = vit->dim;
117
+ ca_size_t idx[CA_RANK_MAX];
118
+ int8_t i;
117
119
  for (i=vit->rank-1; i>=0; i--) {
118
120
  idx[i] = addr % dim[i];
119
121
  addr /= dim[i];
@@ -126,7 +128,7 @@ ca_vi_setup (VALUE self, VALUE rref, VALUE rker)
126
128
  {
127
129
  CAWindowIterator *it;
128
130
  CArray *ref, *ker;
129
- int32_t i;
131
+ int8_t i;
130
132
 
131
133
  rker = rb_obj_clone(rker);
132
134
 
@@ -139,7 +141,7 @@ ca_vi_setup (VALUE self, VALUE rref, VALUE rker)
139
141
  }
140
142
 
141
143
  it->rank = ref->rank;
142
- memcpy(it->dim, ref->dim, it->rank * sizeof(int32_t));
144
+ memcpy(it->dim, ref->dim, it->rank * sizeof(ca_size_t));
143
145
  it->reference = ref;
144
146
  it->kernel = ker;
145
147
  it->kernel_at_addr = ca_vi_kernel_at_addr;
data/ca_obj_array.c CHANGED
@@ -15,8 +15,6 @@
15
15
  #include "rubysig.h"
16
16
  #endif
17
17
 
18
-
19
-
20
18
  /* ------------------------------------------------------------------- */
21
19
 
22
20
  VALUE rb_cCArray, rb_cCAWrap, rb_cCScalar, rb_cCAVirtual;
@@ -119,12 +117,13 @@ rb_ca_reset_gc_interval (VALUE self)
119
117
 
120
118
  static int
121
119
  carray_setup_i (CArray *ca,
122
- int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
120
+ int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
123
121
  CArray *mask, int allocate, int use_calloc)
124
122
  {
125
- int32_t elements;
123
+ ca_size_t elements;
126
124
  double length;
127
- int32_t i;
125
+ int8_t i;
126
+ ca_size_t k;
128
127
 
129
128
  /* check arguments */
130
129
  CA_CHECK_DATA_TYPE(data_type);
@@ -157,8 +156,8 @@ carray_setup_i (CArray *ca,
157
156
  ca->rank = rank;
158
157
  ca->bytes = bytes;
159
158
  ca->elements = elements;
160
- ca->dim = ALLOC_N(int32_t, rank);
161
- memcpy(ca->dim, dim, rank*sizeof(int32_t));
159
+ ca->dim = ALLOC_N(ca_size_t, rank);
160
+ memcpy(ca->dim, dim, rank*sizeof(ca_size_t));
162
161
 
163
162
  if ( allocate ) { /* allocate == true */
164
163
 
@@ -178,9 +177,9 @@ carray_setup_i (CArray *ca,
178
177
 
179
178
  /* initialize elements with Qnil for CA_OBJECT data_type */
180
179
  if ( allocate && data_type == CA_OBJECT ) {
181
- volatile VALUE zero = INT2FIX(0);
180
+ volatile VALUE zero = SIZE2NUM(0);
182
181
  VALUE *p = (VALUE *) ca->ptr;
183
- for (i=0; i<elements; i++) {
182
+ for (k=0; k<elements; k++) {
184
183
  *p++ = zero;
185
184
  }
186
185
  }
@@ -202,21 +201,21 @@ carray_setup_i (CArray *ca,
202
201
 
203
202
  int
204
203
  carray_setup (CArray *ca,
205
- int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes, CArray *mask)
204
+ int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask)
206
205
  {
207
206
  return carray_setup_i(ca, data_type, rank, dim, bytes, mask, 1, 0);
208
207
  }
209
208
 
210
209
  int
211
210
  carray_safe_setup (CArray *ca,
212
- int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes, CArray *mask)
211
+ int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask)
213
212
  {
214
213
  return carray_setup_i(ca, data_type, rank, dim, bytes, mask, 1, 1);
215
214
  }
216
215
 
217
216
  int
218
217
  ca_wrap_setup (CArray *ca,
219
- int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
218
+ int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
220
219
  CArray *mask, char *ptr)
221
220
  {
222
221
  int ret;
@@ -231,7 +230,7 @@ ca_wrap_setup (CArray *ca,
231
230
 
232
231
  int
233
232
  ca_wrap_setup_null (CArray *ca,
234
- int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
233
+ int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
235
234
  CArray *mask)
236
235
  {
237
236
  int ret;
@@ -242,7 +241,7 @@ ca_wrap_setup_null (CArray *ca,
242
241
  }
243
242
 
244
243
  CArray *
245
- carray_new (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
244
+ carray_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
246
245
  CArray *mask)
247
246
  {
248
247
  CArray *ca = ALLOC(CArray);
@@ -251,7 +250,7 @@ carray_new (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
251
250
  }
252
251
 
253
252
  CArray *
254
- carray_new_safe (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
253
+ carray_new_safe (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
255
254
  CArray *mask)
256
255
  {
257
256
  CArray *ca = ALLOC(CArray);
@@ -260,7 +259,7 @@ carray_new_safe (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
260
259
  }
261
260
 
262
261
  CAWrap *
263
- ca_wrap_new (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
262
+ ca_wrap_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
264
263
  CArray *mask, char *ptr)
265
264
  {
266
265
  CAWrap *ca = ALLOC(CAWrap);
@@ -269,7 +268,7 @@ ca_wrap_new (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
269
268
  }
270
269
 
271
270
  CAWrap *
272
- ca_wrap_new_null (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
271
+ ca_wrap_new_null (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
273
272
  CArray *mask)
274
273
  {
275
274
  CAWrap *ca = ALLOC(CAWrap);
@@ -306,7 +305,7 @@ free_ca_wrap (void *ap)
306
305
 
307
306
  static int
308
307
  cscalar_setup (CScalar *ca,
309
- int8_t data_type, int32_t bytes, CArray *mask)
308
+ int8_t data_type, ca_size_t bytes, CArray *mask)
310
309
  {
311
310
  CA_CHECK_DATA_TYPE(data_type);
312
311
  CA_CHECK_BYTES(data_type, bytes);
@@ -326,7 +325,7 @@ cscalar_setup (CScalar *ca,
326
325
  ca_mem_usage += (double)(ca->bytes);
327
326
 
328
327
  if ( data_type == CA_OBJECT ) {
329
- *((VALUE*) ca->ptr) = INT2FIX(0);
328
+ *((VALUE*) ca->ptr) = SIZE2NUM(0);
330
329
  }
331
330
  else {
332
331
  MEMZERO(ca->ptr, char, ca->bytes);
@@ -346,7 +345,7 @@ cscalar_setup (CScalar *ca,
346
345
  */
347
346
 
348
347
  CScalar *
349
- cscalar_new (int8_t data_type, int32_t bytes, CArray *mask)
348
+ cscalar_new (int8_t data_type, ca_size_t bytes, CArray *mask)
350
349
  {
351
350
  CScalar *ca = ALLOC(CScalar);
352
351
  cscalar_setup(ca, data_type, bytes, mask);
@@ -358,7 +357,7 @@ cscalar_new (int8_t data_type, int32_t bytes, CArray *mask)
358
357
  */
359
358
 
360
359
  CScalar *
361
- cscalar_new2 (int8_t data_type, int32_t bytes, char *val)
360
+ cscalar_new2 (int8_t data_type, ca_size_t bytes, char *val)
362
361
  {
363
362
  CScalar *ca = ALLOC(CScalar);
364
363
  cscalar_setup(ca, data_type, bytes, NULL);
@@ -395,18 +394,19 @@ ca_array_func_clone (void *ap)
395
394
  }
396
395
 
397
396
  char *
398
- ca_array_func_ptr_at_addr (void *ap, int32_t addr)
397
+ ca_array_func_ptr_at_addr (void *ap, ca_size_t addr)
399
398
  {
400
399
  CArray *ca = (CArray *) ap;
401
400
  return ca->ptr + ca->bytes * addr;
402
401
  }
403
402
 
404
403
  char *
405
- ca_array_func_ptr_at_index (void *ap, int32_t *idx)
404
+ ca_array_func_ptr_at_index (void *ap, ca_size_t *idx)
406
405
  {
407
406
  CArray *ca = (CArray *) ap;
408
- int32_t *dim = ca->dim;
409
- int32_t n, i;
407
+ ca_size_t *dim = ca->dim;
408
+ int8_t i;
409
+ ca_size_t n;
410
410
  n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[rank-1] */
411
411
  for (i=1; i<ca->rank; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[rank-1] */
412
412
  n = dim[i]*n+idx[i]; /* ... + idx[rank-2]*dim[1] + idx[rank-1] */
@@ -415,18 +415,19 @@ ca_array_func_ptr_at_index (void *ap, int32_t *idx)
415
415
  }
416
416
 
417
417
  void
418
- ca_array_func_fetch_addr (void *ap, int32_t addr, void *ptr)
418
+ ca_array_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
419
419
  {
420
420
  CArray *ca = (CArray *) ap;
421
421
  memcpy(ptr, ca->ptr + ca->bytes * addr, ca->bytes);
422
422
  }
423
423
 
424
424
  void
425
- ca_array_func_fetch_index (void *ap, int32_t *idx, void *ptr)
425
+ ca_array_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
426
426
  {
427
427
  CArray *ca = (CArray *) ap;
428
- int32_t *dim = ca->dim;
429
- int32_t n, i;
428
+ ca_size_t *dim = ca->dim;
429
+ int8_t i;
430
+ ca_size_t n;
430
431
  n = idx[0];
431
432
  for (i=1; i<ca->rank; i++) {
432
433
  n = dim[i]*n+idx[i];
@@ -435,18 +436,19 @@ ca_array_func_fetch_index (void *ap, int32_t *idx, void *ptr)
435
436
  }
436
437
 
437
438
  void
438
- ca_array_func_store_addr (void *ap, int32_t addr, void *ptr)
439
+ ca_array_func_store_addr (void *ap, ca_size_t addr, void *ptr)
439
440
  {
440
441
  CArray *ca = (CArray *) ap;
441
442
  memcpy(ca->ptr + ca->bytes * addr, ptr, ca->bytes);
442
443
  }
443
444
 
444
445
  void
445
- ca_array_func_store_index (void *ap, int32_t *idx, void *ptr)
446
+ ca_array_func_store_index (void *ap, ca_size_t *idx, void *ptr)
446
447
  {
447
448
  CArray *ca = (CArray *) ap;
448
- int32_t *dim = ca->dim;
449
- int32_t n, i;
449
+ ca_size_t *dim = ca->dim;
450
+ int8_t i;
451
+ ca_size_t n;
450
452
  n = idx[0];
451
453
  for (i=1; i<ca->rank; i++) {
452
454
  n = dim[i]*n+idx[i];
@@ -495,8 +497,8 @@ ca_array_func_sync_data (void *ap, void *ptr)
495
497
 
496
498
  #define proc_fill_bang_fixlen() \
497
499
  { \
498
- int32_t i; \
499
- int32_t bytes = ca->bytes; \
500
+ ca_size_t i; \
501
+ ca_size_t bytes = ca->bytes; \
500
502
  char *p = ca->ptr; \
501
503
  for (i=ca->elements; i; i--, p+=bytes) { \
502
504
  memcpy(p, val, bytes); \
@@ -505,7 +507,7 @@ ca_array_func_sync_data (void *ap, void *ptr)
505
507
 
506
508
  #define proc_fill_bang(type) \
507
509
  { \
508
- int32_t i; \
510
+ ca_size_t i; \
509
511
  type *p = (type *)ca->ptr; \
510
512
  type v = *(type *)val; \
511
513
  for (i=ca->elements; i; i--, p++) { \
@@ -604,14 +606,14 @@ ca_scalar_func_clone (void *ap)
604
606
  }
605
607
 
606
608
  char *
607
- ca_scalar_func_ptr_at_addr (void *ap, int32_t addr)
609
+ ca_scalar_func_ptr_at_addr (void *ap, ca_size_t addr)
608
610
  {
609
611
  CArray *ca = (CArray *) ap;
610
612
  return ca->ptr;
611
613
  }
612
614
 
613
615
  char *
614
- ca_scalar_func_ptr_at_index (void *ap, int32_t *idx)
616
+ ca_scalar_func_ptr_at_index (void *ap, ca_size_t *idx)
615
617
  {
616
618
  CArray *ca = (CArray *) ap;
617
619
  return ca->ptr;
@@ -652,7 +654,7 @@ ca_operation_function_t ca_scalar_func = {
652
654
  /* ------------------------------------------------------------------- */
653
655
 
654
656
  VALUE
655
- rb_carray_new (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
657
+ rb_carray_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
656
658
  CArray *mask)
657
659
  {
658
660
  CArray *ca = carray_new(data_type, rank, dim, bytes, mask);
@@ -660,7 +662,7 @@ rb_carray_new (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
660
662
  }
661
663
 
662
664
  VALUE
663
- rb_carray_new_safe (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
665
+ rb_carray_new_safe (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
664
666
  CArray *mask)
665
667
  {
666
668
  CArray *ca = carray_new_safe(data_type, rank, dim, bytes, mask);
@@ -668,14 +670,14 @@ rb_carray_new_safe (int8_t data_type, int8_t rank, int32_t *dim, int32_t bytes,
668
670
  }
669
671
 
670
672
  VALUE
671
- rb_cscalar_new (int8_t data_type, int32_t bytes, CArray *mask)
673
+ rb_cscalar_new (int8_t data_type, ca_size_t bytes, CArray *mask)
672
674
  {
673
675
  CScalar *ca = cscalar_new(data_type, bytes, mask);
674
676
  return ca_wrap_struct(ca);
675
677
  }
676
678
 
677
679
  VALUE
678
- rb_cscalar_new_with_value (int8_t data_type, int32_t bytes, VALUE rval)
680
+ rb_cscalar_new_with_value (int8_t data_type, ca_size_t bytes, VALUE rval)
679
681
  {
680
682
  volatile VALUE obj;
681
683
  obj = rb_cscalar_new(data_type, bytes, NULL);
@@ -719,11 +721,11 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
719
721
  volatile VALUE rtype, rdim, ropt, rbytes = Qnil;
720
722
  CArray *ca;
721
723
  int8_t data_type, rank;
722
- int32_t dim[CA_RANK_MAX];
723
- int32_t bytes;
724
- int32_t i;
724
+ ca_size_t dim[CA_RANK_MAX];
725
+ ca_size_t bytes;
726
+ int8_t i;
725
727
 
726
- rb_scan_args(argc, argv, "21", &rtype, &rdim, &ropt);
728
+ rb_scan_args(argc, argv, "21", (VALUE *)&rtype, (VALUE *) &rdim, (VALUE *) &ropt);
727
729
  rb_scan_options(ropt, "bytes", &rbytes);
728
730
 
729
731
  rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
@@ -732,7 +734,7 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
732
734
  Check_Type(rdim, T_ARRAY);
733
735
  rank = RARRAY_LEN(rdim);
734
736
  for (i=0; i<rank; i++) {
735
- dim[i] = NUM2INT(rb_ary_entry(rdim, i));
737
+ dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
736
738
  }
737
739
 
738
740
  Data_Get_Struct(self, CArray, ca);
@@ -836,11 +838,11 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
836
838
  volatile VALUE obj, target, rtype, rdim, ropt, rbytes = Qnil;
837
839
  CArray *ca;
838
840
  int8_t data_type, rank;
839
- int32_t dim[CA_RANK_MAX];
840
- int32_t bytes;
841
- int32_t i;
841
+ ca_size_t dim[CA_RANK_MAX];
842
+ ca_size_t bytes;
843
+ int8_t i;
842
844
 
843
- rb_scan_args(argc, argv, "21", &rtype, &rdim, &ropt);
845
+ rb_scan_args(argc, argv, "21", (VALUE *) &rtype, (VALUE *) &rdim, (VALUE *) &ropt);
844
846
  rb_scan_options(ropt, "bytes", &rbytes);
845
847
 
846
848
  rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
@@ -848,7 +850,7 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
848
850
  Check_Type(rdim, T_ARRAY);
849
851
  rank = RARRAY_LEN(rdim);
850
852
  for (i=0; i<rank; i++) {
851
- dim[i] = NUM2INT(rb_ary_entry(rdim, i));
853
+ dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
852
854
  }
853
855
 
854
856
  target = rb_yield_values(0);
@@ -863,8 +865,8 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
863
865
  }
864
866
 
865
867
  VALUE
866
- rb_carray_wrap_ptr (int8_t data_type, int8_t rank, int32_t *dim,
867
- int32_t bytes, CArray *mask, char *ptr, VALUE refer)
868
+ rb_carray_wrap_ptr (int8_t data_type, int8_t rank, ca_size_t *dim,
869
+ ca_size_t bytes, CArray *mask, char *ptr, VALUE refer)
868
870
  {
869
871
  volatile VALUE obj;
870
872
  CArray *ca;
@@ -906,9 +908,9 @@ rb_cs_initialize (int argc, VALUE *argv, VALUE self)
906
908
  volatile VALUE rtype, ropt, rbytes = Qnil;
907
909
  CScalar *ca;
908
910
  int8_t data_type;
909
- int32_t bytes;
911
+ ca_size_t bytes;
910
912
 
911
- rb_scan_args(argc, argv, "11", &rtype, &ropt);
913
+ rb_scan_args(argc, argv, "11", (VALUE *) &rtype, (VALUE *) &ropt);
912
914
  rb_scan_options(ropt, "bytes", &rbytes);
913
915
 
914
916
  rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);