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
@@ -132,7 +132,7 @@ ca_project (CArray *ca, CArray *ci, char *lfill, char *ufill)
132
132
 
133
133
  ca_attach_n(2, ca, ci); /* ATTACH */
134
134
 
135
- co = carray_new(ca->data_type, ci->rank, ci->dim, ca->bytes, NULL);
135
+ co = carray_new(ca->data_type, ci->ndim, ci->dim, ca->bytes, NULL);
136
136
  ca_project_loop(co, ca, ci, lfill, ufill);
137
137
 
138
138
  ca_detach_n(2, ca, ci); /* DETACH */
@@ -449,154 +449,6 @@ rb_ca_sorted_copy (VALUE self)
449
449
  return rb_ca_sort_bang(out);
450
450
  }
451
451
 
452
- /* --------------------------------------------------------------- */
453
-
454
- /*
455
- Fisher-Yates method
456
-
457
- # [ruby-list:41356]
458
- # From: Shin-ichiro HARA <sinara blade.nagaokaut.ac.jp>
459
- def shuffle!
460
- array = self
461
- array.each_index do |idx|
462
- jdx = rand(idx + 1)
463
- array[idx], array[jdx] = array[jdx], array[idx]
464
- end
465
- self
466
- end
467
- */
468
-
469
- #define proc_shuffle(type) \
470
- { \
471
- ca_size_t idx, jdx; \
472
- type *ptr, *p, *q; \
473
- type t1; \
474
- ptr = (type *) ca->ptr; \
475
- if ( ca->mask ) { \
476
- boolean8_t *mptr, *mp, *mq; \
477
- boolean8_t mt1; \
478
- mptr = (boolean8_t *)ca->mask->ptr; \
479
- for (idx=0; idx<ca->elements; idx++) { \
480
- jdx = ca_rand((double)(idx+1)); \
481
- p = ptr + idx; \
482
- q = ptr + jdx; \
483
- mp = mptr + idx; \
484
- mq = mptr + jdx; \
485
- t1 = *p; *p = *q; *q = t1; \
486
- mt1 = *mp; *mp = *mq; *mq = mt1; \
487
- } \
488
- } \
489
- else { \
490
- for (idx=0; idx<ca->elements; idx++) { \
491
- jdx = ca_rand((double)(idx+1)); \
492
- p = ptr + idx; \
493
- q = ptr + jdx; \
494
- t1 = *p; *p = *q; *q = t1; \
495
- } \
496
- } \
497
- }
498
-
499
- #define proc_shuffle_fixlen() \
500
- { \
501
- ca_size_t idx, jdx; \
502
- char *ptr, *p, *q; \
503
- char *t = (char*) malloc_with_check(ca->bytes); \
504
- ca_size_t bytes = ca->bytes; \
505
- ptr = ca->ptr; \
506
- if ( ca->mask ) { \
507
- boolean8_t *mptr, *mp, *mq; \
508
- boolean8_t mt1; \
509
- mptr = (boolean8_t *)ca->mask->ptr; \
510
- for (idx=0; idx<ca->elements; idx++) { \
511
- jdx = ca_rand((double)(idx+1)); \
512
- p = ca->ptr + idx*bytes; \
513
- q = ca->ptr + jdx*bytes; \
514
- mp = mptr + idx; \
515
- mq = mptr + jdx; \
516
- memcpy(t, p, bytes); memcpy(p, q, bytes); memcpy(q, t, bytes); \
517
- mt1 = *mp; *mp = *mq; *mq = mt1; \
518
- } \
519
- free(t); \
520
- } \
521
- else { \
522
- for (idx=0; idx<ca->elements; idx++) { \
523
- jdx = ca_rand((double)(idx+1)); \
524
- p = ca->ptr + idx*bytes; \
525
- q = ca->ptr + jdx*bytes; \
526
- memcpy(t, p, bytes); memcpy(p, q, bytes); memcpy(q, t, bytes); \
527
- } \
528
- free(t); \
529
- } \
530
- }
531
-
532
- void ca_check_rand_init ();
533
-
534
- /* rdoc:
535
- class CArray
536
- # shuffles the elements.
537
- # If `self` has mask, the masked elements are also moved by shuffling.
538
- def shuffle!
539
- end
540
- end
541
- */
542
-
543
- static VALUE
544
- rb_ca_shuffle_bang (VALUE self)
545
- {
546
- CArray *ca;
547
-
548
- rb_ca_modify(self);
549
-
550
- Data_Get_Struct(self, CArray, ca);
551
-
552
- ca_check_rand_init();
553
-
554
- ca_attach(ca);
555
-
556
- switch ( ca->data_type ) {
557
- case CA_BOOLEAN:
558
- case CA_INT8: proc_shuffle(int8_t); break;
559
- case CA_UINT8: proc_shuffle(uint8_t); break;
560
- case CA_INT16: proc_shuffle(int16_t); break;
561
- case CA_UINT16: proc_shuffle(uint16_t); break;
562
- case CA_INT32: proc_shuffle(int32_t); break;
563
- case CA_UINT32: proc_shuffle(uint32_t); break;
564
- case CA_INT64: proc_shuffle(int64_t); break;
565
- case CA_UINT64: proc_shuffle(uint64_t); break;
566
- case CA_FLOAT32: proc_shuffle(float32_t); break;
567
- case CA_FLOAT64: proc_shuffle(float64_t); break;
568
- case CA_FLOAT128: proc_shuffle(float128_t); break;
569
- #ifdef HAVE_COMPLEX_H
570
- case CA_CMPLX64: proc_shuffle(cmplx64_t); break;
571
- case CA_CMPLX128: proc_shuffle(cmplx128_t); break;
572
- case CA_CMPLX256: proc_shuffle(cmplx256_t); break;
573
- #endif
574
- case CA_FIXLEN: proc_shuffle_fixlen(); break;
575
- case CA_OBJECT: proc_shuffle(VALUE); break;
576
- default:
577
- rb_raise(rb_eCADataTypeError, "[BUG] array has an unknown data type");
578
- }
579
-
580
- ca_sync(ca);
581
- ca_detach(ca);
582
-
583
- return self;
584
- }
585
-
586
- /* rdoc:
587
- class CArray
588
- def shuffle
589
- end
590
- end
591
- */
592
-
593
- static VALUE
594
- rb_ca_shuffled_copy (VALUE self)
595
- {
596
- volatile VALUE out = rb_ca_copy(self);
597
- rb_ca_data_type_inherit(out, self);
598
- return rb_ca_shuffle_bang(out);
599
- }
600
452
 
601
453
  /* --------------------------------------------------------------- */
602
454
 
@@ -641,7 +493,7 @@ rb_ca_binary_search (VALUE self, volatile VALUE rval)
641
493
  if ( ca->data_type != cv->data_type ) {
642
494
  cv = ca_wrap_readonly(rval, ca->data_type);
643
495
  }
644
- co = carray_new(CA_SIZE, cv->rank, cv->dim, 0, NULL);
496
+ co = carray_new(CA_SIZE, cv->ndim, cv->dim, 0, NULL);
645
497
  out = ca_wrap_struct(co);
646
498
  ca_attach(cv);
647
499
  if ( ca_is_fixlen_type(ca) ) {
@@ -1024,9 +876,6 @@ Init_carray_order ()
1024
876
  rb_define_method(rb_cCArray, "sort!", rb_ca_sort_bang, 0);
1025
877
  rb_define_method(rb_cCArray, "sort", rb_ca_sorted_copy, 0);
1026
878
 
1027
- rb_define_method(rb_cCArray, "shuffle!", rb_ca_shuffle_bang, 0);
1028
- rb_define_method(rb_cCArray, "shuffle", rb_ca_shuffled_copy, 0);
1029
-
1030
879
  rb_define_method(rb_cCArray, "search", rb_ca_linear_search, -1);
1031
880
  rb_define_method(rb_cCArray, "search_index", rb_ca_linear_search_index, -1);
1032
881
 
@@ -293,10 +293,10 @@ rb_ca_cumprod (int argc, VALUE *argv, VALUE self)
293
293
  Data_Get_Struct(self, CArray, ca);
294
294
 
295
295
  if ( ca_is_complex_type(ca) ) {
296
- co = carray_new(CA_CMPLX128, ca->rank, ca->dim, 0, NULL);
296
+ co = carray_new(CA_CMPLX128, ca->ndim, ca->dim, 0, NULL);
297
297
  }
298
298
  else {
299
- co = carray_new(CA_FLOAT64, ca->rank, ca->dim, 0, NULL);
299
+ co = carray_new(CA_FLOAT64, ca->ndim, ca->dim, 0, NULL);
300
300
  }
301
301
 
302
302
  min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
@@ -504,10 +504,10 @@ rb_ca_cumwsum (int argc, VALUE *argv, VALUE self)
504
504
  }
505
505
 
506
506
  if ( ca_is_complex_type(ca) ) {
507
- co = carray_new(CA_CMPLX128, ca->rank, ca->dim, 0, NULL);
507
+ co = carray_new(CA_CMPLX128, ca->ndim, ca->dim, 0, NULL);
508
508
  }
509
509
  else {
510
- co = carray_new(CA_FLOAT64, ca->rank, ca->dim, 0, NULL);
510
+ co = carray_new(CA_FLOAT64, ca->ndim, ca->dim, 0, NULL);
511
511
  }
512
512
 
513
513
  min_count = ( NIL_P(rmin_count) || ( ! ca_has_mask(ca) ) ) ?
@@ -2029,7 +2029,7 @@ rb_ca_grade (int argc, VALUE *argv, VALUE self)
2029
2029
  rb_raise(rb_eArgError, "bin number must be larger than 1");
2030
2030
  }
2031
2031
 
2032
- out = rb_carray_new_safe(CA_SIZE, ca->rank, ca->dim, 0, NULL);
2032
+ out = rb_carray_new_safe(CA_SIZE, ca->ndim, ca->dim, 0, NULL);
2033
2033
  Data_Get_Struct(out, CArray, sa);
2034
2034
 
2035
2035
  ca_attach(ca);
@@ -1383,7 +1383,7 @@ ca_stat_nd_contig_loop (CArray *ca, CArray *co, ca_size_t mc,
1383
1383
  void *p;
1384
1384
  boolean8_t *m;
1385
1385
  ca_size_t i, n;
1386
- if ( level == co->rank ) {
1386
+ if ( level == co->ndim ) {
1387
1387
  CAStatIterator it;
1388
1388
  n = ca->elements/co->elements;
1389
1389
  idx[level] = 0;
@@ -1421,8 +1421,8 @@ rb_ca_stat_nd_contig (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
1421
1421
  ca_type_name[ca->data_type]);
1422
1422
  }
1423
1423
 
1424
- ndim = ca->rank - RARRAY_LEN(vaxis);
1425
- if ( ndim <= 0 || ndim > ca->rank ) {
1424
+ ndim = ca->ndim - RARRAY_LEN(vaxis);
1425
+ if ( ndim <= 0 || ndim > ca->ndim ) {
1426
1426
  rb_raise(rb_eRuntimeError, "invalid dimension specified");
1427
1427
  }
1428
1428
 
@@ -1449,7 +1449,7 @@ rb_ca_stat_nd_contig (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
1449
1449
  char *op;
1450
1450
  boolean8_t *om;
1451
1451
  int8_t i;
1452
- for (i=0; i<ca->rank; i++) {
1452
+ for (i=0; i<ca->ndim; i++) {
1453
1453
  idx[i] = 0;
1454
1454
  }
1455
1455
  ca_attach_n(2, ca, co);
@@ -1474,7 +1474,7 @@ ca_stat_get_offset_loop (CArray *ca, ca_size_t *dm,
1474
1474
  CArray *offset)
1475
1475
  {
1476
1476
  ca_size_t i;
1477
- if ( level == ca->rank - 1 ) {
1477
+ if ( level == ca->ndim - 1 ) {
1478
1478
  if ( dm[level] == 0 ) {
1479
1479
  idx[level] = 0;
1480
1480
  *(ca_size_t *)ca_ptr_at_index(offset, idx1) = ca_index2addr(ca, idx);
@@ -1513,13 +1513,13 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
1513
1513
  ca_size_t loop_dim[CA_RANK_MAX];
1514
1514
  ca_size_t dm[CA_RANK_MAX], dn[CA_RANK_MAX];
1515
1515
  CArray *ca, *co, *first, *offset;
1516
- ca_size_t out_rank, loop_rank;
1516
+ ca_size_t out_ndim, loop_ndim;
1517
1517
  ca_size_t mc;
1518
1518
  ca_size_t i, k;
1519
1519
 
1520
1520
  Data_Get_Struct(self, CArray, ca);
1521
1521
 
1522
- for (i=0; i<ca->rank; i++) {
1522
+ for (i=0; i<ca->ndim; i++) {
1523
1523
  dm[i] = 0;
1524
1524
  dn[i] = 1;
1525
1525
  }
@@ -1530,26 +1530,26 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
1530
1530
  dn[k] = 0;
1531
1531
  }
1532
1532
 
1533
- out_rank = 0;
1534
- loop_rank = 0;
1535
- for (i=0; i<ca->rank; i++) {
1533
+ out_ndim = 0;
1534
+ loop_ndim = 0;
1535
+ for (i=0; i<ca->ndim; i++) {
1536
1536
  if ( dm[i] ) {
1537
- loop_dim[loop_rank] = ca->dim[i];
1538
- loop_rank += 1;
1537
+ loop_dim[loop_ndim] = ca->dim[i];
1538
+ loop_ndim += 1;
1539
1539
  }
1540
1540
  else {
1541
- out_dim[out_rank] = ca->dim[i];
1542
- out_rank += 1;
1541
+ out_dim[out_ndim] = ca->dim[i];
1542
+ out_ndim += 1;
1543
1543
  }
1544
1544
  }
1545
1545
 
1546
- out = rb_carray_new(data_type, out_rank, out_dim, 0, NULL);
1546
+ out = rb_carray_new(data_type, out_ndim, out_dim, 0, NULL);
1547
1547
  Data_Get_Struct(out, CArray, co);
1548
1548
 
1549
- first = carray_new(CA_SIZE, out_rank, out_dim, 0, NULL);
1549
+ first = carray_new(CA_SIZE, out_ndim, out_dim, 0, NULL);
1550
1550
  first->ptr = realloc(first->ptr, first->bytes*(first->elements+1));
1551
1551
 
1552
- offset = carray_new(CA_SIZE, loop_rank, loop_dim, 0, NULL);
1552
+ offset = carray_new(CA_SIZE, loop_ndim, loop_dim, 0, NULL);
1553
1553
  offset->ptr = realloc(offset->ptr, offset->bytes*(offset->elements+1));
1554
1554
 
1555
1555
  ca_stat_get_offset_loop(ca, dn, 0, idx, 0, idx1, first);
@@ -1673,14 +1673,14 @@ rb_ca_stat_general (int argc, VALUE *argv, VALUE self,
1673
1673
 
1674
1674
  for (i=0; i<RARRAY_LEN(vaxis); i++) {
1675
1675
  k = NUM2SIZE(rb_ary_entry(vaxis, RARRAY_LEN(vaxis)-1-i));
1676
- CA_CHECK_INDEX(k, ca->rank);
1677
- if ( k != ca->rank-1-i ) {
1676
+ CA_CHECK_INDEX(k, ca->ndim);
1677
+ if ( k != ca->ndim-1-i ) {
1678
1678
  is_contig = 0;
1679
1679
  }
1680
1680
  }
1681
1681
 
1682
1682
  if ( is_contig ) {
1683
- if ( RARRAY_LEN(vaxis) == ca->rank ) {
1683
+ if ( RARRAY_LEN(vaxis) == ca->ndim ) {
1684
1684
  return rb_ca_stat_1d(self, rmc, vfval, ca_proc);
1685
1685
  }
1686
1686
  else {
@@ -1841,7 +1841,7 @@ ca_dimstat_type2_loop (CArray *ca, CArray *co, ca_size_t mc,
1841
1841
  void *p;
1842
1842
  boolean8_t *m;
1843
1843
  ca_size_t i, n;
1844
- if ( level == co->rank ) {
1844
+ if ( level == co->ndim ) {
1845
1845
  CAStatIterator it;
1846
1846
  n = ca->elements/co->elements;
1847
1847
  idx[level] = 0;
@@ -1871,7 +1871,7 @@ ca_dimstat_type2 (CArray *ca, CArray *co, ca_size_t mc, ca_stat_proc_t *ca_proc)
1871
1871
  char *op;
1872
1872
  boolean8_t *om;
1873
1873
  int8_t i;
1874
- for (i=0; i<ca->rank; i++) {
1874
+ for (i=0; i<ca->ndim; i++) {
1875
1875
  idx[i] = 0;
1876
1876
  }
1877
1877
  ca_attach_n(2, ca, co);
@@ -1904,7 +1904,7 @@ rb_ca_dimstat_type2 (int argc, VALUE *argv, VALUE self,
1904
1904
  }
1905
1905
 
1906
1906
  ndim = NUM2SIZE(rndim);
1907
- if ( ndim <= 0 || ndim > ca->rank ) {
1907
+ if ( ndim <= 0 || ndim > ca->ndim ) {
1908
1908
  rb_raise(rb_eRuntimeError, "invalid dimension specified");
1909
1909
  }
1910
1910
 
@@ -34,26 +34,26 @@ ca_check_type (void *ap, int8_t data_type)
34
34
  }
35
35
 
36
36
  void
37
- ca_check_rank (void *ap, int rank)
37
+ ca_check_ndim (void *ap, int ndim)
38
38
  {
39
39
  CArray *ca = (CArray *) ap;
40
40
  if ( ! ca_is_scalar(ca) ) {
41
- if ( ca->rank != rank ) {
42
- rb_raise(rb_eRuntimeError, "rank mismatch");
41
+ if ( ca->ndim != ndim ) {
42
+ rb_raise(rb_eRuntimeError, "ndim mismatch");
43
43
  }
44
44
  }
45
45
  }
46
46
 
47
47
  void
48
- ca_check_shape (void *ap, int rank, ca_size_t *dim)
48
+ ca_check_shape (void *ap, int ndim, ca_size_t *dim)
49
49
  {
50
50
  CArray *ca = (CArray *) ap;
51
51
  int i;
52
52
  if ( ! ca_is_scalar(ca) ) {
53
- if ( ca->rank != rank ) {
53
+ if ( ca->ndim != ndim ) {
54
54
  rb_raise(rb_eRuntimeError, "shape mismatch");
55
55
  }
56
- for (i=0; i<rank; i++) {
56
+ for (i=0; i<ndim; i++) {
57
57
  if ( ca->dim[i] != dim[i] ) {
58
58
  rb_raise(rb_eRuntimeError, "shape mismatch");
59
59
  }
@@ -72,12 +72,12 @@ ca_check_same_data_type (void *ap1, void *ap2)
72
72
  }
73
73
 
74
74
  void
75
- ca_check_same_rank (void *ap1, void *ap2)
75
+ ca_check_same_ndim (void *ap1, void *ap2)
76
76
  {
77
77
  CArray *ca1 = (CArray *) ap1;
78
78
  CArray *ca2 = (CArray *) ap2;
79
- if ( ca1->rank != ca2->rank ) {
80
- rb_raise(rb_eRuntimeError, "rank mismatch");
79
+ if ( ca1->ndim != ca2->ndim ) {
80
+ rb_raise(rb_eRuntimeError, "ndim mismatch");
81
81
  }
82
82
  }
83
83
 
@@ -98,10 +98,10 @@ ca_check_same_shape (void *ap1, void *ap2)
98
98
  CArray *ca2 = (CArray *) ap2;
99
99
  int i;
100
100
  if ( ( ! ca_is_scalar(ca1) ) && ( ! ca_is_scalar(ca2) ) ) {
101
- if ( ca1->rank != ca2->rank ) {
101
+ if ( ca1->ndim != ca2->ndim ) {
102
102
  rb_raise(rb_eRuntimeError, "shape mismatch");
103
103
  }
104
- for (i=0; i<ca1->rank; i++) {
104
+ for (i=0; i<ca1->ndim; i++) {
105
105
  if ( ca1->dim[i] != ca2->dim[i] ) {
106
106
  rb_raise(rb_eRuntimeError, "shape mismatch");
107
107
  }
@@ -114,7 +114,7 @@ ca_check_index (void *ap, ca_size_t *idx)
114
114
  {
115
115
  CArray *ca = (CArray *) ap;
116
116
  int i;
117
- for (i=0; i<ca->rank; i++) {
117
+ for (i=0; i<ca->ndim; i++) {
118
118
  if ( idx[i] < 0 || idx[i] >= ca->dim[i] ) {
119
119
  rb_raise(rb_eRuntimeError, "invalid index");
120
120
  }
@@ -140,11 +140,11 @@ ca_has_same_shape (void *ap1, void *ap2)
140
140
  if ( ca_is_scalar(ca1) || ca_is_scalar(ca2) ) {
141
141
  return 1;
142
142
  }
143
- else if ( ca1->rank != ca2->rank ) {
143
+ else if ( ca1->ndim != ca2->ndim ) {
144
144
  return 0;
145
145
  }
146
146
  else {
147
- for (i=0; i<ca1->rank; i++) {
147
+ for (i=0; i<ca1->ndim; i++) {
148
148
  if ( ca1->dim[i] != ca2->dim[i] ) {
149
149
  return 0;
150
150
  }
@@ -158,7 +158,7 @@ ca_is_valid_index (void *ap, ca_size_t *idx)
158
158
  {
159
159
  CArray *ca = (CArray *) ap;
160
160
  int8_t i;
161
- for (i=0; i<ca->rank; i++) {
161
+ for (i=0; i<ca->ndim; i++) {
162
162
  if ( idx[i] < 0 || idx[i] >= ca->dim[i] ) {
163
163
  return 0;
164
164
  }
@@ -236,11 +236,11 @@ rb_ca_is_valid_index (int argc, VALUE *argv, VALUE self)
236
236
 
237
237
  Data_Get_Struct(self, CArray, ca);
238
238
 
239
- if ( argc != ca->rank ) {
239
+ if ( argc != ca->ndim ) {
240
240
  rb_raise(rb_eArgError,
241
- "invalid # of arguments (%i for %i)", argc, ca->rank);
241
+ "invalid # of arguments (%i for %i)", argc, ca->ndim);
242
242
  }
243
- for (i=0; i<ca->rank; i++) {
243
+ for (i=0; i<ca->ndim; i++) {
244
244
  idx = NUM2SIZE(argv[i]);
245
245
  if ( idx < 0 ) {
246
246
  idx += ca->dim[i];
@@ -381,7 +381,7 @@ ca_equal (void *ap, void *bp)
381
381
  return 0;
382
382
  }
383
383
 
384
- if ( ca->rank != cb->rank ) { /* rank comparison */
384
+ if ( ca->ndim != cb->ndim ) { /* ndim comparison */
385
385
  return 0;
386
386
  }
387
387
 
@@ -389,7 +389,7 @@ ca_equal (void *ap, void *bp)
389
389
  return 0;
390
390
  }
391
391
 
392
- for (i=0; i<ca->rank; i++) {
392
+ for (i=0; i<ca->ndim; i++) {
393
393
  if ( ca->dim[i] != cb->dim[i] ) { /* dimensional shape comparison */
394
394
  return 0;
395
395
  }
@@ -571,9 +571,11 @@ rb_ca_modify (VALUE self)
571
571
  if ( OBJ_FROZEN(self) ) {
572
572
  rb_error_frozen("CArray object");
573
573
  }
574
+ /*
574
575
  if ( ( ! OBJ_TAINTED(self) ) && rb_safe_level() >= 4 ) {
575
576
  rb_raise(rb_eSecurityError, "Insecure: can't modify carray");
576
577
  }
578
+ */
577
579
  }
578
580
 
579
581
  VALUE
@@ -585,7 +587,6 @@ rb_ca_freeze (VALUE self)
585
587
  return rb_obj_freeze(self);
586
588
  }
587
589
 
588
-
589
590
  void
590
591
  Init_carray_test ()
591
592
  {