carray 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSES → LICENSE} +0 -0
  3. data/NEWS.md +42 -0
  4. data/README.md +5 -5
  5. data/TODO.md +16 -0
  6. data/carray.gemspec +9 -5
  7. data/ext/ca_iter_block.c +3 -5
  8. data/ext/ca_iter_dimension.c +4 -5
  9. data/ext/ca_iter_window.c +2 -4
  10. data/ext/ca_obj_array.c +394 -124
  11. data/ext/ca_obj_bitarray.c +3 -5
  12. data/ext/ca_obj_bitfield.c +3 -5
  13. data/ext/ca_obj_block.c +6 -8
  14. data/ext/ca_obj_fake.c +3 -5
  15. data/ext/ca_obj_farray.c +3 -5
  16. data/ext/ca_obj_field.c +15 -17
  17. data/ext/ca_obj_grid.c +5 -6
  18. data/ext/ca_obj_mapping.c +2 -4
  19. data/ext/ca_obj_object.c +3 -5
  20. data/ext/ca_obj_reduce.c +2 -4
  21. data/ext/ca_obj_refer.c +5 -7
  22. data/ext/ca_obj_repeat.c +2 -4
  23. data/ext/ca_obj_select.c +2 -4
  24. data/ext/ca_obj_shift.c +3 -5
  25. data/ext/ca_obj_transpose.c +3 -5
  26. data/ext/ca_obj_unbound_repeat.c +58 -81
  27. data/ext/ca_obj_window.c +7 -9
  28. data/ext/carray.h +13 -8
  29. data/ext/carray_access.c +111 -18
  30. data/ext/carray_attribute.c +136 -197
  31. data/ext/carray_call_cfunc.c +1 -3
  32. data/ext/carray_cast.c +344 -143
  33. data/ext/carray_cast_func.rb +1 -2
  34. data/ext/carray_class.c +28 -36
  35. data/ext/carray_conversion.c +49 -59
  36. data/ext/carray_copy.c +16 -32
  37. data/ext/carray_core.c +51 -44
  38. data/ext/carray_element.c +25 -44
  39. data/ext/carray_generate.c +71 -50
  40. data/ext/carray_iterator.c +13 -15
  41. data/ext/carray_loop.c +53 -82
  42. data/ext/carray_mask.c +87 -117
  43. data/ext/carray_math.rb +8 -10
  44. data/ext/carray_mathfunc.c +1 -3
  45. data/ext/carray_numeric.c +19 -3
  46. data/ext/carray_operator.c +45 -32
  47. data/ext/carray_order.c +72 -65
  48. data/ext/carray_sort_addr.c +14 -21
  49. data/ext/carray_stat.c +1 -3
  50. data/ext/carray_stat_proc.rb +2 -4
  51. data/ext/carray_test.c +28 -30
  52. data/ext/carray_undef.c +1 -3
  53. data/ext/carray_utils.c +12 -4
  54. data/ext/extconf.rb +1 -1
  55. data/ext/mkmath.rb +1 -1
  56. data/ext/ruby_carray.c +11 -6
  57. data/ext/ruby_ccomplex.c +1 -3
  58. data/ext/ruby_float_func.c +1 -3
  59. data/ext/version.h +5 -7
  60. data/lib/carray.rb +2 -0
  61. data/lib/carray/autoload/autoload_gem_numo_narray.rb +6 -6
  62. data/lib/carray/broadcast.rb +45 -0
  63. data/lib/carray/construct.rb +21 -4
  64. data/lib/carray/iterator.rb +1 -0
  65. data/lib/carray/ordering.rb +28 -2
  66. data/spec/Classes/CABitfield_spec.rb +58 -0
  67. data/spec/Classes/CABlockIterator_spec.rb +114 -0
  68. data/spec/Classes/CABlock_spec.rb +205 -0
  69. data/spec/Classes/CAField_spec.rb +39 -0
  70. data/spec/Classes/CAGrid_spec.rb +75 -0
  71. data/spec/Classes/CAMap_spec.rb +0 -0
  72. data/{test/test_CAMapping.rb → spec/Classes/CAMapping_spec.rb} +35 -36
  73. data/spec/Classes/CAObject_attribute_spec.rb +33 -0
  74. data/spec/Classes/CAObject_spec.rb +33 -0
  75. data/spec/Classes/CARefer_spec.rb +93 -0
  76. data/spec/Classes/CARepeat_spec.rb +65 -0
  77. data/spec/Classes/CASelect_spec.rb +22 -0
  78. data/spec/Classes/CAShift_spec.rb +16 -0
  79. data/spec/Classes/CAStruct_spec.rb +71 -0
  80. data/{test/test_CATranspose.rb → spec/Classes/CATranspose_spec.rb} +20 -21
  81. data/spec/Classes/CAUnboudRepeat_spec.rb +78 -0
  82. data/spec/Classes/CAWindow_spec.rb +54 -0
  83. data/spec/Classes/CAWrap_spec.rb +8 -0
  84. data/{test/test_CArray.rb → spec/Classes/CArray_spec.rb} +48 -92
  85. data/spec/Classes/CScalar_spec.rb +55 -0
  86. data/spec/Features/feature_130_spec.rb +19 -0
  87. data/spec/Features/feature_attributes_spec.rb +280 -0
  88. data/spec/Features/feature_boolean_spec.rb +97 -0
  89. data/spec/Features/feature_broadcast.rb +100 -0
  90. data/spec/Features/feature_cast_function.rb +19 -0
  91. data/spec/Features/feature_cast_spec.rb +33 -0
  92. data/spec/Features/feature_class_spec.rb +84 -0
  93. data/spec/Features/feature_complex_spec.rb +42 -0
  94. data/{test/test_composite.rb → spec/Features/feature_composite_spec.rb} +17 -18
  95. data/spec/Features/feature_convert_spec.rb +46 -0
  96. data/spec/Features/feature_copy_spec.rb +123 -0
  97. data/spec/Features/feature_creation_spec.rb +84 -0
  98. data/spec/Features/feature_element_spec.rb +144 -0
  99. data/spec/Features/feature_extream_spec.rb +54 -0
  100. data/spec/Features/feature_generate_spec.rb +74 -0
  101. data/spec/Features/feature_index_spec.rb +69 -0
  102. data/spec/Features/feature_mask_spec.rb +574 -0
  103. data/spec/Features/feature_math_spec.rb +97 -0
  104. data/spec/Features/feature_order_spec.rb +146 -0
  105. data/spec/Features/feature_ref_store_spec.rb +209 -0
  106. data/spec/Features/feature_serialization_spec.rb +125 -0
  107. data/spec/Features/feature_stat_spec.rb +397 -0
  108. data/spec/Features/feature_virtual_spec.rb +48 -0
  109. data/spec/Features/method_eq_spec.rb +81 -0
  110. data/spec/Features/method_is_nan_spec.rb +12 -0
  111. data/spec/Features/method_map_spec.rb +54 -0
  112. data/spec/Features/method_max_with.rb +20 -0
  113. data/spec/Features/method_min_with.rb +19 -0
  114. data/spec/Features/method_ne_spec.rb +18 -0
  115. data/spec/Features/method_project_spec.rb +188 -0
  116. data/spec/Features/method_ref_spec.rb +27 -0
  117. data/spec/Features/method_round_spec.rb +11 -0
  118. data/spec/Features/method_s_linspace_spec.rb +48 -0
  119. data/spec/Features/method_s_span_spec.rb +14 -0
  120. data/spec/Features/method_seq_spec.rb +47 -0
  121. data/spec/Features/method_sort_with.rb +43 -0
  122. data/spec/Features/method_sorted_with.rb +29 -0
  123. data/spec/Features/method_span_spec.rb +42 -0
  124. data/spec/Features/method_wrap_readonly_spec.rb +43 -0
  125. data/{test → spec/UnitTest}/test_CAVirtual.rb +0 -0
  126. data/spec/spec_all.rb +0 -1
  127. data/utils/convert_test.rb +73 -0
  128. data/utils/{extract_rdoc.rb → extract_yard.rb} +7 -12
  129. metadata +77 -60
  130. data/spec/CABlockIterator/CABlockIterator_spec.rb +0 -113
  131. data/spec/CArray/bug/store_spec.rb +0 -27
  132. data/spec/CArray/index/repeat_spec.rb +0 -10
  133. data/spec/CArray/method/eq_spec.rb +0 -80
  134. data/spec/CArray/method/is_nan_spec.rb +0 -12
  135. data/spec/CArray/method/ne_spec.rb +0 -18
  136. data/spec/CArray/method/round_spec.rb +0 -11
  137. data/spec/CArray/object/_attribute_spec.rb +0 -32
  138. data/spec/CArray/object/s_new_spec.rb +0 -31
  139. data/spec/CArray/serialize/Serialization_spec.rb +0 -89
  140. data/test/test_130.rb +0 -23
  141. data/test/test_ALL.rb +0 -49
  142. data/test/test_CABitfield.rb +0 -59
  143. data/test/test_CABlock.rb +0 -208
  144. data/test/test_CAField.rb +0 -40
  145. data/test/test_CAGrid.rb +0 -76
  146. data/test/test_CAMmap.rb +0 -11
  147. data/test/test_CARefer.rb +0 -94
  148. data/test/test_CARepeat.rb +0 -66
  149. data/test/test_CASelect.rb +0 -23
  150. data/test/test_CAShift.rb +0 -17
  151. data/test/test_CAWindow.rb +0 -55
  152. data/test/test_CAWrap.rb +0 -9
  153. data/test/test_CComplex.rb +0 -83
  154. data/test/test_CScalar.rb +0 -91
  155. data/test/test_attribute.rb +0 -281
  156. data/test/test_block_iterator.rb +0 -17
  157. data/test/test_boolean.rb +0 -99
  158. data/test/test_cast.rb +0 -33
  159. data/test/test_class.rb +0 -85
  160. data/test/test_complex.rb +0 -43
  161. data/test/test_convert.rb +0 -79
  162. data/test/test_copy.rb +0 -141
  163. data/test/test_creation.rb +0 -85
  164. data/test/test_element.rb +0 -146
  165. data/test/test_extream.rb +0 -55
  166. data/test/test_generate.rb +0 -75
  167. data/test/test_index.rb +0 -71
  168. data/test/test_mask.rb +0 -578
  169. data/test/test_math.rb +0 -98
  170. data/test/test_order.rb +0 -147
  171. data/test/test_ref_store.rb +0 -211
  172. data/test/test_stat.rb +0 -406
  173. data/test/test_struct.rb +0 -72
  174. data/test/test_virtual.rb +0 -49
@@ -3,10 +3,8 @@
3
3
  carray_mask.c
4
4
 
5
5
  This file is part of Ruby/CArray extension library.
6
- You can redistribute it and/or modify it under the terms of
7
- the Ruby Licence.
8
6
 
9
- Copyright (C) 2005 Hiroki Motoyoshi
7
+ Copyright (C) 2005-2020 Hiroki Motoyoshi
10
8
 
11
9
  ---------------------------------------------------------------------------- */
12
10
 
@@ -565,12 +563,10 @@ ca_allocate_mask_iterator (int n, ...)
565
563
 
566
564
  /* ------------------------------------------------------------------- */
567
565
 
568
- /* rdoc:
569
- class CArray
570
- # Returns true if self has the mask array.
571
- def has_mask?()
572
- end
573
- end
566
+ /* @overload has_mask?
567
+
568
+ (Masking, Inquiry)
569
+ Returns true if self has the mask array.
574
570
  */
575
571
 
576
572
  VALUE
@@ -581,12 +577,10 @@ rb_ca_has_mask (VALUE self)
581
577
  return ( ca_has_mask(ca) ) ? Qtrue : Qfalse;
582
578
  }
583
579
 
584
- /* rdoc:
585
- class CArray
586
- # Returns true if self has at least one masked element.
587
- def any_masked?
588
- end
589
- end
580
+ /* @overload any_masked?
581
+
582
+ (Masking, Inquiry)
583
+ Returns true if self has at least one masked element.
590
584
  */
591
585
 
592
586
  VALUE
@@ -597,12 +591,10 @@ rb_ca_is_any_masked (VALUE self)
597
591
  return ( ca_is_any_masked(ca) ) ? Qtrue : Qfalse;
598
592
  }
599
593
 
600
- /* rdoc:
601
- class CArray
602
- # Returns true if all elements of self are masked.
603
- def all_masked?
604
- end
605
- end
594
+ /* @overload all_masked?
595
+
596
+ (Masking, Inquiry)
597
+ Returns true if all elements of self are masked.
606
598
  */
607
599
 
608
600
  VALUE
@@ -613,12 +605,10 @@ rb_ca_is_all_masked (VALUE self)
613
605
  return ( ca_is_all_masked(ca) ) ? Qtrue : Qfalse;
614
606
  }
615
607
 
616
- /* rdoc:
617
- class CArray
618
- private
619
- def create_mask
620
- end
621
- end
608
+ /* @overload create_mask
609
+
610
+ (Masking)
611
+ Creates mask array internally (private method)
622
612
  */
623
613
 
624
614
  static VALUE
@@ -631,12 +621,10 @@ rb_ca_create_mask (VALUE self)
631
621
  return Qnil;
632
622
  }
633
623
 
634
- /* rdoc:
635
- class CArray
636
- private
637
- def update_mask
638
- end
639
- end
624
+ /* @overload update_mask
625
+
626
+ (Masking)
627
+ Update mask array internally (private method)
640
628
  */
641
629
 
642
630
  /*
@@ -650,14 +638,12 @@ rb_ca_update_mask (VALUE self)
650
638
  }
651
639
  */
652
640
 
653
- /* rdoc:
654
- class CArray
655
- # Returns new array which refers the data of <code>self</code>.
656
- # The data of masked elements of <code>self</code> can be accessed
657
- # via the returned array. The value array can't be set mask.
658
- def value ()
659
- end
660
- end
641
+ /* @overload value
642
+
643
+ (Masking, Inquiry)
644
+ Returns new array which refers the data of <code>self</code>.
645
+ The data of masked elements of <code>self</code> can be accessed
646
+ via the returned array. The value array can't be set mask.
661
647
  */
662
648
 
663
649
  VALUE
@@ -676,13 +662,11 @@ rb_ca_value_array (VALUE self)
676
662
  return obj;
677
663
  }
678
664
 
679
- /* rdoc:
680
- class CArray
681
- # Returns new array which refers the mask state of <code>self</code>.
682
- # The mask array can't be set mask.
683
- def mask ()
684
- end
685
- end
665
+ /* @overload mask
666
+
667
+ (Masking, Inquiry)
668
+ Returns new array which refers the mask state of <code>self</code>.
669
+ The mask array can't be set mask.
686
670
  */
687
671
 
688
672
  VALUE
@@ -707,14 +691,12 @@ rb_ca_mask_array (VALUE self)
707
691
  }
708
692
  }
709
693
 
710
- /* rdoc:
711
- class CArray
712
- # Asigns <code>new_mask</code> to the mask array of <code>self</code>.
713
- # If <code>self</code> doesn't have a mask array, it will be created
714
- # before asignment.
715
- def mask= (new_mask)
716
- end
717
- end
694
+ /* @overload mask= (new_mask)
695
+
696
+ (Mask, Modification)
697
+ Asigns <code>new_mask</code> to the mask array of <code>self</code>.
698
+ If <code>self</code> doesn't have a mask array, it will be created
699
+ before asignment.
718
700
  */
719
701
 
720
702
  VALUE
@@ -756,14 +738,12 @@ rb_ca_set_mask (VALUE self, VALUE rval)
756
738
  }
757
739
  }
758
740
 
759
- /* rdoc:
760
- class CArray
761
- # Returns new boolean type array of same shape with <code>self</code>.
762
- # The returned array has 1 for the masked elements and
763
- # 0 for not-masked elements.
764
- def is_masked ()
765
- end
766
- end
741
+ /* @overload is_masked
742
+
743
+ (Masking, Element-Wise Inquiry)
744
+ Returns new boolean type array of same shape
745
+ with <code>self</code>. The returned array has 1 for the masked elements and
746
+ 0 for not-masked elements.
767
747
  */
768
748
 
769
749
  VALUE
@@ -799,14 +779,12 @@ rb_ca_is_masked (VALUE self)
799
779
  return ca_wrap_struct(co);
800
780
  }
801
781
 
802
- /* rdoc:
803
- class CArray
804
- # Returns new boolean type array of same shape with <code>self</code>.
805
- # The returned array has 0 for the masked elements and
806
- # 1 for not-masked elements.
807
- def is_not_masked ()
808
- end
809
- end
782
+ /* @overload is_not_masked
783
+
784
+ (Masking, Element-Wise Inquiry)
785
+ Returns new boolean type array of same shape with <code>self</code>.
786
+ The returned array has 0 for the masked elements and
787
+ 1 for not-masked elements.
810
788
  */
811
789
 
812
790
  VALUE
@@ -842,12 +820,10 @@ rb_ca_is_not_masked (VALUE self)
842
820
  return ca_wrap_struct(co);
843
821
  }
844
822
 
845
- /* rdoc:
846
- class CArray
847
- # Returns the number of masked elements.
848
- def count_masked ()
849
- end
850
- end
823
+ /* @overload count_masked
824
+
825
+ (Masking, Statistics)
826
+ Returns the number of masked elements.
851
827
  */
852
828
 
853
829
  VALUE
@@ -858,12 +834,10 @@ rb_ca_count_masked (VALUE self)
858
834
  return SIZE2NUM(ca_count_masked(ca));
859
835
  }
860
836
 
861
- /* rdoc:
862
- class CArray
863
- # Returns the number of not-masked elements.
864
- def count_not_masked ()
865
- end
866
- end
837
+ /* @overload count_not_masked
838
+
839
+ (Masking, Statistics)
840
+ Returns the number of not-masked elements.
867
841
  */
868
842
 
869
843
  VALUE
@@ -874,15 +848,13 @@ rb_ca_count_not_masked (VALUE self)
874
848
  return SIZE2NUM(ca_count_not_masked(ca));
875
849
  }
876
850
 
877
- /* rdoc:
878
- class CArray
879
- # Unmask all elements of the object.
880
- # If the optional argument <code>fill_value</code> is given,
881
- # the masked elements are filled by <code>fill_value</code>.
882
- # The returned array doesn't have the mask array.
883
- def unmask (fill_value=nil)
884
- end
885
- end
851
+ /* @overload unmask (fill_value = nil)
852
+
853
+ (Masking, Destructive)
854
+ Unmask all elements of the object.
855
+ If the optional argument <code>fill_value</code> is given,
856
+ the masked elements are filled by <code>fill_value</code>.
857
+ The returned array doesn't have the mask array.
886
858
  */
887
859
 
888
860
  static VALUE
@@ -928,15 +900,13 @@ rb_ca_mask_fill (VALUE self, VALUE fval)
928
900
  return rb_ca_unmask_method(1, &fval, self);
929
901
  }
930
902
 
931
- /* rdoc:
932
- class CArray
933
- # Returns new unmasked array.
934
- # If the optional argument <code>fill_value</code> is given,
935
- # the masked elements are filled by <code>fill_value</code>.
936
- # The returned array doesn't have the mask array.
937
- def unmask_copy (fill_value=nil)
938
- end
939
- end
903
+ /* @overload unmask_copy (fill_value = nil)
904
+
905
+ (Masking, Conversion)
906
+ Returns new unmasked array.
907
+ If the optional argument <code>fill_value</code> is given,
908
+ the masked elements are filled by <code>fill_value</code>.
909
+ The returned array doesn't have the mask array.
940
910
  */
941
911
 
942
912
  static VALUE
@@ -981,7 +951,11 @@ rb_ca_mask_fill_copy (VALUE self, VALUE fval)
981
951
  return rb_ca_unmask_copy_method(1, &fval, self);
982
952
  }
983
953
 
984
- /* CArray#invert_mask */
954
+ /* @overload invert_mask
955
+
956
+ (Masking, Destructive)
957
+ Inverts mask state.
958
+ */
985
959
 
986
960
  VALUE
987
961
  rb_ca_invert_mask (VALUE self)
@@ -992,13 +966,11 @@ rb_ca_invert_mask (VALUE self)
992
966
  return self;
993
967
  }
994
968
 
995
- /* rdoc:
996
- class CArray
997
- # Sets the mask array of <code>self</code> by the logical sum of
998
- # the mask states of <code>self</code> and arrays given in arguments.
999
- def inherit_mask (*argv)
1000
- end
1001
- end
969
+ /* @overload inherit_mask (*others):
970
+
971
+ (Masking, Destructive)
972
+ Sets the mask array of <code>self</code> by the logical sum of
973
+ the mask states of <code>self</code> and arrays given in arguments.
1002
974
  */
1003
975
 
1004
976
  static VALUE
@@ -1073,13 +1045,11 @@ rb_ca_inherit_mask (VALUE self, int n, ...)
1073
1045
  return self;
1074
1046
  }
1075
1047
 
1076
- /* rdoc:
1077
- class CArray
1078
- # Sets the mask array of <code>self</code> by the logical sum of
1079
- # the mask states of arrays given in arguments.
1080
- def inherit_mask_replace (*argv)
1081
- end
1082
- end
1048
+ /* @overload inherit_mask_replace (*others)
1049
+ Sets the mask array of <code>self</code> by the logical sum of
1050
+ the mask states of arrays given in arguments.
1051
+ This method does not inherit the mask states of itself (different point
1052
+ from `CArray#inherit_mask`)
1083
1053
  */
1084
1054
 
1085
1055
  static VALUE
@@ -18,12 +18,10 @@ HEADERS << <
18
18
  carray_math.c
19
19
 
20
20
  This file is part of Ruby/CArray extension library.
21
- You can redistribute it and/or modify it under the terms of
22
- the Ruby Licence.
23
21
 
24
- This file is automatically generated from carray_math.rb.
25
22
 
26
- Copyright (C) 2005 Hiroki Motoyoshi
23
+ This file is automatically generated from carray_math.rb.
24
+ Copyright (C) 2005-2020 Hiroki Motoyoshi
27
25
 
28
26
  ---------------------------------------------------------------------------- */
29
27
 
@@ -249,7 +247,7 @@ binop("/", "div",
249
247
  CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) / (#2);" : nil,
250
248
  OBJ_TYPES => '(#3) = rb_funcall((#1), id_slash, 1, (#2));')
251
249
 
252
- binop("quo_i", nil,
250
+ binop("quo_i", "quo_i",
253
251
  OBJ_TYPES => '(#3) = rb_funcall((#1), rb_intern("quo"), 1, (#2));')
254
252
 
255
253
  binop("rcp_mul", "rcp_mul",
@@ -697,7 +695,7 @@ rb_ca_ipower (VALUE self, VALUE other)
697
695
  /* unresolved unbound repeat array generates unbound repeat array again */
698
696
  if ( ca->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
699
697
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca;
700
- obj = rb_ca_ubrep_new(obj, cx->rep_ndim, cx->rep_dim);
698
+ obj = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, obj), cx->rep_ndim, cx->rep_dim);
701
699
  }
702
700
 
703
701
  return obj;
@@ -752,7 +750,7 @@ rb_ca_ipower_bang (VALUE self, VALUE other)
752
750
 
753
751
  }
754
752
 
755
- binop("**", "power",
753
+ binop("power", "power",
756
754
  INT_TYPES => "(#3) = op_powi_<type>((#1), (#2));",
757
755
  FLOAT_TYPES => "(#3) = pow((#1), (#2));",
758
756
  CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = cpow((#1), (#2));" : nil,
@@ -775,8 +773,8 @@ static VALUE rb_ca_pow (VALUE self, VALUE other)
775
773
 
776
774
  /* unresolved unbound repeat array generates unbound repeat array again */
777
775
  if ( ca->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
778
- CAUnboundRepeat *cx = (CAUnboundRepeat *) ca;
779
- obj = rb_ca_ubrep_new(obj, cx->rep_ndim, cx->rep_dim);
776
+ CAUnboundRepeat *cx = (CAUnboundRepeat *) ca;
777
+ obj = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, obj), cx->rep_ndim, cx->rep_dim);
780
778
  }
781
779
 
782
780
  return obj;
@@ -803,7 +801,7 @@ METHODS << %{
803
801
  rb_define_method(rb_cCArray, "pow!", rb_ca_pow_bang, 1);
804
802
  }
805
803
 
806
- alias_op("pow", "**")
804
+ alias_op("**", "pow")
807
805
 
808
806
  METHODS << %{
809
807
  id_equal = rb_intern("==");
@@ -3,10 +3,8 @@
3
3
  carray/mathfunc/carray_mathfunc.c
4
4
 
5
5
  This file is part of Ruby/CArray extension library.
6
- You can redistribute it and/or modify it under the terms of
7
- the Ruby Licence.
8
6
 
9
- Copyright (C) 2005 Hiroki Motoyoshi
7
+ Copyright (C) 2005-2020 Hiroki Motoyoshi
10
8
 
11
9
  ---------------------------------------------------------------------------- */
12
10
 
@@ -3,10 +3,8 @@
3
3
  carray_numeric.c
4
4
 
5
5
  This file is part of Ruby/CArray extension library.
6
- You can redistribute it and/or modify it under the terms of
7
- the Ruby Licence.
8
6
 
9
- Copyright (C) 2005 Hiroki Motoyoshi
7
+ Copyright (C) 2005-2020 Hiroki Motoyoshi
10
8
 
11
9
  ---------------------------------------------------------------------------- */
12
10
 
@@ -220,6 +218,15 @@ Init_carray_numeric ()
220
218
  rb_define_alias(rb_cFalseClass, "__and__", "&");
221
219
  rb_define_alias(rb_cFalseClass, "__xor__", "^");
222
220
 
221
+ #if RUBY_VERSION_CODE >= 240
222
+
223
+ rb_define_alias(rb_cInteger, "__or__", "|");
224
+ rb_define_alias(rb_cInteger, "__and__", "&");
225
+ rb_define_alias(rb_cInteger, "__xor__", "^");
226
+ rb_define_alias(rb_cInteger, "__lshift__", "<<");
227
+ rb_define_alias(rb_cInteger, "__rshift__", ">>");
228
+
229
+ #else
223
230
  rb_define_alias(rb_cFixnum, "__or__", "|");
224
231
  rb_define_alias(rb_cFixnum, "__and__", "&");
225
232
  rb_define_alias(rb_cFixnum, "__xor__", "^");
@@ -231,6 +238,7 @@ Init_carray_numeric ()
231
238
  rb_define_alias(rb_cBignum, "__xor__", "^");
232
239
  rb_define_alias(rb_cBignum, "__lshift__", "<<");
233
240
  rb_define_alias(rb_cBignum, "__rshift__", ">>");
241
+ #endif
234
242
 
235
243
  rb_define_method(rb_cTrueClass, "|", rb_hack_or, 1);
236
244
  rb_define_method(rb_cTrueClass, "&", rb_hack_and, 1);
@@ -242,6 +250,13 @@ Init_carray_numeric ()
242
250
  rb_define_method(rb_cFalseClass, "^", rb_hack_xor, 1);
243
251
  rb_define_method(rb_cFalseClass, "*", rb_hack_star, 1);
244
252
 
253
+ #if RUBY_VERSION_CODE >= 240
254
+ rb_define_method(rb_cInteger, "|", rb_hack_or, 1);
255
+ rb_define_method(rb_cInteger, "&", rb_hack_and, 1);
256
+ rb_define_method(rb_cInteger, "^", rb_hack_xor, 1);
257
+ rb_define_method(rb_cInteger, "<<", rb_hack_lshift, 1);
258
+ rb_define_method(rb_cInteger, ">>", rb_hack_rshift, 1);
259
+ #else
245
260
  rb_define_method(rb_cFixnum, "|", rb_hack_or, 1);
246
261
  rb_define_method(rb_cFixnum, "&", rb_hack_and, 1);
247
262
  rb_define_method(rb_cFixnum, "^", rb_hack_xor, 1);
@@ -253,6 +268,7 @@ Init_carray_numeric ()
253
268
  rb_define_method(rb_cBignum, "^", rb_hack_xor, 1);
254
269
  rb_define_method(rb_cBignum, "<<", rb_hack_lshift, 1);
255
270
  rb_define_method(rb_cBignum, ">>", rb_hack_rshift, 1);
271
+ #endif
256
272
 
257
273
  #ifdef HAVE_COMPLEX_H
258
274
  rb_define_method(rb_cCArray, "arg", rb_ca_arg, 0);