carray 2.0.1 → 3.0.1
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 +6 -25
- data/CHANGELOG.md +338 -0
- data/{NEWS.md → CHANGELOG.v1.md} +3 -0
- data/LICENSE +1 -1
- data/README.md +120 -36
- data/carray.gemspec +32 -30
- data/ext/ca_array_pool.c +91 -0
- data/ext/ca_axis_descriptor.h +186 -0
- data/ext/ca_axis_dispatch.c +924 -0
- data/ext/ca_axis_group.c +1244 -0
- data/ext/ca_bincmp_dispatch.c +76 -0
- data/ext/ca_bincmp_dispatch.h +85 -0
- data/ext/ca_binop_dispatch.c +124 -0
- data/ext/ca_binop_dispatch.h +152 -0
- data/ext/ca_categorical_iterator.c +1375 -0
- data/ext/ca_compare.c +94 -0
- data/ext/ca_compare.h +26 -0
- data/ext/ca_composite_dispatch.c +414 -0
- data/ext/ca_composite_dispatch.h +116 -0
- data/ext/ca_for_buffer.h +96 -0
- data/ext/ca_for_each_element.h +239 -0
- data/ext/ca_group_iter.c +304 -0
- data/ext/ca_iter_substrate.h +325 -0
- data/ext/ca_kernel_iterator.c +4367 -0
- data/ext/ca_kernel_iterator.h +2596 -0
- data/ext/ca_moncmp_dispatch.c +37 -0
- data/ext/ca_moncmp_dispatch.h +62 -0
- data/ext/ca_monop_dispatch.c +200 -0
- data/ext/ca_monop_dispatch.h +235 -0
- data/ext/ca_obj_array.c +355 -359
- data/ext/ca_obj_bincmp.c +839 -0
- data/ext/ca_obj_binop.c +948 -0
- data/ext/ca_obj_bitarray.c +369 -164
- data/ext/ca_obj_bitfield.c +294 -234
- data/ext/ca_obj_block.c +189 -711
- data/ext/ca_obj_byte_swap.c +766 -0
- data/ext/ca_obj_const_string.c +967 -0
- data/ext/ca_obj_face.c +750 -0
- data/ext/ca_obj_face.h +279 -0
- data/ext/ca_obj_fake.c +239 -100
- data/ext/ca_obj_farray.c +54 -441
- data/ext/ca_obj_field.c +82 -529
- data/ext/ca_obj_fixlen_string.c +308 -0
- data/ext/ca_obj_grid.c +866 -440
- data/ext/ca_obj_meld.c +1039 -0
- data/ext/ca_obj_moncmp.c +588 -0
- data/ext/ca_obj_monop.c +1123 -0
- data/ext/ca_obj_object.c +866 -296
- data/ext/ca_obj_record.c +470 -0
- data/ext/ca_obj_reduce.c +97 -82
- data/ext/ca_obj_refer.c +593 -459
- data/ext/ca_obj_remap.c +475 -0
- data/ext/ca_obj_repeat.c +92 -477
- data/ext/ca_obj_roll.c +624 -0
- data/ext/ca_obj_select.c +344 -296
- data/ext/ca_obj_select_axis.c +1306 -0
- data/ext/ca_obj_shift.c +231 -793
- data/ext/ca_obj_source.c +78 -0
- data/ext/ca_obj_stack.c +1173 -0
- data/ext/ca_obj_stride.c +2584 -0
- data/ext/ca_obj_string.c +270 -0
- data/ext/ca_obj_tile.c +622 -0
- data/ext/ca_obj_time.c +548 -0
- data/ext/ca_obj_timedelta.c +437 -0
- data/ext/ca_obj_transpose.c +62 -516
- data/ext/ca_obj_triop.c +785 -0
- data/ext/ca_obj_window.c +1202 -565
- data/ext/ca_op_byte_swap.c +175 -0
- data/ext/ca_op_cmplx64.h +123 -0
- data/ext/ca_op_ipower.c +316 -0
- data/ext/ca_op_powi.h +88 -0
- data/ext/ca_sort_kernels.h +132 -0
- data/ext/ca_sweep_engine.c +473 -0
- data/ext/ca_sweep_engine.h +166 -0
- data/ext/ca_transform_common.c +235 -0
- data/ext/ca_triop_dispatch.c +55 -0
- data/ext/ca_triop_dispatch.h +62 -0
- data/ext/carray.h +810 -420
- data/ext/carray_access.c +873 -731
- data/ext/carray_attribute.c +98 -329
- data/ext/carray_bincount.c +255 -0
- data/ext/carray_broadcast.c +376 -0
- data/ext/carray_build_flags.h +3 -0
- data/ext/carray_call_cfunc.c +2897 -874
- data/ext/carray_call_cfunc.h +313 -0
- data/ext/carray_cast.c +1264 -315
- data/ext/carray_cast_func.rb +81 -40
- data/ext/carray_class.c +53 -63
- data/ext/carray_config.h +28 -0
- data/ext/carray_conversion.c +350 -346
- data/ext/carray_copy.c +168 -270
- data/ext/carray_core.c +1396 -206
- data/ext/carray_count.c +312 -0
- data/ext/carray_data_type.c +43 -19
- data/ext/carray_element.c +585 -213
- data/ext/carray_factorize.c +2542 -0
- data/ext/carray_generate.c +230 -559
- data/ext/carray_histogram.c +490 -0
- data/ext/carray_hold.c +228 -0
- data/ext/carray_index_classifier.c +1021 -0
- data/ext/carray_index_classifier.h +27 -0
- data/ext/carray_internal.h +136 -0
- data/ext/carray_kernels_bincmp.c +4446 -0
- data/ext/carray_kernels_binop.c +11001 -0
- data/ext/carray_kernels_init.c +1131 -0
- data/ext/carray_kernels_map.c +3467 -0
- data/ext/carray_kernels_moncmp.c +2097 -0
- data/ext/carray_kernels_monop.c +18313 -0
- data/ext/carray_kernels_reduce_aggregate.c +25837 -0
- data/ext/carray_kernels_reduce_boolean.c +330 -0
- data/ext/carray_kernels_reduce_cumulative.c +14593 -0
- data/ext/carray_kernels_reduce_extreme.c +16948 -0
- data/ext/carray_kernels_reduce_variance.c +3910 -0
- data/ext/carray_kernels_scan.c +3693 -0
- data/ext/carray_kernels_search.c +32138 -0
- data/ext/carray_kernels_sort.c +10626 -0
- data/ext/carray_kernels_triop.c +1392 -0
- data/ext/carray_lazy.c +737 -0
- data/ext/carray_loop.c +88 -200
- data/ext/carray_mask.c +853 -158
- data/ext/carray_math_kernel.h +120 -0
- data/ext/carray_mathfunc.c +10 -241
- data/ext/carray_median_percentile.c +1257 -0
- data/ext/carray_memory_view.c +1650 -0
- data/ext/carray_operator.c +1525 -320
- data/ext/carray_order.c +664 -1394
- data/ext/carray_partition.c +416 -0
- data/ext/carray_random.c +518 -0
- data/ext/carray_scatter.c +357 -0
- data/ext/carray_slab.c +1219 -0
- data/ext/carray_slab.h +84 -0
- data/ext/carray_sort.c +829 -0
- data/ext/carray_sort_kernel.c +620 -0
- data/ext/carray_struct.c +695 -0
- data/ext/carray_test.c +343 -229
- data/ext/carray_undef.c +34 -17
- data/ext/carray_utils.c +175 -74
- data/ext/extconf.rb +234 -55
- data/ext/mk_call_cfunc.rb +671 -0
- data/ext/mkkernel.rb +9096 -0
- data/ext/ruby_carray.c +211 -108
- data/ext/version.h +4 -14
- data/ext/version.rb +5 -13
- data/lib/carray/arrow_tensor.rb +401 -0
- data/lib/carray/attribute.rb +166 -0
- data/lib/carray/autoload_carray.rb +239 -0
- data/lib/carray/autoload_method_extension.rb +45 -0
- data/lib/carray/axis_group.rb +711 -0
- data/lib/carray/basics.rb +481 -0
- data/lib/carray/bincount_nd.rb +358 -0
- data/lib/carray/block_iterator.rb +614 -0
- data/lib/carray/boolean_reduce.rb +109 -0
- data/lib/carray/categorical.rb +561 -0
- data/lib/carray/categorical_iterator.rb +1084 -0
- data/lib/carray/complex.rb +150 -0
- data/lib/carray/conditional.rb +216 -0
- data/lib/carray/const_string.rb +228 -0
- data/lib/carray/construct.rb +160 -328
- data/lib/carray/core_extensions.rb +297 -0
- data/lib/carray/data_type_extension.rb +250 -0
- data/lib/carray/fixlen_string.rb +95 -0
- data/lib/carray/frame/concat.rb +132 -0
- data/lib/carray/frame/convert.rb +95 -0
- data/lib/carray/frame/csv_parser.rb +211 -0
- data/lib/carray/frame/frame.rb +642 -0
- data/lib/carray/frame/group.rb +186 -0
- data/lib/carray/frame/io.rb +321 -0
- data/lib/carray/frame/join.rb +248 -0
- data/lib/carray/frame/records.rb +99 -0
- data/lib/carray/frame/sort.rb +113 -0
- data/lib/carray/frame/verbs.rb +316 -0
- data/lib/carray/frame.rb +16 -0
- data/lib/carray/fuse_source.rb +123 -0
- data/lib/carray/fusion.rb +218 -0
- data/lib/carray/histogram.rb +512 -0
- data/lib/carray/inspect.rb +37 -26
- data/lib/carray/iterator.rb +58 -349
- data/lib/carray/lazy.rb +941 -0
- data/lib/carray/mask_gap_fill.rb +200 -0
- data/lib/carray/math.rb +78 -342
- data/lib/carray/meld_reduce.rb +289 -0
- data/lib/carray/methods/align_addr.rb +116 -0
- data/lib/carray/methods/bin.rb +128 -0
- data/lib/carray/methods/bincount.rb +87 -0
- data/lib/carray/methods/bit_string.rb +92 -0
- data/lib/carray/methods/broadcast.rb +63 -0
- data/lib/carray/methods/choose.rb +39 -0
- data/lib/carray/methods/composition.rb +280 -0
- data/lib/carray/methods/gather_nd.rb +206 -0
- data/lib/carray/methods/index.rb +39 -0
- data/lib/carray/methods/insert_block.rb +99 -0
- data/lib/carray/methods/is_in.rb +141 -0
- data/lib/carray/methods/join.rb +90 -0
- data/lib/carray/methods/locate_addr.rb +52 -0
- data/lib/carray/methods/mask_duplicates.rb +41 -0
- data/lib/carray/methods/meshgrid.rb +90 -0
- data/lib/carray/methods/mode.rb +126 -0
- data/lib/carray/methods/nunique.rb +46 -0
- data/lib/carray/methods/resize.rb +56 -0
- data/lib/carray/methods/snap.rb +161 -0
- data/lib/carray/methods/string_format.rb +57 -0
- data/lib/carray/methods/unique.rb +47 -0
- data/lib/carray/methods/value_counts.rb +71 -0
- data/lib/carray/mkmf.rb +124 -101
- data/lib/carray/runtime.rb +89 -0
- data/lib/carray/serialize.rb +478 -167
- data/lib/carray/slab_iterator.rb +305 -0
- data/lib/carray/stack.rb +291 -0
- data/lib/carray/string.rb +56 -180
- data/lib/carray/string_operation_extension.rb +289 -0
- data/lib/carray/struct.rb +335 -323
- data/lib/carray/struct_builder.rb +697 -0
- data/lib/carray/table.rb +41 -2
- data/lib/carray/time.rb +2654 -38
- data/lib/carray/window_iterator.rb +927 -0
- data/lib/carray.rb +55 -57
- data/yard-stubs/ca_obj_array.rb +385 -0
- data/yard-stubs/ca_obj_bitarray.rb +38 -0
- data/yard-stubs/ca_obj_bitfield.rb +43 -0
- data/yard-stubs/ca_obj_block.rb +73 -0
- data/yard-stubs/ca_obj_byte_swap.rb +56 -0
- data/yard-stubs/ca_obj_fake.rb +31 -0
- data/yard-stubs/ca_obj_farray.rb +32 -0
- data/yard-stubs/ca_obj_field.rb +45 -0
- data/yard-stubs/ca_obj_grid.rb +35 -0
- data/yard-stubs/ca_obj_refer.rb +72 -0
- data/yard-stubs/ca_obj_roll.rb +45 -0
- data/yard-stubs/ca_obj_shift.rb +43 -0
- data/yard-stubs/ca_obj_stride.rb +181 -0
- data/yard-stubs/ca_obj_tile.rb +29 -0
- data/yard-stubs/ca_obj_transpose.rb +40 -0
- data/yard-stubs/ca_obj_window.rb +49 -0
- data/yard-stubs/carray_access.rb +131 -0
- data/yard-stubs/carray_attribute.rb +246 -0
- data/yard-stubs/carray_broadcast.rb +37 -0
- data/yard-stubs/carray_cast.rb +489 -0
- data/yard-stubs/carray_class.rb +65 -0
- data/yard-stubs/carray_conversion.rb +76 -0
- data/yard-stubs/carray_copy.rb +79 -0
- data/yard-stubs/carray_core.rb +114 -0
- data/yard-stubs/carray_count.rb +79 -0
- data/yard-stubs/carray_element.rb +108 -0
- data/yard-stubs/carray_generate.rb +66 -0
- data/yard-stubs/carray_lazy.rb +23 -0
- data/yard-stubs/carray_loop.rb +140 -0
- data/yard-stubs/carray_mask.rb +259 -0
- data/yard-stubs/carray_math.rb +132 -0
- data/yard-stubs/carray_mathfunc.rb +45 -0
- data/yard-stubs/carray_median_percentile.rb +89 -0
- data/yard-stubs/carray_memory_view.rb +163 -0
- data/yard-stubs/carray_order.rb +312 -0
- data/yard-stubs/carray_random.rb +89 -0
- data/yard-stubs/carray_scatter.rb +106 -0
- data/yard-stubs/carray_slab.rb +57 -0
- data/yard-stubs/carray_sort.rb +163 -0
- data/yard-stubs/carray_test.rb +85 -0
- data/yard-stubs/carray_undef.rb +64 -0
- data/yard-stubs/carray_utils.rb +97 -0
- data/yard-stubs/ruby_carray.rb +193 -0
- metadata +220 -138
- data/Rakefile +0 -51
- data/TODO.md +0 -18
- data/ext/ca_iter_block.c +0 -257
- data/ext/ca_iter_dimension.c +0 -299
- data/ext/ca_iter_window.c +0 -214
- data/ext/ca_obj_mapping.c +0 -644
- data/ext/ca_obj_unbound_repeat.c +0 -529
- data/ext/carray_iterator.c +0 -641
- data/ext/carray_math.rb +0 -850
- data/ext/carray_numeric.c +0 -259
- data/ext/carray_sort_addr.c +0 -254
- data/ext/carray_stat.c +0 -2100
- data/ext/carray_stat_proc.rb +0 -1999
- data/ext/mkmath.rb +0 -741
- data/ext/ruby_ccomplex.c +0 -509
- data/ext/ruby_float_func.c +0 -86
- data/lib/carray/array.rb +0 -8
- data/lib/carray/autoload/autoload_base.rb +0 -19
- data/lib/carray/autoload/autoload_gem_cairo.rb +0 -9
- data/lib/carray/autoload/autoload_gem_ffi.rb +0 -9
- data/lib/carray/autoload/autoload_gem_gnuplot.rb +0 -2
- data/lib/carray/autoload/autoload_gem_io_csv.rb +0 -14
- data/lib/carray/autoload/autoload_gem_io_pg.rb +0 -6
- data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +0 -12
- data/lib/carray/autoload/autoload_gem_narray.rb +0 -10
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +0 -15
- data/lib/carray/autoload/autoload_gem_opencv.rb +0 -16
- data/lib/carray/autoload/autoload_gem_random.rb +0 -8
- data/lib/carray/autoload/autoload_gem_rmagick.rb +0 -23
- data/lib/carray/autoload/autoload_gem_zimg.rb +0 -3
- data/lib/carray/autoload/autoload_io_imagemagick.rb +0 -6
- data/lib/carray/autoload/autoload_math_histogram.rb +0 -5
- data/lib/carray/autoload/autoload_math_recurrence.rb +0 -6
- data/lib/carray/autoload/autoload_object_iterator.rb +0 -1
- data/lib/carray/autoload/autoload_object_link.rb +0 -1
- data/lib/carray/autoload/autoload_object_pack.rb +0 -2
- data/lib/carray/autoload.rb +0 -141
- data/lib/carray/basic.rb +0 -191
- data/lib/carray/broadcast.rb +0 -101
- data/lib/carray/compose.rb +0 -315
- data/lib/carray/convert.rb +0 -115
- data/lib/carray/info.rb +0 -110
- data/lib/carray/io/imagemagick.rb +0 -235
- data/lib/carray/mask.rb +0 -102
- data/lib/carray/math/histogram.rb +0 -177
- data/lib/carray/math/recurrence.rb +0 -93
- data/lib/carray/object/ca_obj_iterator.rb +0 -50
- data/lib/carray/object/ca_obj_link.rb +0 -50
- data/lib/carray/object/ca_obj_pack.rb +0 -99
- data/lib/carray/obsolete.rb +0 -256
- data/lib/carray/ordering.rb +0 -181
- data/lib/carray/testing.rb +0 -51
- data/lib/carray/transform.rb +0 -109
- data/mailmap +0 -1
- data/misc/Methods.ja.md +0 -182
- data/misc/NOTE +0 -51
- data/spec/Classes/CABitfield_spec.rb +0 -58
- data/spec/Classes/CABlockIterator_spec.rb +0 -114
- data/spec/Classes/CABlock_spec.rb +0 -205
- data/spec/Classes/CAField_spec.rb +0 -39
- data/spec/Classes/CAGrid_spec.rb +0 -75
- data/spec/Classes/CAMap_spec.rb +0 -0
- data/spec/Classes/CAMapping_spec.rb +0 -105
- data/spec/Classes/CAObject_attribute_spec.rb +0 -33
- data/spec/Classes/CAObject_spec.rb +0 -33
- data/spec/Classes/CARefer_spec.rb +0 -93
- data/spec/Classes/CARepeat_spec.rb +0 -65
- data/spec/Classes/CASelect_spec.rb +0 -22
- data/spec/Classes/CAShift_spec.rb +0 -16
- data/spec/Classes/CAStruct_spec.rb +0 -71
- data/spec/Classes/CATranspose_spec.rb +0 -60
- data/spec/Classes/CAUnboudRepeat_spec.rb +0 -102
- data/spec/Classes/CAWindow_spec.rb +0 -54
- data/spec/Classes/CAWrap_spec.rb +0 -8
- data/spec/Classes/CArray_spec.rb +0 -184
- data/spec/Classes/CScalar_spec.rb +0 -55
- data/spec/Features/feature_130_spec.rb +0 -19
- data/spec/Features/feature_attributes_spec.rb +0 -280
- data/spec/Features/feature_boolean_spec.rb +0 -98
- data/spec/Features/feature_broadcast.rb +0 -116
- data/spec/Features/feature_cast_function.rb +0 -19
- data/spec/Features/feature_cast_spec.rb +0 -33
- data/spec/Features/feature_class_spec.rb +0 -84
- data/spec/Features/feature_complex_spec.rb +0 -42
- data/spec/Features/feature_composite_spec.rb +0 -124
- data/spec/Features/feature_convert_spec.rb +0 -46
- data/spec/Features/feature_copy_spec.rb +0 -123
- data/spec/Features/feature_creation_spec.rb +0 -84
- data/spec/Features/feature_element_spec.rb +0 -144
- data/spec/Features/feature_extream_spec.rb +0 -54
- data/spec/Features/feature_generate_spec.rb +0 -74
- data/spec/Features/feature_index_spec.rb +0 -69
- data/spec/Features/feature_mask_spec.rb +0 -580
- data/spec/Features/feature_math_spec.rb +0 -97
- data/spec/Features/feature_order_spec.rb +0 -146
- data/spec/Features/feature_ref_store_spec.rb +0 -209
- data/spec/Features/feature_serialization_spec.rb +0 -125
- data/spec/Features/feature_stat_spec.rb +0 -397
- data/spec/Features/feature_virtual_spec.rb +0 -48
- data/spec/Features/method_eq_spec.rb +0 -81
- data/spec/Features/method_is_nan_spec.rb +0 -12
- data/spec/Features/method_map_spec.rb +0 -54
- data/spec/Features/method_max_with.rb +0 -20
- data/spec/Features/method_min_with.rb +0 -19
- data/spec/Features/method_ne_spec.rb +0 -18
- data/spec/Features/method_project_spec.rb +0 -188
- data/spec/Features/method_ref_spec.rb +0 -27
- data/spec/Features/method_round_spec.rb +0 -11
- data/spec/Features/method_s_linspace_spec.rb +0 -48
- data/spec/Features/method_s_span_spec.rb +0 -14
- data/spec/Features/method_seq_spec.rb +0 -47
- data/spec/Features/method_sort_with.rb +0 -43
- data/spec/Features/method_sorted_with.rb +0 -29
- data/spec/Features/method_span_spec.rb +0 -42
- data/spec/Features/method_wrap_readonly_spec.rb +0 -43
- data/spec/UnitTest/test_CAVirtual.rb +0 -214
- data/spec/spec_all.rb +0 -10
- data/utils/ca_ase.rb +0 -21
- data/utils/ca_methods.rb +0 -15
- data/utils/cast_checker.rb +0 -30
- data/utils/convert_test.rb +0 -73
- data/utils/extract_yard.rb +0 -22
- data/utils/guess_shape.rb +0 -76
- data/utils/monkey_patch_methods.rb +0 -62
- data/utils/remove_resource_fork.sh +0 -5
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CAByteSwap and CArray#swap_bytes / #endian defined in
|
|
3
|
+
# ext/ca_obj_byte_swap.c.
|
|
4
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
5
|
+
|
|
6
|
+
# Byte-order-reversed view of the parent. Same shape and byte
|
|
7
|
+
# width as the parent; each cell exposes the byte-reversed
|
|
8
|
+
# interpretation. For primitive numeric parents `CArray#swap_bytes`
|
|
9
|
+
# routes through `CAMonOp` instead, so a CAByteSwap instance is
|
|
10
|
+
# usually seen only for `CA_FIXLEN` parents.
|
|
11
|
+
#
|
|
12
|
+
# Writes through the view flow back to the parent on detach
|
|
13
|
+
# (byte-swap is involutive).
|
|
14
|
+
class CAByteSwap < CAView
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class CArray
|
|
18
|
+
# @!group Views
|
|
19
|
+
|
|
20
|
+
# Returns a lazy view of `self` whose cells are byte-swapped
|
|
21
|
+
# versions of the parent cells. Materialises on attach.
|
|
22
|
+
# Primitive numeric parents get a `CAMonOp` view; `CA_FIXLEN`
|
|
23
|
+
# parents (with or without a data_class) get a {CAByteSwap} view.
|
|
24
|
+
#
|
|
25
|
+
# For eager copy semantics use `arr.swap_bytes.to_ca`. The
|
|
26
|
+
# in-place idiom is `ca[] = ca.swap_bytes`; there is no
|
|
27
|
+
# `swap_bytes!`.
|
|
28
|
+
#
|
|
29
|
+
# @overload swap_bytes
|
|
30
|
+
# @return [CArray] byte-swapped view of `self`.
|
|
31
|
+
# @raise [CADataTypeError] when `self.data_type` is `CA_OBJECT`
|
|
32
|
+
# (object arrays cannot be byte-swapped).
|
|
33
|
+
def swap_bytes; end
|
|
34
|
+
|
|
35
|
+
# Returns a view of `self` in the requested byte order.
|
|
36
|
+
#
|
|
37
|
+
# `byte_order` is one of:
|
|
38
|
+
# - `:preserve` / `:native` — identity, since CArrays are stored
|
|
39
|
+
# host-endian.
|
|
40
|
+
# - `:big` — identity on big-endian hosts, otherwise a byte-swap
|
|
41
|
+
# view.
|
|
42
|
+
# - `:little` — identity on little-endian hosts, otherwise a
|
|
43
|
+
# byte-swap view.
|
|
44
|
+
#
|
|
45
|
+
# The keyword set matches `BulkMemoryView.from(producer, endian:)`.
|
|
46
|
+
#
|
|
47
|
+
# @overload endian(byte_order)
|
|
48
|
+
# @param byte_order [Symbol] one of `:preserve`, `:native`,
|
|
49
|
+
# `:big`, `:little`.
|
|
50
|
+
# @return [CArray] `self` or a byte-swap view.
|
|
51
|
+
# @raise [ArgumentError] when `byte_order` is not one of the
|
|
52
|
+
# accepted symbols.
|
|
53
|
+
def endian(byte_order); end
|
|
54
|
+
|
|
55
|
+
# @!endgroup
|
|
56
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for methods defined in ext/ca_obj_fake.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# CAFace-family data_type reinterpret view. Presents its parent with a
|
|
6
|
+
# different `data_type` (and, for `:fixlen`, a different `bytes`);
|
|
7
|
+
# reads and writes cast on the fly. Storage is shared with the
|
|
8
|
+
# parent.
|
|
9
|
+
class CAFake < CAView
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class CArray
|
|
13
|
+
# @!group Views
|
|
14
|
+
# @overload fake(data_type, bytes: 0)
|
|
15
|
+
# Returns a {CAFake} view of `self` whose element type is
|
|
16
|
+
# `data_type` (and `bytes:` for `:fixlen`). Reads and writes go
|
|
17
|
+
# through the cast table, so the returned view shares storage
|
|
18
|
+
# with `self` but exposes it under a different data_type.
|
|
19
|
+
# A Face refuses: its cells do not mean their storage bytes, so
|
|
20
|
+
# reading them under another type hands back what the surface exists to
|
|
21
|
+
# hide. Use {CArray#to_type} for the values, or `face.parent.fake` to
|
|
22
|
+
# reinterpret the storage on purpose. A Numeric Face, whose surface *is*
|
|
23
|
+
# its storage, is unaffected.
|
|
24
|
+
# @param data_type [Symbol, Integer, Class, String]
|
|
25
|
+
# @param bytes [Integer] element byte size for `:fixlen`.
|
|
26
|
+
# @return [CAFake]
|
|
27
|
+
# @raise [TypeError] when `self` is a Face and the request would read its
|
|
28
|
+
# storage under another type.
|
|
29
|
+
def fake(data_type, bytes: 0); end
|
|
30
|
+
# @!endgroup
|
|
31
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CAFarray and CArray#farray defined in ext/ca_obj_farray.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# Column-major (Fortran-order) view of a row-major parent. Pure
|
|
6
|
+
# `CAStride` typedef: the parent's bytes are reread with dimension
|
|
7
|
+
# order reversed (`view.shape[k] == parent.shape[ndim-1-k]`). No
|
|
8
|
+
# data is copied; writes go through to the parent.
|
|
9
|
+
class CAFarray < CAStride
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Mask companion of {CAFarray}.
|
|
13
|
+
# @private
|
|
14
|
+
class CAFarrayMask < CAFarray
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class CArray
|
|
18
|
+
# @!group Views
|
|
19
|
+
|
|
20
|
+
# @overload farray
|
|
21
|
+
# Returns a {CAFarray} view of `self` that exposes the same memory
|
|
22
|
+
# in column-major (Fortran) order. The shape is `self.shape`
|
|
23
|
+
# reversed; element `view[i_0, ..., i_{n-1}]` aliases parent
|
|
24
|
+
# element `self[i_{n-1}, ..., i_0]`.
|
|
25
|
+
#
|
|
26
|
+
# Useful for interop with column-major consumers (LAPACK, Fortran
|
|
27
|
+
# libraries) without copying.
|
|
28
|
+
# @return [CAFarray]
|
|
29
|
+
def farray; end
|
|
30
|
+
|
|
31
|
+
# @!endgroup
|
|
32
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CArray#field defined in ext/ca_obj_field.c. The CAField
|
|
3
|
+
# class shell lives in yard-stubs/ruby_carray.rb.
|
|
4
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
5
|
+
|
|
6
|
+
class CArray
|
|
7
|
+
# @!group Views
|
|
8
|
+
|
|
9
|
+
# @overload field(offset, data_type, bytes: nil)
|
|
10
|
+
# Returns a {CAField} view of one field of a fixlen-record `self`.
|
|
11
|
+
# The view has the same shape as `self`; each element is the
|
|
12
|
+
# `bytes`-wide slice of element type `data_type` at byte `offset`
|
|
13
|
+
# within the corresponding record. No data is copied; writes go
|
|
14
|
+
# through to `self`.
|
|
15
|
+
# @param offset [Integer] byte offset of the field within one record.
|
|
16
|
+
# @param data_type [Symbol, Integer] element type symbol or constant.
|
|
17
|
+
# `:object` is not allowed.
|
|
18
|
+
# @param bytes [Integer, nil] element size; required for `:fixlen`,
|
|
19
|
+
# inferred otherwise.
|
|
20
|
+
# @return [CAField]
|
|
21
|
+
# @raise [RuntimeError] when `offset` is negative or the
|
|
22
|
+
# `offset + bytes` window falls outside one parent record.
|
|
23
|
+
# @overload field(offset, template)
|
|
24
|
+
# Returns a CARefer over a {CAField}: takes `template.elements *
|
|
25
|
+
# template.bytes` bytes at `offset` and exposes them with
|
|
26
|
+
# `template`'s element type and trailing shape.
|
|
27
|
+
# @param offset [Integer]
|
|
28
|
+
# @param template [CArray] element type and trailing shape donor.
|
|
29
|
+
# @return [CArray]
|
|
30
|
+
# @overload field(offset, data_class)
|
|
31
|
+
# Returns a `CARecord` wrapping a {CAField} so the result carries
|
|
32
|
+
# `data_class`'s encode/decode dispatch.
|
|
33
|
+
# @param offset [Integer]
|
|
34
|
+
# @param data_class [Class] e.g. a CAStruct subclass.
|
|
35
|
+
# @return [CArray]
|
|
36
|
+
# @overload field(name)
|
|
37
|
+
# Returns the field named `name`. Delegates to the parent's Face
|
|
38
|
+
# layer (`rb_ca_face_field`); resolution depends on the record
|
|
39
|
+
# schema attached to `self`.
|
|
40
|
+
# @param name [Symbol, String]
|
|
41
|
+
# @return [CArray]
|
|
42
|
+
def field(*); end
|
|
43
|
+
|
|
44
|
+
# @!endgroup
|
|
45
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for methods defined in ext/ca_obj_grid.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
#
|
|
5
|
+
# CAGrid itself is an internal (:nodoc:) view class; only the CArray#grid
|
|
6
|
+
# entry point is user-facing.
|
|
7
|
+
|
|
8
|
+
class CArray
|
|
9
|
+
# @!group Views
|
|
10
|
+
# @overload grid(*selectors)
|
|
11
|
+
# Returns a coordinate-selected view of `self`: one selector per
|
|
12
|
+
# axis picks a set of parent indices along that axis, and the view
|
|
13
|
+
# is their Cartesian product. The output size along axis `k` is the
|
|
14
|
+
# number of indices selected for that axis.
|
|
15
|
+
#
|
|
16
|
+
# Each selector is one of:
|
|
17
|
+
# - `nil` — the whole axis, in order.
|
|
18
|
+
# - an integer `Range` — a contiguous sub-range along the axis.
|
|
19
|
+
# - a `CArray` of integer indices — gather exactly those parent
|
|
20
|
+
# indices (arbitrary order; duplicates produce duplicated cells).
|
|
21
|
+
# - a boolean `CArray` — the indices where it is true.
|
|
22
|
+
#
|
|
23
|
+
# A masked index `CArray` selects only its not-masked cells. The
|
|
24
|
+
# view is writable; scattering back to overlapping cells (from
|
|
25
|
+
# duplicate indices) is last-write-wins.
|
|
26
|
+
#
|
|
27
|
+
# @param selectors [Array<nil, Range, CArray>] one selector per axis.
|
|
28
|
+
# @return [CArray] the grid view.
|
|
29
|
+
# @raise [ArgumentError] when more selectors than `ndim` are given.
|
|
30
|
+
# @raise [IndexError] when a selected index is out of range.
|
|
31
|
+
# @raise [RuntimeError] when a selector is a plain Ruby `Array`
|
|
32
|
+
# (not supported; pass a CArray of indices instead).
|
|
33
|
+
def grid(*selectors); end
|
|
34
|
+
# @!endgroup
|
|
35
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CArray#refer, #reshape, #flatten defined in ext/ca_obj_refer.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
#
|
|
5
|
+
# The CARefer class shell lives in yard-stubs/ruby_carray.rb.
|
|
6
|
+
|
|
7
|
+
class CArray
|
|
8
|
+
# @!group Views
|
|
9
|
+
|
|
10
|
+
# Returns a {CARefer} view of `self` — a strided reinterpretation
|
|
11
|
+
# of the parent's memory. With no arguments the view has the same
|
|
12
|
+
# `data_type`, shape and `bytes` as `self`; the second form
|
|
13
|
+
# accepts a different `data_type` (or a data_class), and optional
|
|
14
|
+
# `bytes:` / `offset:` keywords so the view exposes the parent's
|
|
15
|
+
# bytes as elements of a different width.
|
|
16
|
+
#
|
|
17
|
+
# `bytes:` must divide `parent.bytes` (or vice versa) so element
|
|
18
|
+
# boundaries align. `offset:` is measured in parent elements.
|
|
19
|
+
# The total byte extent of the view must fit inside `self`.
|
|
20
|
+
#
|
|
21
|
+
# When `data_type` is a data_class, the result is wrapped in a
|
|
22
|
+
# `CARecord` so field projection continues to work.
|
|
23
|
+
#
|
|
24
|
+
# @overload refer
|
|
25
|
+
# @return [CARefer] a same-shape same-width alias of `self`.
|
|
26
|
+
# @overload refer(data_type, dim = nil, bytes: nil, offset: 0)
|
|
27
|
+
# @param data_type [Integer, Symbol, Class] target data type or
|
|
28
|
+
# a data_class.
|
|
29
|
+
# @param dim [Array<Integer>, nil] target shape; `nil` reuses
|
|
30
|
+
# `self.shape` (only valid when the byte width is unchanged).
|
|
31
|
+
# @param bytes [Integer, nil] target byte width per element;
|
|
32
|
+
# defaults to `self.bytes`.
|
|
33
|
+
# @param offset [Integer] offset in parent elements.
|
|
34
|
+
# @return [CARefer, CARecord]
|
|
35
|
+
# @raise [RuntimeError] when the byte widths do not divide
|
|
36
|
+
# evenly, when `offset` is negative, or when the requested
|
|
37
|
+
# view extends past the parent's data.
|
|
38
|
+
# @raise [RuntimeError] when reinterpreting a CA_OBJECT parent
|
|
39
|
+
# with a non-object `data_type`.
|
|
40
|
+
def refer(*argv); end
|
|
41
|
+
|
|
42
|
+
# Returns a view of `self` with the requested shape. Element
|
|
43
|
+
# count must match (`-1` or `:~` may stand in for one axis, whose
|
|
44
|
+
# size is inferred); `nil` copies the corresponding axis from
|
|
45
|
+
# `self`. When the reshape can be expressed as strides over
|
|
46
|
+
# `self`'s deepest non-CAStride ancestor, the result is a
|
|
47
|
+
# {CAStride}; otherwise a {CARefer}.
|
|
48
|
+
#
|
|
49
|
+
# @overload reshape(*newdim)
|
|
50
|
+
# @param newdim [Array<Integer, nil, Symbol>] target shape.
|
|
51
|
+
# Integers are axis sizes; `nil` copies from `self` in
|
|
52
|
+
# position order (mirrored from the end after the placeholder);
|
|
53
|
+
# `-1` or `:~` marks the auto-infer placeholder (at most one).
|
|
54
|
+
# @return [CArray] the reshape view.
|
|
55
|
+
# @raise [ArgumentError] when the number of dims exceeds
|
|
56
|
+
# `CA_RANK_MAX`.
|
|
57
|
+
# @raise [RuntimeError] when the product does not equal
|
|
58
|
+
# `self.elements` (with no placeholder), when the placeholder
|
|
59
|
+
# cannot be inferred, when more than one placeholder is
|
|
60
|
+
# given, or when a `nil` has no matching source axis.
|
|
61
|
+
def reshape(*newdim); end
|
|
62
|
+
|
|
63
|
+
# Returns a 1-D view of all cells in row-major order — a
|
|
64
|
+
# {CAStride} when the flatten reduces to pure strides over the
|
|
65
|
+
# deepest ancestor, otherwise a {CARefer}.
|
|
66
|
+
#
|
|
67
|
+
# @overload flatten
|
|
68
|
+
# @return [CArray] the 1-D view.
|
|
69
|
+
def flatten; end
|
|
70
|
+
|
|
71
|
+
# @!endgroup
|
|
72
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CARoll and CArray#roll defined in ext/ca_obj_roll.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# Cyclic-shift view of the parent. Same shape as the parent; each
|
|
6
|
+
# axis `k` is rotated by `shift[k]` cells (modulo `parent.dim[k]`).
|
|
7
|
+
# All parent cells alias through the view exactly once, so writes
|
|
8
|
+
# through the view reach the parent.
|
|
9
|
+
#
|
|
10
|
+
# `CARoll` is a `typedef` of {CATile}: the class hierarchy places it
|
|
11
|
+
# under {CATile}, and the operation table is a copy of `ca_tile_func`
|
|
12
|
+
# with the shift-specific slots overridden.
|
|
13
|
+
class CARoll < CATile
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Mask companion of {CARoll}.
|
|
17
|
+
# @private
|
|
18
|
+
class CARollMask < CARoll
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class CArray
|
|
22
|
+
# @!group Views
|
|
23
|
+
|
|
24
|
+
# Returns a {CARoll} view of `self` cyclically shifted by
|
|
25
|
+
# `shifts[k]` along each axis `k`. Positive shifts move cell `i`
|
|
26
|
+
# of the parent to position `i + shift`; negative shifts move it
|
|
27
|
+
# the other way. Each `shift[k]` is normalised into
|
|
28
|
+
# `[0, self.dim[k])` before use, so any integer is accepted.
|
|
29
|
+
#
|
|
30
|
+
# Fewer args than `ndim` treats the missing axes as `shift = 0`.
|
|
31
|
+
# More args than `ndim` raises `ArgumentError`.
|
|
32
|
+
#
|
|
33
|
+
# The in-place idiom is `ca[] = ca.roll(...)`; there is no `roll!`.
|
|
34
|
+
# For a non-cyclic translation with a fill value use {#shift}.
|
|
35
|
+
#
|
|
36
|
+
# @overload roll(*shifts)
|
|
37
|
+
# @param shifts [Array<Integer>] one shift per axis; may be
|
|
38
|
+
# shorter than `ndim` (missing axes default to `0`).
|
|
39
|
+
# @return [CARoll]
|
|
40
|
+
# @raise [ArgumentError] when more than `ndim` shifts are given.
|
|
41
|
+
# @raise [IndexError] when any parent dimension is non-positive.
|
|
42
|
+
def roll(*shifts); end
|
|
43
|
+
|
|
44
|
+
# @!endgroup
|
|
45
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CAShift and CArray#shift defined in ext/ca_obj_shift.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# Translated view of the parent along each axis. Pure `CAWindow`
|
|
6
|
+
# typedef: only the obj_type tag differs. No data is copied; in-range
|
|
7
|
+
# cells alias the parent, out-of-range cells take the fill value (or are
|
|
8
|
+
# masked).
|
|
9
|
+
class CAShift < CAWindow
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Mask companion of {CAShift}.
|
|
13
|
+
# @private
|
|
14
|
+
class CAShiftMask < CAShift
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class CArray
|
|
18
|
+
# @!group Views
|
|
19
|
+
|
|
20
|
+
# Returns a {CAShift} view of `self` translated by `shifts` along each
|
|
21
|
+
# axis (one shift per dimension; a positive shift moves cell `i` of the
|
|
22
|
+
# parent to position `i + shift`). Out-of-range cells take `fill_value`
|
|
23
|
+
# (default `0`); passing `fill_value: UNDEF` masks them instead of
|
|
24
|
+
# filling. In-range cells alias the parent, so writes through the view
|
|
25
|
+
# reach the parent.
|
|
26
|
+
#
|
|
27
|
+
# The in-place idiom is `ca[] = ca.shift(...)`; there is no `shift!`.
|
|
28
|
+
# For a cyclic (wrap-around) shift use {#roll}, which returns a `CARoll`
|
|
29
|
+
# view.
|
|
30
|
+
#
|
|
31
|
+
# @overload shift(*shifts, fill_value: 0)
|
|
32
|
+
# @param shifts [Array<Integer>] one shift per axis; the count must
|
|
33
|
+
# equal `self.ndim`.
|
|
34
|
+
# @param fill_value [Object] value written to out-of-range cells;
|
|
35
|
+
# `UNDEF` masks them instead.
|
|
36
|
+
# @return [CAShift]
|
|
37
|
+
# @raise [ArgumentError] when the number of shifts does not equal
|
|
38
|
+
# `ndim`, when the removed `:roll` option is given, or when a block
|
|
39
|
+
# is passed (the block form was removed in 3.0).
|
|
40
|
+
def shift(*shifts, fill_value: 0); end
|
|
41
|
+
|
|
42
|
+
# @!endgroup
|
|
43
|
+
end
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CAStride and the CArray view constructors defined in
|
|
3
|
+
# ext/ca_obj_stride.c. See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# Generic strided view of the parent: each cell is addressed as
|
|
6
|
+
# `base_offset + Σ idx[k] * strides[k]` bytes from the parent's buffer, with
|
|
7
|
+
# byte strides that may be negative or zero. That is enough to express axis
|
|
8
|
+
# permutation, reshape, stepped slicing and broadcasting, so most view
|
|
9
|
+
# classes are CAStride subclasses and inherit its behaviour unchanged.
|
|
10
|
+
class CAStride < CAView
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Mask companion of {CAStride}.
|
|
14
|
+
# @private
|
|
15
|
+
class CAStrideMask < CAStride
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class CArray
|
|
19
|
+
# @!group Views
|
|
20
|
+
|
|
21
|
+
# Returns a {CAStride} view of `self` with the given byte strides and
|
|
22
|
+
# starting byte offset, inheriting the receiver's data type and element
|
|
23
|
+
# size. Memory is shared with the receiver.
|
|
24
|
+
#
|
|
25
|
+
# This is a low-level escape hatch: the strides and offset are **not**
|
|
26
|
+
# bounds-checked against the receiver's memory, so a combination that
|
|
27
|
+
# addresses outside it reads or writes past the buffer. Prefer the
|
|
28
|
+
# derived constructors ({#sliding_windows}, {#block_view}, {#flip},
|
|
29
|
+
# {#diagonal}) when one of them expresses the layout.
|
|
30
|
+
#
|
|
31
|
+
# @overload as_strided(shape:, strides:, offset: 0)
|
|
32
|
+
# @param shape [Array<Integer>] axis lengths.
|
|
33
|
+
# @param strides [Array<Integer>] byte stride per axis, same length as
|
|
34
|
+
# `shape`; negative values are allowed.
|
|
35
|
+
# @param offset [Integer] byte offset from the receiver's buffer to the
|
|
36
|
+
# `[0, ..., 0]` element.
|
|
37
|
+
# @return [CAStride]
|
|
38
|
+
# @raise [ArgumentError] when `shape:` or `strides:` is missing, when
|
|
39
|
+
# their lengths differ, or when the rank is 0 or above `CA_RANK_MAX`.
|
|
40
|
+
def as_strided(shape:, strides:, offset: 0); end
|
|
41
|
+
|
|
42
|
+
# Returns a {CAStride} view of overlapping windows over every axis. A
|
|
43
|
+
# parent of shape `[d0, ..., dN-1]` becomes a view of shape
|
|
44
|
+
# `[(d0-w0)/s0+1, ..., (dN-1-wN-1)/sN-1+1, w0, ..., wN-1]`, where `wi` is
|
|
45
|
+
# the window length on axis `i` and `si` the step.
|
|
46
|
+
#
|
|
47
|
+
# Truncate mode: a trailing partial window is dropped rather than padded.
|
|
48
|
+
# Memory is shared with the parent, and because windows overlap, one parent
|
|
49
|
+
# cell is visible from several positions of the view.
|
|
50
|
+
#
|
|
51
|
+
# Reduce over the trailing `ndim` axes for a rolling statistic.
|
|
52
|
+
#
|
|
53
|
+
# @overload sliding_windows(window, step: nil)
|
|
54
|
+
# @overload sliding_windows(w0, w1, ..., step: nil)
|
|
55
|
+
# @param window [Array<Integer>, Integer] window length per axis, one per
|
|
56
|
+
# dimension, as an Array or as variadic arguments.
|
|
57
|
+
# @param step [Array<Integer>, Integer, nil] stride between windows per
|
|
58
|
+
# axis; `nil` means 1 on every axis.
|
|
59
|
+
# @return [CAStride] of rank `2 * ndim`.
|
|
60
|
+
# @raise [ArgumentError] when the window count does not equal `ndim`,
|
|
61
|
+
# when a window or step is not positive, when a window is longer than
|
|
62
|
+
# its axis, or when `2 * ndim` exceeds `CA_RANK_MAX`.
|
|
63
|
+
def sliding_windows(*window, step: nil); end
|
|
64
|
+
|
|
65
|
+
# Returns a {CAStride} view of overlapping windows over the leading `S`
|
|
66
|
+
# axes, with the remaining `ndim - S` trailing axes riding along untouched
|
|
67
|
+
# at their original strides — {#sliding_windows} generalised to arrays that
|
|
68
|
+
# carry non-spatial dimensions such as channels.
|
|
69
|
+
#
|
|
70
|
+
# The window axes are inserted before the trailing axes, so the result rank
|
|
71
|
+
# is `ndim + S`. With `S == ndim` there are no trailing axes and the
|
|
72
|
+
# result is identical to {#sliding_windows}. Truncate mode; memory is
|
|
73
|
+
# shared with the parent.
|
|
74
|
+
#
|
|
75
|
+
# @overload unfold(window, step: nil)
|
|
76
|
+
# @overload unfold(w0, w1, ..., step: nil)
|
|
77
|
+
# @param window [Array<Integer>, Integer] window length for each of the
|
|
78
|
+
# leading axes; its size chooses how many axes are slid over.
|
|
79
|
+
# @param step [Array<Integer>, Integer, nil] stride between windows;
|
|
80
|
+
# `nil` means 1.
|
|
81
|
+
# @return [CAStride] of rank `ndim + window.size`.
|
|
82
|
+
# @raise [ArgumentError] when the window count is not between 1 and
|
|
83
|
+
# `ndim`, when a window or step is not positive, when a window is
|
|
84
|
+
# longer than its axis, or when `ndim + S` exceeds `CA_RANK_MAX`.
|
|
85
|
+
def unfold(*window, step: nil); end
|
|
86
|
+
|
|
87
|
+
# Returns a {CAStride} view of non-overlapping tiles. A parent of shape
|
|
88
|
+
# `[d0, ..., dN-1]` becomes a view of shape
|
|
89
|
+
# `[d0/b0, ..., dN-1/bN-1, b0, ..., bN-1]`, where `bi` is the tile length
|
|
90
|
+
# on axis `i`.
|
|
91
|
+
#
|
|
92
|
+
# Unlike {#sliding_windows} each parent dimension must divide evenly by its
|
|
93
|
+
# tile size: nothing is truncated and no cell is aliased twice. Reduce over
|
|
94
|
+
# the trailing `ndim` axes (e.g. `v.mean(-1, -2)` for a 2-D parent) for
|
|
95
|
+
# per-tile statistics such as pooling or block-wise aggregation. Memory is
|
|
96
|
+
# shared with the parent.
|
|
97
|
+
#
|
|
98
|
+
# @overload block_view(block)
|
|
99
|
+
# @overload block_view(b0, b1, ...)
|
|
100
|
+
# @param block [Array<Integer>, Integer] tile length per axis, one per
|
|
101
|
+
# dimension, as an Array or as variadic arguments.
|
|
102
|
+
# @return [CAStride] of rank `2 * ndim`.
|
|
103
|
+
# @raise [ArgumentError] when the tile count does not equal `ndim`, when
|
|
104
|
+
# a tile length is not positive, when an axis is not divisible by its
|
|
105
|
+
# tile length, or when `2 * ndim` exceeds `CA_RANK_MAX`.
|
|
106
|
+
def block_view(*block); end
|
|
107
|
+
|
|
108
|
+
# Returns a `CATranspose` view in which the given axes are moved to the
|
|
109
|
+
# front, in the order given, with the remaining axes following in their
|
|
110
|
+
# original order — a thin alias over `transposed` that names the intent
|
|
111
|
+
# "bring these axes to the front, keep the rest as the inner slice".
|
|
112
|
+
#
|
|
113
|
+
# @example
|
|
114
|
+
# a = CArray.float64(3, 4, 5).seq
|
|
115
|
+
# a.dim_view(0, 2) # shape [3, 5, 4]
|
|
116
|
+
# a.dim_view(1) # shape [4, 3, 5]
|
|
117
|
+
# a.dim_view(-1) # shape [5, 3, 4]
|
|
118
|
+
#
|
|
119
|
+
# @overload dim_view(axes)
|
|
120
|
+
# @overload dim_view(a0, a1, ...)
|
|
121
|
+
# @param axes [Array<Integer>, Integer] axes to bring to the front;
|
|
122
|
+
# negative indices count from the last axis.
|
|
123
|
+
# @return [CATranspose]
|
|
124
|
+
# @raise [ArgumentError] when no axis is given, when more axes are given
|
|
125
|
+
# than `ndim`, or when an axis is out of range or repeated.
|
|
126
|
+
def dim_view(*axes); end
|
|
127
|
+
|
|
128
|
+
# Returns a {CAStride} view with the listed axes reversed (a negative
|
|
129
|
+
# stride on each); with no argument every axis is reversed. Memory is
|
|
130
|
+
# shared with the parent, so writes through the view propagate.
|
|
131
|
+
#
|
|
132
|
+
# This is the named counterpart of the indexer form
|
|
133
|
+
# `ca[-1..0, nil, -1..0]` — both produce a true negative-stride view with
|
|
134
|
+
# no copy. Use `flip` when the axis list is parametric or when the named
|
|
135
|
+
# intent reads better than the slice form. There is no `flip!`; the
|
|
136
|
+
# in-place idiom is `ca[] = ca.flip`.
|
|
137
|
+
#
|
|
138
|
+
# `reverse` is an alias of `flip`.
|
|
139
|
+
#
|
|
140
|
+
# @example
|
|
141
|
+
# a = CArray.float64(4, 5).seq
|
|
142
|
+
# a.flip # every axis reversed
|
|
143
|
+
# a.flip(0) # row order reversed
|
|
144
|
+
# a.flip(-1) # same as a.flip(1)
|
|
145
|
+
# a.flip([0, 1]) # Array form
|
|
146
|
+
#
|
|
147
|
+
# @overload flip
|
|
148
|
+
# @overload flip(axis)
|
|
149
|
+
# @overload flip(a0, a1, ...)
|
|
150
|
+
# @overload flip([a0, a1, ...])
|
|
151
|
+
# @param axis [Array<Integer>, Integer] axes to reverse; negative indices
|
|
152
|
+
# count from the last axis.
|
|
153
|
+
# @return [CAStride]
|
|
154
|
+
# @raise [ArgumentError] when an axis is out of range or repeated.
|
|
155
|
+
def flip(*axis); end
|
|
156
|
+
|
|
157
|
+
# Returns a {CAStride} view of one diagonal of the parent. For a 2-D
|
|
158
|
+
# parent of shape `[m, n]` this is a 1-D view of length
|
|
159
|
+
# `min(m, n - offset)` for `offset >= 0`, or `min(m + offset, n)` for
|
|
160
|
+
# `offset < 0`.
|
|
161
|
+
#
|
|
162
|
+
# For a higher-rank parent, the two axes named by `axis:` collapse into a
|
|
163
|
+
# single diagonal axis appended at the **end** of the result, and the
|
|
164
|
+
# remaining axes keep their order in front. Memory is shared with the
|
|
165
|
+
# parent.
|
|
166
|
+
#
|
|
167
|
+
# @overload diagonal(offset = 0, axis: [0, 1])
|
|
168
|
+
# @param offset [Integer] signed shift from the main diagonal; positive
|
|
169
|
+
# selects a super-diagonal, negative a sub-diagonal. An offset larger
|
|
170
|
+
# than the relevant axis yields an empty view rather than an error.
|
|
171
|
+
# May be passed positionally or as `offset:`, but not both.
|
|
172
|
+
# @param axis [Array<Integer>] the two distinct axes to take the diagonal
|
|
173
|
+
# over; negative indices count from the last axis.
|
|
174
|
+
# @return [CAStride]
|
|
175
|
+
# @raise [ArgumentError] when the parent has fewer than two dimensions,
|
|
176
|
+
# when `offset` is given both positionally and as a keyword, or when
|
|
177
|
+
# `axis:` is not two distinct in-range axes.
|
|
178
|
+
def diagonal(offset = 0, axis: [0, 1]); end
|
|
179
|
+
|
|
180
|
+
# @!endgroup
|
|
181
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for methods defined in ext/ca_obj_tile.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# Tiled repetition view. Output shape is `parent.dim[k] * reps[k]`
|
|
6
|
+
# along each axis; every tile is a full-parent alias, so writes to
|
|
7
|
+
# overlapping cells are last-write-wins.
|
|
8
|
+
class CATile < CAView
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Mask companion of {CATile}.
|
|
12
|
+
# @private
|
|
13
|
+
class CATileMask < CATile
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class CArray
|
|
17
|
+
# @!group Views
|
|
18
|
+
# @overload tile(*reps)
|
|
19
|
+
# Returns a {CATile} view of `self` tiled `reps[k]` times along
|
|
20
|
+
# each axis `k`. Accepts either positional args
|
|
21
|
+
# (`a.tile(2, 3)`) or a single array (`a.tile([2, 3])`); the
|
|
22
|
+
# number of reps must equal `ndim`.
|
|
23
|
+
# @param reps [Array<Integer>] repetition count per axis.
|
|
24
|
+
# @return [CATile]
|
|
25
|
+
# @raise [ArgumentError] when the number of reps does not match `ndim`.
|
|
26
|
+
# @raise [IndexError] when any `reps[k]` is not positive.
|
|
27
|
+
def tile(*reps); end
|
|
28
|
+
# @!endgroup
|
|
29
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CATranspose and CArray#transpose / #T defined in
|
|
3
|
+
# ext/ca_obj_transpose.c.
|
|
4
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
5
|
+
|
|
6
|
+
# Permuted-axis view of the parent. Pure `CAStride` typedef: only
|
|
7
|
+
# the dim / stride layout differs. No data is copied; writes go
|
|
8
|
+
# through to the parent.
|
|
9
|
+
class CATranspose < CAStride
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Mask companion of {CATranspose}.
|
|
13
|
+
# @private
|
|
14
|
+
class CATransposeMask < CATranspose
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class CArray
|
|
18
|
+
# @!group Views
|
|
19
|
+
|
|
20
|
+
# @overload transpose
|
|
21
|
+
# Returns a {CATranspose} view of `self` with the dimension order
|
|
22
|
+
# reversed (`view.shape[k] == self.shape[ndim-1-k]`).
|
|
23
|
+
# @return [CATranspose]
|
|
24
|
+
# @overload transpose(*imap)
|
|
25
|
+
# Returns a {CATranspose} view of `self` permuted by `imap`, a
|
|
26
|
+
# permutation of `0 ... self.ndim`. Element
|
|
27
|
+
# `view[i_0, ..., i_{n-1}]` aliases parent element with axis `k`
|
|
28
|
+
# sourced from `i` at position `imap[k]`.
|
|
29
|
+
# @param imap [Array<Integer>] permutation of `0 ... ndim`.
|
|
30
|
+
# @return [CATranspose]
|
|
31
|
+
# @raise [ArgumentError] when `imap.length != ndim`.
|
|
32
|
+
# @raise [RuntimeError] when an entry of `imap` is out of range
|
|
33
|
+
# or duplicated.
|
|
34
|
+
def transpose(*imap); end
|
|
35
|
+
|
|
36
|
+
# Alias of {#transpose}.
|
|
37
|
+
def T(*imap); end
|
|
38
|
+
|
|
39
|
+
# @!endgroup
|
|
40
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CAWindow and CArray#window defined in ext/ca_obj_window.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# Sliding rectangular view of the parent whose cells may fall outside it.
|
|
6
|
+
# In-range cells alias the parent, out-of-range cells take the fill value
|
|
7
|
+
# (or are masked). {CAShift} is the same view expressed as a translation.
|
|
8
|
+
class CAWindow < CAView
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Mask companion of {CAWindow}.
|
|
12
|
+
# @private
|
|
13
|
+
class CAWindowMask < CAWindow
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class CArray
|
|
17
|
+
# @!group Views
|
|
18
|
+
|
|
19
|
+
# Returns a {CAWindow} view of `self` covering `ranges` — one range per
|
|
20
|
+
# axis, which may extend past either end of the parent. Cells inside the
|
|
21
|
+
# parent alias it, so writes through the view reach the parent; cells
|
|
22
|
+
# outside take `fill_value` (default `0`), and `fill_value: UNDEF` masks
|
|
23
|
+
# them instead.
|
|
24
|
+
#
|
|
25
|
+
# Only unit-step ranges are accepted, and each range must run forward, so
|
|
26
|
+
# the `0..-1` end-relative notation cannot be used here.
|
|
27
|
+
#
|
|
28
|
+
# @overload window(*ranges, fill_value: 0, bounds: "fill")
|
|
29
|
+
# @param ranges [Array<Range, Integer>] one range per axis; the count
|
|
30
|
+
# must equal `self.ndim`.
|
|
31
|
+
# @param fill_value [Object] value given to out-of-range cells; `UNDEF`
|
|
32
|
+
# masks them instead.
|
|
33
|
+
# @param bounds [String] what an out-of-range index means: `"fill"`
|
|
34
|
+
# (default) uses `fill_value`, `"nearest"` clamps to the edge cell,
|
|
35
|
+
# `"ruby"` reads negative indices from the far end, `"strict"` raises.
|
|
36
|
+
# `"mask"` masks the cell but warns — pass `fill_value: UNDEF` instead.
|
|
37
|
+
# @return [CAWindow]
|
|
38
|
+
# @raise [ArgumentError] when the number of ranges does not equal `ndim`,
|
|
39
|
+
# when a range has a step other than 1 or runs backwards, when a block
|
|
40
|
+
# is passed (the block form was removed in 3.0), or when `bounds` is
|
|
41
|
+
# `"periodic"` / `"reflect"` (both removed in 3.0; use {#roll} for a
|
|
42
|
+
# cyclic shift).
|
|
43
|
+
# @raise [IndexError] when a range selects zero cells.
|
|
44
|
+
# @raise [RuntimeError] when `bounds` conflicts with `fill_value: UNDEF`,
|
|
45
|
+
# or when `bounds` is not a recognised value.
|
|
46
|
+
def window(*ranges, fill_value: 0, bounds: "fill"); end
|
|
47
|
+
|
|
48
|
+
# @!endgroup
|
|
49
|
+
end
|