carray 3.0.7 → 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 -1940
- data/README.md +38 -32
- 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 +6 -9
- data/ext/ca_bincmp_dispatch.h +16 -38
- data/ext/ca_binop_dispatch.c +27 -0
- data/ext/ca_binop_dispatch.h +22 -47
- 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 -1506
- 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 +90 -163
- data/ext/ca_obj_bincmp.c +47 -46
- data/ext/ca_obj_binop.c +38 -38
- data/ext/ca_obj_bitarray.c +5 -17
- data/ext/ca_obj_bitfield.c +15 -30
- data/ext/ca_obj_block.c +11 -12
- data/ext/ca_obj_byte_swap.c +32 -30
- data/ext/ca_obj_const_string.c +57 -62
- data/ext/ca_obj_face.c +99 -91
- data/ext/ca_obj_face.h +32 -170
- data/ext/ca_obj_fake.c +15 -21
- data/ext/ca_obj_farray.c +7 -9
- data/ext/ca_obj_field.c +17 -13
- data/ext/ca_obj_fixlen_string.c +8 -19
- data/ext/ca_obj_grid.c +137 -106
- data/ext/ca_obj_meld.c +23 -21
- data/ext/ca_obj_moncmp.c +10 -21
- data/ext/ca_obj_monop.c +24 -35
- data/ext/ca_obj_object.c +51 -37
- data/ext/ca_obj_record.c +74 -22
- data/ext/ca_obj_reduce.c +8 -10
- data/ext/ca_obj_refer.c +42 -29
- data/ext/ca_obj_remap.c +11 -29
- data/ext/ca_obj_repeat.c +41 -23
- data/ext/ca_obj_roll.c +18 -24
- data/ext/ca_obj_select.c +10 -22
- data/ext/ca_obj_select_axis.c +27 -36
- data/ext/ca_obj_shift.c +22 -42
- data/ext/ca_obj_source.c +1 -5
- data/ext/ca_obj_stack.c +28 -24
- data/ext/ca_obj_stride.c +53 -54
- data/ext/ca_obj_string.c +6 -18
- data/ext/ca_obj_tile.c +12 -12
- 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 +35 -39
- data/ext/ca_obj_window.c +67 -86
- data/ext/ca_op_cmplx64.h +4 -0
- data/ext/ca_op_ipower.c +34 -12
- data/ext/ca_op_powi.h +4 -0
- 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 +20 -26
- data/ext/ca_sweep_engine.c +2 -3
- data/ext/ca_sweep_engine.h +17 -9
- data/ext/ca_transform_common.c +3 -8
- data/ext/ca_triop_dispatch.h +20 -32
- data/ext/caframe_csv_reader.c +11 -11
- data/ext/carray.h +300 -1011
- data/ext/carray_access.c +234 -180
- data/ext/carray_address_basis.c +33 -38
- data/ext/carray_attribute.c +81 -104
- data/ext/carray_bincount.c +12 -14
- data/ext/carray_broadcast.c +30 -26
- data/ext/carray_call_cfunc.c +169 -277
- data/ext/carray_call_cfunc.h +36 -28
- data/ext/carray_cast.c +912 -346
- data/ext/carray_cast_func.rb +31 -3
- data/ext/carray_class.c +6 -11
- data/ext/carray_conversion.c +43 -38
- data/ext/carray_copy.c +28 -26
- data/ext/carray_core.c +217 -126
- data/ext/carray_count.c +27 -15
- data/ext/carray_element.c +40 -25
- data/ext/carray_factorize.c +53 -52
- data/ext/carray_generate.c +26 -19
- data/ext/carray_histogram.c +8 -10
- data/ext/carray_hold.c +7 -9
- data/ext/carray_index_classifier.c +123 -228
- data/ext/carray_index_classifier.h +11 -10
- data/ext/carray_integer_total.c +523 -0
- data/ext/carray_internal.h +1274 -160
- data/ext/carray_key_windows.c +3 -3
- data/ext/carray_lazy.c +21 -36
- data/ext/carray_loop.c +19 -22
- data/ext/carray_mask.c +123 -145
- data/ext/carray_math_kernel.h +23 -47
- data/ext/carray_mathfunc.c +10 -3
- data/ext/carray_median_percentile.c +95 -94
- data/ext/carray_memory_view.c +42 -47
- data/ext/carray_operator.c +423 -122
- data/ext/carray_order.c +121 -85
- data/ext/carray_partition.c +13 -15
- data/ext/carray_random.c +47 -41
- data/ext/carray_round.c +9 -4
- data/ext/carray_scatter.c +54 -40
- data/ext/carray_segment.c +41 -45
- data/ext/carray_slab.c +64 -47
- data/ext/carray_slab.h +44 -33
- data/ext/carray_sort.c +32 -29
- data/ext/carray_sort_kernel.c +12 -10
- data/ext/carray_struct.c +38 -43
- data/ext/carray_test.c +47 -43
- data/ext/carray_time_text.c +24 -31
- data/ext/carray_undef.c +50 -7
- data/ext/carray_utils.c +258 -94
- data/ext/extconf.rb +24 -17
- data/ext/mk_call_cfunc.rb +19 -20
- data/ext/mk_pow5_table.rb +2 -1
- data/ext/mkkernel.rb +782 -461
- 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 +264 -180
- data/lib/carray/basics.rb +272 -48
- data/lib/carray/bincount_nd.rb +33 -16
- data/lib/carray/block_iterator.rb +123 -102
- data/lib/carray/boolean_reduce.rb +7 -4
- data/lib/carray/categorical.rb +63 -51
- data/lib/carray/categorical_iterator.rb +89 -67
- data/lib/carray/complex.rb +61 -41
- data/lib/carray/conditional.rb +49 -22
- data/lib/carray/const_string.rb +54 -62
- data/lib/carray/core_extensions.rb +1 -1
- data/lib/carray/distance_limit.rb +7 -5
- data/lib/carray/factories.rb +269 -0
- data/lib/carray/fixlen_string.rb +25 -24
- data/lib/carray/frame/column_verbs.rb +20 -8
- data/lib/carray/frame/concat.rb +3 -3
- data/lib/carray/frame/convert.rb +2 -1
- data/lib/carray/frame/csv_parser.rb +7 -1
- data/lib/carray/frame/frame.rb +35 -25
- data/lib/carray/frame/group.rb +183 -150
- data/lib/carray/frame/io.rb +26 -7
- data/lib/carray/frame/join.rb +37 -12
- data/lib/carray/frame/records.rb +1 -1
- data/lib/carray/frame/reshape.rb +3 -3
- data/lib/carray/frame/sort.rb +10 -8
- data/lib/carray/frame/verbs.rb +148 -118
- data/lib/carray/frame/windows.rb +232 -21
- data/lib/carray/frame.rb +1 -2
- data/lib/carray/fuse_source.rb +24 -21
- 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 +97 -24
- data/lib/carray/key_windows.rb +83 -57
- data/lib/carray/lazy.rb +196 -94
- 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 +5 -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 +72 -71
- data/lib/carray/methods/{index.rb → coordinate.rb} +13 -13
- data/lib/carray/methods/discovery_along.rb +3 -3
- data/lib/carray/methods/gather_nd.rb +106 -106
- 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 +165 -145
- data/lib/carray/methods/join.rb +2 -1
- data/lib/carray/methods/lag.rb +6 -2
- data/lib/carray/methods/locate_addr.rb +150 -138
- 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 +12 -12
- 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 +18 -17
- data/lib/carray/rng.rb +1 -0
- data/lib/carray/runtime.rb +190 -22
- data/lib/carray/segment_iterator.rb +251 -129
- data/lib/carray/serialize.rb +618 -571
- data/lib/carray/slab_iterator.rb +114 -114
- data/lib/carray/stack.rb +11 -12
- data/lib/carray/string.rb +16 -22
- data/lib/carray/string_operation_extension.rb +76 -52
- data/lib/carray/struct.rb +122 -164
- data/lib/carray/struct_builder.rb +243 -72
- data/lib/carray/time.rb +496 -342
- data/lib/carray/window_iterator.rb +191 -150
- 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 +4 -3
- 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 +7 -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 +26 -15
- data/yard-stubs/carray_access.rb +51 -4
- data/yard-stubs/carray_attribute.rb +26 -38
- data/yard-stubs/carray_cast.rb +118 -165
- 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 +5 -3
- 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 +157 -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 +67 -34
- 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 +10 -2
- data/yard-stubs/carray_slab.rb +7 -4
- data/yard-stubs/carray_sort.rb +7 -6
- data/yard-stubs/carray_undef.rb +44 -5
- data/yard-stubs/ruby_carray.rb +75 -40
- metadata +62 -24
- 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 -25337
- 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 -262
- data/lib/carray/data_type_limits.rb +0 -91
data/ext/ca_obj_window.c
CHANGED
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
#include "carray.h"
|
|
31
31
|
#include "ca_composite_dispatch.h"
|
|
32
32
|
#include "ca_obj_face.h" /* CA_FACE_LIFT_IF_FACE, used by rb_ca_window */
|
|
33
|
-
#include "carray_internal.h" /* ca_axis_view_attach_owned */
|
|
34
33
|
|
|
35
34
|
/* should not be static variable as used by CAIteratorWindow */
|
|
36
35
|
|
|
@@ -114,7 +113,7 @@ const rb_data_type_t cawindow_data_type = {
|
|
|
114
113
|
double-free it. */
|
|
115
114
|
const rb_data_type_t cawindow_mask_data_type = {
|
|
116
115
|
.parent = &cawindow_data_type,
|
|
117
|
-
.wrap_struct_name = "
|
|
116
|
+
.wrap_struct_name = "CAWindow::Mask",
|
|
118
117
|
.function = {
|
|
119
118
|
.dmark = ca_mark,
|
|
120
119
|
.dfree = ca_free_nop,
|
|
@@ -124,7 +123,7 @@ const rb_data_type_t cawindow_mask_data_type = {
|
|
|
124
123
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
125
124
|
};
|
|
126
125
|
|
|
127
|
-
|
|
126
|
+
int16_t CA_OBJ_WINDOW;
|
|
128
127
|
|
|
129
128
|
VALUE rb_cCAWindow;
|
|
130
129
|
VALUE rb_cCAWindowMask;
|
|
@@ -333,6 +332,7 @@ static void ca_window_func_xfer_index (void *ap, ca_size_t *idx, void *data, int
|
|
|
333
332
|
transposed / sub-sampled leaf) fall back to per-cell delivery (correct,
|
|
334
333
|
no whole-view attach). data is contiguous (semantics b). The wiring
|
|
335
334
|
guards ndim == window ndim. window.bytes == parent.bytes (no reinterpret). */
|
|
335
|
+
/* recursion: re-enters at most once, once the parent is attached */
|
|
336
336
|
static void
|
|
337
337
|
ca_window_func_xfer_stride (void *ap, ca_size_t *starts, ca_size_t *counts,
|
|
338
338
|
ca_size_t *strides, void *data, int dir)
|
|
@@ -419,9 +419,11 @@ ca_window_func_xfer_stride (void *ap, ca_size_t *starts, ca_size_t *counts,
|
|
|
419
419
|
if ( parent->ptr ) {
|
|
420
420
|
ca_window_func_xfer_stride(ap, starts, counts, strides, data, dir);
|
|
421
421
|
if ( dir == CA_XFER_PUT ) {
|
|
422
|
-
|
|
422
|
+
ca_sync_detach(parent);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
ca_detach(parent);
|
|
423
426
|
}
|
|
424
|
-
ca_detach(parent);
|
|
425
427
|
return;
|
|
426
428
|
}
|
|
427
429
|
ca_detach(parent);
|
|
@@ -1273,9 +1275,11 @@ ca_window_func_xfer_all (void *ap, void *data, int dir)
|
|
|
1273
1275
|
ca_attach(ca->parent);
|
|
1274
1276
|
ca_window_func_run_fast_path(ca, (char *) data, dir);
|
|
1275
1277
|
if ( dir == CA_XFER_PUT ) {
|
|
1276
|
-
|
|
1278
|
+
ca_sync_detach(ca->parent);
|
|
1279
|
+
}
|
|
1280
|
+
else {
|
|
1281
|
+
ca_detach(ca->parent);
|
|
1277
1282
|
}
|
|
1278
|
-
ca_detach(ca->parent);
|
|
1279
1283
|
return;
|
|
1280
1284
|
}
|
|
1281
1285
|
/* Second chance: ca_attach_is_alias reads the leaf view's own strides, so
|
|
@@ -1355,6 +1359,7 @@ ca_window_func_xfer_all (void *ap, void *data, int dir)
|
|
|
1355
1359
|
fill_data, which continues compose-fold (covering
|
|
1356
1360
|
CAStride-of-CAWindow-of-CAStride chains) and runs the merge + tight-fill
|
|
1357
1361
|
inner loop. PERIODIC / REFLECT windows fall through to the engine path. */
|
|
1362
|
+
/* recursion: fills a stride view over the root, an entity */
|
|
1358
1363
|
static void
|
|
1359
1364
|
ca_window_func_fill_data (void *ap, void *ptr)
|
|
1360
1365
|
{
|
|
@@ -1488,8 +1493,8 @@ ca_window_func_create_mask (void *ap)
|
|
|
1488
1493
|
m->obj_type = ca->obj_type;
|
|
1489
1494
|
m->mask_owner = (CArray *) ca;
|
|
1490
1495
|
if ( pmask == ca->mask_standin ) {
|
|
1491
|
-
/* writes
|
|
1492
|
-
sync, where they can give way to the parent's mask */
|
|
1496
|
+
/* writes made while this view is attached reach the stand-in
|
|
1497
|
+
through the sync, where they can give way to the parent's mask */
|
|
1493
1498
|
m->embed_alias_eligible = 0;
|
|
1494
1499
|
}
|
|
1495
1500
|
ca->mask = (CArray *) m;
|
|
@@ -1622,7 +1627,7 @@ ca_window_describe_axes (void *ap, ca_axis_desc_t *out,
|
|
|
1622
1627
|
/* ------------------------------------------------------------------- */
|
|
1623
1628
|
|
|
1624
1629
|
VALUE
|
|
1625
|
-
rb_ca_window_new (VALUE cary,
|
|
1630
|
+
rb_ca_window_new (volatile VALUE cary,
|
|
1626
1631
|
ca_size_t *start, ca_size_t *count, int8_t bounds, char *fill)
|
|
1627
1632
|
{
|
|
1628
1633
|
/* Scalar-bounds wrapper for the Ruby surface: fan the single policy out
|
|
@@ -1633,7 +1638,7 @@ rb_ca_window_new (VALUE cary,
|
|
|
1633
1638
|
uint8_t bounds_arr[CA_RANK_MAX];
|
|
1634
1639
|
int8_t i;
|
|
1635
1640
|
rb_check_carray_object(cary);
|
|
1636
|
-
|
|
1641
|
+
GetCArray(cary, parent);
|
|
1637
1642
|
for (i = 0; i < parent->ndim; i++) bounds_arr[i] = (uint8_t) bounds;
|
|
1638
1643
|
ca = ca_window_new(parent, start, count, bounds_arr, fill);
|
|
1639
1644
|
obj = ca_wrap_struct(ca);
|
|
@@ -1642,9 +1647,12 @@ rb_ca_window_new (VALUE cary,
|
|
|
1642
1647
|
}
|
|
1643
1648
|
|
|
1644
1649
|
VALUE
|
|
1645
|
-
rb_ca_window (int argc, VALUE *argv, VALUE self)
|
|
1650
|
+
rb_ca_window (int argc, VALUE *argv, volatile VALUE self)
|
|
1646
1651
|
{
|
|
1647
|
-
volatile VALUE obj, ropt
|
|
1652
|
+
volatile VALUE obj, ropt;
|
|
1653
|
+
VALUE rfval = CA_UNSPECIFIED;
|
|
1654
|
+
VALUE rbounds_arg = Qnil;
|
|
1655
|
+
volatile VALUE rbounds, rcs;
|
|
1648
1656
|
CArray *ca;
|
|
1649
1657
|
CScalar *cs;
|
|
1650
1658
|
ca_size_t start[CA_RANK_MAX];
|
|
@@ -1654,10 +1662,11 @@ rb_ca_window (int argc, VALUE *argv, VALUE self)
|
|
|
1654
1662
|
char *cbounds;
|
|
1655
1663
|
ca_size_t i;
|
|
1656
1664
|
|
|
1657
|
-
|
|
1665
|
+
GetCArray(self, ca);
|
|
1658
1666
|
|
|
1659
1667
|
ropt = rb_pop_options(&argc, &argv);
|
|
1660
|
-
rb_scan_options(ropt, "bounds,fill_value", &
|
|
1668
|
+
rb_scan_options(ropt, "bounds,fill_value", &rbounds_arg, &rfval);
|
|
1669
|
+
rbounds = rbounds_arg;
|
|
1661
1670
|
|
|
1662
1671
|
if ( argc != ca->ndim ) {
|
|
1663
1672
|
rb_raise(rb_eArgError, "ndim mismatch");
|
|
@@ -1699,17 +1708,13 @@ rb_ca_window (int argc, VALUE *argv, VALUE self)
|
|
|
1699
1708
|
}
|
|
1700
1709
|
|
|
1701
1710
|
if ( ! NIL_P(rbounds) ) {
|
|
1702
|
-
/* A Symbol
|
|
1703
|
-
|
|
1704
|
-
of one policy do not diverge. */
|
|
1705
|
-
if ( SYMBOL_P(rbounds) ) {
|
|
1706
|
-
rbounds = rb_sym2str(rbounds);
|
|
1707
|
-
}
|
|
1708
|
-
if ( ! RB_TYPE_P(rbounds, T_STRING) ) {
|
|
1711
|
+
/* A Symbol, as CArray#windows takes its bounds:. */
|
|
1712
|
+
if ( ! SYMBOL_P(rbounds) ) {
|
|
1709
1713
|
rb_raise(rb_eTypeError,
|
|
1710
|
-
"window: bounds: must be a Symbol
|
|
1711
|
-
|
|
1714
|
+
"window: bounds: must be a Symbol (got %"PRIsVALUE")",
|
|
1715
|
+
rb_inspect(rbounds));
|
|
1712
1716
|
}
|
|
1717
|
+
rbounds = rb_sym2str(rbounds);
|
|
1713
1718
|
cbounds = StringValueCStr(rbounds);
|
|
1714
1719
|
if ( ! strcmp(cbounds, "ruby") ) {
|
|
1715
1720
|
bounds = CA_BOUNDS_RUBY;
|
|
@@ -1720,28 +1725,14 @@ rb_ca_window (int argc, VALUE *argv, VALUE self)
|
|
|
1720
1725
|
else if ( ! strcmp(cbounds, "nearest") ) {
|
|
1721
1726
|
bounds = CA_BOUNDS_NEAREST;
|
|
1722
1727
|
}
|
|
1723
|
-
else if ( ! strcmp(cbounds, "periodic") ) {
|
|
1724
|
-
rb_raise(rb_eArgError,
|
|
1725
|
-
"bounds=>'periodic' removed in 3.0; "
|
|
1726
|
-
"use CArray#roll(...) for cyclic shift "
|
|
1727
|
-
"(returns a CARoll view)");
|
|
1728
|
-
}
|
|
1729
|
-
else if ( ! strcmp(cbounds, "reflect") ) {
|
|
1730
|
-
rb_raise(rb_eArgError,
|
|
1731
|
-
"bounds=>'reflect' removed in 3.0; "
|
|
1732
|
-
"there is no view-based alternative");
|
|
1733
|
-
}
|
|
1734
|
-
else if ( ! strcmp(cbounds, "mask") ) {
|
|
1735
|
-
rb_warn("CAWindow option :bounds=>\"mask\" will be obsolete");
|
|
1736
|
-
rb_warn("use ca.window(..., fill_value: UNDEF)");
|
|
1737
|
-
bounds = CA_BOUNDS_MASK;
|
|
1738
|
-
}
|
|
1739
1728
|
else if ( ! strcmp(cbounds, "fill") ) {
|
|
1740
1729
|
bounds = ( rfval == CA_UNDEF ) ? CA_BOUNDS_MASK : CA_BOUNDS_FILL;
|
|
1741
1730
|
}
|
|
1742
1731
|
else {
|
|
1743
1732
|
rb_raise(rb_eArgError,
|
|
1744
|
-
"window: unknown bounds: '%s'
|
|
1733
|
+
"window: unknown bounds: '%s' (use :fill, :nearest, :ruby "
|
|
1734
|
+
"or :strict; to mask the cells outside, use fill_value: UNDEF)",
|
|
1735
|
+
cbounds);
|
|
1745
1736
|
}
|
|
1746
1737
|
/* A fill value says what the cells outside the array are; the other
|
|
1747
1738
|
policies say something else about them. */
|
|
@@ -1750,12 +1741,6 @@ rb_ca_window (int argc, VALUE *argv, VALUE self)
|
|
|
1750
1741
|
rb_raise(rb_eArgError,
|
|
1751
1742
|
"window: fill_value: is for bounds: :fill, not :%s", cbounds);
|
|
1752
1743
|
}
|
|
1753
|
-
if ( rfval != CA_UNSPECIFIED && rfval != CA_UNDEF
|
|
1754
|
-
&& bounds == CA_BOUNDS_MASK ) {
|
|
1755
|
-
rb_raise(rb_eArgError,
|
|
1756
|
-
"window: fill_value: %+"PRIsVALUE" conflicts with bounds: :mask "
|
|
1757
|
-
"(use fill_value: UNDEF to mask the cells outside)", rfval);
|
|
1758
|
-
}
|
|
1759
1744
|
}
|
|
1760
1745
|
|
|
1761
1746
|
obj = rb_ca_window_new(self, start, count, bounds, fill);
|
|
@@ -1774,7 +1759,7 @@ rb_ca_window_s_allocate (VALUE klass)
|
|
|
1774
1759
|
}
|
|
1775
1760
|
|
|
1776
1761
|
static VALUE
|
|
1777
|
-
rb_ca_window_initialize_copy (VALUE self, VALUE other)
|
|
1762
|
+
rb_ca_window_initialize_copy (volatile VALUE self, volatile VALUE other)
|
|
1778
1763
|
{
|
|
1779
1764
|
CAWindow *ca, *cs;
|
|
1780
1765
|
|
|
@@ -1798,13 +1783,14 @@ rb_ca_window_initialize_copy (VALUE self, VALUE other)
|
|
|
1798
1783
|
}
|
|
1799
1784
|
|
|
1800
1785
|
static VALUE
|
|
1801
|
-
rb_ca_window_idx2addr0 (int argc, VALUE *argv, VALUE self)
|
|
1786
|
+
rb_ca_window_idx2addr0 (int argc, VALUE *argv, volatile VALUE self)
|
|
1802
1787
|
{
|
|
1803
1788
|
CAWindow *cw;
|
|
1804
1789
|
ca_size_t addr;
|
|
1805
1790
|
int8_t i;
|
|
1806
1791
|
ca_size_t idxi;
|
|
1807
1792
|
|
|
1793
|
+
rb_reject_options(rb_pop_options(&argc, &argv));
|
|
1808
1794
|
TypedData_Get_Struct(self, CAWindow, &cawindow_data_type, cw);
|
|
1809
1795
|
|
|
1810
1796
|
if ( argc != cw->ndim ) {
|
|
@@ -1828,7 +1814,7 @@ rb_ca_window_idx2addr0 (int argc, VALUE *argv, VALUE self)
|
|
|
1828
1814
|
}
|
|
1829
1815
|
|
|
1830
1816
|
static VALUE
|
|
1831
|
-
rb_ca_window_addr2addr0 (VALUE self, VALUE raddr)
|
|
1817
|
+
rb_ca_window_addr2addr0 (volatile VALUE self, VALUE raddr)
|
|
1832
1818
|
{
|
|
1833
1819
|
CAWindow *cw;
|
|
1834
1820
|
ca_size_t addr = NUM2SIZE(raddr);
|
|
@@ -1854,69 +1840,66 @@ rb_ca_window_addr2addr0 (VALUE self, VALUE raddr)
|
|
|
1854
1840
|
|
|
1855
1841
|
|
|
1856
1842
|
static VALUE
|
|
1857
|
-
|
|
1843
|
+
rb_ca_window_get_fill_value (volatile VALUE self)
|
|
1858
1844
|
{
|
|
1859
1845
|
CAWindow *cw;
|
|
1860
1846
|
TypedData_Get_Struct(self, CAWindow, &cawindow_data_type, cw);
|
|
1861
|
-
|
|
1862
|
-
return Qnil;
|
|
1847
|
+
return rb_ca_ptr2obj(self, cw->fill);
|
|
1863
1848
|
}
|
|
1864
1849
|
|
|
1850
|
+
/* The name of a boundary rule, as CArray#window takes it. */
|
|
1865
1851
|
static VALUE
|
|
1866
|
-
|
|
1852
|
+
ca_window_bounds_symbol (int8_t bounds)
|
|
1867
1853
|
{
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1854
|
+
const char *name;
|
|
1855
|
+
switch ( bounds ) {
|
|
1856
|
+
case CA_BOUNDS_RUBY: name = "ruby"; break;
|
|
1857
|
+
case CA_BOUNDS_STRICT: name = "strict"; break;
|
|
1858
|
+
case CA_BOUNDS_NEAREST: name = "nearest"; break;
|
|
1859
|
+
case CA_BOUNDS_PERIODIC: name = "periodic"; break;
|
|
1860
|
+
case CA_BOUNDS_REFLECT: name = "reflect"; break;
|
|
1861
|
+
case CA_BOUNDS_FILL: name = "fill"; break;
|
|
1862
|
+
case CA_BOUNDS_MASK: name = "mask"; break;
|
|
1863
|
+
default: name = "unknown"; break;
|
|
1864
|
+
}
|
|
1865
|
+
return ID2SYM(rb_intern(name));
|
|
1871
1866
|
}
|
|
1872
1867
|
|
|
1873
1868
|
static VALUE
|
|
1874
|
-
rb_ca_window_get_bounds (VALUE self)
|
|
1869
|
+
rb_ca_window_get_bounds (volatile VALUE self)
|
|
1875
1870
|
{
|
|
1876
|
-
/* bounds is per-axis, but
|
|
1877
|
-
|
|
1878
|
-
that was passed in. */
|
|
1871
|
+
/* bounds is per-axis, but CArray#window fans one rule out across all
|
|
1872
|
+
axes, so axis 0 reproduces the rule that was passed in. */
|
|
1879
1873
|
CAWindow *cw;
|
|
1880
1874
|
TypedData_Get_Struct(self, CAWindow, &cawindow_data_type, cw);
|
|
1881
|
-
return
|
|
1875
|
+
return ca_window_bounds_symbol(cw->bounds[0]);
|
|
1882
1876
|
}
|
|
1883
1877
|
|
|
1884
1878
|
/* The boundary rule on each axis, one Symbol per axis. `bounds` answers
|
|
1885
1879
|
for axis 0 only, which is all CArray#window sets; a shift with `roll:`
|
|
1886
1880
|
on some axes sets them one by one. */
|
|
1887
1881
|
static VALUE
|
|
1888
|
-
rb_ca_window_axis_bounds (VALUE self)
|
|
1882
|
+
rb_ca_window_axis_bounds (volatile VALUE self)
|
|
1889
1883
|
{
|
|
1890
1884
|
volatile VALUE ary;
|
|
1891
1885
|
CAWindow *cw;
|
|
1892
|
-
const char *name;
|
|
1893
1886
|
int8_t i;
|
|
1894
1887
|
TypedData_Get_Struct(self, CAWindow, &cawindow_data_type, cw);
|
|
1895
|
-
ary =
|
|
1888
|
+
ary = rb_ary_new_capa(cw->ndim);
|
|
1896
1889
|
for (i=0; i<cw->ndim; i++) {
|
|
1897
|
-
|
|
1898
|
-
case CA_BOUNDS_RUBY: name = "ruby"; break;
|
|
1899
|
-
case CA_BOUNDS_STRICT: name = "strict"; break;
|
|
1900
|
-
case CA_BOUNDS_NEAREST: name = "nearest"; break;
|
|
1901
|
-
case CA_BOUNDS_PERIODIC: name = "periodic"; break;
|
|
1902
|
-
case CA_BOUNDS_REFLECT: name = "reflect"; break;
|
|
1903
|
-
case CA_BOUNDS_FILL: name = "fill"; break;
|
|
1904
|
-
case CA_BOUNDS_MASK: name = "mask"; break;
|
|
1905
|
-
default: name = "unknown"; break;
|
|
1906
|
-
}
|
|
1907
|
-
rb_ary_store(ary, i, ID2SYM(rb_intern(name)));
|
|
1890
|
+
rb_ary_store(ary, i, ca_window_bounds_symbol(cw->bounds[i]));
|
|
1908
1891
|
}
|
|
1909
1892
|
return ary;
|
|
1910
1893
|
}
|
|
1911
1894
|
|
|
1912
1895
|
#define rb_cw_get_attr_ary(name) \
|
|
1913
|
-
rb_cw_## name (VALUE self)
|
|
1896
|
+
rb_cw_## name (volatile VALUE self) \
|
|
1914
1897
|
{ \
|
|
1915
1898
|
volatile VALUE ary; \
|
|
1916
1899
|
CAWindow *cw; \
|
|
1917
1900
|
int8_t i; \
|
|
1918
1901
|
TypedData_Get_Struct(self, CAWindow, &cawindow_data_type, cw); \
|
|
1919
|
-
ary =
|
|
1902
|
+
ary = rb_ary_new_capa(cw->ndim); \
|
|
1920
1903
|
for (i=0; i<cw->ndim; i++) { \
|
|
1921
1904
|
rb_ary_store(ary, i, SIZE2NUM(cw->name[i])); \
|
|
1922
1905
|
} \
|
|
@@ -1935,15 +1918,15 @@ static VALUE rb_cw_get_attr_ary(size0);
|
|
|
1935
1918
|
`extconf.rb --enable-dev-build` or `CARRAY_DEV=1 rake build_ext`.
|
|
1936
1919
|
|
|
1937
1920
|
Polymorphic over CAWindow / CAShift: both share the same C struct layout
|
|
1938
|
-
(CAShift is a typedef of CAWindow)
|
|
1939
|
-
|
|
1940
|
-
self to one of those two classes. */
|
|
1921
|
+
(CAShift is a typedef of CAWindow), and the data type of CAShift has the
|
|
1922
|
+
data type of CAWindow as parent, so the get below accepts both. */
|
|
1941
1923
|
VALUE
|
|
1942
|
-
rb_ca_window_embed_descriptor (VALUE self)
|
|
1924
|
+
rb_ca_window_embed_descriptor (volatile VALUE self)
|
|
1943
1925
|
{
|
|
1944
|
-
CAWindow *ca
|
|
1926
|
+
CAWindow *ca;
|
|
1945
1927
|
VALUE hash, ps_ary, ec_ary, oo_ary;
|
|
1946
1928
|
int8_t k;
|
|
1929
|
+
TypedData_Get_Struct(self, CAWindow, &cawindow_data_type, ca);
|
|
1947
1930
|
|
|
1948
1931
|
ps_ary = rb_ary_new_capa(ca->ndim);
|
|
1949
1932
|
ec_ary = rb_ary_new_capa(ca->ndim);
|
|
@@ -1975,7 +1958,7 @@ Init_ca_obj_window (void)
|
|
|
1975
1958
|
{
|
|
1976
1959
|
|
|
1977
1960
|
rb_cCAWindow = rb_define_class("CAWindow", rb_cCAView);
|
|
1978
|
-
rb_cCAWindowMask =
|
|
1961
|
+
rb_cCAWindowMask = rb_define_class_under(rb_cCAWindow, "Mask", rb_cCAWindow);
|
|
1979
1962
|
|
|
1980
1963
|
/* Pool framework: seven ndim-sized tail fields live in one _pool buffer
|
|
1981
1964
|
(fill stays separate, bytes-sized). Set on the global ca_window_func
|
|
@@ -1990,7 +1973,6 @@ Init_ca_obj_window (void)
|
|
|
1990
1973
|
rb_cCAWindowMask,
|
|
1991
1974
|
&cawindow_mask_data_type, &ca_window_func, sizeof(ca_window_func));
|
|
1992
1975
|
ca_register_cell_moving_view(CA_OBJ_WINDOW);
|
|
1993
|
-
rb_define_const(rb_cObject, "CA_OBJ_WINDOW", INT2NUM(CA_OBJ_WINDOW));
|
|
1994
1976
|
|
|
1995
1977
|
rb_define_method(rb_cCArray, "window", rb_ca_window, -1);
|
|
1996
1978
|
|
|
@@ -2003,7 +1985,6 @@ Init_ca_obj_window (void)
|
|
|
2003
1985
|
rb_define_method(rb_cCAWindow, "addr2addr0", rb_ca_window_addr2addr0, 1);
|
|
2004
1986
|
|
|
2005
1987
|
rb_define_method(rb_cCAWindow, "fill_value", rb_ca_window_get_fill_value, 0);
|
|
2006
|
-
rb_define_method(rb_cCAWindow, "fill_value=", rb_ca_window_set_fill_value, 1);
|
|
2007
1988
|
|
|
2008
1989
|
rb_define_method(rb_cCAWindow, "bounds", rb_ca_window_get_bounds, 0);
|
|
2009
1990
|
|
data/ext/ca_op_cmplx64.h
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
ca_op_cmplx64.h -- the cmplx64 products and quotients, computed in
|
|
4
4
|
double and rounded once
|
|
5
5
|
|
|
6
|
+
This header is internal to carray and carries no contract. It is not
|
|
7
|
+
installed; it ships in the gem's ext/ directory only because carray is
|
|
8
|
+
built from it there.
|
|
9
|
+
|
|
6
10
|
Used by:
|
|
7
11
|
- ext/carray_kernels_binop.c and ext/carray_kernels_monop.c
|
|
8
12
|
(generated from ext/mkkernel.rb): the `*`, `/`, `rcp` and
|
data/ext/ca_op_ipower.c
CHANGED
|
@@ -216,8 +216,8 @@ ca_ipower_cmplx128_t (ca_size_t n, boolean8_t *m,
|
|
|
216
216
|
while (n--) { (*p2) = ca_ipow_cmplx128_t(*p1, ipow); p1++; p2++; }
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
/* The data types the ipower kernels cover; checked before
|
|
220
|
-
|
|
219
|
+
/* The data types the ipower kernels cover; checked before anything is
|
|
220
|
+
attached, so the switches inside cannot fall through to a raise. */
|
|
221
221
|
static int
|
|
222
222
|
ca_ipower_type_ok (CArray *ca)
|
|
223
223
|
{
|
|
@@ -239,7 +239,7 @@ ca_ipower_type_ok (CArray *ca)
|
|
|
239
239
|
* mask attach). Called by rb_ca_pow when the fast-path predicate
|
|
240
240
|
* matches. */
|
|
241
241
|
static VALUE
|
|
242
|
-
rb_ca_ipower (VALUE self, VALUE other)
|
|
242
|
+
rb_ca_ipower (volatile VALUE self, VALUE other)
|
|
243
243
|
{
|
|
244
244
|
volatile VALUE obj;
|
|
245
245
|
CArray *ca, *co;
|
|
@@ -248,7 +248,7 @@ rb_ca_ipower (VALUE self, VALUE other)
|
|
|
248
248
|
|
|
249
249
|
ipow = NUM2LL(other);
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
GetCArray(self, ca);
|
|
252
252
|
|
|
253
253
|
if ( ! ca_ipower_type_ok(ca) ) {
|
|
254
254
|
rb_raise(rb_eCADataTypeError, "invalid data type for ipower");
|
|
@@ -261,7 +261,7 @@ rb_ca_ipower (VALUE self, VALUE other)
|
|
|
261
261
|
m = ( co->mask ) ? (boolean8_t *)co->mask->ptr : NULL;
|
|
262
262
|
|
|
263
263
|
if ( ca_attach_is_alias(ca) ) {
|
|
264
|
-
ca_attach(ca); /*
|
|
264
|
+
ca_attach(ca); /* attach: nothing raises before the detach */
|
|
265
265
|
switch ( ca->data_type ) {
|
|
266
266
|
case CA_FLOAT32:
|
|
267
267
|
ca_ipower_float32_t(ca->elements, m, ca->ptr, ipow, co->ptr); break;
|
|
@@ -297,21 +297,23 @@ rb_ca_ipower (VALUE self, VALUE other)
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
static VALUE
|
|
300
|
-
rb_ca_ipower_bang (VALUE self, VALUE other)
|
|
300
|
+
rb_ca_ipower_bang (volatile VALUE self, VALUE other)
|
|
301
301
|
{
|
|
302
302
|
CArray *ca;
|
|
303
303
|
int64_t ipow;
|
|
304
304
|
boolean8_t *m;
|
|
305
305
|
|
|
306
|
+
rb_ca_modify(self);
|
|
307
|
+
|
|
306
308
|
ipow = NUM2LL(other);
|
|
307
309
|
|
|
308
|
-
|
|
310
|
+
GetCArray(self, ca);
|
|
309
311
|
|
|
310
312
|
if ( ! ca_ipower_type_ok(ca) ) {
|
|
311
313
|
rb_raise(rb_eRuntimeError, "invalid data type for ipower");
|
|
312
314
|
}
|
|
313
315
|
|
|
314
|
-
ca_attach(ca); /*
|
|
316
|
+
ca_attach(ca); /* attach: nothing raises before ca_sync_detach */
|
|
315
317
|
|
|
316
318
|
m = ( ca->mask ) ? (boolean8_t *)ca->mask->ptr : NULL;
|
|
317
319
|
|
|
@@ -331,16 +333,33 @@ rb_ca_ipower_bang (VALUE self, VALUE other)
|
|
|
331
333
|
return self;
|
|
332
334
|
}
|
|
333
335
|
|
|
336
|
+
/* An Integer exponent beyond int64 is taken as a Float: the power is then
|
|
337
|
+
* 0, 1, an infinity or NaN, as for the same exponent written as a Float.
|
|
338
|
+
* Within int64 it stays an Integer for the ipower kernels. */
|
|
339
|
+
static VALUE
|
|
340
|
+
ca_pow_wide_exponent (VALUE other)
|
|
341
|
+
{
|
|
342
|
+
if ( RB_TYPE_P(other, T_BIGNUM) &&
|
|
343
|
+
( RTEST(rb_funcall(other, rb_intern(">"), 1, LL2NUM(INT64_MAX))) ||
|
|
344
|
+
RTEST(rb_funcall(other, rb_intern("<"), 1, LL2NUM(INT64_MIN))) ) ) {
|
|
345
|
+
return DBL2NUM(rb_big2dbl(other));
|
|
346
|
+
}
|
|
347
|
+
return other;
|
|
348
|
+
}
|
|
349
|
+
|
|
334
350
|
/* CArray#pow(other) (alias `**`) — Float/Complex ** Integer takes the
|
|
335
351
|
* ipower fast path in this file; everything else falls through to the
|
|
336
352
|
* mkkernel-generated general pow/cpow (rb_ca_power in
|
|
337
353
|
* ext/carray_kernels.c). */
|
|
338
|
-
static VALUE rb_ca_pow (VALUE self, VALUE other)
|
|
354
|
+
static VALUE rb_ca_pow (volatile VALUE self, VALUE other)
|
|
339
355
|
{
|
|
340
356
|
volatile VALUE obj;
|
|
341
357
|
CArray *ca;
|
|
342
358
|
|
|
343
|
-
|
|
359
|
+
GetCArray(self, ca);
|
|
360
|
+
if ( ca_is_float_type(ca) || ca_is_complex_type(ca) ) {
|
|
361
|
+
other = ca_pow_wide_exponent(other);
|
|
362
|
+
}
|
|
344
363
|
if ( ( ca_is_float_type(ca) || ca_is_complex_type(ca) ) &&
|
|
345
364
|
rb_obj_is_kind_of(other, rb_cInteger) ) {
|
|
346
365
|
return rb_ca_ipower(self, other);
|
|
@@ -354,10 +373,13 @@ static VALUE rb_ca_pow (VALUE self, VALUE other)
|
|
|
354
373
|
/* CArray#pow!(other) — in-place variant of #pow. Dispatch mirrors
|
|
355
374
|
* rb_ca_pow (fast path for Float/Complex ** Integer, otherwise
|
|
356
375
|
* general rb_ca_power_bang). */
|
|
357
|
-
static VALUE rb_ca_pow_bang (VALUE self, VALUE other)
|
|
376
|
+
static VALUE rb_ca_pow_bang (volatile VALUE self, VALUE other)
|
|
358
377
|
{
|
|
359
378
|
CArray *ca;
|
|
360
|
-
|
|
379
|
+
GetCArray(self, ca);
|
|
380
|
+
if ( ca_is_float_type(ca) || ca_is_complex_type(ca) ) {
|
|
381
|
+
other = ca_pow_wide_exponent(other);
|
|
382
|
+
}
|
|
361
383
|
if ( ( ca_is_float_type(ca) || ca_is_complex_type(ca) ) &&
|
|
362
384
|
rb_obj_is_kind_of(other, rb_cInteger) ) {
|
|
363
385
|
return rb_ca_ipower_bang(self, other);
|
data/ext/ca_op_powi.h
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
ca_op_powi.h -- `op_powi_<type>`, an integer to an integer power
|
|
4
4
|
|
|
5
|
+
This header is internal to carray and carries no contract. It is not
|
|
6
|
+
installed; it ships in the gem's ext/ directory only because carray is
|
|
7
|
+
built from it there.
|
|
8
|
+
|
|
5
9
|
The `power` binop kernel's integer variants (generated from
|
|
6
10
|
ext/mkkernel.rb) call `op_powi_<type>`, binary exponentiation in the
|
|
7
11
|
integer type. A float or complex base goes through pow / cpow
|
data/ext/ca_pow5_table.h
CHANGED
data/ext/ca_rng_normal.h
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
ca_rng_normal.h -- uniform to standard normal, as text
|
|
4
4
|
|
|
5
|
+
As a header this file is internal to carray and carries no contract; it
|
|
6
|
+
is not installed. Its text is handed out through
|
|
7
|
+
CArray::Rng::COMMON_SOURCE.
|
|
8
|
+
|
|
5
9
|
Read the two ways ca_rng_xoshiro256pp.h is read: compiled into this
|
|
6
10
|
extension, and handed out through CArray::Rng::COMMON_SOURCE for
|
|
7
11
|
another gem to paste. The same rules apply -- no include guard,
|
data/ext/ca_rng_xoshiro256pp.h
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
ca_rng_xoshiro256pp.h -- the xoshiro256++ generator, as text
|
|
4
4
|
|
|
5
|
+
As a header this file is internal to carray and carries no contract; it
|
|
6
|
+
is not installed. Its text is handed out through CArray::Rng::SOURCE.
|
|
7
|
+
|
|
5
8
|
This file is not a header in the usual sense. It carries no include
|
|
6
9
|
guard and includes nothing, because it is read two ways:
|
|
7
10
|
|
data/ext/ca_sort_kernels.h
CHANGED
|
@@ -2,38 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
ca_sort_kernels.h
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This header is internal to carray and carries no contract. It is not
|
|
6
|
+
installed, and carray.h does not include it: the sources that use it
|
|
7
|
+
(carray_sort_kernel.c, carray_sort.c, carray_partition.c,
|
|
8
|
+
ca_categorical_iterator.c and the generated carray_kernels_*.c)
|
|
9
|
+
include it themselves.
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
(i8 / u8 / i16 / u16 / i32 / u32 / i64 / u64 / f32 / f64)
|
|
9
|
-
P.3 : NaN pre-partition for f32 / f64
|
|
10
|
-
P.4 : pair (value + index) variants for argsort kernels —
|
|
11
|
-
sort_index / sort_addr / partition_index family
|
|
12
|
-
P.9 : value-level quickselect for partition_copy
|
|
11
|
+
Portable sort kernels:
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
typedefs from carray.h — when this header is included from carray.h
|
|
21
|
-
mid-file, those typedefs are already in scope by the time we reach
|
|
22
|
-
the include site.
|
|
13
|
+
- quicksort and mergesort over the 10 numeric data types
|
|
14
|
+
(i8 / u8 / i16 / u16 / i32 / u32 / i64 / u64 / f32 / f64)
|
|
15
|
+
- NaN pre-partition for f32 / f64
|
|
16
|
+
- pair (value + index) variants for the sort_index / sort_addr /
|
|
17
|
+
partition_index family
|
|
18
|
+
- value-level quickselect for partition_copy
|
|
23
19
|
|
|
24
20
|
--------------------------------------------------------------------------- */
|
|
25
21
|
|
|
26
22
|
#ifndef CA_SORT_KERNELS_H
|
|
27
23
|
#define CA_SORT_KERNELS_H 1
|
|
28
24
|
|
|
29
|
-
/* Needs int8_t .. uint64_t / float32_t / double / ca_size_t
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Guard-protected, so the re-entry is a no-op when carray.h is already in
|
|
33
|
-
flight. */
|
|
25
|
+
/* Needs int8_t .. uint64_t / float32_t / double / ca_size_t, so this
|
|
26
|
+
header includes carray.h itself. carray.h has an include guard, so the
|
|
27
|
+
include is a no-op when a source has already included it. */
|
|
34
28
|
#include "carray.h"
|
|
35
29
|
|
|
36
|
-
/*
|
|
30
|
+
/* Quicksort over 10 numeric data types. */
|
|
37
31
|
void ca_sort_quick_i8 (int8_t *a, ca_size_t n);
|
|
38
32
|
void ca_sort_quick_u8 (uint8_t *a, ca_size_t n);
|
|
39
33
|
void ca_sort_quick_i16 (int16_t *a, ca_size_t n);
|
|
@@ -45,7 +39,7 @@ void ca_sort_quick_u64 (uint64_t *a, ca_size_t n);
|
|
|
45
39
|
void ca_sort_quick_f32 (float32_t *a, ca_size_t n);
|
|
46
40
|
void ca_sort_quick_f64 (double *a, ca_size_t n);
|
|
47
41
|
|
|
48
|
-
/*
|
|
42
|
+
/* Mergesort over 10 numeric data types (`aux` is caller-supplied
|
|
49
43
|
scratch buffer of the same length / data type as `a`). */
|
|
50
44
|
void ca_sort_merge_i8 (int8_t *a, int8_t *aux, ca_size_t n);
|
|
51
45
|
void ca_sort_merge_u8 (uint8_t *a, uint8_t *aux, ca_size_t n);
|
|
@@ -58,7 +52,7 @@ void ca_sort_merge_u64 (uint64_t *a, uint64_t *aux, ca_size_t n);
|
|
|
58
52
|
void ca_sort_merge_f32 (float32_t *a, float32_t *aux, ca_size_t n);
|
|
59
53
|
void ca_sort_merge_f64 (double *a, double *aux, ca_size_t n);
|
|
60
54
|
|
|
61
|
-
/*
|
|
55
|
+
/* NaN pre-partition for float data types (Hoare 1-pass, returns finite count). */
|
|
62
56
|
ca_size_t ca_partition_nan_f32 (float32_t *a, ca_size_t n);
|
|
63
57
|
ca_size_t ca_partition_nan_f64 (double *a, ca_size_t n);
|
|
64
58
|
/* The same, keeping the order within both regions; scratch holds n values. */
|
|
@@ -74,7 +68,7 @@ ca_size_t ca_partition_nan_pair_f32 (struct ca_pair_f32 *a, ca_size_t n,
|
|
|
74
68
|
ca_size_t ca_partition_nan_pair_f64 (struct ca_pair_f64 *a, ca_size_t n,
|
|
75
69
|
struct ca_pair_f64 *scratch);
|
|
76
70
|
|
|
77
|
-
/*
|
|
71
|
+
/* Value-level quickselect for partition_copy.
|
|
78
72
|
Reorders a[0..n) so that a[kth] is exact + left/right regions
|
|
79
73
|
satisfy <= / >= contracts. Order within each region unspecified. */
|
|
80
74
|
void ca_partition_quick_i8 (int8_t *a, ca_size_t n, ca_size_t kth);
|
|
@@ -88,7 +82,7 @@ void ca_partition_quick_u64 (uint64_t *a, ca_size_t n, ca_size_t kth);
|
|
|
88
82
|
void ca_partition_quick_f32 (float32_t *a, ca_size_t n, ca_size_t kth);
|
|
89
83
|
void ca_partition_quick_f64 (double *a, ca_size_t n, ca_size_t kth);
|
|
90
84
|
|
|
91
|
-
/*
|
|
85
|
+
/* Pair sort kernels (sort_index / sort_addr). The pair
|
|
92
86
|
struct is opaque to mkkernel-emitted callers via void*; each kernel
|
|
93
87
|
has its own well-defined layout: { TYPE v; ca_size_t i; } with natural
|
|
94
88
|
alignment padding. */
|
data/ext/ca_sweep_engine.c
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
---------------------------------------------------------------------------- */
|
|
18
18
|
|
|
19
19
|
#include "carray.h"
|
|
20
|
-
#include "carray_internal.h" /* ca_lazy_arena_* */
|
|
21
20
|
#include "ca_sweep_engine.h"
|
|
22
21
|
#include "ca_for_buffer.h"
|
|
23
22
|
#include <string.h>
|
|
@@ -714,11 +713,11 @@ ca_with_buffer_body_trampoline (VALUE ctx_val)
|
|
|
714
713
|
}
|
|
715
714
|
|
|
716
715
|
void
|
|
717
|
-
rb_ca_call_with_buffer (VALUE r_ca, int writable,
|
|
716
|
+
rb_ca_call_with_buffer (volatile VALUE r_ca, int writable,
|
|
718
717
|
ca_with_buffer_body_fn body, void *user_data)
|
|
719
718
|
{
|
|
720
719
|
ca_with_buffer_ctx_t ctx;
|
|
721
|
-
|
|
720
|
+
GetCArray(r_ca, ctx.ca);
|
|
722
721
|
ctx.body_fn = body;
|
|
723
722
|
ctx.user_data = user_data;
|
|
724
723
|
ca_attach_window(1, &ctx.ca, writable ? "w" : "r",
|