carray 3.0.0 → 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 +2 -1
- data/CHANGELOG.md +325 -3
- data/{NEWS.md → CHANGELOG.v1.md} +1 -1
- data/README.md +32 -32
- data/carray.gemspec +12 -8
- data/ext/ca_axis_group.c +55 -19
- data/ext/ca_binop_dispatch.c +5 -6
- data/ext/ca_binop_dispatch.h +0 -7
- data/ext/ca_categorical_iterator.c +13 -13
- data/ext/ca_for_each_element.h +6 -8
- data/ext/ca_group_iter.c +1 -1
- data/ext/ca_kernel_iterator.c +69 -23
- data/ext/ca_kernel_iterator.h +3 -10
- data/ext/ca_obj_bincmp.c +57 -27
- data/ext/ca_obj_binop.c +86 -30
- data/ext/ca_obj_const_string.c +3 -1
- data/ext/ca_obj_face.c +80 -0
- data/ext/ca_obj_face.h +33 -1
- data/ext/ca_obj_fake.c +11 -0
- data/ext/ca_obj_fixlen_string.c +3 -1
- data/ext/ca_obj_grid.c +11 -3
- data/ext/ca_obj_meld.c +13 -8
- data/ext/ca_obj_moncmp.c +33 -14
- data/ext/ca_obj_monop.c +19 -7
- data/ext/ca_obj_object.c +99 -4
- data/ext/ca_obj_record.c +3 -1
- data/ext/ca_obj_refer.c +30 -6
- data/ext/ca_obj_roll.c +13 -5
- data/ext/ca_obj_select_axis.c +16 -6
- data/ext/ca_obj_shift.c +3 -3
- data/ext/ca_obj_stride.c +106 -23
- data/ext/ca_obj_string.c +3 -1
- data/ext/ca_obj_tile.c +13 -5
- data/ext/ca_obj_time.c +3 -1
- data/ext/ca_obj_timedelta.c +3 -1
- data/ext/ca_obj_transpose.c +1 -1
- data/ext/ca_obj_triop.c +62 -23
- data/ext/ca_obj_window.c +86 -17
- data/ext/ca_op_cmplx64.h +123 -0
- data/ext/ca_op_ipower.c +0 -3
- data/ext/ca_sort_kernels.h +5 -5
- data/ext/ca_sweep_engine.c +78 -35
- data/ext/ca_sweep_engine.h +13 -4
- data/ext/ca_transform_common.c +7 -0
- data/ext/carray.h +127 -130
- data/ext/carray_access.c +56 -34
- data/ext/carray_bincount.c +8 -8
- data/ext/carray_broadcast.c +99 -6
- data/ext/carray_build_flags.h +3 -0
- data/ext/carray_call_cfunc.c +1491 -0
- data/ext/carray_call_cfunc.h +153 -0
- data/ext/carray_cast.c +69 -31
- data/ext/carray_conversion.c +22 -22
- data/ext/carray_copy.c +12 -2
- data/ext/carray_core.c +57 -10
- data/ext/carray_count.c +1 -1
- data/ext/carray_element.c +7 -7
- data/ext/carray_factorize.c +28 -28
- data/ext/carray_hold.c +1 -1
- data/ext/carray_index_classifier.c +7 -21
- data/ext/carray_internal.h +19 -3
- data/ext/carray_kernels_bincmp.c +1 -0
- data/ext/carray_kernels_binop.c +320 -298
- data/ext/carray_kernels_init.c +1095 -0
- data/ext/carray_kernels_map.c +1 -0
- data/ext/carray_kernels_moncmp.c +1 -0
- data/ext/carray_kernels_monop.c +412 -411
- data/ext/carray_kernels_reduce_aggregate.c +88 -87
- data/ext/carray_kernels_reduce_boolean.c +1 -0
- data/ext/carray_kernels_reduce_cumulative.c +54 -53
- data/ext/carray_kernels_reduce_extreme.c +51 -50
- data/ext/carray_kernels_reduce_variance.c +1 -0
- data/ext/carray_kernels_scan.c +1 -0
- data/ext/carray_kernels_search.c +93 -92
- data/ext/carray_kernels_sort.c +1 -0
- data/ext/carray_kernels_triop.c +1 -0
- data/ext/carray_lazy.c +175 -5
- data/ext/carray_mask.c +6 -5
- data/ext/carray_median_percentile.c +1 -1
- data/ext/carray_memory_view.c +46 -21
- data/ext/carray_operator.c +46 -49
- data/ext/carray_partition.c +4 -4
- data/ext/carray_random.c +7 -7
- data/ext/carray_scatter.c +1 -1
- data/ext/carray_sort.c +3 -3
- data/ext/carray_sort_kernel.c +10 -10
- data/ext/carray_test.c +1 -1
- data/ext/extconf.rb +18 -0
- data/ext/mk_call_cfunc.rb +243 -52
- data/ext/mkkernel.rb +354 -100
- data/ext/ruby_carray.c +18 -16
- data/ext/version.h +4 -4
- data/lib/carray/autoload_carray.rb +19 -0
- data/lib/carray/autoload_method_extension.rb +2 -1
- data/lib/carray/axis_group.rb +7 -7
- data/lib/carray/basics.rb +59 -59
- data/lib/carray/bincount_nd.rb +12 -12
- data/lib/carray/block_iterator.rb +24 -14
- data/lib/carray/categorical.rb +4 -4
- data/lib/carray/categorical_iterator.rb +98 -76
- data/lib/carray/conditional.rb +14 -14
- data/lib/carray/construct.rb +21 -0
- data/lib/carray/core_extensions.rb +62 -5
- data/lib/carray/data_type_extension.rb +18 -1
- data/lib/carray/frame/concat.rb +3 -3
- data/lib/carray/frame/convert.rb +1 -1
- data/lib/carray/frame/frame.rb +4 -11
- data/lib/carray/frame/io.rb +159 -2
- data/lib/carray/frame/sort.rb +1 -1
- data/lib/carray/frame/verbs.rb +18 -1
- data/lib/carray/fuse_source.rb +123 -0
- data/lib/carray/fusion.rb +218 -0
- data/lib/carray/histogram.rb +16 -16
- data/lib/carray/inspect.rb +1 -7
- data/lib/carray/iterator.rb +4 -3
- data/lib/carray/lazy.rb +125 -73
- data/lib/carray/meld_reduce.rb +2 -2
- data/lib/carray/methods/align_addr.rb +1 -1
- data/lib/carray/methods/composition.rb +1 -1
- data/lib/carray/methods/is_in.rb +12 -12
- data/lib/carray/methods/locate_addr.rb +6 -1
- data/lib/carray/methods/mask_duplicates.rb +1 -1
- data/lib/carray/methods/meshgrid.rb +4 -5
- data/lib/carray/methods/mode.rb +2 -2
- data/lib/carray/methods/nunique.rb +1 -1
- data/lib/carray/methods/snap.rb +7 -2
- data/lib/carray/methods/unique.rb +3 -3
- data/lib/carray/methods/value_counts.rb +2 -2
- data/lib/carray/runtime.rb +0 -19
- data/lib/carray/slab_iterator.rb +20 -7
- data/lib/carray/string_operation_extension.rb +5 -5
- data/lib/carray/time.rb +890 -491
- data/lib/carray/window_iterator.rb +285 -13
- data/lib/carray.rb +5 -5
- 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 +59 -10
- data/ext/ca_obj_unbound_repeat.c +0 -496
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for constructor methods defined in ext/ca_obj_array.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
class CArray
|
|
6
|
+
# @!group Construction
|
|
7
|
+
|
|
8
|
+
# @overload initialize(data_type, shape)
|
|
9
|
+
# Allocates a CArray of the given `data_type` and `shape`, with
|
|
10
|
+
# storage left uninitialized (caller is expected to fill it).
|
|
11
|
+
# @param data_type [Symbol, Integer, Class, String] element type.
|
|
12
|
+
# @param shape [Array<Integer>] one extent per axis.
|
|
13
|
+
# @return [self]
|
|
14
|
+
# @overload initialize(data_type, shape, bytes:)
|
|
15
|
+
# For `data_type == :fixlen`, sets the per-element byte size.
|
|
16
|
+
# Ignored for numeric types.
|
|
17
|
+
# @param data_type [Symbol]
|
|
18
|
+
# @param shape [Array<Integer>]
|
|
19
|
+
# @param bytes [Integer]
|
|
20
|
+
# @return [self]
|
|
21
|
+
# @overload initialize(data_type, shape) { value }
|
|
22
|
+
# With a 0-arity block, calls the block once and broadcasts its
|
|
23
|
+
# return value into every cell of the new array (scalar-fill fast
|
|
24
|
+
# path). This is the dominant
|
|
25
|
+
# `CArray.<type>(n) { value }` idiom.
|
|
26
|
+
# @yieldreturn [Object] value to broadcast.
|
|
27
|
+
# @return [self]
|
|
28
|
+
# @overload initialize(data_type, shape) { |*idx| ... }
|
|
29
|
+
# With an n-arity block, calls the block once per cell with the
|
|
30
|
+
# multi-dimensional index unpacked (`|i|` for 1-D, `|i, j|` for
|
|
31
|
+
# 2-D, etc.). The block's return value is stored at that cell.
|
|
32
|
+
# @yieldparam idx [Array<Integer>] per-axis indices.
|
|
33
|
+
# @yieldreturn [Object]
|
|
34
|
+
# @return [self]
|
|
35
|
+
#
|
|
36
|
+
# 3.0 breaking: `CArray.new(MyStruct, ...)` no longer accepts a
|
|
37
|
+
# user class as `data_type`. Use `CARecord.new(MyStruct, *shape)`
|
|
38
|
+
# or define `class MyArr < CARecord; data_class MyStruct; end`.
|
|
39
|
+
def initialize(*); end
|
|
40
|
+
|
|
41
|
+
# @overload initialize_copy(other)
|
|
42
|
+
# Implements `dup` / `clone` semantics: copies `other`'s
|
|
43
|
+
# `data_type`, shape, mask, and element data into `self`. Result
|
|
44
|
+
# is an independent entity.
|
|
45
|
+
#
|
|
46
|
+
# Note that for views, `dup`/`clone` produce a new view sharing
|
|
47
|
+
# the parent (Ruby shallow-copy semantics); use {#copy} when an
|
|
48
|
+
# independent owned array is required.
|
|
49
|
+
# @param other [CArray]
|
|
50
|
+
# @return [self]
|
|
51
|
+
# @api private
|
|
52
|
+
def initialize_copy(other); end
|
|
53
|
+
|
|
54
|
+
# @!endgroup
|
|
55
|
+
|
|
56
|
+
class << self
|
|
57
|
+
# @!group Construction (typed shorthands)
|
|
58
|
+
#
|
|
59
|
+
# `CArray.<type>` (no args) returns the typed class
|
|
60
|
+
# (`CArray::Float64`, `CArray::Int32`, ...). `CArray.<type>(*shape)`
|
|
61
|
+
# is a shorthand for `CArray.new(:<type>, shape)`. The shorthands
|
|
62
|
+
# accept the same optional block as `initialize`.
|
|
63
|
+
|
|
64
|
+
# @overload fixlen
|
|
65
|
+
# Returns the typed class `CArray::Fixlen`.
|
|
66
|
+
# @return [Class]
|
|
67
|
+
# @overload fixlen(*shape, bytes:) { ... }
|
|
68
|
+
# Equivalent to `CArray.new(:fixlen, shape, bytes: bytes) { ... }`.
|
|
69
|
+
# The `bytes:` keyword is required for `:fixlen`.
|
|
70
|
+
# @param shape [Array<Integer>]
|
|
71
|
+
# @param bytes [Integer]
|
|
72
|
+
# @return [CArray]
|
|
73
|
+
def fixlen(*shape, bytes: nil); end
|
|
74
|
+
|
|
75
|
+
# @overload boolean
|
|
76
|
+
# Returns the typed class `CArray::Boolean`.
|
|
77
|
+
# @return [Class]
|
|
78
|
+
# @overload boolean(*shape) { ... }
|
|
79
|
+
# Equivalent to `CArray.new(:boolean, shape) { ... }`.
|
|
80
|
+
# @param shape [Array<Integer>]
|
|
81
|
+
# @return [CArray]
|
|
82
|
+
def boolean(*shape); end
|
|
83
|
+
|
|
84
|
+
# @overload int8
|
|
85
|
+
# Returns the typed class `CArray::Int8`.
|
|
86
|
+
# @return [Class]
|
|
87
|
+
# @overload int8(*shape) { ... }
|
|
88
|
+
# Equivalent to `CArray.new(:int8, shape) { ... }`.
|
|
89
|
+
# @return [CArray]
|
|
90
|
+
def int8(*shape); end
|
|
91
|
+
|
|
92
|
+
# @overload uint8
|
|
93
|
+
# Returns the typed class `CArray::UInt8`.
|
|
94
|
+
# @return [Class]
|
|
95
|
+
# @overload uint8(*shape) { ... }
|
|
96
|
+
# Equivalent to `CArray.new(:uint8, shape) { ... }`.
|
|
97
|
+
# @return [CArray]
|
|
98
|
+
def uint8(*shape); end
|
|
99
|
+
|
|
100
|
+
# @overload int16
|
|
101
|
+
# Returns the typed class `CArray::Int16`.
|
|
102
|
+
# @return [Class]
|
|
103
|
+
# @overload int16(*shape) { ... }
|
|
104
|
+
# Equivalent to `CArray.new(:int16, shape) { ... }`.
|
|
105
|
+
# @return [CArray]
|
|
106
|
+
def int16(*shape); end
|
|
107
|
+
|
|
108
|
+
# @overload uint16
|
|
109
|
+
# Returns the typed class `CArray::UInt16`.
|
|
110
|
+
# @return [Class]
|
|
111
|
+
# @overload uint16(*shape) { ... }
|
|
112
|
+
# Equivalent to `CArray.new(:uint16, shape) { ... }`.
|
|
113
|
+
# @return [CArray]
|
|
114
|
+
def uint16(*shape); end
|
|
115
|
+
|
|
116
|
+
# @overload int32
|
|
117
|
+
# Returns the typed class `CArray::Int32`.
|
|
118
|
+
# @return [Class]
|
|
119
|
+
# @overload int32(*shape) { ... }
|
|
120
|
+
# Equivalent to `CArray.new(:int32, shape) { ... }`.
|
|
121
|
+
# @return [CArray]
|
|
122
|
+
def int32(*shape); end
|
|
123
|
+
|
|
124
|
+
# @overload uint32
|
|
125
|
+
# Returns the typed class `CArray::UInt32`.
|
|
126
|
+
# @return [Class]
|
|
127
|
+
# @overload uint32(*shape) { ... }
|
|
128
|
+
# Equivalent to `CArray.new(:uint32, shape) { ... }`.
|
|
129
|
+
# @return [CArray]
|
|
130
|
+
def uint32(*shape); end
|
|
131
|
+
|
|
132
|
+
# @overload int64
|
|
133
|
+
# Returns the typed class `CArray::Int64`.
|
|
134
|
+
# @return [Class]
|
|
135
|
+
# @overload int64(*shape) { ... }
|
|
136
|
+
# Equivalent to `CArray.new(:int64, shape) { ... }`.
|
|
137
|
+
# @return [CArray]
|
|
138
|
+
def int64(*shape); end
|
|
139
|
+
|
|
140
|
+
# @overload uint64
|
|
141
|
+
# Returns the typed class `CArray::UInt64`.
|
|
142
|
+
# @return [Class]
|
|
143
|
+
# @overload uint64(*shape) { ... }
|
|
144
|
+
# Equivalent to `CArray.new(:uint64, shape) { ... }`.
|
|
145
|
+
# @return [CArray]
|
|
146
|
+
def uint64(*shape); end
|
|
147
|
+
|
|
148
|
+
# @overload float32
|
|
149
|
+
# Returns the typed class `CArray::Float32`.
|
|
150
|
+
# @return [Class]
|
|
151
|
+
# @overload float32(*shape) { ... }
|
|
152
|
+
# Equivalent to `CArray.new(:float32, shape) { ... }`.
|
|
153
|
+
# @return [CArray]
|
|
154
|
+
def float32(*shape); end
|
|
155
|
+
|
|
156
|
+
# @overload float64
|
|
157
|
+
# Returns the typed class `CArray::Float64`.
|
|
158
|
+
# @return [Class]
|
|
159
|
+
# @overload float64(*shape) { ... }
|
|
160
|
+
# Equivalent to `CArray.new(:float64, shape) { ... }`.
|
|
161
|
+
# @return [CArray]
|
|
162
|
+
def float64(*shape); end
|
|
163
|
+
|
|
164
|
+
# @overload cmplx64
|
|
165
|
+
# Returns the typed class `CArray::Cmplx64`.
|
|
166
|
+
# @return [Class]
|
|
167
|
+
# @overload cmplx64(*shape) { ... }
|
|
168
|
+
# Equivalent to `CArray.new(:cmplx64, shape) { ... }`.
|
|
169
|
+
# @return [CArray]
|
|
170
|
+
def cmplx64(*shape); end
|
|
171
|
+
|
|
172
|
+
# @overload cmplx128
|
|
173
|
+
# Returns the typed class `CArray::Cmplx128`.
|
|
174
|
+
# @return [Class]
|
|
175
|
+
# @overload cmplx128(*shape) { ... }
|
|
176
|
+
# Equivalent to `CArray.new(:cmplx128, shape) { ... }`.
|
|
177
|
+
# @return [CArray]
|
|
178
|
+
def cmplx128(*shape); end
|
|
179
|
+
|
|
180
|
+
# @overload object
|
|
181
|
+
# Returns the typed class `CArray::Object`.
|
|
182
|
+
# @return [Class]
|
|
183
|
+
# @overload object(*shape) { ... }
|
|
184
|
+
# Equivalent to `CArray.new(:object, shape) { ... }`.
|
|
185
|
+
# @return [CArray]
|
|
186
|
+
def object(*shape); end
|
|
187
|
+
|
|
188
|
+
# @!endgroup
|
|
189
|
+
|
|
190
|
+
# @!group Construction (legacy-name aliases)
|
|
191
|
+
|
|
192
|
+
# @overload byte(*shape)
|
|
193
|
+
# Alias of {.uint8}.
|
|
194
|
+
def byte(*shape); end
|
|
195
|
+
|
|
196
|
+
# @overload short(*shape)
|
|
197
|
+
# Alias of {.int16}.
|
|
198
|
+
def short(*shape); end
|
|
199
|
+
|
|
200
|
+
# @overload int(*shape)
|
|
201
|
+
# Alias of {.int32}.
|
|
202
|
+
def int(*shape); end
|
|
203
|
+
|
|
204
|
+
# @overload float(*shape)
|
|
205
|
+
# Alias of {.float32}.
|
|
206
|
+
def float(*shape); end
|
|
207
|
+
|
|
208
|
+
# @overload double(*shape)
|
|
209
|
+
# Alias of {.float64}.
|
|
210
|
+
def double(*shape); end
|
|
211
|
+
|
|
212
|
+
# @overload complex(*shape)
|
|
213
|
+
# Alias of {.cmplx64}.
|
|
214
|
+
def complex(*shape); end
|
|
215
|
+
|
|
216
|
+
# @overload dcomplex(*shape)
|
|
217
|
+
# Alias of {.cmplx128}.
|
|
218
|
+
def dcomplex(*shape); end
|
|
219
|
+
|
|
220
|
+
# @!endgroup
|
|
221
|
+
|
|
222
|
+
# @!group External memory wrapping
|
|
223
|
+
|
|
224
|
+
# @overload wrap(data_type, shape) { target }
|
|
225
|
+
# Wraps an external memory block as a CAWrap. The block must
|
|
226
|
+
# return a `target` object that defines `wrap_as_carray(obj)`,
|
|
227
|
+
# which receives the freshly allocated CAWrap and is
|
|
228
|
+
# responsible for setting its `ptr` field.
|
|
229
|
+
#
|
|
230
|
+
# Use this when bridging to a memory source that does not
|
|
231
|
+
# expose the MemoryView protocol (otherwise prefer
|
|
232
|
+
# {.wrap_memory_view} / {.from_memory_view}).
|
|
233
|
+
# @param data_type [Symbol]
|
|
234
|
+
# @param shape [Array<Integer>]
|
|
235
|
+
# @yieldreturn [#wrap_as_carray] external buffer holder.
|
|
236
|
+
# @return [CAWrap]
|
|
237
|
+
def wrap(data_type, shape); end
|
|
238
|
+
|
|
239
|
+
# @!endgroup
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
class CScalar
|
|
244
|
+
# @!group Construction
|
|
245
|
+
|
|
246
|
+
# @overload initialize(data_type)
|
|
247
|
+
# Allocates a CScalar (0-D CArray) of the given `data_type`.
|
|
248
|
+
# @param data_type [Symbol, Integer, Class, String]
|
|
249
|
+
# @return [self]
|
|
250
|
+
# @overload initialize(data_type, bytes:)
|
|
251
|
+
# For `data_type == :fixlen`, sets the per-element byte size.
|
|
252
|
+
# @param data_type [Symbol]
|
|
253
|
+
# @param bytes [Integer]
|
|
254
|
+
# @return [self]
|
|
255
|
+
# @overload initialize(data_type) { |scalar| ... }
|
|
256
|
+
# Yields the freshly allocated scalar; the block's return value
|
|
257
|
+
# is stored at the cell unless it is `scalar` itself.
|
|
258
|
+
# @yieldparam scalar [CScalar]
|
|
259
|
+
# @yieldreturn [Object]
|
|
260
|
+
# @return [self]
|
|
261
|
+
def initialize(*); end
|
|
262
|
+
|
|
263
|
+
# @overload initialize_copy(other)
|
|
264
|
+
# Copies `other`'s `data_type` and stored value into `self`.
|
|
265
|
+
# @param other [CScalar]
|
|
266
|
+
# @return [self]
|
|
267
|
+
# @api private
|
|
268
|
+
def initialize_copy(other); end
|
|
269
|
+
|
|
270
|
+
# @!endgroup
|
|
271
|
+
|
|
272
|
+
class << self
|
|
273
|
+
# @!group Construction (typed shorthands)
|
|
274
|
+
|
|
275
|
+
# @overload fixlen(bytes:) { ... }
|
|
276
|
+
# Equivalent to `CScalar.new(:fixlen, bytes: bytes) { ... }`.
|
|
277
|
+
# @param bytes [Integer]
|
|
278
|
+
# @return [CScalar]
|
|
279
|
+
def fixlen(bytes:); end
|
|
280
|
+
|
|
281
|
+
# @overload boolean { ... }
|
|
282
|
+
# Equivalent to `CScalar.new(:boolean) { ... }`.
|
|
283
|
+
# @return [CScalar]
|
|
284
|
+
def boolean; end
|
|
285
|
+
|
|
286
|
+
# @overload int8 { ... }
|
|
287
|
+
# Equivalent to `CScalar.new(:int8) { ... }`.
|
|
288
|
+
# @return [CScalar]
|
|
289
|
+
def int8; end
|
|
290
|
+
|
|
291
|
+
# @overload uint8 { ... }
|
|
292
|
+
# Equivalent to `CScalar.new(:uint8) { ... }`.
|
|
293
|
+
# @return [CScalar]
|
|
294
|
+
def uint8; end
|
|
295
|
+
|
|
296
|
+
# @overload int16 { ... }
|
|
297
|
+
# Equivalent to `CScalar.new(:int16) { ... }`.
|
|
298
|
+
# @return [CScalar]
|
|
299
|
+
def int16; end
|
|
300
|
+
|
|
301
|
+
# @overload uint16 { ... }
|
|
302
|
+
# Equivalent to `CScalar.new(:uint16) { ... }`.
|
|
303
|
+
# @return [CScalar]
|
|
304
|
+
def uint16; end
|
|
305
|
+
|
|
306
|
+
# @overload int32 { ... }
|
|
307
|
+
# Equivalent to `CScalar.new(:int32) { ... }`.
|
|
308
|
+
# @return [CScalar]
|
|
309
|
+
def int32; end
|
|
310
|
+
|
|
311
|
+
# @overload uint32 { ... }
|
|
312
|
+
# Equivalent to `CScalar.new(:uint32) { ... }`.
|
|
313
|
+
# @return [CScalar]
|
|
314
|
+
def uint32; end
|
|
315
|
+
|
|
316
|
+
# @overload int64 { ... }
|
|
317
|
+
# Equivalent to `CScalar.new(:int64) { ... }`.
|
|
318
|
+
# @return [CScalar]
|
|
319
|
+
def int64; end
|
|
320
|
+
|
|
321
|
+
# @overload uint64 { ... }
|
|
322
|
+
# Equivalent to `CScalar.new(:uint64) { ... }`.
|
|
323
|
+
# @return [CScalar]
|
|
324
|
+
def uint64; end
|
|
325
|
+
|
|
326
|
+
# @overload float32 { ... }
|
|
327
|
+
# Equivalent to `CScalar.new(:float32) { ... }`.
|
|
328
|
+
# @return [CScalar]
|
|
329
|
+
def float32; end
|
|
330
|
+
|
|
331
|
+
# @overload float64 { ... }
|
|
332
|
+
# Equivalent to `CScalar.new(:float64) { ... }`.
|
|
333
|
+
# @return [CScalar]
|
|
334
|
+
def float64; end
|
|
335
|
+
|
|
336
|
+
# @overload cmplx64 { ... }
|
|
337
|
+
# Equivalent to `CScalar.new(:cmplx64) { ... }`.
|
|
338
|
+
# @return [CScalar]
|
|
339
|
+
def cmplx64; end
|
|
340
|
+
|
|
341
|
+
# @overload cmplx128 { ... }
|
|
342
|
+
# Equivalent to `CScalar.new(:cmplx128) { ... }`.
|
|
343
|
+
# @return [CScalar]
|
|
344
|
+
def cmplx128; end
|
|
345
|
+
|
|
346
|
+
# @overload object { ... }
|
|
347
|
+
# Equivalent to `CScalar.new(:object) { ... }`.
|
|
348
|
+
# @return [CScalar]
|
|
349
|
+
def object; end
|
|
350
|
+
|
|
351
|
+
# @!endgroup
|
|
352
|
+
|
|
353
|
+
# @!group Construction (legacy-name aliases)
|
|
354
|
+
|
|
355
|
+
# @overload byte
|
|
356
|
+
# Alias of {.uint8}.
|
|
357
|
+
def byte; end
|
|
358
|
+
|
|
359
|
+
# @overload short
|
|
360
|
+
# Alias of {.int16}.
|
|
361
|
+
def short; end
|
|
362
|
+
|
|
363
|
+
# @overload int
|
|
364
|
+
# Alias of {.int32}.
|
|
365
|
+
def int; end
|
|
366
|
+
|
|
367
|
+
# @overload float
|
|
368
|
+
# Alias of {.float32}.
|
|
369
|
+
def float; end
|
|
370
|
+
|
|
371
|
+
# @overload double
|
|
372
|
+
# Alias of {.float64}.
|
|
373
|
+
def double; end
|
|
374
|
+
|
|
375
|
+
# @overload complex
|
|
376
|
+
# Alias of {.cmplx64}.
|
|
377
|
+
def complex; end
|
|
378
|
+
|
|
379
|
+
# @overload dcomplex
|
|
380
|
+
# Alias of {.cmplx128}.
|
|
381
|
+
def dcomplex; end
|
|
382
|
+
|
|
383
|
+
# @!endgroup
|
|
384
|
+
end
|
|
385
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CABitarray and CArray#bitarray defined in ext/ca_obj_bitarray.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# Per-bit expansion view of the parent. Every parent cell is fanned
|
|
6
|
+
# out into `parent.bytes * 8` boolean cells along a trailing bit
|
|
7
|
+
# axis appended after the parent's own axes, so the view's shape is
|
|
8
|
+
# `[*parent.shape, parent.bytes * 8]` and its `data_type` is
|
|
9
|
+
# `:boolean`.
|
|
10
|
+
#
|
|
11
|
+
# On big-endian hosts the bit axis of a non-fixlen parent reflects
|
|
12
|
+
# network byte order (parent bytes are walked in reverse within each
|
|
13
|
+
# element); single-byte parents are linear on either endian.
|
|
14
|
+
class CABitarray < CAView
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class CArray
|
|
18
|
+
# @!group Views
|
|
19
|
+
|
|
20
|
+
# Returns a {CABitarray} view of `self`, exposing every bit of
|
|
21
|
+
# every parent cell as an individual boolean cell. See
|
|
22
|
+
# {CABitarray} for the axis layout and endian handling.
|
|
23
|
+
#
|
|
24
|
+
# Aliased as `bits`.
|
|
25
|
+
#
|
|
26
|
+
# @overload bitarray
|
|
27
|
+
# @return [CABitarray]
|
|
28
|
+
# @raise [CADataTypeError] when `self.data_type` is a complex or
|
|
29
|
+
# object type (bit-level access is not defined for those).
|
|
30
|
+
def bitarray; end
|
|
31
|
+
|
|
32
|
+
# Alias for {#bitarray}.
|
|
33
|
+
#
|
|
34
|
+
# @return [CABitarray]
|
|
35
|
+
def bits; end
|
|
36
|
+
|
|
37
|
+
# @!endgroup
|
|
38
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CABitfield and CArray#bitfield defined in ext/ca_obj_bitfield.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
# Bit-field extraction view: each cell of `self` carries a contiguous
|
|
6
|
+
# bit field of the parent, exposed as an unsigned-integer (or boolean
|
|
7
|
+
# when the field is 1 bit wide) CArray of the same shape. Writes
|
|
8
|
+
# through the view are read-modify-write against the parent — bits
|
|
9
|
+
# outside the field are preserved.
|
|
10
|
+
class CABitfield < CAView
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class CArray
|
|
14
|
+
# @!group Views
|
|
15
|
+
|
|
16
|
+
# Returns a {CABitfield} view of `self`. Each parent cell is
|
|
17
|
+
# treated as a bag of bits; `range` selects a contiguous slice of
|
|
18
|
+
# those bits, and the resulting view exposes that slice as a cell
|
|
19
|
+
# of the returned array.
|
|
20
|
+
#
|
|
21
|
+
# `range` may be an integer (a single bit — the resulting view has
|
|
22
|
+
# `data_type :boolean`) or a `Range` covering the bit positions.
|
|
23
|
+
# The `data_type` of the view is chosen from the bit width:
|
|
24
|
+
# 1 bit → `:boolean`, 2..8 → `:uint8`, 9..16 → `:uint16`,
|
|
25
|
+
# 17..32 → `:uint32`, 33..64 → `:uint64`.
|
|
26
|
+
#
|
|
27
|
+
# `type` is accepted but currently ignored (the width-derived type
|
|
28
|
+
# is always used).
|
|
29
|
+
#
|
|
30
|
+
# @overload bitfield(range, type = nil)
|
|
31
|
+
# @param range [Integer, Range] bit position (single bit) or bit
|
|
32
|
+
# range within one parent cell.
|
|
33
|
+
# @param type [Symbol, nil] reserved, currently ignored.
|
|
34
|
+
# @return [CABitfield]
|
|
35
|
+
# @raise [IndexError] when `range` extends past the parent's bit
|
|
36
|
+
# width, when the range has a step != 1, or when the bit length
|
|
37
|
+
# is outside `1..64`.
|
|
38
|
+
# @raise [ArgumentError] when the derived bit length exceeds the
|
|
39
|
+
# resolved data type.
|
|
40
|
+
def bitfield(range, type = nil); end
|
|
41
|
+
|
|
42
|
+
# @!endgroup
|
|
43
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for CABlock accessors and address helpers defined in
|
|
3
|
+
# ext/ca_obj_block.c. The CABlock class shell lives in
|
|
4
|
+
# yard-stubs/ruby_carray.rb.
|
|
5
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
6
|
+
|
|
7
|
+
class CABlock
|
|
8
|
+
# @!group Block geometry
|
|
9
|
+
|
|
10
|
+
# @overload size0
|
|
11
|
+
# Returns the parent dimension sizes that the block is carved
|
|
12
|
+
# from (one Integer per axis). Distinct from `shape`, which is
|
|
13
|
+
# the block's own shape (= `count` after step / stride logic).
|
|
14
|
+
# @return [Array<Integer>]
|
|
15
|
+
def size0; end
|
|
16
|
+
|
|
17
|
+
# @overload start
|
|
18
|
+
# Returns the starting index of the block within the parent, per
|
|
19
|
+
# axis.
|
|
20
|
+
# @return [Array<Integer>]
|
|
21
|
+
def start; end
|
|
22
|
+
|
|
23
|
+
# @overload step
|
|
24
|
+
# Returns the per-axis step (stride in parent index units) the
|
|
25
|
+
# block walks the parent with.
|
|
26
|
+
# @return [Array<Integer>]
|
|
27
|
+
def step; end
|
|
28
|
+
|
|
29
|
+
# @overload count
|
|
30
|
+
# Returns the per-axis number of elements the block exposes.
|
|
31
|
+
# Same as `shape`.
|
|
32
|
+
# @return [Array<Integer>]
|
|
33
|
+
def count; end
|
|
34
|
+
|
|
35
|
+
# @overload offset
|
|
36
|
+
# Returns the block's base flat offset into the parent (in
|
|
37
|
+
# element units), set at construction and adjusted as start[]
|
|
38
|
+
# moves.
|
|
39
|
+
# @return [Integer]
|
|
40
|
+
def offset; end
|
|
41
|
+
|
|
42
|
+
# @!endgroup
|
|
43
|
+
|
|
44
|
+
# @!group Address mapping
|
|
45
|
+
|
|
46
|
+
# @overload idx2addr0(*idx)
|
|
47
|
+
# Maps a per-axis view index tuple to the corresponding flat
|
|
48
|
+
# address into the parent (= "addr0"). Useful for projecting a
|
|
49
|
+
# view-local coordinate back onto the parent's buffer.
|
|
50
|
+
# @param idx [Array<Integer>] one Integer per axis;
|
|
51
|
+
# `idx.length == self.ndim` is required.
|
|
52
|
+
# @return [Integer]
|
|
53
|
+
# @raise [ArgumentError] when the number of args does not equal
|
|
54
|
+
# `self.ndim`.
|
|
55
|
+
# @raise [IndexError] when any `idx[k]` is out of range for the
|
|
56
|
+
# block's `shape[k]`.
|
|
57
|
+
def idx2addr0(*idx); end
|
|
58
|
+
|
|
59
|
+
# @overload index2addr0(*idx)
|
|
60
|
+
# Alias of {#idx2addr0}.
|
|
61
|
+
def index2addr0(*idx); end
|
|
62
|
+
|
|
63
|
+
# @overload addr2addr0(addr)
|
|
64
|
+
# Flat-address variant of {#idx2addr0}. Unravels the block-local
|
|
65
|
+
# flat `addr` into a multi-dim index, then maps that to the
|
|
66
|
+
# parent's flat address.
|
|
67
|
+
# @param addr [Integer] block-local flat address
|
|
68
|
+
# (`0...self.elements`).
|
|
69
|
+
# @return [Integer]
|
|
70
|
+
def addr2addr0(addr); end
|
|
71
|
+
|
|
72
|
+
# @!endgroup
|
|
73
|
+
end
|
|
@@ -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
|