scipy 1.16.2__cp311-cp311-win_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.
- scipy/__config__.py +161 -0
- scipy/__init__.py +150 -0
- scipy/_cyutility.cp311-win_arm64.lib +0 -0
- scipy/_cyutility.cp311-win_arm64.pyd +0 -0
- scipy/_distributor_init.py +18 -0
- scipy/_lib/__init__.py +14 -0
- scipy/_lib/_array_api.py +931 -0
- scipy/_lib/_array_api_compat_vendor.py +9 -0
- scipy/_lib/_array_api_no_0d.py +103 -0
- scipy/_lib/_bunch.py +229 -0
- scipy/_lib/_ccallback.py +251 -0
- scipy/_lib/_ccallback_c.cp311-win_arm64.lib +0 -0
- scipy/_lib/_ccallback_c.cp311-win_arm64.pyd +0 -0
- scipy/_lib/_disjoint_set.py +254 -0
- scipy/_lib/_docscrape.py +761 -0
- scipy/_lib/_elementwise_iterative_method.py +346 -0
- scipy/_lib/_fpumode.cp311-win_arm64.lib +0 -0
- scipy/_lib/_fpumode.cp311-win_arm64.pyd +0 -0
- scipy/_lib/_gcutils.py +105 -0
- scipy/_lib/_pep440.py +487 -0
- scipy/_lib/_sparse.py +41 -0
- scipy/_lib/_test_ccallback.cp311-win_arm64.lib +0 -0
- scipy/_lib/_test_ccallback.cp311-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_call.cp311-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_call.cp311-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_def.cp311-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_def.cp311-win_arm64.pyd +0 -0
- scipy/_lib/_testutils.py +373 -0
- scipy/_lib/_threadsafety.py +58 -0
- scipy/_lib/_tmpdirs.py +86 -0
- scipy/_lib/_uarray/LICENSE +29 -0
- scipy/_lib/_uarray/__init__.py +116 -0
- scipy/_lib/_uarray/_backend.py +707 -0
- scipy/_lib/_uarray/_uarray.cp311-win_arm64.lib +0 -0
- scipy/_lib/_uarray/_uarray.cp311-win_arm64.pyd +0 -0
- scipy/_lib/_util.py +1283 -0
- scipy/_lib/array_api_compat/__init__.py +22 -0
- scipy/_lib/array_api_compat/_internal.py +59 -0
- scipy/_lib/array_api_compat/common/__init__.py +1 -0
- scipy/_lib/array_api_compat/common/_aliases.py +727 -0
- scipy/_lib/array_api_compat/common/_fft.py +213 -0
- scipy/_lib/array_api_compat/common/_helpers.py +1058 -0
- scipy/_lib/array_api_compat/common/_linalg.py +232 -0
- scipy/_lib/array_api_compat/common/_typing.py +192 -0
- scipy/_lib/array_api_compat/cupy/__init__.py +13 -0
- scipy/_lib/array_api_compat/cupy/_aliases.py +156 -0
- scipy/_lib/array_api_compat/cupy/_info.py +336 -0
- scipy/_lib/array_api_compat/cupy/_typing.py +31 -0
- scipy/_lib/array_api_compat/cupy/fft.py +36 -0
- scipy/_lib/array_api_compat/cupy/linalg.py +49 -0
- scipy/_lib/array_api_compat/dask/__init__.py +0 -0
- scipy/_lib/array_api_compat/dask/array/__init__.py +12 -0
- scipy/_lib/array_api_compat/dask/array/_aliases.py +376 -0
- scipy/_lib/array_api_compat/dask/array/_info.py +416 -0
- scipy/_lib/array_api_compat/dask/array/fft.py +21 -0
- scipy/_lib/array_api_compat/dask/array/linalg.py +72 -0
- scipy/_lib/array_api_compat/numpy/__init__.py +28 -0
- scipy/_lib/array_api_compat/numpy/_aliases.py +190 -0
- scipy/_lib/array_api_compat/numpy/_info.py +366 -0
- scipy/_lib/array_api_compat/numpy/_typing.py +30 -0
- scipy/_lib/array_api_compat/numpy/fft.py +35 -0
- scipy/_lib/array_api_compat/numpy/linalg.py +143 -0
- scipy/_lib/array_api_compat/torch/__init__.py +22 -0
- scipy/_lib/array_api_compat/torch/_aliases.py +855 -0
- scipy/_lib/array_api_compat/torch/_info.py +369 -0
- scipy/_lib/array_api_compat/torch/_typing.py +3 -0
- scipy/_lib/array_api_compat/torch/fft.py +85 -0
- scipy/_lib/array_api_compat/torch/linalg.py +121 -0
- scipy/_lib/array_api_extra/__init__.py +38 -0
- scipy/_lib/array_api_extra/_delegation.py +171 -0
- scipy/_lib/array_api_extra/_lib/__init__.py +1 -0
- scipy/_lib/array_api_extra/_lib/_at.py +463 -0
- scipy/_lib/array_api_extra/_lib/_backends.py +46 -0
- scipy/_lib/array_api_extra/_lib/_funcs.py +937 -0
- scipy/_lib/array_api_extra/_lib/_lazy.py +357 -0
- scipy/_lib/array_api_extra/_lib/_testing.py +278 -0
- scipy/_lib/array_api_extra/_lib/_utils/__init__.py +1 -0
- scipy/_lib/array_api_extra/_lib/_utils/_compat.py +74 -0
- scipy/_lib/array_api_extra/_lib/_utils/_compat.pyi +45 -0
- scipy/_lib/array_api_extra/_lib/_utils/_helpers.py +559 -0
- scipy/_lib/array_api_extra/_lib/_utils/_typing.py +10 -0
- scipy/_lib/array_api_extra/_lib/_utils/_typing.pyi +105 -0
- scipy/_lib/array_api_extra/testing.py +359 -0
- scipy/_lib/cobyqa/__init__.py +20 -0
- scipy/_lib/cobyqa/framework.py +1240 -0
- scipy/_lib/cobyqa/main.py +1506 -0
- scipy/_lib/cobyqa/models.py +1529 -0
- scipy/_lib/cobyqa/problem.py +1296 -0
- scipy/_lib/cobyqa/settings.py +132 -0
- scipy/_lib/cobyqa/subsolvers/__init__.py +14 -0
- scipy/_lib/cobyqa/subsolvers/geometry.py +387 -0
- scipy/_lib/cobyqa/subsolvers/optim.py +1203 -0
- scipy/_lib/cobyqa/utils/__init__.py +18 -0
- scipy/_lib/cobyqa/utils/exceptions.py +22 -0
- scipy/_lib/cobyqa/utils/math.py +77 -0
- scipy/_lib/cobyqa/utils/versions.py +67 -0
- scipy/_lib/decorator.py +399 -0
- scipy/_lib/deprecation.py +274 -0
- scipy/_lib/doccer.py +366 -0
- scipy/_lib/messagestream.cp311-win_arm64.lib +0 -0
- scipy/_lib/messagestream.cp311-win_arm64.pyd +0 -0
- scipy/_lib/pyprima/__init__.py +212 -0
- scipy/_lib/pyprima/cobyla/__init__.py +0 -0
- scipy/_lib/pyprima/cobyla/cobyla.py +559 -0
- scipy/_lib/pyprima/cobyla/cobylb.py +714 -0
- scipy/_lib/pyprima/cobyla/geometry.py +226 -0
- scipy/_lib/pyprima/cobyla/initialize.py +215 -0
- scipy/_lib/pyprima/cobyla/trustregion.py +492 -0
- scipy/_lib/pyprima/cobyla/update.py +289 -0
- scipy/_lib/pyprima/common/__init__.py +0 -0
- scipy/_lib/pyprima/common/_bounds.py +34 -0
- scipy/_lib/pyprima/common/_linear_constraints.py +46 -0
- scipy/_lib/pyprima/common/_nonlinear_constraints.py +54 -0
- scipy/_lib/pyprima/common/_project.py +173 -0
- scipy/_lib/pyprima/common/checkbreak.py +93 -0
- scipy/_lib/pyprima/common/consts.py +47 -0
- scipy/_lib/pyprima/common/evaluate.py +99 -0
- scipy/_lib/pyprima/common/history.py +38 -0
- scipy/_lib/pyprima/common/infos.py +30 -0
- scipy/_lib/pyprima/common/linalg.py +435 -0
- scipy/_lib/pyprima/common/message.py +290 -0
- scipy/_lib/pyprima/common/powalg.py +131 -0
- scipy/_lib/pyprima/common/preproc.py +277 -0
- scipy/_lib/pyprima/common/present.py +5 -0
- scipy/_lib/pyprima/common/ratio.py +54 -0
- scipy/_lib/pyprima/common/redrho.py +47 -0
- scipy/_lib/pyprima/common/selectx.py +296 -0
- scipy/_lib/tests/__init__.py +0 -0
- scipy/_lib/tests/test__gcutils.py +110 -0
- scipy/_lib/tests/test__pep440.py +67 -0
- scipy/_lib/tests/test__testutils.py +32 -0
- scipy/_lib/tests/test__threadsafety.py +51 -0
- scipy/_lib/tests/test__util.py +641 -0
- scipy/_lib/tests/test_array_api.py +322 -0
- scipy/_lib/tests/test_bunch.py +169 -0
- scipy/_lib/tests/test_ccallback.py +196 -0
- scipy/_lib/tests/test_config.py +45 -0
- scipy/_lib/tests/test_deprecation.py +10 -0
- scipy/_lib/tests/test_doccer.py +143 -0
- scipy/_lib/tests/test_import_cycles.py +18 -0
- scipy/_lib/tests/test_public_api.py +482 -0
- scipy/_lib/tests/test_scipy_version.py +28 -0
- scipy/_lib/tests/test_tmpdirs.py +48 -0
- scipy/_lib/tests/test_warnings.py +137 -0
- scipy/_lib/uarray.py +31 -0
- scipy/cluster/__init__.py +31 -0
- scipy/cluster/_hierarchy.cp311-win_arm64.lib +0 -0
- scipy/cluster/_hierarchy.cp311-win_arm64.pyd +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp311-win_arm64.lib +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp311-win_arm64.pyd +0 -0
- scipy/cluster/_vq.cp311-win_arm64.lib +0 -0
- scipy/cluster/_vq.cp311-win_arm64.pyd +0 -0
- scipy/cluster/hierarchy.py +4348 -0
- scipy/cluster/tests/__init__.py +0 -0
- scipy/cluster/tests/hierarchy_test_data.py +145 -0
- scipy/cluster/tests/test_disjoint_set.py +202 -0
- scipy/cluster/tests/test_hierarchy.py +1238 -0
- scipy/cluster/tests/test_vq.py +434 -0
- scipy/cluster/vq.py +832 -0
- scipy/conftest.py +683 -0
- scipy/constants/__init__.py +358 -0
- scipy/constants/_codata.py +2266 -0
- scipy/constants/_constants.py +369 -0
- scipy/constants/codata.py +21 -0
- scipy/constants/constants.py +53 -0
- scipy/constants/tests/__init__.py +0 -0
- scipy/constants/tests/test_codata.py +78 -0
- scipy/constants/tests/test_constants.py +83 -0
- scipy/datasets/__init__.py +90 -0
- scipy/datasets/_download_all.py +71 -0
- scipy/datasets/_fetchers.py +225 -0
- scipy/datasets/_registry.py +26 -0
- scipy/datasets/_utils.py +81 -0
- scipy/datasets/tests/__init__.py +0 -0
- scipy/datasets/tests/test_data.py +128 -0
- scipy/differentiate/__init__.py +27 -0
- scipy/differentiate/_differentiate.py +1129 -0
- scipy/differentiate/tests/__init__.py +0 -0
- scipy/differentiate/tests/test_differentiate.py +694 -0
- scipy/fft/__init__.py +114 -0
- scipy/fft/_backend.py +196 -0
- scipy/fft/_basic.py +1650 -0
- scipy/fft/_basic_backend.py +197 -0
- scipy/fft/_debug_backends.py +22 -0
- scipy/fft/_fftlog.py +223 -0
- scipy/fft/_fftlog_backend.py +200 -0
- scipy/fft/_helper.py +348 -0
- scipy/fft/_pocketfft/LICENSE.md +25 -0
- scipy/fft/_pocketfft/__init__.py +9 -0
- scipy/fft/_pocketfft/basic.py +251 -0
- scipy/fft/_pocketfft/helper.py +249 -0
- scipy/fft/_pocketfft/pypocketfft.cp311-win_arm64.lib +0 -0
- scipy/fft/_pocketfft/pypocketfft.cp311-win_arm64.pyd +0 -0
- scipy/fft/_pocketfft/realtransforms.py +109 -0
- scipy/fft/_pocketfft/tests/__init__.py +0 -0
- scipy/fft/_pocketfft/tests/test_basic.py +1011 -0
- scipy/fft/_pocketfft/tests/test_real_transforms.py +505 -0
- scipy/fft/_realtransforms.py +706 -0
- scipy/fft/_realtransforms_backend.py +63 -0
- scipy/fft/tests/__init__.py +0 -0
- scipy/fft/tests/mock_backend.py +96 -0
- scipy/fft/tests/test_backend.py +98 -0
- scipy/fft/tests/test_basic.py +504 -0
- scipy/fft/tests/test_fftlog.py +215 -0
- scipy/fft/tests/test_helper.py +558 -0
- scipy/fft/tests/test_multithreading.py +84 -0
- scipy/fft/tests/test_real_transforms.py +247 -0
- scipy/fftpack/__init__.py +103 -0
- scipy/fftpack/_basic.py +428 -0
- scipy/fftpack/_helper.py +115 -0
- scipy/fftpack/_pseudo_diffs.py +554 -0
- scipy/fftpack/_realtransforms.py +598 -0
- scipy/fftpack/basic.py +20 -0
- scipy/fftpack/convolve.cp311-win_arm64.lib +0 -0
- scipy/fftpack/convolve.cp311-win_arm64.pyd +0 -0
- scipy/fftpack/helper.py +19 -0
- scipy/fftpack/pseudo_diffs.py +22 -0
- scipy/fftpack/realtransforms.py +19 -0
- scipy/fftpack/tests/__init__.py +0 -0
- scipy/fftpack/tests/fftw_double_ref.npz +0 -0
- scipy/fftpack/tests/fftw_longdouble_ref.npz +0 -0
- scipy/fftpack/tests/fftw_single_ref.npz +0 -0
- scipy/fftpack/tests/test.npz +0 -0
- scipy/fftpack/tests/test_basic.py +877 -0
- scipy/fftpack/tests/test_helper.py +54 -0
- scipy/fftpack/tests/test_import.py +33 -0
- scipy/fftpack/tests/test_pseudo_diffs.py +388 -0
- scipy/fftpack/tests/test_real_transforms.py +836 -0
- scipy/integrate/__init__.py +122 -0
- scipy/integrate/_bvp.py +1160 -0
- scipy/integrate/_cubature.py +729 -0
- scipy/integrate/_dop.cp311-win_arm64.lib +0 -0
- scipy/integrate/_dop.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_ivp/__init__.py +8 -0
- scipy/integrate/_ivp/base.py +290 -0
- scipy/integrate/_ivp/bdf.py +478 -0
- scipy/integrate/_ivp/common.py +451 -0
- scipy/integrate/_ivp/dop853_coefficients.py +193 -0
- scipy/integrate/_ivp/ivp.py +755 -0
- scipy/integrate/_ivp/lsoda.py +224 -0
- scipy/integrate/_ivp/radau.py +572 -0
- scipy/integrate/_ivp/rk.py +601 -0
- scipy/integrate/_ivp/tests/__init__.py +0 -0
- scipy/integrate/_ivp/tests/test_ivp.py +1287 -0
- scipy/integrate/_ivp/tests/test_rk.py +37 -0
- scipy/integrate/_lebedev.py +5450 -0
- scipy/integrate/_lsoda.cp311-win_arm64.lib +0 -0
- scipy/integrate/_lsoda.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_ode.py +1395 -0
- scipy/integrate/_odepack.cp311-win_arm64.lib +0 -0
- scipy/integrate/_odepack.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_odepack_py.py +273 -0
- scipy/integrate/_quad_vec.py +674 -0
- scipy/integrate/_quadpack.cp311-win_arm64.lib +0 -0
- scipy/integrate/_quadpack.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_quadpack_py.py +1283 -0
- scipy/integrate/_quadrature.py +1336 -0
- scipy/integrate/_rules/__init__.py +12 -0
- scipy/integrate/_rules/_base.py +518 -0
- scipy/integrate/_rules/_gauss_kronrod.py +202 -0
- scipy/integrate/_rules/_gauss_legendre.py +62 -0
- scipy/integrate/_rules/_genz_malik.py +210 -0
- scipy/integrate/_tanhsinh.py +1385 -0
- scipy/integrate/_test_multivariate.cp311-win_arm64.lib +0 -0
- scipy/integrate/_test_multivariate.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_test_odeint_banded.cp311-win_arm64.lib +0 -0
- scipy/integrate/_test_odeint_banded.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_vode.cp311-win_arm64.lib +0 -0
- scipy/integrate/_vode.cp311-win_arm64.pyd +0 -0
- scipy/integrate/dop.py +15 -0
- scipy/integrate/lsoda.py +15 -0
- scipy/integrate/odepack.py +17 -0
- scipy/integrate/quadpack.py +23 -0
- scipy/integrate/tests/__init__.py +0 -0
- scipy/integrate/tests/test__quad_vec.py +211 -0
- scipy/integrate/tests/test_banded_ode_solvers.py +305 -0
- scipy/integrate/tests/test_bvp.py +714 -0
- scipy/integrate/tests/test_cubature.py +1375 -0
- scipy/integrate/tests/test_integrate.py +840 -0
- scipy/integrate/tests/test_odeint_jac.py +74 -0
- scipy/integrate/tests/test_quadpack.py +680 -0
- scipy/integrate/tests/test_quadrature.py +730 -0
- scipy/integrate/tests/test_tanhsinh.py +1171 -0
- scipy/integrate/vode.py +15 -0
- scipy/interpolate/__init__.py +228 -0
- scipy/interpolate/_bary_rational.py +715 -0
- scipy/interpolate/_bsplines.py +2469 -0
- scipy/interpolate/_cubic.py +973 -0
- scipy/interpolate/_dfitpack.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_dfitpack.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_dierckx.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_dierckx.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_fitpack.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack2.py +2397 -0
- scipy/interpolate/_fitpack_impl.py +811 -0
- scipy/interpolate/_fitpack_py.py +898 -0
- scipy/interpolate/_fitpack_repro.py +996 -0
- scipy/interpolate/_interpnd.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_interpnd.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_interpolate.py +2266 -0
- scipy/interpolate/_ndbspline.py +415 -0
- scipy/interpolate/_ndgriddata.py +329 -0
- scipy/interpolate/_pade.py +67 -0
- scipy/interpolate/_polyint.py +1025 -0
- scipy/interpolate/_ppoly.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_ppoly.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_rbf.py +290 -0
- scipy/interpolate/_rbfinterp.py +550 -0
- scipy/interpolate/_rbfinterp_pythran.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_rbfinterp_pythran.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_rgi.py +764 -0
- scipy/interpolate/_rgi_cython.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_rgi_cython.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/dfitpack.py +24 -0
- scipy/interpolate/fitpack.py +31 -0
- scipy/interpolate/fitpack2.py +29 -0
- scipy/interpolate/interpnd.py +24 -0
- scipy/interpolate/interpolate.py +30 -0
- scipy/interpolate/ndgriddata.py +23 -0
- scipy/interpolate/polyint.py +24 -0
- scipy/interpolate/rbf.py +18 -0
- scipy/interpolate/tests/__init__.py +0 -0
- scipy/interpolate/tests/data/bug-1310.npz +0 -0
- scipy/interpolate/tests/data/estimate_gradients_hang.npy +0 -0
- scipy/interpolate/tests/data/gcvspl.npz +0 -0
- scipy/interpolate/tests/test_bary_rational.py +368 -0
- scipy/interpolate/tests/test_bsplines.py +3754 -0
- scipy/interpolate/tests/test_fitpack.py +519 -0
- scipy/interpolate/tests/test_fitpack2.py +1431 -0
- scipy/interpolate/tests/test_gil.py +64 -0
- scipy/interpolate/tests/test_interpnd.py +452 -0
- scipy/interpolate/tests/test_interpolate.py +2630 -0
- scipy/interpolate/tests/test_ndgriddata.py +308 -0
- scipy/interpolate/tests/test_pade.py +107 -0
- scipy/interpolate/tests/test_polyint.py +972 -0
- scipy/interpolate/tests/test_rbf.py +246 -0
- scipy/interpolate/tests/test_rbfinterp.py +534 -0
- scipy/interpolate/tests/test_rgi.py +1151 -0
- scipy/io/__init__.py +116 -0
- scipy/io/_fast_matrix_market/__init__.py +600 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp311-win_arm64.lib +0 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp311-win_arm64.pyd +0 -0
- scipy/io/_fortran.py +354 -0
- scipy/io/_harwell_boeing/__init__.py +7 -0
- scipy/io/_harwell_boeing/_fortran_format_parser.py +316 -0
- scipy/io/_harwell_boeing/hb.py +571 -0
- scipy/io/_harwell_boeing/tests/__init__.py +0 -0
- scipy/io/_harwell_boeing/tests/test_fortran_format.py +74 -0
- scipy/io/_harwell_boeing/tests/test_hb.py +70 -0
- scipy/io/_idl.py +917 -0
- scipy/io/_mmio.py +968 -0
- scipy/io/_netcdf.py +1104 -0
- scipy/io/_test_fortran.cp311-win_arm64.lib +0 -0
- scipy/io/_test_fortran.cp311-win_arm64.pyd +0 -0
- scipy/io/arff/__init__.py +28 -0
- scipy/io/arff/_arffread.py +873 -0
- scipy/io/arff/arffread.py +19 -0
- scipy/io/arff/tests/__init__.py +0 -0
- scipy/io/arff/tests/data/iris.arff +225 -0
- scipy/io/arff/tests/data/missing.arff +8 -0
- scipy/io/arff/tests/data/nodata.arff +11 -0
- scipy/io/arff/tests/data/quoted_nominal.arff +13 -0
- scipy/io/arff/tests/data/quoted_nominal_spaces.arff +13 -0
- scipy/io/arff/tests/data/test1.arff +10 -0
- scipy/io/arff/tests/data/test10.arff +8 -0
- scipy/io/arff/tests/data/test11.arff +11 -0
- scipy/io/arff/tests/data/test2.arff +15 -0
- scipy/io/arff/tests/data/test3.arff +6 -0
- scipy/io/arff/tests/data/test4.arff +11 -0
- scipy/io/arff/tests/data/test5.arff +26 -0
- scipy/io/arff/tests/data/test6.arff +12 -0
- scipy/io/arff/tests/data/test7.arff +15 -0
- scipy/io/arff/tests/data/test8.arff +12 -0
- scipy/io/arff/tests/data/test9.arff +14 -0
- scipy/io/arff/tests/test_arffread.py +421 -0
- scipy/io/harwell_boeing.py +17 -0
- scipy/io/idl.py +17 -0
- scipy/io/matlab/__init__.py +66 -0
- scipy/io/matlab/_byteordercodes.py +75 -0
- scipy/io/matlab/_mio.py +375 -0
- scipy/io/matlab/_mio4.py +632 -0
- scipy/io/matlab/_mio5.py +901 -0
- scipy/io/matlab/_mio5_params.py +281 -0
- scipy/io/matlab/_mio5_utils.cp311-win_arm64.lib +0 -0
- scipy/io/matlab/_mio5_utils.cp311-win_arm64.pyd +0 -0
- scipy/io/matlab/_mio_utils.cp311-win_arm64.lib +0 -0
- scipy/io/matlab/_mio_utils.cp311-win_arm64.pyd +0 -0
- scipy/io/matlab/_miobase.py +435 -0
- scipy/io/matlab/_streams.cp311-win_arm64.lib +0 -0
- scipy/io/matlab/_streams.cp311-win_arm64.pyd +0 -0
- scipy/io/matlab/byteordercodes.py +17 -0
- scipy/io/matlab/mio.py +16 -0
- scipy/io/matlab/mio4.py +17 -0
- scipy/io/matlab/mio5.py +19 -0
- scipy/io/matlab/mio5_params.py +18 -0
- scipy/io/matlab/mio5_utils.py +17 -0
- scipy/io/matlab/mio_utils.py +17 -0
- scipy/io/matlab/miobase.py +16 -0
- scipy/io/matlab/streams.py +16 -0
- scipy/io/matlab/tests/__init__.py +0 -0
- scipy/io/matlab/tests/data/bad_miuint32.mat +0 -0
- scipy/io/matlab/tests/data/bad_miutf8_array_name.mat +0 -0
- scipy/io/matlab/tests/data/big_endian.mat +0 -0
- scipy/io/matlab/tests/data/broken_utf8.mat +0 -0
- scipy/io/matlab/tests/data/corrupted_zlib_checksum.mat +0 -0
- scipy/io/matlab/tests/data/corrupted_zlib_data.mat +0 -0
- scipy/io/matlab/tests/data/debigged_m4.mat +0 -0
- scipy/io/matlab/tests/data/japanese_utf8.txt +5 -0
- scipy/io/matlab/tests/data/little_endian.mat +0 -0
- scipy/io/matlab/tests/data/logical_sparse.mat +0 -0
- scipy/io/matlab/tests/data/malformed1.mat +0 -0
- scipy/io/matlab/tests/data/miuint32_for_miint32.mat +0 -0
- scipy/io/matlab/tests/data/miutf8_array_name.mat +0 -0
- scipy/io/matlab/tests/data/nasty_duplicate_fieldnames.mat +0 -0
- scipy/io/matlab/tests/data/one_by_zero_char.mat +0 -0
- scipy/io/matlab/tests/data/parabola.mat +0 -0
- scipy/io/matlab/tests/data/single_empty_string.mat +0 -0
- scipy/io/matlab/tests/data/some_functions.mat +0 -0
- scipy/io/matlab/tests/data/sqr.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test_empty_struct.mat +0 -0
- scipy/io/matlab/tests/data/test_mat4_le_floats.mat +0 -0
- scipy/io/matlab/tests/data/test_skip_variable.mat +0 -0
- scipy/io/matlab/tests/data/testbool_8_WIN64.mat +0 -0
- scipy/io/matlab/tests/data/testcell_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcell_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcell_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_5.3_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testfunc_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testhdf5_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testminus_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testminus_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testobject_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testscalarcell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsimplecell.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsefloat_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststring_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststring_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testunicode_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testunicode_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testvec_4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/test_byteordercodes.py +29 -0
- scipy/io/matlab/tests/test_mio.py +1399 -0
- scipy/io/matlab/tests/test_mio5_utils.py +179 -0
- scipy/io/matlab/tests/test_mio_funcs.py +51 -0
- scipy/io/matlab/tests/test_mio_utils.py +45 -0
- scipy/io/matlab/tests/test_miobase.py +32 -0
- scipy/io/matlab/tests/test_pathological.py +33 -0
- scipy/io/matlab/tests/test_streams.py +241 -0
- scipy/io/mmio.py +17 -0
- scipy/io/netcdf.py +17 -0
- scipy/io/tests/__init__.py +0 -0
- scipy/io/tests/data/Transparent Busy.ani +0 -0
- scipy/io/tests/data/array_float32_1d.sav +0 -0
- scipy/io/tests/data/array_float32_2d.sav +0 -0
- scipy/io/tests/data/array_float32_3d.sav +0 -0
- scipy/io/tests/data/array_float32_4d.sav +0 -0
- scipy/io/tests/data/array_float32_5d.sav +0 -0
- scipy/io/tests/data/array_float32_6d.sav +0 -0
- scipy/io/tests/data/array_float32_7d.sav +0 -0
- scipy/io/tests/data/array_float32_8d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_1d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_2d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_3d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_4d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_5d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_6d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_7d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_8d.sav +0 -0
- scipy/io/tests/data/example_1.nc +0 -0
- scipy/io/tests/data/example_2.nc +0 -0
- scipy/io/tests/data/example_3_maskedvals.nc +0 -0
- scipy/io/tests/data/fortran-3x3d-2i.dat +0 -0
- scipy/io/tests/data/fortran-mixed.dat +0 -0
- scipy/io/tests/data/fortran-sf8-11x1x10.dat +0 -0
- scipy/io/tests/data/fortran-sf8-15x10x22.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x1.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x5.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x7.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x3x5.dat +0 -0
- scipy/io/tests/data/fortran-si4-11x1x10.dat +0 -0
- scipy/io/tests/data/fortran-si4-15x10x22.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x1.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x5.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x7.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x3x5.dat +0 -0
- scipy/io/tests/data/invalid_pointer.sav +0 -0
- scipy/io/tests/data/null_pointer.sav +0 -0
- scipy/io/tests/data/scalar_byte.sav +0 -0
- scipy/io/tests/data/scalar_byte_descr.sav +0 -0
- scipy/io/tests/data/scalar_complex32.sav +0 -0
- scipy/io/tests/data/scalar_complex64.sav +0 -0
- scipy/io/tests/data/scalar_float32.sav +0 -0
- scipy/io/tests/data/scalar_float64.sav +0 -0
- scipy/io/tests/data/scalar_heap_pointer.sav +0 -0
- scipy/io/tests/data/scalar_int16.sav +0 -0
- scipy/io/tests/data/scalar_int32.sav +0 -0
- scipy/io/tests/data/scalar_int64.sav +0 -0
- scipy/io/tests/data/scalar_string.sav +0 -0
- scipy/io/tests/data/scalar_uint16.sav +0 -0
- scipy/io/tests/data/scalar_uint32.sav +0 -0
- scipy/io/tests/data/scalar_uint64.sav +0 -0
- scipy/io/tests/data/struct_arrays.sav +0 -0
- scipy/io/tests/data/struct_arrays_byte_idl80.sav +0 -0
- scipy/io/tests/data/struct_arrays_replicated.sav +0 -0
- scipy/io/tests/data/struct_arrays_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_inherit.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays_replicated.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_pointers.sav +0 -0
- scipy/io/tests/data/struct_pointers_replicated.sav +0 -0
- scipy/io/tests/data/struct_pointers_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_scalars.sav +0 -0
- scipy/io/tests/data/struct_scalars_replicated.sav +0 -0
- scipy/io/tests/data/struct_scalars_replicated_3d.sav +0 -0
- scipy/io/tests/data/test-1234Hz-le-1ch-10S-20bit-extra.wav +0 -0
- scipy/io/tests/data/test-44100Hz-2ch-32bit-float-be.wav +0 -0
- scipy/io/tests/data/test-44100Hz-2ch-32bit-float-le.wav +0 -0
- scipy/io/tests/data/test-44100Hz-be-1ch-4bytes.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof-no-data.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-incomplete-chunk.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-rf64.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes.wav +0 -0
- scipy/io/tests/data/test-48000Hz-2ch-64bit-float-le-wavex.wav +0 -0
- scipy/io/tests/data/test-8000Hz-be-3ch-5S-24bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-1ch-1byte-ulaw.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-2ch-1byteu.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-inconsistent.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-rf64.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-36bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-45bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-53bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-64bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-4ch-9S-12bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-5ch-9S-5bit.wav +0 -0
- scipy/io/tests/data/various_compressed.sav +0 -0
- scipy/io/tests/test_fortran.py +264 -0
- scipy/io/tests/test_idl.py +483 -0
- scipy/io/tests/test_mmio.py +831 -0
- scipy/io/tests/test_netcdf.py +550 -0
- scipy/io/tests/test_paths.py +93 -0
- scipy/io/tests/test_wavfile.py +501 -0
- scipy/io/wavfile.py +938 -0
- scipy/linalg/__init__.pxd +1 -0
- scipy/linalg/__init__.py +236 -0
- scipy/linalg/_basic.py +2146 -0
- scipy/linalg/_blas_subroutines.h +164 -0
- scipy/linalg/_cythonized_array_utils.cp311-win_arm64.lib +0 -0
- scipy/linalg/_cythonized_array_utils.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_cythonized_array_utils.pxd +40 -0
- scipy/linalg/_cythonized_array_utils.pyi +16 -0
- scipy/linalg/_decomp.py +1645 -0
- scipy/linalg/_decomp_cholesky.py +413 -0
- scipy/linalg/_decomp_cossin.py +236 -0
- scipy/linalg/_decomp_interpolative.cp311-win_arm64.lib +0 -0
- scipy/linalg/_decomp_interpolative.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_ldl.py +356 -0
- scipy/linalg/_decomp_lu.py +401 -0
- scipy/linalg/_decomp_lu_cython.cp311-win_arm64.lib +0 -0
- scipy/linalg/_decomp_lu_cython.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_lu_cython.pyi +6 -0
- scipy/linalg/_decomp_polar.py +113 -0
- scipy/linalg/_decomp_qr.py +494 -0
- scipy/linalg/_decomp_qz.py +452 -0
- scipy/linalg/_decomp_schur.py +336 -0
- scipy/linalg/_decomp_svd.py +545 -0
- scipy/linalg/_decomp_update.cp311-win_arm64.lib +0 -0
- scipy/linalg/_decomp_update.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_expm_frechet.py +417 -0
- scipy/linalg/_fblas.cp311-win_arm64.lib +0 -0
- scipy/linalg/_fblas.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_flapack.cp311-win_arm64.lib +0 -0
- scipy/linalg/_flapack.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_lapack_subroutines.h +1521 -0
- scipy/linalg/_linalg_pythran.cp311-win_arm64.lib +0 -0
- scipy/linalg/_linalg_pythran.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs.py +1050 -0
- scipy/linalg/_matfuncs_expm.cp311-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_expm.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_expm.pyi +6 -0
- scipy/linalg/_matfuncs_inv_ssq.py +886 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp311-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_sqrtm.py +107 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp311-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_misc.py +191 -0
- scipy/linalg/_procrustes.py +113 -0
- scipy/linalg/_sketches.py +189 -0
- scipy/linalg/_solve_toeplitz.cp311-win_arm64.lib +0 -0
- scipy/linalg/_solve_toeplitz.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_solvers.py +862 -0
- scipy/linalg/_special_matrices.py +1322 -0
- scipy/linalg/_testutils.py +65 -0
- scipy/linalg/basic.py +23 -0
- scipy/linalg/blas.py +495 -0
- scipy/linalg/cython_blas.cp311-win_arm64.lib +0 -0
- scipy/linalg/cython_blas.cp311-win_arm64.pyd +0 -0
- scipy/linalg/cython_blas.pxd +169 -0
- scipy/linalg/cython_blas.pyx +1432 -0
- scipy/linalg/cython_lapack.cp311-win_arm64.lib +0 -0
- scipy/linalg/cython_lapack.cp311-win_arm64.pyd +0 -0
- scipy/linalg/cython_lapack.pxd +1528 -0
- scipy/linalg/cython_lapack.pyx +12045 -0
- scipy/linalg/decomp.py +23 -0
- scipy/linalg/decomp_cholesky.py +21 -0
- scipy/linalg/decomp_lu.py +21 -0
- scipy/linalg/decomp_qr.py +20 -0
- scipy/linalg/decomp_schur.py +21 -0
- scipy/linalg/decomp_svd.py +21 -0
- scipy/linalg/interpolative.py +989 -0
- scipy/linalg/lapack.py +1081 -0
- scipy/linalg/matfuncs.py +23 -0
- scipy/linalg/misc.py +21 -0
- scipy/linalg/special_matrices.py +22 -0
- scipy/linalg/tests/__init__.py +0 -0
- scipy/linalg/tests/_cython_examples/extending.pyx +23 -0
- scipy/linalg/tests/_cython_examples/meson.build +34 -0
- scipy/linalg/tests/data/carex_15_data.npz +0 -0
- scipy/linalg/tests/data/carex_18_data.npz +0 -0
- scipy/linalg/tests/data/carex_19_data.npz +0 -0
- scipy/linalg/tests/data/carex_20_data.npz +0 -0
- scipy/linalg/tests/data/carex_6_data.npz +0 -0
- scipy/linalg/tests/data/gendare_20170120_data.npz +0 -0
- scipy/linalg/tests/test_basic.py +2074 -0
- scipy/linalg/tests/test_batch.py +588 -0
- scipy/linalg/tests/test_blas.py +1127 -0
- scipy/linalg/tests/test_cython_blas.py +118 -0
- scipy/linalg/tests/test_cython_lapack.py +22 -0
- scipy/linalg/tests/test_cythonized_array_utils.py +130 -0
- scipy/linalg/tests/test_decomp.py +3189 -0
- scipy/linalg/tests/test_decomp_cholesky.py +268 -0
- scipy/linalg/tests/test_decomp_cossin.py +314 -0
- scipy/linalg/tests/test_decomp_ldl.py +137 -0
- scipy/linalg/tests/test_decomp_lu.py +308 -0
- scipy/linalg/tests/test_decomp_polar.py +110 -0
- scipy/linalg/tests/test_decomp_update.py +1701 -0
- scipy/linalg/tests/test_extending.py +46 -0
- scipy/linalg/tests/test_fblas.py +607 -0
- scipy/linalg/tests/test_interpolative.py +232 -0
- scipy/linalg/tests/test_lapack.py +3620 -0
- scipy/linalg/tests/test_matfuncs.py +1125 -0
- scipy/linalg/tests/test_matmul_toeplitz.py +136 -0
- scipy/linalg/tests/test_procrustes.py +214 -0
- scipy/linalg/tests/test_sketches.py +118 -0
- scipy/linalg/tests/test_solve_toeplitz.py +150 -0
- scipy/linalg/tests/test_solvers.py +844 -0
- scipy/linalg/tests/test_special_matrices.py +636 -0
- scipy/misc/__init__.py +6 -0
- scipy/misc/common.py +6 -0
- scipy/misc/doccer.py +6 -0
- scipy/ndimage/__init__.py +174 -0
- scipy/ndimage/_ctest.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_ctest.cp311-win_arm64.pyd +0 -0
- scipy/ndimage/_cytest.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_cytest.cp311-win_arm64.pyd +0 -0
- scipy/ndimage/_delegators.py +303 -0
- scipy/ndimage/_filters.py +2422 -0
- scipy/ndimage/_fourier.py +306 -0
- scipy/ndimage/_interpolation.py +1033 -0
- scipy/ndimage/_measurements.py +1689 -0
- scipy/ndimage/_morphology.py +2634 -0
- scipy/ndimage/_nd_image.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_nd_image.cp311-win_arm64.pyd +0 -0
- scipy/ndimage/_ndimage_api.py +16 -0
- scipy/ndimage/_ni_docstrings.py +214 -0
- scipy/ndimage/_ni_label.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_ni_label.cp311-win_arm64.pyd +0 -0
- scipy/ndimage/_ni_support.py +139 -0
- scipy/ndimage/_rank_filter_1d.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_rank_filter_1d.cp311-win_arm64.pyd +0 -0
- scipy/ndimage/_support_alternative_backends.py +84 -0
- scipy/ndimage/filters.py +27 -0
- scipy/ndimage/fourier.py +21 -0
- scipy/ndimage/interpolation.py +22 -0
- scipy/ndimage/measurements.py +24 -0
- scipy/ndimage/morphology.py +27 -0
- scipy/ndimage/tests/__init__.py +12 -0
- scipy/ndimage/tests/data/label_inputs.txt +21 -0
- scipy/ndimage/tests/data/label_results.txt +294 -0
- scipy/ndimage/tests/data/label_strels.txt +42 -0
- scipy/ndimage/tests/dots.png +0 -0
- scipy/ndimage/tests/test_c_api.py +102 -0
- scipy/ndimage/tests/test_datatypes.py +67 -0
- scipy/ndimage/tests/test_filters.py +3083 -0
- scipy/ndimage/tests/test_fourier.py +187 -0
- scipy/ndimage/tests/test_interpolation.py +1491 -0
- scipy/ndimage/tests/test_measurements.py +1592 -0
- scipy/ndimage/tests/test_morphology.py +2950 -0
- scipy/ndimage/tests/test_ni_support.py +78 -0
- scipy/ndimage/tests/test_splines.py +70 -0
- scipy/odr/__init__.py +131 -0
- scipy/odr/__odrpack.cp311-win_arm64.lib +0 -0
- scipy/odr/__odrpack.cp311-win_arm64.pyd +0 -0
- scipy/odr/_add_newdocs.py +34 -0
- scipy/odr/_models.py +315 -0
- scipy/odr/_odrpack.py +1154 -0
- scipy/odr/models.py +20 -0
- scipy/odr/odrpack.py +21 -0
- scipy/odr/tests/__init__.py +0 -0
- scipy/odr/tests/test_odr.py +607 -0
- scipy/optimize/__init__.pxd +1 -0
- scipy/optimize/__init__.py +460 -0
- scipy/optimize/_basinhopping.py +741 -0
- scipy/optimize/_bglu_dense.cp311-win_arm64.lib +0 -0
- scipy/optimize/_bglu_dense.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_bracket.py +706 -0
- scipy/optimize/_chandrupatla.py +551 -0
- scipy/optimize/_cobyla_py.py +297 -0
- scipy/optimize/_cobyqa_py.py +72 -0
- scipy/optimize/_constraints.py +598 -0
- scipy/optimize/_dcsrch.py +728 -0
- scipy/optimize/_differentiable_functions.py +835 -0
- scipy/optimize/_differentialevolution.py +1970 -0
- scipy/optimize/_direct.cp311-win_arm64.lib +0 -0
- scipy/optimize/_direct.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_direct_py.py +280 -0
- scipy/optimize/_dual_annealing.py +732 -0
- scipy/optimize/_elementwise.py +798 -0
- scipy/optimize/_group_columns.cp311-win_arm64.lib +0 -0
- scipy/optimize/_group_columns.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_hessian_update_strategy.py +479 -0
- scipy/optimize/_highspy/__init__.py +0 -0
- scipy/optimize/_highspy/_core.cp311-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_core.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_options.cp311-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_highs_options.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_wrapper.py +338 -0
- scipy/optimize/_isotonic.py +157 -0
- scipy/optimize/_lbfgsb.cp311-win_arm64.lib +0 -0
- scipy/optimize/_lbfgsb.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_lbfgsb_py.py +634 -0
- scipy/optimize/_linesearch.py +896 -0
- scipy/optimize/_linprog.py +733 -0
- scipy/optimize/_linprog_doc.py +1434 -0
- scipy/optimize/_linprog_highs.py +422 -0
- scipy/optimize/_linprog_ip.py +1141 -0
- scipy/optimize/_linprog_rs.py +572 -0
- scipy/optimize/_linprog_simplex.py +663 -0
- scipy/optimize/_linprog_util.py +1521 -0
- scipy/optimize/_lsap.cp311-win_arm64.lib +0 -0
- scipy/optimize/_lsap.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_lsq/__init__.py +5 -0
- scipy/optimize/_lsq/bvls.py +183 -0
- scipy/optimize/_lsq/common.py +731 -0
- scipy/optimize/_lsq/dogbox.py +345 -0
- scipy/optimize/_lsq/givens_elimination.cp311-win_arm64.lib +0 -0
- scipy/optimize/_lsq/givens_elimination.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_lsq/least_squares.py +1044 -0
- scipy/optimize/_lsq/lsq_linear.py +361 -0
- scipy/optimize/_lsq/trf.py +587 -0
- scipy/optimize/_lsq/trf_linear.py +249 -0
- scipy/optimize/_milp.py +394 -0
- scipy/optimize/_minimize.py +1199 -0
- scipy/optimize/_minpack.cp311-win_arm64.lib +0 -0
- scipy/optimize/_minpack.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_minpack_py.py +1178 -0
- scipy/optimize/_moduleTNC.cp311-win_arm64.lib +0 -0
- scipy/optimize/_moduleTNC.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_nnls.py +96 -0
- scipy/optimize/_nonlin.py +1634 -0
- scipy/optimize/_numdiff.py +963 -0
- scipy/optimize/_optimize.py +4169 -0
- scipy/optimize/_pava_pybind.cp311-win_arm64.lib +0 -0
- scipy/optimize/_pava_pybind.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_qap.py +760 -0
- scipy/optimize/_remove_redundancy.py +522 -0
- scipy/optimize/_root.py +732 -0
- scipy/optimize/_root_scalar.py +538 -0
- scipy/optimize/_shgo.py +1606 -0
- scipy/optimize/_shgo_lib/__init__.py +0 -0
- scipy/optimize/_shgo_lib/_complex.py +1225 -0
- scipy/optimize/_shgo_lib/_vertex.py +460 -0
- scipy/optimize/_slsqp_py.py +603 -0
- scipy/optimize/_slsqplib.cp311-win_arm64.lib +0 -0
- scipy/optimize/_slsqplib.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_spectral.py +260 -0
- scipy/optimize/_tnc.py +438 -0
- scipy/optimize/_trlib/__init__.py +12 -0
- scipy/optimize/_trlib/_trlib.cp311-win_arm64.lib +0 -0
- scipy/optimize/_trlib/_trlib.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_trustregion.py +318 -0
- scipy/optimize/_trustregion_constr/__init__.py +6 -0
- scipy/optimize/_trustregion_constr/canonical_constraint.py +390 -0
- scipy/optimize/_trustregion_constr/equality_constrained_sqp.py +231 -0
- scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py +584 -0
- scipy/optimize/_trustregion_constr/projections.py +411 -0
- scipy/optimize/_trustregion_constr/qp_subproblem.py +637 -0
- scipy/optimize/_trustregion_constr/report.py +49 -0
- scipy/optimize/_trustregion_constr/tests/__init__.py +0 -0
- scipy/optimize/_trustregion_constr/tests/test_canonical_constraint.py +296 -0
- scipy/optimize/_trustregion_constr/tests/test_nested_minimize.py +39 -0
- scipy/optimize/_trustregion_constr/tests/test_projections.py +214 -0
- scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py +645 -0
- scipy/optimize/_trustregion_constr/tests/test_report.py +34 -0
- scipy/optimize/_trustregion_constr/tr_interior_point.py +361 -0
- scipy/optimize/_trustregion_dogleg.py +122 -0
- scipy/optimize/_trustregion_exact.py +437 -0
- scipy/optimize/_trustregion_krylov.py +65 -0
- scipy/optimize/_trustregion_ncg.py +126 -0
- scipy/optimize/_tstutils.py +972 -0
- scipy/optimize/_zeros.cp311-win_arm64.lib +0 -0
- scipy/optimize/_zeros.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_zeros_py.py +1475 -0
- scipy/optimize/cobyla.py +19 -0
- scipy/optimize/cython_optimize/__init__.py +133 -0
- scipy/optimize/cython_optimize/_zeros.cp311-win_arm64.lib +0 -0
- scipy/optimize/cython_optimize/_zeros.cp311-win_arm64.pyd +0 -0
- scipy/optimize/cython_optimize/_zeros.pxd +33 -0
- scipy/optimize/cython_optimize/c_zeros.pxd +26 -0
- scipy/optimize/cython_optimize.pxd +11 -0
- scipy/optimize/elementwise.py +38 -0
- scipy/optimize/lbfgsb.py +23 -0
- scipy/optimize/linesearch.py +18 -0
- scipy/optimize/minpack.py +27 -0
- scipy/optimize/minpack2.py +17 -0
- scipy/optimize/moduleTNC.py +19 -0
- scipy/optimize/nonlin.py +29 -0
- scipy/optimize/optimize.py +40 -0
- scipy/optimize/slsqp.py +22 -0
- scipy/optimize/tests/__init__.py +0 -0
- scipy/optimize/tests/_cython_examples/extending.pyx +43 -0
- scipy/optimize/tests/_cython_examples/meson.build +32 -0
- scipy/optimize/tests/test__basinhopping.py +535 -0
- scipy/optimize/tests/test__differential_evolution.py +1703 -0
- scipy/optimize/tests/test__dual_annealing.py +416 -0
- scipy/optimize/tests/test__linprog_clean_inputs.py +312 -0
- scipy/optimize/tests/test__numdiff.py +885 -0
- scipy/optimize/tests/test__remove_redundancy.py +228 -0
- scipy/optimize/tests/test__root.py +124 -0
- scipy/optimize/tests/test__shgo.py +1164 -0
- scipy/optimize/tests/test__spectral.py +226 -0
- scipy/optimize/tests/test_bracket.py +896 -0
- scipy/optimize/tests/test_chandrupatla.py +982 -0
- scipy/optimize/tests/test_cobyla.py +195 -0
- scipy/optimize/tests/test_cobyqa.py +252 -0
- scipy/optimize/tests/test_constraint_conversion.py +286 -0
- scipy/optimize/tests/test_constraints.py +255 -0
- scipy/optimize/tests/test_cython_optimize.py +92 -0
- scipy/optimize/tests/test_differentiable_functions.py +1025 -0
- scipy/optimize/tests/test_direct.py +321 -0
- scipy/optimize/tests/test_extending.py +28 -0
- scipy/optimize/tests/test_hessian_update_strategy.py +300 -0
- scipy/optimize/tests/test_isotonic_regression.py +167 -0
- scipy/optimize/tests/test_lbfgsb_hessinv.py +65 -0
- scipy/optimize/tests/test_lbfgsb_setulb.py +122 -0
- scipy/optimize/tests/test_least_squares.py +986 -0
- scipy/optimize/tests/test_linear_assignment.py +116 -0
- scipy/optimize/tests/test_linesearch.py +328 -0
- scipy/optimize/tests/test_linprog.py +2577 -0
- scipy/optimize/tests/test_lsq_common.py +297 -0
- scipy/optimize/tests/test_lsq_linear.py +287 -0
- scipy/optimize/tests/test_milp.py +459 -0
- scipy/optimize/tests/test_minimize_constrained.py +845 -0
- scipy/optimize/tests/test_minpack.py +1194 -0
- scipy/optimize/tests/test_nnls.py +469 -0
- scipy/optimize/tests/test_nonlin.py +572 -0
- scipy/optimize/tests/test_optimize.py +3344 -0
- scipy/optimize/tests/test_quadratic_assignment.py +455 -0
- scipy/optimize/tests/test_regression.py +40 -0
- scipy/optimize/tests/test_slsqp.py +645 -0
- scipy/optimize/tests/test_tnc.py +345 -0
- scipy/optimize/tests/test_trustregion.py +110 -0
- scipy/optimize/tests/test_trustregion_exact.py +351 -0
- scipy/optimize/tests/test_trustregion_krylov.py +170 -0
- scipy/optimize/tests/test_zeros.py +998 -0
- scipy/optimize/tnc.py +22 -0
- scipy/optimize/zeros.py +26 -0
- scipy/signal/__init__.py +316 -0
- scipy/signal/_arraytools.py +264 -0
- scipy/signal/_czt.py +575 -0
- scipy/signal/_delegators.py +568 -0
- scipy/signal/_filter_design.py +5893 -0
- scipy/signal/_fir_filter_design.py +1458 -0
- scipy/signal/_lti_conversion.py +534 -0
- scipy/signal/_ltisys.py +3546 -0
- scipy/signal/_max_len_seq.py +139 -0
- scipy/signal/_max_len_seq_inner.cp311-win_arm64.lib +0 -0
- scipy/signal/_max_len_seq_inner.cp311-win_arm64.pyd +0 -0
- scipy/signal/_peak_finding.py +1310 -0
- scipy/signal/_peak_finding_utils.cp311-win_arm64.lib +0 -0
- scipy/signal/_peak_finding_utils.cp311-win_arm64.pyd +0 -0
- scipy/signal/_polyutils.py +172 -0
- scipy/signal/_savitzky_golay.py +357 -0
- scipy/signal/_short_time_fft.py +2228 -0
- scipy/signal/_signal_api.py +30 -0
- scipy/signal/_signaltools.py +5309 -0
- scipy/signal/_sigtools.cp311-win_arm64.lib +0 -0
- scipy/signal/_sigtools.cp311-win_arm64.pyd +0 -0
- scipy/signal/_sosfilt.cp311-win_arm64.lib +0 -0
- scipy/signal/_sosfilt.cp311-win_arm64.pyd +0 -0
- scipy/signal/_spectral_py.py +2471 -0
- scipy/signal/_spline.cp311-win_arm64.lib +0 -0
- scipy/signal/_spline.cp311-win_arm64.pyd +0 -0
- scipy/signal/_spline.pyi +34 -0
- scipy/signal/_spline_filters.py +848 -0
- scipy/signal/_support_alternative_backends.py +73 -0
- scipy/signal/_upfirdn.py +219 -0
- scipy/signal/_upfirdn_apply.cp311-win_arm64.lib +0 -0
- scipy/signal/_upfirdn_apply.cp311-win_arm64.pyd +0 -0
- scipy/signal/_waveforms.py +687 -0
- scipy/signal/_wavelets.py +29 -0
- scipy/signal/bsplines.py +21 -0
- scipy/signal/filter_design.py +28 -0
- scipy/signal/fir_filter_design.py +21 -0
- scipy/signal/lti_conversion.py +20 -0
- scipy/signal/ltisys.py +25 -0
- scipy/signal/signaltools.py +27 -0
- scipy/signal/spectral.py +21 -0
- scipy/signal/spline.py +18 -0
- scipy/signal/tests/__init__.py +0 -0
- scipy/signal/tests/_scipy_spectral_test_shim.py +311 -0
- scipy/signal/tests/mpsig.py +122 -0
- scipy/signal/tests/test_array_tools.py +111 -0
- scipy/signal/tests/test_bsplines.py +365 -0
- scipy/signal/tests/test_cont2discrete.py +424 -0
- scipy/signal/tests/test_czt.py +221 -0
- scipy/signal/tests/test_dltisys.py +599 -0
- scipy/signal/tests/test_filter_design.py +4744 -0
- scipy/signal/tests/test_fir_filter_design.py +851 -0
- scipy/signal/tests/test_ltisys.py +1225 -0
- scipy/signal/tests/test_max_len_seq.py +71 -0
- scipy/signal/tests/test_peak_finding.py +915 -0
- scipy/signal/tests/test_result_type.py +51 -0
- scipy/signal/tests/test_savitzky_golay.py +363 -0
- scipy/signal/tests/test_short_time_fft.py +1107 -0
- scipy/signal/tests/test_signaltools.py +4735 -0
- scipy/signal/tests/test_spectral.py +2141 -0
- scipy/signal/tests/test_splines.py +427 -0
- scipy/signal/tests/test_upfirdn.py +322 -0
- scipy/signal/tests/test_waveforms.py +400 -0
- scipy/signal/tests/test_wavelets.py +59 -0
- scipy/signal/tests/test_windows.py +987 -0
- scipy/signal/waveforms.py +20 -0
- scipy/signal/wavelets.py +17 -0
- scipy/signal/windows/__init__.py +52 -0
- scipy/signal/windows/_windows.py +2513 -0
- scipy/signal/windows/windows.py +23 -0
- scipy/sparse/__init__.py +350 -0
- scipy/sparse/_base.py +1613 -0
- scipy/sparse/_bsr.py +880 -0
- scipy/sparse/_compressed.py +1328 -0
- scipy/sparse/_construct.py +1454 -0
- scipy/sparse/_coo.py +1581 -0
- scipy/sparse/_csc.py +367 -0
- scipy/sparse/_csparsetools.cp311-win_arm64.lib +0 -0
- scipy/sparse/_csparsetools.cp311-win_arm64.pyd +0 -0
- scipy/sparse/_csr.py +558 -0
- scipy/sparse/_data.py +569 -0
- scipy/sparse/_dia.py +677 -0
- scipy/sparse/_dok.py +669 -0
- scipy/sparse/_extract.py +178 -0
- scipy/sparse/_index.py +444 -0
- scipy/sparse/_lil.py +632 -0
- scipy/sparse/_matrix.py +169 -0
- scipy/sparse/_matrix_io.py +167 -0
- scipy/sparse/_sparsetools.cp311-win_arm64.lib +0 -0
- scipy/sparse/_sparsetools.cp311-win_arm64.pyd +0 -0
- scipy/sparse/_spfuncs.py +76 -0
- scipy/sparse/_sputils.py +632 -0
- scipy/sparse/base.py +24 -0
- scipy/sparse/bsr.py +22 -0
- scipy/sparse/compressed.py +20 -0
- scipy/sparse/construct.py +38 -0
- scipy/sparse/coo.py +23 -0
- scipy/sparse/csc.py +22 -0
- scipy/sparse/csgraph/__init__.py +210 -0
- scipy/sparse/csgraph/_flow.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_flow.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_laplacian.py +563 -0
- scipy/sparse/csgraph/_matching.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_matching.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_reordering.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_reordering.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_shortest_path.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_shortest_path.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_tools.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_tools.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_traversal.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_traversal.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_validation.py +66 -0
- scipy/sparse/csgraph/tests/__init__.py +0 -0
- scipy/sparse/csgraph/tests/test_connected_components.py +119 -0
- scipy/sparse/csgraph/tests/test_conversions.py +61 -0
- scipy/sparse/csgraph/tests/test_flow.py +209 -0
- scipy/sparse/csgraph/tests/test_graph_laplacian.py +368 -0
- scipy/sparse/csgraph/tests/test_matching.py +307 -0
- scipy/sparse/csgraph/tests/test_pydata_sparse.py +197 -0
- scipy/sparse/csgraph/tests/test_reordering.py +70 -0
- scipy/sparse/csgraph/tests/test_shortest_path.py +540 -0
- scipy/sparse/csgraph/tests/test_spanning_tree.py +66 -0
- scipy/sparse/csgraph/tests/test_traversal.py +148 -0
- scipy/sparse/csr.py +22 -0
- scipy/sparse/data.py +18 -0
- scipy/sparse/dia.py +22 -0
- scipy/sparse/dok.py +22 -0
- scipy/sparse/extract.py +23 -0
- scipy/sparse/lil.py +22 -0
- scipy/sparse/linalg/__init__.py +148 -0
- scipy/sparse/linalg/_dsolve/__init__.py +71 -0
- scipy/sparse/linalg/_dsolve/_add_newdocs.py +147 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_dsolve/linsolve.py +882 -0
- scipy/sparse/linalg/_dsolve/tests/__init__.py +0 -0
- scipy/sparse/linalg/_dsolve/tests/test_linsolve.py +928 -0
- scipy/sparse/linalg/_eigen/__init__.py +22 -0
- scipy/sparse/linalg/_eigen/_svds.py +540 -0
- scipy/sparse/linalg/_eigen/_svds_doc.py +382 -0
- scipy/sparse/linalg/_eigen/arpack/COPYING +45 -0
- scipy/sparse/linalg/_eigen/arpack/__init__.py +20 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_eigen/arpack/arpack.py +1706 -0
- scipy/sparse/linalg/_eigen/arpack/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/arpack/tests/test_arpack.py +717 -0
- scipy/sparse/linalg/_eigen/lobpcg/__init__.py +16 -0
- scipy/sparse/linalg/_eigen/lobpcg/lobpcg.py +1110 -0
- scipy/sparse/linalg/_eigen/lobpcg/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.py +725 -0
- scipy/sparse/linalg/_eigen/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/tests/test_svds.py +886 -0
- scipy/sparse/linalg/_expm_multiply.py +816 -0
- scipy/sparse/linalg/_interface.py +920 -0
- scipy/sparse/linalg/_isolve/__init__.py +20 -0
- scipy/sparse/linalg/_isolve/_gcrotmk.py +503 -0
- scipy/sparse/linalg/_isolve/iterative.py +1051 -0
- scipy/sparse/linalg/_isolve/lgmres.py +230 -0
- scipy/sparse/linalg/_isolve/lsmr.py +486 -0
- scipy/sparse/linalg/_isolve/lsqr.py +589 -0
- scipy/sparse/linalg/_isolve/minres.py +372 -0
- scipy/sparse/linalg/_isolve/tests/__init__.py +0 -0
- scipy/sparse/linalg/_isolve/tests/test_gcrotmk.py +183 -0
- scipy/sparse/linalg/_isolve/tests/test_iterative.py +809 -0
- scipy/sparse/linalg/_isolve/tests/test_lgmres.py +225 -0
- scipy/sparse/linalg/_isolve/tests/test_lsmr.py +185 -0
- scipy/sparse/linalg/_isolve/tests/test_lsqr.py +120 -0
- scipy/sparse/linalg/_isolve/tests/test_minres.py +97 -0
- scipy/sparse/linalg/_isolve/tests/test_utils.py +9 -0
- scipy/sparse/linalg/_isolve/tfqmr.py +179 -0
- scipy/sparse/linalg/_isolve/utils.py +121 -0
- scipy/sparse/linalg/_matfuncs.py +940 -0
- scipy/sparse/linalg/_norm.py +195 -0
- scipy/sparse/linalg/_onenormest.py +467 -0
- scipy/sparse/linalg/_propack/_cpropack.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_cpropack.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_special_sparse_arrays.py +949 -0
- scipy/sparse/linalg/_svdp.py +309 -0
- scipy/sparse/linalg/dsolve.py +22 -0
- scipy/sparse/linalg/eigen.py +21 -0
- scipy/sparse/linalg/interface.py +20 -0
- scipy/sparse/linalg/isolve.py +22 -0
- scipy/sparse/linalg/matfuncs.py +18 -0
- scipy/sparse/linalg/tests/__init__.py +0 -0
- scipy/sparse/linalg/tests/propack_test_data.npz +0 -0
- scipy/sparse/linalg/tests/test_expm_multiply.py +367 -0
- scipy/sparse/linalg/tests/test_interface.py +561 -0
- scipy/sparse/linalg/tests/test_matfuncs.py +592 -0
- scipy/sparse/linalg/tests/test_norm.py +154 -0
- scipy/sparse/linalg/tests/test_onenormest.py +252 -0
- scipy/sparse/linalg/tests/test_propack.py +165 -0
- scipy/sparse/linalg/tests/test_pydata_sparse.py +272 -0
- scipy/sparse/linalg/tests/test_special_sparse_arrays.py +337 -0
- scipy/sparse/sparsetools.py +17 -0
- scipy/sparse/spfuncs.py +17 -0
- scipy/sparse/sputils.py +17 -0
- scipy/sparse/tests/__init__.py +0 -0
- scipy/sparse/tests/data/csc_py2.npz +0 -0
- scipy/sparse/tests/data/csc_py3.npz +0 -0
- scipy/sparse/tests/test_arithmetic1d.py +341 -0
- scipy/sparse/tests/test_array_api.py +561 -0
- scipy/sparse/tests/test_base.py +5870 -0
- scipy/sparse/tests/test_common1d.py +447 -0
- scipy/sparse/tests/test_construct.py +872 -0
- scipy/sparse/tests/test_coo.py +1119 -0
- scipy/sparse/tests/test_csc.py +98 -0
- scipy/sparse/tests/test_csr.py +214 -0
- scipy/sparse/tests/test_dok.py +209 -0
- scipy/sparse/tests/test_extract.py +51 -0
- scipy/sparse/tests/test_indexing1d.py +603 -0
- scipy/sparse/tests/test_matrix_io.py +109 -0
- scipy/sparse/tests/test_minmax1d.py +128 -0
- scipy/sparse/tests/test_sparsetools.py +344 -0
- scipy/sparse/tests/test_spfuncs.py +97 -0
- scipy/sparse/tests/test_sputils.py +424 -0
- scipy/spatial/__init__.py +129 -0
- scipy/spatial/_ckdtree.cp311-win_arm64.lib +0 -0
- scipy/spatial/_ckdtree.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_distance_pybind.cp311-win_arm64.lib +0 -0
- scipy/spatial/_distance_pybind.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_distance_wrap.cp311-win_arm64.lib +0 -0
- scipy/spatial/_distance_wrap.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_geometric_slerp.py +238 -0
- scipy/spatial/_hausdorff.cp311-win_arm64.lib +0 -0
- scipy/spatial/_hausdorff.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_kdtree.py +920 -0
- scipy/spatial/_plotutils.py +274 -0
- scipy/spatial/_procrustes.py +132 -0
- scipy/spatial/_qhull.cp311-win_arm64.lib +0 -0
- scipy/spatial/_qhull.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_qhull.pyi +213 -0
- scipy/spatial/_spherical_voronoi.py +341 -0
- scipy/spatial/_voronoi.cp311-win_arm64.lib +0 -0
- scipy/spatial/_voronoi.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_voronoi.pyi +4 -0
- scipy/spatial/ckdtree.py +18 -0
- scipy/spatial/distance.py +3147 -0
- scipy/spatial/distance.pyi +210 -0
- scipy/spatial/kdtree.py +25 -0
- scipy/spatial/qhull.py +25 -0
- scipy/spatial/qhull_src/COPYING_QHULL.txt +39 -0
- scipy/spatial/tests/__init__.py +0 -0
- scipy/spatial/tests/data/cdist-X1.txt +10 -0
- scipy/spatial/tests/data/cdist-X2.txt +20 -0
- scipy/spatial/tests/data/degenerate_pointset.npz +0 -0
- scipy/spatial/tests/data/iris.txt +150 -0
- scipy/spatial/tests/data/pdist-boolean-inp.txt +20 -0
- scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-chebyshev-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-cityblock-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-correlation-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-correlation-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-cosine-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-cosine-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-double-inp.txt +20 -0
- scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-euclidean-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-hamming-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-jaccard-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-jensenshannon-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-seuclidean-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-spearman-ml.txt +1 -0
- scipy/spatial/tests/data/random-bool-data.txt +100 -0
- scipy/spatial/tests/data/random-double-data.txt +100 -0
- scipy/spatial/tests/data/random-int-data.txt +100 -0
- scipy/spatial/tests/data/random-uint-data.txt +100 -0
- scipy/spatial/tests/data/selfdual-4d-polytope.txt +27 -0
- scipy/spatial/tests/test__plotutils.py +91 -0
- scipy/spatial/tests/test__procrustes.py +116 -0
- scipy/spatial/tests/test_distance.py +2389 -0
- scipy/spatial/tests/test_hausdorff.py +199 -0
- scipy/spatial/tests/test_kdtree.py +1536 -0
- scipy/spatial/tests/test_qhull.py +1313 -0
- scipy/spatial/tests/test_slerp.py +417 -0
- scipy/spatial/tests/test_spherical_voronoi.py +358 -0
- scipy/spatial/transform/__init__.py +31 -0
- scipy/spatial/transform/_rigid_transform.cp311-win_arm64.lib +0 -0
- scipy/spatial/transform/_rigid_transform.cp311-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation.cp311-win_arm64.lib +0 -0
- scipy/spatial/transform/_rotation.cp311-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation_groups.py +140 -0
- scipy/spatial/transform/_rotation_spline.py +460 -0
- scipy/spatial/transform/rotation.py +21 -0
- scipy/spatial/transform/tests/__init__.py +0 -0
- scipy/spatial/transform/tests/test_rigid_transform.py +1221 -0
- scipy/spatial/transform/tests/test_rotation.py +2569 -0
- scipy/spatial/transform/tests/test_rotation_groups.py +169 -0
- scipy/spatial/transform/tests/test_rotation_spline.py +183 -0
- scipy/special/__init__.pxd +1 -0
- scipy/special/__init__.py +841 -0
- scipy/special/_add_newdocs.py +9961 -0
- scipy/special/_basic.py +3576 -0
- scipy/special/_comb.cp311-win_arm64.lib +0 -0
- scipy/special/_comb.cp311-win_arm64.pyd +0 -0
- scipy/special/_ellip_harm.py +214 -0
- scipy/special/_ellip_harm_2.cp311-win_arm64.lib +0 -0
- scipy/special/_ellip_harm_2.cp311-win_arm64.pyd +0 -0
- scipy/special/_gufuncs.cp311-win_arm64.lib +0 -0
- scipy/special/_gufuncs.cp311-win_arm64.pyd +0 -0
- scipy/special/_input_validation.py +17 -0
- scipy/special/_lambertw.py +149 -0
- scipy/special/_logsumexp.py +426 -0
- scipy/special/_mptestutils.py +453 -0
- scipy/special/_multiufuncs.py +610 -0
- scipy/special/_orthogonal.py +2592 -0
- scipy/special/_orthogonal.pyi +330 -0
- scipy/special/_precompute/__init__.py +0 -0
- scipy/special/_precompute/cosine_cdf.py +17 -0
- scipy/special/_precompute/expn_asy.py +54 -0
- scipy/special/_precompute/gammainc_asy.py +116 -0
- scipy/special/_precompute/gammainc_data.py +124 -0
- scipy/special/_precompute/hyp2f1_data.py +484 -0
- scipy/special/_precompute/lambertw.py +68 -0
- scipy/special/_precompute/loggamma.py +43 -0
- scipy/special/_precompute/struve_convergence.py +131 -0
- scipy/special/_precompute/utils.py +38 -0
- scipy/special/_precompute/wright_bessel.py +342 -0
- scipy/special/_precompute/wright_bessel_data.py +152 -0
- scipy/special/_precompute/wrightomega.py +41 -0
- scipy/special/_precompute/zetac.py +27 -0
- scipy/special/_sf_error.py +15 -0
- scipy/special/_specfun.cp311-win_arm64.lib +0 -0
- scipy/special/_specfun.cp311-win_arm64.pyd +0 -0
- scipy/special/_special_ufuncs.cp311-win_arm64.lib +0 -0
- scipy/special/_special_ufuncs.cp311-win_arm64.pyd +0 -0
- scipy/special/_spfun_stats.py +106 -0
- scipy/special/_spherical_bessel.py +397 -0
- scipy/special/_support_alternative_backends.py +295 -0
- scipy/special/_test_internal.cp311-win_arm64.lib +0 -0
- scipy/special/_test_internal.cp311-win_arm64.pyd +0 -0
- scipy/special/_test_internal.pyi +9 -0
- scipy/special/_testutils.py +321 -0
- scipy/special/_ufuncs.cp311-win_arm64.lib +0 -0
- scipy/special/_ufuncs.cp311-win_arm64.pyd +0 -0
- scipy/special/_ufuncs.pyi +522 -0
- scipy/special/_ufuncs.pyx +13173 -0
- scipy/special/_ufuncs_cxx.cp311-win_arm64.lib +0 -0
- scipy/special/_ufuncs_cxx.cp311-win_arm64.pyd +0 -0
- scipy/special/_ufuncs_cxx.pxd +142 -0
- scipy/special/_ufuncs_cxx.pyx +427 -0
- scipy/special/_ufuncs_cxx_defs.h +147 -0
- scipy/special/_ufuncs_defs.h +57 -0
- scipy/special/add_newdocs.py +15 -0
- scipy/special/basic.py +87 -0
- scipy/special/cython_special.cp311-win_arm64.lib +0 -0
- scipy/special/cython_special.cp311-win_arm64.pyd +0 -0
- scipy/special/cython_special.pxd +259 -0
- scipy/special/cython_special.pyi +3 -0
- scipy/special/orthogonal.py +45 -0
- scipy/special/sf_error.py +20 -0
- scipy/special/specfun.py +24 -0
- scipy/special/spfun_stats.py +17 -0
- scipy/special/tests/__init__.py +0 -0
- scipy/special/tests/_cython_examples/extending.pyx +12 -0
- scipy/special/tests/_cython_examples/meson.build +34 -0
- scipy/special/tests/data/__init__.py +0 -0
- scipy/special/tests/data/boost.npz +0 -0
- scipy/special/tests/data/gsl.npz +0 -0
- scipy/special/tests/data/local.npz +0 -0
- scipy/special/tests/test_basic.py +4815 -0
- scipy/special/tests/test_bdtr.py +112 -0
- scipy/special/tests/test_boost_ufuncs.py +64 -0
- scipy/special/tests/test_boxcox.py +125 -0
- scipy/special/tests/test_cdflib.py +712 -0
- scipy/special/tests/test_cdft_asymptotic.py +49 -0
- scipy/special/tests/test_cephes_intp_cast.py +29 -0
- scipy/special/tests/test_cosine_distr.py +83 -0
- scipy/special/tests/test_cython_special.py +363 -0
- scipy/special/tests/test_data.py +719 -0
- scipy/special/tests/test_dd.py +42 -0
- scipy/special/tests/test_digamma.py +45 -0
- scipy/special/tests/test_ellip_harm.py +278 -0
- scipy/special/tests/test_erfinv.py +89 -0
- scipy/special/tests/test_exponential_integrals.py +118 -0
- scipy/special/tests/test_extending.py +28 -0
- scipy/special/tests/test_faddeeva.py +85 -0
- scipy/special/tests/test_gamma.py +12 -0
- scipy/special/tests/test_gammainc.py +152 -0
- scipy/special/tests/test_hyp2f1.py +2566 -0
- scipy/special/tests/test_hypergeometric.py +234 -0
- scipy/special/tests/test_iv_ratio.py +249 -0
- scipy/special/tests/test_kolmogorov.py +491 -0
- scipy/special/tests/test_lambertw.py +109 -0
- scipy/special/tests/test_legendre.py +1518 -0
- scipy/special/tests/test_log1mexp.py +85 -0
- scipy/special/tests/test_loggamma.py +70 -0
- scipy/special/tests/test_logit.py +162 -0
- scipy/special/tests/test_logsumexp.py +469 -0
- scipy/special/tests/test_mpmath.py +2293 -0
- scipy/special/tests/test_nan_inputs.py +65 -0
- scipy/special/tests/test_ndtr.py +77 -0
- scipy/special/tests/test_ndtri_exp.py +94 -0
- scipy/special/tests/test_orthogonal.py +821 -0
- scipy/special/tests/test_orthogonal_eval.py +275 -0
- scipy/special/tests/test_owens_t.py +53 -0
- scipy/special/tests/test_pcf.py +24 -0
- scipy/special/tests/test_pdtr.py +48 -0
- scipy/special/tests/test_powm1.py +65 -0
- scipy/special/tests/test_precompute_expn_asy.py +24 -0
- scipy/special/tests/test_precompute_gammainc.py +108 -0
- scipy/special/tests/test_precompute_utils.py +36 -0
- scipy/special/tests/test_round.py +18 -0
- scipy/special/tests/test_sf_error.py +146 -0
- scipy/special/tests/test_sici.py +36 -0
- scipy/special/tests/test_specfun.py +48 -0
- scipy/special/tests/test_spence.py +32 -0
- scipy/special/tests/test_spfun_stats.py +61 -0
- scipy/special/tests/test_sph_harm.py +85 -0
- scipy/special/tests/test_spherical_bessel.py +400 -0
- scipy/special/tests/test_support_alternative_backends.py +248 -0
- scipy/special/tests/test_trig.py +72 -0
- scipy/special/tests/test_ufunc_signatures.py +46 -0
- scipy/special/tests/test_wright_bessel.py +205 -0
- scipy/special/tests/test_wrightomega.py +117 -0
- scipy/special/tests/test_zeta.py +301 -0
- scipy/stats/__init__.py +670 -0
- scipy/stats/_ansari_swilk_statistics.cp311-win_arm64.lib +0 -0
- scipy/stats/_ansari_swilk_statistics.cp311-win_arm64.pyd +0 -0
- scipy/stats/_axis_nan_policy.py +692 -0
- scipy/stats/_biasedurn.cp311-win_arm64.lib +0 -0
- scipy/stats/_biasedurn.cp311-win_arm64.pyd +0 -0
- scipy/stats/_biasedurn.pxd +27 -0
- scipy/stats/_binned_statistic.py +795 -0
- scipy/stats/_binomtest.py +375 -0
- scipy/stats/_bws_test.py +177 -0
- scipy/stats/_censored_data.py +459 -0
- scipy/stats/_common.py +5 -0
- scipy/stats/_constants.py +42 -0
- scipy/stats/_continued_fraction.py +387 -0
- scipy/stats/_continuous_distns.py +12486 -0
- scipy/stats/_correlation.py +210 -0
- scipy/stats/_covariance.py +636 -0
- scipy/stats/_crosstab.py +204 -0
- scipy/stats/_discrete_distns.py +2098 -0
- scipy/stats/_distn_infrastructure.py +4201 -0
- scipy/stats/_distr_params.py +299 -0
- scipy/stats/_distribution_infrastructure.py +5750 -0
- scipy/stats/_entropy.py +428 -0
- scipy/stats/_finite_differences.py +145 -0
- scipy/stats/_fit.py +1351 -0
- scipy/stats/_hypotests.py +2060 -0
- scipy/stats/_kde.py +732 -0
- scipy/stats/_ksstats.py +600 -0
- scipy/stats/_levy_stable/__init__.py +1231 -0
- scipy/stats/_levy_stable/levyst.cp311-win_arm64.lib +0 -0
- scipy/stats/_levy_stable/levyst.cp311-win_arm64.pyd +0 -0
- scipy/stats/_mannwhitneyu.py +492 -0
- scipy/stats/_mgc.py +550 -0
- scipy/stats/_morestats.py +4626 -0
- scipy/stats/_mstats_basic.py +3658 -0
- scipy/stats/_mstats_extras.py +521 -0
- scipy/stats/_multicomp.py +449 -0
- scipy/stats/_multivariate.py +7281 -0
- scipy/stats/_new_distributions.py +452 -0
- scipy/stats/_odds_ratio.py +466 -0
- scipy/stats/_page_trend_test.py +486 -0
- scipy/stats/_probability_distribution.py +1964 -0
- scipy/stats/_qmc.py +2956 -0
- scipy/stats/_qmc_cy.cp311-win_arm64.lib +0 -0
- scipy/stats/_qmc_cy.cp311-win_arm64.pyd +0 -0
- scipy/stats/_qmc_cy.pyi +54 -0
- scipy/stats/_qmvnt.py +454 -0
- scipy/stats/_qmvnt_cy.cp311-win_arm64.lib +0 -0
- scipy/stats/_qmvnt_cy.cp311-win_arm64.pyd +0 -0
- scipy/stats/_quantile.py +335 -0
- scipy/stats/_rcont/__init__.py +4 -0
- scipy/stats/_rcont/rcont.cp311-win_arm64.lib +0 -0
- scipy/stats/_rcont/rcont.cp311-win_arm64.pyd +0 -0
- scipy/stats/_relative_risk.py +263 -0
- scipy/stats/_resampling.py +2352 -0
- scipy/stats/_result_classes.py +40 -0
- scipy/stats/_sampling.py +1314 -0
- scipy/stats/_sensitivity_analysis.py +713 -0
- scipy/stats/_sobol.cp311-win_arm64.lib +0 -0
- scipy/stats/_sobol.cp311-win_arm64.pyd +0 -0
- scipy/stats/_sobol.pyi +54 -0
- scipy/stats/_sobol_direction_numbers.npz +0 -0
- scipy/stats/_stats.cp311-win_arm64.lib +0 -0
- scipy/stats/_stats.cp311-win_arm64.pyd +0 -0
- scipy/stats/_stats.pxd +10 -0
- scipy/stats/_stats_mstats_common.py +322 -0
- scipy/stats/_stats_py.py +11089 -0
- scipy/stats/_stats_pythran.cp311-win_arm64.lib +0 -0
- scipy/stats/_stats_pythran.cp311-win_arm64.pyd +0 -0
- scipy/stats/_survival.py +683 -0
- scipy/stats/_tukeylambda_stats.py +199 -0
- scipy/stats/_unuran/__init__.py +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp311-win_arm64.lib +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp311-win_arm64.pyd +0 -0
- scipy/stats/_unuran/unuran_wrapper.pyi +179 -0
- scipy/stats/_variation.py +126 -0
- scipy/stats/_warnings_errors.py +38 -0
- scipy/stats/_wilcoxon.py +265 -0
- scipy/stats/biasedurn.py +16 -0
- scipy/stats/contingency.py +521 -0
- scipy/stats/distributions.py +24 -0
- scipy/stats/kde.py +18 -0
- scipy/stats/morestats.py +27 -0
- scipy/stats/mstats.py +140 -0
- scipy/stats/mstats_basic.py +42 -0
- scipy/stats/mstats_extras.py +25 -0
- scipy/stats/mvn.py +17 -0
- scipy/stats/qmc.py +236 -0
- scipy/stats/sampling.py +73 -0
- scipy/stats/stats.py +41 -0
- scipy/stats/tests/__init__.py +0 -0
- scipy/stats/tests/common_tests.py +356 -0
- scipy/stats/tests/data/_mvt.py +171 -0
- scipy/stats/tests/data/fisher_exact_results_from_r.py +607 -0
- scipy/stats/tests/data/jf_skew_t_gamlss_pdf_data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-Z1-cdf-sample-data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-Z1-pdf-sample-data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-loc-scale-sample-data.npy +0 -0
- scipy/stats/tests/data/nist_anova/AtmWtAg.dat +108 -0
- scipy/stats/tests/data/nist_anova/SiRstv.dat +85 -0
- scipy/stats/tests/data/nist_anova/SmLs01.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs02.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs03.dat +18069 -0
- scipy/stats/tests/data/nist_anova/SmLs04.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs05.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs06.dat +18069 -0
- scipy/stats/tests/data/nist_anova/SmLs07.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs08.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs09.dat +18069 -0
- scipy/stats/tests/data/nist_linregress/Norris.dat +97 -0
- scipy/stats/tests/data/rel_breitwigner_pdf_sample_data_ROOT.npy +0 -0
- scipy/stats/tests/data/studentized_range_mpmath_ref.json +1499 -0
- scipy/stats/tests/test_axis_nan_policy.py +1388 -0
- scipy/stats/tests/test_binned_statistic.py +568 -0
- scipy/stats/tests/test_censored_data.py +152 -0
- scipy/stats/tests/test_contingency.py +294 -0
- scipy/stats/tests/test_continued_fraction.py +173 -0
- scipy/stats/tests/test_continuous.py +2198 -0
- scipy/stats/tests/test_continuous_basic.py +1053 -0
- scipy/stats/tests/test_continuous_fit_censored.py +683 -0
- scipy/stats/tests/test_correlation.py +80 -0
- scipy/stats/tests/test_crosstab.py +115 -0
- scipy/stats/tests/test_discrete_basic.py +580 -0
- scipy/stats/tests/test_discrete_distns.py +700 -0
- scipy/stats/tests/test_distributions.py +10413 -0
- scipy/stats/tests/test_entropy.py +322 -0
- scipy/stats/tests/test_fast_gen_inversion.py +435 -0
- scipy/stats/tests/test_fit.py +1090 -0
- scipy/stats/tests/test_hypotests.py +1991 -0
- scipy/stats/tests/test_kdeoth.py +676 -0
- scipy/stats/tests/test_marray.py +289 -0
- scipy/stats/tests/test_mgc.py +217 -0
- scipy/stats/tests/test_morestats.py +3259 -0
- scipy/stats/tests/test_mstats_basic.py +2071 -0
- scipy/stats/tests/test_mstats_extras.py +172 -0
- scipy/stats/tests/test_multicomp.py +405 -0
- scipy/stats/tests/test_multivariate.py +4381 -0
- scipy/stats/tests/test_odds_ratio.py +148 -0
- scipy/stats/tests/test_qmc.py +1492 -0
- scipy/stats/tests/test_quantile.py +199 -0
- scipy/stats/tests/test_rank.py +345 -0
- scipy/stats/tests/test_relative_risk.py +95 -0
- scipy/stats/tests/test_resampling.py +2000 -0
- scipy/stats/tests/test_sampling.py +1450 -0
- scipy/stats/tests/test_sensitivity_analysis.py +310 -0
- scipy/stats/tests/test_stats.py +9707 -0
- scipy/stats/tests/test_survival.py +466 -0
- scipy/stats/tests/test_tukeylambda_stats.py +85 -0
- scipy/stats/tests/test_variation.py +216 -0
- scipy/version.py +12 -0
- scipy-1.16.2.dist-info/DELVEWHEEL +2 -0
- scipy-1.16.2.dist-info/LICENSE.txt +912 -0
- scipy-1.16.2.dist-info/METADATA +1061 -0
- scipy-1.16.2.dist-info/RECORD +1530 -0
- scipy-1.16.2.dist-info/WHEEL +4 -0
- scipy.libs/msvcp140-5f1c5dd31916990d94181e07bc3afb32.dll +0 -0
- scipy.libs/scipy_openblas-f3ac85b1f412f7e86514c923dc4058d1.dll +0 -0
scipy/special/_basic.py
ADDED
@@ -0,0 +1,3576 @@
|
|
1
|
+
#
|
2
|
+
# Author: Travis Oliphant, 2002
|
3
|
+
#
|
4
|
+
|
5
|
+
import numpy as np
|
6
|
+
import math
|
7
|
+
import warnings
|
8
|
+
from collections import defaultdict
|
9
|
+
from heapq import heapify, heappop
|
10
|
+
from numpy import (pi, asarray, floor, isscalar, sqrt, where,
|
11
|
+
sin, place, issubdtype, extract, inexact, nan, zeros, sinc)
|
12
|
+
|
13
|
+
from . import _ufuncs
|
14
|
+
from ._ufuncs import (mathieu_a, mathieu_b, iv, jv, gamma, rgamma,
|
15
|
+
psi, hankel1, hankel2, yv, kv, poch, binom,
|
16
|
+
_stirling2_inexact)
|
17
|
+
|
18
|
+
from ._gufuncs import _lqn, _lqmn, _rctj, _rcty
|
19
|
+
from ._input_validation import _nonneg_int_or_fail
|
20
|
+
from . import _specfun
|
21
|
+
from ._comb import _comb_int
|
22
|
+
from ._multiufuncs import (assoc_legendre_p_all,
|
23
|
+
legendre_p_all)
|
24
|
+
from scipy._lib.deprecation import _deprecated
|
25
|
+
|
26
|
+
|
27
|
+
__all__ = [
|
28
|
+
'ai_zeros',
|
29
|
+
'assoc_laguerre',
|
30
|
+
'bei_zeros',
|
31
|
+
'beip_zeros',
|
32
|
+
'ber_zeros',
|
33
|
+
'bernoulli',
|
34
|
+
'berp_zeros',
|
35
|
+
'bi_zeros',
|
36
|
+
'clpmn',
|
37
|
+
'comb',
|
38
|
+
'digamma',
|
39
|
+
'diric',
|
40
|
+
'erf_zeros',
|
41
|
+
'euler',
|
42
|
+
'factorial',
|
43
|
+
'factorial2',
|
44
|
+
'factorialk',
|
45
|
+
'fresnel_zeros',
|
46
|
+
'fresnelc_zeros',
|
47
|
+
'fresnels_zeros',
|
48
|
+
'h1vp',
|
49
|
+
'h2vp',
|
50
|
+
'ivp',
|
51
|
+
'jn_zeros',
|
52
|
+
'jnjnp_zeros',
|
53
|
+
'jnp_zeros',
|
54
|
+
'jnyn_zeros',
|
55
|
+
'jvp',
|
56
|
+
'kei_zeros',
|
57
|
+
'keip_zeros',
|
58
|
+
'kelvin_zeros',
|
59
|
+
'ker_zeros',
|
60
|
+
'kerp_zeros',
|
61
|
+
'kvp',
|
62
|
+
'lmbda',
|
63
|
+
'lpmn',
|
64
|
+
'lpn',
|
65
|
+
'lqmn',
|
66
|
+
'lqn',
|
67
|
+
'mathieu_even_coef',
|
68
|
+
'mathieu_odd_coef',
|
69
|
+
'obl_cv_seq',
|
70
|
+
'pbdn_seq',
|
71
|
+
'pbdv_seq',
|
72
|
+
'pbvv_seq',
|
73
|
+
'perm',
|
74
|
+
'polygamma',
|
75
|
+
'pro_cv_seq',
|
76
|
+
'riccati_jn',
|
77
|
+
'riccati_yn',
|
78
|
+
'sinc',
|
79
|
+
'softplus',
|
80
|
+
'stirling2',
|
81
|
+
'y0_zeros',
|
82
|
+
'y1_zeros',
|
83
|
+
'y1p_zeros',
|
84
|
+
'yn_zeros',
|
85
|
+
'ynp_zeros',
|
86
|
+
'yvp',
|
87
|
+
'zeta'
|
88
|
+
]
|
89
|
+
|
90
|
+
|
91
|
+
__DEPRECATION_MSG_1_15 = (
|
92
|
+
"`scipy.special.{}` is deprecated as of SciPy 1.15.0 and will be "
|
93
|
+
"removed in SciPy 1.17.0. Please use `scipy.special.{}` instead."
|
94
|
+
)
|
95
|
+
|
96
|
+
# mapping k to last n such that factorialk(n, k) < np.iinfo(np.int64).max
|
97
|
+
_FACTORIALK_LIMITS_64BITS = {1: 20, 2: 33, 3: 44, 4: 54, 5: 65,
|
98
|
+
6: 74, 7: 84, 8: 93, 9: 101}
|
99
|
+
# mapping k to last n such that factorialk(n, k) < np.iinfo(np.int32).max
|
100
|
+
_FACTORIALK_LIMITS_32BITS = {1: 12, 2: 19, 3: 25, 4: 31, 5: 37,
|
101
|
+
6: 43, 7: 47, 8: 51, 9: 56}
|
102
|
+
|
103
|
+
|
104
|
+
def diric(x, n):
|
105
|
+
"""Periodic sinc function, also called the Dirichlet function.
|
106
|
+
|
107
|
+
The Dirichlet function is defined as::
|
108
|
+
|
109
|
+
diric(x, n) = sin(x * n/2) / (n * sin(x / 2)),
|
110
|
+
|
111
|
+
where `n` is a positive integer.
|
112
|
+
|
113
|
+
Parameters
|
114
|
+
----------
|
115
|
+
x : array_like
|
116
|
+
Input data
|
117
|
+
n : int
|
118
|
+
Integer defining the periodicity.
|
119
|
+
|
120
|
+
Returns
|
121
|
+
-------
|
122
|
+
diric : ndarray
|
123
|
+
|
124
|
+
Examples
|
125
|
+
--------
|
126
|
+
>>> import numpy as np
|
127
|
+
>>> from scipy import special
|
128
|
+
>>> import matplotlib.pyplot as plt
|
129
|
+
|
130
|
+
>>> x = np.linspace(-8*np.pi, 8*np.pi, num=201)
|
131
|
+
>>> plt.figure(figsize=(8, 8));
|
132
|
+
>>> for idx, n in enumerate([2, 3, 4, 9]):
|
133
|
+
... plt.subplot(2, 2, idx+1)
|
134
|
+
... plt.plot(x, special.diric(x, n))
|
135
|
+
... plt.title('diric, n={}'.format(n))
|
136
|
+
>>> plt.show()
|
137
|
+
|
138
|
+
The following example demonstrates that `diric` gives the magnitudes
|
139
|
+
(modulo the sign and scaling) of the Fourier coefficients of a
|
140
|
+
rectangular pulse.
|
141
|
+
|
142
|
+
Suppress output of values that are effectively 0:
|
143
|
+
|
144
|
+
>>> np.set_printoptions(suppress=True)
|
145
|
+
|
146
|
+
Create a signal `x` of length `m` with `k` ones:
|
147
|
+
|
148
|
+
>>> m = 8
|
149
|
+
>>> k = 3
|
150
|
+
>>> x = np.zeros(m)
|
151
|
+
>>> x[:k] = 1
|
152
|
+
|
153
|
+
Use the FFT to compute the Fourier transform of `x`, and
|
154
|
+
inspect the magnitudes of the coefficients:
|
155
|
+
|
156
|
+
>>> np.abs(np.fft.fft(x))
|
157
|
+
array([ 3. , 2.41421356, 1. , 0.41421356, 1. ,
|
158
|
+
0.41421356, 1. , 2.41421356])
|
159
|
+
|
160
|
+
Now find the same values (up to sign) using `diric`. We multiply
|
161
|
+
by `k` to account for the different scaling conventions of
|
162
|
+
`numpy.fft.fft` and `diric`:
|
163
|
+
|
164
|
+
>>> theta = np.linspace(0, 2*np.pi, m, endpoint=False)
|
165
|
+
>>> k * special.diric(theta, k)
|
166
|
+
array([ 3. , 2.41421356, 1. , -0.41421356, -1. ,
|
167
|
+
-0.41421356, 1. , 2.41421356])
|
168
|
+
"""
|
169
|
+
x, n = asarray(x), asarray(n)
|
170
|
+
n = asarray(n + (x-x))
|
171
|
+
x = asarray(x + (n-n))
|
172
|
+
if issubdtype(x.dtype, inexact):
|
173
|
+
ytype = x.dtype
|
174
|
+
else:
|
175
|
+
ytype = float
|
176
|
+
y = zeros(x.shape, ytype)
|
177
|
+
|
178
|
+
# empirical minval for 32, 64 or 128 bit float computations
|
179
|
+
# where sin(x/2) < minval, result is fixed at +1 or -1
|
180
|
+
if np.finfo(ytype).eps < 1e-18:
|
181
|
+
minval = 1e-11
|
182
|
+
elif np.finfo(ytype).eps < 1e-15:
|
183
|
+
minval = 1e-7
|
184
|
+
else:
|
185
|
+
minval = 1e-3
|
186
|
+
|
187
|
+
mask1 = (n <= 0) | (n != floor(n))
|
188
|
+
place(y, mask1, nan)
|
189
|
+
|
190
|
+
x = x / 2
|
191
|
+
denom = sin(x)
|
192
|
+
mask2 = (1-mask1) & (abs(denom) < minval)
|
193
|
+
xsub = extract(mask2, x)
|
194
|
+
nsub = extract(mask2, n)
|
195
|
+
zsub = xsub / pi
|
196
|
+
place(y, mask2, pow(-1, np.round(zsub)*(nsub-1)))
|
197
|
+
|
198
|
+
mask = (1-mask1) & (1-mask2)
|
199
|
+
xsub = extract(mask, x)
|
200
|
+
nsub = extract(mask, n)
|
201
|
+
dsub = extract(mask, denom)
|
202
|
+
place(y, mask, sin(nsub*xsub)/(nsub*dsub))
|
203
|
+
return y
|
204
|
+
|
205
|
+
|
206
|
+
def jnjnp_zeros(nt):
|
207
|
+
"""Compute zeros of integer-order Bessel functions Jn and Jn'.
|
208
|
+
|
209
|
+
Results are arranged in order of the magnitudes of the zeros.
|
210
|
+
|
211
|
+
Parameters
|
212
|
+
----------
|
213
|
+
nt : int
|
214
|
+
Number (<=1200) of zeros to compute
|
215
|
+
|
216
|
+
Returns
|
217
|
+
-------
|
218
|
+
zo[l-1] : ndarray
|
219
|
+
Value of the lth zero of Jn(x) and Jn'(x). Of length `nt`.
|
220
|
+
n[l-1] : ndarray
|
221
|
+
Order of the Jn(x) or Jn'(x) associated with lth zero. Of length `nt`.
|
222
|
+
m[l-1] : ndarray
|
223
|
+
Serial number of the zeros of Jn(x) or Jn'(x) associated
|
224
|
+
with lth zero. Of length `nt`.
|
225
|
+
t[l-1] : ndarray
|
226
|
+
0 if lth zero in zo is zero of Jn(x), 1 if it is a zero of Jn'(x). Of
|
227
|
+
length `nt`.
|
228
|
+
|
229
|
+
See Also
|
230
|
+
--------
|
231
|
+
jn_zeros, jnp_zeros : to get separated arrays of zeros.
|
232
|
+
|
233
|
+
References
|
234
|
+
----------
|
235
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
236
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
237
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
238
|
+
|
239
|
+
"""
|
240
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt > 1200):
|
241
|
+
raise ValueError("Number must be integer <= 1200.")
|
242
|
+
nt = int(nt)
|
243
|
+
n, m, t, zo = _specfun.jdzo(nt)
|
244
|
+
return zo[1:nt+1], n[:nt], m[:nt], t[:nt]
|
245
|
+
|
246
|
+
|
247
|
+
def jnyn_zeros(n, nt):
|
248
|
+
"""Compute nt zeros of Bessel functions Jn(x), Jn'(x), Yn(x), and Yn'(x).
|
249
|
+
|
250
|
+
Returns 4 arrays of length `nt`, corresponding to the first `nt`
|
251
|
+
zeros of Jn(x), Jn'(x), Yn(x), and Yn'(x), respectively. The zeros
|
252
|
+
are returned in ascending order.
|
253
|
+
|
254
|
+
Parameters
|
255
|
+
----------
|
256
|
+
n : int
|
257
|
+
Order of the Bessel functions
|
258
|
+
nt : int
|
259
|
+
Number (<=1200) of zeros to compute
|
260
|
+
|
261
|
+
Returns
|
262
|
+
-------
|
263
|
+
Jn : ndarray
|
264
|
+
First `nt` zeros of Jn
|
265
|
+
Jnp : ndarray
|
266
|
+
First `nt` zeros of Jn'
|
267
|
+
Yn : ndarray
|
268
|
+
First `nt` zeros of Yn
|
269
|
+
Ynp : ndarray
|
270
|
+
First `nt` zeros of Yn'
|
271
|
+
|
272
|
+
See Also
|
273
|
+
--------
|
274
|
+
jn_zeros, jnp_zeros, yn_zeros, ynp_zeros
|
275
|
+
|
276
|
+
References
|
277
|
+
----------
|
278
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
279
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
280
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
281
|
+
|
282
|
+
Examples
|
283
|
+
--------
|
284
|
+
Compute the first three roots of :math:`J_1`, :math:`J_1'`,
|
285
|
+
:math:`Y_1` and :math:`Y_1'`.
|
286
|
+
|
287
|
+
>>> from scipy.special import jnyn_zeros
|
288
|
+
>>> jn_roots, jnp_roots, yn_roots, ynp_roots = jnyn_zeros(1, 3)
|
289
|
+
>>> jn_roots, yn_roots
|
290
|
+
(array([ 3.83170597, 7.01558667, 10.17346814]),
|
291
|
+
array([2.19714133, 5.42968104, 8.59600587]))
|
292
|
+
|
293
|
+
Plot :math:`J_1`, :math:`J_1'`, :math:`Y_1`, :math:`Y_1'` and their roots.
|
294
|
+
|
295
|
+
>>> import numpy as np
|
296
|
+
>>> import matplotlib.pyplot as plt
|
297
|
+
>>> from scipy.special import jnyn_zeros, jvp, jn, yvp, yn
|
298
|
+
>>> jn_roots, jnp_roots, yn_roots, ynp_roots = jnyn_zeros(1, 3)
|
299
|
+
>>> fig, ax = plt.subplots()
|
300
|
+
>>> xmax= 11
|
301
|
+
>>> x = np.linspace(0, xmax)
|
302
|
+
>>> x[0] += 1e-15
|
303
|
+
>>> ax.plot(x, jn(1, x), label=r"$J_1$", c='r')
|
304
|
+
>>> ax.plot(x, jvp(1, x, 1), label=r"$J_1'$", c='b')
|
305
|
+
>>> ax.plot(x, yn(1, x), label=r"$Y_1$", c='y')
|
306
|
+
>>> ax.plot(x, yvp(1, x, 1), label=r"$Y_1'$", c='c')
|
307
|
+
>>> zeros = np.zeros((3, ))
|
308
|
+
>>> ax.scatter(jn_roots, zeros, s=30, c='r', zorder=5,
|
309
|
+
... label=r"$J_1$ roots")
|
310
|
+
>>> ax.scatter(jnp_roots, zeros, s=30, c='b', zorder=5,
|
311
|
+
... label=r"$J_1'$ roots")
|
312
|
+
>>> ax.scatter(yn_roots, zeros, s=30, c='y', zorder=5,
|
313
|
+
... label=r"$Y_1$ roots")
|
314
|
+
>>> ax.scatter(ynp_roots, zeros, s=30, c='c', zorder=5,
|
315
|
+
... label=r"$Y_1'$ roots")
|
316
|
+
>>> ax.hlines(0, 0, xmax, color='k')
|
317
|
+
>>> ax.set_ylim(-0.6, 0.6)
|
318
|
+
>>> ax.set_xlim(0, xmax)
|
319
|
+
>>> ax.legend(ncol=2, bbox_to_anchor=(1., 0.75))
|
320
|
+
>>> plt.tight_layout()
|
321
|
+
>>> plt.show()
|
322
|
+
"""
|
323
|
+
if not (isscalar(nt) and isscalar(n)):
|
324
|
+
raise ValueError("Arguments must be scalars.")
|
325
|
+
if (floor(n) != n) or (floor(nt) != nt):
|
326
|
+
raise ValueError("Arguments must be integers.")
|
327
|
+
if (nt <= 0):
|
328
|
+
raise ValueError("nt > 0")
|
329
|
+
return _specfun.jyzo(abs(n), nt)
|
330
|
+
|
331
|
+
|
332
|
+
def jn_zeros(n, nt):
|
333
|
+
r"""Compute zeros of integer-order Bessel functions Jn.
|
334
|
+
|
335
|
+
Compute `nt` zeros of the Bessel functions :math:`J_n(x)` on the
|
336
|
+
interval :math:`(0, \infty)`. The zeros are returned in ascending
|
337
|
+
order. Note that this interval excludes the zero at :math:`x = 0`
|
338
|
+
that exists for :math:`n > 0`.
|
339
|
+
|
340
|
+
Parameters
|
341
|
+
----------
|
342
|
+
n : int
|
343
|
+
Order of Bessel function
|
344
|
+
nt : int
|
345
|
+
Number of zeros to return
|
346
|
+
|
347
|
+
Returns
|
348
|
+
-------
|
349
|
+
ndarray
|
350
|
+
First `nt` zeros of the Bessel function.
|
351
|
+
|
352
|
+
See Also
|
353
|
+
--------
|
354
|
+
jv: Real-order Bessel functions of the first kind
|
355
|
+
jnp_zeros: Zeros of :math:`Jn'`
|
356
|
+
|
357
|
+
References
|
358
|
+
----------
|
359
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
360
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
361
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
362
|
+
|
363
|
+
Examples
|
364
|
+
--------
|
365
|
+
Compute the first four positive roots of :math:`J_3`.
|
366
|
+
|
367
|
+
>>> from scipy.special import jn_zeros
|
368
|
+
>>> jn_zeros(3, 4)
|
369
|
+
array([ 6.3801619 , 9.76102313, 13.01520072, 16.22346616])
|
370
|
+
|
371
|
+
Plot :math:`J_3` and its first four positive roots. Note
|
372
|
+
that the root located at 0 is not returned by `jn_zeros`.
|
373
|
+
|
374
|
+
>>> import numpy as np
|
375
|
+
>>> import matplotlib.pyplot as plt
|
376
|
+
>>> from scipy.special import jn, jn_zeros
|
377
|
+
>>> j3_roots = jn_zeros(3, 4)
|
378
|
+
>>> xmax = 18
|
379
|
+
>>> xmin = -1
|
380
|
+
>>> x = np.linspace(xmin, xmax, 500)
|
381
|
+
>>> fig, ax = plt.subplots()
|
382
|
+
>>> ax.plot(x, jn(3, x), label=r'$J_3$')
|
383
|
+
>>> ax.scatter(j3_roots, np.zeros((4, )), s=30, c='r',
|
384
|
+
... label=r"$J_3$_Zeros", zorder=5)
|
385
|
+
>>> ax.scatter(0, 0, s=30, c='k',
|
386
|
+
... label=r"Root at 0", zorder=5)
|
387
|
+
>>> ax.hlines(0, 0, xmax, color='k')
|
388
|
+
>>> ax.set_xlim(xmin, xmax)
|
389
|
+
>>> plt.legend()
|
390
|
+
>>> plt.show()
|
391
|
+
"""
|
392
|
+
return jnyn_zeros(n, nt)[0]
|
393
|
+
|
394
|
+
|
395
|
+
def jnp_zeros(n, nt):
|
396
|
+
r"""Compute zeros of integer-order Bessel function derivatives Jn'.
|
397
|
+
|
398
|
+
Compute `nt` zeros of the functions :math:`J_n'(x)` on the
|
399
|
+
interval :math:`(0, \infty)`. The zeros are returned in ascending
|
400
|
+
order. Note that this interval excludes the zero at :math:`x = 0`
|
401
|
+
that exists for :math:`n > 1`.
|
402
|
+
|
403
|
+
Parameters
|
404
|
+
----------
|
405
|
+
n : int
|
406
|
+
Order of Bessel function
|
407
|
+
nt : int
|
408
|
+
Number of zeros to return
|
409
|
+
|
410
|
+
Returns
|
411
|
+
-------
|
412
|
+
ndarray
|
413
|
+
First `nt` zeros of the Bessel function.
|
414
|
+
|
415
|
+
See Also
|
416
|
+
--------
|
417
|
+
jvp: Derivatives of integer-order Bessel functions of the first kind
|
418
|
+
jv: Float-order Bessel functions of the first kind
|
419
|
+
|
420
|
+
References
|
421
|
+
----------
|
422
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
423
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
424
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
425
|
+
|
426
|
+
Examples
|
427
|
+
--------
|
428
|
+
Compute the first four roots of :math:`J_2'`.
|
429
|
+
|
430
|
+
>>> from scipy.special import jnp_zeros
|
431
|
+
>>> jnp_zeros(2, 4)
|
432
|
+
array([ 3.05423693, 6.70613319, 9.96946782, 13.17037086])
|
433
|
+
|
434
|
+
As `jnp_zeros` yields the roots of :math:`J_n'`, it can be used to
|
435
|
+
compute the locations of the peaks of :math:`J_n`. Plot
|
436
|
+
:math:`J_2`, :math:`J_2'` and the locations of the roots of :math:`J_2'`.
|
437
|
+
|
438
|
+
>>> import numpy as np
|
439
|
+
>>> import matplotlib.pyplot as plt
|
440
|
+
>>> from scipy.special import jn, jnp_zeros, jvp
|
441
|
+
>>> j2_roots = jnp_zeros(2, 4)
|
442
|
+
>>> xmax = 15
|
443
|
+
>>> x = np.linspace(0, xmax, 500)
|
444
|
+
>>> fig, ax = plt.subplots()
|
445
|
+
>>> ax.plot(x, jn(2, x), label=r'$J_2$')
|
446
|
+
>>> ax.plot(x, jvp(2, x, 1), label=r"$J_2'$")
|
447
|
+
>>> ax.hlines(0, 0, xmax, color='k')
|
448
|
+
>>> ax.scatter(j2_roots, np.zeros((4, )), s=30, c='r',
|
449
|
+
... label=r"Roots of $J_2'$", zorder=5)
|
450
|
+
>>> ax.set_ylim(-0.4, 0.8)
|
451
|
+
>>> ax.set_xlim(0, xmax)
|
452
|
+
>>> plt.legend()
|
453
|
+
>>> plt.show()
|
454
|
+
"""
|
455
|
+
return jnyn_zeros(n, nt)[1]
|
456
|
+
|
457
|
+
|
458
|
+
def yn_zeros(n, nt):
|
459
|
+
r"""Compute zeros of integer-order Bessel function Yn(x).
|
460
|
+
|
461
|
+
Compute `nt` zeros of the functions :math:`Y_n(x)` on the interval
|
462
|
+
:math:`(0, \infty)`. The zeros are returned in ascending order.
|
463
|
+
|
464
|
+
Parameters
|
465
|
+
----------
|
466
|
+
n : int
|
467
|
+
Order of Bessel function
|
468
|
+
nt : int
|
469
|
+
Number of zeros to return
|
470
|
+
|
471
|
+
Returns
|
472
|
+
-------
|
473
|
+
ndarray
|
474
|
+
First `nt` zeros of the Bessel function.
|
475
|
+
|
476
|
+
See Also
|
477
|
+
--------
|
478
|
+
yn: Bessel function of the second kind for integer order
|
479
|
+
yv: Bessel function of the second kind for real order
|
480
|
+
|
481
|
+
References
|
482
|
+
----------
|
483
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
484
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
485
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
486
|
+
|
487
|
+
Examples
|
488
|
+
--------
|
489
|
+
Compute the first four roots of :math:`Y_2`.
|
490
|
+
|
491
|
+
>>> from scipy.special import yn_zeros
|
492
|
+
>>> yn_zeros(2, 4)
|
493
|
+
array([ 3.38424177, 6.79380751, 10.02347798, 13.20998671])
|
494
|
+
|
495
|
+
Plot :math:`Y_2` and its first four roots.
|
496
|
+
|
497
|
+
>>> import numpy as np
|
498
|
+
>>> import matplotlib.pyplot as plt
|
499
|
+
>>> from scipy.special import yn, yn_zeros
|
500
|
+
>>> xmin = 2
|
501
|
+
>>> xmax = 15
|
502
|
+
>>> x = np.linspace(xmin, xmax, 500)
|
503
|
+
>>> fig, ax = plt.subplots()
|
504
|
+
>>> ax.hlines(0, xmin, xmax, color='k')
|
505
|
+
>>> ax.plot(x, yn(2, x), label=r'$Y_2$')
|
506
|
+
>>> ax.scatter(yn_zeros(2, 4), np.zeros((4, )), s=30, c='r',
|
507
|
+
... label='Roots', zorder=5)
|
508
|
+
>>> ax.set_ylim(-0.4, 0.4)
|
509
|
+
>>> ax.set_xlim(xmin, xmax)
|
510
|
+
>>> plt.legend()
|
511
|
+
>>> plt.show()
|
512
|
+
"""
|
513
|
+
return jnyn_zeros(n, nt)[2]
|
514
|
+
|
515
|
+
|
516
|
+
def ynp_zeros(n, nt):
|
517
|
+
r"""Compute zeros of integer-order Bessel function derivatives Yn'(x).
|
518
|
+
|
519
|
+
Compute `nt` zeros of the functions :math:`Y_n'(x)` on the
|
520
|
+
interval :math:`(0, \infty)`. The zeros are returned in ascending
|
521
|
+
order.
|
522
|
+
|
523
|
+
Parameters
|
524
|
+
----------
|
525
|
+
n : int
|
526
|
+
Order of Bessel function
|
527
|
+
nt : int
|
528
|
+
Number of zeros to return
|
529
|
+
|
530
|
+
Returns
|
531
|
+
-------
|
532
|
+
ndarray
|
533
|
+
First `nt` zeros of the Bessel derivative function.
|
534
|
+
|
535
|
+
|
536
|
+
See Also
|
537
|
+
--------
|
538
|
+
yvp
|
539
|
+
|
540
|
+
References
|
541
|
+
----------
|
542
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
543
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
544
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
545
|
+
|
546
|
+
Examples
|
547
|
+
--------
|
548
|
+
Compute the first four roots of the first derivative of the
|
549
|
+
Bessel function of second kind for order 0 :math:`Y_0'`.
|
550
|
+
|
551
|
+
>>> from scipy.special import ynp_zeros
|
552
|
+
>>> ynp_zeros(0, 4)
|
553
|
+
array([ 2.19714133, 5.42968104, 8.59600587, 11.74915483])
|
554
|
+
|
555
|
+
Plot :math:`Y_0`, :math:`Y_0'` and confirm visually that the roots of
|
556
|
+
:math:`Y_0'` are located at local extrema of :math:`Y_0`.
|
557
|
+
|
558
|
+
>>> import numpy as np
|
559
|
+
>>> import matplotlib.pyplot as plt
|
560
|
+
>>> from scipy.special import yn, ynp_zeros, yvp
|
561
|
+
>>> zeros = ynp_zeros(0, 4)
|
562
|
+
>>> xmax = 13
|
563
|
+
>>> x = np.linspace(0, xmax, 500)
|
564
|
+
>>> fig, ax = plt.subplots()
|
565
|
+
>>> ax.plot(x, yn(0, x), label=r'$Y_0$')
|
566
|
+
>>> ax.plot(x, yvp(0, x, 1), label=r"$Y_0'$")
|
567
|
+
>>> ax.scatter(zeros, np.zeros((4, )), s=30, c='r',
|
568
|
+
... label=r"Roots of $Y_0'$", zorder=5)
|
569
|
+
>>> for root in zeros:
|
570
|
+
... y0_extremum = yn(0, root)
|
571
|
+
... lower = min(0, y0_extremum)
|
572
|
+
... upper = max(0, y0_extremum)
|
573
|
+
... ax.vlines(root, lower, upper, color='r')
|
574
|
+
>>> ax.hlines(0, 0, xmax, color='k')
|
575
|
+
>>> ax.set_ylim(-0.6, 0.6)
|
576
|
+
>>> ax.set_xlim(0, xmax)
|
577
|
+
>>> plt.legend()
|
578
|
+
>>> plt.show()
|
579
|
+
"""
|
580
|
+
return jnyn_zeros(n, nt)[3]
|
581
|
+
|
582
|
+
|
583
|
+
def y0_zeros(nt, complex=False):
|
584
|
+
"""Compute nt zeros of Bessel function Y0(z), and derivative at each zero.
|
585
|
+
|
586
|
+
The derivatives are given by Y0'(z0) = -Y1(z0) at each zero z0.
|
587
|
+
|
588
|
+
Parameters
|
589
|
+
----------
|
590
|
+
nt : int
|
591
|
+
Number of zeros to return
|
592
|
+
complex : bool, default False
|
593
|
+
Set to False to return only the real zeros; set to True to return only
|
594
|
+
the complex zeros with negative real part and positive imaginary part.
|
595
|
+
Note that the complex conjugates of the latter are also zeros of the
|
596
|
+
function, but are not returned by this routine.
|
597
|
+
|
598
|
+
Returns
|
599
|
+
-------
|
600
|
+
z0n : ndarray
|
601
|
+
Location of nth zero of Y0(z)
|
602
|
+
y0pz0n : ndarray
|
603
|
+
Value of derivative Y0'(z0) for nth zero
|
604
|
+
|
605
|
+
References
|
606
|
+
----------
|
607
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
608
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
609
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
610
|
+
|
611
|
+
Examples
|
612
|
+
--------
|
613
|
+
Compute the first 4 real roots and the derivatives at the roots of
|
614
|
+
:math:`Y_0`:
|
615
|
+
|
616
|
+
>>> import numpy as np
|
617
|
+
>>> from scipy.special import y0_zeros
|
618
|
+
>>> zeros, grads = y0_zeros(4)
|
619
|
+
>>> with np.printoptions(precision=5):
|
620
|
+
... print(f"Roots: {zeros}")
|
621
|
+
... print(f"Gradients: {grads}")
|
622
|
+
Roots: [ 0.89358+0.j 3.95768+0.j 7.08605+0.j 10.22235+0.j]
|
623
|
+
Gradients: [-0.87942+0.j 0.40254+0.j -0.3001 +0.j 0.2497 +0.j]
|
624
|
+
|
625
|
+
Plot the real part of :math:`Y_0` and the first four computed roots.
|
626
|
+
|
627
|
+
>>> import matplotlib.pyplot as plt
|
628
|
+
>>> from scipy.special import y0
|
629
|
+
>>> xmin = 0
|
630
|
+
>>> xmax = 11
|
631
|
+
>>> x = np.linspace(xmin, xmax, 500)
|
632
|
+
>>> fig, ax = plt.subplots()
|
633
|
+
>>> ax.hlines(0, xmin, xmax, color='k')
|
634
|
+
>>> ax.plot(x, y0(x), label=r'$Y_0$')
|
635
|
+
>>> zeros, grads = y0_zeros(4)
|
636
|
+
>>> ax.scatter(zeros.real, np.zeros((4, )), s=30, c='r',
|
637
|
+
... label=r'$Y_0$_zeros', zorder=5)
|
638
|
+
>>> ax.set_ylim(-0.5, 0.6)
|
639
|
+
>>> ax.set_xlim(xmin, xmax)
|
640
|
+
>>> plt.legend(ncol=2)
|
641
|
+
>>> plt.show()
|
642
|
+
|
643
|
+
Compute the first 4 complex roots and the derivatives at the roots of
|
644
|
+
:math:`Y_0` by setting ``complex=True``:
|
645
|
+
|
646
|
+
>>> y0_zeros(4, True)
|
647
|
+
(array([ -2.40301663+0.53988231j, -5.5198767 +0.54718001j,
|
648
|
+
-8.6536724 +0.54841207j, -11.79151203+0.54881912j]),
|
649
|
+
array([ 0.10074769-0.88196771j, -0.02924642+0.5871695j ,
|
650
|
+
0.01490806-0.46945875j, -0.00937368+0.40230454j]))
|
651
|
+
"""
|
652
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
653
|
+
raise ValueError("Arguments must be scalar positive integer.")
|
654
|
+
kf = 0
|
655
|
+
kc = not complex
|
656
|
+
return _specfun.cyzo(nt, kf, kc)
|
657
|
+
|
658
|
+
|
659
|
+
def y1_zeros(nt, complex=False):
|
660
|
+
"""Compute nt zeros of Bessel function Y1(z), and derivative at each zero.
|
661
|
+
|
662
|
+
The derivatives are given by Y1'(z1) = Y0(z1) at each zero z1.
|
663
|
+
|
664
|
+
Parameters
|
665
|
+
----------
|
666
|
+
nt : int
|
667
|
+
Number of zeros to return
|
668
|
+
complex : bool, default False
|
669
|
+
Set to False to return only the real zeros; set to True to return only
|
670
|
+
the complex zeros with negative real part and positive imaginary part.
|
671
|
+
Note that the complex conjugates of the latter are also zeros of the
|
672
|
+
function, but are not returned by this routine.
|
673
|
+
|
674
|
+
Returns
|
675
|
+
-------
|
676
|
+
z1n : ndarray
|
677
|
+
Location of nth zero of Y1(z)
|
678
|
+
y1pz1n : ndarray
|
679
|
+
Value of derivative Y1'(z1) for nth zero
|
680
|
+
|
681
|
+
References
|
682
|
+
----------
|
683
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
684
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
685
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
686
|
+
|
687
|
+
Examples
|
688
|
+
--------
|
689
|
+
Compute the first 4 real roots and the derivatives at the roots of
|
690
|
+
:math:`Y_1`:
|
691
|
+
|
692
|
+
>>> import numpy as np
|
693
|
+
>>> from scipy.special import y1_zeros
|
694
|
+
>>> zeros, grads = y1_zeros(4)
|
695
|
+
>>> with np.printoptions(precision=5):
|
696
|
+
... print(f"Roots: {zeros}")
|
697
|
+
... print(f"Gradients: {grads}")
|
698
|
+
Roots: [ 2.19714+0.j 5.42968+0.j 8.59601+0.j 11.74915+0.j]
|
699
|
+
Gradients: [ 0.52079+0.j -0.34032+0.j 0.27146+0.j -0.23246+0.j]
|
700
|
+
|
701
|
+
Extract the real parts:
|
702
|
+
|
703
|
+
>>> realzeros = zeros.real
|
704
|
+
>>> realzeros
|
705
|
+
array([ 2.19714133, 5.42968104, 8.59600587, 11.74915483])
|
706
|
+
|
707
|
+
Plot :math:`Y_1` and the first four computed roots.
|
708
|
+
|
709
|
+
>>> import matplotlib.pyplot as plt
|
710
|
+
>>> from scipy.special import y1
|
711
|
+
>>> xmin = 0
|
712
|
+
>>> xmax = 13
|
713
|
+
>>> x = np.linspace(xmin, xmax, 500)
|
714
|
+
>>> zeros, grads = y1_zeros(4)
|
715
|
+
>>> fig, ax = plt.subplots()
|
716
|
+
>>> ax.hlines(0, xmin, xmax, color='k')
|
717
|
+
>>> ax.plot(x, y1(x), label=r'$Y_1$')
|
718
|
+
>>> ax.scatter(zeros.real, np.zeros((4, )), s=30, c='r',
|
719
|
+
... label=r'$Y_1$_zeros', zorder=5)
|
720
|
+
>>> ax.set_ylim(-0.5, 0.5)
|
721
|
+
>>> ax.set_xlim(xmin, xmax)
|
722
|
+
>>> plt.legend()
|
723
|
+
>>> plt.show()
|
724
|
+
|
725
|
+
Compute the first 4 complex roots and the derivatives at the roots of
|
726
|
+
:math:`Y_1` by setting ``complex=True``:
|
727
|
+
|
728
|
+
>>> y1_zeros(4, True)
|
729
|
+
(array([ -0.50274327+0.78624371j, -3.83353519+0.56235654j,
|
730
|
+
-7.01590368+0.55339305j, -10.17357383+0.55127339j]),
|
731
|
+
array([-0.45952768+1.31710194j, 0.04830191-0.69251288j,
|
732
|
+
-0.02012695+0.51864253j, 0.011614 -0.43203296j]))
|
733
|
+
"""
|
734
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
735
|
+
raise ValueError("Arguments must be scalar positive integer.")
|
736
|
+
kf = 1
|
737
|
+
kc = not complex
|
738
|
+
return _specfun.cyzo(nt, kf, kc)
|
739
|
+
|
740
|
+
|
741
|
+
def y1p_zeros(nt, complex=False):
|
742
|
+
"""Compute nt zeros of Bessel derivative Y1'(z), and value at each zero.
|
743
|
+
|
744
|
+
The values are given by Y1(z1) at each z1 where Y1'(z1)=0.
|
745
|
+
|
746
|
+
Parameters
|
747
|
+
----------
|
748
|
+
nt : int
|
749
|
+
Number of zeros to return
|
750
|
+
complex : bool, default False
|
751
|
+
Set to False to return only the real zeros; set to True to return only
|
752
|
+
the complex zeros with negative real part and positive imaginary part.
|
753
|
+
Note that the complex conjugates of the latter are also zeros of the
|
754
|
+
function, but are not returned by this routine.
|
755
|
+
|
756
|
+
Returns
|
757
|
+
-------
|
758
|
+
z1pn : ndarray
|
759
|
+
Location of nth zero of Y1'(z)
|
760
|
+
y1z1pn : ndarray
|
761
|
+
Value of derivative Y1(z1) for nth zero
|
762
|
+
|
763
|
+
References
|
764
|
+
----------
|
765
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
766
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
767
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
768
|
+
|
769
|
+
Examples
|
770
|
+
--------
|
771
|
+
Compute the first four roots of :math:`Y_1'` and the values of
|
772
|
+
:math:`Y_1` at these roots.
|
773
|
+
|
774
|
+
>>> import numpy as np
|
775
|
+
>>> from scipy.special import y1p_zeros
|
776
|
+
>>> y1grad_roots, y1_values = y1p_zeros(4)
|
777
|
+
>>> with np.printoptions(precision=5):
|
778
|
+
... print(f"Y1' Roots: {y1grad_roots.real}")
|
779
|
+
... print(f"Y1 values: {y1_values.real}")
|
780
|
+
Y1' Roots: [ 3.68302 6.9415 10.1234 13.28576]
|
781
|
+
Y1 values: [ 0.41673 -0.30317 0.25091 -0.21897]
|
782
|
+
|
783
|
+
`y1p_zeros` can be used to calculate the extremal points of :math:`Y_1`
|
784
|
+
directly. Here we plot :math:`Y_1` and the first four extrema.
|
785
|
+
|
786
|
+
>>> import matplotlib.pyplot as plt
|
787
|
+
>>> from scipy.special import y1, yvp
|
788
|
+
>>> y1_roots, y1_values_at_roots = y1p_zeros(4)
|
789
|
+
>>> real_roots = y1_roots.real
|
790
|
+
>>> xmax = 15
|
791
|
+
>>> x = np.linspace(0, xmax, 500)
|
792
|
+
>>> x[0] += 1e-15
|
793
|
+
>>> fig, ax = plt.subplots()
|
794
|
+
>>> ax.plot(x, y1(x), label=r'$Y_1$')
|
795
|
+
>>> ax.plot(x, yvp(1, x, 1), label=r"$Y_1'$")
|
796
|
+
>>> ax.scatter(real_roots, np.zeros((4, )), s=30, c='r',
|
797
|
+
... label=r"Roots of $Y_1'$", zorder=5)
|
798
|
+
>>> ax.scatter(real_roots, y1_values_at_roots.real, s=30, c='k',
|
799
|
+
... label=r"Extrema of $Y_1$", zorder=5)
|
800
|
+
>>> ax.hlines(0, 0, xmax, color='k')
|
801
|
+
>>> ax.set_ylim(-0.5, 0.5)
|
802
|
+
>>> ax.set_xlim(0, xmax)
|
803
|
+
>>> ax.legend(ncol=2, bbox_to_anchor=(1., 0.75))
|
804
|
+
>>> plt.tight_layout()
|
805
|
+
>>> plt.show()
|
806
|
+
"""
|
807
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
808
|
+
raise ValueError("Arguments must be scalar positive integer.")
|
809
|
+
kf = 2
|
810
|
+
kc = not complex
|
811
|
+
return _specfun.cyzo(nt, kf, kc)
|
812
|
+
|
813
|
+
|
814
|
+
def _bessel_diff_formula(v, z, n, L, phase):
|
815
|
+
# from AMS55.
|
816
|
+
# L(v, z) = J(v, z), Y(v, z), H1(v, z), H2(v, z), phase = -1
|
817
|
+
# L(v, z) = I(v, z) or exp(v*pi*i)K(v, z), phase = 1
|
818
|
+
# For K, you can pull out the exp((v-k)*pi*i) into the caller
|
819
|
+
v = asarray(v)
|
820
|
+
p = 1.0
|
821
|
+
s = L(v-n, z)
|
822
|
+
for i in range(1, n+1):
|
823
|
+
p = phase * (p * (n-i+1)) / i # = choose(k, i)
|
824
|
+
s += p*L(v-n + i*2, z)
|
825
|
+
return s / (2.**n)
|
826
|
+
|
827
|
+
|
828
|
+
def jvp(v, z, n=1):
|
829
|
+
"""Compute derivatives of Bessel functions of the first kind.
|
830
|
+
|
831
|
+
Compute the nth derivative of the Bessel function `Jv` with
|
832
|
+
respect to `z`.
|
833
|
+
|
834
|
+
Parameters
|
835
|
+
----------
|
836
|
+
v : array_like or float
|
837
|
+
Order of Bessel function
|
838
|
+
z : complex
|
839
|
+
Argument at which to evaluate the derivative; can be real or
|
840
|
+
complex.
|
841
|
+
n : int, default 1
|
842
|
+
Order of derivative. For 0 returns the Bessel function `jv` itself.
|
843
|
+
|
844
|
+
Returns
|
845
|
+
-------
|
846
|
+
scalar or ndarray
|
847
|
+
Values of the derivative of the Bessel function.
|
848
|
+
|
849
|
+
Notes
|
850
|
+
-----
|
851
|
+
The derivative is computed using the relation DLFM 10.6.7 [2]_.
|
852
|
+
|
853
|
+
References
|
854
|
+
----------
|
855
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
856
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
857
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
858
|
+
|
859
|
+
.. [2] NIST Digital Library of Mathematical Functions.
|
860
|
+
https://dlmf.nist.gov/10.6.E7
|
861
|
+
|
862
|
+
Examples
|
863
|
+
--------
|
864
|
+
|
865
|
+
Compute the Bessel function of the first kind of order 0 and
|
866
|
+
its first two derivatives at 1.
|
867
|
+
|
868
|
+
>>> from scipy.special import jvp
|
869
|
+
>>> jvp(0, 1, 0), jvp(0, 1, 1), jvp(0, 1, 2)
|
870
|
+
(0.7651976865579666, -0.44005058574493355, -0.3251471008130331)
|
871
|
+
|
872
|
+
Compute the first derivative of the Bessel function of the first
|
873
|
+
kind for several orders at 1 by providing an array for `v`.
|
874
|
+
|
875
|
+
>>> jvp([0, 1, 2], 1, 1)
|
876
|
+
array([-0.44005059, 0.3251471 , 0.21024362])
|
877
|
+
|
878
|
+
Compute the first derivative of the Bessel function of the first
|
879
|
+
kind of order 0 at several points by providing an array for `z`.
|
880
|
+
|
881
|
+
>>> import numpy as np
|
882
|
+
>>> points = np.array([0., 1.5, 3.])
|
883
|
+
>>> jvp(0, points, 1)
|
884
|
+
array([-0. , -0.55793651, -0.33905896])
|
885
|
+
|
886
|
+
Plot the Bessel function of the first kind of order 1 and its
|
887
|
+
first three derivatives.
|
888
|
+
|
889
|
+
>>> import matplotlib.pyplot as plt
|
890
|
+
>>> x = np.linspace(-10, 10, 1000)
|
891
|
+
>>> fig, ax = plt.subplots()
|
892
|
+
>>> ax.plot(x, jvp(1, x, 0), label=r"$J_1$")
|
893
|
+
>>> ax.plot(x, jvp(1, x, 1), label=r"$J_1'$")
|
894
|
+
>>> ax.plot(x, jvp(1, x, 2), label=r"$J_1''$")
|
895
|
+
>>> ax.plot(x, jvp(1, x, 3), label=r"$J_1'''$")
|
896
|
+
>>> plt.legend()
|
897
|
+
>>> plt.show()
|
898
|
+
"""
|
899
|
+
n = _nonneg_int_or_fail(n, 'n')
|
900
|
+
if n == 0:
|
901
|
+
return jv(v, z)
|
902
|
+
else:
|
903
|
+
return _bessel_diff_formula(v, z, n, jv, -1)
|
904
|
+
|
905
|
+
|
906
|
+
def yvp(v, z, n=1):
|
907
|
+
"""Compute derivatives of Bessel functions of the second kind.
|
908
|
+
|
909
|
+
Compute the nth derivative of the Bessel function `Yv` with
|
910
|
+
respect to `z`.
|
911
|
+
|
912
|
+
Parameters
|
913
|
+
----------
|
914
|
+
v : array_like of float
|
915
|
+
Order of Bessel function
|
916
|
+
z : complex
|
917
|
+
Argument at which to evaluate the derivative
|
918
|
+
n : int, default 1
|
919
|
+
Order of derivative. For 0 returns the BEssel function `yv`
|
920
|
+
|
921
|
+
Returns
|
922
|
+
-------
|
923
|
+
scalar or ndarray
|
924
|
+
nth derivative of the Bessel function.
|
925
|
+
|
926
|
+
See Also
|
927
|
+
--------
|
928
|
+
yv : Bessel functions of the second kind
|
929
|
+
|
930
|
+
Notes
|
931
|
+
-----
|
932
|
+
The derivative is computed using the relation DLFM 10.6.7 [2]_.
|
933
|
+
|
934
|
+
References
|
935
|
+
----------
|
936
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
937
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
938
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
939
|
+
|
940
|
+
.. [2] NIST Digital Library of Mathematical Functions.
|
941
|
+
https://dlmf.nist.gov/10.6.E7
|
942
|
+
|
943
|
+
Examples
|
944
|
+
--------
|
945
|
+
Compute the Bessel function of the second kind of order 0 and
|
946
|
+
its first two derivatives at 1.
|
947
|
+
|
948
|
+
>>> from scipy.special import yvp
|
949
|
+
>>> yvp(0, 1, 0), yvp(0, 1, 1), yvp(0, 1, 2)
|
950
|
+
(0.088256964215677, 0.7812128213002889, -0.8694697855159659)
|
951
|
+
|
952
|
+
Compute the first derivative of the Bessel function of the second
|
953
|
+
kind for several orders at 1 by providing an array for `v`.
|
954
|
+
|
955
|
+
>>> yvp([0, 1, 2], 1, 1)
|
956
|
+
array([0.78121282, 0.86946979, 2.52015239])
|
957
|
+
|
958
|
+
Compute the first derivative of the Bessel function of the
|
959
|
+
second kind of order 0 at several points by providing an array for `z`.
|
960
|
+
|
961
|
+
>>> import numpy as np
|
962
|
+
>>> points = np.array([0.5, 1.5, 3.])
|
963
|
+
>>> yvp(0, points, 1)
|
964
|
+
array([ 1.47147239, 0.41230863, -0.32467442])
|
965
|
+
|
966
|
+
Plot the Bessel function of the second kind of order 1 and its
|
967
|
+
first three derivatives.
|
968
|
+
|
969
|
+
>>> import matplotlib.pyplot as plt
|
970
|
+
>>> x = np.linspace(0, 5, 1000)
|
971
|
+
>>> x[0] += 1e-15
|
972
|
+
>>> fig, ax = plt.subplots()
|
973
|
+
>>> ax.plot(x, yvp(1, x, 0), label=r"$Y_1$")
|
974
|
+
>>> ax.plot(x, yvp(1, x, 1), label=r"$Y_1'$")
|
975
|
+
>>> ax.plot(x, yvp(1, x, 2), label=r"$Y_1''$")
|
976
|
+
>>> ax.plot(x, yvp(1, x, 3), label=r"$Y_1'''$")
|
977
|
+
>>> ax.set_ylim(-10, 10)
|
978
|
+
>>> plt.legend()
|
979
|
+
>>> plt.show()
|
980
|
+
"""
|
981
|
+
n = _nonneg_int_or_fail(n, 'n')
|
982
|
+
if n == 0:
|
983
|
+
return yv(v, z)
|
984
|
+
else:
|
985
|
+
return _bessel_diff_formula(v, z, n, yv, -1)
|
986
|
+
|
987
|
+
|
988
|
+
def kvp(v, z, n=1):
|
989
|
+
"""Compute derivatives of real-order modified Bessel function Kv(z)
|
990
|
+
|
991
|
+
Kv(z) is the modified Bessel function of the second kind.
|
992
|
+
Derivative is calculated with respect to `z`.
|
993
|
+
|
994
|
+
Parameters
|
995
|
+
----------
|
996
|
+
v : array_like of float
|
997
|
+
Order of Bessel function
|
998
|
+
z : array_like of complex
|
999
|
+
Argument at which to evaluate the derivative
|
1000
|
+
n : int, default 1
|
1001
|
+
Order of derivative. For 0 returns the Bessel function `kv` itself.
|
1002
|
+
|
1003
|
+
Returns
|
1004
|
+
-------
|
1005
|
+
out : ndarray
|
1006
|
+
The results
|
1007
|
+
|
1008
|
+
See Also
|
1009
|
+
--------
|
1010
|
+
kv
|
1011
|
+
|
1012
|
+
Notes
|
1013
|
+
-----
|
1014
|
+
The derivative is computed using the relation DLFM 10.29.5 [2]_.
|
1015
|
+
|
1016
|
+
References
|
1017
|
+
----------
|
1018
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1019
|
+
Functions", John Wiley and Sons, 1996, chapter 6.
|
1020
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1021
|
+
|
1022
|
+
.. [2] NIST Digital Library of Mathematical Functions.
|
1023
|
+
https://dlmf.nist.gov/10.29.E5
|
1024
|
+
|
1025
|
+
Examples
|
1026
|
+
--------
|
1027
|
+
Compute the modified bessel function of the second kind of order 0 and
|
1028
|
+
its first two derivatives at 1.
|
1029
|
+
|
1030
|
+
>>> from scipy.special import kvp
|
1031
|
+
>>> kvp(0, 1, 0), kvp(0, 1, 1), kvp(0, 1, 2)
|
1032
|
+
(0.42102443824070834, -0.6019072301972346, 1.0229316684379428)
|
1033
|
+
|
1034
|
+
Compute the first derivative of the modified Bessel function of the second
|
1035
|
+
kind for several orders at 1 by providing an array for `v`.
|
1036
|
+
|
1037
|
+
>>> kvp([0, 1, 2], 1, 1)
|
1038
|
+
array([-0.60190723, -1.02293167, -3.85158503])
|
1039
|
+
|
1040
|
+
Compute the first derivative of the modified Bessel function of the
|
1041
|
+
second kind of order 0 at several points by providing an array for `z`.
|
1042
|
+
|
1043
|
+
>>> import numpy as np
|
1044
|
+
>>> points = np.array([0.5, 1.5, 3.])
|
1045
|
+
>>> kvp(0, points, 1)
|
1046
|
+
array([-1.65644112, -0.2773878 , -0.04015643])
|
1047
|
+
|
1048
|
+
Plot the modified bessel function of the second kind and its
|
1049
|
+
first three derivatives.
|
1050
|
+
|
1051
|
+
>>> import matplotlib.pyplot as plt
|
1052
|
+
>>> x = np.linspace(0, 5, 1000)
|
1053
|
+
>>> fig, ax = plt.subplots()
|
1054
|
+
>>> ax.plot(x, kvp(1, x, 0), label=r"$K_1$")
|
1055
|
+
>>> ax.plot(x, kvp(1, x, 1), label=r"$K_1'$")
|
1056
|
+
>>> ax.plot(x, kvp(1, x, 2), label=r"$K_1''$")
|
1057
|
+
>>> ax.plot(x, kvp(1, x, 3), label=r"$K_1'''$")
|
1058
|
+
>>> ax.set_ylim(-2.5, 2.5)
|
1059
|
+
>>> plt.legend()
|
1060
|
+
>>> plt.show()
|
1061
|
+
"""
|
1062
|
+
n = _nonneg_int_or_fail(n, 'n')
|
1063
|
+
if n == 0:
|
1064
|
+
return kv(v, z)
|
1065
|
+
else:
|
1066
|
+
return (-1)**n * _bessel_diff_formula(v, z, n, kv, 1)
|
1067
|
+
|
1068
|
+
|
1069
|
+
def ivp(v, z, n=1):
|
1070
|
+
"""Compute derivatives of modified Bessel functions of the first kind.
|
1071
|
+
|
1072
|
+
Compute the nth derivative of the modified Bessel function `Iv`
|
1073
|
+
with respect to `z`.
|
1074
|
+
|
1075
|
+
Parameters
|
1076
|
+
----------
|
1077
|
+
v : array_like or float
|
1078
|
+
Order of Bessel function
|
1079
|
+
z : array_like
|
1080
|
+
Argument at which to evaluate the derivative; can be real or
|
1081
|
+
complex.
|
1082
|
+
n : int, default 1
|
1083
|
+
Order of derivative. For 0, returns the Bessel function `iv` itself.
|
1084
|
+
|
1085
|
+
Returns
|
1086
|
+
-------
|
1087
|
+
scalar or ndarray
|
1088
|
+
nth derivative of the modified Bessel function.
|
1089
|
+
|
1090
|
+
See Also
|
1091
|
+
--------
|
1092
|
+
iv
|
1093
|
+
|
1094
|
+
Notes
|
1095
|
+
-----
|
1096
|
+
The derivative is computed using the relation DLFM 10.29.5 [2]_.
|
1097
|
+
|
1098
|
+
References
|
1099
|
+
----------
|
1100
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1101
|
+
Functions", John Wiley and Sons, 1996, chapter 6.
|
1102
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1103
|
+
|
1104
|
+
.. [2] NIST Digital Library of Mathematical Functions.
|
1105
|
+
https://dlmf.nist.gov/10.29.E5
|
1106
|
+
|
1107
|
+
Examples
|
1108
|
+
--------
|
1109
|
+
Compute the modified Bessel function of the first kind of order 0 and
|
1110
|
+
its first two derivatives at 1.
|
1111
|
+
|
1112
|
+
>>> from scipy.special import ivp
|
1113
|
+
>>> ivp(0, 1, 0), ivp(0, 1, 1), ivp(0, 1, 2)
|
1114
|
+
(1.2660658777520084, 0.565159103992485, 0.7009067737595233)
|
1115
|
+
|
1116
|
+
Compute the first derivative of the modified Bessel function of the first
|
1117
|
+
kind for several orders at 1 by providing an array for `v`.
|
1118
|
+
|
1119
|
+
>>> ivp([0, 1, 2], 1, 1)
|
1120
|
+
array([0.5651591 , 0.70090677, 0.29366376])
|
1121
|
+
|
1122
|
+
Compute the first derivative of the modified Bessel function of the
|
1123
|
+
first kind of order 0 at several points by providing an array for `z`.
|
1124
|
+
|
1125
|
+
>>> import numpy as np
|
1126
|
+
>>> points = np.array([0., 1.5, 3.])
|
1127
|
+
>>> ivp(0, points, 1)
|
1128
|
+
array([0. , 0.98166643, 3.95337022])
|
1129
|
+
|
1130
|
+
Plot the modified Bessel function of the first kind of order 1 and its
|
1131
|
+
first three derivatives.
|
1132
|
+
|
1133
|
+
>>> import matplotlib.pyplot as plt
|
1134
|
+
>>> x = np.linspace(-5, 5, 1000)
|
1135
|
+
>>> fig, ax = plt.subplots()
|
1136
|
+
>>> ax.plot(x, ivp(1, x, 0), label=r"$I_1$")
|
1137
|
+
>>> ax.plot(x, ivp(1, x, 1), label=r"$I_1'$")
|
1138
|
+
>>> ax.plot(x, ivp(1, x, 2), label=r"$I_1''$")
|
1139
|
+
>>> ax.plot(x, ivp(1, x, 3), label=r"$I_1'''$")
|
1140
|
+
>>> plt.legend()
|
1141
|
+
>>> plt.show()
|
1142
|
+
"""
|
1143
|
+
n = _nonneg_int_or_fail(n, 'n')
|
1144
|
+
if n == 0:
|
1145
|
+
return iv(v, z)
|
1146
|
+
else:
|
1147
|
+
return _bessel_diff_formula(v, z, n, iv, 1)
|
1148
|
+
|
1149
|
+
|
1150
|
+
def h1vp(v, z, n=1):
|
1151
|
+
"""Compute derivatives of Hankel function H1v(z) with respect to `z`.
|
1152
|
+
|
1153
|
+
Parameters
|
1154
|
+
----------
|
1155
|
+
v : array_like
|
1156
|
+
Order of Hankel function
|
1157
|
+
z : array_like
|
1158
|
+
Argument at which to evaluate the derivative. Can be real or
|
1159
|
+
complex.
|
1160
|
+
n : int, default 1
|
1161
|
+
Order of derivative. For 0 returns the Hankel function `h1v` itself.
|
1162
|
+
|
1163
|
+
Returns
|
1164
|
+
-------
|
1165
|
+
scalar or ndarray
|
1166
|
+
Values of the derivative of the Hankel function.
|
1167
|
+
|
1168
|
+
See Also
|
1169
|
+
--------
|
1170
|
+
hankel1
|
1171
|
+
|
1172
|
+
Notes
|
1173
|
+
-----
|
1174
|
+
The derivative is computed using the relation DLFM 10.6.7 [2]_.
|
1175
|
+
|
1176
|
+
References
|
1177
|
+
----------
|
1178
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1179
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
1180
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1181
|
+
|
1182
|
+
.. [2] NIST Digital Library of Mathematical Functions.
|
1183
|
+
https://dlmf.nist.gov/10.6.E7
|
1184
|
+
|
1185
|
+
Examples
|
1186
|
+
--------
|
1187
|
+
Compute the Hankel function of the first kind of order 0 and
|
1188
|
+
its first two derivatives at 1.
|
1189
|
+
|
1190
|
+
>>> from scipy.special import h1vp
|
1191
|
+
>>> h1vp(0, 1, 0), h1vp(0, 1, 1), h1vp(0, 1, 2)
|
1192
|
+
((0.7651976865579664+0.088256964215677j),
|
1193
|
+
(-0.44005058574493355+0.7812128213002889j),
|
1194
|
+
(-0.3251471008130329-0.8694697855159659j))
|
1195
|
+
|
1196
|
+
Compute the first derivative of the Hankel function of the first kind
|
1197
|
+
for several orders at 1 by providing an array for `v`.
|
1198
|
+
|
1199
|
+
>>> h1vp([0, 1, 2], 1, 1)
|
1200
|
+
array([-0.44005059+0.78121282j, 0.3251471 +0.86946979j,
|
1201
|
+
0.21024362+2.52015239j])
|
1202
|
+
|
1203
|
+
Compute the first derivative of the Hankel function of the first kind
|
1204
|
+
of order 0 at several points by providing an array for `z`.
|
1205
|
+
|
1206
|
+
>>> import numpy as np
|
1207
|
+
>>> points = np.array([0.5, 1.5, 3.])
|
1208
|
+
>>> h1vp(0, points, 1)
|
1209
|
+
array([-0.24226846+1.47147239j, -0.55793651+0.41230863j,
|
1210
|
+
-0.33905896-0.32467442j])
|
1211
|
+
"""
|
1212
|
+
n = _nonneg_int_or_fail(n, 'n')
|
1213
|
+
if n == 0:
|
1214
|
+
return hankel1(v, z)
|
1215
|
+
else:
|
1216
|
+
return _bessel_diff_formula(v, z, n, hankel1, -1)
|
1217
|
+
|
1218
|
+
|
1219
|
+
def h2vp(v, z, n=1):
|
1220
|
+
"""Compute derivatives of Hankel function H2v(z) with respect to `z`.
|
1221
|
+
|
1222
|
+
Parameters
|
1223
|
+
----------
|
1224
|
+
v : array_like
|
1225
|
+
Order of Hankel function
|
1226
|
+
z : array_like
|
1227
|
+
Argument at which to evaluate the derivative. Can be real or
|
1228
|
+
complex.
|
1229
|
+
n : int, default 1
|
1230
|
+
Order of derivative. For 0 returns the Hankel function `h2v` itself.
|
1231
|
+
|
1232
|
+
Returns
|
1233
|
+
-------
|
1234
|
+
scalar or ndarray
|
1235
|
+
Values of the derivative of the Hankel function.
|
1236
|
+
|
1237
|
+
See Also
|
1238
|
+
--------
|
1239
|
+
hankel2
|
1240
|
+
|
1241
|
+
Notes
|
1242
|
+
-----
|
1243
|
+
The derivative is computed using the relation DLFM 10.6.7 [2]_.
|
1244
|
+
|
1245
|
+
References
|
1246
|
+
----------
|
1247
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1248
|
+
Functions", John Wiley and Sons, 1996, chapter 5.
|
1249
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1250
|
+
|
1251
|
+
.. [2] NIST Digital Library of Mathematical Functions.
|
1252
|
+
https://dlmf.nist.gov/10.6.E7
|
1253
|
+
|
1254
|
+
Examples
|
1255
|
+
--------
|
1256
|
+
Compute the Hankel function of the second kind of order 0 and
|
1257
|
+
its first two derivatives at 1.
|
1258
|
+
|
1259
|
+
>>> from scipy.special import h2vp
|
1260
|
+
>>> h2vp(0, 1, 0), h2vp(0, 1, 1), h2vp(0, 1, 2)
|
1261
|
+
((0.7651976865579664-0.088256964215677j),
|
1262
|
+
(-0.44005058574493355-0.7812128213002889j),
|
1263
|
+
(-0.3251471008130329+0.8694697855159659j))
|
1264
|
+
|
1265
|
+
Compute the first derivative of the Hankel function of the second kind
|
1266
|
+
for several orders at 1 by providing an array for `v`.
|
1267
|
+
|
1268
|
+
>>> h2vp([0, 1, 2], 1, 1)
|
1269
|
+
array([-0.44005059-0.78121282j, 0.3251471 -0.86946979j,
|
1270
|
+
0.21024362-2.52015239j])
|
1271
|
+
|
1272
|
+
Compute the first derivative of the Hankel function of the second kind
|
1273
|
+
of order 0 at several points by providing an array for `z`.
|
1274
|
+
|
1275
|
+
>>> import numpy as np
|
1276
|
+
>>> points = np.array([0.5, 1.5, 3.])
|
1277
|
+
>>> h2vp(0, points, 1)
|
1278
|
+
array([-0.24226846-1.47147239j, -0.55793651-0.41230863j,
|
1279
|
+
-0.33905896+0.32467442j])
|
1280
|
+
"""
|
1281
|
+
n = _nonneg_int_or_fail(n, 'n')
|
1282
|
+
if n == 0:
|
1283
|
+
return hankel2(v, z)
|
1284
|
+
else:
|
1285
|
+
return _bessel_diff_formula(v, z, n, hankel2, -1)
|
1286
|
+
|
1287
|
+
|
1288
|
+
def riccati_jn(n, x):
|
1289
|
+
r"""Compute Ricatti-Bessel function of the first kind and its derivative.
|
1290
|
+
|
1291
|
+
The Ricatti-Bessel function of the first kind is defined as :math:`x
|
1292
|
+
j_n(x)`, where :math:`j_n` is the spherical Bessel function of the first
|
1293
|
+
kind of order :math:`n`.
|
1294
|
+
|
1295
|
+
This function computes the value and first derivative of the
|
1296
|
+
Ricatti-Bessel function for all orders up to and including `n`.
|
1297
|
+
|
1298
|
+
Parameters
|
1299
|
+
----------
|
1300
|
+
n : int
|
1301
|
+
Maximum order of function to compute
|
1302
|
+
x : float
|
1303
|
+
Argument at which to evaluate
|
1304
|
+
|
1305
|
+
Returns
|
1306
|
+
-------
|
1307
|
+
jn : ndarray
|
1308
|
+
Value of j0(x), ..., jn(x)
|
1309
|
+
jnp : ndarray
|
1310
|
+
First derivative j0'(x), ..., jn'(x)
|
1311
|
+
|
1312
|
+
Notes
|
1313
|
+
-----
|
1314
|
+
The computation is carried out via backward recurrence, using the
|
1315
|
+
relation DLMF 10.51.1 [2]_.
|
1316
|
+
|
1317
|
+
Wrapper for a Fortran routine created by Shanjie Zhang and Jianming
|
1318
|
+
Jin [1]_.
|
1319
|
+
|
1320
|
+
References
|
1321
|
+
----------
|
1322
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1323
|
+
Functions", John Wiley and Sons, 1996.
|
1324
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1325
|
+
.. [2] NIST Digital Library of Mathematical Functions.
|
1326
|
+
https://dlmf.nist.gov/10.51.E1
|
1327
|
+
|
1328
|
+
"""
|
1329
|
+
if not (isscalar(n) and isscalar(x)):
|
1330
|
+
raise ValueError("arguments must be scalars.")
|
1331
|
+
n = _nonneg_int_or_fail(n, 'n', strict=False)
|
1332
|
+
if (n == 0):
|
1333
|
+
n1 = 1
|
1334
|
+
else:
|
1335
|
+
n1 = n
|
1336
|
+
|
1337
|
+
jn = np.empty((n1 + 1,), dtype=np.float64)
|
1338
|
+
jnp = np.empty_like(jn)
|
1339
|
+
|
1340
|
+
_rctj(x, out=(jn, jnp))
|
1341
|
+
return jn[:(n+1)], jnp[:(n+1)]
|
1342
|
+
|
1343
|
+
|
1344
|
+
def riccati_yn(n, x):
|
1345
|
+
"""Compute Ricatti-Bessel function of the second kind and its derivative.
|
1346
|
+
|
1347
|
+
The Ricatti-Bessel function of the second kind is defined here as :math:`+x
|
1348
|
+
y_n(x)`, where :math:`y_n` is the spherical Bessel function of the second
|
1349
|
+
kind of order :math:`n`. *Note that this is in contrast to a common convention
|
1350
|
+
that includes a minus sign in the definition.*
|
1351
|
+
|
1352
|
+
This function computes the value and first derivative of the function for
|
1353
|
+
all orders up to and including `n`.
|
1354
|
+
|
1355
|
+
Parameters
|
1356
|
+
----------
|
1357
|
+
n : int
|
1358
|
+
Maximum order of function to compute
|
1359
|
+
x : float
|
1360
|
+
Argument at which to evaluate
|
1361
|
+
|
1362
|
+
Returns
|
1363
|
+
-------
|
1364
|
+
yn : ndarray
|
1365
|
+
Value of y0(x), ..., yn(x)
|
1366
|
+
ynp : ndarray
|
1367
|
+
First derivative y0'(x), ..., yn'(x)
|
1368
|
+
|
1369
|
+
Notes
|
1370
|
+
-----
|
1371
|
+
The computation is carried out via ascending recurrence, using the
|
1372
|
+
relation DLMF 10.51.1 [2]_.
|
1373
|
+
|
1374
|
+
Wrapper for a Fortran routine created by Shanjie Zhang and Jianming
|
1375
|
+
Jin [1]_.
|
1376
|
+
|
1377
|
+
References
|
1378
|
+
----------
|
1379
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1380
|
+
Functions", John Wiley and Sons, 1996.
|
1381
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1382
|
+
.. [2] NIST Digital Library of Mathematical Functions.
|
1383
|
+
https://dlmf.nist.gov/10.51.E1
|
1384
|
+
|
1385
|
+
"""
|
1386
|
+
if not (isscalar(n) and isscalar(x)):
|
1387
|
+
raise ValueError("arguments must be scalars.")
|
1388
|
+
n = _nonneg_int_or_fail(n, 'n', strict=False)
|
1389
|
+
if (n == 0):
|
1390
|
+
n1 = 1
|
1391
|
+
else:
|
1392
|
+
n1 = n
|
1393
|
+
|
1394
|
+
yn = np.empty((n1 + 1,), dtype=np.float64)
|
1395
|
+
ynp = np.empty_like(yn)
|
1396
|
+
_rcty(x, out=(yn, ynp))
|
1397
|
+
|
1398
|
+
return yn[:(n+1)], ynp[:(n+1)]
|
1399
|
+
|
1400
|
+
|
1401
|
+
def erf_zeros(nt):
|
1402
|
+
"""Compute the first nt zero in the first quadrant, ordered by absolute value.
|
1403
|
+
|
1404
|
+
Zeros in the other quadrants can be obtained by using the symmetries
|
1405
|
+
erf(-z) = erf(z) and erf(conj(z)) = conj(erf(z)).
|
1406
|
+
|
1407
|
+
|
1408
|
+
Parameters
|
1409
|
+
----------
|
1410
|
+
nt : int
|
1411
|
+
The number of zeros to compute
|
1412
|
+
|
1413
|
+
Returns
|
1414
|
+
-------
|
1415
|
+
The locations of the zeros of erf : ndarray (complex)
|
1416
|
+
Complex values at which zeros of erf(z)
|
1417
|
+
|
1418
|
+
References
|
1419
|
+
----------
|
1420
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1421
|
+
Functions", John Wiley and Sons, 1996.
|
1422
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1423
|
+
|
1424
|
+
Examples
|
1425
|
+
--------
|
1426
|
+
>>> from scipy import special
|
1427
|
+
>>> special.erf_zeros(1)
|
1428
|
+
array([1.45061616+1.880943j])
|
1429
|
+
|
1430
|
+
Check that erf is (close to) zero for the value returned by erf_zeros
|
1431
|
+
|
1432
|
+
>>> special.erf(special.erf_zeros(1))
|
1433
|
+
array([4.95159469e-14-1.16407394e-16j])
|
1434
|
+
|
1435
|
+
"""
|
1436
|
+
if (floor(nt) != nt) or (nt <= 0) or not isscalar(nt):
|
1437
|
+
raise ValueError("Argument must be positive scalar integer.")
|
1438
|
+
return _specfun.cerzo(nt)
|
1439
|
+
|
1440
|
+
|
1441
|
+
def fresnelc_zeros(nt):
|
1442
|
+
"""Compute nt complex zeros of cosine Fresnel integral C(z).
|
1443
|
+
|
1444
|
+
Parameters
|
1445
|
+
----------
|
1446
|
+
nt : int
|
1447
|
+
Number of zeros to compute
|
1448
|
+
|
1449
|
+
Returns
|
1450
|
+
-------
|
1451
|
+
fresnelc_zeros: ndarray
|
1452
|
+
Zeros of the cosine Fresnel integral
|
1453
|
+
|
1454
|
+
References
|
1455
|
+
----------
|
1456
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1457
|
+
Functions", John Wiley and Sons, 1996.
|
1458
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1459
|
+
|
1460
|
+
"""
|
1461
|
+
if (floor(nt) != nt) or (nt <= 0) or not isscalar(nt):
|
1462
|
+
raise ValueError("Argument must be positive scalar integer.")
|
1463
|
+
return _specfun.fcszo(1, nt)
|
1464
|
+
|
1465
|
+
|
1466
|
+
def fresnels_zeros(nt):
|
1467
|
+
"""Compute nt complex zeros of sine Fresnel integral S(z).
|
1468
|
+
|
1469
|
+
Parameters
|
1470
|
+
----------
|
1471
|
+
nt : int
|
1472
|
+
Number of zeros to compute
|
1473
|
+
|
1474
|
+
Returns
|
1475
|
+
-------
|
1476
|
+
fresnels_zeros: ndarray
|
1477
|
+
Zeros of the sine Fresnel integral
|
1478
|
+
|
1479
|
+
References
|
1480
|
+
----------
|
1481
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1482
|
+
Functions", John Wiley and Sons, 1996.
|
1483
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1484
|
+
|
1485
|
+
"""
|
1486
|
+
if (floor(nt) != nt) or (nt <= 0) or not isscalar(nt):
|
1487
|
+
raise ValueError("Argument must be positive scalar integer.")
|
1488
|
+
return _specfun.fcszo(2, nt)
|
1489
|
+
|
1490
|
+
|
1491
|
+
def fresnel_zeros(nt):
|
1492
|
+
"""Compute nt complex zeros of sine and cosine Fresnel integrals S(z) and C(z).
|
1493
|
+
|
1494
|
+
Parameters
|
1495
|
+
----------
|
1496
|
+
nt : int
|
1497
|
+
Number of zeros to compute
|
1498
|
+
|
1499
|
+
Returns
|
1500
|
+
-------
|
1501
|
+
zeros_sine: ndarray
|
1502
|
+
Zeros of the sine Fresnel integral
|
1503
|
+
zeros_cosine : ndarray
|
1504
|
+
Zeros of the cosine Fresnel integral
|
1505
|
+
|
1506
|
+
References
|
1507
|
+
----------
|
1508
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1509
|
+
Functions", John Wiley and Sons, 1996.
|
1510
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1511
|
+
|
1512
|
+
"""
|
1513
|
+
if (floor(nt) != nt) or (nt <= 0) or not isscalar(nt):
|
1514
|
+
raise ValueError("Argument must be positive scalar integer.")
|
1515
|
+
return _specfun.fcszo(2, nt), _specfun.fcszo(1, nt)
|
1516
|
+
|
1517
|
+
|
1518
|
+
def assoc_laguerre(x, n, k=0.0):
|
1519
|
+
"""Compute the generalized (associated) Laguerre polynomial of degree n and order k.
|
1520
|
+
|
1521
|
+
The polynomial :math:`L^{(k)}_n(x)` is orthogonal over ``[0, inf)``,
|
1522
|
+
with weighting function ``exp(-x) * x**k`` with ``k > -1``.
|
1523
|
+
|
1524
|
+
Parameters
|
1525
|
+
----------
|
1526
|
+
x : float or ndarray
|
1527
|
+
Points where to evaluate the Laguerre polynomial
|
1528
|
+
n : int
|
1529
|
+
Degree of the Laguerre polynomial
|
1530
|
+
k : int
|
1531
|
+
Order of the Laguerre polynomial
|
1532
|
+
|
1533
|
+
Returns
|
1534
|
+
-------
|
1535
|
+
assoc_laguerre: float or ndarray
|
1536
|
+
Associated laguerre polynomial values
|
1537
|
+
|
1538
|
+
Notes
|
1539
|
+
-----
|
1540
|
+
`assoc_laguerre` is a simple wrapper around `eval_genlaguerre`, with
|
1541
|
+
reversed argument order ``(x, n, k=0.0) --> (n, k, x)``.
|
1542
|
+
|
1543
|
+
"""
|
1544
|
+
return _ufuncs.eval_genlaguerre(n, k, x)
|
1545
|
+
|
1546
|
+
|
1547
|
+
digamma = psi
|
1548
|
+
|
1549
|
+
|
1550
|
+
def polygamma(n, x):
|
1551
|
+
r"""Polygamma functions.
|
1552
|
+
|
1553
|
+
Defined as :math:`\psi^{(n)}(x)` where :math:`\psi` is the
|
1554
|
+
`digamma` function. See [dlmf]_ for details.
|
1555
|
+
|
1556
|
+
Parameters
|
1557
|
+
----------
|
1558
|
+
n : array_like
|
1559
|
+
The order of the derivative of the digamma function; must be
|
1560
|
+
integral
|
1561
|
+
x : array_like
|
1562
|
+
Real valued input
|
1563
|
+
|
1564
|
+
Returns
|
1565
|
+
-------
|
1566
|
+
ndarray
|
1567
|
+
Function results
|
1568
|
+
|
1569
|
+
See Also
|
1570
|
+
--------
|
1571
|
+
digamma
|
1572
|
+
|
1573
|
+
References
|
1574
|
+
----------
|
1575
|
+
.. [dlmf] NIST, Digital Library of Mathematical Functions,
|
1576
|
+
https://dlmf.nist.gov/5.15
|
1577
|
+
|
1578
|
+
Examples
|
1579
|
+
--------
|
1580
|
+
>>> from scipy import special
|
1581
|
+
>>> x = [2, 3, 25.5]
|
1582
|
+
>>> special.polygamma(1, x)
|
1583
|
+
array([ 0.64493407, 0.39493407, 0.03999467])
|
1584
|
+
>>> special.polygamma(0, x) == special.psi(x)
|
1585
|
+
array([ True, True, True], dtype=bool)
|
1586
|
+
|
1587
|
+
"""
|
1588
|
+
n, x = asarray(n), asarray(x)
|
1589
|
+
fac2 = (-1.0)**(n+1) * gamma(n+1.0) * zeta(n+1, x)
|
1590
|
+
return where(n == 0, psi(x), fac2)
|
1591
|
+
|
1592
|
+
|
1593
|
+
def mathieu_even_coef(m, q):
|
1594
|
+
r"""Fourier coefficients for even Mathieu and modified Mathieu functions.
|
1595
|
+
|
1596
|
+
The Fourier series of the even solutions of the Mathieu differential
|
1597
|
+
equation are of the form
|
1598
|
+
|
1599
|
+
.. math:: \mathrm{ce}_{2n}(z, q) = \sum_{k=0}^{\infty} A_{(2n)}^{(2k)} \cos 2kz
|
1600
|
+
|
1601
|
+
.. math:: \mathrm{ce}_{2n+1}(z, q) =
|
1602
|
+
\sum_{k=0}^{\infty} A_{(2n+1)}^{(2k+1)} \cos (2k+1)z
|
1603
|
+
|
1604
|
+
This function returns the coefficients :math:`A_{(2n)}^{(2k)}` for even
|
1605
|
+
input m=2n, and the coefficients :math:`A_{(2n+1)}^{(2k+1)}` for odd input
|
1606
|
+
m=2n+1.
|
1607
|
+
|
1608
|
+
Parameters
|
1609
|
+
----------
|
1610
|
+
m : int
|
1611
|
+
Order of Mathieu functions. Must be non-negative.
|
1612
|
+
q : float (>=0)
|
1613
|
+
Parameter of Mathieu functions. Must be non-negative.
|
1614
|
+
|
1615
|
+
Returns
|
1616
|
+
-------
|
1617
|
+
Ak : ndarray
|
1618
|
+
Even or odd Fourier coefficients, corresponding to even or odd m.
|
1619
|
+
|
1620
|
+
References
|
1621
|
+
----------
|
1622
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1623
|
+
Functions", John Wiley and Sons, 1996.
|
1624
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1625
|
+
.. [2] NIST Digital Library of Mathematical Functions
|
1626
|
+
https://dlmf.nist.gov/28.4#i
|
1627
|
+
|
1628
|
+
"""
|
1629
|
+
if not (isscalar(m) and isscalar(q)):
|
1630
|
+
raise ValueError("m and q must be scalars.")
|
1631
|
+
if (q < 0):
|
1632
|
+
raise ValueError("q >=0")
|
1633
|
+
if (m != floor(m)) or (m < 0):
|
1634
|
+
raise ValueError("m must be an integer >=0.")
|
1635
|
+
|
1636
|
+
if (q <= 1):
|
1637
|
+
qm = 7.5 + 56.1*sqrt(q) - 134.7*q + 90.7*sqrt(q)*q
|
1638
|
+
else:
|
1639
|
+
qm = 17.0 + 3.1*sqrt(q) - .126*q + .0037*sqrt(q)*q
|
1640
|
+
km = int(qm + 0.5*m)
|
1641
|
+
if km > 251:
|
1642
|
+
warnings.warn("Too many predicted coefficients.", RuntimeWarning, stacklevel=2)
|
1643
|
+
kd = 1
|
1644
|
+
m = int(floor(m))
|
1645
|
+
if m % 2:
|
1646
|
+
kd = 2
|
1647
|
+
|
1648
|
+
a = mathieu_a(m, q)
|
1649
|
+
fc = _specfun.fcoef(kd, m, q, a)
|
1650
|
+
return fc[:km]
|
1651
|
+
|
1652
|
+
|
1653
|
+
def mathieu_odd_coef(m, q):
|
1654
|
+
r"""Fourier coefficients for even Mathieu and modified Mathieu functions.
|
1655
|
+
|
1656
|
+
The Fourier series of the odd solutions of the Mathieu differential
|
1657
|
+
equation are of the form
|
1658
|
+
|
1659
|
+
.. math:: \mathrm{se}_{2n+1}(z, q) =
|
1660
|
+
\sum_{k=0}^{\infty} B_{(2n+1)}^{(2k+1)} \sin (2k+1)z
|
1661
|
+
|
1662
|
+
.. math:: \mathrm{se}_{2n+2}(z, q) =
|
1663
|
+
\sum_{k=0}^{\infty} B_{(2n+2)}^{(2k+2)} \sin (2k+2)z
|
1664
|
+
|
1665
|
+
This function returns the coefficients :math:`B_{(2n+2)}^{(2k+2)}` for even
|
1666
|
+
input m=2n+2, and the coefficients :math:`B_{(2n+1)}^{(2k+1)}` for odd
|
1667
|
+
input m=2n+1.
|
1668
|
+
|
1669
|
+
Parameters
|
1670
|
+
----------
|
1671
|
+
m : int
|
1672
|
+
Order of Mathieu functions. Must be non-negative.
|
1673
|
+
q : float (>=0)
|
1674
|
+
Parameter of Mathieu functions. Must be non-negative.
|
1675
|
+
|
1676
|
+
Returns
|
1677
|
+
-------
|
1678
|
+
Bk : ndarray
|
1679
|
+
Even or odd Fourier coefficients, corresponding to even or odd m.
|
1680
|
+
|
1681
|
+
References
|
1682
|
+
----------
|
1683
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1684
|
+
Functions", John Wiley and Sons, 1996.
|
1685
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1686
|
+
|
1687
|
+
"""
|
1688
|
+
if not (isscalar(m) and isscalar(q)):
|
1689
|
+
raise ValueError("m and q must be scalars.")
|
1690
|
+
if (q < 0):
|
1691
|
+
raise ValueError("q >=0")
|
1692
|
+
if (m != floor(m)) or (m <= 0):
|
1693
|
+
raise ValueError("m must be an integer > 0")
|
1694
|
+
|
1695
|
+
if (q <= 1):
|
1696
|
+
qm = 7.5 + 56.1*sqrt(q) - 134.7*q + 90.7*sqrt(q)*q
|
1697
|
+
else:
|
1698
|
+
qm = 17.0 + 3.1*sqrt(q) - .126*q + .0037*sqrt(q)*q
|
1699
|
+
km = int(qm + 0.5*m)
|
1700
|
+
if km > 251:
|
1701
|
+
warnings.warn("Too many predicted coefficients.", RuntimeWarning, stacklevel=2)
|
1702
|
+
kd = 4
|
1703
|
+
m = int(floor(m))
|
1704
|
+
if m % 2:
|
1705
|
+
kd = 3
|
1706
|
+
|
1707
|
+
b = mathieu_b(m, q)
|
1708
|
+
fc = _specfun.fcoef(kd, m, q, b)
|
1709
|
+
return fc[:km]
|
1710
|
+
|
1711
|
+
|
1712
|
+
@_deprecated(__DEPRECATION_MSG_1_15.format("lpmn", "assoc_legendre_p_all"))
|
1713
|
+
def lpmn(m, n, z):
|
1714
|
+
"""Sequence of associated Legendre functions of the first kind.
|
1715
|
+
|
1716
|
+
Computes the associated Legendre function of the first kind of order m and
|
1717
|
+
degree n, ``Pmn(z)`` = :math:`P_n^m(z)`, and its derivative, ``Pmn'(z)``.
|
1718
|
+
Returns two arrays of size ``(m+1, n+1)`` containing ``Pmn(z)`` and
|
1719
|
+
``Pmn'(z)`` for all orders from ``0..m`` and degrees from ``0..n``.
|
1720
|
+
|
1721
|
+
This function takes a real argument ``z``. For complex arguments ``z``
|
1722
|
+
use clpmn instead.
|
1723
|
+
|
1724
|
+
.. deprecated:: 1.15.0
|
1725
|
+
This function is deprecated and will be removed in SciPy 1.17.0.
|
1726
|
+
Please `scipy.special.assoc_legendre_p_all` instead.
|
1727
|
+
|
1728
|
+
Parameters
|
1729
|
+
----------
|
1730
|
+
m : int
|
1731
|
+
``|m| <= n``; the order of the Legendre function.
|
1732
|
+
n : int
|
1733
|
+
where ``n >= 0``; the degree of the Legendre function. Often
|
1734
|
+
called ``l`` (lower case L) in descriptions of the associated
|
1735
|
+
Legendre function
|
1736
|
+
z : array_like
|
1737
|
+
Input value.
|
1738
|
+
|
1739
|
+
Returns
|
1740
|
+
-------
|
1741
|
+
Pmn_z : (m+1, n+1) array
|
1742
|
+
Values for all orders 0..m and degrees 0..n
|
1743
|
+
Pmn_d_z : (m+1, n+1) array
|
1744
|
+
Derivatives for all orders 0..m and degrees 0..n
|
1745
|
+
|
1746
|
+
See Also
|
1747
|
+
--------
|
1748
|
+
clpmn: associated Legendre functions of the first kind for complex z
|
1749
|
+
|
1750
|
+
Notes
|
1751
|
+
-----
|
1752
|
+
In the interval (-1, 1), Ferrer's function of the first kind is
|
1753
|
+
returned. The phase convention used for the intervals (1, inf)
|
1754
|
+
and (-inf, -1) is such that the result is always real.
|
1755
|
+
|
1756
|
+
References
|
1757
|
+
----------
|
1758
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1759
|
+
Functions", John Wiley and Sons, 1996.
|
1760
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1761
|
+
.. [2] NIST Digital Library of Mathematical Functions
|
1762
|
+
https://dlmf.nist.gov/14.3
|
1763
|
+
|
1764
|
+
"""
|
1765
|
+
|
1766
|
+
n = _nonneg_int_or_fail(n, 'n', strict=False)
|
1767
|
+
|
1768
|
+
if (abs(m) > n):
|
1769
|
+
raise ValueError("m must be <= n.")
|
1770
|
+
|
1771
|
+
if np.iscomplexobj(z):
|
1772
|
+
raise ValueError("Argument must be real. Use clpmn instead.")
|
1773
|
+
|
1774
|
+
m, n = int(m), int(n) # Convert to int to maintain backwards compatibility.
|
1775
|
+
|
1776
|
+
branch_cut = np.where(np.abs(z) <= 1, 2, 3)
|
1777
|
+
|
1778
|
+
p, pd = assoc_legendre_p_all(n, abs(m), z, branch_cut=branch_cut, diff_n=1)
|
1779
|
+
p = np.swapaxes(p, 0, 1)
|
1780
|
+
pd = np.swapaxes(pd, 0, 1)
|
1781
|
+
|
1782
|
+
if (m >= 0):
|
1783
|
+
p = p[:(m + 1)]
|
1784
|
+
pd = pd[:(m + 1)]
|
1785
|
+
else:
|
1786
|
+
p = np.insert(p[:(m - 1):-1], 0, p[0], axis=0)
|
1787
|
+
pd = np.insert(pd[:(m - 1):-1], 0, pd[0], axis=0)
|
1788
|
+
|
1789
|
+
return p, pd
|
1790
|
+
|
1791
|
+
|
1792
|
+
@_deprecated(__DEPRECATION_MSG_1_15.format("clpmn", "assoc_legendre_p_all"))
|
1793
|
+
def clpmn(m, n, z, type=3):
|
1794
|
+
"""Associated Legendre function of the first kind for complex arguments.
|
1795
|
+
|
1796
|
+
Computes the associated Legendre function of the first kind of order m and
|
1797
|
+
degree n, ``Pmn(z)`` = :math:`P_n^m(z)`, and its derivative, ``Pmn'(z)``.
|
1798
|
+
Returns two arrays of size ``(m+1, n+1)`` containing ``Pmn(z)`` and
|
1799
|
+
``Pmn'(z)`` for all orders from ``0..m`` and degrees from ``0..n``.
|
1800
|
+
|
1801
|
+
.. deprecated:: 1.15.0
|
1802
|
+
This function is deprecated and will be removed in SciPy 1.17.0.
|
1803
|
+
Please use `scipy.special.assoc_legendre_p_all` instead.
|
1804
|
+
|
1805
|
+
Parameters
|
1806
|
+
----------
|
1807
|
+
m : int
|
1808
|
+
``|m| <= n``; the order of the Legendre function.
|
1809
|
+
n : int
|
1810
|
+
where ``n >= 0``; the degree of the Legendre function. Often
|
1811
|
+
called ``l`` (lower case L) in descriptions of the associated
|
1812
|
+
Legendre function
|
1813
|
+
z : array_like, float or complex
|
1814
|
+
Input value.
|
1815
|
+
type : int, optional
|
1816
|
+
takes values 2 or 3
|
1817
|
+
2: cut on the real axis ``|x| > 1``
|
1818
|
+
3: cut on the real axis ``-1 < x < 1`` (default)
|
1819
|
+
|
1820
|
+
Returns
|
1821
|
+
-------
|
1822
|
+
Pmn_z : (m+1, n+1) array
|
1823
|
+
Values for all orders ``0..m`` and degrees ``0..n``
|
1824
|
+
Pmn_d_z : (m+1, n+1) array
|
1825
|
+
Derivatives for all orders ``0..m`` and degrees ``0..n``
|
1826
|
+
|
1827
|
+
See Also
|
1828
|
+
--------
|
1829
|
+
lpmn: associated Legendre functions of the first kind for real z
|
1830
|
+
|
1831
|
+
Notes
|
1832
|
+
-----
|
1833
|
+
By default, i.e. for ``type=3``, phase conventions are chosen according
|
1834
|
+
to [1]_ such that the function is analytic. The cut lies on the interval
|
1835
|
+
(-1, 1). Approaching the cut from above or below in general yields a phase
|
1836
|
+
factor with respect to Ferrer's function of the first kind
|
1837
|
+
(cf. `lpmn`).
|
1838
|
+
|
1839
|
+
For ``type=2`` a cut at ``|x| > 1`` is chosen. Approaching the real values
|
1840
|
+
on the interval (-1, 1) in the complex plane yields Ferrer's function
|
1841
|
+
of the first kind.
|
1842
|
+
|
1843
|
+
References
|
1844
|
+
----------
|
1845
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1846
|
+
Functions", John Wiley and Sons, 1996.
|
1847
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1848
|
+
.. [2] NIST Digital Library of Mathematical Functions
|
1849
|
+
https://dlmf.nist.gov/14.21
|
1850
|
+
|
1851
|
+
"""
|
1852
|
+
|
1853
|
+
if (abs(m) > n):
|
1854
|
+
raise ValueError("m must be <= n.")
|
1855
|
+
|
1856
|
+
if not (type == 2 or type == 3):
|
1857
|
+
raise ValueError("type must be either 2 or 3.")
|
1858
|
+
|
1859
|
+
m, n = int(m), int(n) # Convert to int to maintain backwards compatibility.
|
1860
|
+
|
1861
|
+
if not np.iscomplexobj(z):
|
1862
|
+
z = np.asarray(z, dtype=complex)
|
1863
|
+
|
1864
|
+
out, out_jac = assoc_legendre_p_all(n, abs(m), z, branch_cut=type, diff_n=1)
|
1865
|
+
out = np.swapaxes(out, 0, 1)
|
1866
|
+
out_jac = np.swapaxes(out_jac, 0, 1)
|
1867
|
+
|
1868
|
+
if (m >= 0):
|
1869
|
+
out = out[:(m + 1)]
|
1870
|
+
out_jac = out_jac[:(m + 1)]
|
1871
|
+
else:
|
1872
|
+
out = np.insert(out[:(m - 1):-1], 0, out[0], axis=0)
|
1873
|
+
out_jac = np.insert(out_jac[:(m - 1):-1], 0, out_jac[0], axis=0)
|
1874
|
+
|
1875
|
+
return out, out_jac
|
1876
|
+
|
1877
|
+
|
1878
|
+
def lqmn(m, n, z):
|
1879
|
+
"""Sequence of associated Legendre functions of the second kind.
|
1880
|
+
|
1881
|
+
Computes the associated Legendre function of the second kind of order m and
|
1882
|
+
degree n, ``Qmn(z)`` = :math:`Q_n^m(z)`, and its derivative, ``Qmn'(z)``.
|
1883
|
+
Returns two arrays of size ``(m+1, n+1)`` containing ``Qmn(z)`` and
|
1884
|
+
``Qmn'(z)`` for all orders from ``0..m`` and degrees from ``0..n``.
|
1885
|
+
|
1886
|
+
Parameters
|
1887
|
+
----------
|
1888
|
+
m : int
|
1889
|
+
``|m| <= n``; the order of the Legendre function.
|
1890
|
+
n : int
|
1891
|
+
where ``n >= 0``; the degree of the Legendre function. Often
|
1892
|
+
called ``l`` (lower case L) in descriptions of the associated
|
1893
|
+
Legendre function
|
1894
|
+
z : array_like, complex
|
1895
|
+
Input value.
|
1896
|
+
|
1897
|
+
Returns
|
1898
|
+
-------
|
1899
|
+
Qmn_z : (m+1, n+1) array
|
1900
|
+
Values for all orders 0..m and degrees 0..n
|
1901
|
+
Qmn_d_z : (m+1, n+1) array
|
1902
|
+
Derivatives for all orders 0..m and degrees 0..n
|
1903
|
+
|
1904
|
+
References
|
1905
|
+
----------
|
1906
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1907
|
+
Functions", John Wiley and Sons, 1996.
|
1908
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1909
|
+
|
1910
|
+
"""
|
1911
|
+
if not isscalar(m) or (m < 0):
|
1912
|
+
raise ValueError("m must be a non-negative integer.")
|
1913
|
+
if not isscalar(n) or (n < 0):
|
1914
|
+
raise ValueError("n must be a non-negative integer.")
|
1915
|
+
|
1916
|
+
m, n = int(m), int(n) # Convert to int to maintain backwards compatibility.
|
1917
|
+
# Ensure neither m nor n == 0
|
1918
|
+
mm = max(1, m)
|
1919
|
+
nn = max(1, n)
|
1920
|
+
|
1921
|
+
z = np.asarray(z)
|
1922
|
+
if (not np.issubdtype(z.dtype, np.inexact)):
|
1923
|
+
z = z.astype(np.float64)
|
1924
|
+
|
1925
|
+
if np.iscomplexobj(z):
|
1926
|
+
q = np.empty((mm + 1, nn + 1) + z.shape, dtype=np.complex128)
|
1927
|
+
else:
|
1928
|
+
q = np.empty((mm + 1, nn + 1) + z.shape, dtype=np.float64)
|
1929
|
+
qd = np.empty_like(q)
|
1930
|
+
if (z.ndim == 0):
|
1931
|
+
_lqmn(z, out=(q, qd))
|
1932
|
+
else:
|
1933
|
+
# new axes must be last for the ufunc
|
1934
|
+
_lqmn(z,
|
1935
|
+
out=(np.moveaxis(q, (0, 1), (-2, -1)),
|
1936
|
+
np.moveaxis(qd, (0, 1), (-2, -1))))
|
1937
|
+
|
1938
|
+
return q[:(m+1), :(n+1)], qd[:(m+1), :(n+1)]
|
1939
|
+
|
1940
|
+
|
1941
|
+
def bernoulli(n):
|
1942
|
+
"""Bernoulli numbers B0..Bn (inclusive).
|
1943
|
+
|
1944
|
+
Parameters
|
1945
|
+
----------
|
1946
|
+
n : int
|
1947
|
+
Indicated the number of terms in the Bernoulli series to generate.
|
1948
|
+
|
1949
|
+
Returns
|
1950
|
+
-------
|
1951
|
+
ndarray
|
1952
|
+
The Bernoulli numbers ``[B(0), B(1), ..., B(n)]``.
|
1953
|
+
|
1954
|
+
References
|
1955
|
+
----------
|
1956
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
1957
|
+
Functions", John Wiley and Sons, 1996.
|
1958
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
1959
|
+
.. [2] "Bernoulli number", Wikipedia, https://en.wikipedia.org/wiki/Bernoulli_number
|
1960
|
+
|
1961
|
+
Examples
|
1962
|
+
--------
|
1963
|
+
>>> import numpy as np
|
1964
|
+
>>> from scipy.special import bernoulli, zeta
|
1965
|
+
>>> bernoulli(4)
|
1966
|
+
array([ 1. , -0.5 , 0.16666667, 0. , -0.03333333])
|
1967
|
+
|
1968
|
+
The Wikipedia article ([2]_) points out the relationship between the
|
1969
|
+
Bernoulli numbers and the zeta function, ``B_n^+ = -n * zeta(1 - n)``
|
1970
|
+
for ``n > 0``:
|
1971
|
+
|
1972
|
+
>>> n = np.arange(1, 5)
|
1973
|
+
>>> -n * zeta(1 - n)
|
1974
|
+
array([ 0.5 , 0.16666667, -0. , -0.03333333])
|
1975
|
+
|
1976
|
+
Note that, in the notation used in the wikipedia article,
|
1977
|
+
`bernoulli` computes ``B_n^-`` (i.e. it used the convention that
|
1978
|
+
``B_1`` is -1/2). The relation given above is for ``B_n^+``, so the
|
1979
|
+
sign of 0.5 does not match the output of ``bernoulli(4)``.
|
1980
|
+
|
1981
|
+
"""
|
1982
|
+
if not isscalar(n) or (n < 0):
|
1983
|
+
raise ValueError("n must be a non-negative integer.")
|
1984
|
+
n = int(n)
|
1985
|
+
if (n < 2):
|
1986
|
+
n1 = 2
|
1987
|
+
else:
|
1988
|
+
n1 = n
|
1989
|
+
return _specfun.bernob(int(n1))[:(n+1)]
|
1990
|
+
|
1991
|
+
|
1992
|
+
def euler(n):
|
1993
|
+
"""Euler numbers E(0), E(1), ..., E(n).
|
1994
|
+
|
1995
|
+
The Euler numbers [1]_ are also known as the secant numbers.
|
1996
|
+
|
1997
|
+
Because ``euler(n)`` returns floating point values, it does not give
|
1998
|
+
exact values for large `n`. The first inexact value is E(22).
|
1999
|
+
|
2000
|
+
Parameters
|
2001
|
+
----------
|
2002
|
+
n : int
|
2003
|
+
The highest index of the Euler number to be returned.
|
2004
|
+
|
2005
|
+
Returns
|
2006
|
+
-------
|
2007
|
+
ndarray
|
2008
|
+
The Euler numbers [E(0), E(1), ..., E(n)].
|
2009
|
+
The odd Euler numbers, which are all zero, are included.
|
2010
|
+
|
2011
|
+
References
|
2012
|
+
----------
|
2013
|
+
.. [1] Sequence A122045, The On-Line Encyclopedia of Integer Sequences,
|
2014
|
+
https://oeis.org/A122045
|
2015
|
+
.. [2] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2016
|
+
Functions", John Wiley and Sons, 1996.
|
2017
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2018
|
+
|
2019
|
+
Examples
|
2020
|
+
--------
|
2021
|
+
>>> import numpy as np
|
2022
|
+
>>> from scipy.special import euler
|
2023
|
+
>>> euler(6)
|
2024
|
+
array([ 1., 0., -1., 0., 5., 0., -61.])
|
2025
|
+
|
2026
|
+
>>> euler(13).astype(np.int64)
|
2027
|
+
array([ 1, 0, -1, 0, 5, 0, -61,
|
2028
|
+
0, 1385, 0, -50521, 0, 2702765, 0])
|
2029
|
+
|
2030
|
+
>>> euler(22)[-1] # Exact value of E(22) is -69348874393137901.
|
2031
|
+
-69348874393137976.0
|
2032
|
+
|
2033
|
+
"""
|
2034
|
+
if not isscalar(n) or (n < 0):
|
2035
|
+
raise ValueError("n must be a non-negative integer.")
|
2036
|
+
n = int(n)
|
2037
|
+
if (n < 2):
|
2038
|
+
n1 = 2
|
2039
|
+
else:
|
2040
|
+
n1 = n
|
2041
|
+
return _specfun.eulerb(n1)[:(n+1)]
|
2042
|
+
|
2043
|
+
|
2044
|
+
@_deprecated(__DEPRECATION_MSG_1_15.format("lpn", "legendre_p_all"))
|
2045
|
+
def lpn(n, z):
|
2046
|
+
"""Legendre function of the first kind.
|
2047
|
+
|
2048
|
+
Compute sequence of Legendre functions of the first kind (polynomials),
|
2049
|
+
Pn(z) and derivatives for all degrees from 0 to n (inclusive).
|
2050
|
+
|
2051
|
+
See also special.legendre for polynomial class.
|
2052
|
+
|
2053
|
+
.. deprecated:: 1.15.0
|
2054
|
+
This function is deprecated and will be removed in SciPy 1.17.0.
|
2055
|
+
Please use `scipy.special.legendre_p_all` instead.
|
2056
|
+
|
2057
|
+
References
|
2058
|
+
----------
|
2059
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2060
|
+
Functions", John Wiley and Sons, 1996.
|
2061
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2062
|
+
"""
|
2063
|
+
|
2064
|
+
return legendre_p_all(n, z, diff_n=1)
|
2065
|
+
|
2066
|
+
|
2067
|
+
def lqn(n, z):
|
2068
|
+
"""Legendre function of the second kind.
|
2069
|
+
|
2070
|
+
Compute sequence of Legendre functions of the second kind, Qn(z) and
|
2071
|
+
derivatives for all degrees from 0 to n (inclusive).
|
2072
|
+
|
2073
|
+
References
|
2074
|
+
----------
|
2075
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2076
|
+
Functions", John Wiley and Sons, 1996.
|
2077
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2078
|
+
|
2079
|
+
"""
|
2080
|
+
n = _nonneg_int_or_fail(n, 'n', strict=False)
|
2081
|
+
if (n < 1):
|
2082
|
+
n1 = 1
|
2083
|
+
else:
|
2084
|
+
n1 = n
|
2085
|
+
|
2086
|
+
z = np.asarray(z)
|
2087
|
+
if (not np.issubdtype(z.dtype, np.inexact)):
|
2088
|
+
z = z.astype(float)
|
2089
|
+
|
2090
|
+
if np.iscomplexobj(z):
|
2091
|
+
qn = np.empty((n1 + 1,) + z.shape, dtype=np.complex128)
|
2092
|
+
else:
|
2093
|
+
qn = np.empty((n1 + 1,) + z.shape, dtype=np.float64)
|
2094
|
+
qd = np.empty_like(qn)
|
2095
|
+
if (z.ndim == 0):
|
2096
|
+
_lqn(z, out=(qn, qd))
|
2097
|
+
else:
|
2098
|
+
# new axes must be last for the ufunc
|
2099
|
+
_lqn(z,
|
2100
|
+
out=(np.moveaxis(qn, 0, -1),
|
2101
|
+
np.moveaxis(qd, 0, -1)))
|
2102
|
+
|
2103
|
+
return qn[:(n+1)], qd[:(n+1)]
|
2104
|
+
|
2105
|
+
|
2106
|
+
def ai_zeros(nt):
|
2107
|
+
"""
|
2108
|
+
Compute `nt` zeros and values of the Airy function Ai and its derivative.
|
2109
|
+
|
2110
|
+
Computes the first `nt` zeros, `a`, of the Airy function Ai(x);
|
2111
|
+
first `nt` zeros, `ap`, of the derivative of the Airy function Ai'(x);
|
2112
|
+
the corresponding values Ai(a');
|
2113
|
+
and the corresponding values Ai'(a).
|
2114
|
+
|
2115
|
+
Parameters
|
2116
|
+
----------
|
2117
|
+
nt : int
|
2118
|
+
Number of zeros to compute
|
2119
|
+
|
2120
|
+
Returns
|
2121
|
+
-------
|
2122
|
+
a : ndarray
|
2123
|
+
First `nt` zeros of Ai(x)
|
2124
|
+
ap : ndarray
|
2125
|
+
First `nt` zeros of Ai'(x)
|
2126
|
+
ai : ndarray
|
2127
|
+
Values of Ai(x) evaluated at first `nt` zeros of Ai'(x)
|
2128
|
+
aip : ndarray
|
2129
|
+
Values of Ai'(x) evaluated at first `nt` zeros of Ai(x)
|
2130
|
+
|
2131
|
+
References
|
2132
|
+
----------
|
2133
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2134
|
+
Functions", John Wiley and Sons, 1996.
|
2135
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2136
|
+
|
2137
|
+
Examples
|
2138
|
+
--------
|
2139
|
+
>>> from scipy import special
|
2140
|
+
>>> a, ap, ai, aip = special.ai_zeros(3)
|
2141
|
+
>>> a
|
2142
|
+
array([-2.33810741, -4.08794944, -5.52055983])
|
2143
|
+
>>> ap
|
2144
|
+
array([-1.01879297, -3.24819758, -4.82009921])
|
2145
|
+
>>> ai
|
2146
|
+
array([ 0.53565666, -0.41901548, 0.38040647])
|
2147
|
+
>>> aip
|
2148
|
+
array([ 0.70121082, -0.80311137, 0.86520403])
|
2149
|
+
|
2150
|
+
"""
|
2151
|
+
kf = 1
|
2152
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2153
|
+
raise ValueError("nt must be a positive integer scalar.")
|
2154
|
+
return _specfun.airyzo(nt, kf)
|
2155
|
+
|
2156
|
+
|
2157
|
+
def bi_zeros(nt):
|
2158
|
+
"""
|
2159
|
+
Compute `nt` zeros and values of the Airy function Bi and its derivative.
|
2160
|
+
|
2161
|
+
Computes the first `nt` zeros, b, of the Airy function Bi(x);
|
2162
|
+
first `nt` zeros, b', of the derivative of the Airy function Bi'(x);
|
2163
|
+
the corresponding values Bi(b');
|
2164
|
+
and the corresponding values Bi'(b).
|
2165
|
+
|
2166
|
+
Parameters
|
2167
|
+
----------
|
2168
|
+
nt : int
|
2169
|
+
Number of zeros to compute
|
2170
|
+
|
2171
|
+
Returns
|
2172
|
+
-------
|
2173
|
+
b : ndarray
|
2174
|
+
First `nt` zeros of Bi(x)
|
2175
|
+
bp : ndarray
|
2176
|
+
First `nt` zeros of Bi'(x)
|
2177
|
+
bi : ndarray
|
2178
|
+
Values of Bi(x) evaluated at first `nt` zeros of Bi'(x)
|
2179
|
+
bip : ndarray
|
2180
|
+
Values of Bi'(x) evaluated at first `nt` zeros of Bi(x)
|
2181
|
+
|
2182
|
+
References
|
2183
|
+
----------
|
2184
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2185
|
+
Functions", John Wiley and Sons, 1996.
|
2186
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2187
|
+
|
2188
|
+
Examples
|
2189
|
+
--------
|
2190
|
+
>>> from scipy import special
|
2191
|
+
>>> b, bp, bi, bip = special.bi_zeros(3)
|
2192
|
+
>>> b
|
2193
|
+
array([-1.17371322, -3.2710933 , -4.83073784])
|
2194
|
+
>>> bp
|
2195
|
+
array([-2.29443968, -4.07315509, -5.51239573])
|
2196
|
+
>>> bi
|
2197
|
+
array([-0.45494438, 0.39652284, -0.36796916])
|
2198
|
+
>>> bip
|
2199
|
+
array([ 0.60195789, -0.76031014, 0.83699101])
|
2200
|
+
|
2201
|
+
"""
|
2202
|
+
kf = 2
|
2203
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2204
|
+
raise ValueError("nt must be a positive integer scalar.")
|
2205
|
+
return _specfun.airyzo(nt, kf)
|
2206
|
+
|
2207
|
+
|
2208
|
+
def lmbda(v, x):
|
2209
|
+
r"""Jahnke-Emden Lambda function, Lambdav(x).
|
2210
|
+
|
2211
|
+
This function is defined as [2]_,
|
2212
|
+
|
2213
|
+
.. math:: \Lambda_v(x) = \Gamma(v+1) \frac{J_v(x)}{(x/2)^v},
|
2214
|
+
|
2215
|
+
where :math:`\Gamma` is the gamma function and :math:`J_v` is the
|
2216
|
+
Bessel function of the first kind.
|
2217
|
+
|
2218
|
+
Parameters
|
2219
|
+
----------
|
2220
|
+
v : float
|
2221
|
+
Order of the Lambda function
|
2222
|
+
x : float
|
2223
|
+
Value at which to evaluate the function and derivatives
|
2224
|
+
|
2225
|
+
Returns
|
2226
|
+
-------
|
2227
|
+
vl : ndarray
|
2228
|
+
Values of Lambda_vi(x), for vi=v-int(v), vi=1+v-int(v), ..., vi=v.
|
2229
|
+
dl : ndarray
|
2230
|
+
Derivatives Lambda_vi'(x), for vi=v-int(v), vi=1+v-int(v), ..., vi=v.
|
2231
|
+
|
2232
|
+
References
|
2233
|
+
----------
|
2234
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2235
|
+
Functions", John Wiley and Sons, 1996.
|
2236
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2237
|
+
.. [2] Jahnke, E. and Emde, F. "Tables of Functions with Formulae and
|
2238
|
+
Curves" (4th ed.), Dover, 1945
|
2239
|
+
"""
|
2240
|
+
if not (isscalar(v) and isscalar(x)):
|
2241
|
+
raise ValueError("arguments must be scalars.")
|
2242
|
+
if (v < 0):
|
2243
|
+
raise ValueError("argument must be > 0.")
|
2244
|
+
n = int(v)
|
2245
|
+
v0 = v - n
|
2246
|
+
if (n < 1):
|
2247
|
+
n1 = 1
|
2248
|
+
else:
|
2249
|
+
n1 = n
|
2250
|
+
v1 = n1 + v0
|
2251
|
+
if (v != floor(v)):
|
2252
|
+
vm, vl, dl = _specfun.lamv(v1, x)
|
2253
|
+
else:
|
2254
|
+
vm, vl, dl = _specfun.lamn(v1, x)
|
2255
|
+
return vl[:(n+1)], dl[:(n+1)]
|
2256
|
+
|
2257
|
+
|
2258
|
+
def pbdv_seq(v, x):
|
2259
|
+
"""Parabolic cylinder functions Dv(x) and derivatives.
|
2260
|
+
|
2261
|
+
Parameters
|
2262
|
+
----------
|
2263
|
+
v : float
|
2264
|
+
Order of the parabolic cylinder function
|
2265
|
+
x : float
|
2266
|
+
Value at which to evaluate the function and derivatives
|
2267
|
+
|
2268
|
+
Returns
|
2269
|
+
-------
|
2270
|
+
dv : ndarray
|
2271
|
+
Values of D_vi(x), for vi=v-int(v), vi=1+v-int(v), ..., vi=v.
|
2272
|
+
dp : ndarray
|
2273
|
+
Derivatives D_vi'(x), for vi=v-int(v), vi=1+v-int(v), ..., vi=v.
|
2274
|
+
|
2275
|
+
References
|
2276
|
+
----------
|
2277
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2278
|
+
Functions", John Wiley and Sons, 1996, chapter 13.
|
2279
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2280
|
+
|
2281
|
+
"""
|
2282
|
+
if not (isscalar(v) and isscalar(x)):
|
2283
|
+
raise ValueError("arguments must be scalars.")
|
2284
|
+
n = int(v)
|
2285
|
+
v0 = v-n
|
2286
|
+
if (n < 1):
|
2287
|
+
n1 = 1
|
2288
|
+
else:
|
2289
|
+
n1 = n
|
2290
|
+
v1 = n1 + v0
|
2291
|
+
dv, dp, pdf, pdd = _specfun.pbdv(v1, x)
|
2292
|
+
return dv[:n1+1], dp[:n1+1]
|
2293
|
+
|
2294
|
+
|
2295
|
+
def pbvv_seq(v, x):
|
2296
|
+
"""Parabolic cylinder functions Vv(x) and derivatives.
|
2297
|
+
|
2298
|
+
Parameters
|
2299
|
+
----------
|
2300
|
+
v : float
|
2301
|
+
Order of the parabolic cylinder function
|
2302
|
+
x : float
|
2303
|
+
Value at which to evaluate the function and derivatives
|
2304
|
+
|
2305
|
+
Returns
|
2306
|
+
-------
|
2307
|
+
dv : ndarray
|
2308
|
+
Values of V_vi(x), for vi=v-int(v), vi=1+v-int(v), ..., vi=v.
|
2309
|
+
dp : ndarray
|
2310
|
+
Derivatives V_vi'(x), for vi=v-int(v), vi=1+v-int(v), ..., vi=v.
|
2311
|
+
|
2312
|
+
References
|
2313
|
+
----------
|
2314
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2315
|
+
Functions", John Wiley and Sons, 1996, chapter 13.
|
2316
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2317
|
+
|
2318
|
+
"""
|
2319
|
+
if not (isscalar(v) and isscalar(x)):
|
2320
|
+
raise ValueError("arguments must be scalars.")
|
2321
|
+
n = int(v)
|
2322
|
+
v0 = v-n
|
2323
|
+
if (n <= 1):
|
2324
|
+
n1 = 1
|
2325
|
+
else:
|
2326
|
+
n1 = n
|
2327
|
+
v1 = n1 + v0
|
2328
|
+
dv, dp, pdf, pdd = _specfun.pbvv(v1, x)
|
2329
|
+
return dv[:n1+1], dp[:n1+1]
|
2330
|
+
|
2331
|
+
|
2332
|
+
def pbdn_seq(n, z):
|
2333
|
+
"""Parabolic cylinder functions Dn(z) and derivatives.
|
2334
|
+
|
2335
|
+
Parameters
|
2336
|
+
----------
|
2337
|
+
n : int
|
2338
|
+
Order of the parabolic cylinder function
|
2339
|
+
z : complex
|
2340
|
+
Value at which to evaluate the function and derivatives
|
2341
|
+
|
2342
|
+
Returns
|
2343
|
+
-------
|
2344
|
+
dv : ndarray
|
2345
|
+
Values of D_i(z), for i=0, ..., i=n.
|
2346
|
+
dp : ndarray
|
2347
|
+
Derivatives D_i'(z), for i=0, ..., i=n.
|
2348
|
+
|
2349
|
+
References
|
2350
|
+
----------
|
2351
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2352
|
+
Functions", John Wiley and Sons, 1996, chapter 13.
|
2353
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2354
|
+
|
2355
|
+
"""
|
2356
|
+
if not (isscalar(n) and isscalar(z)):
|
2357
|
+
raise ValueError("arguments must be scalars.")
|
2358
|
+
if (floor(n) != n):
|
2359
|
+
raise ValueError("n must be an integer.")
|
2360
|
+
if (abs(n) <= 1):
|
2361
|
+
n1 = 1
|
2362
|
+
else:
|
2363
|
+
n1 = n
|
2364
|
+
cpb, cpd = _specfun.cpbdn(n1, z)
|
2365
|
+
return cpb[:n1+1], cpd[:n1+1]
|
2366
|
+
|
2367
|
+
|
2368
|
+
def ber_zeros(nt):
|
2369
|
+
"""Compute nt zeros of the Kelvin function ber.
|
2370
|
+
|
2371
|
+
Parameters
|
2372
|
+
----------
|
2373
|
+
nt : int
|
2374
|
+
Number of zeros to compute. Must be positive.
|
2375
|
+
|
2376
|
+
Returns
|
2377
|
+
-------
|
2378
|
+
ndarray
|
2379
|
+
First `nt` zeros of the Kelvin function.
|
2380
|
+
|
2381
|
+
See Also
|
2382
|
+
--------
|
2383
|
+
ber
|
2384
|
+
|
2385
|
+
References
|
2386
|
+
----------
|
2387
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2388
|
+
Functions", John Wiley and Sons, 1996.
|
2389
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2390
|
+
|
2391
|
+
"""
|
2392
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2393
|
+
raise ValueError("nt must be positive integer scalar.")
|
2394
|
+
return _specfun.klvnzo(nt, 1)
|
2395
|
+
|
2396
|
+
|
2397
|
+
def bei_zeros(nt):
|
2398
|
+
"""Compute nt zeros of the Kelvin function bei.
|
2399
|
+
|
2400
|
+
Parameters
|
2401
|
+
----------
|
2402
|
+
nt : int
|
2403
|
+
Number of zeros to compute. Must be positive.
|
2404
|
+
|
2405
|
+
Returns
|
2406
|
+
-------
|
2407
|
+
ndarray
|
2408
|
+
First `nt` zeros of the Kelvin function.
|
2409
|
+
|
2410
|
+
See Also
|
2411
|
+
--------
|
2412
|
+
bei
|
2413
|
+
|
2414
|
+
References
|
2415
|
+
----------
|
2416
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2417
|
+
Functions", John Wiley and Sons, 1996.
|
2418
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2419
|
+
|
2420
|
+
"""
|
2421
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2422
|
+
raise ValueError("nt must be positive integer scalar.")
|
2423
|
+
return _specfun.klvnzo(nt, 2)
|
2424
|
+
|
2425
|
+
|
2426
|
+
def ker_zeros(nt):
|
2427
|
+
"""Compute nt zeros of the Kelvin function ker.
|
2428
|
+
|
2429
|
+
Parameters
|
2430
|
+
----------
|
2431
|
+
nt : int
|
2432
|
+
Number of zeros to compute. Must be positive.
|
2433
|
+
|
2434
|
+
Returns
|
2435
|
+
-------
|
2436
|
+
ndarray
|
2437
|
+
First `nt` zeros of the Kelvin function.
|
2438
|
+
|
2439
|
+
See Also
|
2440
|
+
--------
|
2441
|
+
ker
|
2442
|
+
|
2443
|
+
References
|
2444
|
+
----------
|
2445
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2446
|
+
Functions", John Wiley and Sons, 1996.
|
2447
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2448
|
+
|
2449
|
+
"""
|
2450
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2451
|
+
raise ValueError("nt must be positive integer scalar.")
|
2452
|
+
return _specfun.klvnzo(nt, 3)
|
2453
|
+
|
2454
|
+
|
2455
|
+
def kei_zeros(nt):
|
2456
|
+
"""Compute nt zeros of the Kelvin function kei.
|
2457
|
+
|
2458
|
+
Parameters
|
2459
|
+
----------
|
2460
|
+
nt : int
|
2461
|
+
Number of zeros to compute. Must be positive.
|
2462
|
+
|
2463
|
+
Returns
|
2464
|
+
-------
|
2465
|
+
ndarray
|
2466
|
+
First `nt` zeros of the Kelvin function.
|
2467
|
+
|
2468
|
+
See Also
|
2469
|
+
--------
|
2470
|
+
kei
|
2471
|
+
|
2472
|
+
References
|
2473
|
+
----------
|
2474
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2475
|
+
Functions", John Wiley and Sons, 1996.
|
2476
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2477
|
+
|
2478
|
+
"""
|
2479
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2480
|
+
raise ValueError("nt must be positive integer scalar.")
|
2481
|
+
return _specfun.klvnzo(nt, 4)
|
2482
|
+
|
2483
|
+
|
2484
|
+
def berp_zeros(nt):
|
2485
|
+
"""Compute nt zeros of the derivative of the Kelvin function ber.
|
2486
|
+
|
2487
|
+
Parameters
|
2488
|
+
----------
|
2489
|
+
nt : int
|
2490
|
+
Number of zeros to compute. Must be positive.
|
2491
|
+
|
2492
|
+
Returns
|
2493
|
+
-------
|
2494
|
+
ndarray
|
2495
|
+
First `nt` zeros of the derivative of the Kelvin function.
|
2496
|
+
|
2497
|
+
See Also
|
2498
|
+
--------
|
2499
|
+
ber, berp
|
2500
|
+
|
2501
|
+
References
|
2502
|
+
----------
|
2503
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2504
|
+
Functions", John Wiley and Sons, 1996.
|
2505
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2506
|
+
|
2507
|
+
|
2508
|
+
Examples
|
2509
|
+
--------
|
2510
|
+
Compute the first 5 zeros of the derivative of the Kelvin function.
|
2511
|
+
|
2512
|
+
>>> from scipy.special import berp_zeros
|
2513
|
+
>>> berp_zeros(5)
|
2514
|
+
array([ 6.03871081, 10.51364251, 14.96844542, 19.41757493, 23.86430432])
|
2515
|
+
|
2516
|
+
"""
|
2517
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2518
|
+
raise ValueError("nt must be positive integer scalar.")
|
2519
|
+
return _specfun.klvnzo(nt, 5)
|
2520
|
+
|
2521
|
+
|
2522
|
+
def beip_zeros(nt):
|
2523
|
+
"""Compute nt zeros of the derivative of the Kelvin function bei.
|
2524
|
+
|
2525
|
+
Parameters
|
2526
|
+
----------
|
2527
|
+
nt : int
|
2528
|
+
Number of zeros to compute. Must be positive.
|
2529
|
+
|
2530
|
+
Returns
|
2531
|
+
-------
|
2532
|
+
ndarray
|
2533
|
+
First `nt` zeros of the derivative of the Kelvin function.
|
2534
|
+
|
2535
|
+
See Also
|
2536
|
+
--------
|
2537
|
+
bei, beip
|
2538
|
+
|
2539
|
+
References
|
2540
|
+
----------
|
2541
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2542
|
+
Functions", John Wiley and Sons, 1996.
|
2543
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2544
|
+
|
2545
|
+
"""
|
2546
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2547
|
+
raise ValueError("nt must be positive integer scalar.")
|
2548
|
+
return _specfun.klvnzo(nt, 6)
|
2549
|
+
|
2550
|
+
|
2551
|
+
def kerp_zeros(nt):
|
2552
|
+
"""Compute nt zeros of the derivative of the Kelvin function ker.
|
2553
|
+
|
2554
|
+
Parameters
|
2555
|
+
----------
|
2556
|
+
nt : int
|
2557
|
+
Number of zeros to compute. Must be positive.
|
2558
|
+
|
2559
|
+
Returns
|
2560
|
+
-------
|
2561
|
+
ndarray
|
2562
|
+
First `nt` zeros of the derivative of the Kelvin function.
|
2563
|
+
|
2564
|
+
See Also
|
2565
|
+
--------
|
2566
|
+
ker, kerp
|
2567
|
+
|
2568
|
+
References
|
2569
|
+
----------
|
2570
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2571
|
+
Functions", John Wiley and Sons, 1996.
|
2572
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2573
|
+
|
2574
|
+
"""
|
2575
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2576
|
+
raise ValueError("nt must be positive integer scalar.")
|
2577
|
+
return _specfun.klvnzo(nt, 7)
|
2578
|
+
|
2579
|
+
|
2580
|
+
def keip_zeros(nt):
|
2581
|
+
"""Compute nt zeros of the derivative of the Kelvin function kei.
|
2582
|
+
|
2583
|
+
Parameters
|
2584
|
+
----------
|
2585
|
+
nt : int
|
2586
|
+
Number of zeros to compute. Must be positive.
|
2587
|
+
|
2588
|
+
Returns
|
2589
|
+
-------
|
2590
|
+
ndarray
|
2591
|
+
First `nt` zeros of the derivative of the Kelvin function.
|
2592
|
+
|
2593
|
+
See Also
|
2594
|
+
--------
|
2595
|
+
kei, keip
|
2596
|
+
|
2597
|
+
References
|
2598
|
+
----------
|
2599
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2600
|
+
Functions", John Wiley and Sons, 1996.
|
2601
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2602
|
+
|
2603
|
+
"""
|
2604
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2605
|
+
raise ValueError("nt must be positive integer scalar.")
|
2606
|
+
return _specfun.klvnzo(nt, 8)
|
2607
|
+
|
2608
|
+
|
2609
|
+
def kelvin_zeros(nt):
|
2610
|
+
"""Compute nt zeros of all Kelvin functions.
|
2611
|
+
|
2612
|
+
Returned in a length-8 tuple of arrays of length nt. The tuple contains
|
2613
|
+
the arrays of zeros of (ber, bei, ker, kei, ber', bei', ker', kei').
|
2614
|
+
|
2615
|
+
References
|
2616
|
+
----------
|
2617
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2618
|
+
Functions", John Wiley and Sons, 1996.
|
2619
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2620
|
+
|
2621
|
+
"""
|
2622
|
+
if not isscalar(nt) or (floor(nt) != nt) or (nt <= 0):
|
2623
|
+
raise ValueError("nt must be positive integer scalar.")
|
2624
|
+
return (_specfun.klvnzo(nt, 1),
|
2625
|
+
_specfun.klvnzo(nt, 2),
|
2626
|
+
_specfun.klvnzo(nt, 3),
|
2627
|
+
_specfun.klvnzo(nt, 4),
|
2628
|
+
_specfun.klvnzo(nt, 5),
|
2629
|
+
_specfun.klvnzo(nt, 6),
|
2630
|
+
_specfun.klvnzo(nt, 7),
|
2631
|
+
_specfun.klvnzo(nt, 8))
|
2632
|
+
|
2633
|
+
|
2634
|
+
def pro_cv_seq(m, n, c):
|
2635
|
+
"""Characteristic values for prolate spheroidal wave functions.
|
2636
|
+
|
2637
|
+
Compute a sequence of characteristic values for the prolate
|
2638
|
+
spheroidal wave functions for mode m and n'=m..n and spheroidal
|
2639
|
+
parameter c.
|
2640
|
+
|
2641
|
+
References
|
2642
|
+
----------
|
2643
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2644
|
+
Functions", John Wiley and Sons, 1996.
|
2645
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2646
|
+
|
2647
|
+
"""
|
2648
|
+
if not (isscalar(m) and isscalar(n) and isscalar(c)):
|
2649
|
+
raise ValueError("Arguments must be scalars.")
|
2650
|
+
if (n != floor(n)) or (m != floor(m)):
|
2651
|
+
raise ValueError("Modes must be integers.")
|
2652
|
+
if (n-m > 199):
|
2653
|
+
raise ValueError("Difference between n and m is too large.")
|
2654
|
+
maxL = n-m+1
|
2655
|
+
return _specfun.segv(m, n, c, 1)[1][:maxL]
|
2656
|
+
|
2657
|
+
|
2658
|
+
def obl_cv_seq(m, n, c):
|
2659
|
+
"""Characteristic values for oblate spheroidal wave functions.
|
2660
|
+
|
2661
|
+
Compute a sequence of characteristic values for the oblate
|
2662
|
+
spheroidal wave functions for mode m and n'=m..n and spheroidal
|
2663
|
+
parameter c.
|
2664
|
+
|
2665
|
+
References
|
2666
|
+
----------
|
2667
|
+
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
|
2668
|
+
Functions", John Wiley and Sons, 1996.
|
2669
|
+
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
|
2670
|
+
|
2671
|
+
"""
|
2672
|
+
if not (isscalar(m) and isscalar(n) and isscalar(c)):
|
2673
|
+
raise ValueError("Arguments must be scalars.")
|
2674
|
+
if (n != floor(n)) or (m != floor(m)):
|
2675
|
+
raise ValueError("Modes must be integers.")
|
2676
|
+
if (n-m > 199):
|
2677
|
+
raise ValueError("Difference between n and m is too large.")
|
2678
|
+
maxL = n-m+1
|
2679
|
+
return _specfun.segv(m, n, c, -1)[1][:maxL]
|
2680
|
+
|
2681
|
+
|
2682
|
+
def comb(N, k, *, exact=False, repetition=False):
|
2683
|
+
"""The number of combinations of N things taken k at a time.
|
2684
|
+
|
2685
|
+
This is often expressed as "N choose k".
|
2686
|
+
|
2687
|
+
Parameters
|
2688
|
+
----------
|
2689
|
+
N : int, ndarray
|
2690
|
+
Number of things.
|
2691
|
+
k : int, ndarray
|
2692
|
+
Number of elements taken.
|
2693
|
+
exact : bool, optional
|
2694
|
+
For integers, if `exact` is False, then floating point precision is
|
2695
|
+
used, otherwise the result is computed exactly.
|
2696
|
+
repetition : bool, optional
|
2697
|
+
If `repetition` is True, then the number of combinations with
|
2698
|
+
repetition is computed.
|
2699
|
+
|
2700
|
+
Returns
|
2701
|
+
-------
|
2702
|
+
val : int, float, ndarray
|
2703
|
+
The total number of combinations.
|
2704
|
+
|
2705
|
+
See Also
|
2706
|
+
--------
|
2707
|
+
binom : Binomial coefficient considered as a function of two real
|
2708
|
+
variables.
|
2709
|
+
|
2710
|
+
Notes
|
2711
|
+
-----
|
2712
|
+
- Array arguments accepted only for exact=False case.
|
2713
|
+
- If N < 0, or k < 0, then 0 is returned.
|
2714
|
+
- If k > N and repetition=False, then 0 is returned.
|
2715
|
+
|
2716
|
+
Examples
|
2717
|
+
--------
|
2718
|
+
>>> import numpy as np
|
2719
|
+
>>> from scipy.special import comb
|
2720
|
+
>>> k = np.array([3, 4])
|
2721
|
+
>>> n = np.array([10, 10])
|
2722
|
+
>>> comb(n, k, exact=False)
|
2723
|
+
array([ 120., 210.])
|
2724
|
+
>>> comb(10, 3, exact=True)
|
2725
|
+
120
|
2726
|
+
>>> comb(10, 3, exact=True, repetition=True)
|
2727
|
+
220
|
2728
|
+
|
2729
|
+
"""
|
2730
|
+
if repetition:
|
2731
|
+
return comb(N + k - 1, k, exact=exact)
|
2732
|
+
if exact:
|
2733
|
+
if int(N) == N and int(k) == k:
|
2734
|
+
# _comb_int casts inputs to integers, which is safe & intended here
|
2735
|
+
return _comb_int(N, k)
|
2736
|
+
else:
|
2737
|
+
raise ValueError("Non-integer `N` and `k` with `exact=True` is not "
|
2738
|
+
"supported.")
|
2739
|
+
else:
|
2740
|
+
k, N = asarray(k), asarray(N)
|
2741
|
+
cond = (k <= N) & (N >= 0) & (k >= 0)
|
2742
|
+
vals = binom(N, k)
|
2743
|
+
if isinstance(vals, np.ndarray):
|
2744
|
+
vals[~cond] = 0
|
2745
|
+
elif not cond:
|
2746
|
+
vals = np.float64(0)
|
2747
|
+
return vals
|
2748
|
+
|
2749
|
+
|
2750
|
+
def perm(N, k, exact=False):
|
2751
|
+
"""Permutations of N things taken k at a time, i.e., k-permutations of N.
|
2752
|
+
|
2753
|
+
It's also known as "partial permutations".
|
2754
|
+
|
2755
|
+
Parameters
|
2756
|
+
----------
|
2757
|
+
N : int, ndarray
|
2758
|
+
Number of things.
|
2759
|
+
k : int, ndarray
|
2760
|
+
Number of elements taken.
|
2761
|
+
exact : bool, optional
|
2762
|
+
If ``True``, calculate the answer exactly using long integer arithmetic (`N`
|
2763
|
+
and `k` must be scalar integers). If ``False``, a floating point approximation
|
2764
|
+
is calculated (more rapidly) using `poch`. Default is ``False``.
|
2765
|
+
|
2766
|
+
Returns
|
2767
|
+
-------
|
2768
|
+
val : int, ndarray
|
2769
|
+
The number of k-permutations of N.
|
2770
|
+
|
2771
|
+
Notes
|
2772
|
+
-----
|
2773
|
+
- Array arguments accepted only for exact=False case.
|
2774
|
+
- If k > N, N < 0, or k < 0, then a 0 is returned.
|
2775
|
+
|
2776
|
+
Examples
|
2777
|
+
--------
|
2778
|
+
>>> import numpy as np
|
2779
|
+
>>> from scipy.special import perm
|
2780
|
+
>>> k = np.array([3, 4])
|
2781
|
+
>>> n = np.array([10, 10])
|
2782
|
+
>>> perm(n, k)
|
2783
|
+
array([ 720., 5040.])
|
2784
|
+
>>> perm(10, 3, exact=True)
|
2785
|
+
720
|
2786
|
+
|
2787
|
+
"""
|
2788
|
+
if exact:
|
2789
|
+
N = np.squeeze(N)[()] # for backward compatibility (accepted size 1 arrays)
|
2790
|
+
k = np.squeeze(k)[()]
|
2791
|
+
if not (isscalar(N) and isscalar(k)):
|
2792
|
+
raise ValueError("`N` and `k` must be scalar integers with `exact=True`.")
|
2793
|
+
|
2794
|
+
floor_N, floor_k = int(N), int(k)
|
2795
|
+
non_integral = not (floor_N == N and floor_k == k)
|
2796
|
+
if non_integral:
|
2797
|
+
raise ValueError("Non-integer `N` and `k` with `exact=True` is not "
|
2798
|
+
"supported.")
|
2799
|
+
|
2800
|
+
if (k > N) or (N < 0) or (k < 0):
|
2801
|
+
return 0
|
2802
|
+
|
2803
|
+
val = 1
|
2804
|
+
for i in range(floor_N - floor_k + 1, floor_N + 1):
|
2805
|
+
val *= i
|
2806
|
+
return val
|
2807
|
+
else:
|
2808
|
+
k, N = asarray(k), asarray(N)
|
2809
|
+
cond = (k <= N) & (N >= 0) & (k >= 0)
|
2810
|
+
vals = poch(N - k + 1, k)
|
2811
|
+
if isinstance(vals, np.ndarray):
|
2812
|
+
vals[~cond] = 0
|
2813
|
+
elif not cond:
|
2814
|
+
vals = np.float64(0)
|
2815
|
+
return vals
|
2816
|
+
|
2817
|
+
|
2818
|
+
# https://stackoverflow.com/a/16327037
|
2819
|
+
def _range_prod(lo, hi, k=1):
|
2820
|
+
"""
|
2821
|
+
Product of a range of numbers spaced k apart (from hi).
|
2822
|
+
|
2823
|
+
For k=1, this returns the product of
|
2824
|
+
lo * (lo+1) * (lo+2) * ... * (hi-2) * (hi-1) * hi
|
2825
|
+
= hi! / (lo-1)!
|
2826
|
+
|
2827
|
+
For k>1, it correspond to taking only every k'th number when
|
2828
|
+
counting down from hi - e.g. 18!!!! = _range_prod(1, 18, 4).
|
2829
|
+
|
2830
|
+
Breaks into smaller products first for speed:
|
2831
|
+
_range_prod(2, 9) = ((2*3)*(4*5))*((6*7)*(8*9))
|
2832
|
+
"""
|
2833
|
+
if lo == 1 and k == 1:
|
2834
|
+
return math.factorial(hi)
|
2835
|
+
|
2836
|
+
if lo + k < hi:
|
2837
|
+
mid = (hi + lo) // 2
|
2838
|
+
if k > 1:
|
2839
|
+
# make sure mid is a multiple of k away from hi
|
2840
|
+
mid = mid - ((mid - hi) % k)
|
2841
|
+
return _range_prod(lo, mid, k) * _range_prod(mid + k, hi, k)
|
2842
|
+
elif lo + k == hi:
|
2843
|
+
return lo * hi
|
2844
|
+
else:
|
2845
|
+
return hi
|
2846
|
+
|
2847
|
+
|
2848
|
+
def _factorialx_array_exact(n, k=1):
|
2849
|
+
"""
|
2850
|
+
Exact computation of factorial for an array.
|
2851
|
+
|
2852
|
+
The factorials are computed in incremental fashion, by taking
|
2853
|
+
the sorted unique values of n and multiplying the intervening
|
2854
|
+
numbers between the different unique values.
|
2855
|
+
|
2856
|
+
In other words, the factorial for the largest input is only
|
2857
|
+
computed once, with each other result computed in the process.
|
2858
|
+
|
2859
|
+
k > 1 corresponds to the multifactorial.
|
2860
|
+
"""
|
2861
|
+
un = np.unique(n)
|
2862
|
+
# numpy changed nan-sorting behaviour with 1.21, see numpy/numpy#18070;
|
2863
|
+
# to unify the behaviour, we remove the nan's here; the respective
|
2864
|
+
# values will be set separately at the end
|
2865
|
+
un = un[~np.isnan(un)]
|
2866
|
+
|
2867
|
+
# Convert to object array if np.int64 can't handle size
|
2868
|
+
if np.isnan(n).any():
|
2869
|
+
dt = float
|
2870
|
+
elif k in _FACTORIALK_LIMITS_64BITS.keys():
|
2871
|
+
if un[-1] > _FACTORIALK_LIMITS_64BITS[k]:
|
2872
|
+
# e.g. k=1: 21! > np.iinfo(np.int64).max
|
2873
|
+
dt = object
|
2874
|
+
elif un[-1] > _FACTORIALK_LIMITS_32BITS[k]:
|
2875
|
+
# e.g. k=3: 26!!! > np.iinfo(np.int32).max
|
2876
|
+
dt = np.int64
|
2877
|
+
else:
|
2878
|
+
dt = np.dtype("long")
|
2879
|
+
else:
|
2880
|
+
# for k >= 10, we always use object
|
2881
|
+
dt = object
|
2882
|
+
|
2883
|
+
out = np.empty_like(n, dtype=dt)
|
2884
|
+
|
2885
|
+
# Handle invalid/trivial values
|
2886
|
+
un = un[un > 1]
|
2887
|
+
out[n < 2] = 1
|
2888
|
+
out[n < 0] = 0
|
2889
|
+
|
2890
|
+
# Calculate products of each range of numbers
|
2891
|
+
# we can only multiply incrementally if the values are k apart;
|
2892
|
+
# therefore we partition `un` into "lanes", i.e. its residues modulo k
|
2893
|
+
for lane in range(0, k):
|
2894
|
+
ul = un[(un % k) == lane] if k > 1 else un
|
2895
|
+
if ul.size:
|
2896
|
+
# after np.unique, un resp. ul are sorted, ul[0] is the smallest;
|
2897
|
+
# cast to python ints to avoid overflow with np.int-types
|
2898
|
+
val = _range_prod(1, int(ul[0]), k=k)
|
2899
|
+
out[n == ul[0]] = val
|
2900
|
+
for i in range(len(ul) - 1):
|
2901
|
+
# by the filtering above, we have ensured that prev & current
|
2902
|
+
# are a multiple of k apart
|
2903
|
+
prev = ul[i]
|
2904
|
+
current = ul[i + 1]
|
2905
|
+
# we already multiplied all factors until prev; continue
|
2906
|
+
# building the full factorial from the following (`prev + 1`);
|
2907
|
+
# use int() for the same reason as above
|
2908
|
+
val *= _range_prod(int(prev + 1), int(current), k=k)
|
2909
|
+
out[n == current] = val
|
2910
|
+
|
2911
|
+
if np.isnan(n).any():
|
2912
|
+
out = out.astype(np.float64)
|
2913
|
+
out[np.isnan(n)] = np.nan
|
2914
|
+
return out
|
2915
|
+
|
2916
|
+
|
2917
|
+
def _factorialx_array_approx(n, k, extend):
|
2918
|
+
"""
|
2919
|
+
Calculate approximation to multifactorial for array n and integer k.
|
2920
|
+
|
2921
|
+
Ensure that values aren't calculated unnecessarily.
|
2922
|
+
"""
|
2923
|
+
if extend == "complex":
|
2924
|
+
return _factorialx_approx_core(n, k=k, extend=extend)
|
2925
|
+
|
2926
|
+
# at this point we are guaranteed that extend='zero' and that k>0 is an integer
|
2927
|
+
result = zeros(n.shape)
|
2928
|
+
# keep nans as nans
|
2929
|
+
place(result, np.isnan(n), np.nan)
|
2930
|
+
# only compute where n >= 0 (excludes nans), everything else is 0
|
2931
|
+
cond = (n >= 0)
|
2932
|
+
n_to_compute = extract(cond, n)
|
2933
|
+
place(result, cond, _factorialx_approx_core(n_to_compute, k=k, extend=extend))
|
2934
|
+
return result
|
2935
|
+
|
2936
|
+
|
2937
|
+
def _gamma1p(vals):
|
2938
|
+
"""
|
2939
|
+
returns gamma(n+1), though with NaN at -1 instead of inf, c.f. #21827
|
2940
|
+
"""
|
2941
|
+
res = gamma(vals + 1)
|
2942
|
+
# replace infinities at -1 (from gamma function at 0) with nan
|
2943
|
+
# gamma only returns inf for real inputs; can ignore complex case
|
2944
|
+
if isinstance(res, np.ndarray):
|
2945
|
+
if not _is_subdtype(vals.dtype, "c"):
|
2946
|
+
res[vals == -1] = np.nan
|
2947
|
+
elif np.isinf(res) and vals == -1:
|
2948
|
+
res = np.float64("nan")
|
2949
|
+
return res
|
2950
|
+
|
2951
|
+
|
2952
|
+
def _factorialx_approx_core(n, k, extend):
|
2953
|
+
"""
|
2954
|
+
Core approximation to multifactorial for array n and integer k.
|
2955
|
+
"""
|
2956
|
+
if k == 1:
|
2957
|
+
# shortcut for k=1; same for both extensions, because we assume the
|
2958
|
+
# handling of extend == 'zero' happens in _factorialx_array_approx
|
2959
|
+
result = _gamma1p(n)
|
2960
|
+
if isinstance(n, np.ndarray):
|
2961
|
+
# gamma does not maintain 0-dim arrays; fix it
|
2962
|
+
result = np.array(result)
|
2963
|
+
return result
|
2964
|
+
|
2965
|
+
if extend == "complex":
|
2966
|
+
# see https://numpy.org/doc/stable/reference/generated/numpy.power.html
|
2967
|
+
p_dtype = complex if (_is_subdtype(type(k), "c") or k < 0) else None
|
2968
|
+
with warnings.catch_warnings():
|
2969
|
+
# do not warn about 0 * inf, nan / nan etc.; the results are correct
|
2970
|
+
warnings.simplefilter("ignore", RuntimeWarning)
|
2971
|
+
# don't use `(n-1)/k` in np.power; underflows if 0 is of a uintX type
|
2972
|
+
result = np.power(k, n / k, dtype=p_dtype) * _gamma1p(n / k)
|
2973
|
+
result *= rgamma(1 / k + 1) / np.power(k, 1 / k, dtype=p_dtype)
|
2974
|
+
if isinstance(n, np.ndarray):
|
2975
|
+
# ensure we keep array-ness for 0-dim inputs; already n/k above loses it
|
2976
|
+
result = np.array(result)
|
2977
|
+
return result
|
2978
|
+
|
2979
|
+
# at this point we are guaranteed that extend='zero' and that k>0 is an integer
|
2980
|
+
n_mod_k = n % k
|
2981
|
+
# scalar case separately, unified handling would be inefficient for arrays;
|
2982
|
+
# don't use isscalar due to numpy/numpy#23574; 0-dim arrays treated below
|
2983
|
+
if not isinstance(n, np.ndarray):
|
2984
|
+
with warnings.catch_warnings():
|
2985
|
+
# large n cause overflow warnings, but infinity is fine
|
2986
|
+
warnings.simplefilter("ignore", RuntimeWarning)
|
2987
|
+
return (
|
2988
|
+
np.power(k, (n - n_mod_k) / k)
|
2989
|
+
* gamma(n / k + 1) / gamma(n_mod_k / k + 1)
|
2990
|
+
* max(n_mod_k, 1)
|
2991
|
+
)
|
2992
|
+
|
2993
|
+
# factor that's independent of the residue class (see factorialk docstring)
|
2994
|
+
with warnings.catch_warnings():
|
2995
|
+
# large n cause overflow warnings, but infinity is fine
|
2996
|
+
warnings.simplefilter("ignore", RuntimeWarning)
|
2997
|
+
result = np.power(k, n / k) * gamma(n / k + 1)
|
2998
|
+
# factor dependent on residue r (for `r=0` it's 1, so we skip `r=0`
|
2999
|
+
# below and thus also avoid evaluating `max(r, 1)`)
|
3000
|
+
def corr(k, r): return np.power(k, -r / k) / gamma(r / k + 1) * r
|
3001
|
+
for r in np.unique(n_mod_k):
|
3002
|
+
if r == 0:
|
3003
|
+
continue
|
3004
|
+
# cast to int because uint types break on `-r`
|
3005
|
+
result[n_mod_k == r] *= corr(k, int(r))
|
3006
|
+
return result
|
3007
|
+
|
3008
|
+
|
3009
|
+
def _is_subdtype(dtype, dtypes):
|
3010
|
+
"""
|
3011
|
+
Shorthand for calculating whether dtype is subtype of some dtypes.
|
3012
|
+
|
3013
|
+
Also allows specifying a list instead of just a single dtype.
|
3014
|
+
|
3015
|
+
Additionaly, the most important supertypes from
|
3016
|
+
https://numpy.org/doc/stable/reference/arrays.scalars.html
|
3017
|
+
can optionally be specified using abbreviations as follows:
|
3018
|
+
"i": np.integer
|
3019
|
+
"f": np.floating
|
3020
|
+
"c": np.complexfloating
|
3021
|
+
"n": np.number (contains the other three)
|
3022
|
+
"""
|
3023
|
+
dtypes = dtypes if isinstance(dtypes, list) else [dtypes]
|
3024
|
+
# map single character abbreviations, if they are in dtypes
|
3025
|
+
mapping = {
|
3026
|
+
"i": np.integer,
|
3027
|
+
"f": np.floating,
|
3028
|
+
"c": np.complexfloating,
|
3029
|
+
"n": np.number
|
3030
|
+
}
|
3031
|
+
dtypes = [mapping.get(x, x) for x in dtypes]
|
3032
|
+
return any(np.issubdtype(dtype, dt) for dt in dtypes)
|
3033
|
+
|
3034
|
+
|
3035
|
+
def _factorialx_wrapper(fname, n, k, exact, extend):
|
3036
|
+
"""
|
3037
|
+
Shared implementation for factorial, factorial2 & factorialk.
|
3038
|
+
"""
|
3039
|
+
if extend not in ("zero", "complex"):
|
3040
|
+
raise ValueError(
|
3041
|
+
f"argument `extend` must be either 'zero' or 'complex', received: {extend}"
|
3042
|
+
)
|
3043
|
+
if exact and extend == "complex":
|
3044
|
+
raise ValueError("Incompatible options: `exact=True` and `extend='complex'`")
|
3045
|
+
|
3046
|
+
msg_unsup = (
|
3047
|
+
"Unsupported data type for {vname} in {fname}: {dtype}\n"
|
3048
|
+
)
|
3049
|
+
if fname == "factorial":
|
3050
|
+
msg_unsup += (
|
3051
|
+
"Permitted data types are integers and floating point numbers, "
|
3052
|
+
"as well as complex numbers if `extend='complex' is passed."
|
3053
|
+
)
|
3054
|
+
else:
|
3055
|
+
msg_unsup += (
|
3056
|
+
"Permitted data types are integers, as well as floating point "
|
3057
|
+
"numbers and complex numbers if `extend='complex' is passed."
|
3058
|
+
)
|
3059
|
+
msg_exact_not_possible = (
|
3060
|
+
"`exact=True` only supports integers, cannot use data type {dtype}"
|
3061
|
+
)
|
3062
|
+
msg_needs_complex = (
|
3063
|
+
"In order to use non-integer arguments, you must opt into this by passing "
|
3064
|
+
"`extend='complex'`. Note that this changes the result for all negative "
|
3065
|
+
"arguments (which by default return 0)."
|
3066
|
+
)
|
3067
|
+
|
3068
|
+
if fname == "factorial2":
|
3069
|
+
msg_needs_complex += (" Additionally, it will rescale the values of the double"
|
3070
|
+
" factorial at even integers by a factor of sqrt(2/pi).")
|
3071
|
+
elif fname == "factorialk":
|
3072
|
+
msg_needs_complex += (" Additionally, it will perturb the values of the"
|
3073
|
+
" multifactorial at most positive integers `n`.")
|
3074
|
+
# check type of k
|
3075
|
+
if not _is_subdtype(type(k), ["i", "f", "c"]):
|
3076
|
+
raise ValueError(msg_unsup.format(vname="`k`", fname=fname, dtype=type(k)))
|
3077
|
+
elif _is_subdtype(type(k), ["f", "c"]) and extend != "complex":
|
3078
|
+
raise ValueError(msg_needs_complex)
|
3079
|
+
# check value of k
|
3080
|
+
if extend == "zero" and k < 1:
|
3081
|
+
msg = f"For `extend='zero'`, k must be a positive integer, received: {k}"
|
3082
|
+
raise ValueError(msg)
|
3083
|
+
elif k == 0:
|
3084
|
+
raise ValueError("Parameter k cannot be zero!")
|
3085
|
+
|
3086
|
+
# factorial allows floats also for extend="zero"
|
3087
|
+
types_requiring_complex = "c" if fname == "factorial" else ["f", "c"]
|
3088
|
+
|
3089
|
+
# don't use isscalar due to numpy/numpy#23574; 0-dim arrays treated below
|
3090
|
+
if np.ndim(n) == 0 and not isinstance(n, np.ndarray):
|
3091
|
+
# scalar cases
|
3092
|
+
if not _is_subdtype(type(n), ["i", "f", "c", type(None)]):
|
3093
|
+
raise ValueError(msg_unsup.format(vname="`n`", fname=fname, dtype=type(n)))
|
3094
|
+
elif _is_subdtype(type(n), types_requiring_complex) and extend != "complex":
|
3095
|
+
raise ValueError(msg_needs_complex)
|
3096
|
+
elif n is None or np.isnan(n):
|
3097
|
+
complexify = (extend == "complex") and _is_subdtype(type(n), "c")
|
3098
|
+
return np.complex128("nan+nanj") if complexify else np.float64("nan")
|
3099
|
+
elif extend == "zero" and n < 0:
|
3100
|
+
return 0 if exact else np.float64(0)
|
3101
|
+
elif n in {0, 1}:
|
3102
|
+
return 1 if exact else np.float64(1)
|
3103
|
+
elif exact and _is_subdtype(type(n), "i"):
|
3104
|
+
# calculate with integers; cast away other int types (like unsigned)
|
3105
|
+
return _range_prod(1, int(n), k=k)
|
3106
|
+
elif exact:
|
3107
|
+
# only relevant for factorial
|
3108
|
+
raise ValueError(msg_exact_not_possible.format(dtype=type(n)))
|
3109
|
+
# approximation
|
3110
|
+
return _factorialx_approx_core(n, k=k, extend=extend)
|
3111
|
+
|
3112
|
+
# arrays & array-likes
|
3113
|
+
n = asarray(n)
|
3114
|
+
|
3115
|
+
if not _is_subdtype(n.dtype, ["i", "f", "c"]):
|
3116
|
+
raise ValueError(msg_unsup.format(vname="`n`", fname=fname, dtype=n.dtype))
|
3117
|
+
elif _is_subdtype(n.dtype, types_requiring_complex) and extend != "complex":
|
3118
|
+
raise ValueError(msg_needs_complex)
|
3119
|
+
elif exact and _is_subdtype(n.dtype, ["f"]):
|
3120
|
+
# only relevant for factorial
|
3121
|
+
raise ValueError(msg_exact_not_possible.format(dtype=n.dtype))
|
3122
|
+
|
3123
|
+
if n.size == 0:
|
3124
|
+
# return empty arrays unchanged
|
3125
|
+
return n
|
3126
|
+
elif exact:
|
3127
|
+
# calculate with integers
|
3128
|
+
return _factorialx_array_exact(n, k=k)
|
3129
|
+
# approximation
|
3130
|
+
return _factorialx_array_approx(n, k=k, extend=extend)
|
3131
|
+
|
3132
|
+
|
3133
|
+
def factorial(n, exact=False, extend="zero"):
|
3134
|
+
"""
|
3135
|
+
The factorial of a number or array of numbers.
|
3136
|
+
|
3137
|
+
The factorial of non-negative integer `n` is the product of all
|
3138
|
+
positive integers less than or equal to `n`::
|
3139
|
+
|
3140
|
+
n! = n * (n - 1) * (n - 2) * ... * 1
|
3141
|
+
|
3142
|
+
Parameters
|
3143
|
+
----------
|
3144
|
+
n : int or float or complex (or array_like thereof)
|
3145
|
+
Input values for ``n!``. Complex values require ``extend='complex'``.
|
3146
|
+
By default, the return value for ``n < 0`` is 0.
|
3147
|
+
exact : bool, optional
|
3148
|
+
If ``exact`` is set to True, calculate the answer exactly using
|
3149
|
+
integer arithmetic, otherwise approximate using the gamma function
|
3150
|
+
(faster, but yields floats instead of integers).
|
3151
|
+
Default is False.
|
3152
|
+
extend : string, optional
|
3153
|
+
One of ``'zero'`` or ``'complex'``; this determines how values ``n<0``
|
3154
|
+
are handled - by default they are 0, but it is possible to opt into the
|
3155
|
+
complex extension of the factorial (see below).
|
3156
|
+
|
3157
|
+
Returns
|
3158
|
+
-------
|
3159
|
+
nf : int or float or complex or ndarray
|
3160
|
+
Factorial of ``n``, as integer, float or complex (depending on ``exact``
|
3161
|
+
and ``extend``). Array inputs are returned as arrays.
|
3162
|
+
|
3163
|
+
Notes
|
3164
|
+
-----
|
3165
|
+
For arrays with ``exact=True``, the factorial is computed only once, for
|
3166
|
+
the largest input, with each other result computed in the process.
|
3167
|
+
The output dtype is increased to ``int64`` or ``object`` if necessary.
|
3168
|
+
|
3169
|
+
With ``exact=False`` the factorial is approximated using the gamma
|
3170
|
+
function (which is also the definition of the complex extension):
|
3171
|
+
|
3172
|
+
.. math:: n! = \\Gamma(n+1)
|
3173
|
+
|
3174
|
+
Examples
|
3175
|
+
--------
|
3176
|
+
>>> import numpy as np
|
3177
|
+
>>> from scipy.special import factorial
|
3178
|
+
>>> arr = np.array([3, 4, 5])
|
3179
|
+
>>> factorial(arr, exact=False)
|
3180
|
+
array([ 6., 24., 120.])
|
3181
|
+
>>> factorial(arr, exact=True)
|
3182
|
+
array([ 6, 24, 120])
|
3183
|
+
>>> factorial(5, exact=True)
|
3184
|
+
120
|
3185
|
+
|
3186
|
+
"""
|
3187
|
+
return _factorialx_wrapper("factorial", n, k=1, exact=exact, extend=extend)
|
3188
|
+
|
3189
|
+
|
3190
|
+
def factorial2(n, exact=False, extend="zero"):
|
3191
|
+
"""Double factorial.
|
3192
|
+
|
3193
|
+
This is the factorial with every second value skipped. E.g., ``7!! = 7 * 5
|
3194
|
+
* 3 * 1``. It can be approximated numerically as::
|
3195
|
+
|
3196
|
+
n!! = 2 ** (n / 2) * gamma(n / 2 + 1) * sqrt(2 / pi) n odd
|
3197
|
+
= 2 ** (n / 2) * gamma(n / 2 + 1) n even
|
3198
|
+
= 2 ** (n / 2) * (n / 2)! n even
|
3199
|
+
|
3200
|
+
The formula for odd ``n`` is the basis for the complex extension.
|
3201
|
+
|
3202
|
+
Parameters
|
3203
|
+
----------
|
3204
|
+
n : int or float or complex (or array_like thereof)
|
3205
|
+
Input values for ``n!!``. Non-integer values require ``extend='complex'``.
|
3206
|
+
By default, the return value for ``n < 0`` is 0.
|
3207
|
+
exact : bool, optional
|
3208
|
+
If ``exact`` is set to True, calculate the answer exactly using
|
3209
|
+
integer arithmetic, otherwise use above approximation (faster,
|
3210
|
+
but yields floats instead of integers).
|
3211
|
+
Default is False.
|
3212
|
+
extend : string, optional
|
3213
|
+
One of ``'zero'`` or ``'complex'``; this determines how values ``n<0``
|
3214
|
+
are handled - by default they are 0, but it is possible to opt into the
|
3215
|
+
complex extension of the double factorial. This also enables passing
|
3216
|
+
complex values to ``n``.
|
3217
|
+
|
3218
|
+
.. warning::
|
3219
|
+
|
3220
|
+
Using the ``'complex'`` extension also changes the values of the
|
3221
|
+
double factorial for even integers, reducing them by a factor of
|
3222
|
+
``sqrt(2/pi) ~= 0.79``, see [1].
|
3223
|
+
|
3224
|
+
Returns
|
3225
|
+
-------
|
3226
|
+
nf : int or float or complex or ndarray
|
3227
|
+
Double factorial of ``n``, as integer, float or complex (depending on
|
3228
|
+
``exact`` and ``extend``). Array inputs are returned as arrays.
|
3229
|
+
|
3230
|
+
Examples
|
3231
|
+
--------
|
3232
|
+
>>> from scipy.special import factorial2
|
3233
|
+
>>> factorial2(7, exact=False)
|
3234
|
+
array(105.00000000000001)
|
3235
|
+
>>> factorial2(7, exact=True)
|
3236
|
+
105
|
3237
|
+
|
3238
|
+
References
|
3239
|
+
----------
|
3240
|
+
.. [1] Complex extension to double factorial
|
3241
|
+
https://en.wikipedia.org/wiki/Double_factorial#Complex_arguments
|
3242
|
+
"""
|
3243
|
+
return _factorialx_wrapper("factorial2", n, k=2, exact=exact, extend=extend)
|
3244
|
+
|
3245
|
+
|
3246
|
+
def factorialk(n, k, exact=False, extend="zero"):
|
3247
|
+
"""Multifactorial of n of order k, n(!!...!).
|
3248
|
+
|
3249
|
+
This is the multifactorial of n skipping k values. For example,
|
3250
|
+
|
3251
|
+
factorialk(17, 4) = 17!!!! = 17 * 13 * 9 * 5 * 1
|
3252
|
+
|
3253
|
+
In particular, for any integer ``n``, we have
|
3254
|
+
|
3255
|
+
factorialk(n, 1) = factorial(n)
|
3256
|
+
|
3257
|
+
factorialk(n, 2) = factorial2(n)
|
3258
|
+
|
3259
|
+
Parameters
|
3260
|
+
----------
|
3261
|
+
n : int or float or complex (or array_like thereof)
|
3262
|
+
Input values for multifactorial. Non-integer values require
|
3263
|
+
``extend='complex'``. By default, the return value for ``n < 0`` is 0.
|
3264
|
+
n : int or float or complex (or array_like thereof)
|
3265
|
+
Order of multifactorial. Non-integer values require ``extend='complex'``.
|
3266
|
+
exact : bool, optional
|
3267
|
+
If ``exact`` is set to True, calculate the answer exactly using
|
3268
|
+
integer arithmetic, otherwise use an approximation (faster,
|
3269
|
+
but yields floats instead of integers)
|
3270
|
+
Default is False.
|
3271
|
+
extend : string, optional
|
3272
|
+
One of ``'zero'`` or ``'complex'``; this determines how values ``n<0`` are
|
3273
|
+
handled - by default they are 0, but it is possible to opt into the complex
|
3274
|
+
extension of the multifactorial. This enables passing complex values,
|
3275
|
+
not only to ``n`` but also to ``k``.
|
3276
|
+
|
3277
|
+
.. warning::
|
3278
|
+
|
3279
|
+
Using the ``'complex'`` extension also changes the values of the
|
3280
|
+
multifactorial at integers ``n != 1 (mod k)`` by a factor depending
|
3281
|
+
on both ``k`` and ``n % k``, see below or [1].
|
3282
|
+
|
3283
|
+
Returns
|
3284
|
+
-------
|
3285
|
+
nf : int or float or complex or ndarray
|
3286
|
+
Multifactorial (order ``k``) of ``n``, as integer, float or complex (depending
|
3287
|
+
on ``exact`` and ``extend``). Array inputs are returned as arrays.
|
3288
|
+
|
3289
|
+
Examples
|
3290
|
+
--------
|
3291
|
+
>>> from scipy.special import factorialk
|
3292
|
+
>>> factorialk(5, k=1, exact=True)
|
3293
|
+
120
|
3294
|
+
>>> factorialk(5, k=3, exact=True)
|
3295
|
+
10
|
3296
|
+
>>> factorialk([5, 7, 9], k=3, exact=True)
|
3297
|
+
array([ 10, 28, 162])
|
3298
|
+
>>> factorialk([5, 7, 9], k=3, exact=False)
|
3299
|
+
array([ 10., 28., 162.])
|
3300
|
+
|
3301
|
+
Notes
|
3302
|
+
-----
|
3303
|
+
While less straight-forward than for the double-factorial, it's possible to
|
3304
|
+
calculate a general approximation formula of n!(k) by studying ``n`` for a given
|
3305
|
+
remainder ``r < k`` (thus ``n = m * k + r``, resp. ``r = n % k``), which can be
|
3306
|
+
put together into something valid for all integer values ``n >= 0`` & ``k > 0``::
|
3307
|
+
|
3308
|
+
n!(k) = k ** ((n - r)/k) * gamma(n/k + 1) / gamma(r/k + 1) * max(r, 1)
|
3309
|
+
|
3310
|
+
This is the basis of the approximation when ``exact=False``.
|
3311
|
+
|
3312
|
+
In principle, any fixed choice of ``r`` (ignoring its relation ``r = n%k``
|
3313
|
+
to ``n``) would provide a suitable analytic continuation from integer ``n``
|
3314
|
+
to complex ``z`` (not only satisfying the functional equation but also
|
3315
|
+
being logarithmically convex, c.f. Bohr-Mollerup theorem) -- in fact, the
|
3316
|
+
choice of ``r`` above only changes the function by a constant factor. The
|
3317
|
+
final constraint that determines the canonical continuation is ``f(1) = 1``,
|
3318
|
+
which forces ``r = 1`` (see also [1]).::
|
3319
|
+
|
3320
|
+
z!(k) = k ** ((z - 1)/k) * gamma(z/k + 1) / gamma(1/k + 1)
|
3321
|
+
|
3322
|
+
References
|
3323
|
+
----------
|
3324
|
+
.. [1] Complex extension to multifactorial
|
3325
|
+
https://en.wikipedia.org/wiki/Double_factorial#Alternative_extension_of_the_multifactorial
|
3326
|
+
"""
|
3327
|
+
return _factorialx_wrapper("factorialk", n, k=k, exact=exact, extend=extend)
|
3328
|
+
|
3329
|
+
|
3330
|
+
def stirling2(N, K, *, exact=False):
|
3331
|
+
r"""Generate Stirling number(s) of the second kind.
|
3332
|
+
|
3333
|
+
Stirling numbers of the second kind count the number of ways to
|
3334
|
+
partition a set with N elements into K non-empty subsets.
|
3335
|
+
|
3336
|
+
The values this function returns are calculated using a dynamic
|
3337
|
+
program which avoids redundant computation across the subproblems
|
3338
|
+
in the solution. For array-like input, this implementation also
|
3339
|
+
avoids redundant computation across the different Stirling number
|
3340
|
+
calculations.
|
3341
|
+
|
3342
|
+
The numbers are sometimes denoted
|
3343
|
+
|
3344
|
+
.. math::
|
3345
|
+
|
3346
|
+
{N \brace{K}}
|
3347
|
+
|
3348
|
+
see [1]_ for details. This is often expressed-verbally-as
|
3349
|
+
"N subset K".
|
3350
|
+
|
3351
|
+
Parameters
|
3352
|
+
----------
|
3353
|
+
N : int, ndarray
|
3354
|
+
Number of things.
|
3355
|
+
K : int, ndarray
|
3356
|
+
Number of non-empty subsets taken.
|
3357
|
+
exact : bool, optional
|
3358
|
+
Uses dynamic programming (DP) with floating point
|
3359
|
+
numbers for smaller arrays and uses a second order approximation due to
|
3360
|
+
Temme for larger entries of `N` and `K` that allows trading speed for
|
3361
|
+
accuracy. See [2]_ for a description. Temme approximation is used for
|
3362
|
+
values ``n>50``. The max error from the DP has max relative error
|
3363
|
+
``4.5*10^-16`` for ``n<=50`` and the max error from the Temme approximation
|
3364
|
+
has max relative error ``5*10^-5`` for ``51 <= n < 70`` and
|
3365
|
+
``9*10^-6`` for ``70 <= n < 101``. Note that these max relative errors will
|
3366
|
+
decrease further as `n` increases.
|
3367
|
+
|
3368
|
+
Returns
|
3369
|
+
-------
|
3370
|
+
val : int, float, ndarray
|
3371
|
+
The number of partitions.
|
3372
|
+
|
3373
|
+
See Also
|
3374
|
+
--------
|
3375
|
+
comb : The number of combinations of N things taken k at a time.
|
3376
|
+
|
3377
|
+
Notes
|
3378
|
+
-----
|
3379
|
+
- If N < 0, or K < 0, then 0 is returned.
|
3380
|
+
- If K > N, then 0 is returned.
|
3381
|
+
|
3382
|
+
The output type will always be `int` or ndarray of `object`.
|
3383
|
+
The input must contain either numpy or python integers otherwise a
|
3384
|
+
TypeError is raised.
|
3385
|
+
|
3386
|
+
References
|
3387
|
+
----------
|
3388
|
+
.. [1] R. L. Graham, D. E. Knuth and O. Patashnik, "Concrete
|
3389
|
+
Mathematics: A Foundation for Computer Science," Addison-Wesley
|
3390
|
+
Publishing Company, Boston, 1989. Chapter 6, page 258.
|
3391
|
+
|
3392
|
+
.. [2] Temme, Nico M. "Asymptotic estimates of Stirling numbers."
|
3393
|
+
Studies in Applied Mathematics 89.3 (1993): 233-243.
|
3394
|
+
|
3395
|
+
Examples
|
3396
|
+
--------
|
3397
|
+
>>> import numpy as np
|
3398
|
+
>>> from scipy.special import stirling2
|
3399
|
+
>>> k = np.array([3, -1, 3])
|
3400
|
+
>>> n = np.array([10, 10, 9])
|
3401
|
+
>>> stirling2(n, k)
|
3402
|
+
array([9330.0, 0.0, 3025.0])
|
3403
|
+
|
3404
|
+
"""
|
3405
|
+
output_is_scalar = np.isscalar(N) and np.isscalar(K)
|
3406
|
+
# make a min-heap of unique (n,k) pairs
|
3407
|
+
N, K = asarray(N), asarray(K)
|
3408
|
+
if not np.issubdtype(N.dtype, np.integer):
|
3409
|
+
raise TypeError("Argument `N` must contain only integers")
|
3410
|
+
if not np.issubdtype(K.dtype, np.integer):
|
3411
|
+
raise TypeError("Argument `K` must contain only integers")
|
3412
|
+
if not exact:
|
3413
|
+
# NOTE: here we allow np.uint via casting to double types prior to
|
3414
|
+
# passing to private ufunc dispatcher. All dispatched functions
|
3415
|
+
# take double type for (n,k) arguments and return double.
|
3416
|
+
return _stirling2_inexact(N.astype(float), K.astype(float))
|
3417
|
+
nk_pairs = list(
|
3418
|
+
set([(n.take(0), k.take(0))
|
3419
|
+
for n, k in np.nditer([N, K], ['refs_ok'])])
|
3420
|
+
)
|
3421
|
+
heapify(nk_pairs)
|
3422
|
+
# base mapping for small values
|
3423
|
+
snsk_vals = defaultdict(int)
|
3424
|
+
for pair in [(0, 0), (1, 1), (2, 1), (2, 2)]:
|
3425
|
+
snsk_vals[pair] = 1
|
3426
|
+
# for each pair in the min-heap, calculate the value, store for later
|
3427
|
+
n_old, n_row = 2, [0, 1, 1]
|
3428
|
+
while nk_pairs:
|
3429
|
+
n, k = heappop(nk_pairs)
|
3430
|
+
if n < 2 or k > n or k <= 0:
|
3431
|
+
continue
|
3432
|
+
elif k == n or k == 1:
|
3433
|
+
snsk_vals[(n, k)] = 1
|
3434
|
+
continue
|
3435
|
+
elif n != n_old:
|
3436
|
+
num_iters = n - n_old
|
3437
|
+
while num_iters > 0:
|
3438
|
+
n_row.append(1)
|
3439
|
+
# traverse from back to remove second row
|
3440
|
+
for j in range(len(n_row)-2, 1, -1):
|
3441
|
+
n_row[j] = n_row[j]*j + n_row[j-1]
|
3442
|
+
num_iters -= 1
|
3443
|
+
snsk_vals[(n, k)] = n_row[k]
|
3444
|
+
else:
|
3445
|
+
snsk_vals[(n, k)] = n_row[k]
|
3446
|
+
n_old, n_row = n, n_row
|
3447
|
+
out_types = [object, object, object] if exact else [float, float, float]
|
3448
|
+
# for each pair in the map, fetch the value, and populate the array
|
3449
|
+
it = np.nditer(
|
3450
|
+
[N, K, None],
|
3451
|
+
['buffered', 'refs_ok'],
|
3452
|
+
[['readonly'], ['readonly'], ['writeonly', 'allocate']],
|
3453
|
+
op_dtypes=out_types,
|
3454
|
+
)
|
3455
|
+
with it:
|
3456
|
+
while not it.finished:
|
3457
|
+
it[2] = snsk_vals[(int(it[0]), int(it[1]))]
|
3458
|
+
it.iternext()
|
3459
|
+
output = it.operands[2]
|
3460
|
+
# If N and K were both scalars, convert output to scalar.
|
3461
|
+
if output_is_scalar:
|
3462
|
+
output = output.take(0)
|
3463
|
+
return output
|
3464
|
+
|
3465
|
+
|
3466
|
+
def zeta(x, q=None, out=None):
|
3467
|
+
r"""
|
3468
|
+
Riemann or Hurwitz zeta function.
|
3469
|
+
|
3470
|
+
Parameters
|
3471
|
+
----------
|
3472
|
+
x : array_like of float or complex.
|
3473
|
+
Input data
|
3474
|
+
q : array_like of float, optional
|
3475
|
+
Input data, must be real. Defaults to Riemann zeta. When `q` is
|
3476
|
+
``None``, complex inputs `x` are supported. If `q` is not ``None``,
|
3477
|
+
then currently only real inputs `x` with ``x >= 1`` are supported,
|
3478
|
+
even when ``q = 1.0`` (corresponding to the Riemann zeta function).
|
3479
|
+
|
3480
|
+
out : ndarray, optional
|
3481
|
+
Output array for the computed values.
|
3482
|
+
|
3483
|
+
Returns
|
3484
|
+
-------
|
3485
|
+
out : array_like
|
3486
|
+
Values of zeta(x).
|
3487
|
+
|
3488
|
+
See Also
|
3489
|
+
--------
|
3490
|
+
zetac
|
3491
|
+
|
3492
|
+
Notes
|
3493
|
+
-----
|
3494
|
+
The two-argument version is the Hurwitz zeta function
|
3495
|
+
|
3496
|
+
.. math::
|
3497
|
+
|
3498
|
+
\zeta(x, q) = \sum_{k=0}^{\infty} \frac{1}{(k + q)^x};
|
3499
|
+
|
3500
|
+
see [dlmf]_ for details. The Riemann zeta function corresponds to
|
3501
|
+
the case when ``q = 1``.
|
3502
|
+
|
3503
|
+
For complex inputs with ``q = None``, points with
|
3504
|
+
``abs(z.imag) > 1e9`` and ``0 <= abs(z.real) < 2.5`` are currently not
|
3505
|
+
supported due to slow convergence causing excessive runtime.
|
3506
|
+
|
3507
|
+
References
|
3508
|
+
----------
|
3509
|
+
.. [dlmf] NIST, Digital Library of Mathematical Functions,
|
3510
|
+
https://dlmf.nist.gov/25.11#i
|
3511
|
+
|
3512
|
+
Examples
|
3513
|
+
--------
|
3514
|
+
>>> import numpy as np
|
3515
|
+
>>> from scipy.special import zeta, polygamma, factorial
|
3516
|
+
|
3517
|
+
Some specific values:
|
3518
|
+
|
3519
|
+
>>> zeta(2), np.pi**2/6
|
3520
|
+
(1.6449340668482266, 1.6449340668482264)
|
3521
|
+
|
3522
|
+
>>> zeta(4), np.pi**4/90
|
3523
|
+
(1.0823232337111381, 1.082323233711138)
|
3524
|
+
|
3525
|
+
First nontrivial zero:
|
3526
|
+
|
3527
|
+
>>> zeta(0.5 + 14.134725141734695j)
|
3528
|
+
0 + 0j
|
3529
|
+
|
3530
|
+
Relation to the `polygamma` function:
|
3531
|
+
|
3532
|
+
>>> m = 3
|
3533
|
+
>>> x = 1.25
|
3534
|
+
>>> polygamma(m, x)
|
3535
|
+
array(2.782144009188397)
|
3536
|
+
>>> (-1)**(m+1) * factorial(m) * zeta(m+1, x)
|
3537
|
+
2.7821440091883969
|
3538
|
+
|
3539
|
+
"""
|
3540
|
+
if q is None:
|
3541
|
+
return _ufuncs._riemann_zeta(x, out)
|
3542
|
+
else:
|
3543
|
+
return _ufuncs._zeta(x, q, out)
|
3544
|
+
|
3545
|
+
|
3546
|
+
def softplus(x, **kwargs):
|
3547
|
+
r"""
|
3548
|
+
Compute the softplus function element-wise.
|
3549
|
+
|
3550
|
+
The softplus function is defined as: ``softplus(x) = log(1 + exp(x))``.
|
3551
|
+
It is a smooth approximation of the rectifier function (ReLU).
|
3552
|
+
|
3553
|
+
Parameters
|
3554
|
+
----------
|
3555
|
+
x : array_like
|
3556
|
+
Input value.
|
3557
|
+
**kwargs
|
3558
|
+
For other keyword-only arguments, see the
|
3559
|
+
`ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html>`_.
|
3560
|
+
|
3561
|
+
Returns
|
3562
|
+
-------
|
3563
|
+
softplus : ndarray
|
3564
|
+
Logarithm of ``exp(0) + exp(x)``.
|
3565
|
+
|
3566
|
+
Examples
|
3567
|
+
--------
|
3568
|
+
>>> from scipy import special
|
3569
|
+
|
3570
|
+
>>> special.softplus(0)
|
3571
|
+
0.6931471805599453
|
3572
|
+
|
3573
|
+
>>> special.softplus([-1, 0, 1])
|
3574
|
+
array([0.31326169, 0.69314718, 1.31326169])
|
3575
|
+
"""
|
3576
|
+
return np.logaddexp(0, x, **kwargs)
|