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.h
CHANGED
@@ -114,7 +114,7 @@ typedef int8_t boolean8_t;
|
|
114
114
|
#endif
|
115
115
|
|
116
116
|
#ifndef HAVE_TYPE_INT64_T
|
117
|
-
# if HAVE_LONG_LONG
|
117
|
+
# if HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8
|
118
118
|
# define HAVE_TYPE_INT64_T 1
|
119
119
|
typedef long long int64_t;
|
120
120
|
# else
|
@@ -123,7 +123,7 @@ typedef int8_t boolean8_t;
|
|
123
123
|
#endif
|
124
124
|
|
125
125
|
#ifndef HAVE_TYPE_UINT64_T
|
126
|
-
# if HAVE_LONG_LONG
|
126
|
+
# if HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8
|
127
127
|
# define HAVE_TYPE_UINT64_T 1
|
128
128
|
typedef unsigned long long uint64_t;
|
129
129
|
# else
|
@@ -131,14 +131,14 @@ typedef int8_t boolean8_t;
|
|
131
131
|
# endif
|
132
132
|
#endif
|
133
133
|
|
134
|
-
#if HAVE_TYPE_FLOAT
|
134
|
+
#if HAVE_TYPE_FLOAT && SIZEOF_FLOAT == 4
|
135
135
|
# define HAVE_TYPE_FLOAT32_T 1
|
136
136
|
typedef float float32_t;
|
137
137
|
#else
|
138
138
|
typedef dummy_t float32_t;
|
139
139
|
#endif
|
140
140
|
|
141
|
-
#if HAVE_TYPE_DOUBLE
|
141
|
+
#if HAVE_TYPE_DOUBLE && SIZEOF_DOUBLE == 8
|
142
142
|
# define HAVE_TYPE_FLOAT64_T 1
|
143
143
|
typedef double float64_t;
|
144
144
|
#else
|
@@ -147,7 +147,7 @@ typedef int8_t boolean8_t;
|
|
147
147
|
|
148
148
|
/* float128_t is currently disabled in extconf.rb */
|
149
149
|
|
150
|
-
#if HAVE_TYPE_LONG_DOUBLE
|
150
|
+
#if HAVE_TYPE_LONG_DOUBLE && SIZEOF_LONG_DOUBLE == 16
|
151
151
|
# define HAVE_TYPE_FLOAT128_T 1
|
152
152
|
typedef long double float128_t;
|
153
153
|
#else
|
@@ -174,7 +174,7 @@ typedef int8_t boolean8_t;
|
|
174
174
|
|
175
175
|
/* cmplx256_t is currently disabled in extconf.rb */
|
176
176
|
|
177
|
-
#if HAVE_TYPE_LONG_DOUBLE_COMPLEX
|
177
|
+
#if defined(HAVE_TYPE_LONG_DOUBLE_COMPLEX) && SIZEOF_LONG_DOUBLE_COMPLEX == 32
|
178
178
|
# define HAVE_TYPE_CMPLX256_T 1
|
179
179
|
typedef long double complex cmplx256_t;
|
180
180
|
#else
|
@@ -291,7 +291,6 @@ enum {
|
|
291
291
|
|
292
292
|
/* -------------------------------------------------------------------- */
|
293
293
|
|
294
|
-
|
295
294
|
typedef struct {
|
296
295
|
int32_t obj_type;
|
297
296
|
int32_t entity_type;
|
@@ -560,6 +559,67 @@ typedef struct {
|
|
560
559
|
|
561
560
|
/* -------------------------------------------------------------------- */
|
562
561
|
|
562
|
+
extern const int ca_endian;
|
563
|
+
extern const int32_t ca_valid[CA_NTYPE];
|
564
|
+
extern const int32_t ca_sizeof[CA_NTYPE];
|
565
|
+
extern const char * ca_type_name[CA_NTYPE];
|
566
|
+
extern const int ca_cast_table[CA_NTYPE][CA_NTYPE];
|
567
|
+
extern const int ca_cast_table2[CA_NTYPE][CA_NTYPE];
|
568
|
+
|
569
|
+
extern VALUE ca_class[CA_OBJ_TYPE_MAX];
|
570
|
+
extern const rb_data_type_t *ca_typeddata[CA_OBJ_TYPE_MAX];
|
571
|
+
extern VALUE ca_mask_class[CA_OBJ_TYPE_MAX];
|
572
|
+
extern const rb_data_type_t *ca_mask_typeddata[CA_OBJ_TYPE_MAX];
|
573
|
+
extern ca_operation_function_t ca_func[CA_OBJ_TYPE_MAX];
|
574
|
+
extern int ca_obj_num;
|
575
|
+
|
576
|
+
#define CAVIRTUAL(x) ((CAVirtual *)(x))
|
577
|
+
|
578
|
+
#define ca_set_flag(ca, flag) ( ca->flags |= flag )
|
579
|
+
#define ca_unset_flag(ca, flag) ( ca->flags &= ~flag )
|
580
|
+
#define ca_test_flag(ca, flag) (( ca->flags & flag ) ? 1 : 0)
|
581
|
+
|
582
|
+
/* -------------------------------------------------------------------- */
|
583
|
+
|
584
|
+
extern const rb_data_type_t caiterator_data_type;
|
585
|
+
|
586
|
+
extern const rb_data_type_t carray_data_type;
|
587
|
+
extern const rb_data_type_t cawrap_data_type;
|
588
|
+
extern const rb_data_type_t cscalar_data_type;
|
589
|
+
extern const rb_data_type_t cavirtual_data_type;
|
590
|
+
|
591
|
+
extern const rb_data_type_t cabitarray_data_type;
|
592
|
+
extern const rb_data_type_t cabitfield_data_type;
|
593
|
+
extern const rb_data_type_t cablock_data_type;
|
594
|
+
extern const rb_data_type_t cafake_data_type;
|
595
|
+
extern const rb_data_type_t cafield_data_type;
|
596
|
+
extern const rb_data_type_t cagrid_data_type;
|
597
|
+
extern const rb_data_type_t camapping_data_type;
|
598
|
+
extern const rb_data_type_t caobject_data_type;
|
599
|
+
extern const rb_data_type_t careduce_data_type;
|
600
|
+
extern const rb_data_type_t carefer_data_type;
|
601
|
+
extern const rb_data_type_t carepeat_data_type;
|
602
|
+
extern const rb_data_type_t caselect_data_type;
|
603
|
+
extern const rb_data_type_t cashift_data_type;
|
604
|
+
extern const rb_data_type_t catrans_data_type;
|
605
|
+
extern const rb_data_type_t caunboundrepeat_data_type;
|
606
|
+
extern const rb_data_type_t cawindow_data_type;
|
607
|
+
|
608
|
+
extern const rb_data_type_t carray_mask_data_type;
|
609
|
+
extern const rb_data_type_t cablock_mask_data_type;
|
610
|
+
extern const rb_data_type_t cagrid_mask_data_type;
|
611
|
+
extern const rb_data_type_t camapping_mask_data_type;
|
612
|
+
extern const rb_data_type_t careduce_mask_data_type;
|
613
|
+
extern const rb_data_type_t carefer_mask_data_type;
|
614
|
+
extern const rb_data_type_t carepeat_mask_data_type;
|
615
|
+
extern const rb_data_type_t caselect_mask_data_type;
|
616
|
+
extern const rb_data_type_t cashift_mask_data_type;
|
617
|
+
extern const rb_data_type_t catrans_mask_data_type;
|
618
|
+
extern const rb_data_type_t caunboundrepeat_mask_data_type;
|
619
|
+
extern const rb_data_type_t cawindow_mask_data_type;
|
620
|
+
|
621
|
+
/* -------------------------------------------------------------------- */
|
622
|
+
|
563
623
|
extern VALUE rb_cCArray;
|
564
624
|
extern VALUE rb_cCAVirtual;
|
565
625
|
extern VALUE rb_cCScalar;
|
@@ -572,6 +632,14 @@ extern VALUE rb_cCARepeat;
|
|
572
632
|
extern VALUE rb_cCAUnboundRepeat;
|
573
633
|
extern VALUE rb_cCAIterator;
|
574
634
|
|
635
|
+
extern VALUE rb_cCArrayMask;
|
636
|
+
extern VALUE rb_cCAReferMask;
|
637
|
+
extern VALUE rb_cCABlockMask;
|
638
|
+
extern VALUE rb_cCASelectMask;
|
639
|
+
extern VALUE rb_cCAObjectMask;
|
640
|
+
extern VALUE rb_cCARepeatMask;
|
641
|
+
extern VALUE rb_cCAUnboundRepeatMask;
|
642
|
+
|
575
643
|
extern VALUE rb_mCA;
|
576
644
|
extern VALUE rb_mCAMath;
|
577
645
|
extern VALUE rb_eCADataTypeError;
|
@@ -595,25 +663,6 @@ extern VALUE rb_cCArrayObject;
|
|
595
663
|
|
596
664
|
/* -------------------------------------------------------------------- */
|
597
665
|
|
598
|
-
extern const int ca_endian;
|
599
|
-
extern const int32_t ca_valid[CA_NTYPE];
|
600
|
-
extern const int32_t ca_sizeof[CA_NTYPE];
|
601
|
-
extern const char * ca_type_name[CA_NTYPE];
|
602
|
-
extern const int ca_cast_table[CA_NTYPE][CA_NTYPE];
|
603
|
-
extern const int ca_cast_table2[CA_NTYPE][CA_NTYPE];
|
604
|
-
|
605
|
-
extern VALUE ca_class[CA_OBJ_TYPE_MAX];
|
606
|
-
extern ca_operation_function_t ca_func[CA_OBJ_TYPE_MAX];
|
607
|
-
extern int ca_obj_num;
|
608
|
-
|
609
|
-
#define CAVIRTUAL(x) ((CAVirtual *)(x))
|
610
|
-
|
611
|
-
#define ca_set_flag(ca, flag) ( ca->flags |= flag )
|
612
|
-
#define ca_unset_flag(ca, flag) ( ca->flags &= ~flag )
|
613
|
-
#define ca_test_flag(ca, flag) (( ca->flags & flag ) ? 1 : 0)
|
614
|
-
|
615
|
-
/* -------------------------------------------------------------------- */
|
616
|
-
|
617
666
|
#define CA_CHECK_DATA_TYPE(data_type) \
|
618
667
|
if ( data_type <= CA_NONE || data_type >= CA_NTYPE ) { \
|
619
668
|
rb_raise(rb_eRuntimeError, "invalid data_type id %i", data_type); \
|
@@ -788,10 +837,20 @@ VALUE rb_ca_call_binop (VALUE self, VALUE other, ca_binop_func_t func[]);
|
|
788
837
|
VALUE rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[]);
|
789
838
|
VALUE rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[]);
|
790
839
|
VALUE rb_ca_call_bincmp (VALUE self, VALUE other, ca_bincmp_func_t func[]);
|
791
|
-
void ca_monop_not_implement(ca_size_t n,
|
792
|
-
|
793
|
-
|
794
|
-
void
|
840
|
+
void ca_monop_not_implement(ca_size_t n, boolean8_t *m,
|
841
|
+
char *ptr1, ca_size_t i1,
|
842
|
+
char *ptr2, ca_size_t i2) __attribute__((noreturn));
|
843
|
+
void ca_binop_not_implement(ca_size_t n, boolean8_t *m,
|
844
|
+
char *ptr1, ca_size_t i1,
|
845
|
+
char *ptr2, ca_size_t i2,
|
846
|
+
char *ptr3, ca_size_t i3) __attribute__((noreturn));
|
847
|
+
void ca_moncmp_not_implement(ca_size_t n, boolean8_t *m,
|
848
|
+
char *ptr1, ca_size_t i1,
|
849
|
+
boolean8_t *ptr2, ca_size_t i2) __attribute__((noreturn));
|
850
|
+
void ca_bincmp_not_implement(ca_size_t n, boolean8_t *m,
|
851
|
+
char *ptr1, ca_size_t b1, ca_size_t i1,
|
852
|
+
char *ptr2, ca_size_t b2, ca_size_t i2,
|
853
|
+
char *ptr3, ca_size_t b3, ca_size_t i3) __attribute__((noreturn));
|
795
854
|
VALUE ca_math_call (VALUE mod, VALUE arg, ID id);
|
796
855
|
|
797
856
|
/* -------------------------------------------------------------------- */
|
@@ -914,7 +973,14 @@ VALUE rb_dim_iter_new (VALUE vca, CAIndexInfo *info);
|
|
914
973
|
|
915
974
|
void * malloc_with_check(size_t size);
|
916
975
|
|
917
|
-
int
|
976
|
+
int
|
977
|
+
ca_install_obj_type (VALUE klass,
|
978
|
+
const rb_data_type_t *typeddata,
|
979
|
+
VALUE mask_klass,
|
980
|
+
const rb_data_type_t *mask_typeddata,
|
981
|
+
ca_operation_function_t func);
|
982
|
+
|
983
|
+
|
918
984
|
VALUE ca_data_type_class (int8_t data_type);
|
919
985
|
|
920
986
|
void ca_mark (void *ap);
|
data/ext/carray_access.c
CHANGED
@@ -26,7 +26,7 @@ rb_ca_store_index (VALUE self, ca_size_t *idx, VALUE rval)
|
|
26
26
|
boolean8_t zero = 0, one = 1;
|
27
27
|
|
28
28
|
rb_ca_modify(self);
|
29
|
-
|
29
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
30
30
|
|
31
31
|
if ( ca_is_empty(ca) ) {
|
32
32
|
return rval;
|
@@ -69,7 +69,7 @@ rb_ca_fetch_index (VALUE self, ca_size_t *idx)
|
|
69
69
|
{
|
70
70
|
volatile VALUE out;
|
71
71
|
CArray *ca;
|
72
|
-
|
72
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
73
73
|
|
74
74
|
if ( ca_is_empty(ca) ) {
|
75
75
|
return Qnil;
|
@@ -108,7 +108,7 @@ rb_ca_store_addr (VALUE self, ca_size_t addr, VALUE rval)
|
|
108
108
|
boolean8_t zero = 0, one = 1;
|
109
109
|
|
110
110
|
rb_ca_modify(self);
|
111
|
-
|
111
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
112
112
|
|
113
113
|
if ( ca_is_empty(ca) ) {
|
114
114
|
return rval;
|
@@ -149,7 +149,7 @@ rb_ca_fetch_addr (VALUE self, ca_size_t addr)
|
|
149
149
|
{
|
150
150
|
volatile VALUE out;
|
151
151
|
CArray *ca;
|
152
|
-
|
152
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
153
153
|
|
154
154
|
if ( ca_is_empty(ca) ) {
|
155
155
|
return Qnil;
|
@@ -196,7 +196,7 @@ rb_ca_fill (VALUE self, VALUE rval)
|
|
196
196
|
CArray *ca;
|
197
197
|
|
198
198
|
rb_ca_modify(self);
|
199
|
-
|
199
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
200
200
|
|
201
201
|
if ( ca_is_empty(ca) ) {
|
202
202
|
return rval;
|
@@ -451,7 +451,7 @@ rb_ca_scan_index (int ca_ndim, ca_size_t *ca_dim, ca_size_t ca_elements,
|
|
451
451
|
|
452
452
|
if ( rb_obj_is_carray(arg) ) {
|
453
453
|
CArray *cs;
|
454
|
-
|
454
|
+
TypedData_Get_Struct(arg, CArray, &carray_data_type, cs);
|
455
455
|
if ( ca_is_integer_type(cs) ) {
|
456
456
|
#if 0
|
457
457
|
if ( ca_ndim == 1 && cs->ndim == 1 ) { /* ca[g] -> CA_REG_GRID (1d) */
|
@@ -849,7 +849,7 @@ rb_ca_scan_index (int ca_ndim, ca_size_t *ca_dim, ca_size_t ca_elements,
|
|
849
849
|
}
|
850
850
|
else if ( rb_obj_is_carray(arg) ) { /* ca[--,ca,--] */
|
851
851
|
CArray *ci;
|
852
|
-
|
852
|
+
TypedData_Get_Struct(arg, CArray, &carray_data_type, ci);
|
853
853
|
if ( ca_is_boolean_type(ci) || ca_is_integer_type(ci) ) {
|
854
854
|
is_grid = 1;
|
855
855
|
goto loop_exit;
|
@@ -944,7 +944,7 @@ rb_ca_ref_address (VALUE self, CAIndexInfo *info)
|
|
944
944
|
{
|
945
945
|
CArray *ca;
|
946
946
|
ca_size_t addr;
|
947
|
-
|
947
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
948
948
|
addr = info->index[0].scalar;
|
949
949
|
return rb_ca_fetch_addr(self, addr);
|
950
950
|
}
|
@@ -954,7 +954,7 @@ rb_ca_store_address (VALUE self, CAIndexInfo *info, volatile VALUE rval)
|
|
954
954
|
{
|
955
955
|
CArray *ca;
|
956
956
|
ca_size_t addr;
|
957
|
-
|
957
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
958
958
|
addr = info->index[0].scalar;
|
959
959
|
if ( rb_obj_is_cscalar(rval) ) {
|
960
960
|
rval = rb_ca_fetch_addr(rval, 0);
|
@@ -969,7 +969,7 @@ rb_ca_ref_point (VALUE self, CAIndexInfo *info)
|
|
969
969
|
CArray *ca;
|
970
970
|
ca_size_t idx[CA_RANK_MAX];
|
971
971
|
int8_t i;
|
972
|
-
|
972
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
973
973
|
for (i=0; i<ca->ndim; i++) {
|
974
974
|
idx[i] = info->index[i].scalar;
|
975
975
|
}
|
@@ -982,7 +982,7 @@ rb_ca_store_point (VALUE self, CAIndexInfo *info, volatile VALUE val)
|
|
982
982
|
CArray *ca;
|
983
983
|
ca_size_t idx[CA_RANK_MAX];
|
984
984
|
int8_t i;
|
985
|
-
|
985
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
986
986
|
for (i=0; i<ca->ndim; i++) {
|
987
987
|
idx[i] = info->index[i].scalar;
|
988
988
|
}
|
@@ -1014,17 +1014,17 @@ rb_ca_store_all (VALUE self, VALUE rval)
|
|
1014
1014
|
rval = rb_ca_fetch_addr(rval, 0);
|
1015
1015
|
}
|
1016
1016
|
|
1017
|
-
|
1017
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1018
1018
|
|
1019
1019
|
retry:
|
1020
1020
|
|
1021
1021
|
if ( rb_obj_is_carray(rval) ) {
|
1022
1022
|
CArray *cv;
|
1023
|
-
|
1023
|
+
TypedData_Get_Struct(rval, CArray, &carray_data_type, cv);
|
1024
1024
|
|
1025
1025
|
if ( cv->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
1026
1026
|
rval = ca_ubrep_bind_with(rval, self);
|
1027
|
-
|
1027
|
+
TypedData_Get_Struct(rval, CArray, &carray_data_type, cv);
|
1028
1028
|
}
|
1029
1029
|
|
1030
1030
|
if ( ca->elements != cv->elements ) {
|
@@ -1217,29 +1217,14 @@ rb_ca_ref_block (VALUE self, CAIndexInfo *info)
|
|
1217
1217
|
int16_t ndim = 0;
|
1218
1218
|
ca_size_t offset = 0;
|
1219
1219
|
ca_size_t flag = 0;
|
1220
|
-
ca_size_t elements;
|
1221
1220
|
ca_size_t i;
|
1222
1221
|
|
1223
|
-
|
1222
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1224
1223
|
|
1225
1224
|
ndim = info->ndim;
|
1226
1225
|
|
1227
|
-
elements = 1;
|
1228
1226
|
for (i=0; i<info->ndim; i++) {
|
1229
1227
|
dim[i] = ca->dim[i];
|
1230
|
-
switch ( info->index_type[i] ) {
|
1231
|
-
case CA_IDX_SCALAR:
|
1232
|
-
elements *= 1;
|
1233
|
-
break;
|
1234
|
-
case CA_IDX_ALL:
|
1235
|
-
elements *= ca->dim[i];
|
1236
|
-
break;
|
1237
|
-
case CA_IDX_BLOCK:
|
1238
|
-
elements *= info->index[i].block.count;
|
1239
|
-
break;
|
1240
|
-
default:
|
1241
|
-
rb_raise(rb_eIndexError, "invalid index for block reference");
|
1242
|
-
}
|
1243
1228
|
}
|
1244
1229
|
|
1245
1230
|
for (i=0; i<info->ndim; i++) {
|
@@ -1291,7 +1276,7 @@ rb_ca_refer_new_flatten (VALUE self)
|
|
1291
1276
|
CArray *ca;
|
1292
1277
|
ca_size_t dim0;
|
1293
1278
|
|
1294
|
-
|
1279
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1295
1280
|
dim0 = ca->elements;
|
1296
1281
|
return rb_ca_refer_new(self, ca->data_type, 1, &dim0, ca->bytes, 0);
|
1297
1282
|
}
|
@@ -1312,7 +1297,7 @@ rb_ca_fetch_method (int argc, VALUE *argv, VALUE self)
|
|
1312
1297
|
|
1313
1298
|
retry:
|
1314
1299
|
|
1315
|
-
|
1300
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1316
1301
|
|
1317
1302
|
info.range_check = 1;
|
1318
1303
|
rb_ca_scan_index(ca->ndim, ca->dim, ca->elements, argc, argv, &info);
|
@@ -1380,7 +1365,6 @@ rb_ca_fetch_method (int argc, VALUE *argv, VALUE self)
|
|
1380
1365
|
default:
|
1381
1366
|
rb_raise(rb_eIndexError, "invalid index specified");
|
1382
1367
|
}
|
1383
|
-
|
1384
1368
|
return obj;
|
1385
1369
|
}
|
1386
1370
|
|
@@ -1391,7 +1375,7 @@ rb_cs_fetch_method (int argc, VALUE *argv, VALUE self)
|
|
1391
1375
|
CArray *ca;
|
1392
1376
|
CAIndexInfo info;
|
1393
1377
|
|
1394
|
-
|
1378
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1395
1379
|
|
1396
1380
|
info.range_check = 0;
|
1397
1381
|
rb_ca_scan_index(ca->ndim, ca->dim, ca->elements, argc, argv, &info);
|
@@ -1484,7 +1468,7 @@ rb_ca_store_method (int argc, VALUE *argv, VALUE self)
|
|
1484
1468
|
|
1485
1469
|
retry:
|
1486
1470
|
|
1487
|
-
|
1471
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1488
1472
|
|
1489
1473
|
info.range_check = 1;
|
1490
1474
|
rb_ca_scan_index(ca->ndim, ca->dim, ca->elements, argc, argv, &info);
|
@@ -1543,7 +1527,7 @@ rb_ca_store_method (int argc, VALUE *argv, VALUE self)
|
|
1543
1527
|
}
|
1544
1528
|
case CA_REG_METHOD_CALL: {
|
1545
1529
|
volatile VALUE idx;
|
1546
|
-
|
1530
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1547
1531
|
ca_attach(ca);
|
1548
1532
|
idx = rb_funcall2(self, SYM2ID(info.symbol), (int)(argc-1), argv+1);
|
1549
1533
|
obj = rb_ca_store(self, idx, rval);
|
@@ -1619,7 +1603,7 @@ rb_ca_store2 (VALUE self, int n, VALUE *rindex, VALUE rval)
|
|
1619
1603
|
static VALUE
|
1620
1604
|
rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
|
1621
1605
|
{
|
1622
|
-
volatile VALUE rtype,
|
1606
|
+
volatile VALUE rtype, rindex;
|
1623
1607
|
CAIndexInfo info;
|
1624
1608
|
int ndim;
|
1625
1609
|
ca_size_t dim[CA_RANK_MAX];
|
@@ -1644,7 +1628,6 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
|
|
1644
1628
|
RARRAY_LEN(ridx), RARRAY_PTR(ridx), &info);
|
1645
1629
|
|
1646
1630
|
rtype = INT2NUM(info.type);
|
1647
|
-
rndim = INT2NUM(info.ndim);
|
1648
1631
|
rindex = rb_ary_new2(info.ndim);
|
1649
1632
|
|
1650
1633
|
switch ( info.type ) {
|
@@ -1736,7 +1719,7 @@ rb_ca_normalize_index (VALUE self, VALUE ridx)
|
|
1736
1719
|
CAIndexInfo info;
|
1737
1720
|
int i;
|
1738
1721
|
|
1739
|
-
|
1722
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1740
1723
|
Check_Type(ridx, T_ARRAY);
|
1741
1724
|
|
1742
1725
|
info.range_check = 1;
|
@@ -1811,7 +1794,7 @@ rb_ca_addr2index (VALUE self, VALUE raddr)
|
|
1811
1794
|
ca_size_t addr;
|
1812
1795
|
int i;
|
1813
1796
|
|
1814
|
-
|
1797
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1815
1798
|
|
1816
1799
|
addr = NUM2SIZE(raddr);
|
1817
1800
|
if ( addr < 0 || addr >= ca->elements ) {
|
@@ -1849,7 +1832,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
|
|
1849
1832
|
boolean8_t *m;
|
1850
1833
|
int all_number = 1;
|
1851
1834
|
|
1852
|
-
|
1835
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1853
1836
|
|
1854
1837
|
if ( argc != ca->ndim ) {
|
1855
1838
|
rb_raise(rb_eRuntimeError, "invalid ndim of index");
|
@@ -1892,7 +1875,7 @@ rb_ca_index2addr (int argc, VALUE *argv, VALUE self)
|
|
1892
1875
|
}
|
1893
1876
|
|
1894
1877
|
obj = rb_carray_new(CA_SIZE, 1, &elements, 0, NULL);
|
1895
|
-
|
1878
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, co);
|
1896
1879
|
|
1897
1880
|
q = (ca_size_t *) co->ptr;
|
1898
1881
|
|