carray 1.5.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +10 -0
- data/TODO.md +1 -0
- data/carray.gemspec +1 -1
- data/ext/ca_iter_block.c +20 -5
- data/ext/ca_iter_dimension.c +21 -10
- data/ext/ca_iter_window.c +17 -5
- data/ext/ca_obj_array.c +73 -10
- data/ext/ca_obj_bitarray.c +21 -6
- data/ext/ca_obj_bitfield.c +21 -11
- data/ext/ca_obj_block.c +34 -10
- data/ext/ca_obj_fake.c +21 -6
- data/ext/ca_obj_farray.c +34 -5
- data/ext/ca_obj_field.c +23 -7
- data/ext/ca_obj_grid.c +36 -7
- data/ext/ca_obj_mapping.c +36 -7
- data/ext/ca_obj_object.c +35 -9
- data/ext/ca_obj_reduce.c +34 -5
- data/ext/ca_obj_refer.c +31 -10
- data/ext/ca_obj_repeat.c +35 -12
- data/ext/ca_obj_select.c +35 -9
- data/ext/ca_obj_shift.c +41 -12
- data/ext/ca_obj_transpose.c +36 -7
- data/ext/ca_obj_unbound_repeat.c +39 -14
- data/ext/ca_obj_window.c +46 -15
- data/ext/carray.h +97 -31
- data/ext/carray_access.c +25 -42
- data/ext/carray_attribute.c +35 -35
- data/ext/carray_call_cfunc.c +28 -28
- data/ext/carray_cast.c +25 -26
- data/ext/carray_cast_func.rb +1 -2
- data/ext/carray_conversion.c +7 -10
- data/ext/carray_copy.c +5 -5
- data/ext/carray_core.c +44 -7
- data/ext/carray_element.c +9 -9
- data/ext/carray_generate.c +7 -7
- data/ext/carray_iterator.c +33 -23
- data/ext/carray_loop.c +9 -9
- data/ext/carray_mask.c +38 -36
- data/ext/carray_math.rb +6 -6
- data/ext/carray_numeric.c +1 -1
- data/ext/carray_operator.c +31 -21
- data/ext/carray_order.c +216 -12
- data/ext/carray_sort_addr.c +2 -2
- data/ext/carray_stat.c +22 -22
- data/ext/carray_stat_proc.rb +13 -13
- data/ext/carray_test.c +8 -8
- data/ext/ruby_carray.c +7 -0
- data/ext/ruby_ccomplex.c +25 -11
- data/ext/version.h +6 -6
- data/lib/carray/inspect.rb +0 -3
- data/lib/carray/io/imagemagick.rb +8 -9
- data/lib/carray/mkmf.rb +1 -0
- data/lib/carray/time.rb +1 -1
- data/spec/Classes/ex1.rb +46 -0
- metadata +4 -6
data/ext/carray_mask.c
CHANGED
@@ -422,7 +422,7 @@ ca_unmask_copy (void *ap, char *fill_value)
|
|
422
422
|
{
|
423
423
|
CArray *ca = (CArray *) ap;
|
424
424
|
CArray *co;
|
425
|
-
char *
|
425
|
+
char *q;
|
426
426
|
boolean8_t *m;
|
427
427
|
ca_size_t i;
|
428
428
|
|
@@ -431,14 +431,13 @@ ca_unmask_copy (void *ap, char *fill_value)
|
|
431
431
|
|
432
432
|
if ( fill_value && ca_has_mask(ca) ) {
|
433
433
|
ca_attach(ca);
|
434
|
-
p = ca->ptr;
|
435
434
|
q = co->ptr;
|
436
435
|
m = (boolean8_t *) ca->mask->ptr;
|
437
436
|
for (i=0; i<ca->elements; i++) {
|
438
437
|
if ( *m ) {
|
439
438
|
memcpy(q, fill_value, ca->bytes);
|
440
439
|
}
|
441
|
-
m++;
|
440
|
+
m++; q+=co->bytes;
|
442
441
|
}
|
443
442
|
ca_detach(ca);
|
444
443
|
}
|
@@ -573,7 +572,7 @@ VALUE
|
|
573
572
|
rb_ca_has_mask (VALUE self)
|
574
573
|
{
|
575
574
|
CArray *ca;
|
576
|
-
|
575
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
577
576
|
return ( ca_has_mask(ca) ) ? Qtrue : Qfalse;
|
578
577
|
}
|
579
578
|
|
@@ -587,7 +586,7 @@ VALUE
|
|
587
586
|
rb_ca_is_any_masked (VALUE self)
|
588
587
|
{
|
589
588
|
CArray *ca;
|
590
|
-
|
589
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
591
590
|
return ( ca_is_any_masked(ca) ) ? Qtrue : Qfalse;
|
592
591
|
}
|
593
592
|
|
@@ -601,7 +600,7 @@ VALUE
|
|
601
600
|
rb_ca_is_all_masked (VALUE self)
|
602
601
|
{
|
603
602
|
CArray *ca;
|
604
|
-
|
603
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
605
604
|
return ( ca_is_all_masked(ca) ) ? Qtrue : Qfalse;
|
606
605
|
}
|
607
606
|
|
@@ -616,7 +615,7 @@ rb_ca_create_mask (VALUE self)
|
|
616
615
|
{
|
617
616
|
CArray *ca;
|
618
617
|
rb_ca_modify(self);
|
619
|
-
|
618
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
620
619
|
ca_create_mask(ca);
|
621
620
|
return Qnil;
|
622
621
|
}
|
@@ -632,7 +631,7 @@ static VALUE
|
|
632
631
|
rb_ca_update_mask (VALUE self)
|
633
632
|
{
|
634
633
|
CArray *ca;
|
635
|
-
|
634
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
636
635
|
ca_update_mask(ca);
|
637
636
|
return Qnil;
|
638
637
|
}
|
@@ -652,10 +651,10 @@ rb_ca_value_array (VALUE self)
|
|
652
651
|
VALUE obj;
|
653
652
|
CArray *ca, *co;
|
654
653
|
|
655
|
-
|
654
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
656
655
|
|
657
656
|
obj = rb_ca_refer_new(self, ca->data_type, ca->ndim, ca->dim, ca->bytes, 0);
|
658
|
-
|
657
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, co);
|
659
658
|
|
660
659
|
ca_set_flag(co, CA_FLAG_VALUE_ARRAY);
|
661
660
|
|
@@ -674,12 +673,13 @@ rb_ca_mask_array (VALUE self)
|
|
674
673
|
{
|
675
674
|
VALUE obj;
|
676
675
|
CArray *ca;
|
677
|
-
|
676
|
+
|
677
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
678
678
|
|
679
679
|
ca_update_mask(ca);
|
680
680
|
if ( ca->mask ) {
|
681
|
-
obj =
|
682
|
-
|
681
|
+
obj = TypedData_Wrap_Struct(ca_mask_class[ca->obj_type],
|
682
|
+
ca_mask_typeddata[ca->obj_type], ca->mask);
|
683
683
|
rb_ivar_set(obj, rb_intern("masked_array"), self);
|
684
684
|
if ( OBJ_FROZEN(self) ) {
|
685
685
|
rb_ca_freeze(obj);
|
@@ -707,7 +707,7 @@ rb_ca_set_mask (VALUE self, VALUE rval)
|
|
707
707
|
|
708
708
|
rb_ca_modify(self);
|
709
709
|
|
710
|
-
|
710
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
711
711
|
|
712
712
|
if ( ca_is_value_array(ca) ) {
|
713
713
|
rb_raise(rb_eRuntimeError,
|
@@ -725,7 +725,7 @@ rb_ca_set_mask (VALUE self, VALUE rval)
|
|
725
725
|
}
|
726
726
|
|
727
727
|
if ( rb_obj_is_carray(rmask) ) {
|
728
|
-
|
728
|
+
TypedData_Get_Struct(rmask, CArray, &carray_data_type, cv);
|
729
729
|
if ( ! ca_is_boolean_type(cv) ) {
|
730
730
|
cv = ca_wrap_readonly(rval, CA_BOOLEAN);
|
731
731
|
}
|
@@ -755,10 +755,10 @@ rb_ca_is_masked (VALUE self)
|
|
755
755
|
boolean8_t *m, *p;
|
756
756
|
ca_size_t i;
|
757
757
|
|
758
|
-
|
758
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
759
759
|
|
760
760
|
if ( ca_is_scalar(ca) ) {
|
761
|
-
co = cscalar_new(CA_BOOLEAN, ca->bytes, NULL);
|
761
|
+
co = (CArray *)cscalar_new(CA_BOOLEAN, ca->bytes, NULL);
|
762
762
|
}
|
763
763
|
else {
|
764
764
|
co = carray_new(CA_BOOLEAN, ca->ndim, ca->dim, ca->bytes, NULL);
|
@@ -770,7 +770,7 @@ rb_ca_is_masked (VALUE self)
|
|
770
770
|
}
|
771
771
|
else {
|
772
772
|
mask = rb_ca_mask_array(self);
|
773
|
-
|
773
|
+
TypedData_Get_Struct(mask, CArray, &carray_data_type, cm);
|
774
774
|
ca_attach(cm);
|
775
775
|
m = (boolean8_t *) cm->ptr;
|
776
776
|
p = (boolean8_t *) co->ptr;
|
@@ -801,10 +801,10 @@ rb_ca_is_not_masked (VALUE self)
|
|
801
801
|
boolean8_t *m, *p;
|
802
802
|
ca_size_t i;
|
803
803
|
|
804
|
-
|
804
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
805
805
|
|
806
806
|
if ( ca_is_scalar(ca) ) {
|
807
|
-
co = cscalar_new(CA_BOOLEAN, ca->bytes, NULL);
|
807
|
+
co = (CArray *) cscalar_new(CA_BOOLEAN, ca->bytes, NULL);
|
808
808
|
}
|
809
809
|
else {
|
810
810
|
co = carray_new(CA_BOOLEAN, ca->ndim, ca->dim, ca->bytes, NULL);
|
@@ -816,7 +816,7 @@ rb_ca_is_not_masked (VALUE self)
|
|
816
816
|
}
|
817
817
|
else {
|
818
818
|
mask = rb_ca_mask_array(self);
|
819
|
-
|
819
|
+
TypedData_Get_Struct(mask, CArray, &carray_data_type, cm);
|
820
820
|
ca_attach(cm);
|
821
821
|
m = (boolean8_t *) cm->ptr;
|
822
822
|
p = (boolean8_t *) co->ptr;
|
@@ -840,7 +840,9 @@ VALUE
|
|
840
840
|
rb_ca_count_masked (VALUE self)
|
841
841
|
{
|
842
842
|
CArray *ca;
|
843
|
-
|
843
|
+
printf("hello\n");
|
844
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
845
|
+
printf("world\n");
|
844
846
|
return SIZE2NUM(ca_count_masked(ca));
|
845
847
|
}
|
846
848
|
|
@@ -854,7 +856,7 @@ VALUE
|
|
854
856
|
rb_ca_count_not_masked (VALUE self)
|
855
857
|
{
|
856
858
|
CArray *ca;
|
857
|
-
|
859
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
858
860
|
return SIZE2NUM(ca_count_not_masked(ca));
|
859
861
|
}
|
860
862
|
|
@@ -881,11 +883,11 @@ rb_ca_unmask_method (int argc, VALUE *argv, VALUE self)
|
|
881
883
|
rfval = argv[0];
|
882
884
|
}
|
883
885
|
|
884
|
-
|
886
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
885
887
|
|
886
888
|
if ( rfval != CA_NIL ) {
|
887
889
|
rcs = rb_cscalar_new_with_value(ca->data_type, ca->bytes, rfval);
|
888
|
-
|
890
|
+
TypedData_Get_Struct(rcs, CScalar, &cscalar_data_type, cv);
|
889
891
|
fval = cv->ptr;
|
890
892
|
}
|
891
893
|
|
@@ -931,11 +933,11 @@ rb_ca_unmask_copy_method (int argc, VALUE *argv, VALUE self)
|
|
931
933
|
rfval = argv[0];
|
932
934
|
}
|
933
935
|
|
934
|
-
|
936
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
935
937
|
|
936
938
|
if ( rfval != CA_NIL ) {
|
937
939
|
rcs = rb_cscalar_new_with_value(ca->data_type, ca->bytes, rfval);
|
938
|
-
|
940
|
+
TypedData_Get_Struct(rcs, CScalar, &cscalar_data_type, cv);
|
939
941
|
fval = cv->ptr;
|
940
942
|
}
|
941
943
|
|
@@ -971,7 +973,7 @@ VALUE
|
|
971
973
|
rb_ca_invert_mask (VALUE self)
|
972
974
|
{
|
973
975
|
CArray *ca;
|
974
|
-
|
976
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
975
977
|
ca_invert_mask(ca);
|
976
978
|
return self;
|
977
979
|
}
|
@@ -992,12 +994,12 @@ rb_ca_inherit_mask_method (int argc, VALUE *argv, VALUE self)
|
|
992
994
|
|
993
995
|
rb_ca_modify(self);
|
994
996
|
|
995
|
-
|
997
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
996
998
|
|
997
999
|
slist = malloc_with_check(sizeof(CArray *)*argc);
|
998
1000
|
for (i=0; i<argc; i++) {
|
999
1001
|
if ( rb_obj_is_carray(argv[i]) ) {
|
1000
|
-
|
1002
|
+
TypedData_Get_Struct(argv[i], CArray, &carray_data_type, cs);
|
1001
1003
|
slist[i] = cs;
|
1002
1004
|
}
|
1003
1005
|
else {
|
@@ -1032,14 +1034,14 @@ rb_ca_inherit_mask (VALUE self, int n, ...)
|
|
1032
1034
|
|
1033
1035
|
rb_ca_modify(self);
|
1034
1036
|
|
1035
|
-
|
1037
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1036
1038
|
|
1037
1039
|
va_start(rothers, n);
|
1038
1040
|
slist = malloc_with_check(sizeof(CArray *)*n);
|
1039
1041
|
for (i=0; i<n; i++) {
|
1040
1042
|
other = va_arg(rothers, VALUE);
|
1041
1043
|
if ( rb_obj_is_carray(other) ) {
|
1042
|
-
|
1044
|
+
TypedData_Get_Struct(other, CArray, &carray_data_type, cs);
|
1043
1045
|
slist[i] = cs;
|
1044
1046
|
}
|
1045
1047
|
else {
|
@@ -1071,12 +1073,12 @@ rb_ca_inherit_mask_replace_method (int argc, VALUE *argv, VALUE self)
|
|
1071
1073
|
|
1072
1074
|
rb_ca_modify(self);
|
1073
1075
|
|
1074
|
-
|
1076
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1075
1077
|
|
1076
1078
|
slist = malloc_with_check(sizeof(CArray *)*argc);
|
1077
1079
|
for (i=0; i<argc; i++) {
|
1078
1080
|
if ( rb_obj_is_carray(argv[i]) ) {
|
1079
|
-
|
1081
|
+
TypedData_Get_Struct(argv[i], CArray, &carray_data_type, cs);
|
1080
1082
|
slist[i] = cs;
|
1081
1083
|
}
|
1082
1084
|
else {
|
@@ -1111,14 +1113,14 @@ rb_ca_inherit_mask_replace (VALUE self, int n, ...)
|
|
1111
1113
|
|
1112
1114
|
rb_ca_modify(self);
|
1113
1115
|
|
1114
|
-
|
1116
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1115
1117
|
|
1116
1118
|
va_start(rothers, n);
|
1117
1119
|
slist = malloc_with_check(sizeof(CArray *)*n);
|
1118
1120
|
for (i=0; i<n; i++) {
|
1119
1121
|
other = va_arg(rothers, VALUE);
|
1120
1122
|
if ( rb_obj_is_carray(other) ) {
|
1121
|
-
|
1123
|
+
TypedData_Get_Struct(other, CArray, &carray_data_type, cs);
|
1122
1124
|
slist[i] = cs;
|
1123
1125
|
}
|
1124
1126
|
else {
|
data/ext/carray_math.rb
CHANGED
@@ -83,7 +83,7 @@ rb_ca_abs (VALUE self)
|
|
83
83
|
{
|
84
84
|
CArray *ca;
|
85
85
|
|
86
|
-
|
86
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
87
87
|
if ( ca_is_complex_type(ca) ) {
|
88
88
|
VALUE ret = rb_ca_abs_i(self);
|
89
89
|
return rb_ca_copy(rb_funcall(ret, rb_intern("real"), 0));
|
@@ -98,7 +98,7 @@ rb_ca_abs_bang (VALUE self)
|
|
98
98
|
{
|
99
99
|
CArray *ca;
|
100
100
|
rb_ca_modify(self);
|
101
|
-
|
101
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
102
102
|
if ( ca_is_complex_type(ca) ) {
|
103
103
|
VALUE ret = rb_ca_abs_i(self);
|
104
104
|
return rb_funcall(self, rb_intern("[]="), 1, ret);
|
@@ -672,7 +672,7 @@ rb_ca_ipower (VALUE self, VALUE other)
|
|
672
672
|
|
673
673
|
ipow = NUM2INT(other);
|
674
674
|
|
675
|
-
|
675
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
676
676
|
|
677
677
|
co = ca_template(ca);
|
678
678
|
obj = ca_wrap_struct(co);
|
@@ -728,7 +728,7 @@ rb_ca_ipower_bang (VALUE self, VALUE other)
|
|
728
728
|
|
729
729
|
ipow = NUM2INT(other);
|
730
730
|
|
731
|
-
|
731
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
732
732
|
|
733
733
|
ca_attach(ca);
|
734
734
|
|
@@ -781,7 +781,7 @@ static VALUE rb_ca_pow (VALUE self, VALUE other)
|
|
781
781
|
volatile VALUE obj;
|
782
782
|
CArray *ca;
|
783
783
|
|
784
|
-
|
784
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
785
785
|
if ( ( ca_is_float_type(ca) || ca_is_complex_type(ca) ) &&
|
786
786
|
rb_obj_is_kind_of(other, rb_cInteger) ) {
|
787
787
|
return rb_ca_ipower(self, other);
|
@@ -802,7 +802,7 @@ static VALUE rb_ca_pow (VALUE self, VALUE other)
|
|
802
802
|
static VALUE rb_ca_pow_bang (VALUE self, VALUE other)
|
803
803
|
{
|
804
804
|
CArray *ca;
|
805
|
-
|
805
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
806
806
|
if ( ( ca_is_float_type(ca) || ca_is_complex_type(ca) ) &&
|
807
807
|
rb_obj_is_kind_of(other, rb_cInteger) ) {
|
808
808
|
return rb_ca_ipower_bang(self, other);
|
data/ext/carray_numeric.c
CHANGED
@@ -147,7 +147,7 @@ rb_ca_arg (VALUE self)
|
|
147
147
|
volatile VALUE obj;
|
148
148
|
CArray *ca, *co;
|
149
149
|
|
150
|
-
|
150
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
151
151
|
|
152
152
|
co = carray_new(CA_FLOAT64, ca->ndim, ca->dim, 0, NULL);
|
153
153
|
obj = ca_wrap_struct(co);
|
data/ext/carray_operator.c
CHANGED
@@ -32,7 +32,7 @@ rb_ca_call_monop (VALUE self, ca_monop_func_t func[])
|
|
32
32
|
volatile VALUE out;
|
33
33
|
CArray *ca1, *ca2; /* ca2 = ca1.op */
|
34
34
|
|
35
|
-
|
35
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca1);
|
36
36
|
|
37
37
|
if ( ca_has_mask(ca1) ) {
|
38
38
|
ca2 = ca_template_safe(ca1);
|
@@ -68,7 +68,7 @@ rb_ca_call_monop_bang (VALUE self, ca_monop_func_t func[])
|
|
68
68
|
|
69
69
|
rb_ca_modify(self);
|
70
70
|
|
71
|
-
|
71
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca1);
|
72
72
|
|
73
73
|
ca_attach(ca1);
|
74
74
|
func[ca1->data_type](ca1->elements,
|
@@ -114,8 +114,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
|
|
114
114
|
/* do implicit casting and resolving unbound repeat array */
|
115
115
|
rb_ca_cast_self_or_other(&self, &other);
|
116
116
|
|
117
|
-
|
118
|
-
|
117
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca1);
|
118
|
+
TypedData_Get_Struct(other, CArray, &carray_data_type, ca2);
|
119
119
|
|
120
120
|
ca_attach_n(2, ca1, ca2);
|
121
121
|
|
@@ -220,8 +220,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
|
|
220
220
|
/* do implicit casting and resolving unbound repeat array */
|
221
221
|
rb_ca_cast_other(&self, &other);
|
222
222
|
|
223
|
-
|
224
|
-
|
223
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca1);
|
224
|
+
TypedData_Get_Struct(other, CArray, &carray_data_type, ca2);
|
225
225
|
|
226
226
|
ca_attach_n(2, ca1, ca2);
|
227
227
|
|
@@ -286,7 +286,7 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
|
|
286
286
|
volatile VALUE out;
|
287
287
|
CArray *ca1, *ca2; /* ca2 = ca1.op */
|
288
288
|
|
289
|
-
|
289
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca1);
|
290
290
|
|
291
291
|
if ( ca_is_scalar(ca1) ) {
|
292
292
|
out = rb_cscalar_new(CA_BOOLEAN, 0, NULL);
|
@@ -295,7 +295,7 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
|
|
295
295
|
out = rb_carray_new(CA_BOOLEAN, ca1->ndim, ca1->dim, 0, NULL);
|
296
296
|
}
|
297
297
|
|
298
|
-
|
298
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, ca2);
|
299
299
|
|
300
300
|
ca_attach(ca1);
|
301
301
|
ca_copy_mask_overlay(ca2, ca2->elements, 1, ca1);
|
@@ -341,8 +341,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
341
341
|
/* do implicit casting and resolving unbound repeat array */
|
342
342
|
rb_ca_cast_self_or_other(&self, &other);
|
343
343
|
|
344
|
-
|
345
|
-
|
344
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca1);
|
345
|
+
TypedData_Get_Struct(other, CArray, &carray_data_type, ca2);
|
346
346
|
|
347
347
|
ca_attach_n(2, ca1, ca2);
|
348
348
|
|
@@ -350,7 +350,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
350
350
|
if ( rb_obj_is_cscalar(self) ) {
|
351
351
|
if ( rb_obj_is_cscalar(other) ) { /* scalar vs scalar */
|
352
352
|
out = rb_cscalar_new(CA_BOOLEAN, 0, NULL);
|
353
|
-
|
353
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, ca3);
|
354
354
|
|
355
355
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
356
356
|
func[ca1->data_type](ca1->elements,
|
@@ -361,7 +361,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
361
361
|
}
|
362
362
|
else { /* scalar vs array */
|
363
363
|
out = rb_carray_new(CA_BOOLEAN, ca2->ndim, ca2->dim, 0, NULL);
|
364
|
-
|
364
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, ca3);
|
365
365
|
|
366
366
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
367
367
|
func[ca1->data_type](ca2->elements,
|
@@ -374,7 +374,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
374
374
|
else {
|
375
375
|
if ( rb_obj_is_cscalar(other) ) { /* array vs scalar */
|
376
376
|
out = rb_carray_new(CA_BOOLEAN, ca1->ndim, ca1->dim, 0, NULL);
|
377
|
-
|
377
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, ca3);
|
378
378
|
|
379
379
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
380
380
|
func[ca1->data_type](ca1->elements,
|
@@ -389,7 +389,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
389
389
|
(ca_size_t) ca1->elements, (ca_size_t) ca2->elements);
|
390
390
|
}
|
391
391
|
out = rb_carray_new(CA_BOOLEAN, ca1->ndim, ca1->dim, 0, NULL);
|
392
|
-
|
392
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, ca3);
|
393
393
|
|
394
394
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
395
395
|
func[ca1->data_type](ca1->elements,
|
@@ -412,28 +412,38 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
412
412
|
}
|
413
413
|
|
414
414
|
void
|
415
|
-
ca_monop_not_implement(ca_size_t n,
|
415
|
+
ca_monop_not_implement(ca_size_t n, boolean8_t *m,
|
416
|
+
char *ptr1, ca_size_t i1,
|
417
|
+
char *ptr2, ca_size_t i2)
|
416
418
|
{
|
417
419
|
rb_raise(rb_eCADataTypeError,
|
418
420
|
"invalid data type for monop (not implemented)");
|
419
421
|
}
|
420
422
|
|
421
423
|
void
|
422
|
-
ca_binop_not_implement(ca_size_t n,
|
424
|
+
ca_binop_not_implement(ca_size_t n, boolean8_t *m,
|
425
|
+
char *ptr1, ca_size_t i1,
|
426
|
+
char *ptr2, ca_size_t i2,
|
427
|
+
char *ptr3, ca_size_t i3)
|
423
428
|
{
|
424
429
|
rb_raise(rb_eCADataTypeError,
|
425
430
|
"invalid data_type for binop (not implemented)");
|
426
431
|
}
|
427
432
|
|
428
433
|
void
|
429
|
-
ca_moncmp_not_implement(ca_size_t n,
|
434
|
+
ca_moncmp_not_implement(ca_size_t n, boolean8_t *m,
|
435
|
+
char *ptr1, ca_size_t i1,
|
436
|
+
boolean8_t *ptr2, ca_size_t i2)
|
430
437
|
{
|
431
438
|
rb_raise(rb_eCADataTypeError,
|
432
439
|
"invalid data_type for moncmp (not implemented)");
|
433
440
|
}
|
434
441
|
|
435
442
|
void
|
436
|
-
ca_bincmp_not_implement (ca_size_t n,
|
443
|
+
ca_bincmp_not_implement (ca_size_t n, boolean8_t *m,
|
444
|
+
char *ptr1, ca_size_t b1, ca_size_t i1,
|
445
|
+
char *ptr2, ca_size_t b2, ca_size_t i2,
|
446
|
+
char *ptr3, ca_size_t b3, ca_size_t i3)
|
437
447
|
{
|
438
448
|
rb_raise(rb_eTypeError, "invalid data_type for bincmp (not implemented)");
|
439
449
|
}
|
@@ -477,7 +487,7 @@ static VALUE
|
|
477
487
|
rb_ca_coerce (VALUE self, VALUE other)
|
478
488
|
{
|
479
489
|
CArray *ca;
|
480
|
-
|
490
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
481
491
|
|
482
492
|
if ( rb_obj_is_carray(other) ) {
|
483
493
|
return Qnil;
|
@@ -554,8 +564,8 @@ rb_ca_mul_add (int argc, VALUE *argv, volatile VALUE self)
|
|
554
564
|
/* do implicit casting and resolving unbound repeat array */
|
555
565
|
rb_ca_cast_self_or_other(&self, &weight);
|
556
566
|
|
557
|
-
|
558
|
-
|
567
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
568
|
+
TypedData_Get_Struct(weight, CArray, &carray_data_type, cw);
|
559
569
|
|
560
570
|
/* checking elements and data_type */
|
561
571
|
ca_check_same_elements(ca, cw);
|