carray 3.0.6 → 3.1.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/.yardopts +1 -1
- data/CHANGELOG.md +7 -1830
- data/README.md +62 -35
- data/carray.gemspec +16 -4
- data/docs/changelogs/CHANGELOG-3.0.md +2464 -0
- data/ext/ca_array_pool.c +4 -5
- data/ext/ca_axis_descriptor.h +45 -30
- data/ext/ca_axis_dispatch.c +7 -4
- data/ext/ca_axis_group.c +12 -15
- data/ext/ca_bincmp_dispatch.h +16 -38
- data/ext/ca_binop_dispatch.c +35 -0
- data/ext/ca_binop_dispatch.h +22 -46
- data/ext/ca_categorical_iterator.c +36 -34
- data/ext/ca_compare.c +0 -1
- data/ext/ca_compare.h +8 -1
- data/ext/ca_composite_dispatch.h +6 -0
- data/ext/ca_for_buffer.h +6 -1
- data/ext/ca_group_iter.c +17 -18
- data/ext/ca_iter_state_fields.h +196 -0
- data/ext/ca_iter_substrate.h +84 -103
- data/ext/ca_kernel_iterator.c +125 -89
- data/ext/ca_kernel_iterator.h +229 -1504
- data/ext/ca_kernel_iterator_internal.h +1167 -0
- data/ext/ca_moncmp_dispatch.h +17 -24
- data/ext/ca_monop_dispatch.h +25 -74
- data/ext/ca_obj_array.c +92 -165
- data/ext/ca_obj_bincmp.c +65 -48
- data/ext/ca_obj_binop.c +74 -49
- data/ext/ca_obj_bitarray.c +7 -21
- data/ext/ca_obj_bitfield.c +93 -26
- data/ext/ca_obj_block.c +11 -12
- data/ext/ca_obj_byte_swap.c +34 -34
- data/ext/ca_obj_const_string.c +464 -304
- data/ext/ca_obj_face.c +167 -121
- data/ext/ca_obj_face.h +32 -170
- data/ext/ca_obj_fake.c +127 -34
- data/ext/ca_obj_farray.c +13 -9
- data/ext/ca_obj_field.c +17 -13
- data/ext/ca_obj_fixlen_string.c +57 -34
- data/ext/ca_obj_grid.c +149 -113
- data/ext/ca_obj_meld.c +28 -26
- data/ext/ca_obj_moncmp.c +10 -21
- data/ext/ca_obj_monop.c +88 -73
- data/ext/ca_obj_object.c +60 -46
- data/ext/ca_obj_record.c +74 -22
- data/ext/ca_obj_reduce.c +10 -14
- data/ext/ca_obj_refer.c +146 -39
- data/ext/ca_obj_remap.c +11 -29
- data/ext/ca_obj_repeat.c +41 -23
- data/ext/ca_obj_roll.c +20 -28
- data/ext/ca_obj_select.c +17 -27
- data/ext/ca_obj_select_axis.c +35 -42
- data/ext/ca_obj_shift.c +22 -42
- data/ext/ca_obj_source.c +1 -5
- data/ext/ca_obj_stack.c +33 -29
- data/ext/ca_obj_stride.c +99 -62
- data/ext/ca_obj_string.c +8 -20
- data/ext/ca_obj_tile.c +14 -16
- data/ext/ca_obj_time.c +12 -23
- data/ext/ca_obj_timedelta.c +12 -23
- data/ext/ca_obj_transpose.c +8 -10
- data/ext/ca_obj_triop.c +48 -49
- data/ext/ca_obj_window.c +87 -99
- data/ext/ca_op_cmplx64.h +4 -0
- data/ext/ca_op_ipower.c +97 -27
- data/ext/ca_op_powi.h +9 -28
- data/ext/ca_pow5_table.h +2 -1
- data/ext/ca_rng_normal.h +4 -0
- data/ext/ca_rng_xoshiro256pp.h +3 -0
- data/ext/ca_sort_kernels.h +23 -26
- data/ext/ca_sweep_engine.c +92 -26
- data/ext/ca_sweep_engine.h +22 -15
- data/ext/ca_transform_common.c +3 -8
- data/ext/ca_triop_dispatch.h +20 -32
- data/ext/caframe_csv_reader.c +12 -12
- data/ext/carray.h +300 -1009
- data/ext/carray_access.c +320 -207
- data/ext/carray_address_basis.c +128 -59
- data/ext/carray_attribute.c +81 -104
- data/ext/carray_bincount.c +12 -14
- data/ext/carray_broadcast.c +31 -27
- data/ext/carray_call_cfunc.c +174 -285
- data/ext/carray_call_cfunc.h +36 -28
- data/ext/carray_cast.c +1191 -351
- data/ext/carray_cast_func.rb +68 -8
- data/ext/carray_class.c +6 -11
- data/ext/carray_conversion.c +98 -39
- data/ext/carray_copy.c +52 -26
- data/ext/carray_core.c +286 -132
- data/ext/carray_count.c +53 -22
- data/ext/carray_element.c +49 -28
- data/ext/carray_factorize.c +64 -63
- data/ext/carray_generate.c +26 -19
- data/ext/carray_histogram.c +9 -11
- data/ext/carray_hold.c +7 -9
- data/ext/carray_index_classifier.c +127 -230
- data/ext/carray_index_classifier.h +11 -10
- data/ext/carray_integer_total.c +523 -0
- data/ext/carray_internal.h +1364 -156
- data/ext/carray_key_windows.c +3 -3
- data/ext/carray_lazy.c +37 -37
- data/ext/carray_loop.c +27 -23
- data/ext/carray_mask.c +235 -150
- data/ext/carray_math_kernel.h +23 -47
- data/ext/carray_mathfunc.c +10 -3
- data/ext/carray_median_percentile.c +106 -100
- data/ext/carray_memory_view.c +83 -69
- data/ext/carray_operator.c +490 -128
- data/ext/carray_order.c +163 -84
- data/ext/carray_partition.c +14 -16
- data/ext/carray_random.c +48 -42
- data/ext/carray_round.c +33 -5
- data/ext/carray_scatter.c +57 -39
- data/ext/carray_segment.c +42 -46
- data/ext/carray_slab.c +77 -51
- data/ext/carray_slab.h +44 -33
- data/ext/carray_sort.c +37 -31
- data/ext/carray_sort_kernel.c +36 -10
- data/ext/carray_struct.c +44 -34
- data/ext/carray_test.c +131 -81
- data/ext/carray_time_text.c +30 -31
- data/ext/carray_undef.c +50 -7
- data/ext/carray_utils.c +373 -139
- data/ext/extconf.rb +24 -17
- data/ext/mk_call_cfunc.rb +25 -31
- data/ext/mk_pow5_table.rb +2 -1
- data/ext/mkkernel.rb +819 -488
- data/ext/ruby_carray.c +47 -42
- data/ext/version.h +7 -5
- data/lib/carray/attribute.rb +19 -18
- data/lib/carray/autoload_carray.rb +20 -15
- data/lib/carray/autoload_method_extension.rb +64 -57
- data/lib/carray/axis_group.rb +272 -185
- data/lib/carray/basics.rb +298 -56
- data/lib/carray/bincount_nd.rb +41 -18
- data/lib/carray/block_iterator.rb +167 -119
- data/lib/carray/boolean_reduce.rb +7 -4
- data/lib/carray/categorical.rb +84 -59
- data/lib/carray/categorical_iterator.rb +90 -67
- data/lib/carray/complex.rb +61 -41
- data/lib/carray/conditional.rb +98 -23
- data/lib/carray/const_string.rb +112 -46
- data/lib/carray/core_extensions.rb +20 -69
- data/lib/carray/distance_limit.rb +7 -5
- data/lib/carray/factories.rb +269 -0
- data/lib/carray/fixlen_string.rb +95 -12
- data/lib/carray/frame/column_verbs.rb +76 -9
- data/lib/carray/frame/concat.rb +51 -7
- data/lib/carray/frame/convert.rb +2 -1
- data/lib/carray/frame/csv_parser.rb +20 -5
- data/lib/carray/frame/frame.rb +73 -31
- data/lib/carray/frame/group.rb +247 -187
- data/lib/carray/frame/io.rb +36 -12
- data/lib/carray/frame/join.rb +56 -17
- data/lib/carray/frame/records.rb +7 -5
- data/lib/carray/frame/reshape.rb +27 -7
- data/lib/carray/frame/sort.rb +10 -8
- data/lib/carray/frame/verbs.rb +217 -134
- data/lib/carray/frame/windows.rb +254 -19
- data/lib/carray/frame.rb +1 -2
- data/lib/carray/fuse_source.rb +28 -23
- data/lib/carray/fusion.rb +30 -30
- data/lib/carray/histogram.rb +35 -16
- data/lib/carray/inspect.rb +7 -7
- data/lib/carray/iterator.rb +104 -23
- data/lib/carray/key_windows.rb +93 -61
- data/lib/carray/lazy.rb +208 -111
- data/lib/carray/limits.rb +80 -0
- data/lib/carray/mask_gap_fill.rb +21 -16
- data/lib/carray/math.rb +87 -50
- data/lib/carray/meld_reduce.rb +30 -8
- data/lib/carray/methods/align_addr.rb +29 -17
- data/lib/carray/methods/bin.rb +8 -1
- data/lib/carray/methods/bincount.rb +4 -2
- data/lib/carray/methods/bit_string.rb +19 -31
- data/lib/carray/methods/broadcast.rb +8 -3
- data/lib/carray/methods/choose.rb +5 -5
- data/lib/carray/methods/composition.rb +73 -72
- data/lib/carray/methods/{index.rb → coordinate.rb} +13 -13
- data/lib/carray/methods/discovery_along.rb +3 -3
- data/lib/carray/methods/factorize.rb +2 -0
- data/lib/carray/methods/gather_nd.rb +106 -103
- data/lib/carray/methods/insert_block.rb +2 -2
- data/lib/carray/methods/is_between.rb +6 -4
- data/lib/carray/methods/is_in.rb +183 -143
- data/lib/carray/methods/join.rb +2 -1
- data/lib/carray/methods/lag.rb +6 -2
- data/lib/carray/methods/locate_addr.rb +157 -94
- data/lib/carray/methods/mask_duplicates.rb +1 -1
- data/lib/carray/methods/meshgrid.rb +28 -16
- data/lib/carray/methods/mode.rb +67 -67
- data/lib/carray/methods/nunique.rb +9 -7
- data/lib/carray/methods/repeat.rb +23 -13
- data/lib/carray/methods/resize.rb +1 -1
- data/lib/carray/methods/snap.rb +24 -20
- data/lib/carray/methods/string_format.rb +2 -2
- data/lib/carray/methods/unique.rb +4 -2
- data/lib/carray/methods/value_counts.rb +1 -1
- data/lib/carray/mkmf.rb +25 -28
- data/lib/carray/percentile_arguments.rb +82 -0
- data/lib/carray/record_order.rb +50 -20
- data/lib/carray/rng.rb +1 -0
- data/lib/carray/runtime.rb +195 -17
- data/lib/carray/segment_iterator.rb +262 -137
- data/lib/carray/serialize.rb +635 -566
- data/lib/carray/slab_iterator.rb +114 -114
- data/lib/carray/stack.rb +14 -15
- data/lib/carray/string.rb +16 -22
- data/lib/carray/string_operation_extension.rb +97 -52
- data/lib/carray/struct.rb +122 -164
- data/lib/carray/struct_builder.rb +247 -73
- data/lib/carray/time.rb +663 -365
- data/lib/carray/window_iterator.rb +232 -155
- data/lib/carray.rb +6 -11
- data/yard-stubs/ca_obj_array.rb +20 -135
- data/yard-stubs/ca_obj_bitarray.rb +1 -8
- data/yard-stubs/ca_obj_bitfield.rb +6 -2
- data/yard-stubs/ca_obj_byte_swap.rb +21 -7
- data/yard-stubs/ca_obj_fake.rb +3 -1
- data/yard-stubs/ca_obj_farray.rb +1 -1
- data/yard-stubs/ca_obj_field.rb +8 -6
- data/yard-stubs/ca_obj_refer.rb +10 -5
- data/yard-stubs/ca_obj_roll.rb +7 -6
- data/yard-stubs/ca_obj_shift.rb +2 -3
- data/yard-stubs/ca_obj_stride.rb +5 -7
- data/yard-stubs/ca_obj_tile.rb +1 -1
- data/yard-stubs/ca_obj_time.rb +43 -0
- data/yard-stubs/ca_obj_transpose.rb +1 -1
- data/yard-stubs/ca_obj_window.rb +28 -16
- data/yard-stubs/carray_access.rb +55 -6
- data/yard-stubs/carray_attribute.rb +26 -38
- data/yard-stubs/carray_cast.rb +121 -162
- data/yard-stubs/carray_class.rb +3 -4
- data/yard-stubs/carray_conversion.rb +6 -7
- data/yard-stubs/carray_copy.rb +2 -1
- data/yard-stubs/carray_count.rb +10 -5
- data/yard-stubs/carray_element.rb +4 -3
- data/yard-stubs/carray_limits.rb +100 -0
- data/yard-stubs/carray_loop.rb +0 -20
- data/yard-stubs/carray_mask.rb +59 -41
- data/yard-stubs/carray_math.rb +162 -100
- data/yard-stubs/carray_mathfunc.rb +415 -3
- data/yard-stubs/carray_median_percentile.rb +29 -11
- data/yard-stubs/carray_memory_view.rb +2 -2
- data/yard-stubs/carray_order.rb +72 -33
- data/yard-stubs/carray_random.rb +6 -6
- data/yard-stubs/carray_reduce.rb +353 -0
- data/yard-stubs/carray_rng.rb +92 -0
- data/yard-stubs/carray_scatter.rb +12 -3
- data/yard-stubs/carray_slab.rb +7 -4
- data/yard-stubs/carray_sort.rb +7 -6
- data/yard-stubs/carray_test.rb +18 -5
- data/yard-stubs/carray_undef.rb +44 -5
- data/yard-stubs/ruby_carray.rb +75 -40
- metadata +63 -25
- data/CHANGELOG.v1.md +0 -126
- data/ext/carray_build_flags.h +0 -3
- data/ext/carray_config.h +0 -28
- data/ext/carray_data_type.c +0 -90
- data/ext/carray_kernels_bincmp.c +0 -6457
- data/ext/carray_kernels_binop.c +0 -31534
- data/ext/carray_kernels_init.c +0 -1734
- data/ext/carray_kernels_moncmp.c +0 -2104
- data/ext/carray_kernels_monop.c +0 -25387
- data/ext/carray_kernels_reduce_aggregate.c +0 -27545
- data/ext/carray_kernels_reduce_boolean.c +0 -1924
- data/ext/carray_kernels_reduce_cumulative.c +0 -11646
- data/ext/carray_kernels_reduce_extreme.c +0 -21631
- data/ext/carray_kernels_reduce_variance.c +0 -5981
- data/ext/carray_kernels_scan.c +0 -4302
- data/ext/carray_kernels_search.c +0 -37776
- data/ext/carray_kernels_sort.c +0 -10814
- data/ext/carray_kernels_triop.c +0 -1864
- data/lib/carray/construct.rb +0 -360
- data/lib/carray/data_type_extension.rb +0 -261
- data/lib/carray/data_type_limits.rb +0 -91
data/ext/carray_attribute.c
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* ---------------------------------------------------------------------------
|
|
2
2
|
|
|
3
3
|
Attribute and predicate accessors for CArray (obj_type / data_type
|
|
4
|
-
/ ndim / shape / dim / bytes / elements + entity? /
|
|
4
|
+
/ ndim / shape / dim / bytes / elements + entity? / view? /
|
|
5
5
|
fixlen? / boolean? / read_only? / mask_array? / etc.) plus the
|
|
6
6
|
view-chain navigators parent / root_array / ancestors.
|
|
7
7
|
|
|
@@ -13,68 +13,67 @@
|
|
|
13
13
|
|
|
14
14
|
#include "carray.h"
|
|
15
15
|
#include "ca_obj_face.h" /* CA_OBJ_RECORD + rb_ca_record_get_data_class */
|
|
16
|
-
#include "carray_internal.h" /* rb_ca_inherit_attr */
|
|
17
16
|
|
|
18
17
|
/* ------------------------------------------------------------------- */
|
|
19
18
|
|
|
20
19
|
VALUE
|
|
21
|
-
rb_ca_obj_type (VALUE self)
|
|
20
|
+
rb_ca_obj_type (volatile VALUE self)
|
|
22
21
|
{
|
|
23
22
|
CArray *ca;
|
|
24
|
-
|
|
23
|
+
GetCArray(self, ca);
|
|
25
24
|
return INT2NUM(ca->obj_type);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
VALUE
|
|
29
|
-
rb_ca_data_type (VALUE self)
|
|
28
|
+
rb_ca_data_type (volatile VALUE self)
|
|
30
29
|
{
|
|
31
30
|
CArray *ca;
|
|
32
|
-
|
|
31
|
+
GetCArray(self, ca);
|
|
33
32
|
/* Return a Symbol via the pre-computed ID cache; the C internal
|
|
34
33
|
int8_t representation is unchanged. */
|
|
35
34
|
return ID2SYM(ca_data_type_sym[ca->data_type]);
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
VALUE
|
|
39
|
-
rb_ca_ndim (VALUE self)
|
|
38
|
+
rb_ca_ndim (volatile VALUE self)
|
|
40
39
|
{
|
|
41
40
|
CArray *ca;
|
|
42
|
-
|
|
41
|
+
GetCArray(self, ca);
|
|
43
42
|
return INT2NUM(ca->ndim);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
VALUE
|
|
47
|
-
rb_ca_bytes (VALUE self)
|
|
46
|
+
rb_ca_bytes (volatile VALUE self)
|
|
48
47
|
{
|
|
49
48
|
CArray *ca;
|
|
50
|
-
|
|
49
|
+
GetCArray(self, ca);
|
|
51
50
|
return SIZE2NUM(ca->bytes);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
VALUE
|
|
55
|
-
rb_ca_flags (VALUE self)
|
|
54
|
+
rb_ca_flags (volatile VALUE self)
|
|
56
55
|
{
|
|
57
56
|
CArray *ca;
|
|
58
|
-
|
|
57
|
+
GetCArray(self, ca);
|
|
59
58
|
return INT2NUM(ca->flags);
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
VALUE
|
|
63
|
-
rb_ca_elements (VALUE self)
|
|
62
|
+
rb_ca_elements (volatile VALUE self)
|
|
64
63
|
{
|
|
65
64
|
CArray *ca;
|
|
66
|
-
|
|
65
|
+
GetCArray(self, ca);
|
|
67
66
|
return SIZE2NUM(ca->elements);
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
VALUE
|
|
71
|
-
rb_ca_dim (VALUE self)
|
|
70
|
+
rb_ca_dim (volatile VALUE self)
|
|
72
71
|
{
|
|
73
72
|
volatile VALUE dim;
|
|
74
73
|
CArray *ca;
|
|
75
74
|
int i;
|
|
76
|
-
|
|
77
|
-
dim =
|
|
75
|
+
GetCArray(self, ca);
|
|
76
|
+
dim = rb_ary_new_capa(ca->ndim);
|
|
78
77
|
for (i=0; i<ca->ndim; i++) {
|
|
79
78
|
rb_ary_store(dim, i, SIZE2NUM(ca->dim[i]));
|
|
80
79
|
}
|
|
@@ -82,43 +81,11 @@ rb_ca_dim (VALUE self)
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
VALUE
|
|
85
|
-
|
|
84
|
+
rb_ca_data_type_name (volatile VALUE self)
|
|
86
85
|
{
|
|
87
86
|
CArray *ca;
|
|
88
|
-
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
VALUE
|
|
93
|
-
rb_ca_dim1 (VALUE self)
|
|
94
|
-
{
|
|
95
|
-
CArray *ca;
|
|
96
|
-
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
97
|
-
return ( ca->ndim >= 2 ) ? SIZE2NUM(ca->dim[1]) : Qnil;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
VALUE
|
|
101
|
-
rb_ca_dim2 (VALUE self)
|
|
102
|
-
{
|
|
103
|
-
CArray *ca;
|
|
104
|
-
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
105
|
-
return ( ca->ndim >= 3 ) ? SIZE2NUM(ca->dim[2]) : Qnil;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
VALUE
|
|
109
|
-
rb_ca_dim3 (VALUE self)
|
|
110
|
-
{
|
|
111
|
-
CArray *ca;
|
|
112
|
-
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
113
|
-
return ( ca->ndim >= 4 ) ? SIZE2NUM(ca->dim[3]) : Qnil;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
VALUE
|
|
117
|
-
rb_ca_data_type_name (VALUE self)
|
|
118
|
-
{
|
|
119
|
-
CArray *ca;
|
|
120
|
-
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
121
|
-
return rb_str_new2(ca_type_name[ca->data_type]);
|
|
87
|
+
GetCArray(self, ca);
|
|
88
|
+
return rb_str_new_cstr(ca_type_name[ca->data_type]);
|
|
122
89
|
}
|
|
123
90
|
|
|
124
91
|
/* ------------------------------------------------------------------- */
|
|
@@ -131,19 +98,19 @@ ca_is_scalar (void *ap)
|
|
|
131
98
|
}
|
|
132
99
|
|
|
133
100
|
VALUE
|
|
134
|
-
rb_ca_is_scalar (VALUE self)
|
|
101
|
+
rb_ca_is_scalar (volatile VALUE self)
|
|
135
102
|
{
|
|
136
103
|
CArray *ca;
|
|
137
|
-
|
|
104
|
+
GetCArray(self, ca);
|
|
138
105
|
return ( ca_is_scalar(ca) ) ? Qtrue : Qfalse;
|
|
139
106
|
}
|
|
140
107
|
|
|
141
108
|
VALUE
|
|
142
|
-
rb_obj_is_cscalar (VALUE obj)
|
|
109
|
+
rb_obj_is_cscalar (volatile VALUE obj)
|
|
143
110
|
{
|
|
144
111
|
CArray *ca;
|
|
145
112
|
if ( rb_obj_is_carray(obj) ) {
|
|
146
|
-
|
|
113
|
+
GetCArray(obj, ca);
|
|
147
114
|
return ( ca_is_scalar(ca) ) ? Qtrue : Qfalse;
|
|
148
115
|
}
|
|
149
116
|
return Qfalse;
|
|
@@ -159,38 +126,38 @@ ca_is_view (void *ap)
|
|
|
159
126
|
}
|
|
160
127
|
|
|
161
128
|
VALUE
|
|
162
|
-
rb_ca_is_entity (VALUE self)
|
|
129
|
+
rb_ca_is_entity (volatile VALUE self)
|
|
163
130
|
{
|
|
164
131
|
CArray *ca;
|
|
165
|
-
|
|
132
|
+
GetCArray(self, ca);
|
|
166
133
|
return ( ca_is_view(ca) ) ? Qfalse : Qtrue;
|
|
167
134
|
}
|
|
168
135
|
|
|
169
136
|
VALUE
|
|
170
|
-
rb_ca_is_virtual (VALUE self)
|
|
137
|
+
rb_ca_is_virtual (volatile VALUE self)
|
|
171
138
|
{
|
|
172
139
|
CArray *ca;
|
|
173
|
-
|
|
140
|
+
GetCArray(self, ca);
|
|
174
141
|
return ( ca_is_view(ca) ) ? Qtrue : Qfalse;
|
|
175
142
|
}
|
|
176
143
|
|
|
177
144
|
/* ------------------------------------------------------------------- */
|
|
178
145
|
|
|
179
146
|
VALUE
|
|
180
|
-
rb_ca_is_attached (VALUE self)
|
|
147
|
+
rb_ca_is_attached (volatile VALUE self)
|
|
181
148
|
{
|
|
182
149
|
CArray *ca;
|
|
183
|
-
|
|
150
|
+
GetCArray(self, ca);
|
|
184
151
|
return ( ca_is_attached(ca) ) ? Qtrue : Qfalse;
|
|
185
152
|
}
|
|
186
153
|
|
|
187
154
|
/* ------------------------------------------------------------------- */
|
|
188
155
|
|
|
189
156
|
VALUE
|
|
190
|
-
rb_ca_is_empty (VALUE self)
|
|
157
|
+
rb_ca_is_empty (volatile VALUE self)
|
|
191
158
|
{
|
|
192
159
|
CArray *ca;
|
|
193
|
-
|
|
160
|
+
GetCArray(self, ca);
|
|
194
161
|
return ( ca->elements == 0 ) ? Qtrue : Qfalse;
|
|
195
162
|
}
|
|
196
163
|
|
|
@@ -200,6 +167,11 @@ int
|
|
|
200
167
|
ca_is_readonly (void *ap)
|
|
201
168
|
{
|
|
202
169
|
CArray *ca = (CArray *) ap;
|
|
170
|
+
/* Asked once per cell written; an entity answers without recursing, so
|
|
171
|
+
only a view checks the stack. */
|
|
172
|
+
if ( ! ca_is_entity(ca) ) {
|
|
173
|
+
ca_check_stack_room();
|
|
174
|
+
}
|
|
203
175
|
if ( ca_test_flag(ca, CA_FLAG_READ_ONLY) ) { /* test -> true */
|
|
204
176
|
return 1;
|
|
205
177
|
}
|
|
@@ -236,10 +208,10 @@ ca_is_readonly (void *ap)
|
|
|
236
208
|
}
|
|
237
209
|
|
|
238
210
|
VALUE
|
|
239
|
-
rb_ca_is_read_only (VALUE self)
|
|
211
|
+
rb_ca_is_read_only (volatile VALUE self)
|
|
240
212
|
{
|
|
241
213
|
CArray *ca;
|
|
242
|
-
|
|
214
|
+
GetCArray(self, ca);
|
|
243
215
|
return ( ca_is_readonly(ca) ) ? Qtrue : Qfalse;
|
|
244
216
|
}
|
|
245
217
|
|
|
@@ -249,6 +221,7 @@ int
|
|
|
249
221
|
ca_is_mask_array (void *ap)
|
|
250
222
|
{
|
|
251
223
|
CArray *ca = (CArray *) ap;
|
|
224
|
+
ca_check_stack_room();
|
|
252
225
|
if ( ca_test_flag(ca, CA_FLAG_MASK_ARRAY) ) { /* test -> true */
|
|
253
226
|
return 1;
|
|
254
227
|
}
|
|
@@ -269,10 +242,10 @@ ca_is_mask_array (void *ap)
|
|
|
269
242
|
}
|
|
270
243
|
|
|
271
244
|
VALUE
|
|
272
|
-
rb_ca_is_mask_array (VALUE self)
|
|
245
|
+
rb_ca_is_mask_array (volatile VALUE self)
|
|
273
246
|
{
|
|
274
247
|
CArray *ca;
|
|
275
|
-
|
|
248
|
+
GetCArray(self, ca);
|
|
276
249
|
return ( ca_is_mask_array(ca) ) ? Qtrue : Qfalse;
|
|
277
250
|
}
|
|
278
251
|
|
|
@@ -282,6 +255,7 @@ int
|
|
|
282
255
|
ca_is_value_array (void *ap)
|
|
283
256
|
{
|
|
284
257
|
CArray *ca = (CArray *) ap;
|
|
258
|
+
ca_check_stack_room();
|
|
285
259
|
if ( ca_test_flag(ca, CA_FLAG_VALUE_ARRAY) ) { /* test -> true */
|
|
286
260
|
return 1;
|
|
287
261
|
}
|
|
@@ -302,20 +276,20 @@ ca_is_value_array (void *ap)
|
|
|
302
276
|
}
|
|
303
277
|
|
|
304
278
|
VALUE
|
|
305
|
-
rb_ca_is_value_array (VALUE self)
|
|
279
|
+
rb_ca_is_value_array (volatile VALUE self)
|
|
306
280
|
{
|
|
307
281
|
CArray *ca;
|
|
308
|
-
|
|
282
|
+
GetCArray(self, ca);
|
|
309
283
|
return ( ca_is_value_array(ca) ) ? Qtrue : Qfalse;
|
|
310
284
|
}
|
|
311
285
|
|
|
312
286
|
/* ------------------------------------------------------------------- */
|
|
313
287
|
|
|
314
288
|
VALUE
|
|
315
|
-
rb_ca_is_face (VALUE self)
|
|
289
|
+
rb_ca_is_face (volatile VALUE self)
|
|
316
290
|
{
|
|
317
291
|
CArray *ca;
|
|
318
|
-
|
|
292
|
+
GetCArray(self, ca);
|
|
319
293
|
return ( ca_is_face(ca) ) ? Qtrue : Qfalse;
|
|
320
294
|
}
|
|
321
295
|
|
|
@@ -329,10 +303,10 @@ ca_is_fixlen_type (void *ap)
|
|
|
329
303
|
}
|
|
330
304
|
|
|
331
305
|
VALUE
|
|
332
|
-
rb_ca_is_fixlen_type (VALUE self)
|
|
306
|
+
rb_ca_is_fixlen_type (volatile VALUE self)
|
|
333
307
|
{
|
|
334
308
|
CArray *ca;
|
|
335
|
-
|
|
309
|
+
GetCArray(self, ca);
|
|
336
310
|
return ca_is_fixlen_type(ca) ? Qtrue : Qfalse;
|
|
337
311
|
}
|
|
338
312
|
|
|
@@ -346,10 +320,10 @@ ca_is_boolean_type (void *ap)
|
|
|
346
320
|
}
|
|
347
321
|
|
|
348
322
|
VALUE
|
|
349
|
-
rb_ca_is_boolean_type (VALUE self)
|
|
323
|
+
rb_ca_is_boolean_type (volatile VALUE self)
|
|
350
324
|
{
|
|
351
325
|
CArray *ca;
|
|
352
|
-
|
|
326
|
+
GetCArray(self, ca);
|
|
353
327
|
return ca_is_boolean_type(ca) ? Qtrue : Qfalse;
|
|
354
328
|
}
|
|
355
329
|
|
|
@@ -364,10 +338,10 @@ ca_is_numeric_type (void *ap)
|
|
|
364
338
|
}
|
|
365
339
|
|
|
366
340
|
VALUE
|
|
367
|
-
rb_ca_is_numeric_type (VALUE self)
|
|
341
|
+
rb_ca_is_numeric_type (volatile VALUE self)
|
|
368
342
|
{
|
|
369
343
|
CArray *ca;
|
|
370
|
-
|
|
344
|
+
GetCArray(self, ca);
|
|
371
345
|
return ca_is_numeric_type(ca) ? Qtrue : Qfalse;
|
|
372
346
|
}
|
|
373
347
|
|
|
@@ -382,10 +356,10 @@ ca_is_integer_type (void *ap)
|
|
|
382
356
|
}
|
|
383
357
|
|
|
384
358
|
VALUE
|
|
385
|
-
rb_ca_is_integer_type (VALUE self)
|
|
359
|
+
rb_ca_is_integer_type (volatile VALUE self)
|
|
386
360
|
{
|
|
387
361
|
CArray *ca;
|
|
388
|
-
|
|
362
|
+
GetCArray(self, ca);
|
|
389
363
|
return ca_is_integer_type(ca) ? Qtrue : Qfalse;
|
|
390
364
|
}
|
|
391
365
|
|
|
@@ -400,10 +374,10 @@ ca_is_float_type (void *ap)
|
|
|
400
374
|
}
|
|
401
375
|
|
|
402
376
|
VALUE
|
|
403
|
-
rb_ca_is_float_type (VALUE self)
|
|
377
|
+
rb_ca_is_float_type (volatile VALUE self)
|
|
404
378
|
{
|
|
405
379
|
CArray *ca;
|
|
406
|
-
|
|
380
|
+
GetCArray(self, ca);
|
|
407
381
|
return ca_is_float_type(ca) ? Qtrue : Qfalse;
|
|
408
382
|
}
|
|
409
383
|
|
|
@@ -418,10 +392,10 @@ ca_is_complex_type (void *ap)
|
|
|
418
392
|
}
|
|
419
393
|
|
|
420
394
|
VALUE
|
|
421
|
-
rb_ca_is_complex_type (VALUE self)
|
|
395
|
+
rb_ca_is_complex_type (volatile VALUE self)
|
|
422
396
|
{
|
|
423
397
|
CArray *ca;
|
|
424
|
-
|
|
398
|
+
GetCArray(self, ca);
|
|
425
399
|
return ca_is_complex_type(ca) ? Qtrue : Qfalse;
|
|
426
400
|
}
|
|
427
401
|
|
|
@@ -435,10 +409,10 @@ ca_is_object_type (void *ap)
|
|
|
435
409
|
}
|
|
436
410
|
|
|
437
411
|
VALUE
|
|
438
|
-
rb_ca_is_object_type (VALUE self)
|
|
412
|
+
rb_ca_is_object_type (volatile VALUE self)
|
|
439
413
|
{
|
|
440
414
|
CArray *ca;
|
|
441
|
-
|
|
415
|
+
GetCArray(self, ca);
|
|
442
416
|
return ca_is_object_type(ca) ? Qtrue : Qfalse;
|
|
443
417
|
}
|
|
444
418
|
|
|
@@ -537,17 +511,20 @@ ca_note_view_of_lent (CArray *p)
|
|
|
537
511
|
}
|
|
538
512
|
|
|
539
513
|
VALUE
|
|
540
|
-
rb_ca_set_parent (VALUE self, VALUE obj)
|
|
514
|
+
rb_ca_set_parent (volatile VALUE self, volatile VALUE obj)
|
|
541
515
|
{
|
|
542
516
|
rb_ivar_set(self, id_parent, obj);
|
|
543
517
|
/* A view of an array lent to a CAObject hook outlives the hook: tell the
|
|
544
518
|
array, so that it keeps its cells when the hook returns. A view of
|
|
545
519
|
several arrays names one here and holds the rest in parents[]. */
|
|
546
520
|
if ( rb_obj_is_carray(obj) ) {
|
|
547
|
-
|
|
521
|
+
CArray *cp;
|
|
522
|
+
GetCArray(obj, cp);
|
|
523
|
+
ca_note_view_of_lent(cp);
|
|
548
524
|
}
|
|
549
525
|
if ( rb_obj_is_carray(self) ) {
|
|
550
|
-
CArray *ca
|
|
526
|
+
CArray *ca;
|
|
527
|
+
GetCArray(self, ca);
|
|
551
528
|
if ( ca_test_flag(ca, CA_FLAG_MULTI_PARENTS) ) {
|
|
552
529
|
CAMultiParent *mp = (CAMultiParent *) ca;
|
|
553
530
|
int32_t k;
|
|
@@ -562,10 +539,10 @@ rb_ca_set_parent (VALUE self, VALUE obj)
|
|
|
562
539
|
/* ------------------------------------------------------------------- */
|
|
563
540
|
|
|
564
541
|
VALUE
|
|
565
|
-
rb_ca_data_class (VALUE self)
|
|
542
|
+
rb_ca_data_class (volatile VALUE self)
|
|
566
543
|
{
|
|
567
544
|
CArray *ca;
|
|
568
|
-
|
|
545
|
+
GetCArray(self, ca);
|
|
569
546
|
/* Only a Face carries data_class; a non-Face CArray is always
|
|
570
547
|
Qnil. CARecord stores it in its tail (reached directly via
|
|
571
548
|
obj_type, no Ruby roundtrip); numeric Faces such as
|
|
@@ -607,6 +584,7 @@ CArray *
|
|
|
607
584
|
ca_root_array (void *ap)
|
|
608
585
|
{
|
|
609
586
|
CArray *ca = (CArray *)ap;
|
|
587
|
+
ca_check_stack_room();
|
|
610
588
|
if ( ca_is_entity(ca) ) {
|
|
611
589
|
return ca;
|
|
612
590
|
}
|
|
@@ -638,6 +616,7 @@ ca_shares_root (void *ap, void *aq)
|
|
|
638
616
|
{
|
|
639
617
|
CArray *ra = ca_root_array(ap);
|
|
640
618
|
CArray *rb = ca_root_array(aq);
|
|
619
|
+
ca_check_stack_room();
|
|
641
620
|
if ( ra == rb ) {
|
|
642
621
|
return 1;
|
|
643
622
|
}
|
|
@@ -665,21 +644,22 @@ ca_shares_root (void *ap, void *aq)
|
|
|
665
644
|
/* Whether self and other may share memory (ca_shares_root), for the plan
|
|
666
645
|
reader that keeps an evaluator off a store reading what it writes. */
|
|
667
646
|
static VALUE
|
|
668
|
-
rb_ca_storage_overlaps (VALUE self, VALUE other)
|
|
647
|
+
rb_ca_storage_overlaps (volatile VALUE self, volatile VALUE other)
|
|
669
648
|
{
|
|
670
649
|
CArray *ca, *cb;
|
|
671
650
|
rb_check_carray_object(other);
|
|
672
|
-
|
|
673
|
-
|
|
651
|
+
GetCArray(self, ca);
|
|
652
|
+
GetCArray(other, cb);
|
|
674
653
|
return ca_shares_root(ca, cb) ? Qtrue : Qfalse;
|
|
675
654
|
}
|
|
676
655
|
|
|
677
656
|
static VALUE
|
|
678
|
-
rb_ca_root_array (VALUE self)
|
|
657
|
+
rb_ca_root_array (volatile VALUE self)
|
|
679
658
|
{
|
|
680
659
|
volatile VALUE refary;
|
|
681
660
|
CArray *ca;
|
|
682
|
-
|
|
661
|
+
ca_check_stack_room();
|
|
662
|
+
GetCArray(self, ca);
|
|
683
663
|
if ( ca_is_entity(ca) ) {
|
|
684
664
|
return self;
|
|
685
665
|
}
|
|
@@ -700,11 +680,12 @@ rb_ca_root_array (VALUE self)
|
|
|
700
680
|
/* ------------------------------------------------------------------- */
|
|
701
681
|
|
|
702
682
|
static VALUE
|
|
703
|
-
rb_ca_ancestors_loop (VALUE self, VALUE list)
|
|
683
|
+
rb_ca_ancestors_loop (volatile VALUE self, VALUE list)
|
|
704
684
|
{
|
|
705
685
|
volatile VALUE refary;
|
|
706
686
|
CArray *ca;
|
|
707
|
-
|
|
687
|
+
ca_check_stack_room();
|
|
688
|
+
GetCArray(self, ca);
|
|
708
689
|
rb_ary_unshift(list, self);
|
|
709
690
|
if ( ca_is_entity(ca) ) {
|
|
710
691
|
return list;
|
|
@@ -748,17 +729,13 @@ Init_carray_attribute (void)
|
|
|
748
729
|
rb_define_method(rb_cCArray, "ndim", rb_ca_ndim, 0);
|
|
749
730
|
rb_define_method(rb_cCArray, "shape", rb_ca_dim, 0);
|
|
750
731
|
rb_define_method(rb_cCArray, "dim", rb_ca_dim, 0);
|
|
751
|
-
rb_define_method(rb_cCArray, "dim0", rb_ca_dim0, 0);
|
|
752
|
-
rb_define_method(rb_cCArray, "dim1", rb_ca_dim1, 0);
|
|
753
|
-
rb_define_method(rb_cCArray, "dim2", rb_ca_dim2, 0);
|
|
754
|
-
rb_define_method(rb_cCArray, "dim3", rb_ca_dim3, 0);
|
|
755
732
|
rb_define_method(rb_cCArray, "elements", rb_ca_elements, 0);
|
|
756
733
|
rb_define_method(rb_cCArray, "length", rb_ca_elements, 0);
|
|
757
734
|
rb_define_method(rb_cCArray, "size", rb_ca_elements, 0);
|
|
758
735
|
|
|
759
736
|
rb_define_method(rb_cCArray, "data_type_name", rb_ca_data_type_name, 0);
|
|
760
737
|
|
|
761
|
-
rb_define_method(rb_cCArray, "parent",
|
|
738
|
+
rb_define_method(rb_cCArray, "parent", rb_ca_parent_method, 0);
|
|
762
739
|
rb_define_private_method(rb_cCArray, "attribute_parent", rb_ca_attribute_parent, 0);
|
|
763
740
|
|
|
764
741
|
rb_define_method(rb_cCArray, "data_class", rb_ca_data_class, 0);
|
|
@@ -767,7 +744,7 @@ Init_carray_attribute (void)
|
|
|
767
744
|
rb_define_method(rb_cCArray, "scalar?", rb_ca_is_scalar, 0);
|
|
768
745
|
|
|
769
746
|
rb_define_method(rb_cCArray, "entity?", rb_ca_is_entity, 0);
|
|
770
|
-
rb_define_method(rb_cCArray, "
|
|
747
|
+
rb_define_method(rb_cCArray, "view?", rb_ca_is_virtual, 0);
|
|
771
748
|
rb_define_method(rb_cCArray, "value_array?", rb_ca_is_value_array, 0);
|
|
772
749
|
rb_define_method(rb_cCArray, "mask_array?", rb_ca_is_mask_array, 0);
|
|
773
750
|
rb_define_method(rb_cCArray, "face?", rb_ca_is_face, 0);
|
data/ext/carray_bincount.c
CHANGED
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
kernels __bincount_count__(length) and
|
|
25
25
|
__bincount_weighted__(weights, length).
|
|
26
26
|
|
|
27
|
-
Design: devel/PROPOSAL_BINCOUNT_DEDICATED_KERNEL.md.
|
|
28
|
-
|
|
29
27
|
--------------------------------------------------------------------------- */
|
|
30
28
|
|
|
31
29
|
#include "carray.h"
|
|
@@ -72,7 +70,7 @@
|
|
|
72
70
|
} \
|
|
73
71
|
} while (0)
|
|
74
72
|
|
|
75
|
-
/* Checked before
|
|
73
|
+
/* Checked before anything is attached: the dispatches above raise on a type
|
|
76
74
|
they do not cover, which would leave the labels (and weights) attached. */
|
|
77
75
|
static void
|
|
78
76
|
bincount_check_types (CArray *cl, CArray *cw)
|
|
@@ -105,16 +103,16 @@ bincount_check_types (CArray *cl, CArray *cw)
|
|
|
105
103
|
self. Allocates a zero-filled UInt32 (or UInt64 if length >= 2^32)
|
|
106
104
|
output of size `length`, then runs the 8-way label dispatch. */
|
|
107
105
|
static VALUE
|
|
108
|
-
rb_ca_bincount_count_kernel (VALUE self, VALUE rlength)
|
|
106
|
+
rb_ca_bincount_count_kernel (volatile VALUE self, VALUE rlength)
|
|
109
107
|
{
|
|
110
108
|
CArray *cl, *co;
|
|
111
|
-
VALUE
|
|
109
|
+
volatile VALUE vout;
|
|
112
110
|
ca_size_t i, n, length;
|
|
113
111
|
ca_size_t shape_out[1];
|
|
114
112
|
boolean8_t *mlabel;
|
|
115
113
|
int out_type;
|
|
116
114
|
|
|
117
|
-
|
|
115
|
+
GetCArray(self, cl);
|
|
118
116
|
length = (ca_size_t) NUM2SIZET(rlength);
|
|
119
117
|
if ( length < 0 ) {
|
|
120
118
|
rb_raise(rb_eArgError, "bincount: length must be non-negative");
|
|
@@ -124,7 +122,7 @@ rb_ca_bincount_count_kernel (VALUE self, VALUE rlength)
|
|
|
124
122
|
out_type = (length > 0xFFFFFFFFLL) ? CA_UINT64 : CA_UINT32;
|
|
125
123
|
shape_out[0] = length;
|
|
126
124
|
vout = rb_carray_new(out_type, 1, shape_out, 0, NULL);
|
|
127
|
-
|
|
125
|
+
GetCArray(vout, co);
|
|
128
126
|
|
|
129
127
|
/* Zero-fill output (we own it, just allocated). */
|
|
130
128
|
memset(co->ptr, 0, (size_t) co->bytes * (size_t) co->elements);
|
|
@@ -134,7 +132,7 @@ rb_ca_bincount_count_kernel (VALUE self, VALUE rlength)
|
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
bincount_check_types(cl, NULL);
|
|
137
|
-
ca_attach(cl); /*
|
|
135
|
+
ca_attach(cl); /* attach: nothing raises before the detach */
|
|
138
136
|
n = cl->elements;
|
|
139
137
|
mlabel = cl->mask ? (boolean8_t *) cl->mask->ptr : NULL;
|
|
140
138
|
|
|
@@ -211,17 +209,17 @@ rb_ca_bincount_count_kernel (VALUE self, VALUE rlength)
|
|
|
211
209
|
(integer + float; the inner WEIGHTED_KERNEL macro branches over the
|
|
212
210
|
four mask combinations). */
|
|
213
211
|
static VALUE
|
|
214
|
-
rb_ca_bincount_weighted_kernel (VALUE self, VALUE rweights, VALUE rlength)
|
|
212
|
+
rb_ca_bincount_weighted_kernel (volatile VALUE self, volatile VALUE rweights, VALUE rlength)
|
|
215
213
|
{
|
|
216
214
|
CArray *cl, *cw, *co;
|
|
217
|
-
VALUE
|
|
215
|
+
volatile VALUE vout;
|
|
218
216
|
ca_size_t i, n, length;
|
|
219
217
|
ca_size_t shape_out[1];
|
|
220
218
|
boolean8_t *mlabel, *mweight;
|
|
221
219
|
int w_type;
|
|
222
220
|
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
GetCArray(self, cl);
|
|
222
|
+
GetCArray(rweights, cw);
|
|
225
223
|
length = (ca_size_t) NUM2SIZET(rlength);
|
|
226
224
|
if ( length < 0 ) {
|
|
227
225
|
rb_raise(rb_eArgError, "bincount: length must be non-negative");
|
|
@@ -235,7 +233,7 @@ rb_ca_bincount_weighted_kernel (VALUE self, VALUE rweights, VALUE rlength)
|
|
|
235
233
|
w_type = cw->data_type;
|
|
236
234
|
shape_out[0] = length;
|
|
237
235
|
vout = rb_carray_new(w_type, 1, shape_out, 0, NULL);
|
|
238
|
-
|
|
236
|
+
GetCArray(vout, co);
|
|
239
237
|
|
|
240
238
|
memset(co->ptr, 0, (size_t) co->bytes * (size_t) co->elements);
|
|
241
239
|
|
|
@@ -244,7 +242,7 @@ rb_ca_bincount_weighted_kernel (VALUE self, VALUE rweights, VALUE rlength)
|
|
|
244
242
|
}
|
|
245
243
|
|
|
246
244
|
bincount_check_types(cl, cw);
|
|
247
|
-
ca_attach_n(2, cl, cw); /*
|
|
245
|
+
ca_attach_n(2, cl, cw); /* attach: nothing raises before the detach */
|
|
248
246
|
n = cl->elements;
|
|
249
247
|
mlabel = cl->mask ? (boolean8_t *) cl->mask->ptr : NULL;
|
|
250
248
|
mweight = cw->mask ? (boolean8_t *) cw->mask->ptr : NULL;
|