carray 3.0.7 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +7 -1940
  4. data/README.md +38 -32
  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 +6 -9
  11. data/ext/ca_bincmp_dispatch.h +16 -38
  12. data/ext/ca_binop_dispatch.c +27 -0
  13. data/ext/ca_binop_dispatch.h +22 -47
  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 -1506
  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 +90 -163
  28. data/ext/ca_obj_bincmp.c +47 -46
  29. data/ext/ca_obj_binop.c +38 -38
  30. data/ext/ca_obj_bitarray.c +5 -17
  31. data/ext/ca_obj_bitfield.c +15 -30
  32. data/ext/ca_obj_block.c +11 -12
  33. data/ext/ca_obj_byte_swap.c +32 -30
  34. data/ext/ca_obj_const_string.c +57 -62
  35. data/ext/ca_obj_face.c +99 -91
  36. data/ext/ca_obj_face.h +32 -170
  37. data/ext/ca_obj_fake.c +15 -21
  38. data/ext/ca_obj_farray.c +7 -9
  39. data/ext/ca_obj_field.c +17 -13
  40. data/ext/ca_obj_fixlen_string.c +8 -19
  41. data/ext/ca_obj_grid.c +137 -106
  42. data/ext/ca_obj_meld.c +23 -21
  43. data/ext/ca_obj_moncmp.c +10 -21
  44. data/ext/ca_obj_monop.c +24 -35
  45. data/ext/ca_obj_object.c +51 -37
  46. data/ext/ca_obj_record.c +74 -22
  47. data/ext/ca_obj_reduce.c +8 -10
  48. data/ext/ca_obj_refer.c +42 -29
  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 +18 -24
  52. data/ext/ca_obj_select.c +10 -22
  53. data/ext/ca_obj_select_axis.c +27 -36
  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 +28 -24
  57. data/ext/ca_obj_stride.c +53 -54
  58. data/ext/ca_obj_string.c +6 -18
  59. data/ext/ca_obj_tile.c +12 -12
  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 +35 -39
  64. data/ext/ca_obj_window.c +67 -86
  65. data/ext/ca_op_cmplx64.h +4 -0
  66. data/ext/ca_op_ipower.c +34 -12
  67. data/ext/ca_op_powi.h +4 -0
  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 +20 -26
  72. data/ext/ca_sweep_engine.c +2 -3
  73. data/ext/ca_sweep_engine.h +17 -9
  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 +11 -11
  77. data/ext/carray.h +300 -1011
  78. data/ext/carray_access.c +234 -180
  79. data/ext/carray_address_basis.c +33 -38
  80. data/ext/carray_attribute.c +81 -104
  81. data/ext/carray_bincount.c +12 -14
  82. data/ext/carray_broadcast.c +30 -26
  83. data/ext/carray_call_cfunc.c +169 -277
  84. data/ext/carray_call_cfunc.h +36 -28
  85. data/ext/carray_cast.c +912 -346
  86. data/ext/carray_cast_func.rb +31 -3
  87. data/ext/carray_class.c +6 -11
  88. data/ext/carray_conversion.c +43 -38
  89. data/ext/carray_copy.c +28 -26
  90. data/ext/carray_core.c +217 -126
  91. data/ext/carray_count.c +27 -15
  92. data/ext/carray_element.c +40 -25
  93. data/ext/carray_factorize.c +53 -52
  94. data/ext/carray_generate.c +26 -19
  95. data/ext/carray_histogram.c +8 -10
  96. data/ext/carray_hold.c +7 -9
  97. data/ext/carray_index_classifier.c +123 -228
  98. data/ext/carray_index_classifier.h +11 -10
  99. data/ext/carray_integer_total.c +523 -0
  100. data/ext/carray_internal.h +1274 -160
  101. data/ext/carray_key_windows.c +3 -3
  102. data/ext/carray_lazy.c +21 -36
  103. data/ext/carray_loop.c +19 -22
  104. data/ext/carray_mask.c +123 -145
  105. data/ext/carray_math_kernel.h +23 -47
  106. data/ext/carray_mathfunc.c +10 -3
  107. data/ext/carray_median_percentile.c +95 -94
  108. data/ext/carray_memory_view.c +42 -47
  109. data/ext/carray_operator.c +423 -122
  110. data/ext/carray_order.c +121 -85
  111. data/ext/carray_partition.c +13 -15
  112. data/ext/carray_random.c +47 -41
  113. data/ext/carray_round.c +9 -4
  114. data/ext/carray_scatter.c +54 -40
  115. data/ext/carray_segment.c +41 -45
  116. data/ext/carray_slab.c +64 -47
  117. data/ext/carray_slab.h +44 -33
  118. data/ext/carray_sort.c +32 -29
  119. data/ext/carray_sort_kernel.c +12 -10
  120. data/ext/carray_struct.c +38 -43
  121. data/ext/carray_test.c +47 -43
  122. data/ext/carray_time_text.c +24 -31
  123. data/ext/carray_undef.c +50 -7
  124. data/ext/carray_utils.c +258 -94
  125. data/ext/extconf.rb +24 -17
  126. data/ext/mk_call_cfunc.rb +19 -20
  127. data/ext/mk_pow5_table.rb +2 -1
  128. data/ext/mkkernel.rb +782 -461
  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 +264 -180
  135. data/lib/carray/basics.rb +272 -48
  136. data/lib/carray/bincount_nd.rb +33 -16
  137. data/lib/carray/block_iterator.rb +123 -102
  138. data/lib/carray/boolean_reduce.rb +7 -4
  139. data/lib/carray/categorical.rb +63 -51
  140. data/lib/carray/categorical_iterator.rb +89 -67
  141. data/lib/carray/complex.rb +61 -41
  142. data/lib/carray/conditional.rb +49 -22
  143. data/lib/carray/const_string.rb +54 -62
  144. data/lib/carray/core_extensions.rb +1 -1
  145. data/lib/carray/distance_limit.rb +7 -5
  146. data/lib/carray/factories.rb +269 -0
  147. data/lib/carray/fixlen_string.rb +25 -24
  148. data/lib/carray/frame/column_verbs.rb +20 -8
  149. data/lib/carray/frame/concat.rb +3 -3
  150. data/lib/carray/frame/convert.rb +2 -1
  151. data/lib/carray/frame/csv_parser.rb +7 -1
  152. data/lib/carray/frame/frame.rb +35 -25
  153. data/lib/carray/frame/group.rb +183 -150
  154. data/lib/carray/frame/io.rb +26 -7
  155. data/lib/carray/frame/join.rb +37 -12
  156. data/lib/carray/frame/records.rb +1 -1
  157. data/lib/carray/frame/reshape.rb +3 -3
  158. data/lib/carray/frame/sort.rb +10 -8
  159. data/lib/carray/frame/verbs.rb +148 -118
  160. data/lib/carray/frame/windows.rb +232 -21
  161. data/lib/carray/frame.rb +1 -2
  162. data/lib/carray/fuse_source.rb +24 -21
  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 +97 -24
  167. data/lib/carray/key_windows.rb +83 -57
  168. data/lib/carray/lazy.rb +196 -94
  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 +5 -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 +72 -71
  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/gather_nd.rb +106 -106
  183. data/lib/carray/methods/insert_block.rb +2 -2
  184. data/lib/carray/methods/is_between.rb +6 -4
  185. data/lib/carray/methods/is_in.rb +165 -145
  186. data/lib/carray/methods/join.rb +2 -1
  187. data/lib/carray/methods/lag.rb +6 -2
  188. data/lib/carray/methods/locate_addr.rb +150 -138
  189. data/lib/carray/methods/mask_duplicates.rb +1 -1
  190. data/lib/carray/methods/meshgrid.rb +28 -16
  191. data/lib/carray/methods/mode.rb +67 -67
  192. data/lib/carray/methods/nunique.rb +9 -7
  193. data/lib/carray/methods/repeat.rb +12 -12
  194. data/lib/carray/methods/resize.rb +1 -1
  195. data/lib/carray/methods/snap.rb +24 -20
  196. data/lib/carray/methods/string_format.rb +2 -2
  197. data/lib/carray/methods/unique.rb +4 -2
  198. data/lib/carray/methods/value_counts.rb +1 -1
  199. data/lib/carray/mkmf.rb +25 -28
  200. data/lib/carray/percentile_arguments.rb +82 -0
  201. data/lib/carray/record_order.rb +18 -17
  202. data/lib/carray/rng.rb +1 -0
  203. data/lib/carray/runtime.rb +190 -22
  204. data/lib/carray/segment_iterator.rb +251 -129
  205. data/lib/carray/serialize.rb +618 -571
  206. data/lib/carray/slab_iterator.rb +114 -114
  207. data/lib/carray/stack.rb +11 -12
  208. data/lib/carray/string.rb +16 -22
  209. data/lib/carray/string_operation_extension.rb +76 -52
  210. data/lib/carray/struct.rb +122 -164
  211. data/lib/carray/struct_builder.rb +243 -72
  212. data/lib/carray/time.rb +496 -342
  213. data/lib/carray/window_iterator.rb +191 -150
  214. data/lib/carray.rb +6 -11
  215. data/yard-stubs/ca_obj_array.rb +20 -135
  216. data/yard-stubs/ca_obj_bitarray.rb +1 -8
  217. data/yard-stubs/ca_obj_bitfield.rb +4 -3
  218. data/yard-stubs/ca_obj_byte_swap.rb +21 -7
  219. data/yard-stubs/ca_obj_fake.rb +3 -1
  220. data/yard-stubs/ca_obj_farray.rb +1 -1
  221. data/yard-stubs/ca_obj_field.rb +8 -6
  222. data/yard-stubs/ca_obj_refer.rb +7 -5
  223. data/yard-stubs/ca_obj_roll.rb +7 -6
  224. data/yard-stubs/ca_obj_shift.rb +2 -3
  225. data/yard-stubs/ca_obj_stride.rb +5 -7
  226. data/yard-stubs/ca_obj_tile.rb +1 -1
  227. data/yard-stubs/ca_obj_time.rb +43 -0
  228. data/yard-stubs/ca_obj_transpose.rb +1 -1
  229. data/yard-stubs/ca_obj_window.rb +26 -15
  230. data/yard-stubs/carray_access.rb +51 -4
  231. data/yard-stubs/carray_attribute.rb +26 -38
  232. data/yard-stubs/carray_cast.rb +118 -165
  233. data/yard-stubs/carray_class.rb +3 -4
  234. data/yard-stubs/carray_conversion.rb +6 -7
  235. data/yard-stubs/carray_copy.rb +2 -1
  236. data/yard-stubs/carray_count.rb +5 -3
  237. data/yard-stubs/carray_element.rb +4 -3
  238. data/yard-stubs/carray_limits.rb +100 -0
  239. data/yard-stubs/carray_loop.rb +0 -20
  240. data/yard-stubs/carray_mask.rb +59 -41
  241. data/yard-stubs/carray_math.rb +157 -100
  242. data/yard-stubs/carray_mathfunc.rb +415 -3
  243. data/yard-stubs/carray_median_percentile.rb +29 -11
  244. data/yard-stubs/carray_memory_view.rb +2 -2
  245. data/yard-stubs/carray_order.rb +67 -34
  246. data/yard-stubs/carray_random.rb +6 -6
  247. data/yard-stubs/carray_reduce.rb +353 -0
  248. data/yard-stubs/carray_rng.rb +92 -0
  249. data/yard-stubs/carray_scatter.rb +10 -2
  250. data/yard-stubs/carray_slab.rb +7 -4
  251. data/yard-stubs/carray_sort.rb +7 -6
  252. data/yard-stubs/carray_undef.rb +44 -5
  253. data/yard-stubs/ruby_carray.rb +75 -40
  254. metadata +62 -24
  255. data/CHANGELOG.v1.md +0 -126
  256. data/ext/carray_build_flags.h +0 -3
  257. data/ext/carray_config.h +0 -28
  258. data/ext/carray_data_type.c +0 -90
  259. data/ext/carray_kernels_bincmp.c +0 -6457
  260. data/ext/carray_kernels_binop.c +0 -31534
  261. data/ext/carray_kernels_init.c +0 -1734
  262. data/ext/carray_kernels_moncmp.c +0 -2104
  263. data/ext/carray_kernels_monop.c +0 -25337
  264. data/ext/carray_kernels_reduce_aggregate.c +0 -27545
  265. data/ext/carray_kernels_reduce_boolean.c +0 -1924
  266. data/ext/carray_kernels_reduce_cumulative.c +0 -11646
  267. data/ext/carray_kernels_reduce_extreme.c +0 -21631
  268. data/ext/carray_kernels_reduce_variance.c +0 -5981
  269. data/ext/carray_kernels_scan.c +0 -4302
  270. data/ext/carray_kernels_search.c +0 -37776
  271. data/ext/carray_kernels_sort.c +0 -10814
  272. data/ext/carray_kernels_triop.c +0 -1864
  273. data/lib/carray/construct.rb +0 -360
  274. data/lib/carray/data_type_extension.rb +0 -262
  275. data/lib/carray/data_type_limits.rb +0 -91
@@ -37,11 +37,12 @@ class CArray
37
37
  # operands.
38
38
  # @raise [ZeroDivisionError] when an integer divisor is `0`. Float
39
39
  # division returns `Infinity` or `NaN` instead.
40
- # @raise [RangeError] when an Integer `other` does not fit the
41
- # integer `data_type` of `self`.
40
+ # @raise [RangeError] when an Integer (or integer CScalar) `other`
41
+ # does not fit the integer `data_type` of `self`: cut to the type, it
42
+ # would give another quotient.
42
43
  # @example
43
44
  # CA_INT32([-7, -1, 7]) / 3 # => [ -3, -1, 2 ]
44
- # CA_DOUBLE([-7.0]) / 3.0 # => [ -2.3333333333333335 ]
45
+ # CA_FLOAT64([-7.0]) / 3.0 # => [ -2.3333333333333335 ]
45
46
  def /(other); end
46
47
 
47
48
  # @overload div(other)
@@ -75,7 +76,7 @@ class CArray
75
76
  # @example
76
77
  # CA_INT32([-7, -1, 7]) % 3 # => [ 2, 2, 1 ]
77
78
  # CA_INT32([7]) % -3 # => [ -2 ]
78
- # CA_DOUBLE([-0.4]) % 1.0 # => [ 0.6 ]
79
+ # CA_FLOAT64([-0.4]) % 1.0 # => [ 0.6 ]
79
80
  def %(other); end
80
81
 
81
82
  # @overload mod(other)
@@ -109,7 +110,7 @@ class CArray
109
110
  # @raise [CArray::DataTypeError] for a complex array.
110
111
  # @example
111
112
  # CA_INT32([-7, -1, 7]).fmod(3) # => [ -1, -1, 1 ]
112
- # CA_DOUBLE([-0.4]).fmod(1.0) # => [ -0.4 ]
113
+ # CA_FLOAT64([-0.4]).fmod(1.0) # => [ -0.4 ]
113
114
  def fmod(other); end
114
115
 
115
116
  # @overload fmod!(other)
@@ -179,6 +180,13 @@ class CArray
179
180
  # `BigDecimal` stay exact). Boolean arrays participate as their 0/1
180
181
  # storage and promote to `:int64`, so a difference can reach `-1`.
181
182
  # Masked elements stay masked.
183
+ #
184
+ # An integer result that does not fit the type wraps, as in C. An
185
+ # Integer (or integer CScalar) `other` that the integer `data_type` of
186
+ # `self` can not hold is taken modulo 2 ** bits the same way, so
187
+ # `CA_UINT8([1]) + 256` is `[1]` and `+ -1` is the same as `- 1`; `&`,
188
+ # `|`, `^`, `-` and `*` take it so too. A store is not an operation:
189
+ # `a[0] = 256` into a uint8 array raises `RangeError`.
182
190
  # @param other [CArray, Numeric] addend, broadcast to `self.shape`.
183
191
  # @return [CArray] result of the promoted `data_type` of the two
184
192
  # operands.
@@ -236,8 +244,17 @@ class CArray
236
244
  # grows roughly in proportion to the exponent (tens of ulps at 100,
237
245
  # hundreds of thousands at a million), where `Float#**` and the same
238
246
  # exponent given as a Float are within an ulp or so; give the exponent
239
- # as a Float when a large one needs full precision. The exponent can
240
- # be any Integer that fits 64 bits.
247
+ # as a Float when a large one needs full precision. An Integer
248
+ # exponent beyond 64 bits is taken as a Float (the power is then 0, 1,
249
+ # an infinity or NaN).
250
+ # On an integer array an Integer (or integer CScalar) exponent is a
251
+ # count of multiplications, of any size: `CA_UINT8([2]) ** 10` is `[0]`,
252
+ # as 2 multiplied by itself 10 times is in uint8.
253
+ # An Integer (or integer CScalar) base on the left that the integer
254
+ # `data_type` of the exponents can not hold is cut to the type where
255
+ # the exponent is 0 or more, and gives 0 where it is negative (`1 / b
256
+ # ** p` in integer division): `1000 ** CA_INT8([2, -1])` is `[64, 0]`,
257
+ # the power computed wide and cut to int8.
241
258
  # Masked elements stay masked.
242
259
  # @param other [CArray, Numeric] exponent, broadcast to `self.shape`.
243
260
  # @return [CArray] result of the promoted `data_type` of the two
@@ -247,11 +264,10 @@ class CArray
247
264
  # CA_INT32([2]) ** -1 # => [ 0 ]
248
265
  def **(other); end
249
266
 
250
- # @overload power(other)
267
+ # @overload pow(other)
251
268
  # Alias of {#**}.
252
- # @param other [CArray, Numeric] exponent.
253
269
  # @return [CArray]
254
- def power(other); end
270
+ def pow(other); end
255
271
 
256
272
  # @overload rcp_mul(other)
257
273
  # Returns `other` divided element-wise by `self` -- the reciprocal
@@ -262,13 +278,15 @@ class CArray
262
278
  # operands.
263
279
  # @raise [ZeroDivisionError] when an integer element of `self` is `0`.
264
280
  # @example
265
- # CA_DOUBLE([1.0, 2.0, 4.0]).rcp_mul(2.0) # => [ 2.0, 1.0, 0.5 ]
281
+ # CA_FLOAT64([1.0, 2.0, 4.0]).rcp_mul(2.0) # => [ 2.0, 1.0, 0.5 ]
266
282
  def rcp_mul(other); end
267
283
 
268
284
  # @overload -@
269
285
  # Returns the element-wise negation of `self`, keeping `self`'s
270
286
  # `data_type`. A boolean array promotes to `:int64`. An `:object`
271
- # array delegates to each element's `#-@`.
287
+ # array delegates to each element's `#-@`. An integer result the type
288
+ # cannot hold wraps modulo 2 ** bits, as `+` and `*` do:
289
+ # `-CA_UINT8([5])` is `[251]` and `-CA_INT8([-128])` is `[-128]`.
272
290
  # @return [CArray]
273
291
  def -@; end
274
292
 
@@ -283,8 +301,8 @@ class CArray
283
301
  # A numeric array keeps its `data_type`; a complex array returns the
284
302
  # real magnitude at that complex type's own width, so a `:cmplx64`
285
303
  # yields `:float32` just as {#real} and {#imag} do. An `:object`
286
- # array calls each cell's `abs`. For the form that keeps a complex
287
- # array complex (magnitude with a zero imaginary part) use {#abs_i}.
304
+ # array calls each cell's `abs`. An integer result the type cannot
305
+ # hold wraps modulo 2 ** bits: `CA_INT8([-128]).abs` is `[-128]`.
288
306
  # @return [CArray] `self`'s `data_type` for numeric and `:object`
289
307
  # input; the real component type for complex input.
290
308
  # @raise [CArray::DataTypeError] for a boolean array.
@@ -292,18 +310,21 @@ class CArray
292
310
  # CA_CMPLX64([Complex(3, 4)]).abs # => [ 5.0 ] (:float32)
293
311
  def abs; end
294
312
 
295
- # @overload abs_i
296
- # Returns the element-wise magnitude of `self`, keeping `self`'s
297
- # `data_type` -- a complex array stays complex (imaginary part
298
- # zero), a boolean promotes to `:int64`, and an `:object` array
299
- # delegates to each element's `#abs`. See {#abs} for the form that
300
- # returns a real magnitude from a complex array.
301
- # @return [CArray] same `data_type` as `self` (`:int64` for boolean).
302
- def abs_i; end
313
+ # @overload abs2
314
+ # Returns the element-wise squared magnitude of `self`: `x * x` for a
315
+ # real array, `re * re + im * im` for a complex one. A complex array
316
+ # answers in the real type of its own width (`:cmplx64` gives
317
+ # `:float32`), as {#abs} does; a real array keeps its `data_type`,
318
+ # and an integer result the type cannot hold wraps modulo 2 ** bits
319
+ # (`CA_INT8([100]).abs2` is `[16]`).
320
+ # @return [CArray]
321
+ # @raise [CArray::DataTypeError] for a boolean or `:object` array.
322
+ def abs2; end
303
323
 
304
324
  # @overload square
305
325
  # Returns `self * self` element-wise, keeping `self`'s `data_type`
306
- # (a boolean promotes to `:int64`).
326
+ # (a boolean promotes to `:int64`). An integer result the type cannot
327
+ # hold wraps modulo 2 ** bits, as `*` does.
307
328
  # @return [CArray]
308
329
  def square; end
309
330
 
@@ -324,7 +345,7 @@ class CArray
324
345
  # @return [CArray] `:float64`, or `self`'s own float/complex type.
325
346
  # @raise [CArray::DataTypeError] for a boolean array.
326
347
  # @example
327
- # CA_DOUBLE([4.0, 16.0]).rsqrt # => [ 0.5, 0.25 ]
348
+ # CA_FLOAT64([4.0, 16.0]).rsqrt # => [ 0.5, 0.25 ]
328
349
  def rsqrt; end
329
350
 
330
351
  # @overload sign
@@ -334,7 +355,7 @@ class CArray
334
355
  # @return [CArray] same `data_type` as `self`.
335
356
  # @raise [CArray::DataTypeError] for an `:object` array.
336
357
  # @example
337
- # CA_DOUBLE([-3.0, 0.0, 2.0]).sign # => [ -1.0, 0.0, 1.0 ]
358
+ # CA_FLOAT64([-3.0, 0.0, 2.0]).sign # => [ -1.0, 0.0, 1.0 ]
338
359
  def sign; end
339
360
 
340
361
  # @overload zero
@@ -369,16 +390,9 @@ class CArray
369
390
  # component type of `self`.
370
391
  # @raise [CArray::DataTypeError] for a boolean or `:object` array.
371
392
  # @example
372
- # CA_DOUBLE([-1.0, 1.0]).arg # => [ 3.141592653589793, 0.0 ]
393
+ # CA_FLOAT64([-1.0, 1.0]).arg # => [ 3.141592653589793, 0.0 ]
373
394
  def arg; end
374
395
 
375
- # @overload imag_i
376
- # Returns the element-wise imaginary part, keeping `self`'s
377
- # `data_type` -- a complex array stays complex (real part zero) and
378
- # a real array yields zeros. See {#imag} for the real-valued form.
379
- # @return [CArray] same `data_type` as `self` (`:int64` for boolean).
380
- def imag_i; end
381
-
382
396
  # @overload floor
383
397
  # Returns the element-wise largest integral value not greater than
384
398
  # each element, keeping `self`'s `data_type` (a `:float64` stays
@@ -489,7 +503,7 @@ class CArray
489
503
  # own float type.
490
504
  # @raise [CArray::DataTypeError] for a boolean or complex array.
491
505
  # @example
492
- # CA_DOUBLE([8.0, 1.0, 0.5]).logb # => [ 3.0, 0.0, -1.0 ]
506
+ # CA_FLOAT64([8.0, 1.0, 0.5]).logb # => [ 3.0, 0.0, -1.0 ]
493
507
  def logb; end
494
508
 
495
509
  # @overload sin
@@ -665,7 +679,7 @@ class CArray
665
679
  # own float type.
666
680
  # @raise [CArray::DataTypeError] for a boolean or complex array.
667
681
  # @example
668
- # CA_DOUBLE([270.0]).deg_180 # => [ -90.0 ]
682
+ # CA_FLOAT64([270.0]).deg_180 # => [ -90.0 ]
669
683
  def deg_180; end
670
684
 
671
685
  # @overload deg_360
@@ -675,7 +689,7 @@ class CArray
675
689
  # own float type.
676
690
  # @raise [CArray::DataTypeError] for a boolean or complex array.
677
691
  # @example
678
- # CA_DOUBLE([-10.0]).deg_360 # => [ 350.0 ]
692
+ # CA_FLOAT64([-10.0]).deg_360 # => [ 350.0 ]
679
693
  def deg_360; end
680
694
 
681
695
  # @overload rad_pi
@@ -699,54 +713,55 @@ class CArray
699
713
  # `NaN`: where one element is `NaN` the other is returned, and only
700
714
  # two `NaN`s give `NaN`. Of `-0.0` and `0.0` the result is `0.0`,
701
715
  # in either order. For the form that lets a `NaN` win see {#maximum}.
716
+ #
717
+ # On an integer array an Integer `other` the type can not hold is
718
+ # taken by value: one below the type is never the larger, so the
719
+ # cells are returned as they are (`CA_INT8([5]).pmax(-1000)` is
720
+ # `[5]`); one above it would be the answer in every cell, which the
721
+ # type can not hold, so it raises `RangeError`.
702
722
  # @param other [CArray, Numeric] the other operand, broadcast to
703
723
  # `self.shape`.
704
724
  # @return [CArray] result of the promoted `data_type` of the two
705
725
  # operands (`:int64` for boolean).
706
726
  # @raise [CArray::DataTypeError] for a complex array, which has no
707
727
  # ordering.
728
+ # @raise [RangeError] for an Integer `other` above the integer type.
708
729
  # @example
709
- # CA_DOUBLE([Float::NAN]).pmax(1.0) # => [ 1.0 ]
730
+ # CA_FLOAT64([Float::NAN]).pmax(1.0) # => [ 1.0 ]
710
731
  def pmax(other); end
711
732
 
712
733
  # @overload pmin(other)
713
734
  # Returns the element-wise smaller of `self` and `other`, ignoring
714
735
  # `NaN`. Of `-0.0` and `0.0` the result is `-0.0`, in either order.
715
- # The counterpart of {#pmax}.
736
+ # The counterpart of {#pmax}: an Integer `other` above the integer
737
+ # type leaves the cells as they are, one below it raises.
716
738
  # @param other [CArray, Numeric] the other operand.
717
739
  # @return [CArray]
718
740
  # @raise [CArray::DataTypeError] for a complex array.
741
+ # @raise [RangeError] for an Integer `other` below the integer type.
719
742
  def pmin(other); end
720
743
 
721
- # @overload fmax(other)
722
- # Alias of {#pmax}, under the name C gives it.
723
- # @param other [CArray, Numeric] the other operand.
724
- # @return [CArray]
725
- def fmax(other); end
726
-
727
- # @overload fmin(other)
728
- # Alias of {#pmin}, under the name C gives it.
729
- # @param other [CArray, Numeric] the other operand.
730
- # @return [CArray]
731
- def fmin(other); end
732
-
733
744
  # @overload maximum(other)
734
745
  # Returns the element-wise larger of `self` and `other`,
735
746
  # propagating `NaN`: where either element is `NaN` the result is
736
747
  # `NaN`. Use this when a `NaN` must not be silently dropped, and
737
- # {#pmax} when it should be skipped.
748
+ # {#pmax} when it should be skipped. An Integer `other` the integer
749
+ # type can not hold is taken as {#pmax} takes it. A time array and a
750
+ # fixed-length string array hold no NaN, so for them `maximum` and
751
+ # {#pmax} give the same answer.
738
752
  # @param other [CArray, Numeric] the other operand, broadcast to
739
753
  # `self.shape`.
740
754
  # @return [CArray] result of the promoted `data_type` of the two
741
755
  # operands (`:int64` for boolean).
742
756
  # @raise [CArray::DataTypeError] for a complex array.
743
757
  # @example
744
- # CA_DOUBLE([Float::NAN]).maximum(1.0) # => [ NaN ]
758
+ # CA_FLOAT64([Float::NAN]).maximum(1.0) # => [ NaN ]
745
759
  def maximum(other); end
746
760
 
747
761
  # @overload minimum(other)
748
762
  # Returns the element-wise smaller of `self` and `other`,
749
- # propagating `NaN`. The counterpart of {#maximum}.
763
+ # propagating `NaN`. The counterpart of {#maximum}; an Integer `other`
764
+ # is taken as {#pmin} takes it.
750
765
  # @param other [CArray, Numeric] the other operand.
751
766
  # @return [CArray]
752
767
  # @raise [CArray::DataTypeError] for a complex array.
@@ -760,7 +775,7 @@ class CArray
760
775
  # @return [CArray] result of the promoted `data_type` of the three
761
776
  # operands.
762
777
  # @example
763
- # CA_DOUBLE([2.0]).fma(3.0, 4.0) # => [ 10.0 ]
778
+ # CA_FLOAT64([2.0]).fma(3.0, 4.0) # => [ 10.0 ]
764
779
  def fma(a, b); end
765
780
 
766
781
  # @overload fms(a, b)
@@ -770,7 +785,7 @@ class CArray
770
785
  # @param b [CArray, Numeric] subtrahend.
771
786
  # @return [CArray]
772
787
  # @example
773
- # CA_DOUBLE([2.0]).fms(3.0, 4.0) # => [ 2.0 ]
788
+ # CA_FLOAT64([2.0]).fms(3.0, 4.0) # => [ 2.0 ]
774
789
  def fms(a, b); end
775
790
 
776
791
  # @overload eq(other)
@@ -793,9 +808,36 @@ class CArray
793
808
  # `self.shape`.
794
809
  # @return [CArray] `:boolean`, same shape as `self`.
795
810
  # @example
796
- # CA_DOUBLE([1.0, 2.0]).eq(2.0) # => [ false, true ]
811
+ # CA_FLOAT64([1.0, 2.0]).eq(2.0) # => [ false, true ]
797
812
  def eq(other); end
798
813
 
814
+ # @overload match(pattern)
815
+ # Returns a boolean array that is true where the cell matches
816
+ # `pattern` with Ruby's `=~`. Takes an `:object` array of Strings and
817
+ # a `:fixlen` array (each cell read as a String); a masked cell gives a
818
+ # masked result.
819
+ # @param pattern [Regexp]
820
+ # @return [CArray] `:boolean`, same shape as `self`.
821
+ # @raise [TypeError] for a numeric array.
822
+ # @example
823
+ # CA_OBJECT(%w[ab cd]).match(/a/) # => [ true, false ]
824
+ def match(pattern); end
825
+
826
+ # @overload =~(pattern)
827
+ # Alias of {#match}.
828
+ # @return [CArray]
829
+ def =~(pattern); end
830
+
831
+ # @overload is_kind_of(klass)
832
+ # Returns a boolean array that is true where the cell is a
833
+ # `klass` (Ruby's `kind_of?`). Takes an `:object` array.
834
+ # @param klass [Class, Module]
835
+ # @return [CArray] `:boolean`, same shape as `self`.
836
+ # @raise [TypeError] for a numeric array.
837
+ # @example
838
+ # CA_OBJECT([1, "a", 2.0]).is_kind_of(Integer) # => [ true, false, false ]
839
+ def is_kind_of(klass); end
840
+
799
841
  # @overload ne(other)
800
842
  # Returns a boolean array that is true where `self` and `other`
801
843
  # differ element-wise. The negation of {#eq}.
@@ -884,33 +926,41 @@ class CArray
884
926
  # @raise [TypeError] for any non-float `data_type`.
885
927
  def feq(other); end
886
928
 
887
- # @overload is_close(other, tolerance)
929
+ # @overload is_close(other, tol)
888
930
  # Returns a boolean array that is true where `self` and `other`
889
931
  # agree element-wise within an **absolute** tolerance:
890
- # `|self - other| <= tolerance`. Complex arrays compare by the
891
- # magnitude of the difference.
932
+ # `|self - other| <= tol`. Complex arrays compare by the
933
+ # magnitude of the difference. Integers compare by their values:
934
+ # the difference is exact, also beyond 2**53, beside an Integer
935
+ # beyond the array's type, and between signed and unsigned arrays.
892
936
  # @param other [CArray, Numeric] comparand, broadcast to
893
937
  # `self.shape`.
894
- # @param tolerance [Numeric] largest accepted absolute difference.
938
+ # @param tol [Numeric] largest accepted absolute difference, zero
939
+ # or positive.
895
940
  # @return [CArray] `:boolean`.
941
+ # @raise [ArgumentError] when `tol` is negative or NaN.
896
942
  # @example
897
- # CA_DOUBLE([1000.0]).is_close(1001.0, 1.0) # => [ true ]
898
- def is_close(other, tolerance); end
943
+ # CA_FLOAT64([1000.0]).is_close(1001.0, 1.0) # => [ true ]
944
+ def is_close(other, tol); end
899
945
 
900
- # @overload is_equiv(other, tolerance)
946
+ # @overload is_equiv(other, tol)
901
947
  # Returns a boolean array that is true where `self` and `other`
902
948
  # agree element-wise within a **relative** tolerance:
903
- # `|self - other| / max(|self|, |other|) <= tolerance`, with
949
+ # `|self - other| / max(|self|, |other|) <= tol`, with
904
950
  # exactly equal elements always true. Prefer this to {#is_close}
905
- # when the elements span several orders of magnitude.
951
+ # when the elements span several orders of magnitude. Integers
952
+ # compare by their values as in {#is_close}: two different
953
+ # integers are never equivalent at `tol = 0`.
906
954
  # @param other [CArray, Numeric] comparand, broadcast to
907
955
  # `self.shape`.
908
- # @param tolerance [Numeric] largest accepted relative difference.
956
+ # @param tol [Numeric] largest accepted relative difference, zero
957
+ # or positive.
909
958
  # @return [CArray] `:boolean`.
959
+ # @raise [ArgumentError] when `tol` is negative or NaN.
910
960
  # @example
911
- # CA_DOUBLE([1000.0]).is_equiv(1001.0, 0.01) # => [ true ]
912
- # CA_DOUBLE([0.001]).is_equiv(0.002, 0.01) # => [ false ]
913
- def is_equiv(other, tolerance); end
961
+ # CA_FLOAT64([1000.0]).is_equiv(1001.0, 0.01) # => [ true ]
962
+ # CA_FLOAT64([0.001]).is_equiv(0.002, 0.01) # => [ false ]
963
+ def is_equiv(other, tol); end
914
964
 
915
965
  # @overload is_nan
916
966
  # Returns a boolean array that is true where an element is `NaN`.
@@ -943,7 +993,7 @@ class CArray
943
993
  # with {#mask_where} to mask the elements a computation cannot use.
944
994
  # @return [CArray] `:boolean`.
945
995
  # @example
946
- # CA_DOUBLE([Float::NAN, 1.0/0, 1.0]).is_invalid # => [ true, true, false ]
996
+ # CA_FLOAT64([Float::NAN, 1.0/0, 1.0]).is_invalid # => [ true, true, false ]
947
997
  def is_invalid; end
948
998
 
949
999
  # @overload signbit
@@ -955,7 +1005,7 @@ class CArray
955
1005
  # @return [CArray] `:boolean`.
956
1006
  # @raise [CArray::DataTypeError] for a complex array.
957
1007
  # @example
958
- # CA_DOUBLE([-1.0, 0.0, -0.0]).signbit # => [ true, false, true ]
1008
+ # CA_FLOAT64([-1.0, 0.0, -0.0]).signbit # => [ true, false, true ]
959
1009
  def signbit; end
960
1010
 
961
1011
  # @overload &(other)
@@ -970,11 +1020,21 @@ class CArray
970
1020
  # genuinely depends on a masked element is the result masked. So
971
1021
  # `(a & b).not` is `true` where `a` is `false`, whatever `b` is,
972
1022
  # while `a.and(b).not` stays masked where `b` is.
1023
+ #
1024
+ # On a boolean array, `other` is `true` / `false`, a boolean array,
1025
+ # or the integer `1` / `0`, which is read as `true` / `false`. The
1026
+ # cells of an object array are read by the same rule, and the result
1027
+ # is boolean. Any other value in an object array raises. Any other
1028
+ # number, and an array of numbers, has no truth value here and
1029
+ # raises: compare it (`ne(0)`) for its truth, or cast the boolean
1030
+ # array (`to_type`) for integer bits.
973
1031
  # @param other [CArray, Integer, true, false] the other operand,
974
1032
  # broadcast to `self.shape`.
975
1033
  # @return [CArray] `:boolean` for boolean operands, otherwise the
976
1034
  # promoted integer `data_type`.
977
- # @raise [CArray::DataTypeError] for a float or complex array.
1035
+ # @raise [CArray::DataTypeError] for a float or complex array, and
1036
+ # for a boolean array beside a number other than `1` / `0` or
1037
+ # an array of numbers, or an object array holding anything else.
978
1038
  def &(other); end
979
1039
 
980
1040
  # @overload bit_and(other)
@@ -989,11 +1049,21 @@ class CArray
989
1049
  # **On boolean arrays it is three-valued (Kleene) as {#&} is; {#or}
990
1050
  # is the two-valued form.** An unknown element `OR` `true` is
991
1051
  # `true`.
1052
+ #
1053
+ # On a boolean array, `other` is `true` / `false`, a boolean array,
1054
+ # or the integer `1` / `0`, which is read as `true` / `false`. The
1055
+ # cells of an object array are read by the same rule, and the result
1056
+ # is boolean. Any other value in an object array raises. Any other
1057
+ # number, and an array of numbers, has no truth value here and
1058
+ # raises: compare it (`ne(0)`) for its truth, or cast the boolean
1059
+ # array (`to_type`) for integer bits.
992
1060
  # @param other [CArray, Integer, true, false] the other operand,
993
1061
  # broadcast to `self.shape`.
994
1062
  # @return [CArray] `:boolean` for boolean operands, otherwise the
995
1063
  # promoted integer `data_type`.
996
- # @raise [CArray::DataTypeError] for a float or complex array.
1064
+ # @raise [CArray::DataTypeError] for a float or complex array, and
1065
+ # for a boolean array beside a number other than `1` / `0` or
1066
+ # an array of numbers, or an object array holding anything else.
997
1067
  def |(other); end
998
1068
 
999
1069
  # @overload bit_or(other)
@@ -1010,11 +1080,21 @@ class CArray
1010
1080
  # Unlike {#&} and {#|} this has no Kleene shortcut -- an exclusive
1011
1081
  # or always depends on both operands -- so a masked element always
1012
1082
  # gives a masked result.
1083
+ #
1084
+ # On a boolean array, `other` is `true` / `false`, a boolean array,
1085
+ # or the integer `1` / `0`, which is read as `true` / `false`. The
1086
+ # cells of an object array are read by the same rule, and the result
1087
+ # is boolean. Any other value in an object array raises. Any other
1088
+ # number, and an array of numbers, has no truth value here and
1089
+ # raises: compare it (`ne(0)`) for its truth, or cast the boolean
1090
+ # array (`to_type`) for integer bits.
1013
1091
  # @param other [CArray, Integer, true, false] the other operand,
1014
1092
  # broadcast to `self.shape`.
1015
1093
  # @return [CArray] `:boolean` for boolean operands, otherwise the
1016
1094
  # promoted integer `data_type`.
1017
- # @raise [CArray::DataTypeError] for a float or complex array.
1095
+ # @raise [CArray::DataTypeError] for a float or complex array, and
1096
+ # for a boolean array beside a number other than `1` / `0` or
1097
+ # an array of numbers, or an object array holding anything else.
1018
1098
  def ^(other); end
1019
1099
 
1020
1100
  # @overload bit_xor(other)
@@ -1080,7 +1160,7 @@ class CArray
1080
1160
  # known -- the element-wise counterpart of keeping only complete
1081
1161
  # records -- and {#&} when an answer the known side settles should
1082
1162
  # stand.
1083
- # @param other [CArray, true, false] the other operand, broadcast
1163
+ # @param other [CArray, true, false, 1, 0] the other operand, broadcast
1084
1164
  # to `self.shape`.
1085
1165
  # @return [CArray] `:boolean`.
1086
1166
  # @raise [CArray::DataTypeError] for any `data_type` other than
@@ -1092,7 +1172,7 @@ class CArray
1092
1172
  # masked element on either side makes the result masked**, as
1093
1173
  # {#and} does. {#|} is the three-valued form: `true | U` is `true`,
1094
1174
  # `true.or(U)` is `U`.
1095
- # @param other [CArray, true, false] the other operand.
1175
+ # @param other [CArray, true, false, 1, 0] the other operand.
1096
1176
  # @return [CArray] `:boolean`.
1097
1177
  # @raise [CArray::DataTypeError] for any `data_type` other than
1098
1178
  # `:boolean` or `:object`.
@@ -1101,7 +1181,7 @@ class CArray
1101
1181
  # @overload xor(other)
1102
1182
  # Returns the logical exclusive `OR` of two boolean arrays,
1103
1183
  # propagating the mask as {#and} does.
1104
- # @param other [CArray, true, false] the other operand.
1184
+ # @param other [CArray, true, false, 1, 0] the other operand.
1105
1185
  # @return [CArray] `:boolean`.
1106
1186
  # @raise [CArray::DataTypeError] for any `data_type` other than
1107
1187
  # `:boolean` or `:object`.
@@ -1114,13 +1194,6 @@ class CArray
1114
1194
  # @raise [CArray::DataTypeError] for a boolean array.
1115
1195
  def abs!; end
1116
1196
 
1117
- # @overload abs_i!
1118
- # Applies {#abs_i} to `self` in place, keeping `self`'s
1119
- # `data_type`.
1120
- # @return [self]
1121
- # @raise [CArray::DataTypeError] for a boolean array.
1122
- def abs_i!; end
1123
-
1124
1197
  # @overload acos!
1125
1198
  # Applies {#acos} to `self` in place, keeping `self`'s
1126
1199
  # `data_type`.
@@ -1380,13 +1453,6 @@ class CArray
1380
1453
  # promotes it instead of raising.
1381
1454
  def hypot!(other); end
1382
1455
 
1383
- # @overload imag_i!
1384
- # Applies {#imag_i} to `self` in place, keeping `self`'s
1385
- # `data_type`.
1386
- # @return [self]
1387
- # @raise [CArray::DataTypeError] for a boolean array.
1388
- def imag_i!; end
1389
-
1390
1456
  # @overload log!
1391
1457
  # Applies {#log} to `self` in place, keeping `self`'s
1392
1458
  # `data_type`.
@@ -1528,15 +1594,6 @@ class CArray
1528
1594
  # @raise [CArray::DataTypeError] for a boolean array.
1529
1595
  def pmin!(other); end
1530
1596
 
1531
- # @overload power!(other)
1532
- # Applies {#power} to `self` in place, keeping `self`'s
1533
- # `data_type`.
1534
- # @param other [CArray, Numeric] the other operand, broadcast to
1535
- # `self.shape`.
1536
- # @return [self]
1537
- # @raise [CArray::DataTypeError] for a boolean array.
1538
- def power!(other); end
1539
-
1540
1597
  # @overload rad!
1541
1598
  # Applies {#rad} to `self` in place, keeping `self`'s
1542
1599
  # `data_type`.