scipy 1.16.2__cp313-cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/_cyutility.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_ccallback_c.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_fpumode.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_test_ccallback.cp313t-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_call.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_call.cp313t-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_def.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_def.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_uarray/_uarray.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/_lib/messagestream.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/cluster/_hierarchy.cp313t-win_arm64.pyd +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp313t-win_arm64.lib +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp313t-win_arm64.pyd +0 -0
- scipy/cluster/_vq.cp313t-win_arm64.lib +0 -0
- scipy/cluster/_vq.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/fft/_pocketfft/pypocketfft.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/fftpack/convolve.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_dop.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_lsoda.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_ode.py +1395 -0
- scipy/integrate/_odepack.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_odepack.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_odepack_py.py +273 -0
- scipy/integrate/_quad_vec.py +674 -0
- scipy/integrate/_quadpack.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_quadpack.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_test_multivariate.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_test_odeint_banded.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_test_odeint_banded.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_vode.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_vode.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_dfitpack.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_dierckx.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_dierckx.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_fitpack.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_interpnd.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_ppoly.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_rbf.py +290 -0
- scipy/interpolate/_rbfinterp.py +550 -0
- scipy/interpolate/_rbfinterp_pythran.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_rbfinterp_pythran.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_rgi.py +764 -0
- scipy/interpolate/_rgi_cython.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_rgi_cython.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/io/_test_fortran.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/io/matlab/_mio5_utils.cp313t-win_arm64.pyd +0 -0
- scipy/io/matlab/_mio_utils.cp313t-win_arm64.lib +0 -0
- scipy/io/matlab/_mio_utils.cp313t-win_arm64.pyd +0 -0
- scipy/io/matlab/_miobase.py +435 -0
- scipy/io/matlab/_streams.cp313t-win_arm64.lib +0 -0
- scipy/io/matlab/_streams.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_cythonized_array_utils.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_decomp_interpolative.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_ldl.py +356 -0
- scipy/linalg/_decomp_lu.py +401 -0
- scipy/linalg/_decomp_lu_cython.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_decomp_lu_cython.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_decomp_update.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_expm_frechet.py +417 -0
- scipy/linalg/_fblas.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_fblas.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_flapack.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_flapack.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_lapack_subroutines.h +1521 -0
- scipy/linalg/_linalg_pythran.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_linalg_pythran.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs.py +1050 -0
- scipy/linalg/_matfuncs_expm.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_expm.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_sqrtm.py +107 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_solve_toeplitz.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/linalg/cython_blas.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/cython_blas.pxd +169 -0
- scipy/linalg/cython_blas.pyx +1432 -0
- scipy/linalg/cython_lapack.cp313t-win_arm64.lib +0 -0
- scipy/linalg/cython_lapack.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_ctest.cp313t-win_arm64.pyd +0 -0
- scipy/ndimage/_cytest.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_cytest.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_nd_image.cp313t-win_arm64.pyd +0 -0
- scipy/ndimage/_ndimage_api.py +16 -0
- scipy/ndimage/_ni_docstrings.py +214 -0
- scipy/ndimage/_ni_label.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_ni_label.cp313t-win_arm64.pyd +0 -0
- scipy/ndimage/_ni_support.py +139 -0
- scipy/ndimage/_rank_filter_1d.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_rank_filter_1d.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/odr/__odrpack.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_bglu_dense.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_direct.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_group_columns.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_hessian_update_strategy.py +479 -0
- scipy/optimize/_highspy/__init__.py +0 -0
- scipy/optimize/_highspy/_core.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_core.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_options.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_highs_options.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_wrapper.py +338 -0
- scipy/optimize/_isotonic.py +157 -0
- scipy/optimize/_lbfgsb.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_lbfgsb.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_lsap.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_lsq/givens_elimination.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_minpack.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_minpack_py.py +1178 -0
- scipy/optimize/_moduleTNC.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_moduleTNC.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_pava_pybind.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_slsqplib.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_trlib/_trlib.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_zeros.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/optimize/cython_optimize/_zeros.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/signal/_max_len_seq_inner.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_peak_finding.py +1310 -0
- scipy/signal/_peak_finding_utils.cp313t-win_arm64.lib +0 -0
- scipy/signal/_peak_finding_utils.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/signal/_sigtools.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_sosfilt.cp313t-win_arm64.lib +0 -0
- scipy/signal/_sosfilt.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_spectral_py.py +2471 -0
- scipy/signal/_spline.cp313t-win_arm64.lib +0 -0
- scipy/signal/_spline.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/signal/_upfirdn_apply.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/sparse/_csparsetools.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/sparse/_sparsetools.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_flow.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_laplacian.py +563 -0
- scipy/sparse/csgraph/_matching.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_matching.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_reordering.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_reordering.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_shortest_path.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_shortest_path.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_tools.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_tools.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_traversal.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_traversal.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_cpropack.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_ckdtree.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_distance_pybind.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_distance_pybind.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_distance_wrap.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_distance_wrap.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_geometric_slerp.py +238 -0
- scipy/spatial/_hausdorff.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_hausdorff.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_qhull.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_qhull.pyi +213 -0
- scipy/spatial/_spherical_voronoi.py +341 -0
- scipy/spatial/_voronoi.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_voronoi.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/spatial/transform/_rigid_transform.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation.cp313t-win_arm64.lib +0 -0
- scipy/spatial/transform/_rotation.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/special/_comb.cp313t-win_arm64.pyd +0 -0
- scipy/special/_ellip_harm.py +214 -0
- scipy/special/_ellip_harm_2.cp313t-win_arm64.lib +0 -0
- scipy/special/_ellip_harm_2.cp313t-win_arm64.pyd +0 -0
- scipy/special/_gufuncs.cp313t-win_arm64.lib +0 -0
- scipy/special/_gufuncs.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/special/_specfun.cp313t-win_arm64.pyd +0 -0
- scipy/special/_special_ufuncs.cp313t-win_arm64.lib +0 -0
- scipy/special/_special_ufuncs.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/special/_test_internal.cp313t-win_arm64.pyd +0 -0
- scipy/special/_test_internal.pyi +9 -0
- scipy/special/_testutils.py +321 -0
- scipy/special/_ufuncs.cp313t-win_arm64.lib +0 -0
- scipy/special/_ufuncs.cp313t-win_arm64.pyd +0 -0
- scipy/special/_ufuncs.pyi +522 -0
- scipy/special/_ufuncs.pyx +13173 -0
- scipy/special/_ufuncs_cxx.cp313t-win_arm64.lib +0 -0
- scipy/special/_ufuncs_cxx.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/special/cython_special.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/stats/_ansari_swilk_statistics.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_axis_nan_policy.py +692 -0
- scipy/stats/_biasedurn.cp313t-win_arm64.lib +0 -0
- scipy/stats/_biasedurn.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/stats/_levy_stable/levyst.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/stats/_qmc_cy.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_qmc_cy.pyi +54 -0
- scipy/stats/_qmvnt.py +454 -0
- scipy/stats/_qmvnt_cy.cp313t-win_arm64.lib +0 -0
- scipy/stats/_qmvnt_cy.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_quantile.py +335 -0
- scipy/stats/_rcont/__init__.py +4 -0
- scipy/stats/_rcont/rcont.cp313t-win_arm64.lib +0 -0
- scipy/stats/_rcont/rcont.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/stats/_sobol.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_sobol.pyi +54 -0
- scipy/stats/_sobol_direction_numbers.npz +0 -0
- scipy/stats/_stats.cp313t-win_arm64.lib +0 -0
- scipy/stats/_stats.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/stats/_stats_pythran.cp313t-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.cp313t-win_arm64.lib +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp313t-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
@@ -0,0 +1,1385 @@
|
|
1
|
+
# mypy: disable-error-code="attr-defined"
|
2
|
+
import math
|
3
|
+
import numpy as np
|
4
|
+
from scipy import special
|
5
|
+
import scipy._lib._elementwise_iterative_method as eim
|
6
|
+
from scipy._lib._util import _RichResult
|
7
|
+
from scipy._lib._array_api import (array_namespace, xp_copy, xp_ravel,
|
8
|
+
xp_promote)
|
9
|
+
|
10
|
+
|
11
|
+
__all__ = ['nsum']
|
12
|
+
|
13
|
+
|
14
|
+
# todo:
|
15
|
+
# figure out warning situation
|
16
|
+
# address https://github.com/scipy/scipy/pull/18650#discussion_r1233032521
|
17
|
+
# without `minweight`, we are also suppressing infinities within the interval.
|
18
|
+
# Is that OK? If so, we can probably get rid of `status=3`.
|
19
|
+
# Add heuristic to stop when improvement is too slow / antithrashing
|
20
|
+
# support singularities? interval subdivision? this feature will be added
|
21
|
+
# eventually, but do we adjust the interface now?
|
22
|
+
# When doing log-integration, should the tolerances control the error of the
|
23
|
+
# log-integral or the error of the integral? The trouble is that `log`
|
24
|
+
# inherently looses some precision so it may not be possible to refine
|
25
|
+
# the integral further. Example: 7th moment of stats.f(15, 20)
|
26
|
+
# respect function evaluation limit?
|
27
|
+
# make public?
|
28
|
+
|
29
|
+
|
30
|
+
def tanhsinh(f, a, b, *, args=(), log=False, maxlevel=None, minlevel=2,
|
31
|
+
atol=None, rtol=None, preserve_shape=False, callback=None):
|
32
|
+
"""Evaluate a convergent integral numerically using tanh-sinh quadrature.
|
33
|
+
|
34
|
+
In practice, tanh-sinh quadrature achieves quadratic convergence for
|
35
|
+
many integrands: the number of accurate *digits* scales roughly linearly
|
36
|
+
with the number of function evaluations [1]_.
|
37
|
+
|
38
|
+
Either or both of the limits of integration may be infinite, and
|
39
|
+
singularities at the endpoints are acceptable. Divergent integrals and
|
40
|
+
integrands with non-finite derivatives or singularities within an interval
|
41
|
+
are out of scope, but the latter may be evaluated be calling `tanhsinh` on
|
42
|
+
each sub-interval separately.
|
43
|
+
|
44
|
+
Parameters
|
45
|
+
----------
|
46
|
+
f : callable
|
47
|
+
The function to be integrated. The signature must be::
|
48
|
+
|
49
|
+
f(xi: ndarray, *argsi) -> ndarray
|
50
|
+
|
51
|
+
where each element of ``xi`` is a finite real number and ``argsi`` is a tuple,
|
52
|
+
which may contain an arbitrary number of arrays that are broadcastable
|
53
|
+
with ``xi``. `f` must be an elementwise function: see documentation of parameter
|
54
|
+
`preserve_shape` for details. It must not mutate the array ``xi`` or the arrays
|
55
|
+
in ``argsi``.
|
56
|
+
If ``f`` returns a value with complex dtype when evaluated at
|
57
|
+
either endpoint, subsequent arguments ``x`` will have complex dtype
|
58
|
+
(but zero imaginary part).
|
59
|
+
a, b : float array_like
|
60
|
+
Real lower and upper limits of integration. Must be broadcastable with one
|
61
|
+
another and with arrays in `args`. Elements may be infinite.
|
62
|
+
args : tuple of array_like, optional
|
63
|
+
Additional positional array arguments to be passed to `f`. Arrays
|
64
|
+
must be broadcastable with one another and the arrays of `a` and `b`.
|
65
|
+
If the callable for which the root is desired requires arguments that are
|
66
|
+
not broadcastable with `x`, wrap that callable with `f` such that `f`
|
67
|
+
accepts only `x` and broadcastable ``*args``.
|
68
|
+
log : bool, default: False
|
69
|
+
Setting to True indicates that `f` returns the log of the integrand
|
70
|
+
and that `atol` and `rtol` are expressed as the logs of the absolute
|
71
|
+
and relative errors. In this case, the result object will contain the
|
72
|
+
log of the integral and error. This is useful for integrands for which
|
73
|
+
numerical underflow or overflow would lead to inaccuracies.
|
74
|
+
When ``log=True``, the integrand (the exponential of `f`) must be real,
|
75
|
+
but it may be negative, in which case the log of the integrand is a
|
76
|
+
complex number with an imaginary part that is an odd multiple of π.
|
77
|
+
maxlevel : int, default: 10
|
78
|
+
The maximum refinement level of the algorithm.
|
79
|
+
|
80
|
+
At the zeroth level, `f` is called once, performing 16 function
|
81
|
+
evaluations. At each subsequent level, `f` is called once more,
|
82
|
+
approximately doubling the number of function evaluations that have
|
83
|
+
been performed. Accordingly, for many integrands, each successive level
|
84
|
+
will double the number of accurate digits in the result (up to the
|
85
|
+
limits of floating point precision).
|
86
|
+
|
87
|
+
The algorithm will terminate after completing level `maxlevel` or after
|
88
|
+
another termination condition is satisfied, whichever comes first.
|
89
|
+
minlevel : int, default: 2
|
90
|
+
The level at which to begin iteration (default: 2). This does not
|
91
|
+
change the total number of function evaluations or the abscissae at
|
92
|
+
which the function is evaluated; it changes only the *number of times*
|
93
|
+
`f` is called. If ``minlevel=k``, then the integrand is evaluated at
|
94
|
+
all abscissae from levels ``0`` through ``k`` in a single call.
|
95
|
+
Note that if `minlevel` exceeds `maxlevel`, the provided `minlevel` is
|
96
|
+
ignored, and `minlevel` is set equal to `maxlevel`.
|
97
|
+
atol, rtol : float, optional
|
98
|
+
Absolute termination tolerance (default: 0) and relative termination
|
99
|
+
tolerance (default: ``eps**0.75``, where ``eps`` is the precision of
|
100
|
+
the result dtype), respectively. Must be non-negative and finite if
|
101
|
+
`log` is False, and must be expressed as the log of a non-negative and
|
102
|
+
finite number if `log` is True. Iteration will stop when
|
103
|
+
``res.error < atol`` or ``res.error < res.integral * rtol``.
|
104
|
+
preserve_shape : bool, default: False
|
105
|
+
In the following, "arguments of `f`" refers to the array ``xi`` and
|
106
|
+
any arrays within ``argsi``. Let ``shape`` be the broadcasted shape
|
107
|
+
of `a`, `b`, and all elements of `args` (which is conceptually
|
108
|
+
distinct from ``xi` and ``argsi`` passed into `f`).
|
109
|
+
|
110
|
+
- When ``preserve_shape=False`` (default), `f` must accept arguments
|
111
|
+
of *any* broadcastable shapes.
|
112
|
+
|
113
|
+
- When ``preserve_shape=True``, `f` must accept arguments of shape
|
114
|
+
``shape`` *or* ``shape + (n,)``, where ``(n,)`` is the number of
|
115
|
+
abscissae at which the function is being evaluated.
|
116
|
+
|
117
|
+
In either case, for each scalar element ``xi[j]`` within ``xi``, the array
|
118
|
+
returned by `f` must include the scalar ``f(xi[j])`` at the same index.
|
119
|
+
Consequently, the shape of the output is always the shape of the input
|
120
|
+
``xi``.
|
121
|
+
|
122
|
+
See Examples.
|
123
|
+
|
124
|
+
callback : callable, optional
|
125
|
+
An optional user-supplied function to be called before the first
|
126
|
+
iteration and after each iteration.
|
127
|
+
Called as ``callback(res)``, where ``res`` is a ``_RichResult``
|
128
|
+
similar to that returned by `tanhsinh` (but containing the
|
129
|
+
current iterate's values of all variables). If `callback` raises a
|
130
|
+
``StopIteration``, the algorithm will terminate immediately and
|
131
|
+
`tanhsinh` will return a result object. `callback` must not mutate
|
132
|
+
`res` or its attributes.
|
133
|
+
|
134
|
+
Returns
|
135
|
+
-------
|
136
|
+
res : _RichResult
|
137
|
+
An object similar to an instance of `scipy.optimize.OptimizeResult` with the
|
138
|
+
following attributes. (The descriptions are written as though the values will
|
139
|
+
be scalars; however, if `f` returns an array, the outputs will be
|
140
|
+
arrays of the same shape.)
|
141
|
+
|
142
|
+
success : bool array
|
143
|
+
``True`` when the algorithm terminated successfully (status ``0``).
|
144
|
+
``False`` otherwise.
|
145
|
+
status : int array
|
146
|
+
An integer representing the exit status of the algorithm.
|
147
|
+
|
148
|
+
``0`` : The algorithm converged to the specified tolerances.
|
149
|
+
``-1`` : (unused)
|
150
|
+
``-2`` : The maximum number of iterations was reached.
|
151
|
+
``-3`` : A non-finite value was encountered.
|
152
|
+
``-4`` : Iteration was terminated by `callback`.
|
153
|
+
``1`` : The algorithm is proceeding normally (in `callback` only).
|
154
|
+
|
155
|
+
integral : float array
|
156
|
+
An estimate of the integral.
|
157
|
+
error : float array
|
158
|
+
An estimate of the error. Only available if level two or higher
|
159
|
+
has been completed; otherwise NaN.
|
160
|
+
maxlevel : int array
|
161
|
+
The maximum refinement level used.
|
162
|
+
nfev : int array
|
163
|
+
The number of points at which `f` was evaluated.
|
164
|
+
|
165
|
+
See Also
|
166
|
+
--------
|
167
|
+
quad
|
168
|
+
|
169
|
+
Notes
|
170
|
+
-----
|
171
|
+
Implements the algorithm as described in [1]_ with minor adaptations for
|
172
|
+
finite-precision arithmetic, including some described by [2]_ and [3]_. The
|
173
|
+
tanh-sinh scheme was originally introduced in [4]_.
|
174
|
+
|
175
|
+
Two error estimation schemes are described in [1]_ Section 5: one attempts to
|
176
|
+
detect and exploit quadratic convergence; the other simply compares the integral
|
177
|
+
estimates at successive levels. While neither is theoretically rigorous or
|
178
|
+
conservative, both work well in practice. Our error estimate uses the minimum of
|
179
|
+
these two schemes with a lower bound of ``eps * res.integral``.
|
180
|
+
|
181
|
+
Due to floating-point error in the abscissae, the function may be evaluated
|
182
|
+
at the endpoints of the interval during iterations, but the values returned by
|
183
|
+
the function at the endpoints will be ignored.
|
184
|
+
|
185
|
+
References
|
186
|
+
----------
|
187
|
+
.. [1] Bailey, David H., Karthik Jeyabalan, and Xiaoye S. Li. "A comparison of
|
188
|
+
three high-precision quadrature schemes." Experimental Mathematics 14.3
|
189
|
+
(2005): 317-329.
|
190
|
+
.. [2] Vanherck, Joren, Bart Sorée, and Wim Magnus. "Tanh-sinh quadrature for
|
191
|
+
single and multiple integration using floating-point arithmetic."
|
192
|
+
arXiv preprint arXiv:2007.15057 (2020).
|
193
|
+
.. [3] van Engelen, Robert A. "Improving the Double Exponential Quadrature
|
194
|
+
Tanh-Sinh, Sinh-Sinh and Exp-Sinh Formulas."
|
195
|
+
https://www.genivia.com/files/qthsh.pdf
|
196
|
+
.. [4] Takahasi, Hidetosi, and Masatake Mori. "Double exponential formulas for
|
197
|
+
numerical integration." Publications of the Research Institute for
|
198
|
+
Mathematical Sciences 9.3 (1974): 721-741.
|
199
|
+
|
200
|
+
Examples
|
201
|
+
--------
|
202
|
+
Evaluate the Gaussian integral:
|
203
|
+
|
204
|
+
>>> import numpy as np
|
205
|
+
>>> from scipy.integrate import tanhsinh
|
206
|
+
>>> def f(x):
|
207
|
+
... return np.exp(-x**2)
|
208
|
+
>>> res = tanhsinh(f, -np.inf, np.inf)
|
209
|
+
>>> res.integral # true value is np.sqrt(np.pi), 1.7724538509055159
|
210
|
+
1.7724538509055159
|
211
|
+
>>> res.error # actual error is 0
|
212
|
+
4.0007963937534104e-16
|
213
|
+
|
214
|
+
The value of the Gaussian function (bell curve) is nearly zero for
|
215
|
+
arguments sufficiently far from zero, so the value of the integral
|
216
|
+
over a finite interval is nearly the same.
|
217
|
+
|
218
|
+
>>> tanhsinh(f, -20, 20).integral
|
219
|
+
1.772453850905518
|
220
|
+
|
221
|
+
However, with unfavorable integration limits, the integration scheme
|
222
|
+
may not be able to find the important region.
|
223
|
+
|
224
|
+
>>> tanhsinh(f, -np.inf, 1000).integral
|
225
|
+
4.500490856616431
|
226
|
+
|
227
|
+
In such cases, or when there are singularities within the interval,
|
228
|
+
break the integral into parts with endpoints at the important points.
|
229
|
+
|
230
|
+
>>> tanhsinh(f, -np.inf, 0).integral + tanhsinh(f, 0, 1000).integral
|
231
|
+
1.772453850905404
|
232
|
+
|
233
|
+
For integration involving very large or very small magnitudes, use
|
234
|
+
log-integration. (For illustrative purposes, the following example shows a
|
235
|
+
case in which both regular and log-integration work, but for more extreme
|
236
|
+
limits of integration, log-integration would avoid the underflow
|
237
|
+
experienced when evaluating the integral normally.)
|
238
|
+
|
239
|
+
>>> res = tanhsinh(f, 20, 30, rtol=1e-10)
|
240
|
+
>>> res.integral, res.error
|
241
|
+
(4.7819613911309014e-176, 4.670364401645202e-187)
|
242
|
+
>>> def log_f(x):
|
243
|
+
... return -x**2
|
244
|
+
>>> res = tanhsinh(log_f, 20, 30, log=True, rtol=np.log(1e-10))
|
245
|
+
>>> np.exp(res.integral), np.exp(res.error)
|
246
|
+
(4.7819613911306924e-176, 4.670364401645093e-187)
|
247
|
+
|
248
|
+
The limits of integration and elements of `args` may be broadcastable
|
249
|
+
arrays, and integration is performed elementwise.
|
250
|
+
|
251
|
+
>>> from scipy import stats
|
252
|
+
>>> dist = stats.gausshyper(13.8, 3.12, 2.51, 5.18)
|
253
|
+
>>> a, b = dist.support()
|
254
|
+
>>> x = np.linspace(a, b, 100)
|
255
|
+
>>> res = tanhsinh(dist.pdf, a, x)
|
256
|
+
>>> ref = dist.cdf(x)
|
257
|
+
>>> np.allclose(res.integral, ref)
|
258
|
+
True
|
259
|
+
|
260
|
+
By default, `preserve_shape` is False, and therefore the callable
|
261
|
+
`f` may be called with arrays of any broadcastable shapes.
|
262
|
+
For example:
|
263
|
+
|
264
|
+
>>> shapes = []
|
265
|
+
>>> def f(x, c):
|
266
|
+
... shape = np.broadcast_shapes(x.shape, c.shape)
|
267
|
+
... shapes.append(shape)
|
268
|
+
... return np.sin(c*x)
|
269
|
+
>>>
|
270
|
+
>>> c = [1, 10, 30, 100]
|
271
|
+
>>> res = tanhsinh(f, 0, 1, args=(c,), minlevel=1)
|
272
|
+
>>> shapes
|
273
|
+
[(4,), (4, 34), (4, 32), (3, 64), (2, 128), (1, 256)]
|
274
|
+
|
275
|
+
To understand where these shapes are coming from - and to better
|
276
|
+
understand how `tanhsinh` computes accurate results - note that
|
277
|
+
higher values of ``c`` correspond with higher frequency sinusoids.
|
278
|
+
The higher frequency sinusoids make the integrand more complicated,
|
279
|
+
so more function evaluations are required to achieve the target
|
280
|
+
accuracy:
|
281
|
+
|
282
|
+
>>> res.nfev
|
283
|
+
array([ 67, 131, 259, 515], dtype=int32)
|
284
|
+
|
285
|
+
The initial ``shape``, ``(4,)``, corresponds with evaluating the
|
286
|
+
integrand at a single abscissa and all four frequencies; this is used
|
287
|
+
for input validation and to determine the size and dtype of the arrays
|
288
|
+
that store results. The next shape corresponds with evaluating the
|
289
|
+
integrand at an initial grid of abscissae and all four frequencies.
|
290
|
+
Successive calls to the function double the total number of abscissae at
|
291
|
+
which the function has been evaluated. However, in later function
|
292
|
+
evaluations, the integrand is evaluated at fewer frequencies because
|
293
|
+
the corresponding integral has already converged to the required
|
294
|
+
tolerance. This saves function evaluations to improve performance, but
|
295
|
+
it requires the function to accept arguments of any shape.
|
296
|
+
|
297
|
+
"Vector-valued" integrands, such as those written for use with
|
298
|
+
`scipy.integrate.quad_vec`, are unlikely to satisfy this requirement.
|
299
|
+
For example, consider
|
300
|
+
|
301
|
+
>>> def f(x):
|
302
|
+
... return [x, np.sin(10*x), np.cos(30*x), x*np.sin(100*x)**2]
|
303
|
+
|
304
|
+
This integrand is not compatible with `tanhsinh` as written; for instance,
|
305
|
+
the shape of the output will not be the same as the shape of ``x``. Such a
|
306
|
+
function *could* be converted to a compatible form with the introduction of
|
307
|
+
additional parameters, but this would be inconvenient. In such cases,
|
308
|
+
a simpler solution would be to use `preserve_shape`.
|
309
|
+
|
310
|
+
>>> shapes = []
|
311
|
+
>>> def f(x):
|
312
|
+
... shapes.append(x.shape)
|
313
|
+
... x0, x1, x2, x3 = x
|
314
|
+
... return [x0, np.sin(10*x1), np.cos(30*x2), x3*np.sin(100*x3)]
|
315
|
+
>>>
|
316
|
+
>>> a = np.zeros(4)
|
317
|
+
>>> res = tanhsinh(f, a, 1, preserve_shape=True)
|
318
|
+
>>> shapes
|
319
|
+
[(4,), (4, 66), (4, 64), (4, 128), (4, 256)]
|
320
|
+
|
321
|
+
Here, the broadcasted shape of `a` and `b` is ``(4,)``. With
|
322
|
+
``preserve_shape=True``, the function may be called with argument
|
323
|
+
``x`` of shape ``(4,)`` or ``(4, n)``, and this is what we observe.
|
324
|
+
|
325
|
+
"""
|
326
|
+
maxfun = None # unused right now
|
327
|
+
(f, a, b, log, maxfun, maxlevel, minlevel,
|
328
|
+
atol, rtol, args, preserve_shape, callback, xp) = _tanhsinh_iv(
|
329
|
+
f, a, b, log, maxfun, maxlevel, minlevel, atol,
|
330
|
+
rtol, args, preserve_shape, callback)
|
331
|
+
|
332
|
+
# Initialization
|
333
|
+
# `eim._initialize` does several important jobs, including
|
334
|
+
# ensuring that limits, each of the `args`, and the output of `f`
|
335
|
+
# broadcast correctly and are of consistent types. To save a function
|
336
|
+
# evaluation, I pass the midpoint of the integration interval. This comes
|
337
|
+
# at a cost of some gymnastics to ensure that the midpoint has the right
|
338
|
+
# shape and dtype. Did you know that 0d and >0d arrays follow different
|
339
|
+
# type promotion rules?
|
340
|
+
with np.errstate(over='ignore', invalid='ignore', divide='ignore'):
|
341
|
+
c = xp.reshape((xp_ravel(a) + xp_ravel(b))/2, a.shape)
|
342
|
+
inf_a, inf_b = xp.isinf(a), xp.isinf(b)
|
343
|
+
c[inf_a] = b[inf_a] - 1. # takes care of infinite a
|
344
|
+
c[inf_b] = a[inf_b] + 1. # takes care of infinite b
|
345
|
+
c[inf_a & inf_b] = 0. # takes care of infinite a and b
|
346
|
+
temp = eim._initialize(f, (c,), args, complex_ok=True,
|
347
|
+
preserve_shape=preserve_shape, xp=xp)
|
348
|
+
f, xs, fs, args, shape, dtype, xp = temp
|
349
|
+
a = xp_ravel(xp.astype(xp.broadcast_to(a, shape), dtype))
|
350
|
+
b = xp_ravel(xp.astype(xp.broadcast_to(b, shape), dtype))
|
351
|
+
|
352
|
+
# Transform improper integrals
|
353
|
+
a, b, a0, negative, abinf, ainf, binf = _transform_integrals(a, b, xp)
|
354
|
+
|
355
|
+
# Define variables we'll need
|
356
|
+
nit, nfev = 0, 1 # one function evaluation performed above
|
357
|
+
zero = -xp.inf if log else 0
|
358
|
+
pi = xp.asarray(xp.pi, dtype=dtype)[()]
|
359
|
+
maxiter = maxlevel - minlevel + 1
|
360
|
+
eps = xp.finfo(dtype).eps
|
361
|
+
if rtol is None:
|
362
|
+
rtol = 0.75*math.log(eps) if log else eps**0.75
|
363
|
+
|
364
|
+
Sn = xp_ravel(xp.full(shape, zero, dtype=dtype)) # latest integral estimate
|
365
|
+
Sn[xp.isnan(a) | xp.isnan(b) | xp.isnan(fs[0])] = xp.nan
|
366
|
+
Sk = xp.reshape(xp.empty_like(Sn), (-1, 1))[:, 0:0] # all integral estimates
|
367
|
+
aerr = xp_ravel(xp.full(shape, xp.nan, dtype=dtype)) # absolute error
|
368
|
+
status = xp_ravel(xp.full(shape, eim._EINPROGRESS, dtype=xp.int32))
|
369
|
+
h0 = _get_base_step(dtype, xp)
|
370
|
+
h0 = xp.real(h0) # base step
|
371
|
+
|
372
|
+
# For term `d4` of error estimate ([1] Section 5), we need to keep the
|
373
|
+
# most extreme abscissae and corresponding `fj`s, `wj`s in Euler-Maclaurin
|
374
|
+
# sum. Here, we initialize these variables.
|
375
|
+
xr0 = xp_ravel(xp.full(shape, -xp.inf, dtype=dtype))
|
376
|
+
fr0 = xp_ravel(xp.full(shape, xp.nan, dtype=dtype))
|
377
|
+
wr0 = xp_ravel(xp.zeros(shape, dtype=dtype))
|
378
|
+
xl0 = xp_ravel(xp.full(shape, xp.inf, dtype=dtype))
|
379
|
+
fl0 = xp_ravel(xp.full(shape, xp.nan, dtype=dtype))
|
380
|
+
wl0 = xp_ravel(xp.zeros(shape, dtype=dtype))
|
381
|
+
d4 = xp_ravel(xp.zeros(shape, dtype=dtype))
|
382
|
+
|
383
|
+
work = _RichResult(
|
384
|
+
Sn=Sn, Sk=Sk, aerr=aerr, h=h0, log=log, dtype=dtype, pi=pi, eps=eps,
|
385
|
+
a=xp.reshape(a, (-1, 1)), b=xp.reshape(b, (-1, 1)), # integration limits
|
386
|
+
n=minlevel, nit=nit, nfev=nfev, status=status, # iter/eval counts
|
387
|
+
xr0=xr0, fr0=fr0, wr0=wr0, xl0=xl0, fl0=fl0, wl0=wl0, d4=d4, # err est
|
388
|
+
ainf=ainf, binf=binf, abinf=abinf, a0=xp.reshape(a0, (-1, 1)), # transforms
|
389
|
+
# Store the xjc/wj pair cache in an object so they can't get compressed
|
390
|
+
# Using RichResult to allow dot notation, but a dictionary would suffice
|
391
|
+
pair_cache=_RichResult(xjc=None, wj=None, indices=[0], h0=None)) # pair cache
|
392
|
+
|
393
|
+
# Constant scalars don't need to be put in `work` unless they need to be
|
394
|
+
# passed outside `tanhsinh`. Examples: atol, rtol, h0, minlevel.
|
395
|
+
|
396
|
+
# Correspondence between terms in the `work` object and the result
|
397
|
+
res_work_pairs = [('status', 'status'), ('integral', 'Sn'),
|
398
|
+
('error', 'aerr'), ('nit', 'nit'), ('nfev', 'nfev')]
|
399
|
+
|
400
|
+
def pre_func_eval(work):
|
401
|
+
# Determine abscissae at which to evaluate `f`
|
402
|
+
work.h = h0 / 2**work.n
|
403
|
+
xjc, wj = _get_pairs(work.n, h0, dtype=work.dtype,
|
404
|
+
inclusive=(work.n == minlevel), xp=xp, work=work)
|
405
|
+
work.xj, work.wj = _transform_to_limits(xjc, wj, work.a, work.b, xp)
|
406
|
+
|
407
|
+
# Perform abscissae substitutions for infinite limits of integration
|
408
|
+
xj = xp_copy(work.xj)
|
409
|
+
xj[work.abinf] = xj[work.abinf] / (1 - xp.real(xj[work.abinf])**2)
|
410
|
+
xj[work.binf] = 1/xj[work.binf] - 1 + work.a0[work.binf]
|
411
|
+
xj[work.ainf] *= -1
|
412
|
+
return xj
|
413
|
+
|
414
|
+
def post_func_eval(x, fj, work):
|
415
|
+
# Weight integrand as required by substitutions for infinite limits
|
416
|
+
if work.log:
|
417
|
+
fj[work.abinf] += (xp.log(1 + work.xj[work.abinf]**2)
|
418
|
+
- 2*xp.log(1 - work.xj[work.abinf]**2))
|
419
|
+
fj[work.binf] -= 2 * xp.log(work.xj[work.binf])
|
420
|
+
else:
|
421
|
+
fj[work.abinf] *= ((1 + work.xj[work.abinf]**2) /
|
422
|
+
(1 - work.xj[work.abinf]**2)**2)
|
423
|
+
fj[work.binf] *= work.xj[work.binf]**-2.
|
424
|
+
|
425
|
+
# Estimate integral with Euler-Maclaurin Sum
|
426
|
+
fjwj, Sn = _euler_maclaurin_sum(fj, work, xp)
|
427
|
+
if work.Sk.shape[-1]:
|
428
|
+
Snm1 = work.Sk[:, -1]
|
429
|
+
Sn = (special.logsumexp(xp.stack([Snm1 - math.log(2), Sn]), axis=0) if log
|
430
|
+
else Snm1 / 2 + Sn)
|
431
|
+
|
432
|
+
work.fjwj = fjwj
|
433
|
+
work.Sn = Sn
|
434
|
+
|
435
|
+
def check_termination(work):
|
436
|
+
"""Terminate due to convergence or encountering non-finite values"""
|
437
|
+
stop = xp.zeros(work.Sn.shape, dtype=bool)
|
438
|
+
|
439
|
+
# Terminate before first iteration if integration limits are equal
|
440
|
+
if work.nit == 0:
|
441
|
+
i = xp_ravel(work.a == work.b) # ravel singleton dimension
|
442
|
+
zero = xp.asarray(-xp.inf if log else 0.)
|
443
|
+
zero = xp.full(work.Sn.shape, zero, dtype=Sn.dtype)
|
444
|
+
zero[xp.isnan(Sn)] = xp.nan
|
445
|
+
work.Sn[i] = zero[i]
|
446
|
+
work.aerr[i] = zero[i]
|
447
|
+
work.status[i] = eim._ECONVERGED
|
448
|
+
stop[i] = True
|
449
|
+
else:
|
450
|
+
# Terminate if convergence criterion is met
|
451
|
+
rerr, aerr = _estimate_error(work, xp)
|
452
|
+
i = (rerr < rtol) | (aerr < atol)
|
453
|
+
work.aerr = xp.reshape(xp.astype(aerr, work.dtype), work.Sn.shape)
|
454
|
+
work.status[i] = eim._ECONVERGED
|
455
|
+
stop[i] = True
|
456
|
+
|
457
|
+
# Terminate if integral estimate becomes invalid
|
458
|
+
if log:
|
459
|
+
Sn_real = xp.real(work.Sn)
|
460
|
+
Sn_pos_inf = xp.isinf(Sn_real) & (Sn_real > 0)
|
461
|
+
i = (Sn_pos_inf | xp.isnan(work.Sn)) & ~stop
|
462
|
+
else:
|
463
|
+
i = ~xp.isfinite(work.Sn) & ~stop
|
464
|
+
work.status[i] = eim._EVALUEERR
|
465
|
+
stop[i] = True
|
466
|
+
|
467
|
+
return stop
|
468
|
+
|
469
|
+
def post_termination_check(work):
|
470
|
+
work.n += 1
|
471
|
+
work.Sk = xp.concat((work.Sk, work.Sn[:, xp.newaxis]), axis=-1)
|
472
|
+
return
|
473
|
+
|
474
|
+
def customize_result(res, shape):
|
475
|
+
# If the integration limits were such that b < a, we reversed them
|
476
|
+
# to perform the calculation, and the final result needs to be negated.
|
477
|
+
if log and xp.any(negative):
|
478
|
+
res['integral'] = res['integral'] + negative * xp.pi * 1.0j
|
479
|
+
else:
|
480
|
+
res['integral'][negative] *= -1
|
481
|
+
|
482
|
+
# For this algorithm, it seems more appropriate to report the maximum
|
483
|
+
# level rather than the number of iterations in which it was performed.
|
484
|
+
res['maxlevel'] = minlevel + res['nit'] - 1
|
485
|
+
res['maxlevel'][res['nit'] == 0] = -1
|
486
|
+
del res['nit']
|
487
|
+
return shape
|
488
|
+
|
489
|
+
# Suppress all warnings initially, since there are many places in the code
|
490
|
+
# for which this is expected behavior.
|
491
|
+
with np.errstate(over='ignore', invalid='ignore', divide='ignore'):
|
492
|
+
res = eim._loop(work, callback, shape, maxiter, f, args, dtype, pre_func_eval,
|
493
|
+
post_func_eval, check_termination, post_termination_check,
|
494
|
+
customize_result, res_work_pairs, xp, preserve_shape)
|
495
|
+
return res
|
496
|
+
|
497
|
+
|
498
|
+
def _get_base_step(dtype, xp):
|
499
|
+
# Compute the base step length for the provided dtype. Theoretically, the
|
500
|
+
# Euler-Maclaurin sum is infinite, but it gets cut off when either the
|
501
|
+
# weights underflow or the abscissae cannot be distinguished from the
|
502
|
+
# limits of integration. The latter happens to occur first for float32 and
|
503
|
+
# float64, and it occurs when `xjc` (the abscissa complement)
|
504
|
+
# in `_compute_pair` underflows. We can solve for the argument `tmax` at
|
505
|
+
# which it will underflow using [2] Eq. 13.
|
506
|
+
fmin = 4*xp.finfo(dtype).smallest_normal # stay a little away from the limit
|
507
|
+
tmax = math.asinh(math.log(2/fmin - 1) / xp.pi)
|
508
|
+
|
509
|
+
# Based on this, we can choose a base step size `h` for level 0.
|
510
|
+
# The number of function evaluations will be `2 + m*2^(k+1)`, where `k` is
|
511
|
+
# the level and `m` is an integer we get to choose. I choose
|
512
|
+
# m = _N_BASE_STEPS = `8` somewhat arbitrarily, but a rationale is that a
|
513
|
+
# power of 2 makes floating point arithmetic more predictable. It also
|
514
|
+
# results in a base step size close to `1`, which is what [1] uses (and I
|
515
|
+
# used here until I found [2] and these ideas settled).
|
516
|
+
h0 = tmax / _N_BASE_STEPS
|
517
|
+
return xp.asarray(h0, dtype=dtype)[()]
|
518
|
+
|
519
|
+
|
520
|
+
_N_BASE_STEPS = 8
|
521
|
+
|
522
|
+
|
523
|
+
def _compute_pair(k, h0, xp):
|
524
|
+
# Compute the abscissa-weight pairs for each level k. See [1] page 9.
|
525
|
+
|
526
|
+
# For now, we compute and store in 64-bit precision. If higher-precision
|
527
|
+
# data types become better supported, it would be good to compute these
|
528
|
+
# using the highest precision available. Or, once there is an Array API-
|
529
|
+
# compatible arbitrary precision array, we can compute at the required
|
530
|
+
# precision.
|
531
|
+
|
532
|
+
# "....each level k of abscissa-weight pairs uses h = 2 **-k"
|
533
|
+
# We adapt to floating point arithmetic using ideas of [2].
|
534
|
+
h = h0 / 2**k
|
535
|
+
max = _N_BASE_STEPS * 2**k
|
536
|
+
|
537
|
+
# For iterations after the first, "....the integrand function needs to be
|
538
|
+
# evaluated only at the odd-indexed abscissas at each level."
|
539
|
+
j = xp.arange(max+1) if k == 0 else xp.arange(1, max+1, 2)
|
540
|
+
jh = j * h
|
541
|
+
|
542
|
+
# "In this case... the weights wj = u1/cosh(u2)^2, where..."
|
543
|
+
pi_2 = xp.pi / 2
|
544
|
+
u1 = pi_2*xp.cosh(jh)
|
545
|
+
u2 = pi_2*xp.sinh(jh)
|
546
|
+
# Denominators get big here. Overflow then underflow doesn't need warning.
|
547
|
+
# with np.errstate(under='ignore', over='ignore'):
|
548
|
+
wj = u1 / xp.cosh(u2)**2
|
549
|
+
# "We actually store 1-xj = 1/(...)."
|
550
|
+
xjc = 1 / (xp.exp(u2) * xp.cosh(u2)) # complement of xj = xp.tanh(u2)
|
551
|
+
|
552
|
+
# When level k == 0, the zeroth xj corresponds with xj = 0. To simplify
|
553
|
+
# code, the function will be evaluated there twice; each gets half weight.
|
554
|
+
wj[0] = wj[0] / 2 if k == 0 else wj[0]
|
555
|
+
|
556
|
+
return xjc, wj # store at full precision
|
557
|
+
|
558
|
+
|
559
|
+
def _pair_cache(k, h0, xp, work):
|
560
|
+
# Cache the abscissa-weight pairs up to a specified level.
|
561
|
+
# Abscissae and weights of consecutive levels are concatenated.
|
562
|
+
# `index` records the indices that correspond with each level:
|
563
|
+
# `xjc[index[k]:index[k+1]` extracts the level `k` abscissae.
|
564
|
+
if not isinstance(h0, type(work.pair_cache.h0)) or h0 != work.pair_cache.h0:
|
565
|
+
work.pair_cache.xjc = xp.empty(0)
|
566
|
+
work.pair_cache.wj = xp.empty(0)
|
567
|
+
work.pair_cache.indices = [0]
|
568
|
+
|
569
|
+
xjcs = [work.pair_cache.xjc]
|
570
|
+
wjs = [work.pair_cache.wj]
|
571
|
+
|
572
|
+
for i in range(len(work.pair_cache.indices)-1, k + 1):
|
573
|
+
xjc, wj = _compute_pair(i, h0, xp)
|
574
|
+
xjcs.append(xjc)
|
575
|
+
wjs.append(wj)
|
576
|
+
work.pair_cache.indices.append(work.pair_cache.indices[-1] + xjc.shape[0])
|
577
|
+
|
578
|
+
work.pair_cache.xjc = xp.concat(xjcs)
|
579
|
+
work.pair_cache.wj = xp.concat(wjs)
|
580
|
+
work.pair_cache.h0 = h0
|
581
|
+
|
582
|
+
|
583
|
+
def _get_pairs(k, h0, inclusive, dtype, xp, work):
|
584
|
+
# Retrieve the specified abscissa-weight pairs from the cache
|
585
|
+
# If `inclusive`, return all up to and including the specified level
|
586
|
+
if (len(work.pair_cache.indices) <= k+2
|
587
|
+
or not isinstance (h0, type(work.pair_cache.h0))
|
588
|
+
or h0 != work.pair_cache.h0):
|
589
|
+
_pair_cache(k, h0, xp, work)
|
590
|
+
|
591
|
+
xjc = work.pair_cache.xjc
|
592
|
+
wj = work.pair_cache.wj
|
593
|
+
indices = work.pair_cache.indices
|
594
|
+
|
595
|
+
start = 0 if inclusive else indices[k]
|
596
|
+
end = indices[k+1]
|
597
|
+
|
598
|
+
return xp.astype(xjc[start:end], dtype), xp.astype(wj[start:end], dtype)
|
599
|
+
|
600
|
+
|
601
|
+
def _transform_to_limits(xjc, wj, a, b, xp):
|
602
|
+
# Transform integral according to user-specified limits. This is just
|
603
|
+
# math that follows from the fact that the standard limits are (-1, 1).
|
604
|
+
# Note: If we had stored xj instead of xjc, we would have
|
605
|
+
# xj = alpha * xj + beta, where beta = (a + b)/2
|
606
|
+
alpha = (b - a) / 2
|
607
|
+
xj = xp.concat((-alpha * xjc + b, alpha * xjc + a), axis=-1)
|
608
|
+
wj = wj*alpha # arguments get broadcasted, so we can't use *=
|
609
|
+
wj = xp.concat((wj, wj), axis=-1)
|
610
|
+
|
611
|
+
# Points at the boundaries can be generated due to finite precision
|
612
|
+
# arithmetic, but these function values aren't supposed to be included in
|
613
|
+
# the Euler-Maclaurin sum. Ideally we wouldn't evaluate the function at
|
614
|
+
# these points; however, we can't easily filter out points since this
|
615
|
+
# function is vectorized. Instead, zero the weights.
|
616
|
+
# Note: values may have complex dtype, but have zero imaginary part
|
617
|
+
xj_real, a_real, b_real = xp.real(xj), xp.real(a), xp.real(b)
|
618
|
+
invalid = (xj_real <= a_real) | (xj_real >= b_real)
|
619
|
+
wj[invalid] = 0
|
620
|
+
return xj, wj
|
621
|
+
|
622
|
+
|
623
|
+
def _euler_maclaurin_sum(fj, work, xp):
|
624
|
+
# Perform the Euler-Maclaurin Sum, [1] Section 4
|
625
|
+
|
626
|
+
# The error estimate needs to know the magnitude of the last term
|
627
|
+
# omitted from the Euler-Maclaurin sum. This is a bit involved because
|
628
|
+
# it may have been computed at a previous level. I sure hope it's worth
|
629
|
+
# all the trouble.
|
630
|
+
xr0, fr0, wr0 = work.xr0, work.fr0, work.wr0
|
631
|
+
xl0, fl0, wl0 = work.xl0, work.fl0, work.wl0
|
632
|
+
|
633
|
+
# It is much more convenient to work with the transposes of our work
|
634
|
+
# variables here.
|
635
|
+
xj, fj, wj = work.xj.T, fj.T, work.wj.T
|
636
|
+
n_x, n_active = xj.shape # number of abscissae, number of active elements
|
637
|
+
|
638
|
+
# We'll work with the left and right sides separately
|
639
|
+
xr, xl = xp_copy(xp.reshape(xj, (2, n_x // 2, n_active))) # this gets modified
|
640
|
+
fr, fl = xp.reshape(fj, (2, n_x // 2, n_active))
|
641
|
+
wr, wl = xp.reshape(wj, (2, n_x // 2, n_active))
|
642
|
+
|
643
|
+
invalid_r = ~xp.isfinite(fr) | (wr == 0)
|
644
|
+
invalid_l = ~xp.isfinite(fl) | (wl == 0)
|
645
|
+
|
646
|
+
# integer index of the maximum abscissa at this level
|
647
|
+
xr[invalid_r] = -xp.inf
|
648
|
+
ir = xp.argmax(xp.real(xr), axis=0, keepdims=True)
|
649
|
+
# abscissa, function value, and weight at this index
|
650
|
+
### Not Array API Compatible... yet ###
|
651
|
+
xr_max = xp.take_along_axis(xr, ir, axis=0)[0]
|
652
|
+
fr_max = xp.take_along_axis(fr, ir, axis=0)[0]
|
653
|
+
wr_max = xp.take_along_axis(wr, ir, axis=0)[0]
|
654
|
+
# boolean indices at which maximum abscissa at this level exceeds
|
655
|
+
# the incumbent maximum abscissa (from all previous levels)
|
656
|
+
# note: abscissa may have complex dtype, but will have zero imaginary part
|
657
|
+
j = xp.real(xr_max) > xp.real(xr0)
|
658
|
+
# Update record of the incumbent abscissa, function value, and weight
|
659
|
+
xr0[j] = xr_max[j]
|
660
|
+
fr0[j] = fr_max[j]
|
661
|
+
wr0[j] = wr_max[j]
|
662
|
+
|
663
|
+
# integer index of the minimum abscissa at this level
|
664
|
+
xl[invalid_l] = xp.inf
|
665
|
+
il = xp.argmin(xp.real(xl), axis=0, keepdims=True)
|
666
|
+
# abscissa, function value, and weight at this index
|
667
|
+
xl_min = xp.take_along_axis(xl, il, axis=0)[0]
|
668
|
+
fl_min = xp.take_along_axis(fl, il, axis=0)[0]
|
669
|
+
wl_min = xp.take_along_axis(wl, il, axis=0)[0]
|
670
|
+
# boolean indices at which minimum abscissa at this level is less than
|
671
|
+
# the incumbent minimum abscissa (from all previous levels)
|
672
|
+
# note: abscissa may have complex dtype, but will have zero imaginary part
|
673
|
+
j = xp.real(xl_min) < xp.real(xl0)
|
674
|
+
# Update record of the incumbent abscissa, function value, and weight
|
675
|
+
xl0[j] = xl_min[j]
|
676
|
+
fl0[j] = fl_min[j]
|
677
|
+
wl0[j] = wl_min[j]
|
678
|
+
fj = fj.T
|
679
|
+
|
680
|
+
# Compute the error estimate `d4` - the magnitude of the leftmost or
|
681
|
+
# rightmost term, whichever is greater.
|
682
|
+
flwl0 = fl0 + xp.log(wl0) if work.log else fl0 * wl0 # leftmost term
|
683
|
+
frwr0 = fr0 + xp.log(wr0) if work.log else fr0 * wr0 # rightmost term
|
684
|
+
magnitude = xp.real if work.log else xp.abs
|
685
|
+
work.d4 = xp.maximum(magnitude(flwl0), magnitude(frwr0))
|
686
|
+
|
687
|
+
# There are two approaches to dealing with function values that are
|
688
|
+
# numerically infinite due to approaching a singularity - zero them, or
|
689
|
+
# replace them with the function value at the nearest non-infinite point.
|
690
|
+
# [3] pg. 22 suggests the latter, so let's do that given that we have the
|
691
|
+
# information.
|
692
|
+
fr0b = xp.broadcast_to(fr0[xp.newaxis, :], fr.shape)
|
693
|
+
fl0b = xp.broadcast_to(fl0[xp.newaxis, :], fl.shape)
|
694
|
+
fr[invalid_r] = fr0b[invalid_r]
|
695
|
+
fl[invalid_l] = fl0b[invalid_l]
|
696
|
+
|
697
|
+
# When wj is zero, log emits a warning
|
698
|
+
# with np.errstate(divide='ignore'):
|
699
|
+
fjwj = fj + xp.log(work.wj) if work.log else fj * work.wj
|
700
|
+
|
701
|
+
# update integral estimate
|
702
|
+
Sn = (special.logsumexp(fjwj + xp.log(work.h), axis=-1) if work.log
|
703
|
+
else xp.sum(fjwj, axis=-1) * work.h)
|
704
|
+
|
705
|
+
work.xr0, work.fr0, work.wr0 = xr0, fr0, wr0
|
706
|
+
work.xl0, work.fl0, work.wl0 = xl0, fl0, wl0
|
707
|
+
|
708
|
+
return fjwj, Sn
|
709
|
+
|
710
|
+
|
711
|
+
def _estimate_error(work, xp):
|
712
|
+
# Estimate the error according to [1] Section 5
|
713
|
+
|
714
|
+
if work.n == 0 or work.nit == 0:
|
715
|
+
# The paper says to use "one" as the error before it can be calculated.
|
716
|
+
# NaN seems to be more appropriate.
|
717
|
+
nan = xp.full_like(work.Sn, xp.nan)
|
718
|
+
return nan, nan
|
719
|
+
|
720
|
+
indices = work.pair_cache.indices
|
721
|
+
|
722
|
+
n_active = work.Sn.shape[0] # number of active elements
|
723
|
+
axis_kwargs = dict(axis=-1, keepdims=True)
|
724
|
+
|
725
|
+
# With a jump start (starting at level higher than 0), we haven't
|
726
|
+
# explicitly calculated the integral estimate at lower levels. But we have
|
727
|
+
# all the function value-weight products, so we can compute the
|
728
|
+
# lower-level estimates.
|
729
|
+
if work.Sk.shape[-1] == 0:
|
730
|
+
h = 2 * work.h # step size at this level
|
731
|
+
n_x = indices[work.n] # number of abscissa up to this level
|
732
|
+
# The right and left fjwj terms from all levels are concatenated along
|
733
|
+
# the last axis. Get out only the terms up to this level.
|
734
|
+
fjwj_rl = xp.reshape(work.fjwj, (n_active, 2, -1))
|
735
|
+
fjwj = xp.reshape(fjwj_rl[:, :, :n_x], (n_active, 2*n_x))
|
736
|
+
# Compute the Euler-Maclaurin sum at this level
|
737
|
+
Snm1 = (special.logsumexp(fjwj, **axis_kwargs) + xp.log(h) if work.log
|
738
|
+
else xp.sum(fjwj, **axis_kwargs) * h)
|
739
|
+
work.Sk = xp.concat((Snm1, work.Sk), axis=-1)
|
740
|
+
|
741
|
+
if work.n == 1:
|
742
|
+
nan = xp.full_like(work.Sn, xp.nan)
|
743
|
+
return nan, nan
|
744
|
+
|
745
|
+
# The paper says not to calculate the error for n<=2, but it's not clear
|
746
|
+
# about whether it starts at level 0 or level 1. We start at level 0, so
|
747
|
+
# why not compute the error beginning in level 2?
|
748
|
+
if work.Sk.shape[-1] < 2:
|
749
|
+
h = 4 * work.h # step size at this level
|
750
|
+
n_x = indices[work.n-1] # number of abscissa up to this level
|
751
|
+
# The right and left fjwj terms from all levels are concatenated along
|
752
|
+
# the last axis. Get out only the terms up to this level.
|
753
|
+
fjwj_rl = xp.reshape(work.fjwj, (work.Sn.shape[0], 2, -1))
|
754
|
+
fjwj = xp.reshape(fjwj_rl[..., :n_x], (n_active, 2*n_x))
|
755
|
+
# Compute the Euler-Maclaurin sum at this level
|
756
|
+
Snm2 = (special.logsumexp(fjwj, **axis_kwargs) + xp.log(h) if work.log
|
757
|
+
else xp.sum(fjwj, **axis_kwargs) * h)
|
758
|
+
work.Sk = xp.concat((Snm2, work.Sk), axis=-1)
|
759
|
+
|
760
|
+
Snm2 = work.Sk[..., -2]
|
761
|
+
Snm1 = work.Sk[..., -1]
|
762
|
+
|
763
|
+
e1 = xp.asarray(work.eps)[()]
|
764
|
+
|
765
|
+
if work.log:
|
766
|
+
log_e1 = xp.log(e1)
|
767
|
+
# Currently, only real integrals are supported in log-scale. All
|
768
|
+
# complex values have imaginary part in increments of pi*j, which just
|
769
|
+
# carries sign information of the original integral, so use of
|
770
|
+
# `xp.real` here is equivalent to absolute value in real scale.
|
771
|
+
d1 = xp.real(special.logsumexp(xp.stack([work.Sn, Snm1 + work.pi*1j]), axis=0))
|
772
|
+
d2 = xp.real(special.logsumexp(xp.stack([work.Sn, Snm2 + work.pi*1j]), axis=0))
|
773
|
+
d3 = log_e1 + xp.max(xp.real(work.fjwj), axis=-1)
|
774
|
+
d4 = work.d4
|
775
|
+
d5 = log_e1 + xp.real(work.Sn)
|
776
|
+
temp = xp.where(d1 > -xp.inf, d1 ** 2 / d2, -xp.inf)
|
777
|
+
ds = xp.stack([temp, 2 * d1, d3, d4])
|
778
|
+
aerr = xp.clip(xp.max(ds, axis=0), d5, d1)
|
779
|
+
rerr = aerr - xp.real(work.Sn)
|
780
|
+
else:
|
781
|
+
# Note: explicit computation of log10 of each of these is unnecessary.
|
782
|
+
d1 = xp.abs(work.Sn - Snm1)
|
783
|
+
d2 = xp.abs(work.Sn - Snm2)
|
784
|
+
d3 = e1 * xp.max(xp.abs(work.fjwj), axis=-1)
|
785
|
+
d4 = work.d4
|
786
|
+
d5 = e1 * xp.abs(work.Sn)
|
787
|
+
temp = xp.where(d1 > 0, d1**(xp.log(d1)/xp.log(d2)), 0)
|
788
|
+
ds = xp.stack([temp, d1**2, d3, d4])
|
789
|
+
aerr = xp.clip(xp.max(ds, axis=0), d5, d1)
|
790
|
+
rerr = aerr/xp.abs(work.Sn)
|
791
|
+
|
792
|
+
return rerr, aerr
|
793
|
+
|
794
|
+
|
795
|
+
def _transform_integrals(a, b, xp):
|
796
|
+
# Transform integrals to a form with finite a <= b
|
797
|
+
# For b == a (even infinite), we ensure that the limits remain equal
|
798
|
+
# For b < a, we reverse the limits and will multiply the final result by -1
|
799
|
+
# For infinite limit on the right, we use the substitution x = 1/t - 1 + a
|
800
|
+
# For infinite limit on the left, we substitute x = -x and treat as above
|
801
|
+
# For infinite limits, we substitute x = t / (1-t**2)
|
802
|
+
ab_same = (a == b)
|
803
|
+
a[ab_same], b[ab_same] = 1, 1
|
804
|
+
|
805
|
+
# `a, b` may have complex dtype but have zero imaginary part
|
806
|
+
negative = xp.real(b) < xp.real(a)
|
807
|
+
a[negative], b[negative] = b[negative], a[negative]
|
808
|
+
|
809
|
+
abinf = xp.isinf(a) & xp.isinf(b)
|
810
|
+
a[abinf], b[abinf] = -1, 1
|
811
|
+
|
812
|
+
ainf = xp.isinf(a)
|
813
|
+
a[ainf], b[ainf] = -b[ainf], -a[ainf]
|
814
|
+
|
815
|
+
binf = xp.isinf(b)
|
816
|
+
a0 = xp_copy(a)
|
817
|
+
a[binf], b[binf] = 0, 1
|
818
|
+
|
819
|
+
return a, b, a0, negative, abinf, ainf, binf
|
820
|
+
|
821
|
+
|
822
|
+
def _tanhsinh_iv(f, a, b, log, maxfun, maxlevel, minlevel,
|
823
|
+
atol, rtol, args, preserve_shape, callback):
|
824
|
+
# Input validation and standardization
|
825
|
+
|
826
|
+
xp = array_namespace(a, b)
|
827
|
+
a, b = xp_promote(a, b, broadcast=True, force_floating=True, xp=xp)
|
828
|
+
|
829
|
+
message = '`f` must be callable.'
|
830
|
+
if not callable(f):
|
831
|
+
raise ValueError(message)
|
832
|
+
|
833
|
+
message = 'All elements of `a` and `b` must be real numbers.'
|
834
|
+
if (xp.isdtype(a.dtype, 'complex floating')
|
835
|
+
or xp.isdtype(b.dtype, 'complex floating')):
|
836
|
+
raise ValueError(message)
|
837
|
+
|
838
|
+
message = '`log` must be True or False.'
|
839
|
+
if log not in {True, False}:
|
840
|
+
raise ValueError(message)
|
841
|
+
log = bool(log)
|
842
|
+
|
843
|
+
if atol is None:
|
844
|
+
atol = -xp.inf if log else 0
|
845
|
+
|
846
|
+
rtol_temp = rtol if rtol is not None else 0.
|
847
|
+
|
848
|
+
# using NumPy for convenience here; these are just floats, not arrays
|
849
|
+
params = np.asarray([atol, rtol_temp, 0.])
|
850
|
+
message = "`atol` and `rtol` must be real numbers."
|
851
|
+
if not np.issubdtype(params.dtype, np.floating):
|
852
|
+
raise ValueError(message)
|
853
|
+
|
854
|
+
if log:
|
855
|
+
message = '`atol` and `rtol` may not be positive infinity.'
|
856
|
+
if np.any(np.isposinf(params)):
|
857
|
+
raise ValueError(message)
|
858
|
+
else:
|
859
|
+
message = '`atol` and `rtol` must be non-negative and finite.'
|
860
|
+
if np.any(params < 0) or np.any(np.isinf(params)):
|
861
|
+
raise ValueError(message)
|
862
|
+
atol = params[0]
|
863
|
+
rtol = rtol if rtol is None else params[1]
|
864
|
+
|
865
|
+
BIGINT = float(2**62)
|
866
|
+
if maxfun is None and maxlevel is None:
|
867
|
+
maxlevel = 10
|
868
|
+
|
869
|
+
maxfun = BIGINT if maxfun is None else maxfun
|
870
|
+
maxlevel = BIGINT if maxlevel is None else maxlevel
|
871
|
+
|
872
|
+
message = '`maxfun`, `maxlevel`, and `minlevel` must be integers.'
|
873
|
+
params = np.asarray([maxfun, maxlevel, minlevel])
|
874
|
+
if not (np.issubdtype(params.dtype, np.number)
|
875
|
+
and np.all(np.isreal(params))
|
876
|
+
and np.all(params.astype(np.int64) == params)):
|
877
|
+
raise ValueError(message)
|
878
|
+
message = '`maxfun`, `maxlevel`, and `minlevel` must be non-negative.'
|
879
|
+
if np.any(params < 0):
|
880
|
+
raise ValueError(message)
|
881
|
+
maxfun, maxlevel, minlevel = params.astype(np.int64)
|
882
|
+
minlevel = min(minlevel, maxlevel)
|
883
|
+
|
884
|
+
if not np.iterable(args):
|
885
|
+
args = (args,)
|
886
|
+
args = (xp.asarray(arg) for arg in args)
|
887
|
+
|
888
|
+
message = '`preserve_shape` must be True or False.'
|
889
|
+
if preserve_shape not in {True, False}:
|
890
|
+
raise ValueError(message)
|
891
|
+
|
892
|
+
if callback is not None and not callable(callback):
|
893
|
+
raise ValueError('`callback` must be callable.')
|
894
|
+
|
895
|
+
return (f, a, b, log, maxfun, maxlevel, minlevel,
|
896
|
+
atol, rtol, args, preserve_shape, callback, xp)
|
897
|
+
|
898
|
+
|
899
|
+
def _nsum_iv(f, a, b, step, args, log, maxterms, tolerances):
|
900
|
+
# Input validation and standardization
|
901
|
+
|
902
|
+
xp = array_namespace(a, b, step)
|
903
|
+
a, b, step = xp_promote(a, b, step, broadcast=True, force_floating=True, xp=xp)
|
904
|
+
|
905
|
+
message = '`f` must be callable.'
|
906
|
+
if not callable(f):
|
907
|
+
raise ValueError(message)
|
908
|
+
|
909
|
+
message = 'All elements of `a`, `b`, and `step` must be real numbers.'
|
910
|
+
if not xp.isdtype(a.dtype, ('integral', 'real floating')):
|
911
|
+
raise ValueError(message)
|
912
|
+
|
913
|
+
valid_b = b >= a # NaNs will be False
|
914
|
+
valid_step = xp.isfinite(step) & (step > 0)
|
915
|
+
valid_abstep = valid_b & valid_step
|
916
|
+
|
917
|
+
message = '`log` must be True or False.'
|
918
|
+
if log not in {True, False}:
|
919
|
+
raise ValueError(message)
|
920
|
+
|
921
|
+
tolerances = {} if tolerances is None else tolerances
|
922
|
+
|
923
|
+
atol = tolerances.get('atol', None)
|
924
|
+
if atol is None:
|
925
|
+
atol = -xp.inf if log else 0
|
926
|
+
|
927
|
+
rtol = tolerances.get('rtol', None)
|
928
|
+
rtol_temp = rtol if rtol is not None else 0.
|
929
|
+
|
930
|
+
# using NumPy for convenience here; these are just floats, not arrays
|
931
|
+
params = np.asarray([atol, rtol_temp, 0.])
|
932
|
+
message = "`atol` and `rtol` must be real numbers."
|
933
|
+
if not np.issubdtype(params.dtype, np.floating):
|
934
|
+
raise ValueError(message)
|
935
|
+
|
936
|
+
if log:
|
937
|
+
message = '`atol`, `rtol` may not be positive infinity or NaN.'
|
938
|
+
if np.any(np.isposinf(params) | np.isnan(params)):
|
939
|
+
raise ValueError(message)
|
940
|
+
else:
|
941
|
+
message = '`atol`, and `rtol` must be non-negative and finite.'
|
942
|
+
if np.any((params < 0) | (~np.isfinite(params))):
|
943
|
+
raise ValueError(message)
|
944
|
+
atol = params[0]
|
945
|
+
rtol = rtol if rtol is None else params[1]
|
946
|
+
|
947
|
+
maxterms_int = int(maxterms)
|
948
|
+
if maxterms_int != maxterms or maxterms < 0:
|
949
|
+
message = "`maxterms` must be a non-negative integer."
|
950
|
+
raise ValueError(message)
|
951
|
+
|
952
|
+
if not np.iterable(args):
|
953
|
+
args = (args,)
|
954
|
+
|
955
|
+
return f, a, b, step, valid_abstep, args, log, maxterms_int, atol, rtol, xp
|
956
|
+
|
957
|
+
|
958
|
+
def nsum(f, a, b, *, step=1, args=(), log=False, maxterms=int(2**20), tolerances=None):
|
959
|
+
r"""Evaluate a convergent finite or infinite series.
|
960
|
+
|
961
|
+
For finite `a` and `b`, this evaluates::
|
962
|
+
|
963
|
+
f(a + np.arange(n)*step).sum()
|
964
|
+
|
965
|
+
where ``n = int((b - a) / step) + 1``, where `f` is smooth, positive, and
|
966
|
+
unimodal. The number of terms in the sum may be very large or infinite,
|
967
|
+
in which case a partial sum is evaluated directly and the remainder is
|
968
|
+
approximated using integration.
|
969
|
+
|
970
|
+
Parameters
|
971
|
+
----------
|
972
|
+
f : callable
|
973
|
+
The function that evaluates terms to be summed. The signature must be::
|
974
|
+
|
975
|
+
f(x: ndarray, *args) -> ndarray
|
976
|
+
|
977
|
+
where each element of ``x`` is a finite real and ``args`` is a tuple,
|
978
|
+
which may contain an arbitrary number of arrays that are broadcastable
|
979
|
+
with ``x``.
|
980
|
+
|
981
|
+
`f` must be an elementwise function: each element ``f(x)[i]``
|
982
|
+
must equal ``f(x[i])`` for all indices ``i``. It must not mutate the
|
983
|
+
array ``x`` or the arrays in ``args``, and it must return NaN where
|
984
|
+
the argument is NaN.
|
985
|
+
|
986
|
+
`f` must represent a smooth, positive, unimodal function of `x` defined at
|
987
|
+
*all reals* between `a` and `b`.
|
988
|
+
a, b : float array_like
|
989
|
+
Real lower and upper limits of summed terms. Must be broadcastable.
|
990
|
+
Each element of `a` must be less than the corresponding element in `b`.
|
991
|
+
step : float array_like
|
992
|
+
Finite, positive, real step between summed terms. Must be broadcastable
|
993
|
+
with `a` and `b`. Note that the number of terms included in the sum will
|
994
|
+
be ``floor((b - a) / step)`` + 1; adjust `b` accordingly to ensure
|
995
|
+
that ``f(b)`` is included if intended.
|
996
|
+
args : tuple of array_like, optional
|
997
|
+
Additional positional arguments to be passed to `f`. Must be arrays
|
998
|
+
broadcastable with `a`, `b`, and `step`. If the callable to be summed
|
999
|
+
requires arguments that are not broadcastable with `a`, `b`, and `step`,
|
1000
|
+
wrap that callable with `f` such that `f` accepts only `x` and
|
1001
|
+
broadcastable ``*args``. See Examples.
|
1002
|
+
log : bool, default: False
|
1003
|
+
Setting to True indicates that `f` returns the log of the terms
|
1004
|
+
and that `atol` and `rtol` are expressed as the logs of the absolute
|
1005
|
+
and relative errors. In this case, the result object will contain the
|
1006
|
+
log of the sum and error. This is useful for summands for which
|
1007
|
+
numerical underflow or overflow would lead to inaccuracies.
|
1008
|
+
maxterms : int, default: 2**20
|
1009
|
+
The maximum number of terms to evaluate for direct summation.
|
1010
|
+
Additional function evaluations may be performed for input
|
1011
|
+
validation and integral evaluation.
|
1012
|
+
atol, rtol : float, optional
|
1013
|
+
Absolute termination tolerance (default: 0) and relative termination
|
1014
|
+
tolerance (default: ``eps**0.5``, where ``eps`` is the precision of
|
1015
|
+
the result dtype), respectively. Must be non-negative
|
1016
|
+
and finite if `log` is False, and must be expressed as the log of a
|
1017
|
+
non-negative and finite number if `log` is True.
|
1018
|
+
|
1019
|
+
Returns
|
1020
|
+
-------
|
1021
|
+
res : _RichResult
|
1022
|
+
An object similar to an instance of `scipy.optimize.OptimizeResult` with the
|
1023
|
+
following attributes. (The descriptions are written as though the values will
|
1024
|
+
be scalars; however, if `f` returns an array, the outputs will be
|
1025
|
+
arrays of the same shape.)
|
1026
|
+
|
1027
|
+
success : bool
|
1028
|
+
``True`` when the algorithm terminated successfully (status ``0``);
|
1029
|
+
``False`` otherwise.
|
1030
|
+
status : int array
|
1031
|
+
An integer representing the exit status of the algorithm.
|
1032
|
+
|
1033
|
+
- ``0`` : The algorithm converged to the specified tolerances.
|
1034
|
+
- ``-1`` : Element(s) of `a`, `b`, or `step` are invalid
|
1035
|
+
- ``-2`` : Numerical integration reached its iteration limit;
|
1036
|
+
the sum may be divergent.
|
1037
|
+
- ``-3`` : A non-finite value was encountered.
|
1038
|
+
- ``-4`` : The magnitude of the last term of the partial sum exceeds
|
1039
|
+
the tolerances, so the error estimate exceeds the tolerances.
|
1040
|
+
Consider increasing `maxterms` or loosening `tolerances`.
|
1041
|
+
Alternatively, the callable may not be unimodal, or the limits of
|
1042
|
+
summation may be too far from the function maximum. Consider
|
1043
|
+
increasing `maxterms` or breaking the sum into pieces.
|
1044
|
+
|
1045
|
+
sum : float array
|
1046
|
+
An estimate of the sum.
|
1047
|
+
error : float array
|
1048
|
+
An estimate of the absolute error, assuming all terms are non-negative,
|
1049
|
+
the function is computed exactly, and direct summation is accurate to
|
1050
|
+
the precision of the result dtype.
|
1051
|
+
nfev : int array
|
1052
|
+
The number of points at which `f` was evaluated.
|
1053
|
+
|
1054
|
+
See Also
|
1055
|
+
--------
|
1056
|
+
mpmath.nsum
|
1057
|
+
|
1058
|
+
Notes
|
1059
|
+
-----
|
1060
|
+
The method implemented for infinite summation is related to the integral
|
1061
|
+
test for convergence of an infinite series: assuming `step` size 1 for
|
1062
|
+
simplicity of exposition, the sum of a monotone decreasing function is bounded by
|
1063
|
+
|
1064
|
+
.. math::
|
1065
|
+
|
1066
|
+
\int_u^\infty f(x) dx \leq \sum_{k=u}^\infty f(k) \leq \int_u^\infty f(x) dx + f(u)
|
1067
|
+
|
1068
|
+
Let :math:`a` represent `a`, :math:`n` represent `maxterms`, :math:`\epsilon_a`
|
1069
|
+
represent `atol`, and :math:`\epsilon_r` represent `rtol`.
|
1070
|
+
The implementation first evaluates the integral :math:`S_l=\int_a^\infty f(x) dx`
|
1071
|
+
as a lower bound of the infinite sum. Then, it seeks a value :math:`c > a` such
|
1072
|
+
that :math:`f(c) < \epsilon_a + S_l \epsilon_r`, if it exists; otherwise,
|
1073
|
+
let :math:`c = a + n`. Then the infinite sum is approximated as
|
1074
|
+
|
1075
|
+
.. math::
|
1076
|
+
|
1077
|
+
\sum_{k=a}^{c-1} f(k) + \int_c^\infty f(x) dx + f(c)/2
|
1078
|
+
|
1079
|
+
and the reported error is :math:`f(c)/2` plus the error estimate of
|
1080
|
+
numerical integration. Note that the integral approximations may require
|
1081
|
+
evaluation of the function at points besides those that appear in the sum,
|
1082
|
+
so `f` must be a continuous and monotonically decreasing function defined
|
1083
|
+
for all reals within the integration interval. However, due to the nature
|
1084
|
+
of the integral approximation, the shape of the function between points
|
1085
|
+
that appear in the sum has little effect. If there is not a natural
|
1086
|
+
extension of the function to all reals, consider using linear interpolation,
|
1087
|
+
which is easy to evaluate and preserves monotonicity.
|
1088
|
+
|
1089
|
+
The approach described above is generalized for non-unit
|
1090
|
+
`step` and finite `b` that is too large for direct evaluation of the sum,
|
1091
|
+
i.e. ``b - a + 1 > maxterms``. It is further generalized to unimodal
|
1092
|
+
functions by directly summing terms surrounding the maximum.
|
1093
|
+
This strategy may fail:
|
1094
|
+
|
1095
|
+
- If the left limit is finite and the maximum is far from it.
|
1096
|
+
- If the right limit is finite and the maximum is far from it.
|
1097
|
+
- If both limits are finite and the maximum is far from the origin.
|
1098
|
+
|
1099
|
+
In these cases, accuracy may be poor, and `nsum` may return status code ``4``.
|
1100
|
+
|
1101
|
+
Although the callable `f` must be non-negative and unimodal,
|
1102
|
+
`nsum` can be used to evaluate more general forms of series. For instance, to
|
1103
|
+
evaluate an alternating series, pass a callable that returns the difference
|
1104
|
+
between pairs of adjacent terms, and adjust `step` accordingly. See Examples.
|
1105
|
+
|
1106
|
+
References
|
1107
|
+
----------
|
1108
|
+
.. [1] Wikipedia. "Integral test for convergence."
|
1109
|
+
https://en.wikipedia.org/wiki/Integral_test_for_convergence
|
1110
|
+
|
1111
|
+
Examples
|
1112
|
+
--------
|
1113
|
+
Compute the infinite sum of the reciprocals of squared integers.
|
1114
|
+
|
1115
|
+
>>> import numpy as np
|
1116
|
+
>>> from scipy.integrate import nsum
|
1117
|
+
>>> res = nsum(lambda k: 1/k**2, 1, np.inf)
|
1118
|
+
>>> ref = np.pi**2/6 # true value
|
1119
|
+
>>> res.error # estimated error
|
1120
|
+
np.float64(7.448762306416137e-09)
|
1121
|
+
>>> (res.sum - ref)/ref # true error
|
1122
|
+
np.float64(-1.839871898894426e-13)
|
1123
|
+
>>> res.nfev # number of points at which callable was evaluated
|
1124
|
+
np.int32(8561)
|
1125
|
+
|
1126
|
+
Compute the infinite sums of the reciprocals of integers raised to powers ``p``,
|
1127
|
+
where ``p`` is an array.
|
1128
|
+
|
1129
|
+
>>> from scipy import special
|
1130
|
+
>>> p = np.arange(3, 10)
|
1131
|
+
>>> res = nsum(lambda k, p: 1/k**p, 1, np.inf, maxterms=1e3, args=(p,))
|
1132
|
+
>>> ref = special.zeta(p, 1)
|
1133
|
+
>>> np.allclose(res.sum, ref)
|
1134
|
+
True
|
1135
|
+
|
1136
|
+
Evaluate the alternating harmonic series.
|
1137
|
+
|
1138
|
+
>>> res = nsum(lambda x: 1/x - 1/(x+1), 1, np.inf, step=2)
|
1139
|
+
>>> res.sum, res.sum - np.log(2) # result, difference vs analytical sum
|
1140
|
+
(np.float64(0.6931471805598691), np.float64(-7.616129948928574e-14))
|
1141
|
+
|
1142
|
+
""" # noqa: E501
|
1143
|
+
# Potential future work:
|
1144
|
+
# - improve error estimate of `_direct` sum
|
1145
|
+
# - add other methods for convergence acceleration (Richardson, epsilon)
|
1146
|
+
# - support negative monotone increasing functions?
|
1147
|
+
# - b < a / negative step?
|
1148
|
+
# - complex-valued function?
|
1149
|
+
# - check for violations of monotonicity?
|
1150
|
+
|
1151
|
+
# Function-specific input validation / standardization
|
1152
|
+
tmp = _nsum_iv(f, a, b, step, args, log, maxterms, tolerances)
|
1153
|
+
f, a, b, step, valid_abstep, args, log, maxterms, atol, rtol, xp = tmp
|
1154
|
+
|
1155
|
+
# Additional elementwise algorithm input validation / standardization
|
1156
|
+
tmp = eim._initialize(f, (a,), args, complex_ok=False, xp=xp)
|
1157
|
+
f, xs, fs, args, shape, dtype, xp = tmp
|
1158
|
+
|
1159
|
+
# Finish preparing `a`, `b`, and `step` arrays
|
1160
|
+
a = xs[0]
|
1161
|
+
b = xp.astype(xp_ravel(xp.broadcast_to(b, shape)), dtype)
|
1162
|
+
step = xp.astype(xp_ravel(xp.broadcast_to(step, shape)), dtype)
|
1163
|
+
valid_abstep = xp_ravel(xp.broadcast_to(valid_abstep, shape))
|
1164
|
+
nterms = xp.floor((b - a) / step)
|
1165
|
+
finite_terms = xp.isfinite(nterms)
|
1166
|
+
b[finite_terms] = a[finite_terms] + nterms[finite_terms]*step[finite_terms]
|
1167
|
+
|
1168
|
+
# Define constants
|
1169
|
+
eps = xp.finfo(dtype).eps
|
1170
|
+
zero = xp.asarray(-xp.inf if log else 0, dtype=dtype)[()]
|
1171
|
+
if rtol is None:
|
1172
|
+
rtol = 0.5*math.log(eps) if log else eps**0.5
|
1173
|
+
constants = (dtype, log, eps, zero, rtol, atol, maxterms)
|
1174
|
+
|
1175
|
+
# Prepare result arrays
|
1176
|
+
S = xp.empty_like(a)
|
1177
|
+
E = xp.empty_like(a)
|
1178
|
+
status = xp.zeros(len(a), dtype=xp.int32)
|
1179
|
+
nfev = xp.ones(len(a), dtype=xp.int32) # one function evaluation above
|
1180
|
+
|
1181
|
+
# Branch for direct sum evaluation / integral approximation / invalid input
|
1182
|
+
i0 = ~valid_abstep # invalid
|
1183
|
+
i0b = b < a # zero
|
1184
|
+
i1 = (nterms + 1 <= maxterms) & ~i0 # direct sum evaluation
|
1185
|
+
i2 = xp.isfinite(a) & ~i1 & ~i0 # infinite sum to the right
|
1186
|
+
i3 = xp.isfinite(b) & ~i2 & ~i1 & ~i0 # infinite sum to the left
|
1187
|
+
i4 = ~i3 & ~i2 & ~i1 & ~i0 # infinite sum on both sides
|
1188
|
+
|
1189
|
+
if xp.any(i0):
|
1190
|
+
S[i0], E[i0] = xp.nan, xp.nan
|
1191
|
+
status[i0] = -1
|
1192
|
+
|
1193
|
+
S[i0b], E[i0b] = zero, zero
|
1194
|
+
status[i0b] = 0
|
1195
|
+
|
1196
|
+
if xp.any(i1):
|
1197
|
+
args_direct = [arg[i1] for arg in args]
|
1198
|
+
tmp = _direct(f, a[i1], b[i1], step[i1], args_direct, constants, xp)
|
1199
|
+
S[i1], E[i1] = tmp[:-1]
|
1200
|
+
nfev[i1] += tmp[-1]
|
1201
|
+
status[i1] = -3 * xp.asarray(~xp.isfinite(S[i1]), dtype=xp.int32)
|
1202
|
+
|
1203
|
+
if xp.any(i2):
|
1204
|
+
args_indirect = [arg[i2] for arg in args]
|
1205
|
+
tmp = _integral_bound(f, a[i2], b[i2], step[i2],
|
1206
|
+
args_indirect, constants, xp)
|
1207
|
+
S[i2], E[i2], status[i2] = tmp[:-1]
|
1208
|
+
nfev[i2] += tmp[-1]
|
1209
|
+
|
1210
|
+
if xp.any(i3):
|
1211
|
+
args_indirect = [arg[i3] for arg in args]
|
1212
|
+
def _f(x, *args): return f(-x, *args)
|
1213
|
+
tmp = _integral_bound(_f, -b[i3], -a[i3], step[i3],
|
1214
|
+
args_indirect, constants, xp)
|
1215
|
+
S[i3], E[i3], status[i3] = tmp[:-1]
|
1216
|
+
nfev[i3] += tmp[-1]
|
1217
|
+
|
1218
|
+
if xp.any(i4):
|
1219
|
+
args_indirect = [arg[i4] for arg in args]
|
1220
|
+
|
1221
|
+
# There are two obvious high-level strategies:
|
1222
|
+
# - Do two separate half-infinite sums (e.g. from -inf to 0 and 1 to inf)
|
1223
|
+
# - Make a callable that returns f(x) + f(-x) and do a single half-infinite sum
|
1224
|
+
# I thought the latter would have about half the overhead, so I went that way.
|
1225
|
+
# Then there are two ways of ensuring that f(0) doesn't get counted twice.
|
1226
|
+
# - Evaluate the sum from 1 to inf and add f(0)
|
1227
|
+
# - Evaluate the sum from 0 to inf and subtract f(0)
|
1228
|
+
# - Evaluate the sum from 0 to inf, but apply a weight of 0.5 when `x = 0`
|
1229
|
+
# The last option has more overhead, but is simpler to implement correctly
|
1230
|
+
# (especially getting the status message right)
|
1231
|
+
if log:
|
1232
|
+
def _f(x, *args):
|
1233
|
+
log_factor = xp.where(x==0, math.log(0.5), 0)
|
1234
|
+
out = xp.stack([f(x, *args), f(-x, *args)], axis=0)
|
1235
|
+
return special.logsumexp(out, axis=0) + log_factor
|
1236
|
+
|
1237
|
+
else:
|
1238
|
+
def _f(x, *args):
|
1239
|
+
factor = xp.where(x==0, 0.5, 1)
|
1240
|
+
return (f(x, *args) + f(-x, *args)) * factor
|
1241
|
+
|
1242
|
+
zero = xp.zeros_like(a[i4])
|
1243
|
+
tmp = _integral_bound(_f, zero, b[i4], step[i4], args_indirect, constants, xp)
|
1244
|
+
S[i4], E[i4], status[i4] = tmp[:-1]
|
1245
|
+
nfev[i4] += 2*tmp[-1]
|
1246
|
+
|
1247
|
+
# Return results
|
1248
|
+
S, E = S.reshape(shape)[()], E.reshape(shape)[()]
|
1249
|
+
status, nfev = status.reshape(shape)[()], nfev.reshape(shape)[()]
|
1250
|
+
return _RichResult(sum=S, error=E, status=status, success=status == 0,
|
1251
|
+
nfev=nfev)
|
1252
|
+
|
1253
|
+
|
1254
|
+
def _direct(f, a, b, step, args, constants, xp, inclusive=True):
|
1255
|
+
# Directly evaluate the sum.
|
1256
|
+
|
1257
|
+
# When used in the context of distributions, `args` would contain the
|
1258
|
+
# distribution parameters. We have broadcasted for simplicity, but we could
|
1259
|
+
# reduce function evaluations when distribution parameters are the same but
|
1260
|
+
# sum limits differ. Roughly:
|
1261
|
+
# - compute the function at all points between min(a) and max(b),
|
1262
|
+
# - compute the cumulative sum,
|
1263
|
+
# - take the difference between elements of the cumulative sum
|
1264
|
+
# corresponding with b and a.
|
1265
|
+
# This is left to future enhancement
|
1266
|
+
|
1267
|
+
dtype, log, eps, zero, _, _, _ = constants
|
1268
|
+
|
1269
|
+
# To allow computation in a single vectorized call, find the maximum number
|
1270
|
+
# of points (over all slices) at which the function needs to be evaluated.
|
1271
|
+
# Note: if `inclusive` is `True`, then we want `1` more term in the sum.
|
1272
|
+
# I didn't think it was great style to use `True` as `1` in Python, so I
|
1273
|
+
# explicitly converted it to an `int` before using it.
|
1274
|
+
inclusive_adjustment = int(inclusive)
|
1275
|
+
steps = xp.round((b - a) / step) + inclusive_adjustment
|
1276
|
+
# Equivalently, steps = xp.round((b - a) / step) + inclusive
|
1277
|
+
max_steps = int(xp.max(steps))
|
1278
|
+
|
1279
|
+
# In each slice, the function will be evaluated at the same number of points,
|
1280
|
+
# but excessive points (those beyond the right sum limit `b`) are replaced
|
1281
|
+
# with NaN to (potentially) reduce the time of these unnecessary calculations.
|
1282
|
+
# Use a new last axis for these calculations for consistency with other
|
1283
|
+
# elementwise algorithms.
|
1284
|
+
a2, b2, step2 = a[:, xp.newaxis], b[:, xp.newaxis], step[:, xp.newaxis]
|
1285
|
+
args2 = [arg[:, xp.newaxis] for arg in args]
|
1286
|
+
ks = a2 + xp.arange(max_steps, dtype=dtype) * step2
|
1287
|
+
i_nan = ks >= (b2 + inclusive_adjustment*step2/2)
|
1288
|
+
ks[i_nan] = xp.nan
|
1289
|
+
fs = f(ks, *args2)
|
1290
|
+
|
1291
|
+
# The function evaluated at NaN is NaN, and NaNs are zeroed in the sum.
|
1292
|
+
# In some cases it may be faster to loop over slices than to vectorize
|
1293
|
+
# like this. This is an optimization that can be added later.
|
1294
|
+
fs[i_nan] = zero
|
1295
|
+
nfev = max_steps - i_nan.sum(axis=-1)
|
1296
|
+
S = special.logsumexp(fs, axis=-1) if log else xp.sum(fs, axis=-1)
|
1297
|
+
# Rough, non-conservative error estimate. See gh-19667 for improvement ideas.
|
1298
|
+
E = xp.real(S) + math.log(eps) if log else eps * abs(S)
|
1299
|
+
return S, E, nfev
|
1300
|
+
|
1301
|
+
|
1302
|
+
def _integral_bound(f, a, b, step, args, constants, xp):
|
1303
|
+
# Estimate the sum with integral approximation
|
1304
|
+
dtype, log, _, _, rtol, atol, maxterms = constants
|
1305
|
+
log2 = xp.asarray(math.log(2), dtype=dtype)
|
1306
|
+
|
1307
|
+
# Get a lower bound on the sum and compute effective absolute tolerance
|
1308
|
+
lb = tanhsinh(f, a, b, args=args, atol=atol, rtol=rtol, log=log)
|
1309
|
+
tol = xp.broadcast_to(xp.asarray(atol), lb.integral.shape)
|
1310
|
+
if log:
|
1311
|
+
tol = special.logsumexp(xp.stack((tol, rtol + lb.integral)), axis=0)
|
1312
|
+
else:
|
1313
|
+
tol = tol + rtol*lb.integral
|
1314
|
+
i_skip = lb.status == -3 # avoid unnecessary f_evals if integral is divergent
|
1315
|
+
tol[i_skip] = xp.nan
|
1316
|
+
status = lb.status
|
1317
|
+
|
1318
|
+
# As in `_direct`, we'll need a temporary new axis for points
|
1319
|
+
# at which to evaluate the function. Append axis at the end for
|
1320
|
+
# consistency with other elementwise algorithms.
|
1321
|
+
a2 = a[..., xp.newaxis]
|
1322
|
+
step2 = step[..., xp.newaxis]
|
1323
|
+
args2 = [arg[..., xp.newaxis] for arg in args]
|
1324
|
+
|
1325
|
+
# Find the location of a term that is less than the tolerance (if possible)
|
1326
|
+
log2maxterms = math.floor(math.log2(maxterms)) if maxterms else 0
|
1327
|
+
n_steps = xp.concat((2**xp.arange(0, log2maxterms), xp.asarray([maxterms])))
|
1328
|
+
n_steps = xp.astype(n_steps, dtype)
|
1329
|
+
nfev = len(n_steps) * 2
|
1330
|
+
ks = a2 + n_steps * step2
|
1331
|
+
fks = f(ks, *args2)
|
1332
|
+
fksp1 = f(ks + step2, *args2) # check that the function is decreasing
|
1333
|
+
fk_insufficient = (fks > tol[:, xp.newaxis]) | (fksp1 > fks)
|
1334
|
+
n_fk_insufficient = xp.sum(fk_insufficient, axis=-1)
|
1335
|
+
nt = xp.minimum(n_fk_insufficient, n_steps.shape[-1]-1)
|
1336
|
+
n_steps = n_steps[nt]
|
1337
|
+
|
1338
|
+
# If `maxterms` is insufficient (i.e. either the magnitude of the last term of the
|
1339
|
+
# partial sum exceeds the tolerance or the function is not decreasing), finish the
|
1340
|
+
# calculation, but report nonzero status. (Improvement: separate the status codes
|
1341
|
+
# for these two cases.)
|
1342
|
+
i_fk_insufficient = (n_fk_insufficient == nfev//2)
|
1343
|
+
|
1344
|
+
# Directly evaluate the sum up to this term
|
1345
|
+
k = a + n_steps * step
|
1346
|
+
left, left_error, left_nfev = _direct(f, a, k, step, args,
|
1347
|
+
constants, xp, inclusive=False)
|
1348
|
+
left_is_pos_inf = xp.isinf(left) & (left > 0)
|
1349
|
+
i_skip |= left_is_pos_inf # if sum is infinite, no sense in continuing
|
1350
|
+
status[left_is_pos_inf] = -3
|
1351
|
+
k[i_skip] = xp.nan
|
1352
|
+
|
1353
|
+
# Use integration to estimate the remaining sum
|
1354
|
+
# Possible optimization for future work: if there were no terms less than
|
1355
|
+
# the tolerance, there is no need to compute the integral to better accuracy.
|
1356
|
+
# Something like:
|
1357
|
+
# atol = xp.maximum(atol, xp.minimum(fk/2 - fb/2))
|
1358
|
+
# rtol = xp.maximum(rtol, xp.minimum((fk/2 - fb/2)/left))
|
1359
|
+
# where `fk`/`fb` are currently calculated below.
|
1360
|
+
right = tanhsinh(f, k, b, args=args, atol=atol, rtol=rtol, log=log)
|
1361
|
+
|
1362
|
+
# Calculate the full estimate and error from the pieces
|
1363
|
+
fk = fks[xp.arange(len(fks)), nt]
|
1364
|
+
|
1365
|
+
# fb = f(b, *args), but some functions return NaN at infinity.
|
1366
|
+
# instead of 0 like they must (for the sum to be convergent).
|
1367
|
+
fb = xp.full_like(fk, -xp.inf) if log else xp.zeros_like(fk)
|
1368
|
+
i = xp.isfinite(b)
|
1369
|
+
if xp.any(i): # better not call `f` with empty arrays
|
1370
|
+
fb[i] = f(b[i], *[arg[i] for arg in args])
|
1371
|
+
nfev = nfev + xp.asarray(i, dtype=left_nfev.dtype)
|
1372
|
+
|
1373
|
+
if log:
|
1374
|
+
log_step = xp.log(step)
|
1375
|
+
S_terms = (left, right.integral - log_step, fk - log2, fb - log2)
|
1376
|
+
S = special.logsumexp(xp.stack(S_terms), axis=0)
|
1377
|
+
E_terms = (left_error, right.error - log_step, fk-log2, fb-log2+xp.pi*1j)
|
1378
|
+
E = xp.real(special.logsumexp(xp.stack(E_terms), axis=0))
|
1379
|
+
else:
|
1380
|
+
S = left + right.integral/step + fk/2 + fb/2
|
1381
|
+
E = left_error + right.error/step + fk/2 - fb/2
|
1382
|
+
status[~i_skip] = right.status[~i_skip]
|
1383
|
+
|
1384
|
+
status[(status == 0) & i_fk_insufficient] = -4
|
1385
|
+
return S, E, status, left_nfev + right.nfev + nfev + lb.nfev
|