scipy 1.15.3__cp312-cp312-macosx_14_0_arm64.whl → 1.16.0rc2__cp312-cp312-macosx_14_0_arm64.whl

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 (628) hide show
  1. scipy/__config__.py +4 -4
  2. scipy/__init__.py +3 -6
  3. scipy/_cyutility.cpython-312-darwin.so +0 -0
  4. scipy/_lib/_array_api.py +486 -161
  5. scipy/_lib/_array_api_compat_vendor.py +9 -0
  6. scipy/_lib/_bunch.py +4 -0
  7. scipy/_lib/_ccallback_c.cpython-312-darwin.so +0 -0
  8. scipy/_lib/_docscrape.py +1 -1
  9. scipy/_lib/_elementwise_iterative_method.py +15 -26
  10. scipy/_lib/_sparse.py +41 -0
  11. scipy/_lib/_test_deprecation_call.cpython-312-darwin.so +0 -0
  12. scipy/_lib/_test_deprecation_def.cpython-312-darwin.so +0 -0
  13. scipy/_lib/_testutils.py +6 -2
  14. scipy/_lib/_util.py +222 -125
  15. scipy/_lib/array_api_compat/__init__.py +4 -4
  16. scipy/_lib/array_api_compat/_internal.py +19 -6
  17. scipy/_lib/array_api_compat/common/__init__.py +1 -1
  18. scipy/_lib/array_api_compat/common/_aliases.py +365 -193
  19. scipy/_lib/array_api_compat/common/_fft.py +94 -64
  20. scipy/_lib/array_api_compat/common/_helpers.py +413 -180
  21. scipy/_lib/array_api_compat/common/_linalg.py +116 -40
  22. scipy/_lib/array_api_compat/common/_typing.py +179 -10
  23. scipy/_lib/array_api_compat/cupy/__init__.py +1 -4
  24. scipy/_lib/array_api_compat/cupy/_aliases.py +61 -41
  25. scipy/_lib/array_api_compat/cupy/_info.py +16 -6
  26. scipy/_lib/array_api_compat/cupy/_typing.py +24 -39
  27. scipy/_lib/array_api_compat/dask/array/__init__.py +6 -3
  28. scipy/_lib/array_api_compat/dask/array/_aliases.py +267 -108
  29. scipy/_lib/array_api_compat/dask/array/_info.py +105 -34
  30. scipy/_lib/array_api_compat/dask/array/fft.py +5 -8
  31. scipy/_lib/array_api_compat/dask/array/linalg.py +21 -22
  32. scipy/_lib/array_api_compat/numpy/__init__.py +13 -15
  33. scipy/_lib/array_api_compat/numpy/_aliases.py +98 -49
  34. scipy/_lib/array_api_compat/numpy/_info.py +36 -16
  35. scipy/_lib/array_api_compat/numpy/_typing.py +27 -43
  36. scipy/_lib/array_api_compat/numpy/fft.py +11 -5
  37. scipy/_lib/array_api_compat/numpy/linalg.py +75 -22
  38. scipy/_lib/array_api_compat/torch/__init__.py +3 -5
  39. scipy/_lib/array_api_compat/torch/_aliases.py +262 -159
  40. scipy/_lib/array_api_compat/torch/_info.py +27 -16
  41. scipy/_lib/array_api_compat/torch/_typing.py +3 -0
  42. scipy/_lib/array_api_compat/torch/fft.py +17 -18
  43. scipy/_lib/array_api_compat/torch/linalg.py +16 -16
  44. scipy/_lib/array_api_extra/__init__.py +26 -3
  45. scipy/_lib/array_api_extra/_delegation.py +171 -0
  46. scipy/_lib/array_api_extra/_lib/__init__.py +1 -0
  47. scipy/_lib/array_api_extra/_lib/_at.py +463 -0
  48. scipy/_lib/array_api_extra/_lib/_backends.py +46 -0
  49. scipy/_lib/array_api_extra/_lib/_funcs.py +937 -0
  50. scipy/_lib/array_api_extra/_lib/_lazy.py +357 -0
  51. scipy/_lib/array_api_extra/_lib/_testing.py +278 -0
  52. scipy/_lib/array_api_extra/_lib/_utils/__init__.py +1 -0
  53. scipy/_lib/array_api_extra/_lib/_utils/_compat.py +74 -0
  54. scipy/_lib/array_api_extra/_lib/_utils/_compat.pyi +45 -0
  55. scipy/_lib/array_api_extra/_lib/_utils/_helpers.py +559 -0
  56. scipy/_lib/array_api_extra/_lib/_utils/_typing.py +10 -0
  57. scipy/_lib/array_api_extra/_lib/_utils/_typing.pyi +105 -0
  58. scipy/_lib/array_api_extra/testing.py +359 -0
  59. scipy/_lib/decorator.py +2 -2
  60. scipy/_lib/doccer.py +1 -7
  61. scipy/_lib/messagestream.cpython-312-darwin.so +0 -0
  62. scipy/_lib/pyprima/__init__.py +212 -0
  63. scipy/_lib/pyprima/cobyla/__init__.py +0 -0
  64. scipy/_lib/pyprima/cobyla/cobyla.py +559 -0
  65. scipy/_lib/pyprima/cobyla/cobylb.py +714 -0
  66. scipy/_lib/pyprima/cobyla/geometry.py +226 -0
  67. scipy/_lib/pyprima/cobyla/initialize.py +215 -0
  68. scipy/_lib/pyprima/cobyla/trustregion.py +492 -0
  69. scipy/_lib/pyprima/cobyla/update.py +289 -0
  70. scipy/_lib/pyprima/common/__init__.py +0 -0
  71. scipy/_lib/pyprima/common/_bounds.py +34 -0
  72. scipy/_lib/pyprima/common/_linear_constraints.py +46 -0
  73. scipy/_lib/pyprima/common/_nonlinear_constraints.py +54 -0
  74. scipy/_lib/pyprima/common/_project.py +173 -0
  75. scipy/_lib/pyprima/common/checkbreak.py +93 -0
  76. scipy/_lib/pyprima/common/consts.py +47 -0
  77. scipy/_lib/pyprima/common/evaluate.py +99 -0
  78. scipy/_lib/pyprima/common/history.py +38 -0
  79. scipy/_lib/pyprima/common/infos.py +30 -0
  80. scipy/_lib/pyprima/common/linalg.py +435 -0
  81. scipy/_lib/pyprima/common/message.py +290 -0
  82. scipy/_lib/pyprima/common/powalg.py +131 -0
  83. scipy/_lib/pyprima/common/preproc.py +277 -0
  84. scipy/_lib/pyprima/common/present.py +5 -0
  85. scipy/_lib/pyprima/common/ratio.py +54 -0
  86. scipy/_lib/pyprima/common/redrho.py +47 -0
  87. scipy/_lib/pyprima/common/selectx.py +296 -0
  88. scipy/_lib/tests/test__util.py +105 -121
  89. scipy/_lib/tests/test_array_api.py +166 -35
  90. scipy/_lib/tests/test_bunch.py +7 -0
  91. scipy/_lib/tests/test_ccallback.py +2 -10
  92. scipy/_lib/tests/test_public_api.py +13 -0
  93. scipy/cluster/_hierarchy.cpython-312-darwin.so +0 -0
  94. scipy/cluster/_optimal_leaf_ordering.cpython-312-darwin.so +0 -0
  95. scipy/cluster/_vq.cpython-312-darwin.so +0 -0
  96. scipy/cluster/hierarchy.py +393 -223
  97. scipy/cluster/tests/test_hierarchy.py +273 -335
  98. scipy/cluster/tests/test_vq.py +45 -61
  99. scipy/cluster/vq.py +39 -35
  100. scipy/conftest.py +263 -157
  101. scipy/constants/_constants.py +4 -1
  102. scipy/constants/tests/test_codata.py +2 -2
  103. scipy/constants/tests/test_constants.py +11 -18
  104. scipy/datasets/_download_all.py +15 -1
  105. scipy/datasets/_fetchers.py +7 -1
  106. scipy/datasets/_utils.py +1 -1
  107. scipy/differentiate/_differentiate.py +25 -25
  108. scipy/differentiate/tests/test_differentiate.py +24 -25
  109. scipy/fft/_basic.py +20 -0
  110. scipy/fft/_helper.py +3 -34
  111. scipy/fft/_pocketfft/helper.py +29 -1
  112. scipy/fft/_pocketfft/tests/test_basic.py +2 -4
  113. scipy/fft/_pocketfft/tests/test_real_transforms.py +4 -4
  114. scipy/fft/_realtransforms.py +13 -0
  115. scipy/fft/tests/test_basic.py +27 -25
  116. scipy/fft/tests/test_fftlog.py +16 -7
  117. scipy/fft/tests/test_helper.py +18 -34
  118. scipy/fft/tests/test_real_transforms.py +8 -10
  119. scipy/fftpack/convolve.cpython-312-darwin.so +0 -0
  120. scipy/fftpack/tests/test_basic.py +2 -4
  121. scipy/fftpack/tests/test_real_transforms.py +8 -9
  122. scipy/integrate/_bvp.py +9 -3
  123. scipy/integrate/_cubature.py +3 -2
  124. scipy/integrate/_dop.cpython-312-darwin.so +0 -0
  125. scipy/integrate/_lsoda.cpython-312-darwin.so +0 -0
  126. scipy/integrate/_ode.py +9 -2
  127. scipy/integrate/_odepack.cpython-312-darwin.so +0 -0
  128. scipy/integrate/_quad_vec.py +21 -29
  129. scipy/integrate/_quadpack.cpython-312-darwin.so +0 -0
  130. scipy/integrate/_quadpack_py.py +11 -7
  131. scipy/integrate/_quadrature.py +3 -3
  132. scipy/integrate/_rules/_base.py +2 -2
  133. scipy/integrate/_tanhsinh.py +48 -47
  134. scipy/integrate/_test_odeint_banded.cpython-312-darwin.so +0 -0
  135. scipy/integrate/_vode.cpython-312-darwin.so +0 -0
  136. scipy/integrate/tests/test__quad_vec.py +0 -6
  137. scipy/integrate/tests/test_banded_ode_solvers.py +85 -0
  138. scipy/integrate/tests/test_cubature.py +21 -35
  139. scipy/integrate/tests/test_quadrature.py +6 -8
  140. scipy/integrate/tests/test_tanhsinh.py +56 -48
  141. scipy/interpolate/__init__.py +70 -58
  142. scipy/interpolate/_bary_rational.py +22 -22
  143. scipy/interpolate/_bsplines.py +119 -66
  144. scipy/interpolate/_cubic.py +65 -50
  145. scipy/interpolate/_dfitpack.cpython-312-darwin.so +0 -0
  146. scipy/interpolate/_dierckx.cpython-312-darwin.so +0 -0
  147. scipy/interpolate/_fitpack.cpython-312-darwin.so +0 -0
  148. scipy/interpolate/_fitpack2.py +9 -6
  149. scipy/interpolate/_fitpack_impl.py +32 -26
  150. scipy/interpolate/_fitpack_repro.py +23 -19
  151. scipy/interpolate/_interpnd.cpython-312-darwin.so +0 -0
  152. scipy/interpolate/_interpolate.py +30 -12
  153. scipy/interpolate/_ndbspline.py +13 -18
  154. scipy/interpolate/_ndgriddata.py +5 -8
  155. scipy/interpolate/_polyint.py +95 -31
  156. scipy/interpolate/_ppoly.cpython-312-darwin.so +0 -0
  157. scipy/interpolate/_rbf.py +2 -2
  158. scipy/interpolate/_rbfinterp.py +1 -1
  159. scipy/interpolate/_rbfinterp_pythran.cpython-312-darwin.so +0 -0
  160. scipy/interpolate/_rgi.py +31 -26
  161. scipy/interpolate/_rgi_cython.cpython-312-darwin.so +0 -0
  162. scipy/interpolate/dfitpack.py +0 -20
  163. scipy/interpolate/interpnd.py +1 -2
  164. scipy/interpolate/tests/test_bary_rational.py +2 -2
  165. scipy/interpolate/tests/test_bsplines.py +97 -1
  166. scipy/interpolate/tests/test_fitpack2.py +39 -1
  167. scipy/interpolate/tests/test_interpnd.py +32 -20
  168. scipy/interpolate/tests/test_interpolate.py +48 -4
  169. scipy/interpolate/tests/test_rgi.py +2 -1
  170. scipy/io/_fast_matrix_market/__init__.py +2 -0
  171. scipy/io/_harwell_boeing/_fortran_format_parser.py +19 -16
  172. scipy/io/_harwell_boeing/hb.py +7 -11
  173. scipy/io/_idl.py +5 -7
  174. scipy/io/_netcdf.py +15 -5
  175. scipy/io/_test_fortran.cpython-312-darwin.so +0 -0
  176. scipy/io/arff/tests/test_arffread.py +3 -3
  177. scipy/io/matlab/__init__.py +5 -3
  178. scipy/io/matlab/_mio.py +4 -1
  179. scipy/io/matlab/_mio5.py +19 -13
  180. scipy/io/matlab/_mio5_utils.cpython-312-darwin.so +0 -0
  181. scipy/io/matlab/_mio_utils.cpython-312-darwin.so +0 -0
  182. scipy/io/matlab/_miobase.py +4 -1
  183. scipy/io/matlab/_streams.cpython-312-darwin.so +0 -0
  184. scipy/io/matlab/tests/test_mio.py +46 -18
  185. scipy/io/matlab/tests/test_mio_funcs.py +1 -1
  186. scipy/io/tests/test_mmio.py +7 -1
  187. scipy/io/tests/test_wavfile.py +41 -0
  188. scipy/io/wavfile.py +57 -10
  189. scipy/linalg/_basic.py +113 -86
  190. scipy/linalg/_cythonized_array_utils.cpython-312-darwin.so +0 -0
  191. scipy/linalg/_decomp.py +22 -9
  192. scipy/linalg/_decomp_cholesky.py +28 -13
  193. scipy/linalg/_decomp_cossin.py +45 -30
  194. scipy/linalg/_decomp_interpolative.cpython-312-darwin.so +0 -0
  195. scipy/linalg/_decomp_ldl.py +4 -1
  196. scipy/linalg/_decomp_lu.py +18 -6
  197. scipy/linalg/_decomp_lu_cython.cpython-312-darwin.so +0 -0
  198. scipy/linalg/_decomp_polar.py +2 -0
  199. scipy/linalg/_decomp_qr.py +6 -2
  200. scipy/linalg/_decomp_qz.py +3 -0
  201. scipy/linalg/_decomp_schur.py +3 -1
  202. scipy/linalg/_decomp_svd.py +13 -2
  203. scipy/linalg/_decomp_update.cpython-312-darwin.so +0 -0
  204. scipy/linalg/_expm_frechet.py +4 -0
  205. scipy/linalg/_fblas.cpython-312-darwin.so +0 -0
  206. scipy/linalg/_flapack.cpython-312-darwin.so +0 -0
  207. scipy/linalg/_linalg_pythran.cpython-312-darwin.so +0 -0
  208. scipy/linalg/_matfuncs.py +187 -4
  209. scipy/linalg/_matfuncs_expm.cpython-312-darwin.so +0 -0
  210. scipy/linalg/_matfuncs_schur_sqrtm.cpython-312-darwin.so +0 -0
  211. scipy/linalg/_matfuncs_sqrtm.py +1 -99
  212. scipy/linalg/_matfuncs_sqrtm_triu.cpython-312-darwin.so +0 -0
  213. scipy/linalg/_procrustes.py +2 -0
  214. scipy/linalg/_sketches.py +17 -6
  215. scipy/linalg/_solve_toeplitz.cpython-312-darwin.so +0 -0
  216. scipy/linalg/_solvers.py +7 -2
  217. scipy/linalg/_special_matrices.py +26 -36
  218. scipy/linalg/cython_blas.cpython-312-darwin.so +0 -0
  219. scipy/linalg/cython_lapack.cpython-312-darwin.so +0 -0
  220. scipy/linalg/lapack.py +22 -2
  221. scipy/linalg/tests/_cython_examples/meson.build +7 -0
  222. scipy/linalg/tests/test_basic.py +31 -16
  223. scipy/linalg/tests/test_batch.py +588 -0
  224. scipy/linalg/tests/test_cythonized_array_utils.py +0 -2
  225. scipy/linalg/tests/test_decomp.py +40 -3
  226. scipy/linalg/tests/test_decomp_cossin.py +14 -0
  227. scipy/linalg/tests/test_decomp_ldl.py +1 -1
  228. scipy/linalg/tests/test_lapack.py +115 -7
  229. scipy/linalg/tests/test_matfuncs.py +157 -102
  230. scipy/linalg/tests/test_procrustes.py +0 -7
  231. scipy/linalg/tests/test_solve_toeplitz.py +1 -1
  232. scipy/linalg/tests/test_special_matrices.py +1 -5
  233. scipy/ndimage/__init__.py +1 -0
  234. scipy/ndimage/_cytest.cpython-312-darwin.so +0 -0
  235. scipy/ndimage/_delegators.py +8 -2
  236. scipy/ndimage/_filters.py +453 -5
  237. scipy/ndimage/_interpolation.py +36 -6
  238. scipy/ndimage/_measurements.py +4 -2
  239. scipy/ndimage/_morphology.py +5 -0
  240. scipy/ndimage/_nd_image.cpython-312-darwin.so +0 -0
  241. scipy/ndimage/_ni_docstrings.py +5 -1
  242. scipy/ndimage/_ni_label.cpython-312-darwin.so +0 -0
  243. scipy/ndimage/_ni_support.py +1 -5
  244. scipy/ndimage/_rank_filter_1d.cpython-312-darwin.so +0 -0
  245. scipy/ndimage/_support_alternative_backends.py +18 -6
  246. scipy/ndimage/tests/test_filters.py +370 -259
  247. scipy/ndimage/tests/test_fourier.py +7 -9
  248. scipy/ndimage/tests/test_interpolation.py +68 -61
  249. scipy/ndimage/tests/test_measurements.py +18 -35
  250. scipy/ndimage/tests/test_morphology.py +143 -131
  251. scipy/ndimage/tests/test_splines.py +1 -3
  252. scipy/odr/__odrpack.cpython-312-darwin.so +0 -0
  253. scipy/optimize/_basinhopping.py +13 -7
  254. scipy/optimize/_bglu_dense.cpython-312-darwin.so +0 -0
  255. scipy/optimize/_bracket.py +17 -24
  256. scipy/optimize/_chandrupatla.py +9 -10
  257. scipy/optimize/_cobyla_py.py +104 -123
  258. scipy/optimize/_constraints.py +14 -10
  259. scipy/optimize/_differentiable_functions.py +371 -230
  260. scipy/optimize/_differentialevolution.py +4 -3
  261. scipy/optimize/_direct.cpython-312-darwin.so +0 -0
  262. scipy/optimize/_dual_annealing.py +1 -1
  263. scipy/optimize/_elementwise.py +1 -4
  264. scipy/optimize/_group_columns.cpython-312-darwin.so +0 -0
  265. scipy/optimize/_lbfgsb.cpython-312-darwin.so +0 -0
  266. scipy/optimize/_lbfgsb_py.py +57 -16
  267. scipy/optimize/_linprog_doc.py +2 -2
  268. scipy/optimize/_linprog_highs.py +2 -2
  269. scipy/optimize/_linprog_ip.py +25 -10
  270. scipy/optimize/_linprog_util.py +14 -16
  271. scipy/optimize/_lsap.cpython-312-darwin.so +0 -0
  272. scipy/optimize/_lsq/common.py +3 -3
  273. scipy/optimize/_lsq/dogbox.py +16 -2
  274. scipy/optimize/_lsq/givens_elimination.cpython-312-darwin.so +0 -0
  275. scipy/optimize/_lsq/least_squares.py +198 -126
  276. scipy/optimize/_lsq/lsq_linear.py +6 -6
  277. scipy/optimize/_lsq/trf.py +35 -8
  278. scipy/optimize/_milp.py +3 -1
  279. scipy/optimize/_minimize.py +105 -36
  280. scipy/optimize/_minpack.cpython-312-darwin.so +0 -0
  281. scipy/optimize/_minpack_py.py +21 -14
  282. scipy/optimize/_moduleTNC.cpython-312-darwin.so +0 -0
  283. scipy/optimize/_nnls.py +20 -21
  284. scipy/optimize/_nonlin.py +34 -3
  285. scipy/optimize/_numdiff.py +288 -110
  286. scipy/optimize/_optimize.py +86 -48
  287. scipy/optimize/_pava_pybind.cpython-312-darwin.so +0 -0
  288. scipy/optimize/_remove_redundancy.py +5 -5
  289. scipy/optimize/_root_scalar.py +1 -1
  290. scipy/optimize/_shgo.py +6 -0
  291. scipy/optimize/_shgo_lib/_complex.py +1 -1
  292. scipy/optimize/_slsqp_py.py +216 -124
  293. scipy/optimize/_slsqplib.cpython-312-darwin.so +0 -0
  294. scipy/optimize/_spectral.py +1 -1
  295. scipy/optimize/_tnc.py +8 -1
  296. scipy/optimize/_trlib/_trlib.cpython-312-darwin.so +0 -0
  297. scipy/optimize/_trustregion.py +20 -6
  298. scipy/optimize/_trustregion_constr/canonical_constraint.py +7 -7
  299. scipy/optimize/_trustregion_constr/equality_constrained_sqp.py +1 -1
  300. scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py +11 -3
  301. scipy/optimize/_trustregion_constr/projections.py +12 -8
  302. scipy/optimize/_trustregion_constr/qp_subproblem.py +9 -9
  303. scipy/optimize/_trustregion_constr/tests/test_projections.py +7 -7
  304. scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py +77 -77
  305. scipy/optimize/_trustregion_constr/tr_interior_point.py +5 -5
  306. scipy/optimize/_trustregion_exact.py +0 -1
  307. scipy/optimize/_zeros.cpython-312-darwin.so +0 -0
  308. scipy/optimize/_zeros_py.py +97 -17
  309. scipy/optimize/cython_optimize/_zeros.cpython-312-darwin.so +0 -0
  310. scipy/optimize/slsqp.py +0 -1
  311. scipy/optimize/tests/test__basinhopping.py +1 -1
  312. scipy/optimize/tests/test__differential_evolution.py +4 -4
  313. scipy/optimize/tests/test__linprog_clean_inputs.py +5 -3
  314. scipy/optimize/tests/test__numdiff.py +66 -22
  315. scipy/optimize/tests/test__remove_redundancy.py +2 -2
  316. scipy/optimize/tests/test__shgo.py +9 -1
  317. scipy/optimize/tests/test_bracket.py +36 -46
  318. scipy/optimize/tests/test_chandrupatla.py +133 -135
  319. scipy/optimize/tests/test_cobyla.py +74 -45
  320. scipy/optimize/tests/test_constraints.py +1 -1
  321. scipy/optimize/tests/test_differentiable_functions.py +226 -6
  322. scipy/optimize/tests/test_lbfgsb_hessinv.py +22 -0
  323. scipy/optimize/tests/test_least_squares.py +125 -13
  324. scipy/optimize/tests/test_linear_assignment.py +3 -3
  325. scipy/optimize/tests/test_linprog.py +3 -3
  326. scipy/optimize/tests/test_lsq_linear.py +6 -6
  327. scipy/optimize/tests/test_minimize_constrained.py +2 -2
  328. scipy/optimize/tests/test_minpack.py +4 -4
  329. scipy/optimize/tests/test_nnls.py +43 -3
  330. scipy/optimize/tests/test_nonlin.py +36 -0
  331. scipy/optimize/tests/test_optimize.py +95 -17
  332. scipy/optimize/tests/test_slsqp.py +36 -4
  333. scipy/optimize/tests/test_zeros.py +34 -1
  334. scipy/signal/__init__.py +12 -23
  335. scipy/signal/_delegators.py +568 -0
  336. scipy/signal/_filter_design.py +459 -241
  337. scipy/signal/_fir_filter_design.py +262 -90
  338. scipy/signal/_lti_conversion.py +3 -2
  339. scipy/signal/_ltisys.py +118 -91
  340. scipy/signal/_max_len_seq_inner.cpython-312-darwin.so +0 -0
  341. scipy/signal/_peak_finding_utils.cpython-312-darwin.so +0 -0
  342. scipy/signal/_polyutils.py +172 -0
  343. scipy/signal/_short_time_fft.py +519 -70
  344. scipy/signal/_signal_api.py +30 -0
  345. scipy/signal/_signaltools.py +719 -399
  346. scipy/signal/_sigtools.cpython-312-darwin.so +0 -0
  347. scipy/signal/_sosfilt.cpython-312-darwin.so +0 -0
  348. scipy/signal/_spectral_py.py +230 -50
  349. scipy/signal/_spline.cpython-312-darwin.so +0 -0
  350. scipy/signal/_spline_filters.py +108 -68
  351. scipy/signal/_support_alternative_backends.py +73 -0
  352. scipy/signal/_upfirdn.py +4 -1
  353. scipy/signal/_upfirdn_apply.cpython-312-darwin.so +0 -0
  354. scipy/signal/_waveforms.py +2 -11
  355. scipy/signal/_wavelets.py +1 -1
  356. scipy/signal/fir_filter_design.py +1 -0
  357. scipy/signal/spline.py +4 -11
  358. scipy/signal/tests/_scipy_spectral_test_shim.py +2 -171
  359. scipy/signal/tests/test_bsplines.py +114 -79
  360. scipy/signal/tests/test_cont2discrete.py +9 -2
  361. scipy/signal/tests/test_filter_design.py +721 -481
  362. scipy/signal/tests/test_fir_filter_design.py +332 -140
  363. scipy/signal/tests/test_savitzky_golay.py +4 -3
  364. scipy/signal/tests/test_short_time_fft.py +221 -3
  365. scipy/signal/tests/test_signaltools.py +2144 -1348
  366. scipy/signal/tests/test_spectral.py +50 -6
  367. scipy/signal/tests/test_splines.py +161 -96
  368. scipy/signal/tests/test_upfirdn.py +84 -50
  369. scipy/signal/tests/test_waveforms.py +20 -0
  370. scipy/signal/tests/test_windows.py +607 -466
  371. scipy/signal/windows/_windows.py +287 -148
  372. scipy/sparse/__init__.py +23 -4
  373. scipy/sparse/_base.py +270 -108
  374. scipy/sparse/_bsr.py +7 -4
  375. scipy/sparse/_compressed.py +59 -231
  376. scipy/sparse/_construct.py +90 -38
  377. scipy/sparse/_coo.py +115 -181
  378. scipy/sparse/_csc.py +4 -4
  379. scipy/sparse/_csparsetools.cpython-312-darwin.so +0 -0
  380. scipy/sparse/_csr.py +2 -2
  381. scipy/sparse/_data.py +48 -48
  382. scipy/sparse/_dia.py +105 -18
  383. scipy/sparse/_dok.py +0 -23
  384. scipy/sparse/_index.py +4 -4
  385. scipy/sparse/_matrix.py +23 -0
  386. scipy/sparse/_sparsetools.cpython-312-darwin.so +0 -0
  387. scipy/sparse/_sputils.py +37 -22
  388. scipy/sparse/base.py +0 -9
  389. scipy/sparse/bsr.py +0 -14
  390. scipy/sparse/compressed.py +0 -23
  391. scipy/sparse/construct.py +0 -6
  392. scipy/sparse/coo.py +0 -14
  393. scipy/sparse/csc.py +0 -3
  394. scipy/sparse/csgraph/_flow.cpython-312-darwin.so +0 -0
  395. scipy/sparse/csgraph/_matching.cpython-312-darwin.so +0 -0
  396. scipy/sparse/csgraph/_min_spanning_tree.cpython-312-darwin.so +0 -0
  397. scipy/sparse/csgraph/_reordering.cpython-312-darwin.so +0 -0
  398. scipy/sparse/csgraph/_shortest_path.cpython-312-darwin.so +0 -0
  399. scipy/sparse/csgraph/_tools.cpython-312-darwin.so +0 -0
  400. scipy/sparse/csgraph/_traversal.cpython-312-darwin.so +0 -0
  401. scipy/sparse/csgraph/tests/test_matching.py +14 -2
  402. scipy/sparse/csgraph/tests/test_pydata_sparse.py +4 -1
  403. scipy/sparse/csgraph/tests/test_shortest_path.py +83 -27
  404. scipy/sparse/csr.py +0 -5
  405. scipy/sparse/data.py +1 -6
  406. scipy/sparse/dia.py +0 -7
  407. scipy/sparse/dok.py +0 -10
  408. scipy/sparse/linalg/_dsolve/_superlu.cpython-312-darwin.so +0 -0
  409. scipy/sparse/linalg/_dsolve/linsolve.py +9 -0
  410. scipy/sparse/linalg/_dsolve/tests/test_linsolve.py +35 -28
  411. scipy/sparse/linalg/_eigen/arpack/_arpack.cpython-312-darwin.so +0 -0
  412. scipy/sparse/linalg/_eigen/arpack/arpack.py +23 -17
  413. scipy/sparse/linalg/_eigen/lobpcg/lobpcg.py +6 -6
  414. scipy/sparse/linalg/_interface.py +17 -18
  415. scipy/sparse/linalg/_isolve/_gcrotmk.py +4 -4
  416. scipy/sparse/linalg/_isolve/iterative.py +51 -45
  417. scipy/sparse/linalg/_isolve/lgmres.py +6 -6
  418. scipy/sparse/linalg/_isolve/minres.py +5 -5
  419. scipy/sparse/linalg/_isolve/tfqmr.py +7 -7
  420. scipy/sparse/linalg/_isolve/utils.py +2 -8
  421. scipy/sparse/linalg/_matfuncs.py +1 -1
  422. scipy/sparse/linalg/_norm.py +1 -1
  423. scipy/sparse/linalg/_propack/_cpropack.cpython-312-darwin.so +0 -0
  424. scipy/sparse/linalg/_propack/_dpropack.cpython-312-darwin.so +0 -0
  425. scipy/sparse/linalg/_propack/_spropack.cpython-312-darwin.so +0 -0
  426. scipy/sparse/linalg/_propack/_zpropack.cpython-312-darwin.so +0 -0
  427. scipy/sparse/linalg/_special_sparse_arrays.py +39 -38
  428. scipy/sparse/linalg/tests/test_pydata_sparse.py +14 -0
  429. scipy/sparse/tests/test_arithmetic1d.py +5 -2
  430. scipy/sparse/tests/test_base.py +214 -42
  431. scipy/sparse/tests/test_common1d.py +7 -7
  432. scipy/sparse/tests/test_construct.py +1 -1
  433. scipy/sparse/tests/test_coo.py +272 -4
  434. scipy/sparse/tests/test_sparsetools.py +5 -0
  435. scipy/sparse/tests/test_sputils.py +36 -7
  436. scipy/spatial/_ckdtree.cpython-312-darwin.so +0 -0
  437. scipy/spatial/_distance_pybind.cpython-312-darwin.so +0 -0
  438. scipy/spatial/_distance_wrap.cpython-312-darwin.so +0 -0
  439. scipy/spatial/_hausdorff.cpython-312-darwin.so +0 -0
  440. scipy/spatial/_qhull.cpython-312-darwin.so +0 -0
  441. scipy/spatial/_voronoi.cpython-312-darwin.so +0 -0
  442. scipy/spatial/distance.py +49 -42
  443. scipy/spatial/tests/test_distance.py +15 -1
  444. scipy/spatial/tests/test_kdtree.py +1 -0
  445. scipy/spatial/tests/test_qhull.py +7 -2
  446. scipy/spatial/transform/__init__.py +5 -3
  447. scipy/spatial/transform/_rigid_transform.cpython-312-darwin.so +0 -0
  448. scipy/spatial/transform/_rotation.cpython-312-darwin.so +0 -0
  449. scipy/spatial/transform/tests/test_rigid_transform.py +1221 -0
  450. scipy/spatial/transform/tests/test_rotation.py +1213 -832
  451. scipy/spatial/transform/tests/test_rotation_groups.py +3 -3
  452. scipy/spatial/transform/tests/test_rotation_spline.py +29 -8
  453. scipy/special/__init__.py +1 -47
  454. scipy/special/_add_newdocs.py +34 -772
  455. scipy/special/_basic.py +22 -25
  456. scipy/special/_comb.cpython-312-darwin.so +0 -0
  457. scipy/special/_ellip_harm_2.cpython-312-darwin.so +0 -0
  458. scipy/special/_gufuncs.cpython-312-darwin.so +0 -0
  459. scipy/special/_logsumexp.py +67 -58
  460. scipy/special/_orthogonal.pyi +1 -1
  461. scipy/special/_specfun.cpython-312-darwin.so +0 -0
  462. scipy/special/_special_ufuncs.cpython-312-darwin.so +0 -0
  463. scipy/special/_spherical_bessel.py +4 -4
  464. scipy/special/_support_alternative_backends.py +212 -119
  465. scipy/special/_test_internal.cpython-312-darwin.so +0 -0
  466. scipy/special/_testutils.py +4 -4
  467. scipy/special/_ufuncs.cpython-312-darwin.so +0 -0
  468. scipy/special/_ufuncs.pyi +1 -0
  469. scipy/special/_ufuncs.pyx +215 -1400
  470. scipy/special/_ufuncs_cxx.cpython-312-darwin.so +0 -0
  471. scipy/special/_ufuncs_cxx.pxd +2 -15
  472. scipy/special/_ufuncs_cxx.pyx +5 -44
  473. scipy/special/_ufuncs_cxx_defs.h +2 -16
  474. scipy/special/_ufuncs_defs.h +0 -8
  475. scipy/special/cython_special.cpython-312-darwin.so +0 -0
  476. scipy/special/cython_special.pxd +1 -1
  477. scipy/special/tests/_cython_examples/meson.build +10 -1
  478. scipy/special/tests/test_basic.py +153 -20
  479. scipy/special/tests/test_boost_ufuncs.py +3 -0
  480. scipy/special/tests/test_cdflib.py +35 -11
  481. scipy/special/tests/test_gammainc.py +16 -0
  482. scipy/special/tests/test_hyp2f1.py +2 -2
  483. scipy/special/tests/test_log1mexp.py +85 -0
  484. scipy/special/tests/test_logsumexp.py +206 -64
  485. scipy/special/tests/test_mpmath.py +1 -0
  486. scipy/special/tests/test_nan_inputs.py +1 -1
  487. scipy/special/tests/test_orthogonal.py +17 -18
  488. scipy/special/tests/test_sf_error.py +3 -2
  489. scipy/special/tests/test_sph_harm.py +6 -7
  490. scipy/special/tests/test_support_alternative_backends.py +211 -76
  491. scipy/stats/__init__.py +4 -1
  492. scipy/stats/_ansari_swilk_statistics.cpython-312-darwin.so +0 -0
  493. scipy/stats/_axis_nan_policy.py +5 -12
  494. scipy/stats/_biasedurn.cpython-312-darwin.so +0 -0
  495. scipy/stats/_continued_fraction.py +387 -0
  496. scipy/stats/_continuous_distns.py +277 -310
  497. scipy/stats/_correlation.py +1 -1
  498. scipy/stats/_covariance.py +6 -3
  499. scipy/stats/_discrete_distns.py +39 -32
  500. scipy/stats/_distn_infrastructure.py +39 -12
  501. scipy/stats/_distribution_infrastructure.py +900 -238
  502. scipy/stats/_entropy.py +9 -10
  503. scipy/{_lib → stats}/_finite_differences.py +1 -1
  504. scipy/stats/_hypotests.py +83 -50
  505. scipy/stats/_kde.py +53 -49
  506. scipy/stats/_ksstats.py +1 -1
  507. scipy/stats/_levy_stable/__init__.py +7 -15
  508. scipy/stats/_levy_stable/levyst.cpython-312-darwin.so +0 -0
  509. scipy/stats/_morestats.py +118 -73
  510. scipy/stats/_mstats_basic.py +13 -17
  511. scipy/stats/_mstats_extras.py +8 -8
  512. scipy/stats/_multivariate.py +89 -113
  513. scipy/stats/_new_distributions.py +97 -20
  514. scipy/stats/_page_trend_test.py +12 -5
  515. scipy/stats/_probability_distribution.py +265 -43
  516. scipy/stats/_qmc.py +14 -9
  517. scipy/stats/_qmc_cy.cpython-312-darwin.so +0 -0
  518. scipy/stats/_qmvnt.py +16 -95
  519. scipy/stats/_qmvnt_cy.cpython-312-darwin.so +0 -0
  520. scipy/stats/_quantile.py +335 -0
  521. scipy/stats/_rcont/rcont.cpython-312-darwin.so +0 -0
  522. scipy/stats/_resampling.py +4 -29
  523. scipy/stats/_sampling.py +1 -1
  524. scipy/stats/_sobol.cpython-312-darwin.so +0 -0
  525. scipy/stats/_stats.cpython-312-darwin.so +0 -0
  526. scipy/stats/_stats_mstats_common.py +21 -2
  527. scipy/stats/_stats_py.py +550 -476
  528. scipy/stats/_stats_pythran.cpython-312-darwin.so +0 -0
  529. scipy/stats/_unuran/unuran_wrapper.cpython-312-darwin.so +0 -0
  530. scipy/stats/_unuran/unuran_wrapper.pyi +2 -1
  531. scipy/stats/_variation.py +6 -8
  532. scipy/stats/_wilcoxon.py +13 -7
  533. scipy/stats/tests/common_tests.py +6 -4
  534. scipy/stats/tests/test_axis_nan_policy.py +62 -24
  535. scipy/stats/tests/test_continued_fraction.py +173 -0
  536. scipy/stats/tests/test_continuous.py +379 -60
  537. scipy/stats/tests/test_continuous_basic.py +18 -12
  538. scipy/stats/tests/test_discrete_basic.py +14 -8
  539. scipy/stats/tests/test_discrete_distns.py +16 -16
  540. scipy/stats/tests/test_distributions.py +95 -75
  541. scipy/stats/tests/test_entropy.py +40 -48
  542. scipy/stats/tests/test_fit.py +4 -3
  543. scipy/stats/tests/test_hypotests.py +153 -24
  544. scipy/stats/tests/test_kdeoth.py +109 -41
  545. scipy/stats/tests/test_marray.py +289 -0
  546. scipy/stats/tests/test_morestats.py +79 -47
  547. scipy/stats/tests/test_mstats_basic.py +3 -3
  548. scipy/stats/tests/test_multivariate.py +434 -83
  549. scipy/stats/tests/test_qmc.py +13 -10
  550. scipy/stats/tests/test_quantile.py +199 -0
  551. scipy/stats/tests/test_rank.py +119 -112
  552. scipy/stats/tests/test_resampling.py +47 -56
  553. scipy/stats/tests/test_sampling.py +9 -4
  554. scipy/stats/tests/test_stats.py +799 -939
  555. scipy/stats/tests/test_variation.py +8 -6
  556. scipy/version.py +2 -2
  557. {scipy-1.15.3.dist-info → scipy-1.16.0rc2.dist-info}/LICENSE.txt +4 -4
  558. {scipy-1.15.3.dist-info → scipy-1.16.0rc2.dist-info}/METADATA +11 -11
  559. {scipy-1.15.3.dist-info → scipy-1.16.0rc2.dist-info}/RECORD +560 -567
  560. scipy-1.16.0rc2.dist-info/WHEEL +6 -0
  561. scipy/_lib/array_api_extra/_funcs.py +0 -484
  562. scipy/_lib/array_api_extra/_typing.py +0 -8
  563. scipy/interpolate/_bspl.cpython-312-darwin.so +0 -0
  564. scipy/optimize/_cobyla.cpython-312-darwin.so +0 -0
  565. scipy/optimize/_cython_nnls.cpython-312-darwin.so +0 -0
  566. scipy/optimize/_slsqp.cpython-312-darwin.so +0 -0
  567. scipy/spatial/qhull_src/COPYING.txt +0 -38
  568. scipy/special/libsf_error_state.dylib +0 -0
  569. scipy/special/tests/test_log_softmax.py +0 -109
  570. scipy/special/tests/test_xsf_cuda.py +0 -114
  571. scipy/special/xsf/binom.h +0 -89
  572. scipy/special/xsf/cdflib.h +0 -100
  573. scipy/special/xsf/cephes/airy.h +0 -307
  574. scipy/special/xsf/cephes/besselpoly.h +0 -51
  575. scipy/special/xsf/cephes/beta.h +0 -257
  576. scipy/special/xsf/cephes/cbrt.h +0 -131
  577. scipy/special/xsf/cephes/chbevl.h +0 -85
  578. scipy/special/xsf/cephes/chdtr.h +0 -193
  579. scipy/special/xsf/cephes/const.h +0 -87
  580. scipy/special/xsf/cephes/ellie.h +0 -293
  581. scipy/special/xsf/cephes/ellik.h +0 -251
  582. scipy/special/xsf/cephes/ellpe.h +0 -107
  583. scipy/special/xsf/cephes/ellpk.h +0 -117
  584. scipy/special/xsf/cephes/expn.h +0 -260
  585. scipy/special/xsf/cephes/gamma.h +0 -398
  586. scipy/special/xsf/cephes/hyp2f1.h +0 -596
  587. scipy/special/xsf/cephes/hyperg.h +0 -361
  588. scipy/special/xsf/cephes/i0.h +0 -149
  589. scipy/special/xsf/cephes/i1.h +0 -158
  590. scipy/special/xsf/cephes/igam.h +0 -421
  591. scipy/special/xsf/cephes/igam_asymp_coeff.h +0 -195
  592. scipy/special/xsf/cephes/igami.h +0 -313
  593. scipy/special/xsf/cephes/j0.h +0 -225
  594. scipy/special/xsf/cephes/j1.h +0 -198
  595. scipy/special/xsf/cephes/jv.h +0 -715
  596. scipy/special/xsf/cephes/k0.h +0 -164
  597. scipy/special/xsf/cephes/k1.h +0 -163
  598. scipy/special/xsf/cephes/kn.h +0 -243
  599. scipy/special/xsf/cephes/lanczos.h +0 -112
  600. scipy/special/xsf/cephes/ndtr.h +0 -275
  601. scipy/special/xsf/cephes/poch.h +0 -85
  602. scipy/special/xsf/cephes/polevl.h +0 -167
  603. scipy/special/xsf/cephes/psi.h +0 -194
  604. scipy/special/xsf/cephes/rgamma.h +0 -111
  605. scipy/special/xsf/cephes/scipy_iv.h +0 -811
  606. scipy/special/xsf/cephes/shichi.h +0 -248
  607. scipy/special/xsf/cephes/sici.h +0 -224
  608. scipy/special/xsf/cephes/sindg.h +0 -221
  609. scipy/special/xsf/cephes/tandg.h +0 -139
  610. scipy/special/xsf/cephes/trig.h +0 -58
  611. scipy/special/xsf/cephes/unity.h +0 -186
  612. scipy/special/xsf/cephes/zeta.h +0 -172
  613. scipy/special/xsf/config.h +0 -304
  614. scipy/special/xsf/digamma.h +0 -205
  615. scipy/special/xsf/error.h +0 -57
  616. scipy/special/xsf/evalpoly.h +0 -47
  617. scipy/special/xsf/expint.h +0 -266
  618. scipy/special/xsf/hyp2f1.h +0 -694
  619. scipy/special/xsf/iv_ratio.h +0 -173
  620. scipy/special/xsf/lambertw.h +0 -150
  621. scipy/special/xsf/loggamma.h +0 -163
  622. scipy/special/xsf/sici.h +0 -200
  623. scipy/special/xsf/tools.h +0 -427
  624. scipy/special/xsf/trig.h +0 -164
  625. scipy/special/xsf/wright_bessel.h +0 -843
  626. scipy/special/xsf/zlog1.h +0 -35
  627. scipy/stats/_mvn.cpython-312-darwin.so +0 -0
  628. scipy-1.15.3.dist-info/WHEEL +0 -4
@@ -1,843 +0,0 @@
1
- /* Translated from Cython into C++ by SciPy developers in 2023.
2
- * Original header with Copyright information appears below.
3
- */
4
-
5
- /* Implementation of Wright's generalized Bessel function Phi, see
6
- * https://dlmf.nist.gov/10.46.E1
7
- *
8
- * Copyright: Christian Lorentzen
9
- *
10
- * Distributed under the same license as SciPy
11
- *
12
- *
13
- * Implementation Overview:
14
- *
15
- * First, different functions are implemented valid for certain domains of the
16
- * three arguments.
17
- * Finally they are put together in wright_bessel. See the docstring of
18
- * that function for more details.
19
- */
20
-
21
- #pragma once
22
-
23
- #include "cephes/lanczos.h"
24
- #include "cephes/polevl.h"
25
- #include "cephes/rgamma.h"
26
- #include "config.h"
27
- #include "digamma.h"
28
- #include "error.h"
29
-
30
- namespace xsf {
31
-
32
- namespace detail {
33
- // rgamma_zero: smallest value x for which rgamma(x) == 0 as x gets large
34
- constexpr double rgamma_zero = 178.47241115886637;
35
-
36
- XSF_HOST_DEVICE inline double exp_rgamma(double x, double y) {
37
- /* Compute exp(x) / gamma(y) = exp(x) * rgamma(y).
38
- *
39
- * This helper function avoids overflow by using the lanczos
40
- * approximation of the gamma function.
41
- */
42
- return std::exp(x + (1 - std::log(y + cephes::lanczos_g - 0.5)) * (y - 0.5)) /
43
- cephes::lanczos_sum_expg_scaled(y);
44
- }
45
-
46
- XSF_HOST_DEVICE inline double wb_series(double a, double b, double x, unsigned int nstart, unsigned int nstop) {
47
- /* 1. Taylor series expansion in x=0 for x <= 1.
48
- *
49
- * Phi(a, b, x) = sum_k x^k / k! / Gamma(a*k + b)
50
- *
51
- * Note that every term, and therefore also Phi(a, b, x) is
52
- * monotone decreasing with increasing a or b.
53
- */
54
- double xk_k = std::pow(x, nstart) * cephes::rgamma(nstart + 1); // x^k/k!
55
- double res = xk_k * cephes::rgamma(nstart * a + b);
56
- // term k=nstart+1, +2, +3, ...
57
- if (nstop > nstart) {
58
- // series expansion until term k such that a*k+b <= rgamma_zero
59
- unsigned int k_max = std::floor((rgamma_zero - b) / a);
60
- if (nstop > k_max) {
61
- nstop = k_max;
62
- }
63
- for (unsigned int k = nstart + 1; k < nstop; k++) {
64
- xk_k *= x / k;
65
- res += xk_k * cephes::rgamma(a * k + b);
66
- }
67
- }
68
- return res;
69
- }
70
-
71
- template<bool log_wb>
72
- XSF_HOST_DEVICE inline double wb_large_a(double a, double b, double x, int n) {
73
- /* 2. Taylor series expansion in x=0, for large a.
74
- *
75
- * Phi(a, b, x) = sum_k x^k / k! / Gamma(a*k + b)
76
- *
77
- * Use Stirling's formula to find k=k_max, the maximum term.
78
- * Then use n terms of Taylor series around k_max.
79
- */
80
- int k_max = static_cast<int>(std::pow(std::pow(a, -a) * x, 1.0 / (1 + a)));
81
-
82
- int nstart = k_max - n / 2;
83
- if (nstart < 0) {
84
- nstart = 0;
85
- }
86
-
87
- double res = 0;
88
- double lnx = std::log(x);
89
- // For numerical stability, we factor out the maximum term exp(..) with k=k_max
90
- // but only if it is larger than 0.
91
- double max_exponent = std::fmax(0, k_max * lnx - cephes::lgam(k_max + 1) - cephes::lgam(a * k_max + b));
92
- for (int k = nstart; k < nstart + n; k++) {
93
- res += std::exp(k * lnx - cephes::lgam(k + 1) - cephes::lgam(a * k + b) - max_exponent);
94
- }
95
-
96
- if (!log_wb) {
97
- res *= std::exp(max_exponent);
98
- } else {
99
- // logarithm of Wright's function
100
- res = max_exponent + std::log(res);
101
- }
102
- return res;
103
- }
104
-
105
- template<bool log_wb>
106
- XSF_HOST_DEVICE inline double wb_small_a(double a, double b, double x, int order) {
107
- /* 3. Taylor series in a=0 up to order 5, for tiny a and not too large x
108
- *
109
- * Phi(a, b, x) = exp(x)/Gamma(b)
110
- * (1 - a*x * Psi(b) + a^2/2*x*(1+x) * (Psi(b)^2 - Psi'(b)
111
- + ... )
112
- + O(a^6))
113
- *
114
- * where Psi is the digamma function.
115
- *
116
- * Parameter order takes effect only when b > 1e-3 and 2 <= order <= 5,
117
- * otherwise it defaults to 2, or if b <= 1e-3, to 5. The lower order is,
118
- * the fewer polygamma functions have to be computed.
119
- *
120
- * Call: python _precompute/wright_bessel.py 1
121
- *
122
- * For small b, i.e. b <= 1e-3, cancellation of poles of digamma(b)/Gamma(b)
123
- * and polygamma needs to be carried out => series expansion in a=0 to order 5
124
- * and in b=0 to order 4.
125
- * Call: python _precompute/wright_bessel.py 2
126
- */
127
- double A[6]; // coefficients of a^k (1, -x * Psi(b), ...)
128
- double B[6]; // powers of b^k/k! or terms in polygamma functions
129
- constexpr double C[5] = { // coefficients of a^k1 * b^k2
130
- 1.0000000000000000, // C[0]
131
- 1.1544313298030657, // C[1]
132
- -3.9352684291215233, // C[2]
133
- -1.0080632408182857, // C[3]
134
- 19.984633365874979, // C[4]
135
- };
136
- double X[6] = { // polynomials in x;
137
- 1, // X[0]
138
- x, // X[1]
139
- x * (x + 1), // X[2]
140
- x * (x * (x + 3) + 1), // X[3]
141
- x * (x * (x * (x + 6) + 7) + 1), // X[4]
142
- x * (x * (x * (x * (x + 10) + 25) + 15) + 1), // X[5]
143
- };
144
- double res;
145
-
146
- if (b <= 1E-3) {
147
- /* Series expansion of both a and b up to order 5:
148
- * M_PI = pi
149
- * M_EG = Euler Gamma aka Euler Mascheroni constant
150
- * M_Z3 = zeta(3)
151
- * C[0] = 1
152
- * C[1] = 2*M_EG
153
- * C[2] = 3*M_EG^2 - M_PI^2/2
154
- * C[3] = 4*M_EG^3 - 2*M_EG*M_PI^2 + 8*M_Z3
155
- * C[4] = 5*M_EG^4 - 5*M_EG^2*M_PI^2 + 40*M_EG*M_Z3 + M_PI^4/12
156
- */
157
- B[0] = 1.;
158
- for (int k = 1; k < 5; k++) {
159
- B[k] = b / k * B[k - 1];
160
- }
161
- // Note that polevl assumes inverse ordering => A[5] = 0th term
162
- A[5] = cephes::rgamma(b);
163
- A[4] = X[1] * (C[0] + C[1] * b + C[2] * B[2] + C[3] * B[3] + C[4] * B[4]);
164
- A[3] = X[2] / 2. * (C[1] + C[2] * b + C[3] * B[2] + C[4] * B[3]);
165
- A[2] = X[3] / 6. * (C[2] + C[3] * b + C[4] * B[2]);
166
- A[1] = X[4] / 24. * (C[3] + C[4] * b);
167
- A[0] = X[5] / 120. * C[4];
168
- // res = exp(x) * (A[5] + A[4] * a + A[3] * a^2 + A[2] * a^3 + ...)
169
- if (!log_wb) {
170
- res = exp(x) * cephes::polevl(a, A, 5);
171
- } else {
172
- // logarithm of Wright's function
173
- res = x + std::log(cephes::polevl(a, A, 5));
174
- }
175
- } else {
176
- /* Phi(a, b, x) = exp(x)/gamma(b) * sum(A[i] * X[i] * B[i], i=0..5)
177
- * A[n] = a^n/n!
178
- * But here, we repurpose A[n] = X[n] * B[n] / n!
179
- * Note that polevl assumes inverse ordering => A[order] = 0th term */
180
- double dg = digamma(b);
181
- // pg1 = polygamma(1, b)
182
- double pg1 = cephes::zeta(2, b);
183
- if (order <= 2) {
184
- res = 1 + a * x * (-dg + 0.5 * a * (1 + x) * (dg * dg - pg1));
185
- } else {
186
- if (order > 5) {
187
- order = 5;
188
- }
189
- // pg2 = polygamma(2, b)
190
- double pg2 = -2 * cephes::zeta(3, b);
191
- B[0] = 1;
192
- B[1] = -dg;
193
- B[2] = dg * dg - pg1;
194
- B[3] = (-dg * dg + 3 * pg1) * dg - pg2;
195
- A[order] = 1;
196
- A[order - 1] = X[1] * B[1];
197
- A[order - 2] = X[2] * B[2] / 2.;
198
- A[order - 3] = X[3] * B[3] / 6.;
199
- if (order >= 4) {
200
- // double pg3 = polygamma(3, b)
201
- double pg3 = 6 * cephes::zeta(4, b);
202
- B[4] = ((dg * dg - 6 * pg1) * dg + 4 * pg2) * dg + 3 * pg1 * pg1 - pg3;
203
- A[order - 4] = X[4] * B[4] / 24.;
204
- if (order >= 5) {
205
- // pg4 = polygamma(4, b)
206
- double pg4 = -24 * cephes::zeta(5, b);
207
- B[5] =
208
- ((((-dg * dg + 10 * pg1) * dg - 10 * pg2) * dg - 15 * pg1 * pg1 + 5 * pg3) * dg +
209
- 10 * pg1 * pg2 - pg4);
210
- A[order - 5] = X[5] * B[5] / 120.;
211
- }
212
- }
213
- res = cephes::polevl(a, A, order);
214
- }
215
- // res *= exp(x) * rgamma(b)
216
- if (!log_wb) {
217
- res *= exp_rgamma(x, b);
218
- } else {
219
- // logarithm of Wright's function
220
- res = x - cephes::lgam(b) + std::log(res);
221
- }
222
- }
223
- return res;
224
- }
225
-
226
- template<bool log_wb>
227
- XSF_HOST_DEVICE inline double wb_asymptotic(double a, double b, double x) {
228
- /* 4. Asymptotic expansion for large x up to order 8
229
- *
230
- * Phi(a, b, x) ~ Z^(1/2-b) * exp((1+a)/a * Z) * sum_k (-1)^k * C_k / Z^k
231
- *
232
- * with Z = (a*x)^(1/(1+a)).
233
- * Call: python _precompute/wright_bessel.py 3
234
- */
235
- double A[15]; // powers of a
236
- double B[17]; // powers of b
237
- double Ap1[9]; // powers of (1+a)
238
- double C[9]; // coefficients of asymptotic series a_k
239
-
240
- A[0] = 1.;
241
- B[0] = 1.;
242
- Ap1[0] = 1.;
243
- for (int k = 1; k < 15; k++) {
244
- A[k] = A[k - 1] * a;
245
- }
246
- for (int k = 1; k < 17; k++) {
247
- B[k] = B[k - 1] * b;
248
- }
249
- for (int k = 1; k < 9; k++) {
250
- Ap1[k] = Ap1[k - 1] * (1 + a);
251
- }
252
-
253
- C[0] = 1. / std::sqrt(2. * M_PI * Ap1[1]);
254
-
255
- C[1] = C[0] / (24 * Ap1[1]);
256
- C[1] *= (2 * a + 1) * (2 + a) - 12 * b * (1 + a - b);
257
-
258
- C[2] = C[0] / (1152 * Ap1[2]);
259
- C[2] *=
260
- (144 * B[4] - 96 * B[3] * (5 * a + 1) + 24 * B[2] * (20 * A[2] + 5 * a - 4) -
261
- 24 * b * Ap1[1] * (6 * A[2] - 7 * a - 2) + (a + 2) * (2 * a + 1) * (2 * A[2] - 19 * a + 2));
262
-
263
- C[3] = C[0] / (414720 * Ap1[3]);
264
- C[3] *=
265
- (8640 * B[6] - 8640 * B[5] * (7 * a - 1) + 10800 * B[4] * (14 * A[2] - 7 * a - 2) -
266
- 1440 * B[3] * (112 * A[3] - 147 * A[2] - 63 * a + 8) +
267
- 180 * B[2] * (364 * A[4] - 1288 * A[3] - 567 * A[2] + 392 * a + 76) -
268
- 180 * b * Ap1[1] * (20 * A[4] - 516 * A[3] + 417 * A[2] + 172 * a - 12) -
269
- (a + 2) * (2 * a + 1) * (556 * A[4] + 1628 * A[3] - 9093 * A[2] + 1628 * a + 556));
270
-
271
- C[4] = C[0] / (39813120 * Ap1[4]);
272
- C[4] *=
273
- (103680 * B[8] - 414720 * B[7] * (3 * a - 1) + 725760 * B[6] * a * (8 * a - 7) -
274
- 48384 * B[5] * (274 * A[3] - 489 * A[2] + 39 * a + 26) +
275
- 30240 * B[4] * (500 * A[4] - 1740 * A[3] + 495 * A[2] + 340 * a - 12) -
276
- 2880 * B[3] * (2588 * A[5] - 19780 * A[4] + 14453 * A[3] + 9697 * A[2] - 1892 * a - 404) +
277
- 48 * B[2] *
278
- (11488 * A[6] - 547836 * A[5] + 1007484 * A[4] + 593353 * A[3] - 411276 * A[2] - 114396 * a + 4288) +
279
- 48 * b * Ap1[1] *
280
- (7784 * A[6] + 48180 * A[5] - 491202 * A[4] + 336347 * A[3] + 163734 * A[2] - 28908 * a - 5560) -
281
- (a + 2) * (2 * a + 1) *
282
- (4568 * A[6] - 226668 * A[5] - 465702 * A[4] + 2013479 * A[3] - 465702 * A[2] - 226668 * a + 4568));
283
-
284
- C[5] = C[0] / (6688604160. * Ap1[5]);
285
- C[5] *=
286
- (1741824 * B[10] - 2903040 * B[9] * (11 * a - 5) + 2177280 * B[8] * (110 * A[2] - 121 * a + 14) -
287
- 580608 * B[7] * (1628 * A[3] - 3333 * A[2] + 1023 * a + 52) +
288
- 169344 * B[6] * (12364 * A[4] - 43648 * A[3] + 26763 * A[2] + 1232 * a - 788) -
289
- 24192 * B[5] * (104852 * A[5] - 646624 * A[4] + 721391 * A[3] - 16841 * A[2] - 74096 * a + 148) +
290
- 2016 * B[4] *
291
- (710248 * A[6] - 8878716 * A[5] + 17928834 * A[4] - 3333407 * A[3] - 4339566 * A[2] + 287364 * a +
292
- 89128) -
293
- 1344 * B[3] *
294
- (87824 * A[7] - 7150220 * A[6] + 29202756 * A[5] - 15113527 * A[4] - 14223011 * A[3] + 3462492 * A[2] +
295
- 1137092 * a - 18896) -
296
- 84 * B[2] *
297
- (1690480 * A[8] + 14139136 * A[7] - 232575464 * A[6] + 296712592 * A[5] + 215856619 * A[4] -
298
- 152181392 * A[3] - 47718440 * A[2] + 5813632 * a + 943216) +
299
- 84 * b * Ap1[1] *
300
- (82224 * A[8] - 5628896 * A[7] - 26466520 * A[6] + 168779208 * A[5] - 104808005 * A[4] -
301
- 56259736 * A[3] + 15879912 * A[2] + 4020640 * a - 63952) +
302
- (a + 2) * (2 * a + 1) *
303
- (2622064 * A[8] + 12598624 * A[7] - 167685080 * A[6] - 302008904 * A[5] + 1115235367. * A[4] -
304
- 302008904 * A[3] - 167685080 * A[2] + 12598624 * a + 2622064));
305
-
306
- C[6] = C[0] / (4815794995200. * Ap1[6]);
307
- C[6] *=
308
- (104509440 * B[12] - 209018880 * B[11] * (13 * a - 7) + 574801920 * B[10] * (52 * A[2] - 65 * a + 12) -
309
- 63866880 * B[9] * (2834 * A[3] - 6279 * A[2] + 2769 * a - 134) +
310
- 23950080 * B[8] * (27404 * A[4] - 98228 * A[3] + 78663 * A[2] - 10868 * a - 1012) -
311
- 13685760 * B[7] * (105612 * A[5] - 599196 * A[4] + 791843 * A[3] - 224913 * A[2] - 27612 * a + 4540) +
312
- 2661120 * B[6] *
313
- (693680 * A[6] - 6473532 * A[5] + 13736424 * A[4] - 7047469 * A[3] - 723840 * A[2] + 471588 * a + 7376
314
- ) -
315
- 2661120 * B[5] *
316
- (432536 * A[7] - 7850804 * A[6] + 27531114 * A[5] - 24234457 * A[4] - 703001 * A[3] + 3633474 * A[2] -
317
- 36244 * a - 45128) +
318
- 166320 * B[4] *
319
- (548912 * A[8] - 75660832 * A[7] + 502902712 * A[6] - 764807992 * A[5] + 91248287 * A[4] +
320
- 217811464 * A[3] - 20365384 * A[2] - 9776416 * a + 37936) +
321
- 10080 * B[3] *
322
- (18759728 * A[9] + 165932208 * A[8] - 4710418440. * A[7] + 13686052536. * A[6] - 5456818809. * A[5] -
323
- 6834514245. * A[4] + 1919299512. * A[3] + 752176152 * A[2] - 45661200 * a - 8616848) -
324
- 360 * B[2] *
325
- (32743360 * A[10] - 3381871792. * A[9] - 21488827776. * A[8] + 200389923864. * A[7] -
326
- 198708005340. * A[6] - 171633799779. * A[5] + 123124874028. * A[4] + 40072774872. * A[3] -
327
- 9137993280. * A[2] - 1895843248. * a + 18929728) -
328
- 360 * b * Ap1[1] *
329
- (57685408 * A[10] + 406929456 * A[9] - 6125375760. * A[8] - 27094918920. * A[7] +
330
- 128752249410. * A[6] - 74866710561. * A[5] - 42917416470. * A[4] + 16256951352. * A[3] +
331
- 4375268400. * A[2] - 316500688 * a - 47197152) +
332
- (a + 2) * (2 * a + 1) *
333
- (167898208 * A[10] - 22774946512. * A[9] - 88280004528. * A[8] + 611863976472. * A[7] +
334
- 1041430242126. * A[6] - 3446851131657. * A[5] + 1041430242126. * A[4] + 611863976472. * A[3] -
335
- 88280004528. * A[2] - 22774946512. * a + 167898208));
336
-
337
- C[7] = C[0] / (115579079884800. * Ap1[7]);
338
- C[7] *=
339
- (179159040 * B[14] - 1254113280. * B[13] * (5 * a - 3) + 1358622720. * B[12] * (70 * A[2] - 95 * a + 22) -
340
- 905748480 * B[11] * (904 * A[3] - 2109 * A[2] + 1119 * a - 112) +
341
- 1245404160. * B[10] * (3532 * A[4] - 12824 * A[3] + 11829 * A[2] - 2824 * a + 44) -
342
- 59304960 * B[9] * (256820 * A[5] - 1397680 * A[4] + 2025545 * A[3] - 869495 * A[2] + 52000 * a + 8788) +
343
- 14826240 * B[8] *
344
- (2274536 * A[6] - 18601572 * A[5] + 40698318 * A[4] - 28230079 * A[3] + 3916398 * A[2] + 832668 * a -
345
- 65176) -
346
- 59304960 * B[7] *
347
- (760224 * A[7] - 9849164 * A[6] + 32495784 * A[5] - 34813869 * A[4] + 9175207 * A[3] + 1898688 * A[2] -
348
- 469788 * a - 13184) +
349
- 25945920 * B[6] *
350
- (1167504 * A[8] - 28779840 * A[7] + 149752856 * A[6] - 246026112 * A[5] + 111944073 * A[4] +
351
- 18341600 * A[3] - 12131496 * A[2] - 274368 * a + 102800) -
352
- 157248 * B[5] *
353
- (12341872 * A[9] - 3122991216. * A[8] + 29900054232. * A[7] - 78024816720. * A[6] +
354
- 58914656739. * A[5] + 4637150811. * A[4] - 11523402480. * A[3] + 236218968 * A[2] + 337923216 * a +
355
- 1592048) -
356
- 28080 * B[4] *
357
- (265154912 * A[10] + 2276098704. * A[9] - 105569461008. * A[8] + 496560666360. * A[7] -
358
- 627891462858. * A[6] + 41935358025. * A[5] + 203913875814. * A[4] - 23984801544. * A[3] -
359
- 13869306000. * A[2] + 372786832 * a + 103532640) +
360
- 1440 * B[3] *
361
- (310292864 * A[11] - 55169117872. * A[10] - 358957020112. * A[9] + 5714152556088. * A[8] -
362
- 13241597459352. * A[7] + 4220720097141. * A[6] + 6845418090249. * A[5] - 2129559215808. * A[4] -
363
- 909225098472. * A[3] + 107518582576. * A[2] + 25619444368. * a - 113832704) +
364
- 12 * B[2] *
365
- (135319651136. * A[12] + 1119107842176. * A[11] - 22193518174320. * A[10] - 133421793595520. * A[9] +
366
- 860103051087996. * A[8] - 703353374803080. * A[7] - 704240127687381. * A[6] +
367
- 513111704637960. * A[5] + 166909061348316. * A[4] - 57671564069120. * A[3] - 12453426246000. * A[2] +
368
- 695901207936. * a + 93786157376.) -
369
- 12 * b * Ap1[1] *
370
- (4365353408. * A[12] - 720248637504. * A[11] - 4222331152560. * A[10] + 29413934270560. * A[9] +
371
- 132123980710980. * A[8] - 511247376962820. * A[7] + 283403639131779. * A[6] +
372
- 170415792320940. * A[5] - 79274388426588. * A[4] - 21009953050400. * A[3] + 3284035340880. * A[2] +
373
- 589294339776. * a - 3693760576.) -
374
- (a + 2) * (2 * a + 1) *
375
- (34221025984. * A[12] + 226022948160. * A[11] - 5067505612464. * A[10] - 18868361443936. * A[9] +
376
- 86215425028308. * A[8] + 143500920544692. * A[7] - 437682618704613. * A[6] + 143500920544692. * A[5] +
377
- 86215425028308. * A[4] - 18868361443936. * A[3] - 5067505612464. * A[2] + 226022948160. * a +
378
- 34221025984.));
379
-
380
- C[8] = C[0] / (22191183337881600. * Ap1[8]);
381
- C[8] *=
382
- (2149908480. * B[16] - 5733089280. * B[15] * (17 * a - 11) +
383
- 7166361600. * B[14] * (272 * A[2] - 391 * a + 104) -
384
- 3344302080. * B[13] * (6766 * A[3] - 16371 * A[2] + 9741 * a - 1306) +
385
- 1811496960. * B[12] * (93092 * A[4] - 341564 * A[3] + 344199 * A[2] - 104924 * a + 6308) -
386
- 517570560 * B[11] *
387
- (1626220 * A[5] - 8641508 * A[4] + 13274773 * A[3] - 6952303 * A[2] + 1007420 * a + 5564) +
388
- 284663808 * B[10] *
389
- (9979136 * A[6] - 75766892 * A[5] + 169256148 * A[4] - 136824959 * A[3] + 35714348 * A[2] -
390
- 463692 * a - 293664) -
391
- 1423319040. * B[9] *
392
- (4466648 * A[7] - 49231116 * A[6] + 157507414 * A[5] - 187114257 * A[4] + 78372295 * A[3] -
393
- 4470082 * A[2] - 1913996 * a + 82424) +
394
- 266872320 * B[8] *
395
- (33133136 * A[8] - 564264544 * A[7] + 2618606424. * A[6] - 4491310104. * A[5] + 2853943765. * A[4] -
396
- 374694552 * A[3] - 135365288 * A[2] + 17623968 * a + 696912) -
397
- 2156544 * B[7] *
398
- (2914256144. * A[9] - 93491712432. * A[8] + 664876176984. * A[7] - 1661362937880. * A[6] +
399
- 1563719627313. * A[5] - 382840842843. * A[4] - 115399415640. * A[3] + 34565562936. * A[2] +
400
- 1609337232. * a - 217321904) +
401
- 179712 * B[6] *
402
- (1266018560. * A[10] - 789261834512. * A[9] + 10186841596896. * A[8] - 38877799073352. * A[7] +
403
- 54334425968952. * A[6] - 22529574889533. * A[5] - 5132942328000. * A[4] + 3438377465592. * A[3] +
404
- 84287641248. * A[2] - 72493479440. * a - 807415936) +
405
- 13824 * B[5] *
406
- (156356794976. * A[11] + 1180898077328. * A[10] - 90615270907936. * A[9] + 609258947056248. * A[8] -
407
- 1312655191366722. * A[7] + 885900509321745. * A[6] + 112162151855265. * A[5] -
408
- 212803071513258. * A[4] + 6805217831352. * A[3] + 10051742651296. * A[2] - 55035924848. * a -
409
- 52946379296.) -
410
- 576 * B[4] *
411
- (143943926464. * A[12] - 60115486481856. * A[11] - 376366989757200. * A[10] +
412
- 9534223075576160. * A[9] - 35603777465262396. * A[8] + 39375990156664980. * A[7] -
413
- 868175004137259. * A[6] - 14279180718355020. * A[5] + 1985747535239364. * A[4] +
414
- 1264001337603680. * A[3] - 75972792514320. * A[2] - 23855850572736. * a - 4996648256.) -
415
- 384 * B[3] *
416
- (2038525473856. * A[13] + 16057322146112. * A[12] - 502133360559024. * A[11] -
417
- 2985686417468080. * A[10] + 32418922182093292. * A[9] - 63665380623022452. * A[8] +
418
- 16481208821092575. * A[7] + 34161547357596099. * A[6] - 11490298497454932. * A[5] -
419
- 5117272758337156. * A[4] + 933703210750480. * A[3] + 234855186762000. * A[2] - 7860524600000. * a -
420
- 1226607567040.) +
421
- 96 * B[2] *
422
- (324439754752. * A[14] - 77231415197120. * A[13] - 539102931841856. * A[12] +
423
- 4618258299956336. * A[11] + 28588485529469792. * A[10] - 141383982651179428. * A[9] +
424
- 98783147840417772. * A[8] + 112831723492305801. * A[7] - 83329761150975036. * A[6] -
425
- 26553582937192900. * A[5] + 12469117738765952. * A[4] + 2587165396642160. * A[3] -
426
- 340406368038080. * A[2] - 53659641606080. * a + 219671272960.) +
427
- 96 * b * Ap1[1] *
428
- (1026630779520. * A[14] + 8781958472768. * A[13] - 210659786204384. * A[12] -
429
- 1222283505284208. * A[11] + 5064251967491416. * A[10] + 24013052207628140. * A[9] -
430
- 79710880160087370. * A[8] + 42596558293213227. * A[7] + 26570293386695790. * A[6] -
431
- 14407831324576884. * A[5] - 3617322833922440. * A[4] + 950664948554384. * A[3] +
432
- 172358006894496. * A[2] - 7430887938496. * a - 889746675584.) -
433
- (a + 2) * (2 * a + 1) *
434
- (573840801152. * A[14] - 156998277198784. * A[13] - 898376974770592. * A[12] +
435
- 8622589006459984. * A[11] + 32874204024803560. * A[10] - 111492707520083828. * A[9] -
436
- 184768503480287646. * A[8] + 528612016938984183. * A[7] - 184768503480287646. * A[6] -
437
- 111492707520083828. * A[5] + 32874204024803560. * A[4] + 8622589006459984. * A[3] -
438
- 898376974770592. * A[2] - 156998277198784. * a + 573840801152.));
439
-
440
- double Z = std::pow(a * x, 1 / Ap1[1]);
441
- double Zp = 1.;
442
- double res = C[0];
443
- for (int k = 1; k < 9; k++) {
444
- Zp /= Z;
445
- res += (k % 2 == 0 ? 1 : -1) * C[k] * Zp;
446
- }
447
- if (!log_wb) {
448
- res *= std::pow(Z, 0.5 - b) * std::exp(Ap1[1] / a * Z);
449
- } else {
450
- // logarithm of Wright's function
451
- res = std::log(Z) * (0.5 - b) + Ap1[1] / a * Z + std::log(res);
452
- }
453
- return res;
454
- }
455
-
456
- XSF_HOST_DEVICE inline double wb_Kmod(double exp_term, double eps, double a, double b, double x, double r) {
457
- /* Compute integrand Kmod(eps, a, b, x, r) for Gauss-Laguerre quadrature.
458
- *
459
- * K(a, b, x, r+eps) = exp(-r-eps) * Kmod(eps, a, b, x, r)
460
- *
461
- * Kmod(eps, a, b, x, r) = exp(x * (r+eps)^(-a) * cos(pi*a)) * (r+eps)^(-b)
462
- * * sin(x * (r+eps)^(-a) * sin(pi*a) + pi * b)
463
- *
464
- * Note that we additionally factor out exp(exp_term) which helps with large
465
- * terms in the exponent of exp(...)
466
- */
467
- double x_r_a = x * std::pow(r + eps, -a);
468
- return std::exp(x_r_a * cephes::cospi(a) + exp_term) * std::pow(r + eps, -b) *
469
- std::sin(x_r_a * cephes::sinpi(a) + M_PI * b);
470
- }
471
-
472
- XSF_HOST_DEVICE inline double wb_P(double exp_term, double eps, double a, double b, double x, double phi) {
473
- /* Compute integrand P for Gauss-Legendre quadrature.
474
- *
475
- * P(eps, a, b, x, phi) = exp(eps * cos(phi) + x * eps^(-a) * cos(a*phi))
476
- * * cos(eps * sin(phi) - x * eps^(-a) * sin(a*phi)
477
- * + (1-b)*phi)
478
- *
479
- * Note that we additionally factor out exp(exp_term) which helps with large
480
- * terms in the exponent of exp(...)
481
- */
482
- double x_eps_a = x * std::pow(eps, -a);
483
- return std::exp(eps * std::cos(phi) + x_eps_a * std::cos(a * phi) + exp_term) *
484
- std::cos(eps * std::sin(phi) - x_eps_a * std::sin(a * phi) + (1 - b) * phi);
485
- }
486
-
487
- /* roots of laguerre polynomial of order 50
488
- * scipy.special.roots_laguerre(50)[0] or
489
- * sympy.integrals.quadrature.import gauss_laguerre(50, 16)[0] */
490
- constexpr double wb_x_laguerre[] = {
491
- 0.02863051833937908, 0.1508829356769337, 0.3709487815348964, 0.6890906998810479, 1.105625023539913,
492
- 1.620961751102501, 2.23561037591518, 2.950183366641835, 3.765399774405782, 4.682089387559285,
493
- 5.70119757478489, 6.823790909794551, 8.051063669390792, 9.384345308258407, 10.82510903154915,
494
- 12.37498160875746, 14.03575459982991, 15.80939719784467, 17.69807093335025, 19.70414653546156,
495
- 21.83022330657825, 24.0791514444115, 26.45405784125298, 28.95837601193738, 31.59588095662286,
496
- 34.37072996309045, 37.28751061055049, 40.35129757358607, 43.56772026999502, 46.94304399160304,
497
- 50.48426796312992, 54.19924488016862, 58.09682801724853, 62.18705417568891, 66.48137387844482,
498
- 70.99294482661949, 75.73701154772731, 80.73140480247769, 85.99721113646323, 91.55969041253388,
499
- 97.44956561485056, 103.7048912366923, 110.3738588076403, 117.5191982031112, 125.2254701334734,
500
- 133.6120279227287, 142.8583254892541, 153.2603719726036, 165.3856433166825, 180.6983437092145
501
- };
502
- /* weights for laguerre polynomial of order 50
503
- * sympy.integrals.quadrature.import gauss_laguerre(50, 16)[1] */
504
- constexpr double wb_w_laguerre[] = {
505
- 0.07140472613518988, 0.1471486069645884, 0.1856716275748313, 0.1843853825273539,
506
- 0.1542011686063556, 0.1116853699022688, 0.07105288549019586, 0.04002027691150833,
507
- 0.02005062308007171, 0.008960851203646281, 0.00357811241531566, 0.00127761715678905,
508
- 0.0004080302449837189, 0.0001165288322309724, 2.974170493694165e-5, 6.777842526542028e-6,
509
- 1.37747950317136e-6, 2.492886181720092e-7, 4.010354350427827e-8, 5.723331748141425e-9,
510
- 7.229434249182665e-10, 8.061710142281779e-11, 7.913393099943723e-12, 6.81573661767678e-13,
511
- 5.13242671658949e-14, 3.365624762437814e-15, 1.913476326965035e-16, 9.385589781827253e-18,
512
- 3.950069964503411e-19, 1.417749517827512e-20, 4.309970276292175e-22, 1.101257519845548e-23,
513
- 2.344617755608987e-25, 4.11854415463823e-27, 5.902246763596448e-29, 6.812008916553065e-31,
514
- 6.237449498812102e-33, 4.452440579683377e-35, 2.426862352250487e-37, 9.852971481049686e-40,
515
- 2.891078872318428e-42, 5.906162708112361e-45, 8.01287459750397e-48, 6.789575424396417e-51,
516
- 3.308173010849252e-54, 8.250964876440456e-58, 8.848728128298018e-62, 3.064894889844417e-66,
517
- 1.988708229330752e-71, 6.049567152238783e-78
518
- };
519
- /* roots of legendre polynomial of order 50
520
- * sympy.integrals.quadrature.import gauss_legendre(50, 16)[0] */
521
- constexpr double wb_x_legendre[] = {
522
- -0.998866404420071, -0.9940319694320907, -0.9853540840480059, -0.9728643851066921, -0.9566109552428079,
523
- -0.9366566189448779, -0.9130785566557919, -0.885967979523613, -0.8554297694299461, -0.8215820708593359,
524
- -0.7845558329003993, -0.7444943022260685, -0.7015524687068223, -0.6558964656854394, -0.6077029271849502,
525
- -0.5571583045146501, -0.5044581449074642, -0.4498063349740388, -0.3934143118975651, -0.3355002454194374,
526
- -0.276288193779532, -0.2160072368760418, -0.1548905899981459, -0.09317470156008614, -0.03109833832718888,
527
- 0.03109833832718888, 0.09317470156008614, 0.1548905899981459, 0.2160072368760418, 0.276288193779532,
528
- 0.3355002454194374, 0.3934143118975651, 0.4498063349740388, 0.5044581449074642, 0.5571583045146501,
529
- 0.6077029271849502, 0.6558964656854394, 0.7015524687068223, 0.7444943022260685, 0.7845558329003993,
530
- 0.8215820708593359, 0.8554297694299461, 0.885967979523613, 0.9130785566557919, 0.9366566189448779,
531
- 0.9566109552428079, 0.9728643851066921, 0.9853540840480059, 0.9940319694320907, 0.998866404420071
532
- };
533
- /* weights for legendre polynomial of order 50
534
- * sympy.integrals.quadrature.import gauss_legendre(50, 16)[1] */
535
- constexpr double wb_w_legendre[] = {
536
- 0.002908622553155141, 0.006759799195745401, 0.01059054838365097, 0.01438082276148557, 0.01811556071348939,
537
- 0.02178024317012479, 0.02536067357001239, 0.0288429935805352, 0.03221372822357802, 0.03545983561514615,
538
- 0.03856875661258768, 0.0415284630901477, 0.04432750433880328, 0.04695505130394843, 0.04940093844946632,
539
- 0.05165570306958114, 0.05371062188899625, 0.05555774480621252, 0.05718992564772838, 0.05860084981322245,
540
- 0.05978505870426546, 0.06073797084177022, 0.06145589959031666, 0.06193606742068324, 0.06217661665534726,
541
- 0.06217661665534726, 0.06193606742068324, 0.06145589959031666, 0.06073797084177022, 0.05978505870426546,
542
- 0.05860084981322245, 0.05718992564772838, 0.05555774480621252, 0.05371062188899625, 0.05165570306958114,
543
- 0.04940093844946632, 0.04695505130394843, 0.04432750433880328, 0.0415284630901477, 0.03856875661258768,
544
- 0.03545983561514615, 0.03221372822357802, 0.0288429935805352, 0.02536067357001239, 0.02178024317012479,
545
- 0.01811556071348939, 0.01438082276148557, 0.01059054838365097, 0.006759799195745401, 0.002908622553155141
546
- };
547
- /* Fitted parameters for optimal choice of eps
548
- * Call: python _precompute/wright_bessel.py 4 */
549
- constexpr double wb_A[] = {0.41037, 0.30833, 6.9952, 18.382, -2.8566, 2.1122};
550
-
551
- template<bool log_wb>
552
- XSF_HOST_DEVICE inline double wright_bessel_integral(double a, double b, double x) {
553
- /* 5. Integral representation
554
- *
555
- * K(a, b, x, r) = exp(-r + x * r^(-a) * cos(pi*a)) * r^(-b)
556
- * * sin(x * r^(-a) * sin(pi*a) + pi * b)
557
- * P(eps, a, b, x, phi) = exp(eps * cos(phi) + x * eps^(-a) * cos(a*phi))
558
- * * cos(eps * sin(phi) - x * eps^(-a) * sin(a*phi)
559
- * + (1-b)*phi)
560
- *
561
- * Phi(a, b, x) = 1/pi * int_eps^inf K(a, b, x, r) * dr
562
- * + eps^(1-b)/pi * int_0^pi P(eps, a, b, x, phi) * dphi
563
- *
564
- * for any eps > 0.
565
- *
566
- * Note that P has a misprint in Luchko (2008) Eq. 9, the cos(phi(beta-1)) at
567
- * the end of the first line should be removed and the −sin(phi(beta−1)) at
568
- * the end of the second line should read +(1-b)*phi.
569
- * This integral representation introduced the free parameter eps (from the
570
- * radius of complex contour integration). We try to choose eps such that
571
- * the integrand behaves smoothly. Note that this is quite diffrent from how
572
- * Luchko (2008) deals with eps: he is either looking for the limit eps -> 0
573
- * or he sets (silently) eps=1. But having the freedom to set eps is much more
574
- * powerful for numerical evaluation.
575
- *
576
- * As K has a leading exp(-r), we factor this out and apply Gauss-Laguerre
577
- * quadrature rule:
578
- *
579
- * int_0^inf K(a, b, x, r+eps) dr = exp(-eps) int_0^inf exp(-r) Kmod(.., r) dr
580
- *
581
- * Note the shift r -> r+eps to have integation from 0 to infinity.
582
- * The integral over P is done via a Gauss-Legendre quadrature rule.
583
- *
584
- * Note: Hardest argument range is large z, large b and small eps.
585
- */
586
-
587
- /* We use the free choice of eps to make the integral better behaved.
588
- * 1. Concern is oscillatory behaviour of P. Therefore, we'd like to
589
- * make the change in the argument of cosine small, i.e. make arc length
590
- * int_0^phi sqrt(1 + f'(phi)^2) dphi small, with
591
- * f(phi) = eps * sin(phi) - x * eps^(-a) * sin(a*phi) + (1-b)*phi
592
- * Proxy, make |f'(phi)| small.
593
- * 2. Concern is int_0 K ~ int_0 (r+eps)^(-b) .. dr
594
- * This is difficult as r -> 0 for large b. It behaves better for larger
595
- * values of eps.
596
- */
597
-
598
- // Minimize oscillatory behavoir of P
599
- double eps =
600
- (wb_A[0] * b * std::exp(-0.5 * a) +
601
- std::exp(
602
- wb_A[1] + 1 / (1 + a) * std::log(x) - wb_A[2] * std::exp(-wb_A[3] * a) +
603
- wb_A[4] / (1 + std::exp(wb_A[5] * a))
604
- ));
605
-
606
- if (a >= 4 && x >= 100) {
607
- eps += 1; // This part is hard to fit
608
- }
609
-
610
- // Large b
611
- if (b >= 8) {
612
- /* Make P small compared to K by setting eps large enough.
613
- * int K ~ exp(-eps) and int P ~ eps^(1-b) */
614
- eps = std::fmax(eps, std::pow(b, -b / (1. - b)) + 0.1 * b);
615
- }
616
-
617
- // safeguard, higher better for larger a, lower better for tiny a.
618
- eps = std::fmin(eps, 150.);
619
- eps = std::fmax(eps, 3.); // 3 seems to be a pretty good choice in general.
620
-
621
- // We factor out exp(-exp_term) from wb_Kmod and wb_P to avoid overflow of
622
- // exp(..).
623
- double exp_term = 0;
624
- // From the exponent of K:
625
- double r = wb_x_laguerre[50-1]; // largest value of x used in wb_Kmod
626
- double x_r_a = x * std::pow(r + eps, -a);
627
- exp_term = std::fmax(exp_term, x_r_a * cephes::cospi(a));
628
- // From the exponent of P:
629
- double x_eps_a = x * std::pow(eps, -a);
630
- // phi = 0 => cos(phi) = cos(a * phi) = 1
631
- exp_term = std::fmax(exp_term, eps + x_eps_a);
632
- // phi = pi => cos(phi) = -1
633
- exp_term = std::fmax(exp_term, -eps + x_eps_a * cephes::cospi(a));
634
-
635
- double res1 = 0;
636
- double res2 = 0;
637
-
638
- double y;
639
- for (int k = 0; k < 50; k++) {
640
- res1 += wb_w_laguerre[k] * wb_Kmod(-exp_term, eps, a, b, x, wb_x_laguerre[k]);
641
- // y = (b-a)*(x+1)/2.0 + a for integration from a=0 to b=pi
642
- y = M_PI * (wb_x_legendre[k] + 1) / 2.0;
643
- res2 += wb_w_legendre[k] * wb_P(-exp_term, eps, a, b, x, y);
644
- }
645
- res1 *= std::exp(-eps);
646
- // (b-a)/2.0 * np.sum(w*func(y, *args), axis=-1)
647
- res2 *= M_PI / 2.0;
648
- res2 *= std::pow(eps, 1 - b);
649
-
650
- if (!log_wb) {
651
- // Remember the factored out exp_term from wb_Kmod and wb_P
652
- return std::exp(exp_term) / M_PI * (res1 + res2);
653
- } else {
654
- // logarithm of Wright's function
655
- return exp_term + std::log((res1 + res2) / M_PI);
656
- }
657
- }
658
- } // namespace detail
659
-
660
- template<bool log_wb>
661
- XSF_HOST_DEVICE inline double wright_bessel_t(double a, double b, double x) {
662
- /* Compute Wright's generalized Bessel function for scalar arguments.
663
- *
664
- * According to [1], it is an entire function defined as
665
- *
666
- * .. math:: \Phi(a, b; x) = \sum_{k=0}^\infty \frac{x^k}{k! \Gamma(a k + b)}
667
- *
668
- * So far, only non-negative values of rho=a, beta=b and z=x are implemented.
669
- * There are 5 different approaches depending on the ranges of the arguments:
670
- *
671
- * 1. Taylor series expansion in x=0 [1], for x <= 1.
672
- * Involves gamma funtions in each term.
673
- * 2. Taylor series expansion in x=0 [2], for large a.
674
- * 3. Taylor series in a=0, for tiny a and not too large x.
675
- * 4. Asymptotic expansion for large x [3, 4].
676
- * Suitable for large x while still small a and b.
677
- * 5. Integral representation [5], in principle for all arguments.
678
- *
679
- * References
680
- * ----------
681
- * [1] https://dlmf.nist.gov/10.46.E1
682
- * [2] P. K. Dunn, G. K. Smyth (2005), Series evaluation of Tweedie exponential
683
- * dispersion model densities. Statistics and Computing 15 (2005): 267-280.
684
- * [3] E. M. Wright (1935), The asymptotic expansion of the generalized Bessel
685
- * function. Proc. London Math. Soc. (2) 38, pp. 257-270.
686
- * https://doi.org/10.1112/plms/s2-38.1.257
687
- * [4] R. B. Paris (2017), The asymptotics of the generalised Bessel function,
688
- * Mathematica Aeterna, Vol. 7, 2017, no. 4, 381 - 406,
689
- * https://arxiv.org/abs/1711.03006
690
- * [5] Y. F. Luchko (2008), Algorithms for Evaluation of the Wright Function for
691
- * the Real Arguments' Values, Fractional Calculus and Applied Analysis 11(1)
692
- * http://sci-gems.math.bas.bg/jspui/bitstream/10525/1298/1/fcaa-vol11-num1-2008-57p-75p.pdf
693
- */
694
- if (std::isnan(a) || std::isnan(b) || std::isnan(x)) {
695
- return std::numeric_limits<double>::quiet_NaN();
696
- }
697
- if (a < 0 || b < 0 || x < 0) {
698
- set_error("wright_bessel", SF_ERROR_DOMAIN, NULL);
699
- return std::numeric_limits<double>::quiet_NaN();
700
- }
701
- if (std::isinf(x)) {
702
- if (std::isinf(a) || std::isinf(b)) {
703
- return std::numeric_limits<double>::quiet_NaN();
704
- }
705
- return std::numeric_limits<double>::infinity();
706
- }
707
- if (std::isinf(a) || std::isinf(b)) {
708
- return std::numeric_limits<double>::quiet_NaN(); // or 0
709
- }
710
- if (a >= detail::rgamma_zero || b >= detail::rgamma_zero) {
711
- set_error("wright_bessel", SF_ERROR_OVERFLOW, NULL);
712
- return std::numeric_limits<double>::quiet_NaN();
713
- }
714
- if (x == 0) {
715
- // return rgamma(b)
716
- if (!log_wb) {
717
- return cephes::rgamma(b);
718
- } else {
719
- // logarithm of Wright's function
720
- return -cephes::lgam(b);
721
- }
722
- }
723
- if (a == 0) {
724
- // return exp(x) * rgamma(b)
725
- if (!log_wb) {
726
- return detail::exp_rgamma(x, b);
727
- } else {
728
- // logarithm of Wright's function
729
- return x - cephes::lgam(b);
730
- }
731
- }
732
-
733
- constexpr double exp_inf = 709.78271289338403;
734
- int order;
735
- if ((a <= 1e-3 && b <= 50 && x <= 9) || (a <= 1e-4 && b <= 70 && x <= 100) ||
736
- (a <= 1e-5 && b <= 170 && (x < exp_inf || (log_wb && x <= 1e3)))) {
737
- /* Taylor Series expansion in a=0 to order=order => precision <= 1e-11
738
- * If beta is also small => precision <= 1e-11.
739
- * max order = 5 */
740
- if (a <= 1e-5) {
741
- if (x <= 1) {
742
- order = 2;
743
- } else if (x <= 10) {
744
- order = 3;
745
- } else if (x <= 100) {
746
- order = 4;
747
- } else { // x < exp_inf
748
- order = 5;
749
- }
750
- } else if (a <= 1e-4) {
751
- if (x <= 1e-2) {
752
- order = 2;
753
- } else if (x <= 1) {
754
- order = 3;
755
- } else if (x <= 10) {
756
- order = 4;
757
- } else { // x <= 100
758
- order = 5;
759
- }
760
- } else { // a <= 1e-3
761
- if (x <= 1e-5) {
762
- order = 2;
763
- } else if (x <= 1e-1) {
764
- order = 3;
765
- } else if (x <= 1) {
766
- order = 4;
767
- } else { // x <= 9
768
- order = 5;
769
- }
770
- }
771
-
772
- return detail::wb_small_a<log_wb>(a, b, x, order);
773
- }
774
-
775
- if (x <= 1) {
776
- // 18 term Taylor Series => error mostly smaller 5e-14
777
- double res = detail::wb_series(a, b, x, 0, 18);
778
- if (log_wb) res = std::log(res);
779
- return res;
780
- }
781
- if (x <= 2) {
782
- // 20 term Taylor Series => error mostly smaller 1e-12 to 1e-13
783
- double res = detail::wb_series(a, b, x, 0, 20);
784
- if (log_wb) res = std::log(res);
785
- return res;
786
- }
787
- if (a >= 5) {
788
- /* Taylor series around the approximate maximum term.
789
- * Set number of terms=order. */
790
- if (a >= 10) {
791
- if (x <= 1e11) {
792
- order = 6;
793
- } else {
794
- order = static_cast<int>(std::fmin(std::log10(x) - 5 + b / 10, 30));
795
- }
796
- } else {
797
- if (x <= 1e4) {
798
- order = 6;
799
- } else if (x <= 1e8) {
800
- order = static_cast<int>(2 * std::log10(x));
801
- } else if (x <= 1e10) {
802
- order = static_cast<int>(4 * std::log10(x) - 16);
803
- } else {
804
- order = static_cast<int>(std::fmin(6 * std::log10(x) - 36, 100));
805
- }
806
- }
807
- return detail::wb_large_a<log_wb>(a, b, x, order);
808
- }
809
- if (std::pow(a * x, 1 / (1. + a)) >= 14 + b * b / (2 * (1 + a))) {
810
- /* Asymptotic expansion in Z = (a*x)^(1/(1+a)) up to 8th term 1/Z^8.
811
- * For 1/Z^k, the highest term in b is b^(2*k) * a0 / (2^k k! (1+a)^k).
812
- * As a0 is a common factor to all orders, this explains a bit the
813
- * domain of good convergence set above.
814
- * => precision ~ 1e-11 but can go down to ~1e-8 or 1e-7
815
- * Note: We ensured a <= 5 as this is a bad approximation for large a. */
816
- return detail::wb_asymptotic<log_wb>(a, b, x);
817
- }
818
- if (0.5 <= a && a <= 1.8 && 100 <= b && 1e5 <= x) {
819
- // This is a very hard domain. This condition is placed after wb_asymptotic.
820
- // TODO: Explore ways to cover this domain.
821
- return std::numeric_limits<double>::quiet_NaN();
822
- }
823
- return detail::wright_bessel_integral<log_wb>(a, b, x);
824
- }
825
-
826
-
827
- XSF_HOST_DEVICE inline double wright_bessel(double a, double b, double x) {
828
- return wright_bessel_t<false>(a, b, x);
829
- }
830
-
831
- XSF_HOST_DEVICE inline float wright_bessel(float a, float b, float x) {
832
- return wright_bessel(static_cast<double>(a), static_cast<double>(b), static_cast<double>(x));
833
- }
834
-
835
- XSF_HOST_DEVICE inline double log_wright_bessel(double a, double b, double x) {
836
- return wright_bessel_t<true>(a, b, x);
837
- }
838
-
839
- XSF_HOST_DEVICE inline float log_wright_bessel(float a, float b, float x) {
840
- return log_wright_bessel(static_cast<double>(a), static_cast<double>(b), static_cast<double>(x));
841
- }
842
-
843
- } // namespace xsf