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/carray_mask.c
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
#include <stdint.h>
|
|
12
12
|
#include "ruby.h"
|
|
13
13
|
#include "carray.h"
|
|
14
|
-
#include "carray_internal.h" /* ca_lazy_arena_* */
|
|
15
14
|
#include "ca_obj_face.h" /* CA_FACE_LIFT_IF_FACE for the mask-lift path */
|
|
16
15
|
#include <ruby/ractor.h>
|
|
17
16
|
|
|
@@ -299,6 +298,10 @@ ca_has_mask (void *ap)
|
|
|
299
298
|
{
|
|
300
299
|
CArray *ca = (CArray *) ap;
|
|
301
300
|
|
|
301
|
+
if ( ! ca->mask && ! ca_is_entity(ca) ) { /* an entity asks no parent */
|
|
302
|
+
ca_check_stack_room();
|
|
303
|
+
}
|
|
304
|
+
|
|
302
305
|
if ( ca->mask ) { /* mask array already created */
|
|
303
306
|
return 1;
|
|
304
307
|
}
|
|
@@ -371,7 +374,7 @@ ca_is_any_masked (void *ap)
|
|
|
371
374
|
non-zero word (the typical "all zero, no mask actually set" hot
|
|
372
375
|
pattern). An O(n) scan cache is not viable here: the mask is
|
|
373
376
|
dynamic and a view chain can introduce a mask mid-chain. */
|
|
374
|
-
ca_attach(ca->mask); /*
|
|
377
|
+
ca_attach(ca->mask); /* attach: nothing raises before the detach */
|
|
375
378
|
flag = ca_mask_word_any((boolean8_t *) ca->mask->ptr, ca->elements);
|
|
376
379
|
ca_detach(ca->mask);
|
|
377
380
|
}
|
|
@@ -398,7 +401,7 @@ ca_is_all_masked (void *ap)
|
|
|
398
401
|
/* cheap mask: O(1) alias attach + word-level all_set with early exit.
|
|
399
402
|
The word check uses (w == 0x0101...01ULL) under the {0,1}
|
|
400
403
|
invariant; returns on the first non-fully-set word. */
|
|
401
|
-
ca_attach(ca->mask); /*
|
|
404
|
+
ca_attach(ca->mask); /* attach: nothing raises before the detach */
|
|
402
405
|
flag = ca_mask_word_all_set((boolean8_t *) ca->mask->ptr, ca->elements);
|
|
403
406
|
ca_detach(ca->mask);
|
|
404
407
|
}
|
|
@@ -427,7 +430,7 @@ ca_view_func_create_mask (void *ap)
|
|
|
427
430
|
/* The sync slot of a view whose mask came from ca_view_func_create_mask
|
|
428
431
|
calls this after syncing its parent. The view's mask is a refer over
|
|
429
432
|
the parent's mask, and when the parent's mask is itself a view, both
|
|
430
|
-
hold a buffer while the
|
|
433
|
+
hold a buffer while the view is attached; the refer writes past the
|
|
431
434
|
parent's buffer to the root. Syncing the parent then writes its
|
|
432
435
|
buffer, from before the view's mask was written, back over the root,
|
|
433
436
|
so the view's mask is synced once more. */
|
|
@@ -477,7 +480,7 @@ ca_update_mask (void *ap)
|
|
|
477
480
|
static VALUE
|
|
478
481
|
ca_create_mask_attach (VALUE arg)
|
|
479
482
|
{
|
|
480
|
-
ca_attach((CArray *) arg); /*
|
|
483
|
+
ca_attach((CArray *) arg); /* attach: released by the view's detach */
|
|
481
484
|
return Qnil;
|
|
482
485
|
}
|
|
483
486
|
|
|
@@ -515,7 +518,7 @@ ca_mask_standin_current (CArray *mask_view, CArray *reading, CArray *parent,
|
|
|
515
518
|
if ( standin == NULL || reading != standin ) {
|
|
516
519
|
return reading;
|
|
517
520
|
}
|
|
518
|
-
/* Not
|
|
521
|
+
/* Not while an attach has published its buffer: that buffer and the
|
|
519
522
|
detach to come are those of the stand-in. The attach and allocate
|
|
520
523
|
slots run before the buffer is published, and may still give way. */
|
|
521
524
|
if ( CAVIEW(mask_view)->attach > 0 && mask_view->ptr != NULL ) {
|
|
@@ -550,10 +553,11 @@ ca_mask_buffer_holder (CArray *ca)
|
|
|
550
553
|
}
|
|
551
554
|
|
|
552
555
|
/* Marks the cells addrs of mask, the mask of a view at or below chain. The
|
|
553
|
-
write goes past any buffer an
|
|
554
|
-
and the sync that
|
|
556
|
+
write goes past any buffer an attached view holds on the way to the root,
|
|
557
|
+
and the sync before that view's detach sends the buffer: the cells this
|
|
555
558
|
write turned true are copied into it, read as the difference of two
|
|
556
|
-
gathers so that what
|
|
559
|
+
gathers so that what was written there meanwhile through the attached
|
|
560
|
+
view stays. */
|
|
557
561
|
static void
|
|
558
562
|
ca_mask_fill_past_buffers (CArray *mask, CArray *chain, ca_size_t m,
|
|
559
563
|
ca_size_t *addrs)
|
|
@@ -564,6 +568,7 @@ ca_mask_fill_past_buffers (CArray *mask, CArray *chain, ca_size_t m,
|
|
|
564
568
|
boolean8_t *before, *after, *z;
|
|
565
569
|
boolean8_t one = 1;
|
|
566
570
|
ca_size_t i, n;
|
|
571
|
+
ca_check_stack_room();
|
|
567
572
|
|
|
568
573
|
if ( owner == NULL ) {
|
|
569
574
|
ca_fill_addrs(mask, m, addrs, &one);
|
|
@@ -572,8 +577,8 @@ ca_mask_fill_past_buffers (CArray *mask, CArray *chain, ca_size_t m,
|
|
|
572
577
|
held = owner->mask;
|
|
573
578
|
n = held->elements;
|
|
574
579
|
/* A view answers from its buffer while it has one: the clone has none. */
|
|
575
|
-
|
|
576
|
-
reader
|
|
580
|
+
reader = ca_wrap_struct((CArray *) ca_clone(held));
|
|
581
|
+
GetCArray(reader, rd);
|
|
577
582
|
before = ALLOCV_N(boolean8_t, holder, 2 * n);
|
|
578
583
|
after = before + n;
|
|
579
584
|
ca_xfer_all(rd, before, CA_XFER_GET);
|
|
@@ -586,7 +591,6 @@ ca_mask_fill_past_buffers (CArray *mask, CArray *chain, ca_size_t m,
|
|
|
586
591
|
}
|
|
587
592
|
}
|
|
588
593
|
ALLOCV_END(holder);
|
|
589
|
-
RB_GC_GUARD(reader);
|
|
590
594
|
}
|
|
591
595
|
|
|
592
596
|
void
|
|
@@ -738,6 +742,7 @@ void
|
|
|
738
742
|
ca_create_mask (void *ap)
|
|
739
743
|
{
|
|
740
744
|
CArray *ca = (CArray *) ap;
|
|
745
|
+
ca_check_stack_room();
|
|
741
746
|
|
|
742
747
|
if ( ca->mask ) {
|
|
743
748
|
return;
|
|
@@ -846,7 +851,7 @@ ca_setup_mask (void *ap, CArray *mask)
|
|
|
846
851
|
/* The overlay reads each source's mask into the destination's. A
|
|
847
852
|
source's mask can be made or read by calling Ruby (a CAObject's mask
|
|
848
853
|
hooks) and raise, so every mask is made first and the lot are read
|
|
849
|
-
|
|
854
|
+
while they are all attached, through one ca_attach_window.
|
|
850
855
|
|
|
851
856
|
A source whose cells live in the destination's root has its mask read
|
|
852
857
|
into a snapshot before the destination's mask is made, cleared or
|
|
@@ -1085,7 +1090,7 @@ ca_count_masked (void *ap)
|
|
|
1085
1090
|
if ( ca->mask ) {
|
|
1086
1091
|
if ( ca_attach_is_alias(ca->mask) ) {
|
|
1087
1092
|
/* cheap mask: O(1) alias attach + word-bulk count. */
|
|
1088
|
-
ca_attach(ca->mask); /*
|
|
1093
|
+
ca_attach(ca->mask); /* attach: nothing raises before the detach */
|
|
1089
1094
|
m = (boolean8_t *) ca->mask->ptr;
|
|
1090
1095
|
count = ca_mask_word_count(m, ca->elements);
|
|
1091
1096
|
ca_detach(ca->mask);
|
|
@@ -1151,7 +1156,7 @@ ca_unmask (void *ap, char *fill_value)
|
|
|
1151
1156
|
ca_fill(ca->mask, &zero);
|
|
1152
1157
|
}
|
|
1153
1158
|
else {
|
|
1154
|
-
ca_attach(ca); /*
|
|
1159
|
+
ca_attach(ca); /* attach: nothing raises before the detach */
|
|
1155
1160
|
|
|
1156
1161
|
switch ( ca->bytes ) {
|
|
1157
1162
|
case 1: proc_fill_bang_width(uint8_t); break;
|
|
@@ -1213,22 +1218,6 @@ ca_unmask_copy (void *ap, char *fill_value)
|
|
|
1213
1218
|
return a.co;
|
|
1214
1219
|
}
|
|
1215
1220
|
|
|
1216
|
-
void
|
|
1217
|
-
ca_invert_mask (void *ap)
|
|
1218
|
-
{
|
|
1219
|
-
CArray *ca = (CArray *) ap;
|
|
1220
|
-
boolean8_t *m;
|
|
1221
|
-
|
|
1222
|
-
ca_create_mask(ca);
|
|
1223
|
-
|
|
1224
|
-
ca_attach(ca->mask); /* window: nothing raises inside */
|
|
1225
|
-
m = (boolean8_t *) ca->mask->ptr;
|
|
1226
|
-
ca_mask_word_not(m, m, ca->elements); /* in-place 1 - m, LSB-XOR word loop */
|
|
1227
|
-
ca_sync_detach(ca->mask);
|
|
1228
|
-
|
|
1229
|
-
return;
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
1221
|
boolean8_t *
|
|
1233
1222
|
ca_allocate_mask_iterator_n (int n, CArray **slist)
|
|
1234
1223
|
{
|
|
@@ -1289,7 +1278,7 @@ ca_allocate_mask_iterator_n (int n, CArray **slist)
|
|
|
1289
1278
|
masks[k] = cs->mask;
|
|
1290
1279
|
scalar[k++] = (char) ca_is_scalar(cs);
|
|
1291
1280
|
}
|
|
1292
|
-
ca_attach_all(masks, k); /*
|
|
1281
|
+
ca_attach_all(masks, k); /* attach: nothing raises before the detach */
|
|
1293
1282
|
|
|
1294
1283
|
m = xmalloc(sizeof(boolean8_t)*elements);
|
|
1295
1284
|
memset(m, 0, elements);
|
|
@@ -1346,10 +1335,10 @@ Returns true if self has the mask array.
|
|
|
1346
1335
|
*/
|
|
1347
1336
|
|
|
1348
1337
|
VALUE
|
|
1349
|
-
rb_ca_has_mask (VALUE self)
|
|
1338
|
+
rb_ca_has_mask (volatile VALUE self)
|
|
1350
1339
|
{
|
|
1351
1340
|
CArray *ca;
|
|
1352
|
-
|
|
1341
|
+
GetCArray(self, ca);
|
|
1353
1342
|
return ( ca_has_mask(ca) ) ? Qtrue : Qfalse;
|
|
1354
1343
|
}
|
|
1355
1344
|
|
|
@@ -1360,10 +1349,10 @@ Returns true if self has at least one masked element.
|
|
|
1360
1349
|
*/
|
|
1361
1350
|
|
|
1362
1351
|
VALUE
|
|
1363
|
-
rb_ca_is_any_masked (VALUE self)
|
|
1352
|
+
rb_ca_is_any_masked (volatile VALUE self)
|
|
1364
1353
|
{
|
|
1365
1354
|
CArray *ca;
|
|
1366
|
-
|
|
1355
|
+
GetCArray(self, ca);
|
|
1367
1356
|
return ( ca_is_any_masked(ca) ) ? Qtrue : Qfalse;
|
|
1368
1357
|
}
|
|
1369
1358
|
|
|
@@ -1374,10 +1363,10 @@ Returns true if all elements of self are masked.
|
|
|
1374
1363
|
*/
|
|
1375
1364
|
|
|
1376
1365
|
VALUE
|
|
1377
|
-
rb_ca_is_all_masked (VALUE self)
|
|
1366
|
+
rb_ca_is_all_masked (volatile VALUE self)
|
|
1378
1367
|
{
|
|
1379
1368
|
CArray *ca;
|
|
1380
|
-
|
|
1369
|
+
GetCArray(self, ca);
|
|
1381
1370
|
return ( ca_is_all_masked(ca) ) ? Qtrue : Qfalse;
|
|
1382
1371
|
}
|
|
1383
1372
|
|
|
@@ -1388,11 +1377,11 @@ Creates mask array internally (private method)
|
|
|
1388
1377
|
*/
|
|
1389
1378
|
|
|
1390
1379
|
static VALUE
|
|
1391
|
-
rb_ca_create_mask (VALUE self)
|
|
1380
|
+
rb_ca_create_mask (volatile VALUE self)
|
|
1392
1381
|
{
|
|
1393
1382
|
CArray *ca;
|
|
1394
1383
|
rb_ca_modify(self);
|
|
1395
|
-
|
|
1384
|
+
GetCArray(self, ca);
|
|
1396
1385
|
ca_create_mask(ca);
|
|
1397
1386
|
return Qnil;
|
|
1398
1387
|
}
|
|
@@ -1408,7 +1397,7 @@ static VALUE
|
|
|
1408
1397
|
rb_ca_update_mask (VALUE self)
|
|
1409
1398
|
{
|
|
1410
1399
|
CArray *ca;
|
|
1411
|
-
|
|
1400
|
+
GetCArray(self, ca);
|
|
1412
1401
|
ca_update_mask(ca);
|
|
1413
1402
|
return Qnil;
|
|
1414
1403
|
}
|
|
@@ -1423,16 +1412,16 @@ via the returned array. The value array can't be set mask.
|
|
|
1423
1412
|
*/
|
|
1424
1413
|
|
|
1425
1414
|
VALUE
|
|
1426
|
-
rb_ca_value_array (VALUE self)
|
|
1415
|
+
rb_ca_value_array (volatile VALUE self)
|
|
1427
1416
|
{
|
|
1428
|
-
VALUE obj;
|
|
1417
|
+
volatile VALUE obj;
|
|
1429
1418
|
CArray *ca, *co;
|
|
1430
1419
|
|
|
1431
|
-
|
|
1420
|
+
GetCArray(self, ca);
|
|
1432
1421
|
|
|
1433
1422
|
obj = rb_ca_refer_new(self, ca->data_type, ca->ndim, ca->dim, ca->bytes, 0);
|
|
1434
1423
|
|
|
1435
|
-
|
|
1424
|
+
GetCArray(obj, co);
|
|
1436
1425
|
|
|
1437
1426
|
/* Value arrays ignore the mask by definition. ca_stride_setup
|
|
1438
1427
|
auto-propagates the parent's mask into newly-built CAStride
|
|
@@ -1477,12 +1466,12 @@ The mask array can't be set mask.
|
|
|
1477
1466
|
*/
|
|
1478
1467
|
|
|
1479
1468
|
VALUE
|
|
1480
|
-
rb_ca_mask_array (VALUE self)
|
|
1469
|
+
rb_ca_mask_array (volatile VALUE self)
|
|
1481
1470
|
{
|
|
1482
1471
|
volatile VALUE obj;
|
|
1483
1472
|
CArray *ca;
|
|
1484
1473
|
|
|
1485
|
-
|
|
1474
|
+
GetCArray(self, ca);
|
|
1486
1475
|
|
|
1487
1476
|
ca_update_mask(ca);
|
|
1488
1477
|
if ( ca->mask ) {
|
|
@@ -1511,12 +1500,13 @@ rb_ca_mask_array (VALUE self)
|
|
|
1511
1500
|
rebuilt here from its own view instead. The mask of an entity is an
|
|
1512
1501
|
entity and is copied. */
|
|
1513
1502
|
static VALUE
|
|
1514
|
-
ca_mask_view_dup (VALUE self)
|
|
1503
|
+
ca_mask_view_dup (volatile VALUE self)
|
|
1515
1504
|
{
|
|
1516
1505
|
volatile VALUE obj;
|
|
1517
1506
|
const rb_data_type_t *type;
|
|
1518
1507
|
CArray *ca, *cp;
|
|
1519
|
-
|
|
1508
|
+
ca_check_stack_room();
|
|
1509
|
+
GetCArray(self, ca);
|
|
1520
1510
|
cp = (CArray *) ca_func[ca->obj_type].clone(ca);
|
|
1521
1511
|
ca_keep_chain_flags(cp, ca);
|
|
1522
1512
|
type = ca_typeddata[ca->obj_type];
|
|
@@ -1530,10 +1520,10 @@ ca_mask_view_dup (VALUE self)
|
|
|
1530
1520
|
}
|
|
1531
1521
|
|
|
1532
1522
|
static VALUE
|
|
1533
|
-
rb_ca_mask_dup (VALUE self)
|
|
1523
|
+
rb_ca_mask_dup (volatile VALUE self)
|
|
1534
1524
|
{
|
|
1535
1525
|
CArray *ca;
|
|
1536
|
-
|
|
1526
|
+
GetCArray(self, ca);
|
|
1537
1527
|
if ( ! ca_is_view(ca) ) {
|
|
1538
1528
|
return rb_call_super(0, NULL);
|
|
1539
1529
|
}
|
|
@@ -1541,26 +1531,18 @@ rb_ca_mask_dup (VALUE self)
|
|
|
1541
1531
|
}
|
|
1542
1532
|
|
|
1543
1533
|
static VALUE
|
|
1544
|
-
rb_ca_mask_clone (int argc, VALUE *argv, VALUE self)
|
|
1534
|
+
rb_ca_mask_clone (int argc, VALUE *argv, volatile VALUE self)
|
|
1545
1535
|
{
|
|
1546
1536
|
VALUE opts = Qnil, vfreeze = Qnil;
|
|
1547
1537
|
volatile VALUE obj;
|
|
1548
1538
|
CArray *ca;
|
|
1549
|
-
|
|
1539
|
+
GetCArray(self, ca);
|
|
1550
1540
|
if ( ! ca_is_view(ca) ) {
|
|
1551
1541
|
return rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS);
|
|
1552
1542
|
}
|
|
1553
1543
|
rb_scan_args(argc, argv, "0:", &opts);
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
ID kw[1];
|
|
1557
|
-
VALUE val[1];
|
|
1558
|
-
kw[0] = rb_intern("freeze");
|
|
1559
|
-
rb_get_kwargs(opts, kw, 0, 1, val);
|
|
1560
|
-
if ( val[0] != Qundef ) {
|
|
1561
|
-
vfreeze = val[0];
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1544
|
+
/* Any key but freeze: is refused, as Kernel#clone does. */
|
|
1545
|
+
rb_scan_options(opts, "freeze", &vfreeze);
|
|
1564
1546
|
obj = ca_mask_view_dup(self);
|
|
1565
1547
|
if ( RTEST(vfreeze) || ( NIL_P(vfreeze) && OBJ_FROZEN(self) ) ) {
|
|
1566
1548
|
rb_obj_freeze(obj);
|
|
@@ -1577,14 +1559,22 @@ before asignment.
|
|
|
1577
1559
|
*/
|
|
1578
1560
|
|
|
1579
1561
|
VALUE
|
|
1580
|
-
rb_ca_set_mask (VALUE self, VALUE rval)
|
|
1562
|
+
rb_ca_set_mask (volatile VALUE self, VALUE rval)
|
|
1581
1563
|
{
|
|
1582
1564
|
volatile VALUE rmask = rval;
|
|
1583
1565
|
CArray *ca, *cv;
|
|
1584
1566
|
|
|
1585
1567
|
rb_ca_modify(self);
|
|
1586
1568
|
|
|
1587
|
-
|
|
1569
|
+
/* Whoever writes mask = nil means to clear the mask, so the refusal
|
|
1570
|
+
says how to do that rather than how to mask a cell. */
|
|
1571
|
+
if ( NIL_P(rmask) ) {
|
|
1572
|
+
rb_raise(rb_eTypeError,
|
|
1573
|
+
"mask=: nil is not a mask; to clear the mask, "
|
|
1574
|
+
"assign false or call unmask");
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
GetCArray(self, ca);
|
|
1588
1578
|
|
|
1589
1579
|
if ( ca_is_value_array(ca) ) {
|
|
1590
1580
|
rb_raise(rb_eTypeError,
|
|
@@ -1615,7 +1605,7 @@ rb_ca_set_mask (VALUE self, VALUE rval)
|
|
|
1615
1605
|
it, is 1-D or squeezes to it, or broadcasts along size-1 axes.
|
|
1616
1606
|
Checked before the mask exists, so a refused one leaves none. */
|
|
1617
1607
|
ca_broadcast_to_destination(self, &rmask);
|
|
1618
|
-
|
|
1608
|
+
GetCArray(rmask, cv);
|
|
1619
1609
|
/* A new mask taken from self's own root, or from self's mask, is
|
|
1620
1610
|
read from a copy: making and writing self's mask would change it
|
|
1621
1611
|
before it is read. */
|
|
@@ -1623,7 +1613,7 @@ rb_ca_set_mask (VALUE self, VALUE rval)
|
|
|
1623
1613
|
if ( ca_shares_root(cv, ca) ||
|
|
1624
1614
|
( ca->mask && ca_shares_root(cv, ca->mask) ) ) {
|
|
1625
1615
|
rmask = rb_ca_copy(rmask);
|
|
1626
|
-
|
|
1616
|
+
GetCArray(rmask, cv);
|
|
1627
1617
|
}
|
|
1628
1618
|
if ( ! ca_is_boolean_type(cv) ) {
|
|
1629
1619
|
cv = ca_wrap_readonly(rmask, CA_BOOLEAN);
|
|
@@ -1648,7 +1638,7 @@ with <code>self</code>. The returned array has 1 for the masked elements and
|
|
|
1648
1638
|
*/
|
|
1649
1639
|
|
|
1650
1640
|
VALUE
|
|
1651
|
-
rb_ca_is_masked (VALUE self)
|
|
1641
|
+
rb_ca_is_masked (volatile VALUE self)
|
|
1652
1642
|
{
|
|
1653
1643
|
volatile VALUE out;
|
|
1654
1644
|
CArray *ca, *co;
|
|
@@ -1656,7 +1646,7 @@ rb_ca_is_masked (VALUE self)
|
|
|
1656
1646
|
boolean8_t *p;
|
|
1657
1647
|
ca_size_t i;
|
|
1658
1648
|
|
|
1659
|
-
|
|
1649
|
+
GetCArray(self, ca);
|
|
1660
1650
|
|
|
1661
1651
|
if ( ca_is_scalar(ca) ) {
|
|
1662
1652
|
co = (CArray *)cscalar_new(CA_BOOLEAN, ca->bytes, NULL);
|
|
@@ -1691,7 +1681,7 @@ The returned array has 0 for the masked elements and
|
|
|
1691
1681
|
*/
|
|
1692
1682
|
|
|
1693
1683
|
VALUE
|
|
1694
|
-
rb_ca_is_not_masked (VALUE self)
|
|
1684
|
+
rb_ca_is_not_masked (volatile VALUE self)
|
|
1695
1685
|
{
|
|
1696
1686
|
volatile VALUE out;
|
|
1697
1687
|
CArray *ca, *co;
|
|
@@ -1699,7 +1689,7 @@ rb_ca_is_not_masked (VALUE self)
|
|
|
1699
1689
|
boolean8_t *p;
|
|
1700
1690
|
ca_size_t i;
|
|
1701
1691
|
|
|
1702
|
-
|
|
1692
|
+
GetCArray(self, ca);
|
|
1703
1693
|
|
|
1704
1694
|
if ( ca_is_scalar(ca) ) {
|
|
1705
1695
|
co = (CArray *)cscalar_new(CA_BOOLEAN, ca->bytes, NULL);
|
|
@@ -1728,7 +1718,7 @@ rb_ca_is_not_masked (VALUE self)
|
|
|
1728
1718
|
VALUE
|
|
1729
1719
|
rb_ca_scan_mask_count (VALUE self, VALUE axis)
|
|
1730
1720
|
{
|
|
1731
|
-
VALUE present =
|
|
1721
|
+
VALUE present = rb_ca_is_not_masked(self);
|
|
1732
1722
|
VALUE count;
|
|
1733
1723
|
if ( NIL_P(axis) ) {
|
|
1734
1724
|
count = rb_funcall(present, rb_intern("cumsum"), 0);
|
|
@@ -1738,47 +1728,48 @@ rb_ca_scan_mask_count (VALUE self, VALUE axis)
|
|
|
1738
1728
|
rb_hash_aset(kw, ID2SYM(rb_intern("axis")), axis);
|
|
1739
1729
|
count = rb_funcallv_kw(present, rb_intern("cumsum"), 1, &kw, RB_PASS_KEYWORDS);
|
|
1740
1730
|
}
|
|
1741
|
-
|
|
1731
|
+
/* coerce: a fixed type, a count is int64 */
|
|
1732
|
+
return rb_ca_to_type(count, ID2SYM(ca_data_type_sym[CA_INT64]), Qnil);
|
|
1742
1733
|
}
|
|
1743
1734
|
|
|
1744
|
-
/* @overload unmask (fill_value
|
|
1735
|
+
/* @overload unmask (fill_value)
|
|
1745
1736
|
|
|
1746
1737
|
(Masking, Destructive)
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
the masked elements are filled by <code>fill_value</code>.
|
|
1750
|
-
The returned array doesn't have the mask array.
|
|
1738
|
+
Fills the masked elements with fill_value and clears their mask.
|
|
1739
|
+
A fill value is required; mask = false clears the mask without one.
|
|
1751
1740
|
*/
|
|
1752
1741
|
|
|
1753
1742
|
static VALUE
|
|
1754
|
-
rb_ca_unmask_method (int argc, VALUE *argv, VALUE self)
|
|
1743
|
+
rb_ca_unmask_method (int argc, VALUE *argv, volatile VALUE self)
|
|
1755
1744
|
{
|
|
1756
|
-
volatile VALUE rfval
|
|
1745
|
+
volatile VALUE rfval, rcs;
|
|
1757
1746
|
CArray *ca;
|
|
1758
1747
|
CScalar *cv;
|
|
1759
|
-
char *fval
|
|
1748
|
+
char *fval;
|
|
1760
1749
|
|
|
1761
1750
|
rb_ca_modify(self);
|
|
1762
1751
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1752
|
+
rb_check_arity(argc, 0, 1);
|
|
1753
|
+
if ( argc == 0 ) {
|
|
1754
|
+
rb_raise(rb_eArgError,
|
|
1755
|
+
"unmask: a fill value is required (or method:); "
|
|
1756
|
+
"to clear the mask without a value, assign mask = false");
|
|
1765
1757
|
}
|
|
1758
|
+
rfval = argv[0];
|
|
1766
1759
|
|
|
1767
1760
|
/* Filling with UNDEF leaves the cells undefined, as storing UNDEF does. */
|
|
1768
1761
|
if ( rfval == CA_UNDEF ) {
|
|
1769
1762
|
return self;
|
|
1770
1763
|
}
|
|
1771
1764
|
|
|
1772
|
-
|
|
1765
|
+
GetCArray(self, ca);
|
|
1773
1766
|
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
rb_ca_obj2ptr(self, rfval, fval);
|
|
1781
|
-
}
|
|
1767
|
+
/* The fill is a value of the array (a struct, an instant for a Face):
|
|
1768
|
+
rb_ca_obj2ptr writes it as one cell of the storage. */
|
|
1769
|
+
rcs = rb_cscalar_new(ca_strip_face(ca)->data_type, ca->bytes, NULL);
|
|
1770
|
+
TypedData_Get_Struct(rcs, CScalar, &cscalar_data_type, cv);
|
|
1771
|
+
fval = cv->ptr;
|
|
1772
|
+
rb_ca_obj2ptr(self, rfval, fval);
|
|
1782
1773
|
|
|
1783
1774
|
ca_unmask(ca, fval);
|
|
1784
1775
|
|
|
@@ -1787,10 +1778,17 @@ rb_ca_unmask_method (int argc, VALUE *argv, VALUE self)
|
|
|
1787
1778
|
|
|
1788
1779
|
/* api: rb_ca_unmask */
|
|
1789
1780
|
|
|
1781
|
+
/* Clears the mask without a value: the masked cells show whatever their
|
|
1782
|
+
storage holds. */
|
|
1783
|
+
|
|
1790
1784
|
VALUE
|
|
1791
|
-
rb_ca_unmask (VALUE self)
|
|
1785
|
+
rb_ca_unmask (volatile VALUE self)
|
|
1792
1786
|
{
|
|
1793
|
-
|
|
1787
|
+
CArray *ca;
|
|
1788
|
+
rb_ca_modify(self);
|
|
1789
|
+
GetCArray(self, ca);
|
|
1790
|
+
ca_unmask(ca, NULL);
|
|
1791
|
+
return self;
|
|
1794
1792
|
}
|
|
1795
1793
|
|
|
1796
1794
|
/* api: rb_ca_mask_fill */
|
|
@@ -1806,7 +1804,7 @@ rb_ca_mask_fill (VALUE self, VALUE fval)
|
|
|
1806
1804
|
surface is strip_mask). */
|
|
1807
1805
|
|
|
1808
1806
|
static VALUE
|
|
1809
|
-
rb_ca_unmask_copy_method (int argc, VALUE *argv, VALUE self)
|
|
1807
|
+
rb_ca_unmask_copy_method (int argc, VALUE *argv, volatile VALUE self)
|
|
1810
1808
|
{
|
|
1811
1809
|
volatile VALUE obj, rfval = CA_UNSPECIFIED, rcs;
|
|
1812
1810
|
CArray *ca, *co;
|
|
@@ -1823,7 +1821,7 @@ rb_ca_unmask_copy_method (int argc, VALUE *argv, VALUE self)
|
|
|
1823
1821
|
return rb_ca_copy(self);
|
|
1824
1822
|
}
|
|
1825
1823
|
|
|
1826
|
-
|
|
1824
|
+
GetCArray(self, ca);
|
|
1827
1825
|
|
|
1828
1826
|
if ( rfval != CA_UNSPECIFIED ) {
|
|
1829
1827
|
/* The fill is a value of the array (a struct, an instant for a Face):
|
|
@@ -1856,22 +1854,6 @@ rb_ca_mask_fill_copy (VALUE self, VALUE fval)
|
|
|
1856
1854
|
return rb_ca_unmask_copy_method(1, &fval, self);
|
|
1857
1855
|
}
|
|
1858
1856
|
|
|
1859
|
-
/* @overload invert_mask
|
|
1860
|
-
|
|
1861
|
-
(Masking, Destructive)
|
|
1862
|
-
Inverts mask state.
|
|
1863
|
-
*/
|
|
1864
|
-
|
|
1865
|
-
VALUE
|
|
1866
|
-
rb_ca_invert_mask (VALUE self)
|
|
1867
|
-
{
|
|
1868
|
-
CArray *ca;
|
|
1869
|
-
rb_ca_modify(self);
|
|
1870
|
-
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
1871
|
-
ca_invert_mask(ca);
|
|
1872
|
-
return self;
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
1857
|
/* guard_undef(*values, fill_value: UNDEF, &block) — class method.
|
|
1876
1858
|
Returns fill_value if any of values is UNDEF, otherwise yields values
|
|
1877
1859
|
to the block and returns its result.
|
|
@@ -1904,32 +1886,26 @@ rb_ca_s_guard_undef(int argc, VALUE *argv, VALUE klass)
|
|
|
1904
1886
|
key (`:eq, v`) is evaluated on the Face, where it compares values rather
|
|
1905
1887
|
than storage. */
|
|
1906
1888
|
static VALUE
|
|
1907
|
-
ca_mask_copy_where (VALUE self, int argc, VALUE *argv)
|
|
1889
|
+
ca_mask_copy_where (volatile VALUE self, int argc, VALUE *argv)
|
|
1908
1890
|
{
|
|
1909
1891
|
CArray *ca;
|
|
1910
1892
|
volatile VALUE obj;
|
|
1911
|
-
VALUE
|
|
1912
|
-
|
|
1893
|
+
VALUE sel; /* its address is taken, so it stays on the stack */
|
|
1894
|
+
GetCArray(self, ca);
|
|
1913
1895
|
if ( ca_is_face(ca) && ca_is_readonly(ca) ) {
|
|
1914
1896
|
obj = rb_ca_copy(rb_ca_strip_face_value(self));
|
|
1915
1897
|
if ( argc >= 1 && SYMBOL_P(argv[0]) ) {
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
rb_funcallv(obj, rb_intern("[]="), 2, all_args);
|
|
1898
|
+
sel = rb_funcallv(self, SYM2ID(argv[0]), argc - 1, argv + 1);
|
|
1899
|
+
rb_ca_store2(obj, 1, &sel, CA_UNDEF);
|
|
1919
1900
|
}
|
|
1920
1901
|
else {
|
|
1921
|
-
|
|
1922
|
-
all_args[argc] = CA_UNDEF;
|
|
1923
|
-
rb_funcallv(obj, rb_intern("[]="), argc + 1, all_args);
|
|
1902
|
+
rb_ca_store2(obj, argc, argv, CA_UNDEF);
|
|
1924
1903
|
}
|
|
1925
1904
|
return rb_funcall(obj, rb_intern("face_lift"), 1, self);
|
|
1926
1905
|
}
|
|
1927
1906
|
obj = rb_ca_copy(self);
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
/* a CScalar takes no index; its one-cell view does */
|
|
1931
|
-
rb_funcallv(ca_is_scalar(ca) ? rb_funcall(obj, rb_intern("flatten"), 0) : obj,
|
|
1932
|
-
rb_intern("[]="), argc + 1, all_args);
|
|
1907
|
+
/* rb_ca_store2 indexes a CScalar as a one-cell array */
|
|
1908
|
+
rb_ca_store2(obj, argc, argv, CA_UNDEF);
|
|
1933
1909
|
return obj;
|
|
1934
1910
|
}
|
|
1935
1911
|
|
|
@@ -1955,6 +1931,7 @@ rb_ca_mask_invalid (VALUE self)
|
|
|
1955
1931
|
static VALUE
|
|
1956
1932
|
rb_ca_mask_where (int argc, VALUE *argv, VALUE self)
|
|
1957
1933
|
{
|
|
1934
|
+
rb_reject_options(rb_pop_options(&argc, &argv));
|
|
1958
1935
|
if (argc == 0) {
|
|
1959
1936
|
rb_raise(rb_eArgError, "mask_where requires at least 1 argument");
|
|
1960
1937
|
}
|
|
@@ -1982,7 +1959,7 @@ the mask states of <code>self</code> and arrays given in arguments.
|
|
|
1982
1959
|
*/
|
|
1983
1960
|
|
|
1984
1961
|
static VALUE
|
|
1985
|
-
rb_ca_inherit_mask_method (int argc, VALUE *argv, VALUE self)
|
|
1962
|
+
rb_ca_inherit_mask_method (int argc, VALUE *argv, volatile VALUE self)
|
|
1986
1963
|
{
|
|
1987
1964
|
CArray **slist;
|
|
1988
1965
|
volatile VALUE holder;
|
|
@@ -1991,12 +1968,13 @@ rb_ca_inherit_mask_method (int argc, VALUE *argv, VALUE self)
|
|
|
1991
1968
|
|
|
1992
1969
|
rb_ca_modify(self);
|
|
1993
1970
|
|
|
1994
|
-
|
|
1971
|
+
GetCArray(self, ca);
|
|
1995
1972
|
|
|
1996
1973
|
slist = ALLOCV_N(CArray *, holder, argc);
|
|
1997
1974
|
for (i=0; i<argc; i++) {
|
|
1998
1975
|
if ( rb_obj_is_carray(argv[i]) ) {
|
|
1999
|
-
|
|
1976
|
+
/* gc: argv holds it for the call */
|
|
1977
|
+
GetCArray(argv[i], cs);
|
|
2000
1978
|
ca_inherit_mask_check_source(ca, cs);
|
|
2001
1979
|
slist[i] = cs;
|
|
2002
1980
|
}
|
|
@@ -2022,7 +2000,7 @@ rb_ca_inherit_mask_n (VALUE self, int n, VALUE *rothers)
|
|
|
2022
2000
|
/* api: rb_ca_inherit_mask */
|
|
2023
2001
|
|
|
2024
2002
|
VALUE
|
|
2025
|
-
rb_ca_inherit_mask (VALUE self, int n, ...)
|
|
2003
|
+
rb_ca_inherit_mask (volatile VALUE self, int n, ...)
|
|
2026
2004
|
{
|
|
2027
2005
|
volatile VALUE other;
|
|
2028
2006
|
CArray **slist;
|
|
@@ -2033,14 +2011,14 @@ rb_ca_inherit_mask (VALUE self, int n, ...)
|
|
|
2033
2011
|
|
|
2034
2012
|
rb_ca_modify(self);
|
|
2035
2013
|
|
|
2036
|
-
|
|
2014
|
+
GetCArray(self, ca);
|
|
2037
2015
|
|
|
2038
2016
|
va_start(rothers, n);
|
|
2039
2017
|
slist = ALLOCV_N(CArray *, holder, n);
|
|
2040
2018
|
for (i=0; i<n; i++) {
|
|
2041
2019
|
other = va_arg(rothers, VALUE);
|
|
2042
2020
|
if ( rb_obj_is_carray(other) ) {
|
|
2043
|
-
|
|
2021
|
+
GetCArray(other, cs);
|
|
2044
2022
|
ca_inherit_mask_check_source(ca, cs);
|
|
2045
2023
|
slist[i] = cs;
|
|
2046
2024
|
}
|
|
@@ -2065,7 +2043,7 @@ from `CArray#inherit_mask`)
|
|
|
2065
2043
|
*/
|
|
2066
2044
|
|
|
2067
2045
|
static VALUE
|
|
2068
|
-
rb_ca_inherit_mask_replace_method (int argc, VALUE *argv, VALUE self)
|
|
2046
|
+
rb_ca_inherit_mask_replace_method (int argc, VALUE *argv, volatile VALUE self)
|
|
2069
2047
|
{
|
|
2070
2048
|
CArray **slist;
|
|
2071
2049
|
volatile VALUE holder;
|
|
@@ -2074,12 +2052,13 @@ rb_ca_inherit_mask_replace_method (int argc, VALUE *argv, VALUE self)
|
|
|
2074
2052
|
|
|
2075
2053
|
rb_ca_modify(self);
|
|
2076
2054
|
|
|
2077
|
-
|
|
2055
|
+
GetCArray(self, ca);
|
|
2078
2056
|
|
|
2079
2057
|
slist = ALLOCV_N(CArray *, holder, argc);
|
|
2080
2058
|
for (i=0; i<argc; i++) {
|
|
2081
2059
|
if ( rb_obj_is_carray(argv[i]) ) {
|
|
2082
|
-
|
|
2060
|
+
/* gc: argv holds it for the call */
|
|
2061
|
+
GetCArray(argv[i], cs);
|
|
2083
2062
|
ca_inherit_mask_check_source(ca, cs);
|
|
2084
2063
|
slist[i] = cs;
|
|
2085
2064
|
}
|
|
@@ -2105,7 +2084,7 @@ rb_ca_inherit_mask_replace_n (VALUE self, int n, VALUE *rothers)
|
|
|
2105
2084
|
/* api: rb_ca_inherit_mask_replace */
|
|
2106
2085
|
|
|
2107
2086
|
VALUE
|
|
2108
|
-
rb_ca_inherit_mask_replace (VALUE self, int n, ...)
|
|
2087
|
+
rb_ca_inherit_mask_replace (volatile VALUE self, int n, ...)
|
|
2109
2088
|
{
|
|
2110
2089
|
volatile VALUE other;
|
|
2111
2090
|
CArray **slist;
|
|
@@ -2116,14 +2095,14 @@ rb_ca_inherit_mask_replace (VALUE self, int n, ...)
|
|
|
2116
2095
|
|
|
2117
2096
|
rb_ca_modify(self);
|
|
2118
2097
|
|
|
2119
|
-
|
|
2098
|
+
GetCArray(self, ca);
|
|
2120
2099
|
|
|
2121
2100
|
va_start(rothers, n);
|
|
2122
2101
|
slist = ALLOCV_N(CArray *, holder, n);
|
|
2123
2102
|
for (i=0; i<n; i++) {
|
|
2124
2103
|
other = va_arg(rothers, VALUE);
|
|
2125
2104
|
if ( rb_obj_is_carray(other) ) {
|
|
2126
|
-
|
|
2105
|
+
GetCArray(other, cs);
|
|
2127
2106
|
ca_inherit_mask_check_source(ca, cs);
|
|
2128
2107
|
slist[i] = cs;
|
|
2129
2108
|
}
|
|
@@ -2150,7 +2129,7 @@ ca_count_uniform (CArray *ca, const int8_t *axes, int8_t naxes, ca_size_t fill)
|
|
|
2150
2129
|
int8_t ndim = 0;
|
|
2151
2130
|
int i, j;
|
|
2152
2131
|
int64_t v = (int64_t) fill;
|
|
2153
|
-
VALUE
|
|
2132
|
+
volatile VALUE result;
|
|
2154
2133
|
CArray *co;
|
|
2155
2134
|
|
|
2156
2135
|
if ( naxes == ca->ndim ) {
|
|
@@ -2164,7 +2143,7 @@ ca_count_uniform (CArray *ca, const int8_t *axes, int8_t naxes, ca_size_t fill)
|
|
|
2164
2143
|
if (!is_axis) dim[ndim++] = ca->dim[i];
|
|
2165
2144
|
}
|
|
2166
2145
|
result = rb_carray_new(CA_INT64, ndim, dim, 0, NULL);
|
|
2167
|
-
|
|
2146
|
+
GetCArray(result, co);
|
|
2168
2147
|
ca_fill(co, &v);
|
|
2169
2148
|
return result;
|
|
2170
2149
|
}
|
|
@@ -2188,11 +2167,11 @@ extern VALUE rb_ca_count_false_ki (int argc, VALUE *argv, VALUE self);
|
|
|
2188
2167
|
Public (non-static) linkage so rb_ca_count in carray_count.c can forward
|
|
2189
2168
|
count(UNDEF) here directly without going through Ruby method dispatch. */
|
|
2190
2169
|
static VALUE
|
|
2191
|
-
ca_count_by_mask (int argc, VALUE *argv, VALUE self, int masked)
|
|
2170
|
+
ca_count_by_mask (int argc, VALUE *argv, volatile VALUE self, int masked)
|
|
2192
2171
|
{
|
|
2193
2172
|
CArray *ca;
|
|
2194
2173
|
VALUE kw_hash = Qnil, mask_obj;
|
|
2195
|
-
|
|
2174
|
+
GetCArray(self, ca);
|
|
2196
2175
|
rb_scan_args(argc, argv, "0:", &kw_hash);
|
|
2197
2176
|
|
|
2198
2177
|
if ( ! ca_has_mask(ca) ) {
|
|
@@ -2213,7 +2192,7 @@ ca_count_by_mask (int argc, VALUE *argv, VALUE self, int masked)
|
|
|
2213
2192
|
}
|
|
2214
2193
|
{
|
|
2215
2194
|
ca_size_t one[CA_RANK_MAX];
|
|
2216
|
-
VALUE
|
|
2195
|
+
volatile VALUE shape = rb_ary_new_capa(ca->ndim), cell;
|
|
2217
2196
|
boolean8_t zero = 0;
|
|
2218
2197
|
CArray *cc;
|
|
2219
2198
|
int i;
|
|
@@ -2222,7 +2201,7 @@ ca_count_by_mask (int argc, VALUE *argv, VALUE self, int masked)
|
|
|
2222
2201
|
rb_ary_push(shape, SIZE2NUM(ca->dim[i]));
|
|
2223
2202
|
}
|
|
2224
2203
|
cell = rb_carray_new(CA_BOOLEAN, ca->ndim, one, 0, NULL);
|
|
2225
|
-
|
|
2204
|
+
GetCArray(cell, cc);
|
|
2226
2205
|
ca_fill(cc, &zero);
|
|
2227
2206
|
mask_obj = rb_funcallv(cell, rb_intern("broadcast_to"),
|
|
2228
2207
|
(int) RARRAY_LEN(shape), RARRAY_CONST_PTR(shape));
|
|
@@ -2570,7 +2549,6 @@ Init_carray_mask (void)
|
|
|
2570
2549
|
(arity 1, no default), matching the "all arguments mandatory"
|
|
2571
2550
|
regularity of the mask SET family. */
|
|
2572
2551
|
rb_define_method(rb_cCArray, "strip_mask", rb_ca_mask_fill_copy, 1);
|
|
2573
|
-
rb_define_method(rb_cCArray, "invert_mask", rb_ca_invert_mask, 0);
|
|
2574
2552
|
rb_define_singleton_method(rb_cCArray, "guard_undef", rb_ca_s_guard_undef, -1);
|
|
2575
2553
|
rb_define_method(rb_cCArray, "mask_eq", rb_ca_mask_eq, 1);
|
|
2576
2554
|
rb_define_method(rb_cCArray, "mask_invalid", rb_ca_mask_invalid, 0);
|