carray 1.4.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSES +22 -0
  3. data/README.md +18 -14
  4. data/Rakefile +1 -1
  5. data/carray.gemspec +5 -13
  6. data/{ca_iter_block.c → ext/ca_iter_block.c} +13 -13
  7. data/{ca_iter_dimension.c → ext/ca_iter_dimension.c} +16 -16
  8. data/{ca_iter_window.c → ext/ca_iter_window.c} +10 -10
  9. data/{ca_obj_array.c → ext/ca_obj_array.c} +60 -55
  10. data/{ca_obj_bitarray.c → ext/ca_obj_bitarray.c} +12 -12
  11. data/{ca_obj_bitfield.c → ext/ca_obj_bitfield.c} +7 -7
  12. data/{ca_obj_block.c → ext/ca_obj_block.c} +42 -42
  13. data/{ca_obj_fake.c → ext/ca_obj_fake.c} +7 -7
  14. data/{ca_obj_farray.c → ext/ca_obj_farray.c} +18 -18
  15. data/{ca_obj_field.c → ext/ca_obj_field.c} +15 -15
  16. data/{ca_obj_grid.c → ext/ca_obj_grid.c} +27 -27
  17. data/{ca_obj_mapping.c → ext/ca_obj_mapping.c} +9 -9
  18. data/{ca_obj_object.c → ext/ca_obj_object.c} +37 -37
  19. data/{ca_obj_reduce.c → ext/ca_obj_reduce.c} +1 -1
  20. data/{ca_obj_refer.c → ext/ca_obj_refer.c} +33 -33
  21. data/{ca_obj_repeat.c → ext/ca_obj_repeat.c} +43 -43
  22. data/{ca_obj_select.c → ext/ca_obj_select.c} +2 -2
  23. data/{ca_obj_shift.c → ext/ca_obj_shift.c} +23 -23
  24. data/{ca_obj_transpose.c → ext/ca_obj_transpose.c} +23 -23
  25. data/{ca_obj_unbound_repeat.c → ext/ca_obj_unbound_repeat.c} +55 -55
  26. data/{ca_obj_window.c → ext/ca_obj_window.c} +26 -26
  27. data/{carray.h → ext/carray.h} +73 -51
  28. data/{carray_access.c → ext/carray_access.c} +83 -83
  29. data/{carray_attribute.c → ext/carray_attribute.c} +12 -12
  30. data/{carray_call_cfunc.c → ext/carray_call_cfunc.c} +0 -0
  31. data/{carray_cast.c → ext/carray_cast.c} +6 -6
  32. data/{carray_cast_func.rb → ext/carray_cast_func.rb} +0 -0
  33. data/{carray_class.c → ext/carray_class.c} +0 -0
  34. data/{carray_conversion.c → ext/carray_conversion.c} +8 -10
  35. data/{carray_copy.c → ext/carray_copy.c} +19 -19
  36. data/{carray_core.c → ext/carray_core.c} +2 -2
  37. data/ext/carray_data_type.c +66 -0
  38. data/{carray_element.c → ext/carray_element.c} +9 -9
  39. data/{carray_generate.c → ext/carray_generate.c} +0 -0
  40. data/{carray_iterator.c → ext/carray_iterator.c} +40 -38
  41. data/{carray_loop.c → ext/carray_loop.c} +24 -24
  42. data/{carray_mask.c → ext/carray_mask.c} +17 -6
  43. data/{carray_math.rb → ext/carray_math.rb} +3 -3
  44. data/ext/{mathfunc/carray_mathfunc.c → carray_mathfunc.c} +0 -0
  45. data/{carray_numeric.c → ext/carray_numeric.c} +1 -1
  46. data/{carray_operator.c → ext/carray_operator.c} +9 -9
  47. data/{carray_order.c → ext/carray_order.c} +2 -153
  48. data/{carray_sort_addr.c → ext/carray_sort_addr.c} +0 -0
  49. data/{carray_stat.c → ext/carray_stat.c} +5 -5
  50. data/{carray_stat_proc.rb → ext/carray_stat_proc.rb} +23 -23
  51. data/{carray_test.c → ext/carray_test.c} +22 -21
  52. data/{carray_undef.c → ext/carray_undef.c} +0 -0
  53. data/{carray_utils.c → ext/carray_utils.c} +0 -0
  54. data/{extconf.rb → ext/extconf.rb} +0 -5
  55. data/{mkmath.rb → ext/mkmath.rb} +0 -0
  56. data/{ruby_carray.c → ext/ruby_carray.c} +9 -2
  57. data/{ruby_ccomplex.c → ext/ruby_ccomplex.c} +0 -0
  58. data/{ruby_float_func.c → ext/ruby_float_func.c} +0 -0
  59. data/{version.h → ext/version.h} +5 -5
  60. data/{version.rb → ext/version.rb} +0 -0
  61. data/lib/carray.rb +48 -37
  62. data/lib/carray/{base/autoload.rb → autoload.rb} +1 -1
  63. data/lib/carray/autoload/autoload_base.rb +1 -1
  64. data/lib/carray/autoload/autoload_gem_numo_narray.rb +4 -3
  65. data/lib/carray/autoload/autoload_gem_random.rb +8 -0
  66. data/lib/carray/basic.rb +193 -0
  67. data/lib/carray/compose.rb +291 -0
  68. data/lib/carray/construct.rb +445 -0
  69. data/lib/carray/convert.rb +115 -0
  70. data/lib/carray/{base/inspect.rb → inspect.rb} +6 -6
  71. data/lib/carray/io/imagemagick.rb +1 -1
  72. data/lib/carray/{base/iterator.rb → iterator.rb} +3 -3
  73. data/lib/carray/mask.rb +91 -0
  74. data/lib/carray/{base/math.rb → math.rb} +16 -46
  75. data/lib/carray/math/histogram.rb +7 -7
  76. data/lib/carray/mkmf.rb +8 -0
  77. data/lib/carray/object/ca_obj_pack.rb +8 -8
  78. data/lib/carray/obsolete.rb +272 -0
  79. data/lib/carray/ordering.rb +157 -0
  80. data/lib/carray/{base/serialize.rb → serialize.rb} +28 -53
  81. data/lib/carray/{base/string.rb → string.rb} +12 -64
  82. data/lib/carray/{base/struct.rb → struct.rb} +16 -16
  83. data/lib/carray/{io/table.rb → table.rb} +1 -10
  84. data/lib/carray/testing.rb +56 -0
  85. data/lib/carray/time.rb +78 -0
  86. data/lib/carray/transform.rb +100 -0
  87. data/misc/Methods.ja.md +182 -0
  88. data/{NOTE → misc/NOTE} +0 -0
  89. data/test/test_ALL.rb +0 -2
  90. data/test/test_order.rb +7 -7
  91. data/test/test_ref_store.rb +13 -13
  92. data/test/test_stat.rb +7 -15
  93. data/{devel → utils}/guess_shape.rb +0 -0
  94. data/utils/{diff_method.rb → monkey_patch_methods.rb} +17 -7
  95. metadata +88 -151
  96. data/COPYING +0 -56
  97. data/GPL +0 -340
  98. data/LEGAL +0 -50
  99. data/TODO +0 -5
  100. data/carray_random.c +0 -531
  101. data/devel/im2col.rb +0 -17
  102. data/ext/calculus/carray_calculus.c +0 -931
  103. data/ext/calculus/carray_interp.c +0 -358
  104. data/ext/calculus/extconf.rb +0 -12
  105. data/ext/calculus/lib/math/calculus.rb +0 -119
  106. data/ext/calculus/lib/math/interp/adapter_interp1d.rb +0 -31
  107. data/ext/mathfunc/extconf.rb +0 -18
  108. data/ext/mathfunc/test/test_hypot.rb +0 -5
  109. data/ext/mathfunc/test/test_j0.rb +0 -22
  110. data/ext/mathfunc/test/test_jn.rb +0 -8
  111. data/ext/mathfunc/test/test_sph.rb +0 -9
  112. data/lib/carray/autoload/autoload_io_table.rb +0 -1
  113. data/lib/carray/autoload/autoload_math_interp.rb +0 -4
  114. data/lib/carray/base/basic.rb +0 -1146
  115. data/lib/carray/base/obsolete.rb +0 -131
  116. data/lib/carray/math/interp.rb +0 -57
  117. data/lib/carray/math/interp/adapter_gsl_spline.rb +0 -47
  118. data/mt19937ar.c +0 -182
  119. data/mt19937ar.h +0 -86
  120. data/rdoc_main.rb +0 -27
  121. data/rdoc_math.rb +0 -5
  122. data/rdoc_stat.rb +0 -31
  123. data/test/test_narray.rb +0 -64
  124. data/test/test_random.rb +0 -15
  125. data/utils/create_rdoc.sh +0 -9
  126. data/utils/make_tgz.sh +0 -3
@@ -59,10 +59,10 @@ static VALUE rb_cCAObjectMask;
59
59
 
60
60
 
61
61
  static CAObjectMask *
62
- ca_objmask_new (VALUE array, int8_t rank, ca_size_t *dim)
62
+ ca_objmask_new (VALUE array, int8_t ndim, ca_size_t *dim)
63
63
  {
64
64
  CAObjectMask *ca = ALLOC(CAObjectMask);
65
- ca_wrap_setup_null((CArray *)ca, CA_BOOLEAN, rank, dim, 0, NULL);
65
+ ca_wrap_setup_null((CArray *)ca, CA_BOOLEAN, ndim, dim, 0, NULL);
66
66
  ca->obj_type = CA_OBJ_OBJECT_MASK;
67
67
  ca->array = array;
68
68
 
@@ -81,7 +81,7 @@ static void *
81
81
  ca_objmask_func_clone (void *ap)
82
82
  {
83
83
  CAObjectMask *ca = (CAObjectMask *) ap;
84
- return ca_objmask_new(ca->array, ca->rank, ca->dim);
84
+ return ca_objmask_new(ca->array, ca->ndim, ca->dim);
85
85
  }
86
86
 
87
87
  void
@@ -100,8 +100,8 @@ ca_objmask_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
100
100
  else if ( rb_obj_respond_to(ca->array, rb_intern("mask_fetch_index"), Qtrue) ) {
101
101
  ca_size_t idx[CA_RANK_MAX];
102
102
  ca_addr2index(ca, addr, idx);
103
- ridx = rb_ary_new2(ca->rank);
104
- for (i=0; i<ca->rank; i++) {
103
+ ridx = rb_ary_new2(ca->ndim);
104
+ for (i=0; i<ca->ndim; i++) {
105
105
  rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
106
106
  }
107
107
  rval = rb_funcall(ca->array, rb_intern("mask_fetch_index"), 1, ridx);
@@ -121,8 +121,8 @@ ca_objmask_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
121
121
  int i;
122
122
 
123
123
  if ( rb_obj_respond_to(ca->array, rb_intern("mask_fetch_index"), Qtrue) ) {
124
- ridx = rb_ary_new2(ca->rank);
125
- for (i=0; i<ca->rank; i++) {
124
+ ridx = rb_ary_new2(ca->ndim);
125
+ for (i=0; i<ca->ndim; i++) {
126
126
  rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
127
127
  }
128
128
  rval = rb_funcall(ca->array, rb_intern("mask_fetch_index"), 1, ridx);
@@ -158,8 +158,8 @@ ca_objmask_func_store_addr (void *ap, ca_size_t addr, void *ptr)
158
158
  else if ( rb_obj_respond_to(ca->array, rb_intern("mask_store_index"), Qtrue) ) {
159
159
  ca_size_t idx[CA_RANK_MAX];
160
160
  ca_addr2index(ca, addr, idx);
161
- ridx = rb_ary_new2(ca->rank);
162
- for (i=0; i<ca->rank; i++) {
161
+ ridx = rb_ary_new2(ca->ndim);
162
+ for (i=0; i<ca->ndim; i++) {
163
163
  rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
164
164
  }
165
165
  rb_funcall(ca->array, rb_intern("mask_store_index"), 2, ridx, rval);
@@ -177,8 +177,8 @@ ca_objmask_func_store_index (void *ap, ca_size_t *idx, void *ptr)
177
177
  rval = INT2NUM( *(uint8_t*)ptr );
178
178
 
179
179
  if ( rb_obj_respond_to(ca->array, rb_intern("mask_store_index"), Qtrue) ) {
180
- ridx = rb_ary_new2(ca->rank);
181
- for (i=0; i<ca->rank; i++) {
180
+ ridx = rb_ary_new2(ca->ndim);
181
+ for (i=0; i<ca->ndim; i++) {
182
182
  rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
183
183
  }
184
184
  rb_funcall(ca->array, rb_intern("mask_store_index"), 2, ridx, rval);
@@ -290,7 +290,7 @@ rb_ca_objmask_initialize_copy (VALUE self, VALUE other)
290
290
  Data_Get_Struct(self, CAObjectMask, ca);
291
291
  Data_Get_Struct(other, CAObjectMask, cs);
292
292
 
293
- carray_setup((CArray *)ca, CA_BOOLEAN, cs->rank, cs->dim, 0, NULL);
293
+ carray_setup((CArray *)ca, CA_BOOLEAN, cs->ndim, cs->dim, 0, NULL);
294
294
  ca->obj_type = CA_OBJ_OBJECT_MASK;
295
295
  ca->array = cs->array;
296
296
 
@@ -301,7 +301,7 @@ rb_ca_objmask_initialize_copy (VALUE self, VALUE other)
301
301
 
302
302
  static int
303
303
  ca_object_setup (CAObject *ca,
304
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes)
304
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes)
305
305
  {
306
306
  ca_size_t elements;
307
307
  double length;
@@ -310,15 +310,15 @@ ca_object_setup (CAObject *ca,
310
310
  /* check arguments */
311
311
 
312
312
  CA_CHECK_DATA_TYPE(data_type);
313
- CA_CHECK_RANK(rank);
314
- CA_CHECK_DIM(rank, dim);
313
+ CA_CHECK_RANK(ndim);
314
+ CA_CHECK_DIM(ndim, dim);
315
315
  CA_CHECK_BYTES(data_type, bytes);
316
316
 
317
317
  /* calculate total number of elements */
318
318
 
319
319
  elements = 1;
320
320
  length = bytes;
321
- for (i=0; i<rank; i++) {
321
+ for (i=0; i<ndim; i++) {
322
322
  elements *= dim[i];
323
323
  length *= dim[i];
324
324
  }
@@ -330,7 +330,7 @@ ca_object_setup (CAObject *ca,
330
330
  ca->obj_type = CA_OBJ_OBJECT;
331
331
  ca->data_type = data_type;
332
332
  ca->flags = 0;
333
- ca->rank = rank;
333
+ ca->ndim = ndim;
334
334
  ca->bytes = bytes;
335
335
  ca->elements = elements;
336
336
  ca->ptr = NULL;
@@ -339,20 +339,20 @@ ca_object_setup (CAObject *ca,
339
339
  ca->attach = 0;
340
340
  ca->nosync = 0;
341
341
 
342
- ca->dim = ALLOC_N(ca_size_t, rank);
342
+ ca->dim = ALLOC_N(ca_size_t, ndim);
343
343
 
344
- ca->data = ca_wrap_new_null(data_type, rank, dim, bytes, NULL);
344
+ ca->data = ca_wrap_new_null(data_type, ndim, dim, bytes, NULL);
345
345
 
346
- memcpy(ca->dim, dim, rank * sizeof(ca_size_t));
346
+ memcpy(ca->dim, dim, ndim * sizeof(ca_size_t));
347
347
 
348
348
  return 0;
349
349
  }
350
350
 
351
351
  static CAObject *
352
- ca_object_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes)
352
+ ca_object_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes)
353
353
  {
354
354
  CAObject *ca = ALLOC(CAObject);
355
- ca_object_setup(ca, data_type, rank, dim, bytes);
355
+ ca_object_setup(ca, data_type, ndim, dim, bytes);
356
356
  return ca;
357
357
  }
358
358
 
@@ -373,7 +373,7 @@ static void *
373
373
  ca_object_func_clone (void *ap)
374
374
  {
375
375
  CAObject *ca = (CAObject *) ap;
376
- return ca_object_new(ca->bytes, ca->rank, ca->dim, ca->bytes);
376
+ return ca_object_new(ca->bytes, ca->ndim, ca->dim, ca->bytes);
377
377
  }
378
378
 
379
379
  #define ca_object_func_ptr_at_addr ca_array_func_ptr_at_addr
@@ -408,8 +408,8 @@ ca_object_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
408
408
  else {
409
409
  ca_size_t idx[CA_RANK_MAX];
410
410
  ca_addr2index(ca, addr, idx);
411
- ridx = rb_ary_new2(ca->rank);
412
- for (i=0; i<ca->rank; i++) {
411
+ ridx = rb_ary_new2(ca->ndim);
412
+ for (i=0; i<ca->ndim; i++) {
413
413
  rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
414
414
  }
415
415
  rval = rb_funcall(ca->self, rb_intern("fetch_index"), 1, ridx);
@@ -439,8 +439,8 @@ ca_object_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
439
439
  volatile VALUE ridx, raddr, rval;
440
440
  int i;
441
441
  if ( rb_obj_respond_to(ca->self, rb_intern("fetch_index"), Qtrue) ) {
442
- ridx = rb_ary_new2(ca->rank);
443
- for (i=0; i<ca->rank; i++) {
442
+ ridx = rb_ary_new2(ca->ndim);
443
+ for (i=0; i<ca->ndim; i++) {
444
444
  rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
445
445
  }
446
446
  rval = rb_funcall(ca->self, rb_intern("fetch_index"), 1, ridx);
@@ -498,8 +498,8 @@ ca_object_func_store_addr (void *ap, ca_size_t addr, void *ptr)
498
498
  else {
499
499
  ca_size_t idx[CA_RANK_MAX];
500
500
  ca_addr2index(ca, addr, idx);
501
- ridx = rb_ary_new2(ca->rank);
502
- for (i=0; i<ca->rank; i++) {
501
+ ridx = rb_ary_new2(ca->ndim);
502
+ for (i=0; i<ca->ndim; i++) {
503
503
  rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
504
504
  }
505
505
  rval = rb_ca_ptr2obj(ca->self, ptr);
@@ -514,8 +514,8 @@ ca_object_func_store_index (void *ap, ca_size_t *idx, void *ptr)
514
514
  volatile VALUE ridx, raddr, rval;
515
515
  int i;
516
516
  if ( rb_obj_respond_to(ca->self, rb_intern("store_index"), Qtrue) ) {
517
- ridx = rb_ary_new2(ca->rank);
518
- for (i=0; i<ca->rank; i++) {
517
+ ridx = rb_ary_new2(ca->ndim);
518
+ for (i=0; i<ca->ndim; i++) {
519
519
  rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
520
520
  }
521
521
  rval = rb_ca_ptr2obj(ca->self, ptr);
@@ -634,7 +634,7 @@ ca_object_func_create_mask (void *ap)
634
634
  if ( ! ca->data->mask ) {
635
635
  ca_create_mask(ca->data);
636
636
  }
637
- ca->mask = (CArray*) ca_objmask_new(ca->self, ca->rank, ca->dim);
637
+ ca->mask = (CArray*) ca_objmask_new(ca->self, ca->ndim, ca->dim);
638
638
  ca->mask->ptr = ca->data->mask->ptr;
639
639
  rmask = ca_wrap_struct(ca->mask);
640
640
  rb_ivar_set(ca->self, rb_intern("mask"), rmask);
@@ -679,7 +679,7 @@ rb_ca_object_initialize_copy (VALUE self, VALUE other)
679
679
  Data_Get_Struct(self, CAObject, ca);
680
680
  Data_Get_Struct(other, CAObject, cs);
681
681
 
682
- ca_object_setup(ca, cs->data_type, cs->rank, cs->dim, cs->bytes);
682
+ ca_object_setup(ca, cs->data_type, cs->ndim, cs->dim, cs->bytes);
683
683
  ca->self = self;
684
684
 
685
685
  rb_ca_data_type_inherit(self, other);
@@ -703,7 +703,7 @@ rb_ca_object_initialize (int argc, VALUE *argv, VALUE self)
703
703
  {
704
704
  volatile VALUE rtype, rdim, ropt, rbytes = Qnil, rrdonly = Qnil, rparent = Qnil, rdata;
705
705
  CAObject *ca;
706
- int8_t data_type, rank;
706
+ int8_t data_type, ndim;
707
707
  ca_size_t dim[CA_RANK_MAX];
708
708
  ca_size_t bytes;
709
709
  int i;
@@ -721,13 +721,13 @@ rb_ca_object_initialize (int argc, VALUE *argv, VALUE self)
721
721
 
722
722
  Check_Type(rdim, T_ARRAY);
723
723
 
724
- rank = RARRAY_LEN(rdim);
725
- for (i=0; i<rank; i++) {
724
+ ndim = RARRAY_LEN(rdim);
725
+ for (i=0; i<ndim; i++) {
726
726
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
727
727
  }
728
728
 
729
729
  Data_Get_Struct(self, CAObject, ca);
730
- ca_object_setup(ca, data_type, rank, dim, bytes);
730
+ ca_object_setup(ca, data_type, ndim, dim, bytes);
731
731
  ca->self = self;
732
732
 
733
733
  rdata = ca_wrap_struct(ca->data);
@@ -40,7 +40,7 @@ ca_reduce_setup (CAReduce *ca, CArray *parent, ca_size_t count, ca_size_t offset
40
40
  ca->obj_type = CA_OBJ_REDUCE;
41
41
  ca->data_type = CA_BOOLEAN; /* data type is fixed to boolean */
42
42
  ca->flags = 0;
43
- ca->rank = 1;
43
+ ca->ndim = 1;
44
44
  ca->bytes = ca_sizeof[CA_BOOLEAN];
45
45
  ca->elements = elements;
46
46
  ca->ptr = NULL;
@@ -21,7 +21,7 @@ VALUE rb_cCARefer;
21
21
 
22
22
  static int
23
23
  ca_refer_setup (CARefer *ca, CArray *parent,
24
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
24
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
25
25
  ca_size_t offset)
26
26
  {
27
27
  ca_size_t elements, ratio;
@@ -29,8 +29,8 @@ ca_refer_setup (CARefer *ca, CArray *parent,
29
29
  int is_deformed;
30
30
 
31
31
  CA_CHECK_DATA_TYPE(data_type);
32
- CA_CHECK_RANK(rank);
33
- CA_CHECK_DIM(rank, dim);
32
+ CA_CHECK_RANK(ndim);
33
+ CA_CHECK_DIM(ndim, dim);
34
34
  CA_CHECK_BYTES(data_type, bytes);
35
35
 
36
36
  if ( ca_is_object_type(parent) && data_type != CA_OBJECT ) {
@@ -42,10 +42,10 @@ ca_refer_setup (CARefer *ca, CArray *parent,
42
42
  }
43
43
 
44
44
  /* calc datanum and check deformation */
45
- is_deformed = ( rank == parent->rank ) ? 0 : 1;
45
+ is_deformed = ( ndim == parent->ndim ) ? 0 : 1;
46
46
  ratio = 1;
47
47
  elements = 1;
48
- for (i=0; i<rank; i++) {
48
+ for (i=0; i<ndim; i++) {
49
49
  elements *= dim[i];
50
50
  if ( dim[i] != parent->dim[i] ) {
51
51
  is_deformed |= 1;
@@ -79,10 +79,10 @@ ca_refer_setup (CARefer *ca, CArray *parent,
79
79
  ca->obj_type = CA_OBJ_REFER;
80
80
  ca->data_type = data_type;
81
81
  ca->flags = 0;
82
- ca->rank = rank;
82
+ ca->ndim = ndim;
83
83
  ca->bytes = bytes;
84
84
  ca->elements = elements;
85
- ca->dim = ALLOC_N(ca_size_t, rank);
85
+ ca->dim = ALLOC_N(ca_size_t, ndim);
86
86
  ca->ptr = NULL;
87
87
  ca->mask = NULL;
88
88
  ca->mask0 = NULL;
@@ -99,7 +99,7 @@ ca_refer_setup (CARefer *ca, CArray *parent,
99
99
  ca->is_deformed = 1;
100
100
  }
101
101
 
102
- memcpy(ca->dim, dim, rank * sizeof(ca_size_t));
102
+ memcpy(ca->dim, dim, ndim * sizeof(ca_size_t));
103
103
 
104
104
  if ( ca_is_scalar(parent) ) {
105
105
  ca_set_flag(ca, CA_FLAG_SCALAR);
@@ -110,11 +110,11 @@ ca_refer_setup (CARefer *ca, CArray *parent,
110
110
 
111
111
  CARefer *
112
112
  ca_refer_new (CArray *parent,
113
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
113
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
114
114
  ca_size_t offset)
115
115
  {
116
116
  CARefer *ca = ALLOC(CARefer);
117
- ca_refer_setup(ca, parent, data_type, rank, dim, bytes, offset);
117
+ ca_refer_setup(ca, parent, data_type, ndim, dim, bytes, offset);
118
118
  return ca;
119
119
  }
120
120
 
@@ -137,7 +137,7 @@ ca_refer_func_clone (void *ap)
137
137
  {
138
138
  CARefer *ca = (CARefer *) ap;
139
139
  return ca_refer_new(ca->parent,
140
- ca->data_type, ca->rank, ca->dim, ca->bytes, ca->offset);
140
+ ca->data_type, ca->ndim, ca->dim, ca->bytes, ca->offset);
141
141
  }
142
142
 
143
143
  static char *
@@ -167,9 +167,9 @@ ca_refer_func_ptr_at_index (void *ap, ca_size_t *idx)
167
167
  ca_size_t *dim = ca->dim;
168
168
  int8_t i;
169
169
  ca_size_t n;
170
- n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[rank-1] */
171
- for (i=1; i<ca->rank; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[rank-1] */
172
- n = dim[i]*n+idx[i]; /* ... + idx[rank-2]*dim[1] + idx[rank-1] */
170
+ n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[ndim-1] */
171
+ for (i=1; i<ca->ndim; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[ndim-1] */
172
+ n = dim[i]*n+idx[i]; /* ... + idx[ndim-2]*dim[1] + idx[ndim-1] */
173
173
  }
174
174
  return ca->ptr + ca->bytes * n;
175
175
  }
@@ -222,7 +222,7 @@ ca_refer_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
222
222
  int8_t i;
223
223
  ca_size_t n;
224
224
  n = idx[0];
225
- for (i=1; i<ca->rank; i++) {
225
+ for (i=1; i<ca->ndim; i++) {
226
226
  n = dim[i]*n+idx[i];
227
227
  }
228
228
  ca_refer_func_fetch_addr(ca, n, ptr);
@@ -283,7 +283,7 @@ ca_refer_func_store_index (void *ap, ca_size_t *idx, void *ptr)
283
283
  int8_t i;
284
284
  ca_size_t n;
285
285
  n = idx[0];
286
- for (i=1; i<ca->rank; i++) {
286
+ for (i=1; i<ca->ndim; i++) {
287
287
  n = dim[i]*n+idx[i];
288
288
  }
289
289
  ca_refer_func_store_addr(ca, n, ptr);
@@ -421,29 +421,29 @@ ca_refer_func_create_mask (void *ap)
421
421
  if ( ca->bytes == ca->parent->bytes ) {
422
422
  ca->mask =
423
423
  (CArray *) ca_refer_new(ca->parent->mask,
424
- CA_BOOLEAN, ca->rank, ca->dim, 0, ca->offset);
424
+ CA_BOOLEAN, ca->ndim, ca->dim, 0, ca->offset);
425
425
  }
426
426
  else if ( ca->is_deformed == -2 ) {
427
427
  ca_size_t count[CA_RANK_MAX];
428
428
  int i;
429
- for (i=0; i<ca->parent->rank; i++) {
429
+ for (i=0; i<ca->parent->ndim; i++) {
430
430
  count[i] = 0;
431
431
  }
432
- count[ca->parent->rank] = ca->ratio;
432
+ count[ca->parent->ndim] = ca->ratio;
433
433
  ca->mask0 =
434
- (CArray *) ca_repeat_new(ca->parent->mask, ca->parent->rank+1, count);
434
+ (CArray *) ca_repeat_new(ca->parent->mask, ca->parent->ndim+1, count);
435
435
  ca_unset_flag(ca->mask0, CA_FLAG_READ_ONLY);
436
436
 
437
437
  ca->mask =
438
438
  (CArray *) ca_refer_new(ca->mask0,
439
- CA_BOOLEAN, ca->rank, ca->dim, 0, ca->offset);
439
+ CA_BOOLEAN, ca->ndim, ca->dim, 0, ca->offset);
440
440
  }
441
441
  else if ( ca->is_deformed == 2 ) {
442
442
  /* TODO */
443
443
  ca->mask0 =
444
444
  (CArray *) ca_reduce_new(ca->parent->mask, ca->ratio, ca->offset);
445
445
  ca->mask =
446
- (CArray *) ca_refer_new(ca->mask0, CA_BOOLEAN, ca->rank, ca->dim, 0, 0);
446
+ (CArray *) ca_refer_new(ca->mask0, CA_BOOLEAN, ca->ndim, ca->dim, 0, 0);
447
447
  }
448
448
  }
449
449
 
@@ -485,7 +485,7 @@ rb_ca_refer_initialize_copy (VALUE self, VALUE other)
485
485
  Data_Get_Struct(self, CARefer, ca);
486
486
  Data_Get_Struct(other, CARefer, cs);
487
487
 
488
- ca_refer_setup(ca, cs->parent, cs->data_type, cs->rank, cs->dim,
488
+ ca_refer_setup(ca, cs->parent, cs->data_type, cs->ndim, cs->dim,
489
489
  cs->bytes, cs->offset);
490
490
 
491
491
  return self;
@@ -514,7 +514,7 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
514
514
  CArray *ca;
515
515
  CARefer *cr;
516
516
  int8_t data_type;
517
- int8_t rank;
517
+ int8_t ndim;
518
518
  ca_size_t dim[CA_RANK_MAX];
519
519
  ca_size_t bytes, offset = 0;
520
520
  int8_t i;
@@ -524,11 +524,11 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
524
524
  if ( argc == 0 ) { /* CArray#refer() */
525
525
  data_type = ca->data_type;
526
526
  bytes = ca->bytes;
527
- rank = ca->rank;
528
- for (i=0; i<rank; i++) {
527
+ ndim = ca->ndim;
528
+ for (i=0; i<ndim; i++) {
529
529
  dim[i] = ca->dim[i];
530
530
  }
531
- cr = ca_refer_new((CArray*)ca, data_type, rank, dim, bytes, offset);
531
+ cr = ca_refer_new((CArray*)ca, data_type, ndim, dim, bytes, offset);
532
532
  obj = ca_wrap_struct(cr);
533
533
  rb_ca_set_parent(obj, self);
534
534
  rb_ca_data_type_inherit(obj, self);
@@ -558,10 +558,10 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
558
558
  }
559
559
 
560
560
  Check_Type(rdim, T_ARRAY);
561
- rank = RARRAY_LEN(rdim);
561
+ ndim = RARRAY_LEN(rdim);
562
562
 
563
563
  elements = 1;
564
- for (i=0; i<rank; i++) {
564
+ for (i=0; i<ndim; i++) {
565
565
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
566
566
  elements *= dim[i];
567
567
  }
@@ -570,7 +570,7 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
570
570
  offset = NUM2SIZE(roffset);
571
571
  }
572
572
 
573
- cr = ca_refer_new((CArray*)ca, data_type, rank, dim, bytes, offset);
573
+ cr = ca_refer_new((CArray*)ca, data_type, ndim, dim, bytes, offset);
574
574
  obj = ca_wrap_struct(cr);
575
575
  rb_ca_set_parent(obj, self);
576
576
  rb_ca_data_type_import(obj, rtype);
@@ -584,7 +584,7 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
584
584
 
585
585
  VALUE
586
586
  rb_ca_refer_new (VALUE self,
587
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
587
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
588
588
  ca_size_t offset)
589
589
  {
590
590
  volatile VALUE list, rdim, ropt;
@@ -593,8 +593,8 @@ rb_ca_refer_new (VALUE self,
593
593
 
594
594
  Data_Get_Struct(self, CArray, ca);
595
595
 
596
- rdim = rb_ary_new2(rank);
597
- for (i=0; i<rank; i++) {
596
+ rdim = rb_ary_new2(ndim);
597
+ for (i=0; i<ndim; i++) {
598
598
  rb_ary_store(rdim, i, SIZE2NUM(dim[i]));
599
599
  }
600
600
 
@@ -20,16 +20,16 @@ VALUE rb_cCARepeat;
20
20
  */
21
21
 
22
22
  int
23
- ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
23
+ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t ndim, ca_size_t *count)
24
24
  {
25
25
  int8_t data_type;
26
26
  ca_size_t elements, bytes, nrpt, repeat_level, repeat_num,
27
- contig_level, contig_num, data_rank;
27
+ contig_level, contig_num, data_ndim;
28
28
  int i, j;
29
29
 
30
30
  nrpt = 1;
31
- data_rank = 0;
32
- for (i=0; i<rank; i++) {
31
+ data_ndim = 0;
32
+ for (i=0; i<ndim; i++) {
33
33
  if ( count[i] < 0 ) {
34
34
  rb_raise(rb_eRuntimeError,
35
35
  "negative size for %i-th dimension specified", i);
@@ -39,27 +39,27 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
39
39
  nrpt *= count[i];
40
40
  }
41
41
  else {
42
- data_rank += 1;
42
+ data_ndim += 1;
43
43
  }
44
44
  }
45
45
 
46
46
  repeat_level = 0;
47
47
  repeat_num = 1;
48
- for (i=0; i<rank && count[i]; i++) {
48
+ for (i=0; i<ndim && count[i]; i++) {
49
49
  repeat_level = i+1;
50
50
  repeat_num *= count[i];
51
51
  }
52
52
 
53
- contig_level = rank-1;
53
+ contig_level = ndim-1;
54
54
  contig_num = 1;
55
- for (i=rank-1; i >= 0 && count[i]; i--) {
55
+ for (i=ndim-1; i >= 0 && count[i]; i--) {
56
56
  contig_level = i;
57
57
  contig_num *= count[i];
58
58
  }
59
59
 
60
- if ( data_rank != parent->rank ) {
60
+ if ( data_ndim != parent->ndim ) {
61
61
  rb_raise(rb_eRuntimeError,
62
- "mismatch in rank between original array and determined by # of dummies");
62
+ "mismatch in ndim between original array and determined by # of dummies");
63
63
  }
64
64
 
65
65
  if ( ((double) parent->elements) * nrpt > CA_LENGTH_MAX ) {
@@ -73,24 +73,24 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
73
73
  ca->obj_type = CA_OBJ_REPEAT;
74
74
  ca->data_type = data_type;
75
75
  ca->flags = 0;
76
- ca->rank = rank;
76
+ ca->ndim = ndim;
77
77
  ca->bytes = bytes;
78
78
  ca->elements = elements;
79
79
  ca->ptr = NULL;
80
80
  ca->mask = NULL;
81
- ca->dim = ALLOC_N(ca_size_t, rank);
81
+ ca->dim = ALLOC_N(ca_size_t, ndim);
82
82
 
83
83
  ca->parent = parent;
84
84
  ca->attach = 0;
85
85
  ca->nosync = 0;
86
- ca->count = ALLOC_N(ca_size_t, rank);
86
+ ca->count = ALLOC_N(ca_size_t, ndim);
87
87
  ca->repeat_level = repeat_level;
88
88
  ca->repeat_num = repeat_num;
89
89
  ca->contig_level = contig_level;
90
90
  ca->contig_num = contig_num;
91
91
 
92
92
  j = 0;
93
- for (i=0; i<rank; i++) {
93
+ for (i=0; i<ndim; i++) {
94
94
  if ( count[i] ) {
95
95
  ca->dim[i] = count[i];
96
96
  }
@@ -99,7 +99,7 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
99
99
  }
100
100
  }
101
101
 
102
- memcpy(ca->count, count, rank * sizeof(ca_size_t));
102
+ memcpy(ca->count, count, ndim * sizeof(ca_size_t));
103
103
 
104
104
  ca_set_flag(ca, CA_FLAG_READ_ONLY);
105
105
 
@@ -112,10 +112,10 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
112
112
 
113
113
 
114
114
  CARepeat *
115
- ca_repeat_new (CArray *parent, int8_t rank, ca_size_t *count)
115
+ ca_repeat_new (CArray *parent, int8_t ndim, ca_size_t *count)
116
116
  {
117
117
  CARepeat *ca = ALLOC(CARepeat);
118
- ca_repeat_setup(ca, parent, rank, count);
118
+ ca_repeat_setup(ca, parent, ndim, count);
119
119
  return ca;
120
120
  }
121
121
 
@@ -141,7 +141,7 @@ static void *
141
141
  ca_repeat_func_clone (void *ap)
142
142
  {
143
143
  CARepeat *ca = (CARepeat *) ap;
144
- return ca_repeat_new(ca->parent, ca->rank, ca->count);
144
+ return ca_repeat_new(ca->parent, ca->ndim, ca->count);
145
145
  }
146
146
 
147
147
  static char *
@@ -173,7 +173,7 @@ ca_repeat_func_ptr_at_index (void *ap, ca_size_t *idx)
173
173
 
174
174
  j = 0;
175
175
  n = 0;
176
- for (i=0; i<ca->rank; i++) {
176
+ for (i=0; i<ca->ndim; i++) {
177
177
  if ( ! count[i] ) {
178
178
  n = dim0[j]*n + idx[i];
179
179
  j++;
@@ -199,7 +199,7 @@ ca_repeat_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
199
199
  ca_size_t n, j;
200
200
  j = 0;
201
201
  n = 0;
202
- for (i=0; i<ca->rank; i++) {
202
+ for (i=0; i<ca->ndim; i++) {
203
203
  if ( ! count[i] ) {
204
204
  idx0[j++] = idx[i];
205
205
  }
@@ -217,7 +217,7 @@ ca_repeat_func_store_index (void *ap, ca_size_t *idx, void *ptr)
217
217
  ca_size_t n, j;
218
218
  j = 0;
219
219
  n = 0;
220
- for (i=0; i<ca->rank; i++) {
220
+ for (i=0; i<ca->ndim; i++) {
221
221
  if ( ! count[i] ) {
222
222
  idx0[j++] = idx[i];
223
223
  }
@@ -305,7 +305,7 @@ ca_repeat_func_create_mask (void *ap)
305
305
  ca_create_mask(ca->parent);
306
306
  }
307
307
  ca->mask =
308
- (CArray *) ca_repeat_new(ca->parent->mask, ca->rank, ca->count);
308
+ (CArray *) ca_repeat_new(ca->parent->mask, ca->ndim, ca->count);
309
309
  }
310
310
 
311
311
  ca_operation_function_t ca_repeat_func = {
@@ -410,7 +410,7 @@ ca_repeat_attach (CARepeat *ca)
410
410
  ca_size_t i;
411
411
  char *dp, *sp;
412
412
 
413
- for (i=0; i<ca->rank; i++) {
413
+ for (i=0; i<ca->ndim; i++) {
414
414
  idx[i] = 0;
415
415
  idx0[i] = 0;
416
416
  }
@@ -459,7 +459,7 @@ ca_repeat_sync (CARepeat *ca)
459
459
  ca_size_t idx[CA_RANK_MAX];
460
460
  ca_size_t idx0[CA_RANK_MAX];
461
461
  int8_t i;
462
- for (i=0; i<ca->rank; i++) {
462
+ for (i=0; i<ca->ndim; i++) {
463
463
  idx[i] = 0;
464
464
  idx0[i] = 0;
465
465
  }
@@ -475,14 +475,14 @@ ca_repeat_fill (CARepeat *ca, char *ptr)
475
475
  /* ------------------------------------------------------------------- */
476
476
 
477
477
  VALUE
478
- rb_ca_repeat_new (VALUE cary, int8_t rank, ca_size_t *count)
478
+ rb_ca_repeat_new (VALUE cary, int8_t ndim, ca_size_t *count)
479
479
  {
480
480
  volatile VALUE obj;
481
481
  CArray *parent;
482
482
  CARepeat *ca;
483
483
  rb_check_carray_object(cary);
484
484
  Data_Get_Struct(cary, CArray, parent);
485
- ca = ca_repeat_new(parent, rank, count);
485
+ ca = ca_repeat_new(parent, ndim, count);
486
486
  obj = ca_wrap_struct(ca);
487
487
  rb_ca_set_parent(obj, cary);
488
488
  rb_ca_data_type_inherit(obj, cary);
@@ -507,7 +507,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
507
507
  ) ) {
508
508
  volatile VALUE args;
509
509
  CArray *ct;
510
- ca_size_t rank, dim[CA_RANK_MAX];
510
+ ca_size_t ndim, dim[CA_RANK_MAX];
511
511
  int k;
512
512
  if ( argv[0] == ID2SYM(rb_intern("%") ) ) {
513
513
  Data_Get_Struct(argv[1], CArray, ct);
@@ -515,34 +515,34 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
515
515
  else {
516
516
  Data_Get_Struct(argv[0], CArray, ct);
517
517
  }
518
- if ( ct->rank < ca->rank ) {
519
- rb_raise(rb_eRuntimeError, "invalid rank to template");
518
+ if ( ct->ndim < ca->ndim ) {
519
+ rb_raise(rb_eRuntimeError, "invalid ndim to template");
520
520
  }
521
521
  args = rb_ary_new();
522
- rank = 0;
522
+ ndim = 0;
523
523
  if ( argv[0] == ID2SYM(rb_intern("%") ) ) {
524
524
  k = 0;
525
- for (i=0; i<ct->rank; i++) {
525
+ for (i=0; i<ct->ndim; i++) {
526
526
  if ( ca->dim[k] == 1 ) {
527
527
  rb_ary_push(args, SIZE2NUM(ct->dim[i]));
528
528
  k++;
529
529
  }
530
530
  else if ( ct->dim[i] == ca->dim[k] ) {
531
531
  rb_ary_push(args, ID2SYM(rb_intern("%")));
532
- dim[rank] = ca->dim[k];
533
- k++; rank++;
532
+ dim[ndim] = ca->dim[k];
533
+ k++; ndim++;
534
534
  }
535
535
  else {
536
536
  rb_ary_push(args, SIZE2NUM(ct->dim[i]));
537
537
  }
538
538
  }
539
- if ( rank != ca->rank ) {
540
- self = rb_ca_refer_new(self, ca->data_type, rank, dim, ca->bytes, 0);
539
+ if ( ndim != ca->ndim ) {
540
+ self = rb_ca_refer_new(self, ca->data_type, ndim, dim, ca->bytes, 0);
541
541
  }
542
542
  }
543
543
  else {
544
- k = ca->rank - 1;
545
- for (i=ct->rank-1; i>=0; i--) {
544
+ k = ca->ndim - 1;
545
+ for (i=ct->ndim-1; i>=0; i--) {
546
546
  if ( ca->dim[k] == 1 ) {
547
547
  rb_ary_unshift(args, SIZE2NUM(ct->dim[i]));
548
548
  k--;
@@ -556,14 +556,14 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
556
556
  }
557
557
  }
558
558
  if ( k != 0 ) {
559
- rank = 0;
560
- for (i=0; i<ca->rank; i++) {
559
+ ndim = 0;
560
+ for (i=0; i<ca->ndim; i++) {
561
561
  if ( ca->dim[i] != 1 ) {
562
- dim[rank] = ca->dim[i];
563
- rank++;
562
+ dim[ndim] = ca->dim[i];
563
+ ndim++;
564
564
  }
565
565
  }
566
- self = rb_ca_refer_new(self, ca->data_type, rank, dim, ca->bytes, 0);
566
+ self = rb_ca_refer_new(self, ca->data_type, ndim, dim, ca->bytes, 0);
567
567
  }
568
568
  }
569
569
  return rb_ca_repeat((int)RARRAY_LEN(args), RARRAY_PTR(args), self);
@@ -625,7 +625,7 @@ rb_ca_repeat_initialize_copy (VALUE self, VALUE other)
625
625
  Data_Get_Struct(self, CARepeat, ca);
626
626
  Data_Get_Struct(other, CARepeat, cs);
627
627
 
628
- ca_repeat_setup(ca, cs->parent, cs->rank, cs->count);
628
+ ca_repeat_setup(ca, cs->parent, cs->ndim, cs->count);
629
629
 
630
630
  return self;
631
631
  }