carray 3.0.6 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +7 -1830
  4. data/README.md +62 -35
  5. data/carray.gemspec +16 -4
  6. data/docs/changelogs/CHANGELOG-3.0.md +2464 -0
  7. data/ext/ca_array_pool.c +4 -5
  8. data/ext/ca_axis_descriptor.h +45 -30
  9. data/ext/ca_axis_dispatch.c +7 -4
  10. data/ext/ca_axis_group.c +12 -15
  11. data/ext/ca_bincmp_dispatch.h +16 -38
  12. data/ext/ca_binop_dispatch.c +35 -0
  13. data/ext/ca_binop_dispatch.h +22 -46
  14. data/ext/ca_categorical_iterator.c +36 -34
  15. data/ext/ca_compare.c +0 -1
  16. data/ext/ca_compare.h +8 -1
  17. data/ext/ca_composite_dispatch.h +6 -0
  18. data/ext/ca_for_buffer.h +6 -1
  19. data/ext/ca_group_iter.c +17 -18
  20. data/ext/ca_iter_state_fields.h +196 -0
  21. data/ext/ca_iter_substrate.h +84 -103
  22. data/ext/ca_kernel_iterator.c +125 -89
  23. data/ext/ca_kernel_iterator.h +229 -1504
  24. data/ext/ca_kernel_iterator_internal.h +1167 -0
  25. data/ext/ca_moncmp_dispatch.h +17 -24
  26. data/ext/ca_monop_dispatch.h +25 -74
  27. data/ext/ca_obj_array.c +92 -165
  28. data/ext/ca_obj_bincmp.c +65 -48
  29. data/ext/ca_obj_binop.c +74 -49
  30. data/ext/ca_obj_bitarray.c +7 -21
  31. data/ext/ca_obj_bitfield.c +93 -26
  32. data/ext/ca_obj_block.c +11 -12
  33. data/ext/ca_obj_byte_swap.c +34 -34
  34. data/ext/ca_obj_const_string.c +464 -304
  35. data/ext/ca_obj_face.c +167 -121
  36. data/ext/ca_obj_face.h +32 -170
  37. data/ext/ca_obj_fake.c +127 -34
  38. data/ext/ca_obj_farray.c +13 -9
  39. data/ext/ca_obj_field.c +17 -13
  40. data/ext/ca_obj_fixlen_string.c +57 -34
  41. data/ext/ca_obj_grid.c +149 -113
  42. data/ext/ca_obj_meld.c +28 -26
  43. data/ext/ca_obj_moncmp.c +10 -21
  44. data/ext/ca_obj_monop.c +88 -73
  45. data/ext/ca_obj_object.c +60 -46
  46. data/ext/ca_obj_record.c +74 -22
  47. data/ext/ca_obj_reduce.c +10 -14
  48. data/ext/ca_obj_refer.c +146 -39
  49. data/ext/ca_obj_remap.c +11 -29
  50. data/ext/ca_obj_repeat.c +41 -23
  51. data/ext/ca_obj_roll.c +20 -28
  52. data/ext/ca_obj_select.c +17 -27
  53. data/ext/ca_obj_select_axis.c +35 -42
  54. data/ext/ca_obj_shift.c +22 -42
  55. data/ext/ca_obj_source.c +1 -5
  56. data/ext/ca_obj_stack.c +33 -29
  57. data/ext/ca_obj_stride.c +99 -62
  58. data/ext/ca_obj_string.c +8 -20
  59. data/ext/ca_obj_tile.c +14 -16
  60. data/ext/ca_obj_time.c +12 -23
  61. data/ext/ca_obj_timedelta.c +12 -23
  62. data/ext/ca_obj_transpose.c +8 -10
  63. data/ext/ca_obj_triop.c +48 -49
  64. data/ext/ca_obj_window.c +87 -99
  65. data/ext/ca_op_cmplx64.h +4 -0
  66. data/ext/ca_op_ipower.c +97 -27
  67. data/ext/ca_op_powi.h +9 -28
  68. data/ext/ca_pow5_table.h +2 -1
  69. data/ext/ca_rng_normal.h +4 -0
  70. data/ext/ca_rng_xoshiro256pp.h +3 -0
  71. data/ext/ca_sort_kernels.h +23 -26
  72. data/ext/ca_sweep_engine.c +92 -26
  73. data/ext/ca_sweep_engine.h +22 -15
  74. data/ext/ca_transform_common.c +3 -8
  75. data/ext/ca_triop_dispatch.h +20 -32
  76. data/ext/caframe_csv_reader.c +12 -12
  77. data/ext/carray.h +300 -1009
  78. data/ext/carray_access.c +320 -207
  79. data/ext/carray_address_basis.c +128 -59
  80. data/ext/carray_attribute.c +81 -104
  81. data/ext/carray_bincount.c +12 -14
  82. data/ext/carray_broadcast.c +31 -27
  83. data/ext/carray_call_cfunc.c +174 -285
  84. data/ext/carray_call_cfunc.h +36 -28
  85. data/ext/carray_cast.c +1191 -351
  86. data/ext/carray_cast_func.rb +68 -8
  87. data/ext/carray_class.c +6 -11
  88. data/ext/carray_conversion.c +98 -39
  89. data/ext/carray_copy.c +52 -26
  90. data/ext/carray_core.c +286 -132
  91. data/ext/carray_count.c +53 -22
  92. data/ext/carray_element.c +49 -28
  93. data/ext/carray_factorize.c +64 -63
  94. data/ext/carray_generate.c +26 -19
  95. data/ext/carray_histogram.c +9 -11
  96. data/ext/carray_hold.c +7 -9
  97. data/ext/carray_index_classifier.c +127 -230
  98. data/ext/carray_index_classifier.h +11 -10
  99. data/ext/carray_integer_total.c +523 -0
  100. data/ext/carray_internal.h +1364 -156
  101. data/ext/carray_key_windows.c +3 -3
  102. data/ext/carray_lazy.c +37 -37
  103. data/ext/carray_loop.c +27 -23
  104. data/ext/carray_mask.c +235 -150
  105. data/ext/carray_math_kernel.h +23 -47
  106. data/ext/carray_mathfunc.c +10 -3
  107. data/ext/carray_median_percentile.c +106 -100
  108. data/ext/carray_memory_view.c +83 -69
  109. data/ext/carray_operator.c +490 -128
  110. data/ext/carray_order.c +163 -84
  111. data/ext/carray_partition.c +14 -16
  112. data/ext/carray_random.c +48 -42
  113. data/ext/carray_round.c +33 -5
  114. data/ext/carray_scatter.c +57 -39
  115. data/ext/carray_segment.c +42 -46
  116. data/ext/carray_slab.c +77 -51
  117. data/ext/carray_slab.h +44 -33
  118. data/ext/carray_sort.c +37 -31
  119. data/ext/carray_sort_kernel.c +36 -10
  120. data/ext/carray_struct.c +44 -34
  121. data/ext/carray_test.c +131 -81
  122. data/ext/carray_time_text.c +30 -31
  123. data/ext/carray_undef.c +50 -7
  124. data/ext/carray_utils.c +373 -139
  125. data/ext/extconf.rb +24 -17
  126. data/ext/mk_call_cfunc.rb +25 -31
  127. data/ext/mk_pow5_table.rb +2 -1
  128. data/ext/mkkernel.rb +819 -488
  129. data/ext/ruby_carray.c +47 -42
  130. data/ext/version.h +7 -5
  131. data/lib/carray/attribute.rb +19 -18
  132. data/lib/carray/autoload_carray.rb +20 -15
  133. data/lib/carray/autoload_method_extension.rb +64 -57
  134. data/lib/carray/axis_group.rb +272 -185
  135. data/lib/carray/basics.rb +298 -56
  136. data/lib/carray/bincount_nd.rb +41 -18
  137. data/lib/carray/block_iterator.rb +167 -119
  138. data/lib/carray/boolean_reduce.rb +7 -4
  139. data/lib/carray/categorical.rb +84 -59
  140. data/lib/carray/categorical_iterator.rb +90 -67
  141. data/lib/carray/complex.rb +61 -41
  142. data/lib/carray/conditional.rb +98 -23
  143. data/lib/carray/const_string.rb +112 -46
  144. data/lib/carray/core_extensions.rb +20 -69
  145. data/lib/carray/distance_limit.rb +7 -5
  146. data/lib/carray/factories.rb +269 -0
  147. data/lib/carray/fixlen_string.rb +95 -12
  148. data/lib/carray/frame/column_verbs.rb +76 -9
  149. data/lib/carray/frame/concat.rb +51 -7
  150. data/lib/carray/frame/convert.rb +2 -1
  151. data/lib/carray/frame/csv_parser.rb +20 -5
  152. data/lib/carray/frame/frame.rb +73 -31
  153. data/lib/carray/frame/group.rb +247 -187
  154. data/lib/carray/frame/io.rb +36 -12
  155. data/lib/carray/frame/join.rb +56 -17
  156. data/lib/carray/frame/records.rb +7 -5
  157. data/lib/carray/frame/reshape.rb +27 -7
  158. data/lib/carray/frame/sort.rb +10 -8
  159. data/lib/carray/frame/verbs.rb +217 -134
  160. data/lib/carray/frame/windows.rb +254 -19
  161. data/lib/carray/frame.rb +1 -2
  162. data/lib/carray/fuse_source.rb +28 -23
  163. data/lib/carray/fusion.rb +30 -30
  164. data/lib/carray/histogram.rb +35 -16
  165. data/lib/carray/inspect.rb +7 -7
  166. data/lib/carray/iterator.rb +104 -23
  167. data/lib/carray/key_windows.rb +93 -61
  168. data/lib/carray/lazy.rb +208 -111
  169. data/lib/carray/limits.rb +80 -0
  170. data/lib/carray/mask_gap_fill.rb +21 -16
  171. data/lib/carray/math.rb +87 -50
  172. data/lib/carray/meld_reduce.rb +30 -8
  173. data/lib/carray/methods/align_addr.rb +29 -17
  174. data/lib/carray/methods/bin.rb +8 -1
  175. data/lib/carray/methods/bincount.rb +4 -2
  176. data/lib/carray/methods/bit_string.rb +19 -31
  177. data/lib/carray/methods/broadcast.rb +8 -3
  178. data/lib/carray/methods/choose.rb +5 -5
  179. data/lib/carray/methods/composition.rb +73 -72
  180. data/lib/carray/methods/{index.rb → coordinate.rb} +13 -13
  181. data/lib/carray/methods/discovery_along.rb +3 -3
  182. data/lib/carray/methods/factorize.rb +2 -0
  183. data/lib/carray/methods/gather_nd.rb +106 -103
  184. data/lib/carray/methods/insert_block.rb +2 -2
  185. data/lib/carray/methods/is_between.rb +6 -4
  186. data/lib/carray/methods/is_in.rb +183 -143
  187. data/lib/carray/methods/join.rb +2 -1
  188. data/lib/carray/methods/lag.rb +6 -2
  189. data/lib/carray/methods/locate_addr.rb +157 -94
  190. data/lib/carray/methods/mask_duplicates.rb +1 -1
  191. data/lib/carray/methods/meshgrid.rb +28 -16
  192. data/lib/carray/methods/mode.rb +67 -67
  193. data/lib/carray/methods/nunique.rb +9 -7
  194. data/lib/carray/methods/repeat.rb +23 -13
  195. data/lib/carray/methods/resize.rb +1 -1
  196. data/lib/carray/methods/snap.rb +24 -20
  197. data/lib/carray/methods/string_format.rb +2 -2
  198. data/lib/carray/methods/unique.rb +4 -2
  199. data/lib/carray/methods/value_counts.rb +1 -1
  200. data/lib/carray/mkmf.rb +25 -28
  201. data/lib/carray/percentile_arguments.rb +82 -0
  202. data/lib/carray/record_order.rb +50 -20
  203. data/lib/carray/rng.rb +1 -0
  204. data/lib/carray/runtime.rb +195 -17
  205. data/lib/carray/segment_iterator.rb +262 -137
  206. data/lib/carray/serialize.rb +635 -566
  207. data/lib/carray/slab_iterator.rb +114 -114
  208. data/lib/carray/stack.rb +14 -15
  209. data/lib/carray/string.rb +16 -22
  210. data/lib/carray/string_operation_extension.rb +97 -52
  211. data/lib/carray/struct.rb +122 -164
  212. data/lib/carray/struct_builder.rb +247 -73
  213. data/lib/carray/time.rb +663 -365
  214. data/lib/carray/window_iterator.rb +232 -155
  215. data/lib/carray.rb +6 -11
  216. data/yard-stubs/ca_obj_array.rb +20 -135
  217. data/yard-stubs/ca_obj_bitarray.rb +1 -8
  218. data/yard-stubs/ca_obj_bitfield.rb +6 -2
  219. data/yard-stubs/ca_obj_byte_swap.rb +21 -7
  220. data/yard-stubs/ca_obj_fake.rb +3 -1
  221. data/yard-stubs/ca_obj_farray.rb +1 -1
  222. data/yard-stubs/ca_obj_field.rb +8 -6
  223. data/yard-stubs/ca_obj_refer.rb +10 -5
  224. data/yard-stubs/ca_obj_roll.rb +7 -6
  225. data/yard-stubs/ca_obj_shift.rb +2 -3
  226. data/yard-stubs/ca_obj_stride.rb +5 -7
  227. data/yard-stubs/ca_obj_tile.rb +1 -1
  228. data/yard-stubs/ca_obj_time.rb +43 -0
  229. data/yard-stubs/ca_obj_transpose.rb +1 -1
  230. data/yard-stubs/ca_obj_window.rb +28 -16
  231. data/yard-stubs/carray_access.rb +55 -6
  232. data/yard-stubs/carray_attribute.rb +26 -38
  233. data/yard-stubs/carray_cast.rb +121 -162
  234. data/yard-stubs/carray_class.rb +3 -4
  235. data/yard-stubs/carray_conversion.rb +6 -7
  236. data/yard-stubs/carray_copy.rb +2 -1
  237. data/yard-stubs/carray_count.rb +10 -5
  238. data/yard-stubs/carray_element.rb +4 -3
  239. data/yard-stubs/carray_limits.rb +100 -0
  240. data/yard-stubs/carray_loop.rb +0 -20
  241. data/yard-stubs/carray_mask.rb +59 -41
  242. data/yard-stubs/carray_math.rb +162 -100
  243. data/yard-stubs/carray_mathfunc.rb +415 -3
  244. data/yard-stubs/carray_median_percentile.rb +29 -11
  245. data/yard-stubs/carray_memory_view.rb +2 -2
  246. data/yard-stubs/carray_order.rb +72 -33
  247. data/yard-stubs/carray_random.rb +6 -6
  248. data/yard-stubs/carray_reduce.rb +353 -0
  249. data/yard-stubs/carray_rng.rb +92 -0
  250. data/yard-stubs/carray_scatter.rb +12 -3
  251. data/yard-stubs/carray_slab.rb +7 -4
  252. data/yard-stubs/carray_sort.rb +7 -6
  253. data/yard-stubs/carray_test.rb +18 -5
  254. data/yard-stubs/carray_undef.rb +44 -5
  255. data/yard-stubs/ruby_carray.rb +75 -40
  256. metadata +63 -25
  257. data/CHANGELOG.v1.md +0 -126
  258. data/ext/carray_build_flags.h +0 -3
  259. data/ext/carray_config.h +0 -28
  260. data/ext/carray_data_type.c +0 -90
  261. data/ext/carray_kernels_bincmp.c +0 -6457
  262. data/ext/carray_kernels_binop.c +0 -31534
  263. data/ext/carray_kernels_init.c +0 -1734
  264. data/ext/carray_kernels_moncmp.c +0 -2104
  265. data/ext/carray_kernels_monop.c +0 -25387
  266. data/ext/carray_kernels_reduce_aggregate.c +0 -27545
  267. data/ext/carray_kernels_reduce_boolean.c +0 -1924
  268. data/ext/carray_kernels_reduce_cumulative.c +0 -11646
  269. data/ext/carray_kernels_reduce_extreme.c +0 -21631
  270. data/ext/carray_kernels_reduce_variance.c +0 -5981
  271. data/ext/carray_kernels_scan.c +0 -4302
  272. data/ext/carray_kernels_search.c +0 -37776
  273. data/ext/carray_kernels_sort.c +0 -10814
  274. data/ext/carray_kernels_triop.c +0 -1864
  275. data/lib/carray/construct.rb +0 -360
  276. data/lib/carray/data_type_extension.rb +0 -261
  277. data/lib/carray/data_type_limits.rb +0 -91
data/lib/carray.rb CHANGED
@@ -7,10 +7,8 @@ require 'carray_ext'
7
7
  CArray.send(:library_root=, __dir__)
8
8
 
9
9
  # Top-level CAMath module -- math namespace for CArrays.
10
- # `CAMath.sin(ca)` works because module functions inherited
11
- # from Math (via include) accept any object that responds to
12
- # the corresponding instance method; CArray defines those in
13
- # C.
10
+ # CAMath includes Math for its constants (CAMath::PI, CAMath::E). The
11
+ # functions of CAMath are defined in C and in lib/carray/math.rb.
14
12
  module CAMath
15
13
  include Math
16
14
  end
@@ -18,13 +16,13 @@ end
18
16
  # carray/inspect is loaded lazily via autoload_carray (#inspect / #source_code
19
17
  # stubs). #inspect fires on the first p / pp / irb display or error-message
20
18
  # interpolation, so compute programs that never print a CArray skip it.
21
- require 'carray/construct'
22
- require 'carray/data_type_extension'
23
- require 'carray/data_type_limits' # MIN / MAX / TINY / EPSILON on the typed classes
19
+ require 'carray/factories' # zeros / ones / eye / linspace / arange / full / empty
20
+ require 'carray/limits' # CArray::Limits::INT32_MAX and the rest
24
21
  # carray/stack is loaded lazily via autoload_carray (entry-method stubs).
25
22
  # CAStack is C-defined so its constant is always present; only the Ruby
26
23
  # composition surface (stack/meld/montage/split/append) needs the file.
27
24
  require 'carray/runtime' # load-bearing Ruby support the core depends on
25
+ require 'carray/percentile_arguments' # how percentile reads p and returns answers (the C core calls it)
28
26
  require 'carray/basics' # frequently-used convenience methods kept eager
29
27
  require 'carray/conditional' # then_else / replace_where / conditional
30
28
  require 'carray/mask_gap_fill' # unmask/strip_mask method: keyword (hold / linear gap-fill)
@@ -39,9 +37,6 @@ require 'carray/rng' # CArray::Rng: the generator its C is shared from
39
37
  require 'carray/complex' # real / imag accessors; MUST precede carray/lazy
40
38
  # (lazy aliases real/imag at load time)
41
39
  require 'carray/lazy' # the lazy elementwise view layer
42
- # carray/face.rb was deleted (the Phase 1 skeleton CArray::Face module
43
- # became dead weight, replaced by C-layer macro deploy +
44
- # copy_state/storage_to_element convention).
45
40
  require 'carray/time' # CATime / CATimedelta
46
41
  # carray/methods/* (bincount / broadcast / gather_nd+put_nd) are small
47
42
  # single-feature method files, loaded lazily via autoload_carray.
@@ -58,7 +53,7 @@ require 'carray/fixlen_string' # CAFixlenString construction surface
58
53
  require 'carray/inspect'
59
54
  # CArray.format lives in carray/methods/string_format.rb, autoloaded on first call
60
55
 
61
- # carray/frame is loaded lazily via autoload_carray (CAFrame / GroupedFrame
56
+ # carray/frame is loaded lazily via autoload_carray (CAFrame / CAGroupedFrame
62
57
  # constants). Nothing in the eager core references the frame, so programs that
63
58
  # only use arrays never pay its load cost.
64
59
 
@@ -7,10 +7,22 @@ class CArray
7
7
 
8
8
  # @overload initialize(data_type, shape)
9
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.
10
+ # every cell set to 0.
11
+ # @param data_type [Symbol, String] element type.
12
12
  # @param shape [Array<Integer>] one extent per axis.
13
13
  # @return [self]
14
+ # @overload initialize(data_type, shape, raw: true)
15
+ # Allocates without the zero fill: the contents are undefined until
16
+ # written. Use it when every cell is written before it is read.
17
+ # `:object` arrays are set to 0 anyway, because the garbage
18
+ # collector walks them. The typed constructors take it too
19
+ # (`CArray.int32(n, raw: true)`); {CArray.empty} is the same with
20
+ # the shape first.
21
+ # @param data_type [Symbol, String]
22
+ # @param shape [Array<Integer>]
23
+ # @param raw [Boolean] true to leave out the zero fill (default false).
24
+ # @return [self]
25
+ # @raise [ArgumentError] if `raw` is not true, false or nil.
14
26
  # @overload initialize(data_type, shape, bytes:)
15
27
  # For `data_type == :fixlen`, sets the per-element byte size.
16
28
  # Ignored for numeric types.
@@ -56,14 +68,11 @@ class CArray
56
68
  class << self
57
69
  # @!group Construction (typed shorthands)
58
70
  #
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]
71
+ # `CArray.<type>(*shape)` is a shorthand for
72
+ # `CArray.new(:<type>, shape)`. The shorthands accept the same
73
+ # optional block as `initialize`. Without a shape they raise
74
+ # `ArgumentError`.
75
+
67
76
  # @overload fixlen(*shape, bytes:) { ... }
68
77
  # Equivalent to `CArray.new(:fixlen, shape, bytes: bytes) { ... }`.
69
78
  # The `bytes:` keyword is required for `:fixlen`, and is 1 or more.
@@ -72,171 +81,78 @@ class CArray
72
81
  # @return [CArray]
73
82
  def fixlen(*shape, bytes: nil); end
74
83
 
75
- # @overload boolean
76
- # Returns the typed class `CArray::Boolean`.
77
- # @return [Class]
78
84
  # @overload boolean(*shape) { ... }
79
85
  # Equivalent to `CArray.new(:boolean, shape) { ... }`.
80
86
  # @param shape [Array<Integer>]
81
87
  # @return [CArray]
82
88
  def boolean(*shape); end
83
89
 
84
- # @overload int8
85
- # Returns the typed class `CArray::Int8`.
86
- # @return [Class]
87
90
  # @overload int8(*shape) { ... }
88
91
  # Equivalent to `CArray.new(:int8, shape) { ... }`.
89
92
  # @return [CArray]
90
93
  def int8(*shape); end
91
94
 
92
- # @overload uint8
93
- # Returns the typed class `CArray::UInt8`.
94
- # @return [Class]
95
95
  # @overload uint8(*shape) { ... }
96
96
  # Equivalent to `CArray.new(:uint8, shape) { ... }`.
97
97
  # @return [CArray]
98
98
  def uint8(*shape); end
99
99
 
100
- # @overload int16
101
- # Returns the typed class `CArray::Int16`.
102
- # @return [Class]
103
100
  # @overload int16(*shape) { ... }
104
101
  # Equivalent to `CArray.new(:int16, shape) { ... }`.
105
102
  # @return [CArray]
106
103
  def int16(*shape); end
107
104
 
108
- # @overload uint16
109
- # Returns the typed class `CArray::UInt16`.
110
- # @return [Class]
111
105
  # @overload uint16(*shape) { ... }
112
106
  # Equivalent to `CArray.new(:uint16, shape) { ... }`.
113
107
  # @return [CArray]
114
108
  def uint16(*shape); end
115
109
 
116
- # @overload int32
117
- # Returns the typed class `CArray::Int32`.
118
- # @return [Class]
119
110
  # @overload int32(*shape) { ... }
120
111
  # Equivalent to `CArray.new(:int32, shape) { ... }`.
121
112
  # @return [CArray]
122
113
  def int32(*shape); end
123
114
 
124
- # @overload uint32
125
- # Returns the typed class `CArray::UInt32`.
126
- # @return [Class]
127
115
  # @overload uint32(*shape) { ... }
128
116
  # Equivalent to `CArray.new(:uint32, shape) { ... }`.
129
117
  # @return [CArray]
130
118
  def uint32(*shape); end
131
119
 
132
- # @overload int64
133
- # Returns the typed class `CArray::Int64`.
134
- # @return [Class]
135
120
  # @overload int64(*shape) { ... }
136
121
  # Equivalent to `CArray.new(:int64, shape) { ... }`.
137
122
  # @return [CArray]
138
123
  def int64(*shape); end
139
124
 
140
- # @overload uint64
141
- # Returns the typed class `CArray::UInt64`.
142
- # @return [Class]
143
125
  # @overload uint64(*shape) { ... }
144
126
  # Equivalent to `CArray.new(:uint64, shape) { ... }`.
145
127
  # @return [CArray]
146
128
  def uint64(*shape); end
147
129
 
148
- # @overload float32
149
- # Returns the typed class `CArray::Float32`.
150
- # @return [Class]
151
130
  # @overload float32(*shape) { ... }
152
131
  # Equivalent to `CArray.new(:float32, shape) { ... }`.
153
132
  # @return [CArray]
154
133
  def float32(*shape); end
155
134
 
156
- # @overload float64
157
- # Returns the typed class `CArray::Float64`.
158
- # @return [Class]
159
135
  # @overload float64(*shape) { ... }
160
136
  # Equivalent to `CArray.new(:float64, shape) { ... }`.
161
137
  # @return [CArray]
162
138
  def float64(*shape); end
163
139
 
164
- # @overload cmplx64
165
- # Returns the typed class `CArray::Cmplx64`.
166
- # @return [Class]
167
140
  # @overload cmplx64(*shape) { ... }
168
141
  # Equivalent to `CArray.new(:cmplx64, shape) { ... }`.
169
142
  # @return [CArray]
170
143
  def cmplx64(*shape); end
171
144
 
172
- # @overload cmplx128
173
- # Returns the typed class `CArray::Cmplx128`.
174
- # @return [Class]
175
145
  # @overload cmplx128(*shape) { ... }
176
146
  # Equivalent to `CArray.new(:cmplx128, shape) { ... }`.
177
147
  # @return [CArray]
178
148
  def cmplx128(*shape); end
179
149
 
180
- # @overload object
181
- # Returns the typed class `CArray::Object`.
182
- # @return [Class]
183
150
  # @overload object(*shape) { ... }
184
151
  # Equivalent to `CArray.new(:object, shape) { ... }`.
185
152
  # @return [CArray]
186
153
  def object(*shape); end
187
154
 
188
155
  # @!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
156
  end
241
157
  end
242
158
 
@@ -246,7 +162,7 @@ class CScalar
246
162
  # @overload initialize(data_type)
247
163
  # Allocates a CScalar of the given `data_type`: one cell on one axis
248
164
  # (`ndim` 1, `shape` `[1]`).
249
- # @param data_type [Symbol, Integer, Class, String]
165
+ # @param data_type [Symbol, Class, String]
250
166
  # @return [self]
251
167
  # @overload initialize(data_type, bytes:)
252
168
  # For `data_type == :fixlen`, sets the per-element byte size.
@@ -375,36 +291,5 @@ class CScalar
375
291
 
376
292
  # @!endgroup
377
293
 
378
- # @!group Construction (legacy-name aliases)
379
-
380
- # @overload byte
381
- # Alias of {.uint8}.
382
- def byte; end
383
-
384
- # @overload short
385
- # Alias of {.int16}.
386
- def short; end
387
-
388
- # @overload int
389
- # Alias of {.int32}.
390
- def int; end
391
-
392
- # @overload float
393
- # Alias of {.float32}.
394
- def float; end
395
-
396
- # @overload double
397
- # Alias of {.float64}.
398
- def double; end
399
-
400
- # @overload complex
401
- # Alias of {.cmplx64}.
402
- def complex; end
403
-
404
- # @overload dcomplex
405
- # Alias of {.cmplx128}.
406
- def dcomplex; end
407
-
408
- # @!endgroup
409
294
  end
410
295
  end
@@ -26,20 +26,13 @@ class CArray
26
26
  # every parent cell as an individual boolean cell. See
27
27
  # {CABitarray} for the axis layout and endian handling.
28
28
  #
29
- # Aliased as `bits`.
30
- #
31
29
  # @overload bitarray
32
30
  # @return [CABitarray]
33
- # @raise [CADataTypeError] when `self.data_type` is a complex or
31
+ # @raise [CArray::DataTypeError] when `self.data_type` is a complex or
34
32
  # object type (bit-level access is not defined for those).
35
33
  # @raise [ArgumentError] when `self` has a mask; use
36
34
  # `value.bitarray` to read the bits without it.
37
35
  def bitarray; end
38
36
 
39
- # Alias for {#bitarray}.
40
- #
41
- # @return [CABitarray]
42
- def bits; end
43
-
44
37
  # @!endgroup
45
38
  end
@@ -30,12 +30,16 @@ class CArray
30
30
  # narrowest unsigned type that holds the field is used: 1 bit →
31
31
  # `:boolean`, 2..8 → `:uint8`, 9..16 → `:uint16`, 17..32 → `:uint32`,
32
32
  # 33..64 → `:uint64`. A write keeps the low bits of the value that
33
- # fit the field, signed or not (-3 into a 3-bit field is `0b101`).
33
+ # fit the field, signed or not, for an Integer of any size (-3 into a
34
+ # 3-bit field is `0b101`, 300 is `0b100`). The same holds for a view
35
+ # taken of the field (a slice, an index, a mask selection). A Float
36
+ # goes through `Integer()`; a String is refused, as a store into any
37
+ # number cell refuses it.
34
38
  #
35
39
  # @overload bitfield(range, type = nil)
36
40
  # @param range [Integer, Range] bit position (single bit) or bit
37
41
  # range within one parent cell.
38
- # @param type [Symbol, Integer, nil] the integer type the field is
42
+ # @param type [Symbol, nil] the integer type the field is
39
43
  # read as, or `nil` for the narrowest unsigned type.
40
44
  # @return [CABitfield]
41
45
  # @raise [IndexError] when `range` extends past the parent's bit
@@ -6,8 +6,8 @@
6
6
  # Byte-order-reversed view of the parent. Same shape and byte
7
7
  # width as the parent; each cell exposes the byte-reversed
8
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.
9
+ # routes through `CAMonOp` instead, so a CAByteSwap is seen only as
10
+ # the storage under a record's `swap_bytes`.
11
11
  #
12
12
  # Writes through the view flow back to the parent on detach
13
13
  # (byte-swap is involutive).
@@ -19,16 +19,27 @@ class CArray
19
19
 
20
20
  # Returns a lazy view of `self` whose cells are byte-swapped
21
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.
22
+ # Each number is swapped by the width of its type (a complex
23
+ # number swaps its two parts). A record is swapped member by
24
+ # member.
24
25
  #
25
- # For eager copy semantics use `arr.swap_bytes.to_ca`. The
26
+ # A fixlen cell has no byte order: CArray does not know whether its
27
+ # bytes are one number, several numbers, or text. So a fixlen array
28
+ # (CAFixlenString and CAConstString included) is returned as it is,
29
+ # as a uint8 or boolean array is left unchanged, and the fixlen
30
+ # members of a record stay as they are. To swap the bytes of fixlen
31
+ # cells as numbers, give them a type first (`refer` or `as_type`).
32
+ # A Face that knows what its cells hold can define `swap_bytes` for
33
+ # itself; {#endian} uses that definition.
34
+ #
35
+ # For eager copy semantics use `arr.swap_bytes.copy`. The
26
36
  # in-place idiom is `ca[] = ca.swap_bytes`; there is no
27
37
  # `swap_bytes!`.
28
38
  #
29
39
  # @overload swap_bytes
30
- # @return [CArray] byte-swapped view of `self`.
31
- # @raise [CADataTypeError] when `self.data_type` is `CA_OBJECT`
40
+ # @return [CArray] byte-swapped view of `self`, or `self` for a
41
+ # fixlen array.
42
+ # @raise [CArray::DataTypeError] when `self.data_type` is `CA_OBJECT`
32
43
  # (object arrays cannot be byte-swapped).
33
44
  def swap_bytes; end
34
45
 
@@ -42,6 +53,9 @@ class CArray
42
53
  # - `:little` — identity on little-endian hosts, otherwise a
43
54
  # byte-swap view.
44
55
  #
56
+ # The byte-swap view is what {#swap_bytes} returns, so a fixlen array
57
+ # is returned as it is in every byte order.
58
+ #
45
59
  # The keyword set matches `BulkMemoryView.from(producer, endian:)`.
46
60
  #
47
61
  # @overload endian(byte_order)
@@ -21,7 +21,9 @@ class CArray
21
21
  # hide. Use {CArray#to_type} for the values, or `face.parent.fake` to
22
22
  # reinterpret the storage on purpose. A Numeric Face, whose surface *is*
23
23
  # its storage, is unaffected.
24
- # @param data_type [Symbol, Integer, Class, String]
24
+ # @param data_type [Symbol, Class, String] a data class (from `CArray.struct`) reads fixlen cells of its size as records (a
25
+ # {CARecord}) and refuses other cells, and a Face whose storage
26
+ # is not its values (a const string).
25
27
  # @param bytes [Integer] element byte size for `:fixlen` (1 or more).
26
28
  # @return [CAFake]
27
29
  # @raise [TypeError] when `self` is a Face and the request would read its
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  # Mask companion of {CAFarray}.
13
13
  # @private
14
- class CAFarrayMask < CAFarray
14
+ class CAFarray::Mask < CAFarray
15
15
  end
16
16
 
17
17
  class CArray
@@ -12,11 +12,13 @@ class CArray
12
12
  # `bytes`-wide slice of element type `data_type` at byte `offset`
13
13
  # within the corresponding record. No data is copied; writes go
14
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.
15
+ # @param offset [Integer] byte offset of the field within one
16
+ # record (in bytes, not elements; {#refer}'s `offset:` counts
17
+ # parent elements instead).
18
+ # @param data_type [Symbol] element type.
17
19
  # `:object` is not allowed.
18
- # @param bytes [Integer, nil] element size; required for `:fixlen`,
19
- # inferred otherwise.
20
+ # @param bytes [Integer, nil] element size; required for `:fixlen`; another type refuses a
21
+ # width other than its own.
20
22
  # @return [CAField]
21
23
  # @raise [ArgumentError] when `offset` is negative or the
22
24
  # `offset + bytes` window falls outside one parent record.
@@ -28,13 +30,13 @@ class CArray
28
30
  # Returns a CARefer over a {CAField}: takes `template.elements *
29
31
  # template.bytes` bytes at `offset` and exposes them with
30
32
  # `template`'s element type and trailing shape.
31
- # @param offset [Integer]
33
+ # @param offset [Integer] byte offset within one record.
32
34
  # @param template [CArray] element type and trailing shape donor.
33
35
  # @return [CArray]
34
36
  # @overload field(offset, data_class)
35
37
  # Returns a `CARecord` wrapping a {CAField} so the result carries
36
38
  # `data_class`'s encode/decode dispatch.
37
- # @param offset [Integer]
39
+ # @param offset [Integer] byte offset within one record.
38
40
  # @param data_class [Class] e.g. a CAStruct subclass.
39
41
  # @return [CArray]
40
42
  # @overload field(name)
@@ -24,17 +24,22 @@ class CArray
24
24
  # @overload refer
25
25
  # @return [CARefer] a same-shape same-width alias of `self`.
26
26
  # @overload refer(data_type, dim = nil, bytes: nil, offset: 0)
27
- # @param data_type [Integer, Symbol, Class] target data type or
27
+ # @param data_type [Symbol, String, Class] target data type or
28
28
  # a data_class.
29
29
  # @param dim [Array<Integer>, nil] target shape; `nil` reuses
30
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.
31
+ # @param bytes [Integer, nil] width of a `:fixlen` element;
32
+ # defaults to `self.bytes`. Another type refuses a width other
33
+ # than its own.
34
+ # @param offset [Integer] offset in parent elements (not bytes;
35
+ # {#field}'s first argument is a byte offset within one record).
34
36
  # @return [CARefer, CARecord]
35
37
  # @raise [ArgumentError] when the byte widths do not divide
36
38
  # evenly, when `offset` is negative, or when the requested
37
39
  # view extends past the parent's data.
40
+ # @raise [TypeError] on a Face, for a data type that is neither its
41
+ # surface type nor its storage type: `to_type` gives the values,
42
+ # `parent.refer` the raw storage.
38
43
  # @raise [CArray::DataTypeError] when reinterpreting a CA_OBJECT parent
39
44
  # with a non-object `data_type`, or a parent of another data type as
40
45
  # `:boolean` (a boolean cell holds 0 or 1; compare instead, `ne(0)`).
@@ -54,7 +59,7 @@ class CArray
54
59
  # `-1` or `:~` marks the auto-infer placeholder (at most one).
55
60
  # @return [CArray] the reshape view.
56
61
  # @raise [ArgumentError] when the number of dims exceeds
57
- # `CA_RANK_MAX`.
62
+ # `CArray::RANK_MAX`.
58
63
  # @raise [ArgumentError] when the product does not equal
59
64
  # `self.elements` (with no placeholder), when the placeholder
60
65
  # cannot be inferred, when more than one placeholder is
@@ -15,7 +15,7 @@ end
15
15
 
16
16
  # Mask companion of {CARoll}.
17
17
  # @private
18
- class CARollMask < CARoll
18
+ class CARoll::Mask < CARoll
19
19
  end
20
20
 
21
21
  class CArray
@@ -27,17 +27,18 @@ class CArray
27
27
  # the other way. Each `shift[k]` is normalised into
28
28
  # `[0, self.shape[k])` before use, so any integer is accepted.
29
29
  #
30
- # Fewer args than `ndim` treats the missing axes as `shift = 0`.
31
- # More args than `ndim` raises `ArgumentError`.
30
+ # Give one shift for every axis, as {#shift} takes; write `0` for an axis
31
+ # that does not move (`a.roll(1, 0)` rolls a 2-D array along axis 0).
32
32
  #
33
33
  # The in-place idiom is `ca[] = ca.roll(...)`; there is no `roll!`.
34
34
  # For a non-cyclic translation with a fill value use {#shift}.
35
35
  #
36
36
  # @overload roll(*shifts)
37
- # @param shifts [Array<Integer>] one shift per axis; may be
38
- # shorter than `ndim` (missing axes default to `0`).
37
+ # @param shifts [Array<Integer>] one shift per axis; the count must
38
+ # equal `self.ndim`.
39
39
  # @return [CARoll]
40
- # @raise [ArgumentError] when more than `ndim` shifts are given.
40
+ # @raise [ArgumentError] when the number of shifts does not equal
41
+ # `ndim`.
41
42
  def roll(*shifts); end
42
43
 
43
44
  # @!endgroup
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  # Mask companion of {CAShift}.
13
13
  # @private
14
- class CAShiftMask < CAShift
14
+ class CAShift::Mask < CAShift
15
15
  end
16
16
 
17
17
  class CArray
@@ -39,8 +39,7 @@ class CArray
39
39
  # `UNDEF` masks them instead.
40
40
  # @return [CAShift]
41
41
  # @raise [ArgumentError] when the number of shifts does not equal
42
- # `ndim`, when the removed `:roll` option is given, or when a block
43
- # is passed (the block form was removed in 3.0).
42
+ # `ndim`, or when a block is passed.
44
43
  def shift(*shifts, fill_value: 0); end
45
44
 
46
45
  # @!endgroup
@@ -12,7 +12,7 @@ end
12
12
 
13
13
  # Mask companion of {CAStride}.
14
14
  # @private
15
- class CAStrideMask < CAStride
15
+ class CAStride::Mask < CAStride
16
16
  end
17
17
 
18
18
  class CArray
@@ -37,7 +37,7 @@ class CArray
37
37
  # `[0, ..., 0]` element.
38
38
  # @return [CAStride]
39
39
  # @raise [ArgumentError] when `shape:` or `strides:` is missing, when
40
- # their lengths differ, or when the rank is 0 or above `CA_RANK_MAX`.
40
+ # their lengths differ, or when the rank is 0 or above `CArray::RANK_MAX`.
41
41
  def as_strided(shape:, strides:, offset: 0); end
42
42
 
43
43
  # Returns a {CAStride} view of overlapping windows over every axis. A
@@ -61,7 +61,7 @@ class CArray
61
61
  # @return [CAStride] of rank `2 * ndim`.
62
62
  # @raise [ArgumentError] when the window count does not equal `ndim`,
63
63
  # when a window or step is not positive, when a window is longer than
64
- # its axis, or when `2 * ndim` exceeds `CA_RANK_MAX`.
64
+ # its axis, or when `2 * ndim` exceeds `CArray::RANK_MAX`.
65
65
  def sliding_windows(*window, step: nil); end
66
66
 
67
67
  # Returns a {CAStride} view of overlapping windows over the leading `S`
@@ -83,7 +83,7 @@ class CArray
83
83
  # @return [CAStride] of rank `ndim + window.size`.
84
84
  # @raise [ArgumentError] when the window count is not between 1 and
85
85
  # `ndim`, when a window or step is not positive, when a window is
86
- # longer than its axis, or when `ndim + S` exceeds `CA_RANK_MAX`.
86
+ # longer than its axis, or when `ndim + S` exceeds `CArray::RANK_MAX`.
87
87
  def unfold(*window, step: nil); end
88
88
 
89
89
  # Returns a {CAStride} view of non-overlapping tiles. A parent of shape
@@ -105,7 +105,7 @@ class CArray
105
105
  # the parent is a Face).
106
106
  # @raise [ArgumentError] when the tile count does not equal `ndim`, when
107
107
  # a tile length is not positive, when an axis is not divisible by its
108
- # tile length, or when `2 * ndim` exceeds `CA_RANK_MAX`.
108
+ # tile length, or when `2 * ndim` exceeds `CArray::RANK_MAX`.
109
109
  def block_view(*block); end
110
110
 
111
111
  # Returns a `CATranspose` view in which the given axes are moved to the
@@ -138,8 +138,6 @@ class CArray
138
138
  # intent reads better than the slice form. There is no `flip!`; the
139
139
  # in-place idiom is `ca[] = ca.flip`.
140
140
  #
141
- # `reverse` is an alias of `flip`.
142
- #
143
141
  # @example
144
142
  # a = CArray.float64(4, 5).seq
145
143
  # a.flip # every axis reversed
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  # Mask companion of {CATile}.
12
12
  # @private
13
- class CATileMask < CATile
13
+ class CATile::Mask < CATile
14
14
  end
15
15
 
16
16
  class CArray
@@ -0,0 +1,43 @@
1
+ # DOCUMENTATION ONLY — DO NOT REQUIRE.
2
+ # Stubs for the C-defined readers of CATime, CATimedelta and their
3
+ # element classes (ext/ca_obj_time.c, ext/ca_obj_timedelta.c). The rest
4
+ # of these classes is documented at the source in lib/carray/time.rb.
5
+ # See yard-stubs/README.md and yard-stubs/STYLE.md.
6
+
7
+ class CATime
8
+ # @overload unit
9
+ # Returns the resolution the instants of this array are counted in.
10
+ # @return [CATime::Resolution]
11
+ def unit; end
12
+
13
+ class Element
14
+ # @overload unit
15
+ # Returns the resolution this instant is counted in.
16
+ # @return [CATime::Resolution]
17
+ def unit; end
18
+
19
+ # @overload value
20
+ # Returns the count of {#unit}s from the epoch to this instant.
21
+ # @return [Integer]
22
+ def value; end
23
+ end
24
+ end
25
+
26
+ class CATimedelta
27
+ # @overload unit
28
+ # Returns the resolution the durations of this array are counted in.
29
+ # @return [CATime::Resolution]
30
+ def unit; end
31
+
32
+ class Element
33
+ # @overload unit
34
+ # Returns the resolution this duration is counted in.
35
+ # @return [CATime::Resolution]
36
+ def unit; end
37
+
38
+ # @overload value
39
+ # Returns the count of {#unit}s in this duration.
40
+ # @return [Integer]
41
+ def value; end
42
+ end
43
+ end
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  # Mask companion of {CATranspose}.
13
13
  # @private
14
- class CATransposeMask < CATranspose
14
+ class CATranspose::Mask < CATranspose
15
15
  end
16
16
 
17
17
  class CArray