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.gemspec CHANGED
@@ -41,7 +41,5 @@ Gem::Specification::new do |s|
41
41
  s.required_ruby_version = ">= 1.8.1"
42
42
  s.add_runtime_dependency 'narray', '~> 0.6.1.1'
43
43
  s.add_runtime_dependency 'narray_miss', '~> 1.3'
44
- s.add_runtime_dependency 'axlsx', '~> 2.0'
45
- s.add_runtime_dependency 'spreadsheet', '~> 1.1'
46
44
  s.add_runtime_dependency 'sqlite3', '~> 1.3'
47
45
  end
data/carray.h CHANGED
@@ -179,6 +179,7 @@ typedef int8_t boolean8_t;
179
179
  typedef dummy_t cmplx256_t;
180
180
  #endif
181
181
 
182
+
182
183
  #include <stddef.h>
183
184
 
184
185
  #define CA_ALIGN_VOIDP offsetof(struct { char c; void *x; }, x)
@@ -198,7 +199,6 @@ typedef int8_t boolean8_t;
198
199
 
199
200
  #define CA_OBJ_TYPE_MAX 256
200
201
  #define CA_RANK_MAX 16
201
- #define CA_LENGTH_MAX 0x7fffffff
202
202
  #define CA_ATTACH_MAX 0x80000000
203
203
 
204
204
  #define CA_FLAG_SCALAR 1
@@ -272,17 +272,34 @@ enum {
272
272
 
273
273
  /* -------------------------------------------------------------------- */
274
274
 
275
+ #ifdef HAVE_TYPE_INT64_T
276
+ typedef int64_t ca_size_t;
277
+ #define CA_SIZE CA_INT64
278
+ #define NUM2SIZE(x) NUM2LL(x)
279
+ #define SIZE2NUM(x) LL2NUM(x)
280
+ #define CA_LENGTH_MAX 0x7fffffffffffffff
281
+ #else
282
+ typedef int32_t ca_size_t;
283
+ #define CA_SIZE CA_INT32
284
+ #define NUM2SIZE(x) NUM2LONG(x)
285
+ #define SIZE2NUM(x) LONG2NUM(x)
286
+ #define CA_LENGTH_MAX 0x7fffffff
287
+ #endif
288
+
289
+ /* -------------------------------------------------------------------- */
290
+
291
+
275
292
  typedef struct {
276
293
  int32_t obj_type;
277
294
  int32_t entity_type;
278
295
  void (*free_object) (void *ap);
279
296
  void * (*clone) (void *ap);
280
- char * (*ptr_at_addr) (void *ap, int32_t addr);
281
- char * (*ptr_at_index) (void *ap, int32_t *idx);
282
- void (*fetch_addr) (void *ap, int32_t addr, void *data);
283
- void (*fetch_index) (void *ap, int32_t *idx, void *data);
284
- void (*store_addr) (void *ap, int32_t addr, void *data);
285
- void (*store_index) (void *ap, int32_t *idx, void *data);
297
+ char * (*ptr_at_addr) (void *ap, ca_size_t addr);
298
+ char * (*ptr_at_index) (void *ap, ca_size_t *idx);
299
+ void (*fetch_addr) (void *ap, ca_size_t addr, void *data);
300
+ void (*fetch_index) (void *ap, ca_size_t *idx, void *data);
301
+ void (*store_addr) (void *ap, ca_size_t addr, void *data);
302
+ void (*store_index) (void *ap, ca_size_t *idx, void *data);
286
303
  void (*allocate) (void *ap);
287
304
  void (*attach) (void *ap);
288
305
  void (*sync) (void *ap);
@@ -296,12 +313,12 @@ typedef struct {
296
313
  /* default operation_function */
297
314
 
298
315
  void * ca_array_func_clone (void *ap);
299
- char * ca_array_func_ptr_at_addr (void *ap, int32_t addr);
300
- char * ca_array_func_ptr_at_index (void *ap, int32_t *idx);
301
- void ca_array_func_fetch_addr (void *ap, int32_t addr, void *ptr);
302
- void ca_array_func_fetch_index (void *ap, int32_t *idx, void *ptr);
303
- void ca_array_func_store_addr (void *ap, int32_t addr, void *ptr);
304
- void ca_array_func_store_index (void *ap, int32_t *idx, void *ptr);
316
+ char * ca_array_func_ptr_at_addr (void *ap, ca_size_t addr);
317
+ char * ca_array_func_ptr_at_index (void *ap, ca_size_t *idx);
318
+ void ca_array_func_fetch_addr (void *ap, ca_size_t addr, void *ptr);
319
+ void ca_array_func_fetch_index (void *ap, ca_size_t *idx, void *ptr);
320
+ void ca_array_func_store_addr (void *ap, ca_size_t addr, void *ptr);
321
+ void ca_array_func_store_index (void *ap, ca_size_t *idx, void *ptr);
305
322
  void ca_array_func_allocate (void *ap);
306
323
  void ca_array_func_attach (void *ap);
307
324
  void ca_array_func_sync (void *ap);
@@ -322,9 +339,9 @@ struct _CArray {
322
339
  int8_t data_type;
323
340
  int8_t rank;
324
341
  int32_t flags;
325
- int32_t bytes;
326
- int32_t elements;
327
- int32_t *dim;
342
+ ca_size_t bytes;
343
+ ca_size_t elements;
344
+ ca_size_t *dim;
328
345
  char *ptr;
329
346
  CArray *mask;
330
347
  }; /* 28 + 4*rank (bytes) */
@@ -336,12 +353,12 @@ typedef struct {
336
353
  int8_t data_type;
337
354
  int8_t rank;
338
355
  int32_t flags;
339
- int32_t bytes;
340
- int32_t elements;
341
- int32_t *dim;
356
+ ca_size_t bytes;
357
+ ca_size_t elements;
358
+ ca_size_t *dim;
342
359
  char *ptr;
343
360
  CArray *mask;
344
- int32_t _dim;
361
+ ca_size_t _dim;
345
362
  } CScalar; /* 32 (bytes) */
346
363
 
347
364
  typedef struct {
@@ -349,9 +366,9 @@ typedef struct {
349
366
  int8_t data_type;
350
367
  int8_t rank;
351
368
  int32_t flags;
352
- int32_t bytes;
353
- int32_t elements;
354
- int32_t *dim;
369
+ ca_size_t bytes;
370
+ ca_size_t elements;
371
+ ca_size_t *dim;
355
372
  char *ptr;
356
373
  CArray *mask;
357
374
  CArray *parent;
@@ -364,9 +381,9 @@ typedef struct {
364
381
  int8_t data_type;
365
382
  int8_t rank;
366
383
  int32_t flags;
367
- int32_t bytes;
368
- int32_t elements;
369
- int32_t *dim;
384
+ ca_size_t bytes;
385
+ ca_size_t elements;
386
+ ca_size_t *dim;
370
387
  char *ptr;
371
388
  CArray *mask;
372
389
  CArray *parent;
@@ -377,8 +394,8 @@ typedef struct {
377
394
  /* 1 : deformed */
378
395
  /* -2 : divided */
379
396
  /* 2 : spanned */
380
- int32_t ratio;
381
- int32_t offset;
397
+ ca_size_t ratio;
398
+ ca_size_t offset;
382
399
  CArray *mask0;
383
400
  } CARefer; /* 52 + 4*(rank) (bytes) */
384
401
 
@@ -387,9 +404,9 @@ typedef struct {
387
404
  int8_t data_type;
388
405
  int8_t rank;
389
406
  int32_t flags;
390
- int32_t bytes;
391
- int32_t elements;
392
- int32_t *dim;
407
+ ca_size_t bytes;
408
+ ca_size_t elements;
409
+ ca_size_t *dim;
393
410
  char *ptr;
394
411
  CArray *mask;
395
412
  CArray *parent;
@@ -397,13 +414,13 @@ typedef struct {
397
414
  uint8_t nosync;
398
415
  /* ---------- */
399
416
  int8_t maxdim_index;
400
- int32_t maxdim_step;
401
- int32_t maxdim_step0;
402
- int32_t offset;
403
- int32_t *start;
404
- int32_t *step;
405
- int32_t *count;
406
- int32_t *size0;
417
+ ca_size_t maxdim_step;
418
+ ca_size_t maxdim_step0;
419
+ ca_size_t offset;
420
+ ca_size_t *start;
421
+ ca_size_t *step;
422
+ ca_size_t *count;
423
+ ca_size_t *size0;
407
424
  } CABlock; /* 68 + 20*(rank) (bytes) */
408
425
 
409
426
  typedef struct {
@@ -411,9 +428,9 @@ typedef struct {
411
428
  int8_t data_type;
412
429
  int8_t rank;
413
430
  int32_t flags;
414
- int32_t bytes;
415
- int32_t elements;
416
- int32_t *dim;
431
+ ca_size_t bytes;
432
+ ca_size_t elements;
433
+ ca_size_t *dim;
417
434
  char *ptr;
418
435
  CArray *mask;
419
436
  CArray *parent;
@@ -421,9 +438,9 @@ typedef struct {
421
438
  uint8_t nosync;
422
439
  /* ---------- */
423
440
  uint8_t bounds;
424
- int32_t *start;
425
- int32_t *count;
426
- int32_t *size0;
441
+ ca_size_t *start;
442
+ ca_size_t *count;
443
+ ca_size_t *size0;
427
444
  char *fill;
428
445
  } CAWindow; /* 56 + 16*(rank) + 1*(bytes) (bytes) */
429
446
 
@@ -432,9 +449,9 @@ typedef struct {
432
449
  int8_t data_type;
433
450
  int8_t rank;
434
451
  int32_t flags;
435
- int32_t bytes;
436
- int32_t elements;
437
- int32_t *dim;
452
+ ca_size_t bytes;
453
+ ca_size_t elements;
454
+ ca_size_t *dim;
438
455
  char *ptr;
439
456
  CArray *mask;
440
457
  CArray *parent;
@@ -455,9 +472,9 @@ typedef struct {
455
472
  int8_t data_type;
456
473
  int8_t rank;
457
474
  int32_t flags;
458
- int32_t bytes;
459
- int32_t elements;
460
- int32_t *dim;
475
+ ca_size_t bytes;
476
+ ca_size_t elements;
477
+ ca_size_t *dim;
461
478
  char *ptr;
462
479
  CArray *mask;
463
480
  /* -------------*/
@@ -469,20 +486,20 @@ typedef struct {
469
486
  int8_t data_type;
470
487
  int8_t rank;
471
488
  int32_t flags;
472
- int32_t bytes;
473
- int32_t elements;
474
- int32_t *dim;
489
+ ca_size_t bytes;
490
+ ca_size_t elements;
491
+ ca_size_t *dim;
475
492
  char *ptr;
476
493
  CArray *mask;
477
494
  CArray *parent;
478
495
  uint32_t attach;
479
496
  uint8_t nosync;
480
497
  /* -------------*/
481
- int32_t *count;
482
- int32_t repeat_level;
483
- int32_t repeat_num;
484
- int32_t contig_level;
485
- int32_t contig_num;
498
+ ca_size_t *count;
499
+ ca_size_t repeat_level;
500
+ ca_size_t repeat_num;
501
+ ca_size_t contig_level;
502
+ ca_size_t contig_num;
486
503
  } CARepeat; /* 60 + 8*(rank) (bytes) */
487
504
 
488
505
  typedef struct {
@@ -490,9 +507,9 @@ typedef struct {
490
507
  int8_t data_type;
491
508
  int8_t rank;
492
509
  int32_t flags;
493
- int32_t bytes;
494
- int32_t elements;
495
- int32_t *dim;
510
+ ca_size_t bytes;
511
+ ca_size_t elements;
512
+ ca_size_t *dim;
496
513
  char *ptr;
497
514
  CArray *mask;
498
515
  CArray *parent;
@@ -500,7 +517,7 @@ typedef struct {
500
517
  uint8_t nosync;
501
518
  /* -------------*/
502
519
  int8_t rep_rank;
503
- int32_t *rep_dim;
520
+ ca_size_t *rep_dim;
504
521
  } CAUnboundRepeat; /* 44 + 8*(rank) (bytes) */
505
522
 
506
523
  /*
@@ -513,29 +530,29 @@ typedef struct {
513
530
  int8_t data_type;
514
531
  int8_t rank;
515
532
  int32_t flags;
516
- int32_t bytes;
517
- int32_t elements;
518
- int32_t *dim;
533
+ ca_size_t bytes;
534
+ ca_size_t elements;
535
+ ca_size_t *dim;
519
536
  char *ptr;
520
537
  CArray *mask;
521
538
  CArray *parent;
522
539
  uint32_t attach;
523
540
  uint8_t nosync;
524
541
  /* ---- */
525
- int32_t count;
526
- int32_t offset;
542
+ ca_size_t count;
543
+ ca_size_t offset;
527
544
  } CAReduce;
528
545
 
529
546
  /* -------------------------------------------------------------------- */
530
547
 
531
548
  typedef struct {
532
549
  int8_t rank;
533
- int32_t dim[CA_RANK_MAX];
550
+ ca_size_t dim[CA_RANK_MAX];
534
551
  CArray *reference;
535
- CArray * (*kernel_at_addr)(void *, int32_t, CArray *);
536
- CArray * (*kernel_at_index)(void *, int32_t *, CArray *);
537
- CArray * (*kernel_move_to_addr)(void *, int32_t, CArray *);
538
- CArray * (*kernel_move_to_index)(void *, int32_t *, CArray *);
552
+ CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
553
+ CArray * (*kernel_at_index)(void *, ca_size_t *, CArray *);
554
+ CArray * (*kernel_move_to_addr)(void *, ca_size_t, CArray *);
555
+ CArray * (*kernel_move_to_index)(void *, ca_size_t *, CArray *);
539
556
  } CAIterator;
540
557
 
541
558
  /* -------------------------------------------------------------------- */
@@ -597,7 +614,7 @@ extern int ca_obj_num;
597
614
 
598
615
  #define CA_CHECK_DIM(rank, dim) \
599
616
  { \
600
- int32_t i_; \
617
+ int8_t i_; \
601
618
  for (i_=0; i_<rank; i_++) { \
602
619
  if ( dim[i_] < 0 ) { \
603
620
  rb_raise(rb_eRuntimeError, "negative size dimension at %i-dim", i_); \
@@ -623,12 +640,12 @@ extern int ca_obj_num;
623
640
  index += (dim); \
624
641
  } \
625
642
  if ( index < 0 || index >= (dim) ) { \
626
- rb_raise(rb_eIndexError, "index out of range ( %i <=> 0..%i )", index, dim-1); \
643
+ rb_raise(rb_eIndexError, "index out of range ( %lld <=> 0..%lld )", (ca_size_t) index, (ca_size_t) dim-1); \
627
644
  }
628
645
 
629
646
  #define CA_CHECK_BOUND(ca, idx) \
630
647
  { \
631
- int32_t i; \
648
+ int8_t i; \
632
649
  for (i=0; i<ca->rank; i++) { \
633
650
  if ( idx[i] < 0 || idx[i] >= ca->dim[i] ) { \
634
651
  rb_raise(rb_eRuntimeError, "index out of range at %i-dim ( %i <=> 0..%i )", i, idx[i], ca->dim[i]-1); \
@@ -663,12 +680,12 @@ boolean8_t OBJ2BOOL (VALUE v);
663
680
 
664
681
  unsigned long rb_obj2ulong (VALUE);
665
682
  long rb_obj2long (VALUE);
666
- #define OBJ2LONG(x) (FIXNUM_P(x)?FIX2LONG(x):rb_obj2long((VALUE)x))
683
+ #define OBJ2LONG(x) rb_obj2long((VALUE)x)
667
684
  #define OBJ2ULONG(x) rb_obj2ulong((VALUE)x)
668
685
 
669
686
  long long rb_obj2ll (VALUE);
670
687
  unsigned long long rb_obj2ull (VALUE);
671
- #define OBJ2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_obj2ll((VALUE)x))
688
+ #define OBJ2LL(x) rb_obj2ll((VALUE)x)
672
689
  #define OBJ2ULL(x) rb_obj2ull((VALUE)x)
673
690
 
674
691
  double OBJ2DBL (VALUE v);
@@ -704,11 +721,11 @@ enum {
704
721
  }; /* CA_INDEX_TYPE */
705
722
 
706
723
  typedef union {
707
- int32_t scalar;
724
+ ca_size_t scalar;
708
725
  struct {
709
- int32_t start;
710
- int32_t step;
711
- int32_t count;
726
+ ca_size_t start;
727
+ ca_size_t step;
728
+ ca_size_t count;
712
729
  } block;
713
730
  struct {
714
731
  ID id;
@@ -728,10 +745,20 @@ typedef struct {
728
745
 
729
746
  /* -------------------------------------------------------------------- */
730
747
 
731
- typedef void (*ca_monop_func_t)();
732
- typedef void (*ca_binop_func_t)();
733
- typedef void (*ca_moncmp_func_t)();
734
- typedef void (*ca_bincmp_func_t)();
748
+ typedef void (*ca_monop_func_t)(ca_size_t n, boolean8_t *m,
749
+ char *ptr1, ca_size_t i1,
750
+ char *ptr2, ca_size_t i2);
751
+ typedef void (*ca_binop_func_t)(ca_size_t n, boolean8_t *m,
752
+ char *ptr1, ca_size_t i1,
753
+ char *ptr2, ca_size_t i2,
754
+ char *ptr3, ca_size_t i3);
755
+ typedef void (*ca_moncmp_func_t)(ca_size_t n, boolean8_t *m,
756
+ char *ptr1, ca_size_t i1,
757
+ boolean8_t *ptr2, ca_size_t i2);
758
+ typedef void (*ca_bincmp_func_t)(ca_size_t n, boolean8_t *m,
759
+ char *ptr1, ca_size_t b1, ca_size_t i1,
760
+ char *ptr2, ca_size_t b2, ca_size_t i2,
761
+ char *ptr3, ca_size_t b3, ca_size_t i3);
735
762
 
736
763
  VALUE rb_ca_call_monop (VALUE self, ca_monop_func_t func[]);
737
764
  VALUE rb_ca_call_monop_bang (VALUE self, ca_monop_func_t func[]);
@@ -739,10 +766,10 @@ VALUE rb_ca_call_binop (VALUE self, VALUE other, ca_binop_func_t func[]);
739
766
  VALUE rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[]);
740
767
  VALUE rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[]);
741
768
  VALUE rb_ca_call_bincmp (VALUE self, VALUE other, ca_bincmp_func_t func[]);
742
- void ca_monop_not_implement(int32_t n, char *ptr1, char *ptr2);
743
- void ca_binop_not_implement(int32_t n, char *ptr1, char *ptr2, char *ptr3);
744
- void ca_moncmp_not_implement(int32_t n, char *ptr1, char *ptr2);
745
- void ca_bincmp_not_implement(int32_t n, char *ptr1, char *ptr2, char *ptr3);
769
+ void ca_monop_not_implement(ca_size_t n, char *ptr1, char *ptr2);
770
+ void ca_binop_not_implement(ca_size_t n, char *ptr1, char *ptr2, char *ptr3);
771
+ void ca_moncmp_not_implement(ca_size_t n, char *ptr1, char *ptr2);
772
+ void ca_bincmp_not_implement(ca_size_t n, char *ptr1, char *ptr2, char *ptr3);
746
773
  VALUE ca_math_call (VALUE mod, VALUE arg, ID id);
747
774
 
748
775
  /* -------------------------------------------------------------------- */
@@ -750,50 +777,50 @@ VALUE ca_math_call (VALUE mod, VALUE arg, ID id);
750
777
  /* --- ca_obj_array.c --- */
751
778
 
752
779
  int carray_setup (CArray *ca,
753
- int8_t data_type, int8_t rank, int32_t *dim,
754
- int32_t bytes, CArray *mask);
780
+ int8_t data_type, int8_t rank, ca_size_t *dim,
781
+ ca_size_t bytes, CArray *mask);
755
782
 
756
783
  int carray_safe_setup (CArray *ca,
757
- int8_t data_type, int8_t rank, int32_t *dim,
758
- int32_t bytes, CArray *mask);
784
+ int8_t data_type, int8_t rank, ca_size_t *dim,
785
+ ca_size_t bytes, CArray *mask);
759
786
 
760
787
  int ca_wrap_setup_null (CArray *ca,
761
- int8_t data_type, int8_t rank, int32_t *dim,
762
- int32_t bytes, CArray *mask);
788
+ int8_t data_type, int8_t rank, ca_size_t *dim,
789
+ ca_size_t bytes, CArray *mask);
763
790
 
764
791
  void free_carray (void *ap);
765
792
  void free_ca_wrap (void *ap);
766
793
 
767
794
  CArray *carray_new (int8_t data_type,
768
- int8_t rank, int32_t *dim, int32_t bytes, CArray *ma);
795
+ int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *ma);
769
796
  CArray *carray_new_safe (int8_t data_type,
770
- int8_t rank, int32_t *dim, int32_t bytes, CArray *mask);
797
+ int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask);
771
798
  VALUE rb_carray_new (int8_t data_type,
772
- int8_t rank, int32_t *dim, int32_t bytes, CArray *mask);
799
+ int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask);
773
800
  VALUE rb_carray_new_safe (int8_t data_type,
774
- int8_t rank, int32_t *dim, int32_t bytes, CArray *mask);
801
+ int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask);
775
802
 
776
803
  CAWrap *ca_wrap_new (int8_t data_type,
777
- int8_t rank, int32_t *dim, int32_t bytes,
804
+ int8_t rank, ca_size_t *dim, ca_size_t bytes,
778
805
  CArray *mask, char *ptr);
779
806
 
780
807
  CAWrap *ca_wrap_new_null (int8_t data_type,
781
- int8_t rank, int32_t *dim, int32_t bytes,
808
+ int8_t rank, ca_size_t *dim, ca_size_t bytes,
782
809
  CArray *mask);
783
810
 
784
- CScalar *cscalar_new (int8_t data_type, int32_t bytes, CArray *ma);
785
- CScalar *cscalar_new2 (int8_t data_type, int32_t bytes, char *val);
786
- VALUE rb_cscalar_new (int8_t data_type, int32_t bytes, CArray *mask);
787
- VALUE rb_cscalar_new_with_value (int8_t data_type, int32_t bytes, VALUE rval);
811
+ CScalar *cscalar_new (int8_t data_type, ca_size_t bytes, CArray *ma);
812
+ CScalar *cscalar_new2 (int8_t data_type, ca_size_t bytes, char *val);
813
+ VALUE rb_cscalar_new (int8_t data_type, ca_size_t bytes, CArray *mask);
814
+ VALUE rb_cscalar_new_with_value (int8_t data_type, ca_size_t bytes, VALUE rval);
788
815
 
789
816
  /* --- ca_obj_refer.c --- */
790
817
 
791
818
  CARefer *ca_refer_new (CArray *ca,
792
- int8_t data_type, int8_t rank, int32_t *dim,
793
- int32_t bytes, int32_t offset);
819
+ int8_t data_type, int8_t rank, ca_size_t *dim,
820
+ ca_size_t bytes, ca_size_t offset);
794
821
  VALUE rb_ca_refer_new (VALUE self,
795
- int8_t data_type, int8_t rank, int32_t *dim,
796
- int32_t bytes, int32_t offset);
822
+ int8_t data_type, int8_t rank, ca_size_t *dim,
823
+ ca_size_t bytes, ca_size_t offset);
797
824
 
798
825
  /* --- ca_obj_farray.c --- */
799
826
 
@@ -802,12 +829,12 @@ VALUE rb_ca_farray (VALUE self);
802
829
  /* --- ca_obj_block.c --- */
803
830
 
804
831
  CABlock *ca_block_new (CArray *carray,
805
- int8_t rank, int32_t *dim,
806
- int32_t *start, int32_t *step, int32_t *count,
807
- int32_t offset);
808
- VALUE rb_ca_block_new (VALUE cary, int8_t rank, int32_t *dim,
809
- int32_t *start, int32_t *step, int32_t *count,
810
- int32_t offset);
832
+ int8_t rank, ca_size_t *dim,
833
+ ca_size_t *start, ca_size_t *step, ca_size_t *count,
834
+ ca_size_t offset);
835
+ VALUE rb_ca_block_new (VALUE cary, int8_t rank, ca_size_t *dim,
836
+ ca_size_t *start, ca_size_t *step, ca_size_t *count,
837
+ ca_size_t offset);
811
838
 
812
839
  /* --- ca_obj_select.c --- */
813
840
 
@@ -816,7 +843,7 @@ VALUE rb_ca_select_new_share (VALUE cary, VALUE select);
816
843
 
817
844
  /* --- ca_obj_grid.c --- */
818
845
 
819
- VALUE rb_ca_grid_new (VALUE cary, int32_t *dim, CArray **grid);
846
+ VALUE rb_ca_grid_new (VALUE cary, ca_size_t *dim, CArray **grid);
820
847
  VALUE rb_ca_grid (int argc, VALUE *argv, VALUE self);
821
848
 
822
849
  /* --- ca_obj_mapping.c --- */
@@ -827,27 +854,27 @@ VALUE rb_ca_mapping (int argc, VALUE *argv, VALUE self);
827
854
  /* --- ca_obj_field.c --- */
828
855
 
829
856
  VALUE rb_ca_field_new (VALUE cary,
830
- int32_t offset, int8_t data_type, int32_t bytes);
857
+ ca_size_t offset, int8_t data_type, ca_size_t bytes);
831
858
  VALUE rb_ca_field (int argc, VALUE *argv, VALUE self);
832
859
 
833
860
  /* --- ca_obj_fake.c --- */
834
861
 
835
- VALUE rb_ca_fake_new (VALUE cary, int8_t data_type, int32_t bytes);
862
+ VALUE rb_ca_fake_new (VALUE cary, int8_t data_type, ca_size_t bytes);
836
863
  VALUE rb_ca_fake_type (VALUE self, VALUE rtype, VALUE rbytes);
837
864
 
838
865
  /* --- ca_obj_repeat.c --- */
839
866
 
840
- CARepeat *ca_repeat_new (CArray *carray, int8_t rank, int32_t *count);
867
+ CARepeat *ca_repeat_new (CArray *carray, int8_t rank, ca_size_t *count);
841
868
 
842
- VALUE rb_ca_repeat_new (VALUE cary, int8_t rank, int32_t *count);
869
+ VALUE rb_ca_repeat_new (VALUE cary, int8_t rank, ca_size_t *count);
843
870
  VALUE rb_ca_repeat (int argc, VALUE *argv, VALUE self);
844
871
 
845
- VALUE rb_ca_ubrep_new (VALUE cary, int32_t rep_rank, int32_t *rep_dim);
872
+ VALUE rb_ca_ubrep_new (VALUE cary, int32_t rep_rank, ca_size_t *rep_dim);
846
873
  VALUE ca_ubrep_bind_with (VALUE self, VALUE other);
847
874
 
848
875
  /* --- ca_obj_reduce.c --- */
849
876
 
850
- CAReduce *ca_reduce_new (CArray *carray, int32_t count, int32_t offset);
877
+ CAReduce *ca_reduce_new (CArray *carray, ca_size_t count, ca_size_t offset);
851
878
 
852
879
  /* --- ca_iter_dimension --- */
853
880
 
@@ -895,14 +922,14 @@ int ca_is_object_type (void *ap);
895
922
  void ca_check_type (void *ap, int8_t data_type);
896
923
  #define ca_check_data_type(ap, data_type) ca_check_type(ap, data_type)
897
924
  void ca_check_rank (void *ap, int rank);
898
- void ca_check_shape (void *ap, int rank, int32_t *dim);
925
+ void ca_check_shape (void *ap, int rank, ca_size_t *dim);
899
926
  void ca_check_same_data_type (void *ap1, void *ap2);
900
927
  void ca_check_same_rank (void *ap1, void *ap2);
901
928
  void ca_check_same_elements (void *ap1, void *ap2);
902
929
  void ca_check_same_shape (void *ap1, void *ap2);
903
- void ca_check_index (void *ap, int32_t *idx);
930
+ void ca_check_index (void *ap, ca_size_t *idx);
904
931
  void ca_check_data_class (VALUE rtype);
905
- int ca_is_valid_index (void *ap, int32_t *idx);
932
+ int ca_is_valid_index (void *ap, ca_size_t *idx);
906
933
 
907
934
  /* API : allocate, attach, update, sync, detach */
908
935
 
@@ -924,25 +951,25 @@ void *ca_clone (void *ap); /* use rb_obj_clone() */
924
951
  CArray *ca_copy (void *ap); /* use rb_ca_copy() */
925
952
  CArray *ca_template (void *ap); /* use rb_ca_template() */
926
953
  CArray *ca_template_safe (void *ap); /* use rb_ca_template() */
927
- CArray *ca_template_safe2 (void *ap, int8_t data_type, int32_t bytes);
954
+ CArray *ca_template_safe2 (void *ap, int8_t data_type, ca_size_t bytes);
928
955
  /* use rb_ca_template() */
929
956
 
930
- void ca_paste (void *ap, int32_t *idx, void *sp);
931
- void ca_cut (void *ap, int32_t *offset, void *sp);
957
+ void ca_paste (void *ap, ca_size_t *idx, void *sp);
958
+ void ca_cut (void *ap, ca_size_t *offset, void *sp);
932
959
  void ca_fill (void *ap, void *ptr);
933
960
 
934
961
  /* API : fetch, store */
935
962
 
936
- void ca_addr2index (void *ap, int32_t addr, int32_t *idx);
937
- int32_t ca_index2addr (void *ap, int32_t *idx);
963
+ void ca_addr2index (void *ap, ca_size_t addr, ca_size_t *idx);
964
+ ca_size_t ca_index2addr (void *ap, ca_size_t *idx);
938
965
 
939
- void *ca_ptr_at_index (void *ap, int32_t *idx);
940
- void *ca_ptr_at_addr (void *ap, int32_t addr);
966
+ void *ca_ptr_at_index (void *ap, ca_size_t *idx);
967
+ void *ca_ptr_at_addr (void *ap, ca_size_t addr);
941
968
 
942
- void ca_fetch_index (void *ap, int32_t *idx, void *ptr);
943
- void ca_fetch_addr (void *ap, int32_t addr, void *ptr);
944
- void ca_store_index (void *ap, int32_t *idx, void *ptr);
945
- void ca_store_addr (void *ap, int32_t addr, void *ptr);
969
+ void ca_fetch_index (void *ap, ca_size_t *idx, void *ptr);
970
+ void ca_fetch_addr (void *ap, ca_size_t addr, void *ptr);
971
+ void ca_store_index (void *ap, ca_size_t *idx, void *ptr);
972
+ void ca_store_addr (void *ap, ca_size_t addr, void *ptr);
946
973
 
947
974
  void ca_copy_data (void *ap, char *ptr);
948
975
  void ca_sync_data (void *ap, char *ptr);
@@ -962,21 +989,21 @@ void ca_create_mask (void *ap);
962
989
  void ca_clear_mask (void *ap);
963
990
  void ca_setup_mask (void *ap, CArray *mask);
964
991
  void ca_copy_mask (void *ap, void *ao);
965
- void ca_copy_mask_overlay_n (void *ap, int32_t elements, int n, CArray **slist);
966
- void ca_copy_mask_overlay (void *ap, int32_t elements, int n, ...);
967
- void ca_copy_mask_overwrite_n (void *ap, int32_t elements, int n, CArray **slist);
968
- void ca_copy_mask_overwrite (void *ap, int32_t elements, int n, ...);
969
- int32_t ca_count_masked (void *ap);
970
- int32_t ca_count_not_masked (void *ap);
992
+ void ca_copy_mask_overlay_n (void *ap, ca_size_t elements, int n, CArray **slist);
993
+ void ca_copy_mask_overlay (void *ap, ca_size_t elements, int n, ...);
994
+ void ca_copy_mask_overwrite_n (void *ap, ca_size_t elements, int n, CArray **slist);
995
+ void ca_copy_mask_overwrite (void *ap, ca_size_t elements, int n, ...);
996
+ ca_size_t ca_count_masked (void *ap);
997
+ ca_size_t ca_count_not_masked (void *ap);
971
998
  void ca_unmask (void *ap, char *fill_value);
972
999
  CArray *ca_unmasked_copy (void *ap, char *fill_value);
973
1000
 
974
1001
  /* API : cast, conversion */
975
1002
 
976
- typedef void (*ca_cast_func_t)(int32_t, CArray *, void *, CArray *, void *, boolean8_t *);
1003
+ typedef void (*ca_cast_func_t)(ca_size_t, CArray *, void *, CArray *, void *, boolean8_t *);
977
1004
  extern ca_cast_func_t ca_cast_func_table[CA_NTYPE][CA_NTYPE];
978
- void ca_cast_block(int32_t n, void *a1, void *ptr1, void *a2, void *ptr2);
979
- void ca_cast_block_with_mask (int32_t n, void *ap1, void *ptr1,
1005
+ void ca_cast_block(ca_size_t n, void *a1, void *ptr1, void *a2, void *ptr2);
1006
+ void ca_cast_block_with_mask (ca_size_t n, void *ap1, void *ptr1,
980
1007
  void *ap2, void *ptr2, boolean8_t *m);
981
1008
  void ca_ptr2ptr (void *ca1, void *ptr1, void *ca2, void *ptr2);
982
1009
  void ca_ptr2val (void *ap1, void *ptr1, int8_t data_type2, void *ptr2);
@@ -986,7 +1013,7 @@ VALUE ca_ptr2obj (void *ap, void *ptr); /* use rb_ca_ptr2obj() */
986
1013
  void ca_obj2ptr (void *ap, VALUE obj, void *ptr); /* use rb_ca_ptr2obj() */
987
1014
 
988
1015
  void ca_block_from_carray(CArray *cs,
989
- int32_t *start, int32_t *step, int32_t *count, CArray *ca);
1016
+ ca_size_t *start, ca_size_t *step, ca_size_t *count, CArray *ca);
990
1017
 
991
1018
  #define ca_wrap_writable(obj, data_type) \
992
1019
  (obj = rb_ca_wrap_writable(obj, INT2NUM(data_type)), (CArray*) DATA_PTR(obj))
@@ -994,7 +1021,7 @@ void ca_block_from_carray(CArray *cs,
994
1021
  (obj = rb_ca_wrap_readonly(obj, INT2NUM(data_type)), (CArray*) DATA_PTR(obj))
995
1022
 
996
1023
  VALUE rb_carray_wrap_ptr (int8_t data_type,
997
- int8_t rank, int32_t *dim, int32_t bytes,
1024
+ int8_t rank, ca_size_t *dim, ca_size_t bytes,
998
1025
  CArray *mask, char *ptr, VALUE refer);
999
1026
 
1000
1027
  void * ca_to_cptr (void *ap);
@@ -1004,19 +1031,19 @@ void * ca_to_cptr (void *ap);
1004
1031
  boolean8_t *ca_allocate_mask_iterator (int n, ...);
1005
1032
  boolean8_t *ca_allocate_mask_iterator_n (int n, CArray **slist);
1006
1033
 
1007
- int32_t ca_get_loop_count (int n, ...);
1008
- int32_t ca_set_iterator (int n, ...);
1034
+ ca_size_t ca_get_loop_count (int n, ...);
1035
+ ca_size_t ca_set_iterator (int n, ...);
1009
1036
 
1010
- void ca_swap_bytes (char *p, int32_t bytes, int32_t elements);
1011
- void ca_parse_range (VALUE vrange, int size,
1012
- int *offset, int *count, int *step);
1013
- void ca_parse_range_without_check (VALUE arg, int size,
1014
- int *offset, int *count, int *step);
1037
+ void ca_swap_bytes (char *p, ca_size_t bytes, ca_size_t elements);
1038
+ void ca_parse_range (VALUE vrange, ca_size_t size,
1039
+ ca_size_t *offset, ca_size_t *count, ca_size_t *step);
1040
+ void ca_parse_range_without_check (VALUE arg, ca_size_t size,
1041
+ ca_size_t *offset, ca_size_t *count, ca_size_t *step);
1015
1042
 
1016
1043
  int ca_equal (void *ap, void *bp);
1017
1044
  void ca_zerodiv(void);
1018
1045
  int32_t ca_rand (double rmax);
1019
- int32_t ca_bounds_normalize_index (int8_t bounds, int32_t size0, int32_t k);
1046
+ ca_size_t ca_bounds_normalize_index (int8_t bounds, ca_size_t size0, ca_size_t k);
1020
1047
 
1021
1048
  /* API : high level */
1022
1049
 
@@ -1036,12 +1063,12 @@ VALUE ca_wrap_struct (void *ap);
1036
1063
  /* query data_type */
1037
1064
  int8_t rb_ca_guess_type (VALUE obj);
1038
1065
  void rb_ca_guess_type_and_bytes (VALUE rtype, VALUE rbytes,
1039
- int8_t *data_type, int32_t *bytes);
1066
+ int8_t *data_type, ca_size_t *bytes);
1040
1067
  int rb_ca_is_type (VALUE arg, int type);
1041
1068
 
1042
1069
  /* scan index */
1043
- void rb_ca_scan_index (int ca_rank, int32_t *ca_dim, int32_t elements,
1044
- int argc, VALUE *argv, CAIndexInfo *info);
1070
+ void rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t elements,
1071
+ long argc, VALUE *argv, CAIndexInfo *info);
1045
1072
 
1046
1073
  /* cast */
1047
1074
  void rb_ca_cast_self (volatile VALUE *self);
@@ -1141,15 +1168,15 @@ VALUE rb_ca_addr2index (VALUE self, VALUE raddr);
1141
1168
  /* elemental access like ca[i,j,k] or ca[addr] */
1142
1169
  VALUE rb_ca_ptr2obj (VALUE self, void *ptr);
1143
1170
  #define rb_ca_fetch_ptr(self, ptr) rb_ca_ptr2obj(self, ptr)
1144
- VALUE rb_ca_fetch_index (VALUE self, int32_t *idx);
1145
- VALUE rb_ca_fetch_addr (VALUE self, int32_t addr);
1171
+ VALUE rb_ca_fetch_index (VALUE self, ca_size_t *idx);
1172
+ VALUE rb_ca_fetch_addr (VALUE self, ca_size_t addr);
1146
1173
  VALUE rb_ca_fetch (VALUE self, VALUE index);
1147
1174
  VALUE rb_ca_fetch2 (VALUE self, int n, VALUE *vindex);
1148
1175
 
1149
1176
  VALUE rb_ca_obj2ptr (VALUE self, VALUE val, void *ptr);
1150
1177
  #define rb_ca_store_ptr(self, ptr, val) rb_ca_obj2ptr(self, val, ptr)
1151
- VALUE rb_ca_store_index (VALUE self, int32_t *idx, VALUE val);
1152
- VALUE rb_ca_store_addr (VALUE self, int32_t addr, VALUE val);
1178
+ VALUE rb_ca_store_index (VALUE self, ca_size_t *idx, VALUE val);
1179
+ VALUE rb_ca_store_addr (VALUE self, ca_size_t addr, VALUE val);
1153
1180
  VALUE rb_ca_store (VALUE self, VALUE index, VALUE val);
1154
1181
  VALUE rb_ca_store2 (VALUE self, int n, VALUE *vindex, VALUE val);
1155
1182
  VALUE rb_ca_store_all (VALUE self, VALUE val);
@@ -1166,7 +1193,7 @@ VALUE rb_ca_elem_test_masked (VALUE self, VALUE vidx1);
1166
1193
  /* data type conversion */
1167
1194
  VALUE rb_ca_ptr2ptr (VALUE ra1, void *ptr1, VALUE ra2, void *ptr2);
1168
1195
  #define rb_ca_cast_ptr (VALUE ra1, void *ptr1, VALUE ra2, void *ptr2);
1169
- VALUE rb_ca_cast_block (int32_t n, VALUE ra1, void *ptr1,
1196
+ VALUE rb_ca_cast_block (ca_size_t n, VALUE ra1, void *ptr1,
1170
1197
  VALUE ra2, void *ptr2);
1171
1198
 
1172
1199
  VALUE rb_ca_to_type (VALUE self, VALUE rtype, VALUE rbytes);