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
@@ -3,11 +3,21 @@
3
3
  # ext/carray_mathfunc.c. Most CAMath entries (atan2 / hypot / expm1
4
4
  # / log1p / copysign / logaddexp / nextafter / fmod / min / max) live
5
5
  # in lib/carray/math.rb and are documented at the source. This file
6
- # covers only the C-defined module functions.
6
+ # covers only the C-defined module functions, the one-argument ones
7
+ # (ext/mkkernel.rb defines them beside the array methods) among them.
7
8
  # See yard-stubs/README.md and yard-stubs/STYLE.md.
8
9
 
9
- # Namespace for math module functions that operate on CArray (and
10
- # auto-wrappable scalar) inputs.
10
+ # Namespace for math module functions over CArrays.
11
+ #
12
+ # A one-argument function (`CAMath.sqrt`, `CAMath.abs`, `CAMath.sign`, ...)
13
+ # given a CArray answers through the array's method (`CAMath.abs(a)` is
14
+ # `a.abs`). Given a number, it answers as it answers for an array of that
15
+ # number, and returns the one cell as a Ruby value: an Integer in the int64
16
+ # range is read as int64, a Float as float64, a Complex as cmplx128, and
17
+ # any other number (a larger Integer, a Rational) as an object cell. So
18
+ # `CAMath.abs(-2.5)` is `2.5`, `CAMath.sqrt(-1.0)` is NaN, and
19
+ # `CAMath.floor(2.7)` is `2.0`. A Ruby Array, a Range and an object that
20
+ # is not a number are refused with TypeError.
11
21
  module CAMath
12
22
  module_function
13
23
 
@@ -42,4 +52,406 @@ module CAMath
42
52
  # @return [CArray]
43
53
  # @raise [RuntimeError] when the build lacks `lgamma`.
44
54
  def lgamma(x); end
55
+
56
+ # @!group One-argument functions
57
+
58
+ # @overload zero(x)
59
+ # Returns zero in the type of `x`. The types and the special values are
60
+ # those of {CArray#zero}.
61
+ # @param x [CArray, Numeric]
62
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
63
+ # for a number.
64
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
65
+ def zero(x); end
66
+
67
+ # @overload one(x)
68
+ # Returns one in the type of `x`. The types and the special values are
69
+ # those of {CArray#one}.
70
+ # @param x [CArray, Numeric]
71
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
72
+ # for a number.
73
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
74
+ def one(x); end
75
+
76
+ # @overload neg(x)
77
+ # Returns `x` negated. The types and the special values are those of
78
+ # {CArray#neg}.
79
+ # @param x [CArray, Numeric]
80
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
81
+ # for a number.
82
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
83
+ def neg(x); end
84
+
85
+ # @overload abs(x)
86
+ # Returns the magnitude of `x`. The types and the special values are
87
+ # those of {CArray#abs}.
88
+ # @param x [CArray, Numeric]
89
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
90
+ # for a number.
91
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
92
+ def abs(x); end
93
+
94
+ # @overload abs2(x)
95
+ # Returns the squared magnitude of `x`. The types and the special values
96
+ # are those of {CArray#abs2}.
97
+ # @param x [CArray, Numeric]
98
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
99
+ # for a number.
100
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
101
+ def abs2(x); end
102
+
103
+ # @overload sign(x)
104
+ # Returns `-1`, `0` or `1` by the sign of `x`, in the type of `x`. The
105
+ # types and the special values are those of {CArray#sign}.
106
+ # @param x [CArray, Numeric]
107
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
108
+ # for a number.
109
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
110
+ def sign(x); end
111
+
112
+ # @overload square(x)
113
+ # Returns `x * x`. The types and the special values are those of
114
+ # {CArray#square}.
115
+ # @param x [CArray, Numeric]
116
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
117
+ # for a number.
118
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
119
+ def square(x); end
120
+
121
+ # @overload rcp(x)
122
+ # Returns the reciprocal `1 / x`, in the type of `x`. The types and the
123
+ # special values are those of {CArray#rcp}.
124
+ # @param x [CArray, Numeric]
125
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
126
+ # for a number.
127
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
128
+ def rcp(x); end
129
+
130
+ # @overload sqrt(x)
131
+ # Returns the square root of `x`. The types and the special values are
132
+ # those of {CArray#sqrt}.
133
+ # @param x [CArray, Numeric]
134
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
135
+ # for a number.
136
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
137
+ def sqrt(x); end
138
+
139
+ # @overload rsqrt(x)
140
+ # Returns the reciprocal square root `1 / sqrt(x)`. The types and the
141
+ # special values are those of {CArray#rsqrt}.
142
+ # @param x [CArray, Numeric]
143
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
144
+ # for a number.
145
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
146
+ def rsqrt(x); end
147
+
148
+ # @overload conj(x)
149
+ # Returns the complex conjugate of `x`. The types and the special values
150
+ # are those of {CArray#conj}.
151
+ # @param x [CArray, Numeric]
152
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
153
+ # for a number.
154
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
155
+ def conj(x); end
156
+
157
+ # @overload arg(x)
158
+ # Returns the argument (phase angle, in radians) of `x`, in `(-pi, pi]`.
159
+ # The types and the special values are those of {CArray#arg}.
160
+ # @param x [CArray, Numeric]
161
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
162
+ # for a number.
163
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
164
+ def arg(x); end
165
+
166
+ # @overload bit_neg(x)
167
+ # Returns the complement of `x`: a bitwise NOT for an integer. The types
168
+ # and the special values are those of {CArray#bit_neg}.
169
+ # @param x [CArray, Numeric]
170
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
171
+ # for a number.
172
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
173
+ def bit_neg(x); end
174
+
175
+ # @overload not(x)
176
+ # Returns the logical negation of a boolean array `x`, as {CArray#not}
177
+ # does.
178
+ # @param x [CArray] a boolean array.
179
+ # @return [CArray]
180
+ # @raise [CArray::DataTypeError] when `x` is not boolean.
181
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
182
+ def not(x); end
183
+
184
+ # @overload floor(x)
185
+ # Returns the largest integral value not greater than `x`, in the type
186
+ # of `x`. The types and the special values are those of {CArray#floor}.
187
+ # @param x [CArray, Numeric]
188
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
189
+ # for a number.
190
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
191
+ def floor(x); end
192
+
193
+ # @overload ceil(x)
194
+ # Returns the smallest integral value not less than `x`, in the type of
195
+ # `x`. The types and the special values are those of {CArray#ceil}.
196
+ # @param x [CArray, Numeric]
197
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
198
+ # for a number.
199
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
200
+ def ceil(x); end
201
+
202
+ # @overload round(x)
203
+ # Returns `x` rounded to the nearest integral value, half away from
204
+ # zero, in the type of `x`. The types and the special values are those
205
+ # of {CArray#round}.
206
+ # @param x [CArray, Numeric]
207
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
208
+ # for a number.
209
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
210
+ def round(x); end
211
+
212
+ # @overload trunc(x)
213
+ # Returns `x` with its fractional part removed, in the type of `x`. The
214
+ # types and the special values are those of {CArray#trunc}.
215
+ # @param x [CArray, Numeric]
216
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
217
+ # for a number.
218
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
219
+ def trunc(x); end
220
+
221
+ # @overload frac(x)
222
+ # Returns the fractional part of `x`, with the sign of `x`. The types
223
+ # and the special values are those of {CArray#frac}.
224
+ # @param x [CArray, Numeric]
225
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
226
+ # for a number.
227
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
228
+ def frac(x); end
229
+
230
+ # @overload exp(x)
231
+ # Returns `e` raised to `x`. The types and the special values are those
232
+ # of {CArray#exp}.
233
+ # @param x [CArray, Numeric]
234
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
235
+ # for a number.
236
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
237
+ def exp(x); end
238
+
239
+ # @overload exp2(x)
240
+ # Returns `2` raised to `x`. The types and the special values are those
241
+ # of {CArray#exp2}.
242
+ # @param x [CArray, Numeric]
243
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
244
+ # for a number.
245
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
246
+ def exp2(x); end
247
+
248
+ # @overload exp10(x)
249
+ # Returns `10` raised to `x`. The types and the special values are those
250
+ # of {CArray#exp10}.
251
+ # @param x [CArray, Numeric]
252
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
253
+ # for a number.
254
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
255
+ def exp10(x); end
256
+
257
+ # @overload log(x)
258
+ # Returns the natural logarithm of `x`. The types and the special values
259
+ # are those of {CArray#log}.
260
+ # @param x [CArray, Numeric]
261
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
262
+ # for a number.
263
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
264
+ def log(x); end
265
+
266
+ # @overload log2(x)
267
+ # Returns the base-2 logarithm of `x`. The types and the special values
268
+ # are those of {CArray#log2}.
269
+ # @param x [CArray, Numeric]
270
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
271
+ # for a number.
272
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
273
+ def log2(x); end
274
+
275
+ # @overload log10(x)
276
+ # Returns the base-10 logarithm of `x`. The types and the special values
277
+ # are those of {CArray#log10}.
278
+ # @param x [CArray, Numeric]
279
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
280
+ # for a number.
281
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
282
+ def log10(x); end
283
+
284
+ # @overload logb(x)
285
+ # Returns the exponent of `x` in the floating-point radix, as a
286
+ # floating-point value. The types and the special values are those of
287
+ # {CArray#logb}.
288
+ # @param x [CArray, Numeric]
289
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
290
+ # for a number.
291
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
292
+ def logb(x); end
293
+
294
+ # @overload sin(x)
295
+ # Returns the sine of `x`, taken in radians. The types and the special
296
+ # values are those of {CArray#sin}.
297
+ # @param x [CArray, Numeric]
298
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
299
+ # for a number.
300
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
301
+ def sin(x); end
302
+
303
+ # @overload cos(x)
304
+ # Returns the cosine of `x`, taken in radians. The types and the special
305
+ # values are those of {CArray#cos}.
306
+ # @param x [CArray, Numeric]
307
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
308
+ # for a number.
309
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
310
+ def cos(x); end
311
+
312
+ # @overload tan(x)
313
+ # Returns the tangent of `x`, taken in radians. The types and the
314
+ # special values are those of {CArray#tan}.
315
+ # @param x [CArray, Numeric]
316
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
317
+ # for a number.
318
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
319
+ def tan(x); end
320
+
321
+ # @overload asin(x)
322
+ # Returns the arc sine of `x`, in radians. The types and the special
323
+ # values are those of {CArray#asin}.
324
+ # @param x [CArray, Numeric]
325
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
326
+ # for a number.
327
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
328
+ def asin(x); end
329
+
330
+ # @overload acos(x)
331
+ # Returns the arc cosine of `x`, in radians. The types and the special
332
+ # values are those of {CArray#acos}.
333
+ # @param x [CArray, Numeric]
334
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
335
+ # for a number.
336
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
337
+ def acos(x); end
338
+
339
+ # @overload atan(x)
340
+ # Returns the arc tangent of `x`, in radians. The types and the special
341
+ # values are those of {CArray#atan}.
342
+ # @param x [CArray, Numeric]
343
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
344
+ # for a number.
345
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
346
+ def atan(x); end
347
+
348
+ # @overload sinh(x)
349
+ # Returns the hyperbolic sine of `x`. The types and the special values
350
+ # are those of {CArray#sinh}.
351
+ # @param x [CArray, Numeric]
352
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
353
+ # for a number.
354
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
355
+ def sinh(x); end
356
+
357
+ # @overload cosh(x)
358
+ # Returns the hyperbolic cosine of `x`. The types and the special values
359
+ # are those of {CArray#cosh}.
360
+ # @param x [CArray, Numeric]
361
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
362
+ # for a number.
363
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
364
+ def cosh(x); end
365
+
366
+ # @overload tanh(x)
367
+ # Returns the hyperbolic tangent of `x`. The types and the special
368
+ # values are those of {CArray#tanh}.
369
+ # @param x [CArray, Numeric]
370
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
371
+ # for a number.
372
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
373
+ def tanh(x); end
374
+
375
+ # @overload asinh(x)
376
+ # Returns the inverse hyperbolic sine of `x`. The types and the special
377
+ # values are those of {CArray#asinh}.
378
+ # @param x [CArray, Numeric]
379
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
380
+ # for a number.
381
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
382
+ def asinh(x); end
383
+
384
+ # @overload acosh(x)
385
+ # Returns the inverse hyperbolic cosine of `x`. The types and the
386
+ # special values are those of {CArray#acosh}.
387
+ # @param x [CArray, Numeric]
388
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
389
+ # for a number.
390
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
391
+ def acosh(x); end
392
+
393
+ # @overload atanh(x)
394
+ # Returns the inverse hyperbolic tangent of `x`. The types and the
395
+ # special values are those of {CArray#atanh}.
396
+ # @param x [CArray, Numeric]
397
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
398
+ # for a number.
399
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
400
+ def atanh(x); end
401
+
402
+ # @overload rad(x)
403
+ # Returns `x` converted from degrees to radians. The types and the
404
+ # special values are those of {CArray#rad}.
405
+ # @param x [CArray, Numeric]
406
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
407
+ # for a number.
408
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
409
+ def rad(x); end
410
+
411
+ # @overload deg(x)
412
+ # Returns `x` converted from radians to degrees. The types and the
413
+ # special values are those of {CArray#deg}.
414
+ # @param x [CArray, Numeric]
415
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
416
+ # for a number.
417
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
418
+ def deg(x); end
419
+
420
+ # @overload deg_360(x)
421
+ # Returns `x`, taken in degrees, wrapped into `[0, 360)`. The types and
422
+ # the special values are those of {CArray#deg_360}.
423
+ # @param x [CArray, Numeric]
424
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
425
+ # for a number.
426
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
427
+ def deg_360(x); end
428
+
429
+ # @overload deg_180(x)
430
+ # Returns `x`, taken in degrees, wrapped into `(-180, 180]`. The types
431
+ # and the special values are those of {CArray#deg_180}.
432
+ # @param x [CArray, Numeric]
433
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
434
+ # for a number.
435
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
436
+ def deg_180(x); end
437
+
438
+ # @overload rad_2pi(x)
439
+ # Returns `x`, taken in radians, wrapped into `[0, 2*pi)`. The types and
440
+ # the special values are those of {CArray#rad_2pi}.
441
+ # @param x [CArray, Numeric]
442
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
443
+ # for a number.
444
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
445
+ def rad_2pi(x); end
446
+
447
+ # @overload rad_pi(x)
448
+ # Returns `x`, taken in radians, wrapped into `(-pi, pi]`. The types and
449
+ # the special values are those of {CArray#rad_pi}.
450
+ # @param x [CArray, Numeric]
451
+ # @return [CArray, Object] a CArray for a CArray, one Ruby value
452
+ # for a number.
453
+ # @raise [TypeError] when `x` is neither a CArray nor a number.
454
+ def rad_pi(x); end
455
+
456
+ # @!endgroup
45
457
  end
@@ -46,13 +46,25 @@ class CArray
46
46
  # Returns percentile values at each `p` (each in `[0, 100]`)
47
47
  # along `axis` or over all elements.
48
48
  #
49
- # `p` may be given as individual positional arguments, a single
50
- # `Array<Numeric>`, or a single 1-D `CArray`. When the effective
51
- # `p` count (after flattening) is 1, the result is unwrapped:
52
- # flat form returns a `Float`, per-axis form returns a `CArray`
53
- # (a bare value along the only axis of a 1-D array, as {#median}).
54
- # With 2 or more `p` values the result is an `Array` whose length
55
- # matches the number of requested `p` values.
49
+ # The form in which `p` is given decides the form of the result.
50
+ # Below, "one answer" is what one `p` gives: a `Float` (or the
51
+ # element, for an object array) over all elements, and the reduced
52
+ # `CArray` along `axis` (a bare value along the only axis of a 1-D
53
+ # array, as {#median}).
54
+ #
55
+ # - one Numeric, `percentile(50)`: one answer. A `CScalar` is one
56
+ # Numeric here, as it is to an operator.
57
+ # - one `Array`, `percentile([25, 75])`: an `Array` with one answer
58
+ # per `p`, also when the Array has one element. Use this form when
59
+ # the number of `p` values is not fixed.
60
+ # - one `CArray` that is not a `CScalar`, `percentile(ps)`: one `CArray` of shape
61
+ # `ps.shape + ` the shape of one answer.
62
+ # - several Numerics, `percentile(25, 75)`: one `CArray` of shape
63
+ # `[2] + ` the shape of one answer. `r[0, ...]` is the answer for
64
+ # the first `p`.
65
+ #
66
+ # An `Array` or a `CArray` cannot be given together with other `p`
67
+ # values.
56
68
  #
57
69
  # `method` picks the interpolation rule between adjacent order
58
70
  # statistics:
@@ -85,23 +97,29 @@ class CArray
85
97
  # @param method [Symbol] one of `:linear`, `:lower`, `:higher`,
86
98
  # `:nearest`, `:midpoint`.
87
99
  # @param keep_axis [Boolean]
88
- # @return [Float, CArray, Object, Array<Float>, Array<CArray>, Array<Object>]
100
+ # @return [Float, Object, CArray, Array<Float>, Array<CArray>, Array<Object>]
101
+ # one answer for one Numeric `p`, an `Array` for an `Array` of `p`,
102
+ # and a `CArray` for several `p` or a `CArray` of `p`.
89
103
  # @raise [CArray::DataTypeError] for fixlen data_type, or when an
90
104
  # interpolating `method` is asked to interpolate between objects
91
105
  # that have no arithmetic.
92
106
  # @raise [ArgumentError] on empty `p` list, `p` outside `[0, 100]`,
93
- # empty axis, unknown `method`, or invalid option combinations.
107
+ # an `Array` or `CArray` of `p` given with other `p` values, a
108
+ # `CArray` of `p` with masked elements, empty axis, unknown
109
+ # `method`, or invalid option combinations.
94
110
  def percentile(*); end
95
111
 
96
- # @overload quantile(axis: nil, keep_axis: false)
112
+ # @overload quantile(axis: nil, keep_axis: false, min_count: nil, fill_value: nil)
97
113
  # Returns the five quartile percentiles
98
114
  # `[p0, p25, p50, p75, p100]` — shorthand for
99
- # `percentile(0, 25, 50, 75, 100, axis: axis, keep_axis: keep_axis)`.
115
+ # `percentile([0, 25, 50, 75, 100], ...)` with the same keywords.
100
116
  # Accepts no positional arguments. Flat form returns
101
117
  # `Array<Float>` of length 5; per-axis form returns `Array<CArray>`
102
118
  # of length 5, each CArray reduced along `axis`.
103
119
  # @param axis [Integer, nil]
104
120
  # @param keep_axis [Boolean]
121
+ # @param min_count [Integer, nil] as for {#percentile}.
122
+ # @param fill_value [Object, nil] as for {#percentile}.
105
123
  # @return [Array<Float>, Array<CArray>]
106
124
  # @raise [ArgumentError] on any positional argument.
107
125
  def quantile(*); end
@@ -63,7 +63,7 @@ class CArray
63
63
  # The result is a plain `CArray` whatever the receiver; a
64
64
  # receiver other than `CArray` or a `CAWrap` raises `TypeError`.
65
65
  # @param src [Object] any MemoryView producer.
66
- # @param data_type [Symbol, Integer, Class, nil] target data
66
+ # @param data_type [Symbol, nil] target data
67
67
  # type. Required for typeless producers; optional (must match
68
68
  # producer format) for typed ones.
69
69
  # @param mask [Object, nil] optional paired mask MemoryView
@@ -143,7 +143,7 @@ class CArray
143
143
  # algebra. For semantic identity that does survive it, see
144
144
  # {file:docs/topics/CAFace.md CAFace}.
145
145
  # @param src [Object] any MemoryView producer.
146
- # @param data_type [Symbol, Integer, Class, nil] target data
146
+ # @param data_type [Symbol, nil] target data
147
147
  # type, same rules as {.from_memory_view}.
148
148
  # @param mask [Object, nil] optional paired mask MemoryView
149
149
  # source.