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
@@ -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)
@@ -784,13 +799,45 @@ class CArray
784
799
  # point equality is exact here; for a tolerant comparison see
785
800
  # {#is_close} (absolute) or {#is_equiv} (relative). Integers compare
786
801
  # by value, as for {#<}.
802
+ #
803
+ # `eq(UNDEF)` asks the mask, as {#is_masked} does. `nil`, a String, a
804
+ # Symbol or another value that is not a number is no value of a numeric
805
+ # or boolean array, so `eq` is false in every cell there; an `:object`
806
+ # or `:fixlen` array compares it like any other value.
787
807
  # @param other [CArray, Numeric, Object] comparand, broadcast to
788
808
  # `self.shape`.
789
809
  # @return [CArray] `:boolean`, same shape as `self`.
790
810
  # @example
791
- # CA_DOUBLE([1.0, 2.0]).eq(2.0) # => [ false, true ]
811
+ # CA_FLOAT64([1.0, 2.0]).eq(2.0) # => [ false, true ]
792
812
  def eq(other); end
793
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
+
794
841
  # @overload ne(other)
795
842
  # Returns a boolean array that is true where `self` and `other`
796
843
  # differ element-wise. The negation of {#eq}.
@@ -879,33 +926,41 @@ class CArray
879
926
  # @raise [TypeError] for any non-float `data_type`.
880
927
  def feq(other); end
881
928
 
882
- # @overload is_close(other, tolerance)
929
+ # @overload is_close(other, tol)
883
930
  # Returns a boolean array that is true where `self` and `other`
884
931
  # agree element-wise within an **absolute** tolerance:
885
- # `|self - other| <= tolerance`. Complex arrays compare by the
886
- # 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.
887
936
  # @param other [CArray, Numeric] comparand, broadcast to
888
937
  # `self.shape`.
889
- # @param tolerance [Numeric] largest accepted absolute difference.
938
+ # @param tol [Numeric] largest accepted absolute difference, zero
939
+ # or positive.
890
940
  # @return [CArray] `:boolean`.
941
+ # @raise [ArgumentError] when `tol` is negative or NaN.
891
942
  # @example
892
- # CA_DOUBLE([1000.0]).is_close(1001.0, 1.0) # => [ true ]
893
- 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
894
945
 
895
- # @overload is_equiv(other, tolerance)
946
+ # @overload is_equiv(other, tol)
896
947
  # Returns a boolean array that is true where `self` and `other`
897
948
  # agree element-wise within a **relative** tolerance:
898
- # `|self - other| / max(|self|, |other|) <= tolerance`, with
949
+ # `|self - other| / max(|self|, |other|) <= tol`, with
899
950
  # exactly equal elements always true. Prefer this to {#is_close}
900
- # 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`.
901
954
  # @param other [CArray, Numeric] comparand, broadcast to
902
955
  # `self.shape`.
903
- # @param tolerance [Numeric] largest accepted relative difference.
956
+ # @param tol [Numeric] largest accepted relative difference, zero
957
+ # or positive.
904
958
  # @return [CArray] `:boolean`.
959
+ # @raise [ArgumentError] when `tol` is negative or NaN.
905
960
  # @example
906
- # CA_DOUBLE([1000.0]).is_equiv(1001.0, 0.01) # => [ true ]
907
- # CA_DOUBLE([0.001]).is_equiv(0.002, 0.01) # => [ false ]
908
- 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
909
964
 
910
965
  # @overload is_nan
911
966
  # Returns a boolean array that is true where an element is `NaN`.
@@ -938,7 +993,7 @@ class CArray
938
993
  # with {#mask_where} to mask the elements a computation cannot use.
939
994
  # @return [CArray] `:boolean`.
940
995
  # @example
941
- # 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 ]
942
997
  def is_invalid; end
943
998
 
944
999
  # @overload signbit
@@ -950,7 +1005,7 @@ class CArray
950
1005
  # @return [CArray] `:boolean`.
951
1006
  # @raise [CArray::DataTypeError] for a complex array.
952
1007
  # @example
953
- # 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 ]
954
1009
  def signbit; end
955
1010
 
956
1011
  # @overload &(other)
@@ -965,11 +1020,21 @@ class CArray
965
1020
  # genuinely depends on a masked element is the result masked. So
966
1021
  # `(a & b).not` is `true` where `a` is `false`, whatever `b` is,
967
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.
968
1031
  # @param other [CArray, Integer, true, false] the other operand,
969
1032
  # broadcast to `self.shape`.
970
1033
  # @return [CArray] `:boolean` for boolean operands, otherwise the
971
1034
  # promoted integer `data_type`.
972
- # @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.
973
1038
  def &(other); end
974
1039
 
975
1040
  # @overload bit_and(other)
@@ -984,11 +1049,21 @@ class CArray
984
1049
  # **On boolean arrays it is three-valued (Kleene) as {#&} is; {#or}
985
1050
  # is the two-valued form.** An unknown element `OR` `true` is
986
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.
987
1060
  # @param other [CArray, Integer, true, false] the other operand,
988
1061
  # broadcast to `self.shape`.
989
1062
  # @return [CArray] `:boolean` for boolean operands, otherwise the
990
1063
  # promoted integer `data_type`.
991
- # @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.
992
1067
  def |(other); end
993
1068
 
994
1069
  # @overload bit_or(other)
@@ -1005,11 +1080,21 @@ class CArray
1005
1080
  # Unlike {#&} and {#|} this has no Kleene shortcut -- an exclusive
1006
1081
  # or always depends on both operands -- so a masked element always
1007
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.
1008
1091
  # @param other [CArray, Integer, true, false] the other operand,
1009
1092
  # broadcast to `self.shape`.
1010
1093
  # @return [CArray] `:boolean` for boolean operands, otherwise the
1011
1094
  # promoted integer `data_type`.
1012
- # @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.
1013
1098
  def ^(other); end
1014
1099
 
1015
1100
  # @overload bit_xor(other)
@@ -1075,7 +1160,7 @@ class CArray
1075
1160
  # known -- the element-wise counterpart of keeping only complete
1076
1161
  # records -- and {#&} when an answer the known side settles should
1077
1162
  # stand.
1078
- # @param other [CArray, true, false] the other operand, broadcast
1163
+ # @param other [CArray, true, false, 1, 0] the other operand, broadcast
1079
1164
  # to `self.shape`.
1080
1165
  # @return [CArray] `:boolean`.
1081
1166
  # @raise [CArray::DataTypeError] for any `data_type` other than
@@ -1087,7 +1172,7 @@ class CArray
1087
1172
  # masked element on either side makes the result masked**, as
1088
1173
  # {#and} does. {#|} is the three-valued form: `true | U` is `true`,
1089
1174
  # `true.or(U)` is `U`.
1090
- # @param other [CArray, true, false] the other operand.
1175
+ # @param other [CArray, true, false, 1, 0] the other operand.
1091
1176
  # @return [CArray] `:boolean`.
1092
1177
  # @raise [CArray::DataTypeError] for any `data_type` other than
1093
1178
  # `:boolean` or `:object`.
@@ -1096,7 +1181,7 @@ class CArray
1096
1181
  # @overload xor(other)
1097
1182
  # Returns the logical exclusive `OR` of two boolean arrays,
1098
1183
  # propagating the mask as {#and} does.
1099
- # @param other [CArray, true, false] the other operand.
1184
+ # @param other [CArray, true, false, 1, 0] the other operand.
1100
1185
  # @return [CArray] `:boolean`.
1101
1186
  # @raise [CArray::DataTypeError] for any `data_type` other than
1102
1187
  # `:boolean` or `:object`.
@@ -1109,13 +1194,6 @@ class CArray
1109
1194
  # @raise [CArray::DataTypeError] for a boolean array.
1110
1195
  def abs!; end
1111
1196
 
1112
- # @overload abs_i!
1113
- # Applies {#abs_i} to `self` in place, keeping `self`'s
1114
- # `data_type`.
1115
- # @return [self]
1116
- # @raise [CArray::DataTypeError] for a boolean array.
1117
- def abs_i!; end
1118
-
1119
1197
  # @overload acos!
1120
1198
  # Applies {#acos} to `self` in place, keeping `self`'s
1121
1199
  # `data_type`.
@@ -1375,13 +1453,6 @@ class CArray
1375
1453
  # promotes it instead of raising.
1376
1454
  def hypot!(other); end
1377
1455
 
1378
- # @overload imag_i!
1379
- # Applies {#imag_i} to `self` in place, keeping `self`'s
1380
- # `data_type`.
1381
- # @return [self]
1382
- # @raise [CArray::DataTypeError] for a boolean array.
1383
- def imag_i!; end
1384
-
1385
1456
  # @overload log!
1386
1457
  # Applies {#log} to `self` in place, keeping `self`'s
1387
1458
  # `data_type`.
@@ -1523,15 +1594,6 @@ class CArray
1523
1594
  # @raise [CArray::DataTypeError] for a boolean array.
1524
1595
  def pmin!(other); end
1525
1596
 
1526
- # @overload power!(other)
1527
- # Applies {#power} to `self` in place, keeping `self`'s
1528
- # `data_type`.
1529
- # @param other [CArray, Numeric] the other operand, broadcast to
1530
- # `self.shape`.
1531
- # @return [self]
1532
- # @raise [CArray::DataTypeError] for a boolean array.
1533
- def power!(other); end
1534
-
1535
1597
  # @overload rad!
1536
1598
  # Applies {#rad} to `self` in place, keeping `self`'s
1537
1599
  # `data_type`.