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_mask.c CHANGED
@@ -39,7 +39,7 @@ ca_has_mask (void *ap)
39
39
  else if ( ca_is_caobject(ca) ) { /* CAObject */
40
40
  CAObject *co = (CAObject *) ca;
41
41
  if ( rb_obj_respond_to(co->self, rb_intern("mask_created?"), Qtrue) ) {
42
- return rb_funcall(co->self, rb_intern("mask_created?"), 0);
42
+ return RTEST(rb_funcall(co->self, rb_intern("mask_created?"), 0));
43
43
  }
44
44
  return ( ca->mask != NULL ) ? 1 : 0;
45
45
  }
@@ -60,7 +60,7 @@ ca_is_any_masked (void *ap)
60
60
  {
61
61
  CArray *ca = (CArray *) ap;
62
62
  boolean8_t *m;
63
- int32_t i;
63
+ ca_size_t i;
64
64
  int flag = 0;
65
65
 
66
66
  ca_update_mask(ca);
@@ -84,7 +84,7 @@ ca_is_all_masked (void *ap)
84
84
  {
85
85
  CArray *ca = (CArray *) ap;
86
86
  boolean8_t *m;
87
- int32_t i;
87
+ ca_size_t i;
88
88
  int flag;
89
89
 
90
90
  ca_update_mask(ca);
@@ -177,20 +177,20 @@ ca_setup_mask (void *ap, CArray *mask)
177
177
  }
178
178
 
179
179
  /*
180
- ca_copy_mask_overlay_n (void *ap, int32_t elements, int n, CArray **slist)
180
+ ca_copy_mask_overlay_n (void *ap, ca_size_t elements, int n, CArray **slist)
181
181
 
182
182
  + slist[i] can be NULL (simply skipped)
183
183
 
184
184
  */
185
185
 
186
186
  void
187
- ca_copy_mask_overlay_n (void *ap, int32_t elements, int n, CArray **slist)
187
+ ca_copy_mask_overlay_n (void *ap, ca_size_t elements, int n, CArray **slist)
188
188
  {
189
189
  CArray *ca = (CArray *) ap;
190
190
  CArray *cs;
191
191
  boolean8_t *ma, *ms;
192
192
  int i, some_has_mask = 0;
193
- int32_t j;
193
+ ca_size_t j;
194
194
 
195
195
  for (i=0; i<n; i++) {
196
196
  if ( slist[i] && ca_has_mask(slist[i]) ) {
@@ -247,7 +247,7 @@ ca_copy_mask_overlay_n (void *ap, int32_t elements, int n, CArray **slist)
247
247
  }
248
248
 
249
249
  void
250
- ca_copy_mask_overlay (void *ap, int32_t elements, int n, ...)
250
+ ca_copy_mask_overlay (void *ap, ca_size_t elements, int n, ...)
251
251
  {
252
252
  CArray *ca = (CArray *) ap;
253
253
  CArray **slist;
@@ -267,7 +267,7 @@ ca_copy_mask_overlay (void *ap, int32_t elements, int n, ...)
267
267
  }
268
268
 
269
269
  void
270
- ca_copy_mask_overwrite_n (void *ap, int32_t elements, int n, CArray **slist)
270
+ ca_copy_mask_overwrite_n (void *ap, ca_size_t elements, int n, CArray **slist)
271
271
  {
272
272
  CArray *ca = (CArray *) ap;
273
273
 
@@ -281,7 +281,7 @@ ca_copy_mask_overwrite_n (void *ap, int32_t elements, int n, CArray **slist)
281
281
  }
282
282
 
283
283
  void
284
- ca_copy_mask_overwrite (void *ap, int32_t elements, int n, ...)
284
+ ca_copy_mask_overwrite (void *ap, ca_size_t elements, int n, ...)
285
285
  {
286
286
  CArray *ca = (CArray *) ap;
287
287
  CArray **slist;
@@ -315,12 +315,12 @@ ca_copy_mask (void *ap, void *ao)
315
315
  ca_copy_mask_overlay(ca, ca->elements, 1, co);
316
316
  }
317
317
 
318
- int32_t
318
+ ca_size_t
319
319
  ca_count_masked (void *ap)
320
320
  {
321
321
  CArray *ca = (CArray *) ap;
322
322
  boolean8_t *m;
323
- int32_t i, count = 0;
323
+ ca_size_t i, count = 0;
324
324
 
325
325
  ca_update_mask(ca);
326
326
 
@@ -338,7 +338,7 @@ ca_count_masked (void *ap)
338
338
  return count;
339
339
  }
340
340
 
341
- int32_t
341
+ ca_size_t
342
342
  ca_count_not_masked (void *ap)
343
343
  {
344
344
  CArray *ca = (CArray *) ap;
@@ -347,7 +347,7 @@ ca_count_not_masked (void *ap)
347
347
 
348
348
  #define proc_fill_bang(type) \
349
349
  { \
350
- int32_t i; \
350
+ ca_size_t i; \
351
351
  type *p = (type *)ca->ptr; \
352
352
  type v = *(type *)fill_value; \
353
353
  boolean8_t *m = (boolean8_t *) ca->mask->ptr; \
@@ -362,7 +362,7 @@ ca_count_not_masked (void *ap)
362
362
 
363
363
  #define proc_fill_bang_fixlen() \
364
364
  { \
365
- int32_t i; \
365
+ ca_size_t i; \
366
366
  char *p = ca->ptr; \
367
367
  boolean8_t *m = (boolean8_t *) ca->mask->ptr; \
368
368
  for (i=0; i<ca->elements; i++) { \
@@ -424,7 +424,7 @@ ca_unmask_copy (void *ap, char *fill_value)
424
424
  CArray *co;
425
425
  char *p, *q;
426
426
  boolean8_t *m;
427
- int32_t i;
427
+ ca_size_t i;
428
428
 
429
429
  co = ca_template(ca);
430
430
  ca_copy_data(ca, co->ptr);
@@ -451,7 +451,7 @@ ca_invert_mask (void *ap)
451
451
  {
452
452
  CArray *ca = (CArray *) ap;
453
453
  boolean8_t *m;
454
- int32_t i;
454
+ ca_size_t i;
455
455
 
456
456
  ca_update_mask(ca);
457
457
 
@@ -475,7 +475,7 @@ ca_allocate_mask_iterator_n (int n, CArray **slist)
475
475
  {
476
476
  boolean8_t *m, *mp, *ms;
477
477
  CArray *cs;
478
- int32_t j, elements = -1;
478
+ ca_size_t j, elements = -1;
479
479
  int i, some_has_mask = 0;
480
480
 
481
481
  for (i=0; i<n; i++) {
@@ -771,7 +771,7 @@ rb_ca_is_masked (VALUE self)
771
771
  CArray *ca, *cm, *co;
772
772
  boolean8_t zero = 0;
773
773
  boolean8_t *m, *p;
774
- int32_t i;
774
+ ca_size_t i;
775
775
 
776
776
  Data_Get_Struct(self, CArray, ca);
777
777
 
@@ -814,7 +814,7 @@ rb_ca_is_not_masked (VALUE self)
814
814
  CArray *ca, *cm, *co;
815
815
  boolean8_t one = 1;
816
816
  boolean8_t *m, *p;
817
- int32_t i;
817
+ ca_size_t i;
818
818
 
819
819
  Data_Get_Struct(self, CArray, ca);
820
820
 
@@ -853,7 +853,7 @@ rb_ca_count_masked (VALUE self)
853
853
  {
854
854
  CArray *ca;
855
855
  Data_Get_Struct(self, CArray, ca);
856
- return INT2NUM(ca_count_masked(ca));
856
+ return SIZE2NUM(ca_count_masked(ca));
857
857
  }
858
858
 
859
859
  /* rdoc:
@@ -869,7 +869,7 @@ rb_ca_count_not_masked (VALUE self)
869
869
  {
870
870
  CArray *ca;
871
871
  Data_Get_Struct(self, CArray, ca);
872
- return INT2NUM(ca_count_not_masked(ca));
872
+ return SIZE2NUM(ca_count_not_masked(ca));
873
873
  }
874
874
 
875
875
  static VALUE
data/carray_math.rb CHANGED
@@ -148,7 +148,7 @@ monfunc("rcp", "rcp",
148
148
  INT_TYPES => "if ((#1)==0) {ca_zerodiv();}; (#2) = 1/(#1);",
149
149
  FLOAT_TYPES => "(#2) = 1/(#1);",
150
150
  CMPLX_TYPES => HAVE_COMPLEX ? "(#2) = 1/(#1);" : nil,
151
- OBJ_TYPES => '(#2) = rb_funcall(INT2FIX(1), id_slash, 1, (#1));')
151
+ OBJ_TYPES => '(#2) = rb_funcall(INT2NUM(1), id_slash, 1, (#1));')
152
152
  monfunc("sqrt", "sqrt",
153
153
  FLOAT_TYPES => "(#2) = sqrt(#1);",
154
154
  CMPLX_TYPES => HAVE_COMPLEX ? "(#2) = csqrt(#1);" : nil,
@@ -283,10 +283,10 @@ static VALUE
283
283
  rb_ca_bit_and (VALUE self, VALUE other)
284
284
  {
285
285
  if ( rb_ca_is_boolean_type(self) ) {
286
- return rb_ca_bit_and_i(self, rb_ca_wrap_readonly(other, INT2FIX(CA_BOOLEAN)));
286
+ return rb_ca_bit_and_i(self, rb_ca_wrap_readonly(other, INT2NUM(CA_BOOLEAN)));
287
287
  }
288
288
  else if ( rb_obj_is_carray(other) && rb_ca_is_boolean_type(other) ) {
289
- return rb_ca_bit_and_i(rb_ca_wrap_readonly(self, INT2FIX(CA_BOOLEAN)), other);
289
+ return rb_ca_bit_and_i(rb_ca_wrap_readonly(self, INT2NUM(CA_BOOLEAN)), other);
290
290
  }
291
291
  else {
292
292
  return rb_ca_bit_and_i(self, other);
@@ -297,10 +297,10 @@ static VALUE
297
297
  rb_ca_bit_or (VALUE self, VALUE other)
298
298
  {
299
299
  if ( rb_ca_is_boolean_type(self) ) {
300
- return rb_ca_bit_or_i(self, rb_ca_wrap_readonly(other, INT2FIX(CA_BOOLEAN)));
300
+ return rb_ca_bit_or_i(self, rb_ca_wrap_readonly(other, INT2NUM(CA_BOOLEAN)));
301
301
  }
302
302
  else if ( rb_obj_is_carray(other) && rb_ca_is_boolean_type(other) ) {
303
- return rb_ca_bit_or_i(rb_ca_wrap_readonly(self, INT2FIX(CA_BOOLEAN)), other);
303
+ return rb_ca_bit_or_i(rb_ca_wrap_readonly(self, INT2NUM(CA_BOOLEAN)), other);
304
304
  }
305
305
  else {
306
306
  return rb_ca_bit_or_i(self, other);
@@ -311,10 +311,10 @@ static VALUE
311
311
  rb_ca_bit_xor (VALUE self, VALUE other)
312
312
  {
313
313
  if ( rb_ca_is_boolean_type(self) ) {
314
- return rb_ca_bit_xor_i(self, rb_ca_wrap_readonly(other, INT2FIX(CA_BOOLEAN)));
314
+ return rb_ca_bit_xor_i(self, rb_ca_wrap_readonly(other, INT2NUM(CA_BOOLEAN)));
315
315
  }
316
316
  else if ( rb_obj_is_carray(other) && rb_ca_is_boolean_type(other) ) {
317
- return rb_ca_bit_xor_i(rb_ca_wrap_readonly(self, INT2FIX(CA_BOOLEAN)), other);
317
+ return rb_ca_bit_xor_i(rb_ca_wrap_readonly(self, INT2NUM(CA_BOOLEAN)), other);
318
318
  }
319
319
  else {
320
320
  return rb_ca_bit_xor_i(self, other);
@@ -415,10 +415,10 @@ static VALUE
415
415
  rb_ca_and (VALUE self, VALUE other)
416
416
  {
417
417
  if ( rb_ca_is_boolean_type(self) ) {
418
- return rb_ca_and_i(self, rb_ca_wrap_readonly(other, INT2FIX(CA_BOOLEAN)));
418
+ return rb_ca_and_i(self, rb_ca_wrap_readonly(other, INT2NUM(CA_BOOLEAN)));
419
419
  }
420
420
  else if ( rb_obj_is_carray(other) && rb_ca_is_boolean_type(other) ) {
421
- return rb_ca_and_i(rb_ca_wrap_readonly(self, INT2FIX(CA_BOOLEAN)), other);
421
+ return rb_ca_and_i(rb_ca_wrap_readonly(self, INT2NUM(CA_BOOLEAN)), other);
422
422
  }
423
423
  else {
424
424
  return rb_ca_and_i(self, other);
@@ -429,10 +429,10 @@ static VALUE
429
429
  rb_ca_or (VALUE self, VALUE other)
430
430
  {
431
431
  if ( rb_ca_is_boolean_type(self) ) {
432
- return rb_ca_or_i(self, rb_ca_wrap_readonly(other, INT2FIX(CA_BOOLEAN)));
432
+ return rb_ca_or_i(self, rb_ca_wrap_readonly(other, INT2NUM(CA_BOOLEAN)));
433
433
  }
434
434
  else if ( rb_obj_is_carray(other) && rb_ca_is_boolean_type(other) ) {
435
- return rb_ca_or_i(rb_ca_wrap_readonly(self, INT2FIX(CA_BOOLEAN)), other);
435
+ return rb_ca_or_i(rb_ca_wrap_readonly(self, INT2NUM(CA_BOOLEAN)), other);
436
436
  }
437
437
  else {
438
438
  return rb_ca_or_i(self, other);
@@ -443,10 +443,10 @@ static VALUE
443
443
  rb_ca_xor (VALUE self, VALUE other)
444
444
  {
445
445
  if ( rb_ca_is_boolean_type(self) ) {
446
- return rb_ca_xor_i(self, rb_ca_wrap_readonly(other, INT2FIX(CA_BOOLEAN)));
446
+ return rb_ca_xor_i(self, rb_ca_wrap_readonly(other, INT2NUM(CA_BOOLEAN)));
447
447
  }
448
448
  else if ( rb_obj_is_carray(other) && rb_ca_is_boolean_type(other) ) {
449
- return rb_ca_xor_i(rb_ca_wrap_readonly(self, INT2FIX(CA_BOOLEAN)), other);
449
+ return rb_ca_xor_i(rb_ca_wrap_readonly(self, INT2NUM(CA_BOOLEAN)), other);
450
450
  }
451
451
  else {
452
452
  return rb_ca_xor_i(self, other);
@@ -571,7 +571,7 @@ op_powi_fc(cmplx64_t);
571
571
  op_powi_fc(cmplx128_t);
572
572
 
573
573
  static void
574
- ca_ipower_float32_t (int32_t n, boolean8_t *m,
574
+ ca_ipower_float32_t (ca_size_t n, boolean8_t *m,
575
575
  char *ptr1, int32_t ipow, char *ptr2)
576
576
  {
577
577
  float32_t *p1 = (float32_t *) ptr1, *p2 = (float32_t *) ptr2;
@@ -586,7 +586,7 @@ ca_ipower_float32_t (int32_t n, boolean8_t *m,
586
586
  }
587
587
 
588
588
  static void
589
- ca_ipower_float64_t (int32_t n, boolean8_t *m,
589
+ ca_ipower_float64_t (ca_size_t n, boolean8_t *m,
590
590
  char *ptr1, int32_t ipow, char *ptr2)
591
591
  {
592
592
  float64_t *p1 = (float64_t *) ptr1, *p2 = (float64_t *) ptr2;
@@ -601,7 +601,7 @@ ca_ipower_float64_t (int32_t n, boolean8_t *m,
601
601
  }
602
602
 
603
603
  static void
604
- ca_ipower_float128_t (int32_t n, boolean8_t *m,
604
+ ca_ipower_float128_t (ca_size_t n, boolean8_t *m,
605
605
  char *ptr1, int32_t ipow, char *ptr2)
606
606
  {
607
607
  float128_t *p1 = (float128_t *) ptr1, *p2 = (float128_t *) ptr2;
@@ -616,7 +616,7 @@ ca_ipower_float128_t (int32_t n, boolean8_t *m,
616
616
  }
617
617
 
618
618
  static void
619
- ca_ipower_cmplx64_t (int32_t n, boolean8_t *m,
619
+ ca_ipower_cmplx64_t (ca_size_t n, boolean8_t *m,
620
620
  char *ptr1, int32_t ipow, char *ptr2)
621
621
  {
622
622
  cmplx64_t *p1 = (cmplx64_t *) ptr1, *p2 = (cmplx64_t *) ptr2;
@@ -631,7 +631,7 @@ ca_ipower_cmplx64_t (int32_t n, boolean8_t *m,
631
631
  }
632
632
 
633
633
  static void
634
- ca_ipower_cmplx128_t (int32_t n, boolean8_t *m,
634
+ ca_ipower_cmplx128_t (ca_size_t n, boolean8_t *m,
635
635
  char *ptr1, int32_t ipow, char *ptr2)
636
636
  {
637
637
  cmplx128_t *p1 = (cmplx128_t *) ptr1, *p2 = (cmplx128_t *) ptr2;
data/carray_numeric.c CHANGED
@@ -146,7 +146,7 @@ rb_hack_star (VALUE x, VALUE y)
146
146
  type *p = (type *) ca->ptr; \
147
147
  double *q = (double *) co->ptr; \
148
148
  boolean8_t *m = (ca->mask) ? (boolean8_t *) ca->mask->ptr : NULL; \
149
- int32_t i; \
149
+ ca_size_t i; \
150
150
  if ( m ) { \
151
151
  for (i=ca->elements; i; i--, p++, q++) { \
152
152
  if ( ! *m++ ) \
data/carray_operator.c CHANGED
@@ -150,8 +150,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
150
150
  }
151
151
  else { /* array vs array */
152
152
  if ( ca1->elements != ca2->elements ) {
153
- rb_raise(rb_eRuntimeError, "elements mismatch (%i <-> %i)",
154
- ca1->elements, ca2->elements);
153
+ rb_raise(rb_eRuntimeError, "elements mismatch (%lld <-> %lld)",
154
+ (ca_size_t) ca1->elements, (ca_size_t) ca2->elements);
155
155
  }
156
156
  if ( ca_has_mask(ca1) || ca_has_mask(ca2) ) {
157
157
  ca3 = ca_template_safe(ca1);
@@ -212,8 +212,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
212
212
  }
213
213
  else { /* scalar vs array */
214
214
  if ( ca1->elements != ca2->elements ) {
215
- rb_raise(rb_eRuntimeError, "elements mismatch (%i <-> %i)",
216
- ca1->elements, ca2->elements);
215
+ rb_raise(rb_eRuntimeError, "elements mismatch (%lld <-> %lld)",
216
+ (ca_size_t) ca1->elements, (ca_size_t) ca2->elements);
217
217
  }
218
218
 
219
219
  ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
@@ -233,8 +233,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
233
233
  }
234
234
  else { /* array vs array */
235
235
  if ( ca1->elements != ca2->elements ) {
236
- rb_raise(rb_eRuntimeError, "elements mismatch in binop (%i <-> %i)",
237
- ca1->elements, ca2->elements);
236
+ rb_raise(rb_eRuntimeError, "elements mismatch in binop (%lld <-> %lld)",
237
+ (ca_size_t) ca1->elements, (ca_size_t) ca2->elements);
238
238
  }
239
239
 
240
240
  ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
@@ -285,6 +285,7 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
285
285
  return out;
286
286
  }
287
287
 
288
+
288
289
  extern ca_monop_func_t ca_bincmp_eq[CA_NTYPE];
289
290
  extern ca_monop_func_t ca_bincmp_ne[CA_NTYPE];
290
291
 
@@ -352,8 +353,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
352
353
  }
353
354
  else { /* array vs array */
354
355
  if ( ca1->elements != ca2->elements ) {
355
- rb_raise(rb_eRuntimeError, "elements mismatch in bincmp (%i <-> %i)",
356
- ca1->elements, ca2->elements);
356
+ rb_raise(rb_eRuntimeError, "elements mismatch in bincmp (%lld <-> %lld)",
357
+ (ca_size_t) ca1->elements, (ca_size_t) ca2->elements);
357
358
  }
358
359
  out = rb_carray_new(CA_BOOLEAN, ca1->rank, ca1->dim, 0, NULL);
359
360
  Data_Get_Struct(out, CArray, ca3);
@@ -378,28 +379,28 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
378
379
  }
379
380
 
380
381
  void
381
- ca_monop_not_implement(int32_t n, char *ptr1, char *ptr2)
382
+ ca_monop_not_implement(ca_size_t n, char *ptr1, char *ptr2)
382
383
  {
383
384
  rb_raise(rb_eCADataTypeError,
384
385
  "invalid data type for monop (not implemented)");
385
386
  }
386
387
 
387
388
  void
388
- ca_binop_not_implement(int32_t n, char *ptr1, char *ptr2, char *ptr3)
389
+ ca_binop_not_implement(ca_size_t n, char *ptr1, char *ptr2, char *ptr3)
389
390
  {
390
391
  rb_raise(rb_eCADataTypeError,
391
392
  "invalid data_type for binop (not implemented)");
392
393
  }
393
394
 
394
395
  void
395
- ca_moncmp_not_implement(int32_t n, char *ptr1, char *ptr2)
396
+ ca_moncmp_not_implement(ca_size_t n, char *ptr1, char *ptr2)
396
397
  {
397
398
  rb_raise(rb_eCADataTypeError,
398
399
  "invalid data_type for moncmp (not implemented)");
399
400
  }
400
401
 
401
402
  void
402
- ca_bincmp_not_implement (int32_t n, char *ptr1, char *ptr2, char *ptr3)
403
+ ca_bincmp_not_implement (ca_size_t n, char *ptr1, char *ptr2, char *ptr3)
403
404
  {
404
405
  rb_raise(rb_eTypeError, "invalid data_type for bincmp (not implemented)");
405
406
  }
@@ -470,11 +471,11 @@ rb_ca_coerce (VALUE self, VALUE other)
470
471
  { \
471
472
  type *p1 = (type*)ca->ptr; \
472
473
  type *p2; \
473
- int s2; \
474
+ ca_size_t s2; \
474
475
  boolean8_t *m = mi; \
475
476
  type sum = 0; \
476
- int32_t count = 0; \
477
- int32_t i; \
477
+ ca_size_t count = 0; \
478
+ ca_size_t i; \
478
479
  ca_set_iterator(1, cw, &p2, &s2); \
479
480
  if ( m ) { \
480
481
  count = 0; \
@@ -509,10 +510,10 @@ rb_ca_mul_add (int argc, VALUE *argv, volatile VALUE self)
509
510
  volatile VALUE rfval = Qnil;
510
511
  CArray *ca, *cw;
511
512
  boolean8_t *mi = NULL;
512
- int min_count;
513
+ ca_size_t min_count;
513
514
 
514
515
  /* FIXME: to parse :mask_limit, :fill_value */
515
- rb_scan_args(argc, argv, "12", &weight, &rmin_count, &rfval);
516
+ rb_scan_args(argc, argv, "12", (VALUE *) &weight, (VALUE *) &rmin_count, (VALUE *) &rfval);
516
517
 
517
518
  /* do implicit casting and resolving unbound repeat array */
518
519
  rb_ca_cast_self_or_other(&self, &weight);
@@ -533,7 +534,7 @@ rb_ca_mul_add (int argc, VALUE *argv, volatile VALUE self)
533
534
  }
534
535
 
535
536
  min_count = ( NIL_P(rmin_count) || ( ! mi ) ) ?
536
- ca->elements - 1 : NUM2INT(rmin_count);
537
+ ca->elements - 1 : NUM2SIZE(rmin_count);
537
538
 
538
539
  if ( min_count < 0 ) {
539
540
  min_count += ca->elements;
data/carray_order.c CHANGED
@@ -67,9 +67,9 @@ rb_ca_value_not_masked (VALUE self)
67
67
  static void
68
68
  ca_project_loop (CArray *co, CArray *ca, CArray *ci, char *lfill, char *ufill)
69
69
  {
70
- int32_t map_elements = ca->elements;
71
- int32_t *ip = (int32_t*) ci->ptr;
72
- int32_t n, i;
70
+ ca_size_t map_elements = ca->elements;
71
+ ca_size_t *ip = (ca_size_t*) ci->ptr;
72
+ ca_size_t n, i;
73
73
  boolean8_t *mi, *ma;
74
74
  boolean8_t *mio, *mii, *mia;
75
75
 
@@ -154,12 +154,12 @@ rb_ca_project (int argc, VALUE *argv, VALUE self)
154
154
  CArray *ca, *ci, *co;
155
155
  char *lfval, *ufval;
156
156
 
157
- rb_scan_args(argc, argv, "12", &rindex, &vlfval, &vufval);
157
+ rb_scan_args(argc, argv, "12", (VALUE *) &rindex, (VALUE *) &vlfval, (VALUE *) &vufval);
158
158
 
159
159
  Data_Get_Struct(self, CArray, ca);
160
160
 
161
161
  rb_check_carray_object(rindex);
162
- ci = ca_wrap_readonly(rindex, CA_INT32);
162
+ ci = ca_wrap_readonly(rindex, CA_SIZE);
163
163
 
164
164
  lfval = malloc_with_check(ca->bytes);
165
165
  ufval = malloc_with_check(ca->bytes);
@@ -215,7 +215,7 @@ rb_ca_project (int argc, VALUE *argv, VALUE self)
215
215
 
216
216
  #define proc_reverse_bang_data() \
217
217
  { \
218
- int32_t bytes = ca->bytes; \
218
+ ca_size_t bytes = ca->bytes; \
219
219
  char *p = ca->ptr; \
220
220
  char *q = ca->ptr + bytes * (ca->elements - 1); \
221
221
  char *v = malloc_with_check(bytes); \
@@ -299,7 +299,7 @@ rb_ca_reversed_copy (VALUE self)
299
299
  /* ------------------------------------------------------------------------- */
300
300
 
301
301
  typedef struct {
302
- int32_t bytes;
302
+ ca_size_t bytes;
303
303
  char *ptr;
304
304
  } cmp_data;
305
305
 
@@ -410,7 +410,7 @@ rb_ca_sort_bang (VALUE self)
410
410
  if ( ca_is_fixlen_type(ca) ) {
411
411
  cmp_data *cmp_ptr, *p;
412
412
  char *ca_ptr, *q;
413
- int32_t i;
413
+ ca_size_t i;
414
414
  cmp_ptr = malloc_with_check(sizeof(cmp_data)*ca->elements);
415
415
  ca_ptr = malloc_with_check(ca_length(ca));
416
416
  for (i=0, p=cmp_ptr, q=ca->ptr; i<ca->elements; i++, p++, q+=ca->bytes) {
@@ -468,7 +468,7 @@ rb_ca_sorted_copy (VALUE self)
468
468
 
469
469
  #define proc_shuffle(type) \
470
470
  { \
471
- int32_t idx, jdx; \
471
+ ca_size_t idx, jdx; \
472
472
  type *ptr, *p, *q; \
473
473
  type t1; \
474
474
  ptr = (type *) ca->ptr; \
@@ -498,10 +498,10 @@ rb_ca_sorted_copy (VALUE self)
498
498
 
499
499
  #define proc_shuffle_fixlen() \
500
500
  { \
501
- int32_t idx, jdx; \
501
+ ca_size_t idx, jdx; \
502
502
  char *ptr, *p, *q; \
503
503
  char *t = (char*) malloc_with_check(ca->bytes); \
504
- int32_t bytes = ca->bytes; \
504
+ ca_size_t bytes = ca->bytes; \
505
505
  ptr = ca->ptr; \
506
506
  if ( ca->mask ) { \
507
507
  boolean8_t *mptr, *mp, *mq; \
@@ -636,18 +636,18 @@ rb_ca_binary_search (VALUE self, volatile VALUE rval)
636
636
  volatile VALUE vidx;
637
637
  CArray *cv, *co;
638
638
  char *ptr, *val;
639
- int32_t i, idx;
639
+ ca_size_t i, idx;
640
640
  Data_Get_Struct(rval, CArray, cv);
641
641
  if ( ca->data_type != cv->data_type ) {
642
642
  cv = ca_wrap_readonly(rval, ca->data_type);
643
643
  }
644
- co = carray_new(CA_INT32, cv->rank, cv->dim, 0, NULL);
644
+ co = carray_new(CA_SIZE, cv->rank, cv->dim, 0, NULL);
645
645
  out = ca_wrap_struct(co);
646
646
  ca_attach(cv);
647
647
  if ( ca_is_fixlen_type(ca) ) {
648
648
  cmp_data *cmp_ptr, *p, *ptr, cmp_val;
649
649
  char *q;
650
- int32_t i;
650
+ ca_size_t i;
651
651
  cmp_val.bytes = ca->bytes;
652
652
  cmp_ptr = malloc_with_check(sizeof(cmp_data)*ca->elements);
653
653
  for (i=0, p=cmp_ptr, q=ca->ptr; i<ca->elements; i++, p++, q+=ca->bytes) {
@@ -658,7 +658,7 @@ rb_ca_binary_search (VALUE self, volatile VALUE rval)
658
658
  cmp_val.ptr = ca_ptr_at_addr(cv, i);
659
659
  ptr = bsearch(&cmp_val, cmp_ptr, ca->elements, sizeof(cmp_data),
660
660
  ca_qsort_cmp[CA_FIXLEN]);
661
- vidx = ( ! ptr ) ? CA_UNDEF : INT2NUM(ptr - cmp_ptr);
661
+ vidx = ( ! ptr ) ? CA_UNDEF : SIZE2NUM(ptr - cmp_ptr);
662
662
  rb_ca_store_addr(out, i, vidx);
663
663
  }
664
664
  free(cmp_ptr);
@@ -685,7 +685,7 @@ rb_ca_binary_search (VALUE self, volatile VALUE rval)
685
685
  if ( ca_is_fixlen_type(ca) ) {
686
686
  cmp_data *cmp_ptr, *p, *ptr, cmp_val;
687
687
  char *q;
688
- int32_t i;
688
+ ca_size_t i;
689
689
  cmp_val.bytes = ca->bytes;
690
690
  cmp_val.ptr = val;
691
691
  cmp_ptr = malloc_with_check(sizeof(cmp_data)*ca->elements);
@@ -695,14 +695,14 @@ rb_ca_binary_search (VALUE self, volatile VALUE rval)
695
695
  }
696
696
  ptr = bsearch(&cmp_val, cmp_ptr, ca->elements, sizeof(cmp_data),
697
697
  ca_qsort_cmp[CA_FIXLEN]);
698
- out = ( ! ptr ) ? Qnil : INT2NUM((ptr - cmp_ptr));
698
+ out = ( ! ptr ) ? Qnil : SIZE2NUM((ptr - cmp_ptr));
699
699
  free(cmp_ptr);
700
700
  }
701
701
  else {
702
702
  char *ptr;
703
703
  ptr = bsearch(val, ca->ptr, ca->elements, ca->bytes,
704
704
  ca_qsort_cmp[ca->data_type]);
705
- out = ( ! ptr ) ? Qnil : INT2NUM((ptr - ca->ptr)/ca->bytes);
705
+ out = ( ! ptr ) ? Qnil : SIZE2NUM((ptr - ca->ptr)/ca->bytes);
706
706
  }
707
707
  }
708
708
  ca_detach(ca);
@@ -729,8 +729,8 @@ rb_ca_binary_search_index (VALUE self, volatile VALUE rval)
729
729
  { \
730
730
  type *ptr = (type *) ca->ptr; \
731
731
  boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
732
- type val = (type) NUM2LONG(value); \
733
- int32_t i; \
732
+ type val = (type) NUM2LL(value); \
733
+ ca_size_t i; \
734
734
  if ( m ) { \
735
735
  for (i=0; i<ca->elements; i++, ptr++) { \
736
736
  if ( ! *m++ ) { \
@@ -757,7 +757,7 @@ rb_ca_binary_search_index (VALUE self, volatile VALUE rval)
757
757
  boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
758
758
  type val = (type) NUM2DBL(value); \
759
759
  double eps = (NIL_P(veps)) ? defeps*fabs(val) : NUM2DBL(veps); \
760
- int32_t i; \
760
+ ca_size_t i; \
761
761
  if ( m ) { \
762
762
  for (i=0; i<ca->elements; i++, ptr++) { \
763
763
  if ( ! *m++ ) { \
@@ -784,7 +784,7 @@ rb_ca_binary_search_index (VALUE self, volatile VALUE rval)
784
784
  boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
785
785
  type val = (type) NUM2CC(value); \
786
786
  double eps = (NIL_P(veps)) ? defeps*cabs(val) : NUM2DBL(veps); \
787
- int32_t i; \
787
+ ca_size_t i; \
788
788
  if ( m ) { \
789
789
  for (i=0; i<ca->elements; i++, ptr++) { \
790
790
  if ( ! *m++ ) { \
@@ -809,7 +809,7 @@ rb_ca_binary_search_index (VALUE self, volatile VALUE rval)
809
809
  { \
810
810
  VALUE *ptr = (VALUE *) ca->ptr; \
811
811
  boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
812
- int32_t i; \
812
+ ca_size_t i; \
813
813
  if ( m ) { \
814
814
  for (i=0; i<ca->elements; i++, ptr++) { \
815
815
  if ( ! *m++ ) { \
@@ -843,9 +843,9 @@ rb_ca_linear_search (int argc, VALUE *argv, VALUE self)
843
843
  {
844
844
  volatile VALUE value, veps;
845
845
  CArray *ca;
846
- int32_t addr;
846
+ ca_size_t addr;
847
847
 
848
- rb_scan_args(argc, argv, "11", &value, &veps);
848
+ rb_scan_args(argc, argv, "11", (VALUE *) &value, (VALUE *) &veps);
849
849
 
850
850
  Data_Get_Struct(self, CArray, ca);
851
851
 
@@ -878,7 +878,7 @@ rb_ca_linear_search (int argc, VALUE *argv, VALUE self)
878
878
 
879
879
  ca_detach(ca);
880
880
 
881
- return ( addr == -1 ) ? Qnil : LONG2NUM(addr);
881
+ return ( addr == -1 ) ? Qnil : SIZE2NUM(addr);
882
882
  }
883
883
 
884
884
  /* rdoc:
@@ -904,7 +904,7 @@ rb_ca_linear_search_index (int argc, VALUE *argv, VALUE self)
904
904
  type val = (type) from(value); \
905
905
  double trial; \
906
906
  double diff = 1.0/0.0; \
907
- int32_t i; \
907
+ ca_size_t i; \
908
908
  addr = -1; \
909
909
  if ( m ) { \
910
910
  for (i=0; i<ca->elements; i++, ptr++) { \
@@ -935,7 +935,7 @@ rb_ca_linear_search_index (int argc, VALUE *argv, VALUE self)
935
935
  VALUE val = value; \
936
936
  VALUE trial; \
937
937
  VALUE diff = rb_float_new(1.0/0.0); \
938
- int32_t i; \
938
+ ca_size_t i; \
939
939
  addr = -1; \
940
940
  if ( m ) { \
941
941
  for (i=0; i<ca->elements; i++, ptr++) { \
@@ -970,7 +970,7 @@ static VALUE
970
970
  rb_ca_linear_search_nearest (VALUE self, VALUE value)
971
971
  {
972
972
  CArray *ca;
973
- int32_t addr;
973
+ ca_size_t addr;
974
974
 
975
975
  Data_Get_Struct(self, CArray, ca);
976
976
 
@@ -1001,7 +1001,7 @@ rb_ca_linear_search_nearest (VALUE self, VALUE value)
1001
1001
 
1002
1002
  ca_detach(ca);
1003
1003
 
1004
- return ( addr == -1 ) ? Qnil : LONG2NUM(addr);
1004
+ return ( addr == -1 ) ? Qnil : SIZE2NUM(addr);
1005
1005
  }
1006
1006
 
1007
1007
  static VALUE