carray 3.0.3 → 3.0.5
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/CHANGELOG.md +469 -0
- data/README.md +3 -2
- data/carray.gemspec +1 -1
- data/ext/ca_array_pool.c +25 -1
- data/ext/ca_axis_descriptor.h +27 -24
- data/ext/ca_axis_dispatch.c +14 -26
- data/ext/ca_axis_group.c +27 -27
- data/ext/ca_binop_dispatch.c +1 -29
- data/ext/ca_binop_dispatch.h +0 -1
- data/ext/ca_categorical_iterator.c +231 -153
- data/ext/ca_compare.c +9 -20
- data/ext/ca_composite_dispatch.c +9 -9
- data/ext/ca_group_iter.c +16 -17
- data/ext/ca_kernel_iterator.c +1240 -2000
- data/ext/ca_kernel_iterator.h +502 -519
- data/ext/ca_monop_dispatch.c +82 -59
- data/ext/ca_monop_dispatch.h +1 -0
- data/ext/ca_obj_array.c +152 -45
- data/ext/ca_obj_bincmp.c +25 -21
- data/ext/ca_obj_binop.c +16 -26
- data/ext/ca_obj_bitarray.c +8 -3
- data/ext/ca_obj_bitfield.c +63 -49
- data/ext/ca_obj_block.c +18 -9
- data/ext/ca_obj_byte_swap.c +7 -7
- data/ext/ca_obj_const_string.c +188 -22
- data/ext/ca_obj_face.c +280 -58
- data/ext/ca_obj_face.h +19 -0
- data/ext/ca_obj_fake.c +15 -29
- data/ext/ca_obj_farray.c +6 -3
- data/ext/ca_obj_field.c +30 -8
- data/ext/ca_obj_fixlen_string.c +2 -3
- data/ext/ca_obj_grid.c +455 -134
- data/ext/ca_obj_meld.c +172 -34
- data/ext/ca_obj_moncmp.c +23 -8
- data/ext/ca_obj_monop.c +113 -67
- data/ext/ca_obj_object.c +210 -52
- data/ext/ca_obj_record.c +15 -7
- data/ext/ca_obj_reduce.c +17 -8
- data/ext/ca_obj_refer.c +42 -35
- data/ext/ca_obj_remap.c +30 -9
- data/ext/ca_obj_repeat.c +9 -10
- data/ext/ca_obj_roll.c +31 -10
- data/ext/ca_obj_select.c +48 -14
- data/ext/ca_obj_select_axis.c +15 -47
- data/ext/ca_obj_shift.c +41 -7
- data/ext/ca_obj_stack.c +180 -34
- data/ext/ca_obj_stride.c +190 -134
- data/ext/ca_obj_string.c +80 -4
- data/ext/ca_obj_tile.c +32 -11
- data/ext/ca_obj_time.c +22 -6
- data/ext/ca_obj_timedelta.c +22 -6
- data/ext/ca_obj_transpose.c +13 -7
- data/ext/ca_obj_triop.c +26 -32
- data/ext/ca_obj_window.c +267 -74
- data/ext/ca_op_ipower.c +4 -4
- data/ext/ca_sort_kernels.h +6 -3
- data/ext/ca_sweep_engine.c +2 -2
- data/ext/caframe_csv_reader.c +80 -1
- data/ext/carray.h +214 -75
- data/ext/carray_access.c +200 -99
- data/ext/carray_address_basis.c +343 -87
- data/ext/carray_attribute.c +113 -6
- data/ext/carray_bincount.c +10 -8
- data/ext/carray_broadcast.c +13 -8
- data/ext/carray_build_flags.h +3 -0
- data/ext/carray_call_cfunc.c +108 -0
- data/ext/carray_cast.c +375 -96
- data/ext/carray_cast_func.rb +90 -20
- data/ext/carray_class.c +4 -3
- data/ext/carray_config.h +28 -0
- data/ext/carray_conversion.c +18 -9
- data/ext/carray_copy.c +51 -14
- data/ext/carray_core.c +150 -55
- data/ext/carray_count.c +56 -20
- data/ext/carray_element.c +81 -33
- data/ext/carray_factorize.c +138 -84
- data/ext/carray_generate.c +199 -52
- data/ext/carray_histogram.c +63 -18
- data/ext/carray_hold.c +12 -15
- data/ext/carray_index_classifier.c +388 -176
- data/ext/carray_internal.h +348 -29
- data/ext/carray_kernels_bincmp.c +4453 -0
- data/ext/carray_kernels_binop.c +11368 -0
- data/ext/carray_kernels_init.c +1734 -0
- data/ext/carray_kernels_moncmp.c +2104 -0
- data/ext/carray_kernels_monop.c +18369 -0
- data/ext/carray_kernels_reduce_aggregate.c +23818 -0
- data/ext/carray_kernels_reduce_boolean.c +406 -0
- data/ext/carray_kernels_reduce_cumulative.c +10086 -0
- data/ext/carray_kernels_reduce_extreme.c +17634 -0
- data/ext/carray_kernels_reduce_variance.c +3849 -0
- data/ext/carray_kernels_scan.c +4302 -0
- data/ext/carray_kernels_search.c +33829 -0
- data/ext/carray_kernels_sort.c +10897 -0
- data/ext/carray_kernels_triop.c +1864 -0
- data/ext/carray_key_windows.c +220 -0
- data/ext/carray_lazy.c +170 -111
- data/ext/carray_mask.c +337 -94
- data/ext/carray_median_percentile.c +82 -28
- data/ext/carray_memory_view.c +669 -561
- data/ext/carray_operator.c +129 -52
- data/ext/carray_order.c +604 -77
- data/ext/carray_partition.c +28 -27
- data/ext/carray_random.c +85 -31
- data/ext/carray_round.c +273 -0
- data/ext/carray_scatter.c +87 -45
- data/ext/carray_segment.c +3 -3
- data/ext/carray_slab.c +123 -37
- data/ext/carray_sort.c +259 -51
- data/ext/carray_sort_kernel.c +5 -7
- data/ext/carray_struct.c +54 -61
- data/ext/carray_test.c +26 -5
- data/ext/carray_time_text.c +4 -2
- data/ext/carray_undef.c +4 -0
- data/ext/carray_utils.c +309 -66
- data/ext/mk_call_cfunc.rb +19 -2
- data/ext/mkkernel.rb +403 -350
- data/ext/ruby_carray.c +10 -4
- data/ext/version.h +4 -4
- data/lib/carray/attribute.rb +139 -22
- data/lib/carray/autoload_carray.rb +8 -31
- data/lib/carray/autoload_method_extension.rb +14 -5
- data/lib/carray/axis_group.rb +255 -106
- data/lib/carray/basics.rb +105 -17
- data/lib/carray/bincount_nd.rb +12 -2
- data/lib/carray/block_iterator.rb +126 -23
- data/lib/carray/boolean_reduce.rb +17 -17
- data/lib/carray/categorical.rb +195 -59
- data/lib/carray/categorical_iterator.rb +132 -29
- data/lib/carray/complex.rb +5 -5
- data/lib/carray/conditional.rb +67 -18
- data/lib/carray/const_string.rb +24 -5
- data/lib/carray/construct.rb +15 -11
- data/lib/carray/data_type_extension.rb +9 -1
- data/lib/carray/distance_limit.rb +77 -0
- data/lib/carray/fixlen_string.rb +48 -3
- data/lib/carray/frame/column_verbs.rb +71 -0
- data/lib/carray/frame/concat.rb +17 -3
- data/lib/carray/frame/convert.rb +69 -0
- data/lib/carray/frame/csv_parser.rb +111 -17
- data/lib/carray/frame/describe.rb +3 -2
- data/lib/carray/frame/frame.rb +252 -28
- data/lib/carray/frame/group.rb +603 -101
- data/lib/carray/frame/io.rb +117 -28
- data/lib/carray/frame/join.rb +312 -51
- data/lib/carray/frame/records.rb +83 -7
- data/lib/carray/frame/reshape.rb +42 -35
- data/lib/carray/frame/sort.rb +7 -19
- data/lib/carray/frame/verbs.rb +188 -48
- data/lib/carray/frame/windows.rb +117 -0
- data/lib/carray/frame.rb +2 -0
- data/lib/carray/fuse_source.rb +42 -6
- data/lib/carray/fusion.rb +40 -16
- data/lib/carray/histogram.rb +6 -1
- data/lib/carray/inspect.rb +31 -8
- data/lib/carray/iterator.rb +85 -7
- data/lib/carray/key_windows.rb +620 -0
- data/lib/carray/lazy.rb +217 -183
- data/lib/carray/mask_gap_fill.rb +63 -57
- data/lib/carray/meld_reduce.rb +12 -14
- data/lib/carray/methods/bin.rb +26 -18
- data/lib/carray/methods/bincount.rb +16 -0
- data/lib/carray/methods/bit_string.rb +1 -1
- data/lib/carray/methods/choose.rb +16 -3
- data/lib/carray/methods/composition.rb +3 -1
- data/lib/carray/methods/gather_nd.rb +14 -5
- data/lib/carray/methods/insert_block.rb +2 -2
- data/lib/carray/methods/is_between.rb +59 -0
- data/lib/carray/methods/is_in.rb +61 -37
- data/lib/carray/methods/join.rb +1 -6
- data/lib/carray/methods/lag.rb +49 -0
- data/lib/carray/methods/locate_addr.rb +47 -51
- data/lib/carray/methods/mode.rb +1 -1
- data/lib/carray/methods/nunique.rb +11 -6
- data/lib/carray/methods/resize.rb +3 -3
- data/lib/carray/methods/value_counts.rb +4 -11
- data/lib/carray/record_order.rb +3 -3
- data/lib/carray/rng.rb +3 -0
- data/lib/carray/runtime.rb +53 -8
- data/lib/carray/segment_iterator.rb +323 -88
- data/lib/carray/serialize.rb +45 -14
- data/lib/carray/slab_iterator.rb +50 -0
- data/lib/carray/stack.rb +15 -12
- data/lib/carray/string.rb +113 -5
- data/lib/carray/string_operation_extension.rb +21 -6
- data/lib/carray/struct.rb +9 -21
- data/lib/carray/struct_builder.rb +24 -11
- data/lib/carray/time.rb +819 -158
- data/lib/carray/window_iterator.rb +122 -16
- data/lib/carray.rb +7 -0
- data/yard-stubs/ca_obj_bitfield.rb +1 -1
- data/yard-stubs/ca_obj_field.rb +4 -0
- data/yard-stubs/ca_obj_grid.rb +21 -10
- data/yard-stubs/ca_obj_refer.rb +2 -1
- data/yard-stubs/ca_obj_roll.rb +2 -2
- data/yard-stubs/ca_obj_shift.rb +5 -1
- data/yard-stubs/ca_obj_tile.rb +1 -1
- data/yard-stubs/ca_obj_transpose.rb +5 -4
- data/yard-stubs/ca_obj_window.rb +8 -3
- data/yard-stubs/carray_access.rb +6 -1
- data/yard-stubs/carray_attribute.rb +3 -6
- data/yard-stubs/carray_cast.rb +12 -0
- data/yard-stubs/carray_conversion.rb +7 -2
- data/yard-stubs/carray_copy.rb +4 -2
- data/yard-stubs/carray_count.rb +4 -4
- data/yard-stubs/carray_element.rb +17 -10
- data/yard-stubs/carray_generate.rb +21 -1
- data/yard-stubs/carray_mask.rb +32 -3
- data/yard-stubs/carray_math.rb +41 -5
- data/yard-stubs/carray_median_percentile.rb +5 -2
- data/yard-stubs/carray_memory_view.rb +40 -23
- data/yard-stubs/carray_order.rb +129 -22
- data/yard-stubs/carray_random.rb +13 -4
- data/yard-stubs/carray_scatter.rb +17 -10
- data/yard-stubs/carray_slab.rb +9 -2
- data/yard-stubs/carray_sort.rb +6 -5
- data/yard-stubs/carray_test.rb +5 -3
- metadata +25 -3
- data/lib/carray/arrow_tensor.rb +0 -401
- data/lib/carray/table.rb +0 -108
data/ext/ca_obj_refer.c
CHANGED
|
@@ -74,10 +74,10 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
|
74
74
|
ca_size_t s;
|
|
75
75
|
int8_t i;
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
CA_CHECK_DATA_TYPE_GIVEN(data_type);
|
|
78
|
+
CA_CHECK_RANK_GIVEN(ndim);
|
|
79
|
+
CA_CHECK_DIM_GIVEN(ndim, dim);
|
|
80
|
+
CA_CHECK_BYTES_GIVEN(data_type, bytes);
|
|
81
81
|
|
|
82
82
|
/* An object cell is a VALUE the GC marks: reading other bytes as one
|
|
83
83
|
marks garbage, and reading one as bytes exposes an address. */
|
|
@@ -89,6 +89,14 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
|
89
89
|
rb_raise(rb_eCADataTypeError,
|
|
90
90
|
"non-object array can't be referred as object data type");
|
|
91
91
|
}
|
|
92
|
+
/* A boolean cell holds 0 or 1, and a view that reads other bytes as
|
|
93
|
+
boolean cannot keep them so: the parent is written as what it is. */
|
|
94
|
+
if (data_type == CA_BOOLEAN && parent->data_type != CA_BOOLEAN) {
|
|
95
|
+
rb_raise(rb_eCADataTypeError,
|
|
96
|
+
"%s: a %s array can't be referred as boolean (its bytes need not "
|
|
97
|
+
"be 0 or 1); compare it instead, e.g. ne(0)",
|
|
98
|
+
ca_calling_method_name(), ca_type_name[parent->data_type]);
|
|
99
|
+
}
|
|
92
100
|
if (parent->elements && bytes > parent_bytes * parent->elements) {
|
|
93
101
|
rb_raise(rb_eArgError, "bytes exceeds the data size of referent");
|
|
94
102
|
}
|
|
@@ -129,16 +137,17 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
|
129
137
|
return 0;
|
|
130
138
|
}
|
|
131
139
|
|
|
132
|
-
/*
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
pointer during error unwind. */
|
|
140
|
+
/* mask0 is written by ca_refer_func_create_mask when the constructor
|
|
141
|
+
takes the parent's mask, and freed on error unwind, so it starts
|
|
142
|
+
NULL. */
|
|
136
143
|
ca->mask0 = NULL;
|
|
137
144
|
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
ca_stride_setup_view((CAStride *) ca, CA_OBJ_REFER, parent,
|
|
146
|
+
data_type, bytes, ndim, dim, strides, base_offset);
|
|
140
147
|
|
|
141
|
-
|
|
148
|
+
/* A refer of a scalar stays one only while it has the one cell: read as
|
|
149
|
+
narrower elements it is an array of several. */
|
|
150
|
+
if (ca_is_scalar(parent) && ca->elements == 1) {
|
|
142
151
|
ca_set_flag(ca, CA_FLAG_SCALAR);
|
|
143
152
|
}
|
|
144
153
|
return 0;
|
|
@@ -153,6 +162,7 @@ ca_refer_new (CArray *parent,
|
|
|
153
162
|
ca_refer_setup(NULL, parent, data_type, ndim, dim, bytes, offset);
|
|
154
163
|
ca = (CARefer *) ca_array_alloc(CA_OBJ_REFER, ndim);
|
|
155
164
|
ca_refer_setup(ca, parent, data_type, ndim, dim, bytes, offset);
|
|
165
|
+
ca_fill_or_free((CArray *) ca, ca_view_inherit_mask, (VALUE) ca);
|
|
156
166
|
return ca;
|
|
157
167
|
}
|
|
158
168
|
|
|
@@ -203,16 +213,20 @@ ca_refer_func_create_mask (void *ap)
|
|
|
203
213
|
else if (ca->bytes < parent_bytes) {
|
|
204
214
|
/* Divided reinterpret: one parent element splits into
|
|
205
215
|
ratio = parent_bytes / bytes view elements. Build a
|
|
206
|
-
|
|
207
|
-
ratio sub-positions, then
|
|
208
|
-
actual shape.
|
|
216
|
+
repeat of two axes, (parent elements, ratio), that broadcasts
|
|
217
|
+
each parent mask bit across the ratio sub-positions, then
|
|
218
|
+
refer-reshape it to the view's actual shape. Two axes whatever
|
|
219
|
+
the parent's rank, so a parent at CA_RANK_MAX needs no extra
|
|
220
|
+
one. */
|
|
209
221
|
ca_size_t ratio = parent_bytes / ca->bytes;
|
|
210
|
-
ca_size_t
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
222
|
+
ca_size_t mdim[2], mstrides[2];
|
|
223
|
+
mdim[0] = ca->parent->elements;
|
|
224
|
+
mdim[1] = ratio;
|
|
225
|
+
mstrides[0] = 1;
|
|
226
|
+
mstrides[1] = 0;
|
|
214
227
|
ca->mask0 =
|
|
215
|
-
(CArray *)
|
|
228
|
+
(CArray *) ca_stride_new(CA_OBJ_REPEAT, ca->parent->mask, CA_BOOLEAN, 1,
|
|
229
|
+
2, mdim, mstrides, 0);
|
|
216
230
|
ca_unset_flag(ca->mask0, CA_FLAG_READ_ONLY);
|
|
217
231
|
/* mask0 has ratio cells per parent element, so the offset is counted
|
|
218
232
|
in those. */
|
|
@@ -260,6 +274,7 @@ rb_ca_refer_initialize_copy (VALUE self, VALUE other)
|
|
|
260
274
|
unusual mod-bytes alignments. */
|
|
261
275
|
ca_refer_setup(ca, cs->parent, cs->data_type, cs->ndim, cs->dim,
|
|
262
276
|
cs->bytes, cs->base_offset / cs->parent->bytes);
|
|
277
|
+
ca_view_inherit_mask((VALUE) ca);
|
|
263
278
|
return self;
|
|
264
279
|
}
|
|
265
280
|
|
|
@@ -488,7 +503,7 @@ rb_ca_refer_kw (int argc, VALUE *argv, VALUE ropt, VALUE self)
|
|
|
488
503
|
}
|
|
489
504
|
}
|
|
490
505
|
Check_Type(rdim, T_ARRAY);
|
|
491
|
-
|
|
506
|
+
CA_CHECK_RANK_GIVEN(RARRAY_LEN(rdim)); /* before dim[] is filled */
|
|
492
507
|
ndim = RARRAY_LEN(rdim);
|
|
493
508
|
for (i = 0; i < ndim; i++) dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
|
494
509
|
if (! NIL_P(roffset)) offset = NUM2SIZE(roffset);
|
|
@@ -610,9 +625,10 @@ rb_ca_reshape (int argc, VALUE *argv, VALUE self)
|
|
|
610
625
|
|
|
611
626
|
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
612
627
|
|
|
613
|
-
if (argc
|
|
614
|
-
rb_raise(rb_eArgError, "reshape:
|
|
628
|
+
if ( argc == 0 ) {
|
|
629
|
+
rb_raise(rb_eArgError, "reshape: give at least one axis");
|
|
615
630
|
}
|
|
631
|
+
ca_check_rank_fits(argc, "reshape");
|
|
616
632
|
|
|
617
633
|
/* Locate the (at most one) auto-infer placeholder. `-1` is the
|
|
618
634
|
conventional spelling; `:~` is the unified auto-fill sigil
|
|
@@ -775,7 +791,7 @@ rb_ca_flatten (VALUE self)
|
|
|
775
791
|
before axis 0 twice -> [1, 1, 2, 3]
|
|
776
792
|
|
|
777
793
|
Returns a CARefer view (zero-copy alias to +self+'s data, via reshape).
|
|
778
|
-
Bound to the
|
|
794
|
+
Bound to the private method insert_size_one_axes; the user-facing
|
|
779
795
|
insert_axis (with the repeat: keyword) is the Ruby method in
|
|
780
796
|
lib/carray/basics.rb, which builds on this primitive.
|
|
781
797
|
|
|
@@ -795,11 +811,7 @@ rb_ca_insert_axis (int argc, VALUE *argv, VALUE self)
|
|
|
795
811
|
|
|
796
812
|
ndim = (int) ca->ndim;
|
|
797
813
|
new_ndim = ndim + argc;
|
|
798
|
-
|
|
799
|
-
rb_raise(rb_eArgError,
|
|
800
|
-
"insert_axis: resulting ndim %d exceeds CA_RANK_MAX %d",
|
|
801
|
-
new_ndim, CA_RANK_MAX);
|
|
802
|
-
}
|
|
814
|
+
ca_check_rank_fits(new_ndim, "insert_axis");
|
|
803
815
|
|
|
804
816
|
ngap = ndim + 1; /* gaps live in [0, ndim] (ndim = the end gap) */
|
|
805
817
|
|
|
@@ -809,12 +821,7 @@ rb_ca_insert_axis (int argc, VALUE *argv, VALUE self)
|
|
|
809
821
|
gap_count[i] = 0;
|
|
810
822
|
}
|
|
811
823
|
for (i = 0; i < argc; i++) {
|
|
812
|
-
int
|
|
813
|
-
int g = (raw < 0) ? raw + ngap : raw;
|
|
814
|
-
if (g < 0 || g >= ngap) {
|
|
815
|
-
rb_raise(rb_eArgError,
|
|
816
|
-
"insert_axis: axis %d out of range for ndim %d", raw, ndim);
|
|
817
|
-
}
|
|
824
|
+
int g = ca_normalize_axis_arg(argv[i], ngap, "insert_axis");
|
|
818
825
|
gap_count[g]++;
|
|
819
826
|
}
|
|
820
827
|
|
|
@@ -858,7 +865,7 @@ Init_ca_obj_refer (void)
|
|
|
858
865
|
/* The bare size-1 primitive. The user-facing `insert_axis` (with its
|
|
859
866
|
`repeat:` keyword) is the Ruby method in lib/carray/basics.rb, which
|
|
860
867
|
owns the name and calls this primitive. */
|
|
861
|
-
|
|
868
|
+
rb_define_private_method(rb_cCArray, "insert_size_one_axes", rb_ca_insert_axis, -1);
|
|
862
869
|
rb_define_alloc_func(rb_cCARefer, rb_ca_refer_s_allocate);
|
|
863
870
|
rb_define_method(rb_cCARefer, "initialize_copy",
|
|
864
871
|
rb_ca_refer_initialize_copy, 1);
|
data/ext/ca_obj_remap.c
CHANGED
|
@@ -129,6 +129,12 @@ ca_remap_setup (CARemap *ca, CArray *ref, CArray *idx)
|
|
|
129
129
|
{
|
|
130
130
|
ca_remap_check_constraints(ref, idx);
|
|
131
131
|
|
|
132
|
+
/* ca == NULL asks for the checks above only, so that a constructor can
|
|
133
|
+
run them before it allocates. */
|
|
134
|
+
if ( ca == NULL ) {
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
132
138
|
ca->obj_type = CA_OBJ_REMAP;
|
|
133
139
|
ca->data_type = ref->data_type;
|
|
134
140
|
ca->flags = 0;
|
|
@@ -147,9 +153,6 @@ ca_remap_setup (CARemap *ca, CArray *ref, CArray *idx)
|
|
|
147
153
|
ca->nosync = 0;
|
|
148
154
|
ca->idx = idx;
|
|
149
155
|
|
|
150
|
-
if ( ca_has_mask(ref) ) {
|
|
151
|
-
ca_create_mask(ca);
|
|
152
|
-
}
|
|
153
156
|
|
|
154
157
|
if ( ca_is_scalar(ref) ) {
|
|
155
158
|
ca_set_flag(ca, CA_FLAG_SCALAR);
|
|
@@ -161,8 +164,11 @@ ca_remap_setup (CARemap *ca, CArray *ref, CArray *idx)
|
|
|
161
164
|
CARemap *
|
|
162
165
|
ca_remap_new (CArray *ref, CArray *idx)
|
|
163
166
|
{
|
|
164
|
-
CARemap *ca
|
|
167
|
+
CARemap *ca;
|
|
168
|
+
ca_remap_setup(NULL, ref, idx);
|
|
169
|
+
ca = (CARemap *) ca_array_alloc(CA_OBJ_REMAP, ref->ndim);
|
|
165
170
|
ca_remap_setup(ca, ref, idx);
|
|
171
|
+
ca_fill_or_free((CArray *) ca, ca_view_inherit_mask, (VALUE) ca);
|
|
166
172
|
return ca;
|
|
167
173
|
}
|
|
168
174
|
|
|
@@ -211,7 +217,7 @@ static void
|
|
|
211
217
|
ca_remap_func_allocate (void *ap)
|
|
212
218
|
{
|
|
213
219
|
CARemap *ca = (CARemap *) ap;
|
|
214
|
-
ca->ptr =
|
|
220
|
+
ca->ptr = ca_alloc_cells((CArray *) ca);
|
|
215
221
|
}
|
|
216
222
|
|
|
217
223
|
static void
|
|
@@ -435,8 +441,9 @@ rb_ca_remap_new (VALUE cary, VALUE rmapper)
|
|
|
435
441
|
}
|
|
436
442
|
|
|
437
443
|
/* Read-only accessor for the per-cell index CArray that defines this
|
|
438
|
-
CARemap's mapping
|
|
439
|
-
|
|
444
|
+
CARemap's mapping: the array the view reads. For ca[mapper] it is a
|
|
445
|
+
copy of mapper taken at the call, so a later change to mapper does
|
|
446
|
+
not reach the view. Companion to
|
|
440
447
|
CABlock#start / CAStride#strides / CAWindow#count etc. — the view
|
|
441
448
|
hierarchy is preserved so each named view class exposes its own
|
|
442
449
|
defining semantic state. */
|
|
@@ -453,8 +460,22 @@ rb_ca_remap_mapper (VALUE self)
|
|
|
453
460
|
static VALUE
|
|
454
461
|
rb_ca_remap_dup (VALUE self)
|
|
455
462
|
{
|
|
456
|
-
|
|
457
|
-
|
|
463
|
+
volatile VALUE rmapper = rb_ivar_get(self, rb_intern("remap_idx"));
|
|
464
|
+
if ( NIL_P(rmapper) ) {
|
|
465
|
+
/* The mask of a CARemap (it holds no index array of its own): another
|
|
466
|
+
remap over the same parent mask and index. The array it is the mask
|
|
467
|
+
of keeps both alive, so the copy holds that array too. */
|
|
468
|
+
volatile VALUE obj;
|
|
469
|
+
CArray *ca, *cp;
|
|
470
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
471
|
+
cp = (CArray *) ca_remap_func_clone(ca);
|
|
472
|
+
ca_keep_chain_flags(cp, ca);
|
|
473
|
+
obj = TypedData_Wrap_Struct(rb_obj_class(self), &caremap_data_type, cp);
|
|
474
|
+
rb_ivar_set(obj, rb_intern("masked_array"),
|
|
475
|
+
rb_ivar_get(self, rb_intern("masked_array")));
|
|
476
|
+
return obj;
|
|
477
|
+
}
|
|
478
|
+
return rb_ca_remap_new(rb_ca_parent(self), rmapper);
|
|
458
479
|
}
|
|
459
480
|
|
|
460
481
|
static VALUE
|
data/ext/ca_obj_repeat.c
CHANGED
|
@@ -39,9 +39,7 @@ ca_repeat_setup (CAStride *ca, CArray *parent, int8_t ndim, ca_size_t *count)
|
|
|
39
39
|
int8_t data_ndim = 0;
|
|
40
40
|
int8_t i, j;
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
rb_raise(rb_eArgError, "invalid ndim %d", (int) ndim);
|
|
44
|
-
}
|
|
42
|
+
ca_check_rank_fits(ndim, NULL);
|
|
45
43
|
for (i = 0; i < ndim; i++) {
|
|
46
44
|
if (count[i] < 0) {
|
|
47
45
|
rb_raise(rb_eArgError,
|
|
@@ -86,9 +84,9 @@ ca_repeat_setup (CAStride *ca, CArray *parent, int8_t ndim, ca_size_t *count)
|
|
|
86
84
|
return 0;
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
ca_stride_setup_view(ca, CA_OBJ_REPEAT, parent,
|
|
88
|
+
parent->data_type, parent->bytes,
|
|
89
|
+
ndim, newdim, strides, 0);
|
|
92
90
|
|
|
93
91
|
ca_set_flag(ca, CA_FLAG_READ_ONLY);
|
|
94
92
|
if (ca->mask) {
|
|
@@ -104,6 +102,7 @@ ca_repeat_new (CArray *parent, int8_t ndim, ca_size_t *count)
|
|
|
104
102
|
ca_repeat_setup(NULL, parent, ndim, count);
|
|
105
103
|
ca = (CAStride *) ca_array_alloc(CA_OBJ_REPEAT, ndim);
|
|
106
104
|
ca_repeat_setup(ca, parent, ndim, count);
|
|
105
|
+
ca_fill_or_free((CArray *) ca, ca_view_inherit_mask, (VALUE) ca);
|
|
107
106
|
return ca;
|
|
108
107
|
}
|
|
109
108
|
|
|
@@ -216,12 +215,12 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
|
216
215
|
self = rb_ca_refer_new(self, ca->data_type, ndim, dim, ca->bytes, 0);
|
|
217
216
|
}
|
|
218
217
|
}
|
|
219
|
-
|
|
218
|
+
self = rb_ca_repeat((int)RARRAY_LEN(args), (VALUE *)RARRAY_CONST_PTR(args), self);
|
|
219
|
+
RB_GC_GUARD(args); /* the repeat reads its arguments out of args */
|
|
220
|
+
return self;
|
|
220
221
|
}
|
|
221
222
|
|
|
222
|
-
|
|
223
|
-
rb_raise(rb_eArgError, "invalid ndim %d", argc);
|
|
224
|
-
}
|
|
223
|
+
ca_check_rank_fits(argc, NULL); /* count[] and dim[] hold CA_RANK_MAX */
|
|
225
224
|
|
|
226
225
|
repeat = 1;
|
|
227
226
|
for (i=0; i<argc; i++) {
|
data/ext/ca_obj_roll.c
CHANGED
|
@@ -112,6 +112,8 @@ ca_roll_setup (CARoll *ca, CArray *parent, ca_size_t *shift)
|
|
|
112
112
|
ca->parent = parent;
|
|
113
113
|
ca->attach = 0;
|
|
114
114
|
ca->nosync = 0;
|
|
115
|
+
ca->reps = NULL; /* set before either allocation can raise */
|
|
116
|
+
ca->dim = NULL;
|
|
115
117
|
ca->reps = ALLOC_N(ca_size_t, ndim); /* repurposed as shift[] */
|
|
116
118
|
ca->dim = ALLOC_N(ca_size_t, ndim);
|
|
117
119
|
|
|
@@ -126,21 +128,37 @@ ca_roll_setup (CARoll *ca, CArray *parent, ca_size_t *shift)
|
|
|
126
128
|
ca->reps[i] = s;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
if ( ca_has_mask(parent) ) {
|
|
130
|
-
ca_create_mask(ca);
|
|
131
|
-
}
|
|
132
131
|
|
|
133
132
|
return 0;
|
|
134
133
|
}
|
|
135
134
|
|
|
135
|
+
typedef struct {
|
|
136
|
+
CARoll *ca;
|
|
137
|
+
CArray *parent;
|
|
138
|
+
ca_size_t *shift;
|
|
139
|
+
} ca_roll_new_arg;
|
|
140
|
+
|
|
141
|
+
static VALUE
|
|
142
|
+
ca_roll_new_setup (VALUE varg)
|
|
143
|
+
{
|
|
144
|
+
ca_roll_new_arg *a = (ca_roll_new_arg *) varg;
|
|
145
|
+
ca_roll_setup(a->ca, a->parent, a->shift);
|
|
146
|
+
return Qnil;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* The setup allocates reps and dim after the struct: when either fails,
|
|
150
|
+
the struct goes too. */
|
|
136
151
|
CARoll *
|
|
137
152
|
ca_roll_new (CArray *parent, ca_size_t *shift)
|
|
138
153
|
{
|
|
139
|
-
|
|
154
|
+
ca_roll_new_arg a;
|
|
140
155
|
ca_roll_setup(NULL, parent, shift);
|
|
141
|
-
ca
|
|
142
|
-
|
|
143
|
-
|
|
156
|
+
a.ca = ALLOC(CARoll);
|
|
157
|
+
a.parent = parent;
|
|
158
|
+
a.shift = shift;
|
|
159
|
+
ca_fill_or_free((CArray *) a.ca, ca_roll_new_setup, (VALUE) &a);
|
|
160
|
+
ca_fill_or_free((CArray *) a.ca, ca_view_inherit_mask, (VALUE) a.ca);
|
|
161
|
+
return a.ca;
|
|
144
162
|
}
|
|
145
163
|
|
|
146
164
|
static void
|
|
@@ -261,6 +279,7 @@ ca_roll_func_xfer_stride (void *ap, ca_size_t *starts, ca_size_t *counts,
|
|
|
261
279
|
ca_size_t idx[CA_RANK_MAX], doff = 0, base = 0;
|
|
262
280
|
for (k = 0; k < ndim; k++) base += starts[k] * rnative[k];
|
|
263
281
|
for (k = 0; k < ndim; k++) idx[k] = 0;
|
|
282
|
+
/* empty: the slot returns on an empty region at its entry */
|
|
264
283
|
while (1) {
|
|
265
284
|
ca_size_t roff = base, ridx[CA_RANK_MAX];
|
|
266
285
|
for (k = 0; k < ndim; k++) roff += idx[k] * strides[k];
|
|
@@ -364,6 +383,7 @@ ca_roll_func_xfer_stride (void *ap, ca_size_t *starts, ca_size_t *counts,
|
|
|
364
383
|
}
|
|
365
384
|
|
|
366
385
|
for (k = 0; k < ndim; k++) o[k] = 0;
|
|
386
|
+
/* empty: the slot returns on an empty region at its entry */
|
|
367
387
|
while (1) {
|
|
368
388
|
ca_size_t pbase = 0, doff = 0, i;
|
|
369
389
|
for (k = 0; k < inner; k++) {
|
|
@@ -506,7 +526,7 @@ ca_roll_func_allocate (void *ap)
|
|
|
506
526
|
{
|
|
507
527
|
CARoll *ca = (CARoll *) ap;
|
|
508
528
|
ca_attach(ca->parent);
|
|
509
|
-
ca->ptr =
|
|
529
|
+
ca->ptr = ca_alloc_cells((CArray *) ca);
|
|
510
530
|
}
|
|
511
531
|
|
|
512
532
|
static void
|
|
@@ -514,7 +534,7 @@ ca_roll_func_attach (void *ap)
|
|
|
514
534
|
{
|
|
515
535
|
CARoll *ca = (CARoll *) ap;
|
|
516
536
|
ca_attach(ca->parent);
|
|
517
|
-
ca->ptr =
|
|
537
|
+
ca->ptr = ca_alloc_cells((CArray *) ca);
|
|
518
538
|
ca_roll_iterate_regions(ca, ca->ptr, 0);
|
|
519
539
|
}
|
|
520
540
|
|
|
@@ -629,7 +649,7 @@ rb_ca_roll (int argc, VALUE *argv, VALUE self)
|
|
|
629
649
|
}
|
|
630
650
|
for ( i = 0; i < ca->ndim; i++ ) {
|
|
631
651
|
if ( i < argc ) {
|
|
632
|
-
shift[i] =
|
|
652
|
+
shift[i] = ca_integer_arg(argv[i], "a shift", NULL);
|
|
633
653
|
} else {
|
|
634
654
|
shift[i] = 0;
|
|
635
655
|
}
|
|
@@ -659,6 +679,7 @@ rb_ca_roll_initialize_copy (VALUE self, VALUE other)
|
|
|
659
679
|
ca_check_uninitialized(ca);
|
|
660
680
|
TypedData_Get_Struct(other, CARoll, &caroll_data_type, cs);
|
|
661
681
|
ca_roll_setup(ca, cs->parent, cs->reps);
|
|
682
|
+
ca_view_inherit_mask((VALUE) ca);
|
|
662
683
|
return self;
|
|
663
684
|
}
|
|
664
685
|
|
data/ext/ca_obj_select.c
CHANGED
|
@@ -130,7 +130,8 @@ ca_select_snapshot (CArray *select)
|
|
|
130
130
|
|
|
131
131
|
/* Set up the view over `parent` from an owned selector snapshot (see
|
|
132
132
|
ca_select_snapshot) and pre-compute ca->indices (TRUE positions in flat
|
|
133
|
-
parent order).
|
|
133
|
+
parent order). Raises only when the indices cannot be allocated, after
|
|
134
|
+
every field free_ca_select reads is set. */
|
|
134
135
|
static int
|
|
135
136
|
ca_select_setup (CASelect *ca, CArray *parent, CArray *snapshot)
|
|
136
137
|
{
|
|
@@ -162,15 +163,19 @@ ca_select_setup (CASelect *ca, CArray *parent, CArray *snapshot)
|
|
|
162
163
|
if ( s[i] ) count++;
|
|
163
164
|
}
|
|
164
165
|
ca->elements = count;
|
|
165
|
-
/*
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
/* One slot more than count: the loop below writes every position
|
|
167
|
+
and advances only on TRUE, so a run of FALSE after the last TRUE
|
|
168
|
+
writes slot `count`. Writing without a branch keeps a selector
|
|
169
|
+
with TRUE and FALSE mixed at random from mispredicting on most
|
|
170
|
+
cells. The extra slot also keeps count == 0 from malloc(0). */
|
|
171
|
+
ca->indices = (ca_size_t *) xmalloc(sizeof(ca_size_t) * (count + 1));
|
|
170
172
|
{
|
|
171
|
-
ca_size_t
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
ca_size_t *ix = ca->indices;
|
|
174
|
+
ca_size_t n = ca->select->elements;
|
|
175
|
+
ca_size_t j = 0;
|
|
176
|
+
for (i = 0; i < n; i++) {
|
|
177
|
+
ix[j] = i;
|
|
178
|
+
j += ( s[i] != 0 );
|
|
174
179
|
}
|
|
175
180
|
}
|
|
176
181
|
/* Constant-step detection: promotes to STRIDE descriptor kind
|
|
@@ -207,13 +212,42 @@ ca_select_setup (CASelect *ca, CArray *parent, CArray *snapshot)
|
|
|
207
212
|
return 0;
|
|
208
213
|
}
|
|
209
214
|
|
|
215
|
+
typedef struct {
|
|
216
|
+
CASelect *ca;
|
|
217
|
+
CArray *parent;
|
|
218
|
+
CArray *snapshot;
|
|
219
|
+
} ca_select_new_arg;
|
|
220
|
+
|
|
221
|
+
static VALUE
|
|
222
|
+
ca_select_new_alloc (VALUE varg)
|
|
223
|
+
{
|
|
224
|
+
ca_select_new_arg *a = (ca_select_new_arg *) varg;
|
|
225
|
+
a->ca = ALLOC(CASelect);
|
|
226
|
+
return Qnil;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
static VALUE
|
|
230
|
+
ca_select_new_setup (VALUE varg)
|
|
231
|
+
{
|
|
232
|
+
ca_select_new_arg *a = (ca_select_new_arg *) varg;
|
|
233
|
+
ca_select_setup(a->ca, a->parent, a->snapshot);
|
|
234
|
+
return Qnil;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* The struct and the indices are allocated after the snapshot. When the
|
|
238
|
+
struct cannot be allocated the snapshot goes; when the indices cannot,
|
|
239
|
+
the struct goes and takes the snapshot with it (the setup stores the
|
|
240
|
+
snapshot before it allocates the indices). */
|
|
210
241
|
CArray *
|
|
211
242
|
ca_select_new (CArray *parent, CArray *select)
|
|
212
243
|
{
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
244
|
+
ca_select_new_arg a;
|
|
245
|
+
a.parent = parent;
|
|
246
|
+
a.snapshot = ca_select_snapshot(select);
|
|
247
|
+
/* check: the setup checks nothing */
|
|
248
|
+
ca_fill_or_free(a.snapshot, ca_select_new_alloc, (VALUE) &a);
|
|
249
|
+
ca_fill_or_free((CArray *) a.ca, ca_select_new_setup, (VALUE) &a);
|
|
250
|
+
return (CArray*) a.ca;
|
|
217
251
|
}
|
|
218
252
|
|
|
219
253
|
/* Alias for source compatibility. Both constructors produce a
|
|
@@ -431,7 +465,7 @@ ca_select_func_allocate (void *ap)
|
|
|
431
465
|
if ( ! ca_parent_lends_no_memory(ca->parent) ) {
|
|
432
466
|
ca_attach(ca->parent);
|
|
433
467
|
}
|
|
434
|
-
ca->ptr =
|
|
468
|
+
ca->ptr = ca_alloc_cells((CArray *) ca);
|
|
435
469
|
}
|
|
436
470
|
|
|
437
471
|
static void
|
data/ext/ca_obj_select_axis.c
CHANGED
|
@@ -311,6 +311,7 @@ ca_select_axis_new (CArray *parent, int8_t indirect_axis,
|
|
|
311
311
|
CArray *selector,
|
|
312
312
|
ca_size_t *ap_start, ca_size_t *ap_count, ca_size_t *ap_step)
|
|
313
313
|
{
|
|
314
|
+
/* check: the callers (clone, create_mask) pass an existing view's checked selector */
|
|
314
315
|
CASelectAxis *ca = (CASelectAxis *) ca_array_alloc(CA_OBJ_SELECT_AXIS, parent->ndim);
|
|
315
316
|
ca_select_axis_setup(ca, parent, indirect_axis, selector,
|
|
316
317
|
ap_start, ap_count, ap_step);
|
|
@@ -590,6 +591,7 @@ ca_select_axis_func_xfer_stride (void *ap, ca_size_t *starts, ca_size_t *counts,
|
|
|
590
591
|
ca_size_t idx[CA_RANK_MAX], doff = 0, base = 0;
|
|
591
592
|
for (k = 0; k < ndim; k++) base += starts[k] * cnative[k];
|
|
592
593
|
for (k = 0; k < ndim; k++) idx[k] = 0;
|
|
594
|
+
/* empty: the slot returns on an empty region at its entry */
|
|
593
595
|
while (1) {
|
|
594
596
|
ca_size_t coff = base, cidx[CA_RANK_MAX];
|
|
595
597
|
for (k = 0; k < ndim; k++) coff += idx[k] * strides[k];
|
|
@@ -673,6 +675,7 @@ ca_select_axis_func_xfer_stride (void *ap, ca_size_t *starts, ca_size_t *counts,
|
|
|
673
675
|
ca_xfer_stride/ca_xfer_addrs. */
|
|
674
676
|
for (k = 0; k < ndim; k++) o[k] = 0;
|
|
675
677
|
|
|
678
|
+
/* empty: the slot returns on an empty region at its entry */
|
|
676
679
|
while (1) {
|
|
677
680
|
ca_size_t pbase = 0, doff = 0;
|
|
678
681
|
for (k = 0; k < inner; k++) {
|
|
@@ -725,7 +728,7 @@ ca_select_axis_func_allocate (void *ap)
|
|
|
725
728
|
if ( ! ca_parent_lends_no_memory(ca->parent) ) {
|
|
726
729
|
ca_attach(ca->parent);
|
|
727
730
|
}
|
|
728
|
-
ca->ptr =
|
|
731
|
+
ca->ptr = ca_alloc_cells((CArray *) ca);
|
|
729
732
|
}
|
|
730
733
|
|
|
731
734
|
static void
|
|
@@ -895,6 +898,7 @@ rb_ca_select_axis_s_new_debug (VALUE klass, VALUE rparent, VALUE rindirect,
|
|
|
895
898
|
VALUE rap_count, VALUE rap_step)
|
|
896
899
|
{
|
|
897
900
|
CArray *parent, *selector;
|
|
901
|
+
/* fits: an axis number from the view that made it */
|
|
898
902
|
int8_t indirect_axis = (int8_t) NUM2INT(rindirect);
|
|
899
903
|
int8_t ndim;
|
|
900
904
|
int8_t k;
|
|
@@ -966,15 +970,15 @@ rb_ca_select_axis_eligible_p (int argc, VALUE *argv, VALUE self)
|
|
|
966
970
|
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
967
971
|
if ( argc != ca->ndim ) return 0;
|
|
968
972
|
|
|
969
|
-
/* axis 0 is the boolean (indirect).
|
|
973
|
+
/* axis 0 is the boolean (indirect). The rest are read as the indexer
|
|
974
|
+
reads them; a run of more than one step, or of no cells, goes to
|
|
975
|
+
CAGrid. */
|
|
970
976
|
for ( i = 1; i < argc; i++ ) {
|
|
971
977
|
VALUE arg = argv[i];
|
|
972
|
-
|
|
973
|
-
if (
|
|
974
|
-
|
|
975
|
-
if (
|
|
976
|
-
if ( rb_obj_is_kind_of(arg, rb_cInteger) ) continue;
|
|
977
|
-
return 0;
|
|
978
|
+
ca_size_t start, count, step;
|
|
979
|
+
if ( rb_obj_is_carray(arg) ) return 0; /* CArray at axis > 0 → bail */
|
|
980
|
+
ca_index_axis_key(arg, ca->dim[i], i, &start, &count, &step);
|
|
981
|
+
if ( step != 1 || count < 1 ) return 0;
|
|
978
982
|
}
|
|
979
983
|
|
|
980
984
|
return 1;
|
|
@@ -1006,45 +1010,9 @@ rb_ca_select_axis (int argc, VALUE *argv, VALUE self)
|
|
|
1006
1010
|
for ( i = 0; i < argc; i++ ) {
|
|
1007
1011
|
VALUE arg = argv[i];
|
|
1008
1012
|
|
|
1009
|
-
if (
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
ap_step[i] = 1;
|
|
1013
|
-
}
|
|
1014
|
-
else if ( FIXNUM_P(arg) || rb_obj_is_kind_of(arg, rb_cInteger) ) {
|
|
1015
|
-
ca_size_t n = NUM2LL(arg);
|
|
1016
|
-
if ( n < 0 ) n += parent->dim[i];
|
|
1017
|
-
if ( n < 0 || n >= parent->dim[i] ) {
|
|
1018
|
-
rb_raise(rb_eIndexError,
|
|
1019
|
-
"CASelectAxis: index %lld out of range at axis %d",
|
|
1020
|
-
(long long) n, i);
|
|
1021
|
-
}
|
|
1022
|
-
ap_start[i] = n;
|
|
1023
|
-
ap_count[i] = 1;
|
|
1024
|
-
ap_step[i] = 1;
|
|
1025
|
-
}
|
|
1026
|
-
else if ( rb_obj_is_kind_of(arg, rb_cRange) ) {
|
|
1027
|
-
VALUE rfirst = rb_funcall(arg, rb_intern("first"), 0);
|
|
1028
|
-
VALUE rlast = rb_funcall(arg, rb_intern("last"), 0);
|
|
1029
|
-
int exclusive = RTEST(rb_funcall(arg, rb_intern("exclude_end?"), 0));
|
|
1030
|
-
ca_size_t a = NUM2LL(rfirst);
|
|
1031
|
-
ca_size_t b = NUM2LL(rlast);
|
|
1032
|
-
if ( a < 0 ) a += parent->dim[i];
|
|
1033
|
-
if ( b < 0 ) b += parent->dim[i];
|
|
1034
|
-
ca_size_t cnt = exclusive ? (b - a) : (b - a + 1);
|
|
1035
|
-
if ( cnt <= 0 ) {
|
|
1036
|
-
rb_raise(rb_eIndexError,
|
|
1037
|
-
"CASelectAxis: empty range at axis %d", i);
|
|
1038
|
-
}
|
|
1039
|
-
if ( a < 0 || a >= parent->dim[i] ||
|
|
1040
|
-
(a + cnt - 1) < 0 || (a + cnt - 1) >= parent->dim[i] ) {
|
|
1041
|
-
rb_raise(rb_eIndexError,
|
|
1042
|
-
"CASelectAxis: range [%lld..%lld] out of bounds at axis %d",
|
|
1043
|
-
(long long) a, (long long) (a + cnt - 1), i);
|
|
1044
|
-
}
|
|
1045
|
-
ap_start[i] = a;
|
|
1046
|
-
ap_count[i] = cnt;
|
|
1047
|
-
ap_step[i] = 1;
|
|
1013
|
+
if ( ! rb_obj_is_carray(arg) ) {
|
|
1014
|
+
ca_index_axis_key(arg, parent->dim[i], i,
|
|
1015
|
+
&ap_start[i], &ap_count[i], &ap_step[i]);
|
|
1048
1016
|
}
|
|
1049
1017
|
else if ( rb_obj_is_carray(arg) && rb_ca_is_boolean_type(arg) ) {
|
|
1050
1018
|
TypedData_Get_Struct(arg, CArray, &carray_data_type, selector);
|