scipy 1.16.2__cp314-cp314-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.cp314-win_arm64.lib +0 -0
- scipy/_cyutility.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/_lib/_ccallback_c.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/_lib/_fpumode.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/_lib/_test_ccallback.cp314-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_call.cp314-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_call.cp314-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_def.cp314-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_def.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/_lib/_uarray/_uarray.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/_lib/messagestream.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/cluster/_hierarchy.cp314-win_arm64.pyd +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp314-win_arm64.lib +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp314-win_arm64.pyd +0 -0
- scipy/cluster/_vq.cp314-win_arm64.lib +0 -0
- scipy/cluster/_vq.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/fft/_pocketfft/pypocketfft.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/fftpack/convolve.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/integrate/_dop.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/integrate/_lsoda.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_ode.py +1395 -0
- scipy/integrate/_odepack.cp314-win_arm64.lib +0 -0
- scipy/integrate/_odepack.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_odepack_py.py +273 -0
- scipy/integrate/_quad_vec.py +674 -0
- scipy/integrate/_quadpack.cp314-win_arm64.lib +0 -0
- scipy/integrate/_quadpack.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/integrate/_test_multivariate.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_test_odeint_banded.cp314-win_arm64.lib +0 -0
- scipy/integrate/_test_odeint_banded.cp314-win_arm64.pyd +0 -0
- scipy/integrate/_vode.cp314-win_arm64.lib +0 -0
- scipy/integrate/_vode.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_dfitpack.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_dierckx.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_dierckx.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_fitpack.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_interpnd.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_ppoly.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_rbf.py +290 -0
- scipy/interpolate/_rbfinterp.py +550 -0
- scipy/interpolate/_rbfinterp_pythran.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_rbfinterp_pythran.cp314-win_arm64.pyd +0 -0
- scipy/interpolate/_rgi.py +764 -0
- scipy/interpolate/_rgi_cython.cp314-win_arm64.lib +0 -0
- scipy/interpolate/_rgi_cython.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/io/_test_fortran.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/io/matlab/_mio5_utils.cp314-win_arm64.pyd +0 -0
- scipy/io/matlab/_mio_utils.cp314-win_arm64.lib +0 -0
- scipy/io/matlab/_mio_utils.cp314-win_arm64.pyd +0 -0
- scipy/io/matlab/_miobase.py +435 -0
- scipy/io/matlab/_streams.cp314-win_arm64.lib +0 -0
- scipy/io/matlab/_streams.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/linalg/_cythonized_array_utils.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/linalg/_decomp_interpolative.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_ldl.py +356 -0
- scipy/linalg/_decomp_lu.py +401 -0
- scipy/linalg/_decomp_lu_cython.cp314-win_arm64.lib +0 -0
- scipy/linalg/_decomp_lu_cython.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/linalg/_decomp_update.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_expm_frechet.py +417 -0
- scipy/linalg/_fblas.cp314-win_arm64.lib +0 -0
- scipy/linalg/_fblas.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_flapack.cp314-win_arm64.lib +0 -0
- scipy/linalg/_flapack.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_lapack_subroutines.h +1521 -0
- scipy/linalg/_linalg_pythran.cp314-win_arm64.lib +0 -0
- scipy/linalg/_linalg_pythran.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs.py +1050 -0
- scipy/linalg/_matfuncs_expm.cp314-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_expm.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp314-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_sqrtm.py +107 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp314-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/linalg/_solve_toeplitz.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/linalg/cython_blas.cp314-win_arm64.pyd +0 -0
- scipy/linalg/cython_blas.pxd +169 -0
- scipy/linalg/cython_blas.pyx +1432 -0
- scipy/linalg/cython_lapack.cp314-win_arm64.lib +0 -0
- scipy/linalg/cython_lapack.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_ctest.cp314-win_arm64.pyd +0 -0
- scipy/ndimage/_cytest.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_cytest.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_nd_image.cp314-win_arm64.pyd +0 -0
- scipy/ndimage/_ndimage_api.py +16 -0
- scipy/ndimage/_ni_docstrings.py +214 -0
- scipy/ndimage/_ni_label.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_ni_label.cp314-win_arm64.pyd +0 -0
- scipy/ndimage/_ni_support.py +139 -0
- scipy/ndimage/_rank_filter_1d.cp314-win_arm64.lib +0 -0
- scipy/ndimage/_rank_filter_1d.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/odr/__odrpack.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_bglu_dense.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_direct.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_group_columns.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_hessian_update_strategy.py +479 -0
- scipy/optimize/_highspy/__init__.py +0 -0
- scipy/optimize/_highspy/_core.cp314-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_core.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_options.cp314-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_highs_options.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_wrapper.py +338 -0
- scipy/optimize/_isotonic.py +157 -0
- scipy/optimize/_lbfgsb.cp314-win_arm64.lib +0 -0
- scipy/optimize/_lbfgsb.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_lsap.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_lsq/givens_elimination.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_minpack.cp314-win_arm64.pyd +0 -0
- scipy/optimize/_minpack_py.py +1178 -0
- scipy/optimize/_moduleTNC.cp314-win_arm64.lib +0 -0
- scipy/optimize/_moduleTNC.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_pava_pybind.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_slsqplib.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_trlib/_trlib.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/_zeros.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/optimize/cython_optimize/_zeros.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/signal/_max_len_seq_inner.cp314-win_arm64.pyd +0 -0
- scipy/signal/_peak_finding.py +1310 -0
- scipy/signal/_peak_finding_utils.cp314-win_arm64.lib +0 -0
- scipy/signal/_peak_finding_utils.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/signal/_sigtools.cp314-win_arm64.pyd +0 -0
- scipy/signal/_sosfilt.cp314-win_arm64.lib +0 -0
- scipy/signal/_sosfilt.cp314-win_arm64.pyd +0 -0
- scipy/signal/_spectral_py.py +2471 -0
- scipy/signal/_spline.cp314-win_arm64.lib +0 -0
- scipy/signal/_spline.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/signal/_upfirdn_apply.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/sparse/_csparsetools.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/sparse/_sparsetools.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_flow.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_laplacian.py +563 -0
- scipy/sparse/csgraph/_matching.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_matching.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_reordering.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_reordering.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_shortest_path.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_shortest_path.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_tools.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_tools.cp314-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_traversal.cp314-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_traversal.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_cpropack.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp314-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp314-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/spatial/_ckdtree.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_distance_pybind.cp314-win_arm64.lib +0 -0
- scipy/spatial/_distance_pybind.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_distance_wrap.cp314-win_arm64.lib +0 -0
- scipy/spatial/_distance_wrap.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_geometric_slerp.py +238 -0
- scipy/spatial/_hausdorff.cp314-win_arm64.lib +0 -0
- scipy/spatial/_hausdorff.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/spatial/_qhull.cp314-win_arm64.pyd +0 -0
- scipy/spatial/_qhull.pyi +213 -0
- scipy/spatial/_spherical_voronoi.py +341 -0
- scipy/spatial/_voronoi.cp314-win_arm64.lib +0 -0
- scipy/spatial/_voronoi.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/spatial/transform/_rigid_transform.cp314-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation.cp314-win_arm64.lib +0 -0
- scipy/spatial/transform/_rotation.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/special/_comb.cp314-win_arm64.pyd +0 -0
- scipy/special/_ellip_harm.py +214 -0
- scipy/special/_ellip_harm_2.cp314-win_arm64.lib +0 -0
- scipy/special/_ellip_harm_2.cp314-win_arm64.pyd +0 -0
- scipy/special/_gufuncs.cp314-win_arm64.lib +0 -0
- scipy/special/_gufuncs.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/special/_specfun.cp314-win_arm64.pyd +0 -0
- scipy/special/_special_ufuncs.cp314-win_arm64.lib +0 -0
- scipy/special/_special_ufuncs.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/special/_test_internal.cp314-win_arm64.pyd +0 -0
- scipy/special/_test_internal.pyi +9 -0
- scipy/special/_testutils.py +321 -0
- scipy/special/_ufuncs.cp314-win_arm64.lib +0 -0
- scipy/special/_ufuncs.cp314-win_arm64.pyd +0 -0
- scipy/special/_ufuncs.pyi +522 -0
- scipy/special/_ufuncs.pyx +13173 -0
- scipy/special/_ufuncs_cxx.cp314-win_arm64.lib +0 -0
- scipy/special/_ufuncs_cxx.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/special/cython_special.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/stats/_ansari_swilk_statistics.cp314-win_arm64.pyd +0 -0
- scipy/stats/_axis_nan_policy.py +692 -0
- scipy/stats/_biasedurn.cp314-win_arm64.lib +0 -0
- scipy/stats/_biasedurn.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/stats/_levy_stable/levyst.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/stats/_qmc_cy.cp314-win_arm64.pyd +0 -0
- scipy/stats/_qmc_cy.pyi +54 -0
- scipy/stats/_qmvnt.py +454 -0
- scipy/stats/_qmvnt_cy.cp314-win_arm64.lib +0 -0
- scipy/stats/_qmvnt_cy.cp314-win_arm64.pyd +0 -0
- scipy/stats/_quantile.py +335 -0
- scipy/stats/_rcont/__init__.py +4 -0
- scipy/stats/_rcont/rcont.cp314-win_arm64.lib +0 -0
- scipy/stats/_rcont/rcont.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/stats/_sobol.cp314-win_arm64.pyd +0 -0
- scipy/stats/_sobol.pyi +54 -0
- scipy/stats/_sobol_direction_numbers.npz +0 -0
- scipy/stats/_stats.cp314-win_arm64.lib +0 -0
- scipy/stats/_stats.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/stats/_stats_pythran.cp314-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.cp314-win_arm64.lib +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp314-win_arm64.pyd +0 -0
- scipy/stats/_unuran/unuran_wrapper.pyi +179 -0
- scipy/stats/_variation.py +126 -0
- scipy/stats/_warnings_errors.py +38 -0
- scipy/stats/_wilcoxon.py +265 -0
- scipy/stats/biasedurn.py +16 -0
- scipy/stats/contingency.py +521 -0
- scipy/stats/distributions.py +24 -0
- scipy/stats/kde.py +18 -0
- scipy/stats/morestats.py +27 -0
- scipy/stats/mstats.py +140 -0
- scipy/stats/mstats_basic.py +42 -0
- scipy/stats/mstats_extras.py +25 -0
- scipy/stats/mvn.py +17 -0
- scipy/stats/qmc.py +236 -0
- scipy/stats/sampling.py +73 -0
- scipy/stats/stats.py +41 -0
- scipy/stats/tests/__init__.py +0 -0
- scipy/stats/tests/common_tests.py +356 -0
- scipy/stats/tests/data/_mvt.py +171 -0
- scipy/stats/tests/data/fisher_exact_results_from_r.py +607 -0
- scipy/stats/tests/data/jf_skew_t_gamlss_pdf_data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-Z1-cdf-sample-data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-Z1-pdf-sample-data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-loc-scale-sample-data.npy +0 -0
- scipy/stats/tests/data/nist_anova/AtmWtAg.dat +108 -0
- scipy/stats/tests/data/nist_anova/SiRstv.dat +85 -0
- scipy/stats/tests/data/nist_anova/SmLs01.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs02.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs03.dat +18069 -0
- scipy/stats/tests/data/nist_anova/SmLs04.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs05.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs06.dat +18069 -0
- scipy/stats/tests/data/nist_anova/SmLs07.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs08.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs09.dat +18069 -0
- scipy/stats/tests/data/nist_linregress/Norris.dat +97 -0
- scipy/stats/tests/data/rel_breitwigner_pdf_sample_data_ROOT.npy +0 -0
- scipy/stats/tests/data/studentized_range_mpmath_ref.json +1499 -0
- scipy/stats/tests/test_axis_nan_policy.py +1388 -0
- scipy/stats/tests/test_binned_statistic.py +568 -0
- scipy/stats/tests/test_censored_data.py +152 -0
- scipy/stats/tests/test_contingency.py +294 -0
- scipy/stats/tests/test_continued_fraction.py +173 -0
- scipy/stats/tests/test_continuous.py +2198 -0
- scipy/stats/tests/test_continuous_basic.py +1053 -0
- scipy/stats/tests/test_continuous_fit_censored.py +683 -0
- scipy/stats/tests/test_correlation.py +80 -0
- scipy/stats/tests/test_crosstab.py +115 -0
- scipy/stats/tests/test_discrete_basic.py +580 -0
- scipy/stats/tests/test_discrete_distns.py +700 -0
- scipy/stats/tests/test_distributions.py +10413 -0
- scipy/stats/tests/test_entropy.py +322 -0
- scipy/stats/tests/test_fast_gen_inversion.py +435 -0
- scipy/stats/tests/test_fit.py +1090 -0
- scipy/stats/tests/test_hypotests.py +1991 -0
- scipy/stats/tests/test_kdeoth.py +676 -0
- scipy/stats/tests/test_marray.py +289 -0
- scipy/stats/tests/test_mgc.py +217 -0
- scipy/stats/tests/test_morestats.py +3259 -0
- scipy/stats/tests/test_mstats_basic.py +2071 -0
- scipy/stats/tests/test_mstats_extras.py +172 -0
- scipy/stats/tests/test_multicomp.py +405 -0
- scipy/stats/tests/test_multivariate.py +4381 -0
- scipy/stats/tests/test_odds_ratio.py +148 -0
- scipy/stats/tests/test_qmc.py +1492 -0
- scipy/stats/tests/test_quantile.py +199 -0
- scipy/stats/tests/test_rank.py +345 -0
- scipy/stats/tests/test_relative_risk.py +95 -0
- scipy/stats/tests/test_resampling.py +2000 -0
- scipy/stats/tests/test_sampling.py +1450 -0
- scipy/stats/tests/test_sensitivity_analysis.py +310 -0
- scipy/stats/tests/test_stats.py +9707 -0
- scipy/stats/tests/test_survival.py +466 -0
- scipy/stats/tests/test_tukeylambda_stats.py +85 -0
- scipy/stats/tests/test_variation.py +216 -0
- scipy/version.py +12 -0
- scipy-1.16.2.dist-info/DELVEWHEEL +2 -0
- scipy-1.16.2.dist-info/LICENSE.txt +912 -0
- scipy-1.16.2.dist-info/METADATA +1061 -0
- scipy-1.16.2.dist-info/RECORD +1530 -0
- scipy-1.16.2.dist-info/WHEEL +4 -0
- scipy.libs/msvcp140-5f1c5dd31916990d94181e07bc3afb32.dll +0 -0
- scipy.libs/scipy_openblas-f3ac85b1f412f7e86514c923dc4058d1.dll +0 -0
scipy/linalg/_basic.py
ADDED
@@ -0,0 +1,2146 @@
|
|
1
|
+
#
|
2
|
+
# Author: Pearu Peterson, March 2002
|
3
|
+
#
|
4
|
+
# w/ additions by Travis Oliphant, March 2002
|
5
|
+
# and Jake Vanderplas, August 2012
|
6
|
+
|
7
|
+
import warnings
|
8
|
+
from warnings import warn
|
9
|
+
from itertools import product
|
10
|
+
import numpy as np
|
11
|
+
from numpy import atleast_1d, atleast_2d
|
12
|
+
from scipy._lib._util import _apply_over_batch
|
13
|
+
from .lapack import get_lapack_funcs, _compute_lwork
|
14
|
+
from ._misc import LinAlgError, _datacopied, LinAlgWarning
|
15
|
+
from ._decomp import _asarray_validated
|
16
|
+
from . import _decomp, _decomp_svd
|
17
|
+
from ._solve_toeplitz import levinson
|
18
|
+
from ._cythonized_array_utils import (find_det_from_lu, bandwidth, issymmetric,
|
19
|
+
ishermitian)
|
20
|
+
|
21
|
+
__all__ = ['solve', 'solve_triangular', 'solveh_banded', 'solve_banded',
|
22
|
+
'solve_toeplitz', 'solve_circulant', 'inv', 'det', 'lstsq',
|
23
|
+
'pinv', 'pinvh', 'matrix_balance', 'matmul_toeplitz']
|
24
|
+
|
25
|
+
|
26
|
+
# The numpy facilities for type-casting checks are too slow for small sized
|
27
|
+
# arrays and eat away the time budget for the checkups. Here we set a
|
28
|
+
# precomputed dict container of the numpy.can_cast() table.
|
29
|
+
|
30
|
+
# It can be used to determine quickly what a dtype can be cast to LAPACK
|
31
|
+
# compatible types, i.e., 'float32, float64, complex64, complex128'.
|
32
|
+
# Then it can be checked via "casting_dict[arr.dtype.char]"
|
33
|
+
lapack_cast_dict = {x: ''.join([y for y in 'fdFD' if np.can_cast(x, y)])
|
34
|
+
for x in np.typecodes['All']}
|
35
|
+
|
36
|
+
|
37
|
+
# Linear equations
|
38
|
+
def _solve_check(n, info, lamch=None, rcond=None):
|
39
|
+
""" Check arguments during the different steps of the solution phase """
|
40
|
+
if info < 0:
|
41
|
+
raise ValueError(f'LAPACK reported an illegal value in {-info}-th argument.')
|
42
|
+
elif 0 < info or rcond == 0:
|
43
|
+
raise LinAlgError('Matrix is singular.')
|
44
|
+
|
45
|
+
if lamch is None:
|
46
|
+
return
|
47
|
+
E = lamch('E')
|
48
|
+
if not (rcond >= E): # `rcond < E` doesn't handle NaN
|
49
|
+
warn(f'Ill-conditioned matrix (rcond={rcond:.6g}): '
|
50
|
+
'result may not be accurate.',
|
51
|
+
LinAlgWarning, stacklevel=3)
|
52
|
+
|
53
|
+
|
54
|
+
def _find_matrix_structure(a):
|
55
|
+
n = a.shape[0]
|
56
|
+
n_below, n_above = bandwidth(a)
|
57
|
+
|
58
|
+
if n_below == n_above == 0:
|
59
|
+
kind = 'diagonal'
|
60
|
+
elif n_above == 0:
|
61
|
+
kind = 'lower triangular'
|
62
|
+
elif n_below == 0:
|
63
|
+
kind = 'upper triangular'
|
64
|
+
elif n_above <= 1 and n_below <= 1 and n > 3:
|
65
|
+
kind = 'tridiagonal'
|
66
|
+
elif np.issubdtype(a.dtype, np.complexfloating) and ishermitian(a):
|
67
|
+
kind = 'hermitian'
|
68
|
+
elif issymmetric(a):
|
69
|
+
kind = 'symmetric'
|
70
|
+
else:
|
71
|
+
kind = 'general'
|
72
|
+
|
73
|
+
return kind, n_below, n_above
|
74
|
+
|
75
|
+
|
76
|
+
@_apply_over_batch(('a', 2), ('b', '1|2'))
|
77
|
+
def solve(a, b, lower=False, overwrite_a=False,
|
78
|
+
overwrite_b=False, check_finite=True, assume_a=None,
|
79
|
+
transposed=False):
|
80
|
+
"""
|
81
|
+
Solve the equation ``a @ x = b`` for ``x``,
|
82
|
+
where `a` is a square matrix.
|
83
|
+
|
84
|
+
If the data matrix is known to be a particular type then supplying the
|
85
|
+
corresponding string to ``assume_a`` key chooses the dedicated solver.
|
86
|
+
The available options are
|
87
|
+
|
88
|
+
============================= ================================
|
89
|
+
diagonal 'diagonal'
|
90
|
+
tridiagonal 'tridiagonal'
|
91
|
+
banded 'banded'
|
92
|
+
upper triangular 'upper triangular'
|
93
|
+
lower triangular 'lower triangular'
|
94
|
+
symmetric 'symmetric' (or 'sym')
|
95
|
+
hermitian 'hermitian' (or 'her')
|
96
|
+
symmetric positive definite 'positive definite' (or 'pos')
|
97
|
+
general 'general' (or 'gen')
|
98
|
+
============================= ================================
|
99
|
+
|
100
|
+
Parameters
|
101
|
+
----------
|
102
|
+
a : (N, N) array_like
|
103
|
+
Square input data
|
104
|
+
b : (N, NRHS) array_like
|
105
|
+
Input data for the right hand side.
|
106
|
+
lower : bool, default: False
|
107
|
+
Ignored unless ``assume_a`` is one of ``'sym'``, ``'her'``, or ``'pos'``.
|
108
|
+
If True, the calculation uses only the data in the lower triangle of `a`;
|
109
|
+
entries above the diagonal are ignored. If False (default), the
|
110
|
+
calculation uses only the data in the upper triangle of `a`; entries
|
111
|
+
below the diagonal are ignored.
|
112
|
+
overwrite_a : bool, default: False
|
113
|
+
Allow overwriting data in `a` (may enhance performance).
|
114
|
+
overwrite_b : bool, default: False
|
115
|
+
Allow overwriting data in `b` (may enhance performance).
|
116
|
+
check_finite : bool, default: True
|
117
|
+
Whether to check that the input matrices contain only finite numbers.
|
118
|
+
Disabling may give a performance gain, but may result in problems
|
119
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
120
|
+
assume_a : str, optional
|
121
|
+
Valid entries are described above.
|
122
|
+
If omitted or ``None``, checks are performed to identify structure so the
|
123
|
+
appropriate solver can be called.
|
124
|
+
transposed : bool, default: False
|
125
|
+
If True, solve ``a.T @ x == b``. Raises `NotImplementedError`
|
126
|
+
for complex `a`.
|
127
|
+
|
128
|
+
Returns
|
129
|
+
-------
|
130
|
+
x : (N, NRHS) ndarray
|
131
|
+
The solution array.
|
132
|
+
|
133
|
+
Raises
|
134
|
+
------
|
135
|
+
ValueError
|
136
|
+
If size mismatches detected or input a is not square.
|
137
|
+
LinAlgError
|
138
|
+
If the computation fails because of matrix singularity.
|
139
|
+
LinAlgWarning
|
140
|
+
If an ill-conditioned input a is detected.
|
141
|
+
NotImplementedError
|
142
|
+
If transposed is True and input a is a complex matrix.
|
143
|
+
|
144
|
+
Notes
|
145
|
+
-----
|
146
|
+
If the input b matrix is a 1-D array with N elements, when supplied
|
147
|
+
together with an NxN input a, it is assumed as a valid column vector
|
148
|
+
despite the apparent size mismatch. This is compatible with the
|
149
|
+
numpy.dot() behavior and the returned result is still 1-D array.
|
150
|
+
|
151
|
+
The general, symmetric, Hermitian and positive definite solutions are
|
152
|
+
obtained via calling ?GESV, ?SYSV, ?HESV, and ?POSV routines of
|
153
|
+
LAPACK respectively.
|
154
|
+
|
155
|
+
The datatype of the arrays define which solver is called regardless
|
156
|
+
of the values. In other words, even when the complex array entries have
|
157
|
+
precisely zero imaginary parts, the complex solver will be called based
|
158
|
+
on the data type of the array.
|
159
|
+
|
160
|
+
Examples
|
161
|
+
--------
|
162
|
+
Given `a` and `b`, solve for `x`:
|
163
|
+
|
164
|
+
>>> import numpy as np
|
165
|
+
>>> a = np.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]])
|
166
|
+
>>> b = np.array([2, 4, -1])
|
167
|
+
>>> from scipy import linalg
|
168
|
+
>>> x = linalg.solve(a, b)
|
169
|
+
>>> x
|
170
|
+
array([ 2., -2., 9.])
|
171
|
+
>>> np.dot(a, x) == b
|
172
|
+
array([ True, True, True], dtype=bool)
|
173
|
+
|
174
|
+
"""
|
175
|
+
# Flags for 1-D or N-D right-hand side
|
176
|
+
b_is_1D = False
|
177
|
+
|
178
|
+
# check finite after determining structure
|
179
|
+
a1 = atleast_2d(_asarray_validated(a, check_finite=False))
|
180
|
+
b1 = atleast_1d(_asarray_validated(b, check_finite=False))
|
181
|
+
a1, b1 = _ensure_dtype_cdsz(a1, b1)
|
182
|
+
n = a1.shape[0]
|
183
|
+
|
184
|
+
overwrite_a = overwrite_a or _datacopied(a1, a)
|
185
|
+
overwrite_b = overwrite_b or _datacopied(b1, b)
|
186
|
+
|
187
|
+
if a1.shape[0] != a1.shape[1]:
|
188
|
+
raise ValueError('Input a needs to be a square matrix.')
|
189
|
+
|
190
|
+
if n != b1.shape[0]:
|
191
|
+
# Last chance to catch 1x1 scalar a and 1-D b arrays
|
192
|
+
if not (n == 1 and b1.size != 0):
|
193
|
+
raise ValueError('Input b has to have same number of rows as '
|
194
|
+
'input a')
|
195
|
+
|
196
|
+
# accommodate empty arrays
|
197
|
+
if b1.size == 0:
|
198
|
+
dt = solve(np.eye(2, dtype=a1.dtype), np.ones(2, dtype=b1.dtype)).dtype
|
199
|
+
return np.empty_like(b1, dtype=dt)
|
200
|
+
|
201
|
+
# regularize 1-D b arrays to 2D
|
202
|
+
if b1.ndim == 1:
|
203
|
+
if n == 1:
|
204
|
+
b1 = b1[None, :]
|
205
|
+
else:
|
206
|
+
b1 = b1[:, None]
|
207
|
+
b_is_1D = True
|
208
|
+
|
209
|
+
if assume_a not in {None, 'diagonal', 'tridiagonal', 'banded', 'lower triangular',
|
210
|
+
'upper triangular', 'symmetric', 'hermitian',
|
211
|
+
'positive definite', 'general', 'sym', 'her', 'pos', 'gen'}:
|
212
|
+
raise ValueError(f'{assume_a} is not a recognized matrix structure')
|
213
|
+
|
214
|
+
# for a real matrix, describe it as "symmetric", not "hermitian"
|
215
|
+
# (lapack doesn't know what to do with real hermitian matrices)
|
216
|
+
if assume_a in {'hermitian', 'her'} and not np.iscomplexobj(a1):
|
217
|
+
assume_a = 'symmetric'
|
218
|
+
|
219
|
+
n_below, n_above = None, None
|
220
|
+
if assume_a is None:
|
221
|
+
assume_a, n_below, n_above = _find_matrix_structure(a1)
|
222
|
+
|
223
|
+
# Get the correct lamch function.
|
224
|
+
# The LAMCH functions only exists for S and D
|
225
|
+
# So for complex values we have to convert to real/double.
|
226
|
+
if a1.dtype.char in 'fF': # single precision
|
227
|
+
lamch = get_lapack_funcs('lamch', dtype='f')
|
228
|
+
else:
|
229
|
+
lamch = get_lapack_funcs('lamch', dtype='d')
|
230
|
+
|
231
|
+
|
232
|
+
# Since the I-norm and 1-norm are the same for symmetric matrices
|
233
|
+
# we can collect them all in this one call
|
234
|
+
# Note however, that when issuing 'gen' and form!='none', then
|
235
|
+
# the I-norm should be used
|
236
|
+
if transposed:
|
237
|
+
trans = 1
|
238
|
+
norm = 'I'
|
239
|
+
if np.iscomplexobj(a1):
|
240
|
+
raise NotImplementedError('scipy.linalg.solve can currently '
|
241
|
+
'not solve a^T x = b or a^H x = b '
|
242
|
+
'for complex matrices.')
|
243
|
+
else:
|
244
|
+
trans = 0
|
245
|
+
norm = '1'
|
246
|
+
|
247
|
+
# Currently we do not have the other forms of the norm calculators
|
248
|
+
# lansy, lanpo, lanhe.
|
249
|
+
# However, in any case they only reduce computations slightly...
|
250
|
+
if assume_a == 'diagonal':
|
251
|
+
anorm = _matrix_norm_diagonal(a1, check_finite)
|
252
|
+
elif assume_a == 'tridiagonal':
|
253
|
+
anorm = _matrix_norm_tridiagonal(norm, a1, check_finite)
|
254
|
+
elif assume_a == 'banded':
|
255
|
+
n_below, n_above = bandwidth(a1) if n_below is None else (n_below, n_above)
|
256
|
+
a2, n_below, n_above = ((a1.T, n_above, n_below) if transposed
|
257
|
+
else (a1, n_below, n_above))
|
258
|
+
ab = _to_banded(n_below, n_above, a2)
|
259
|
+
anorm = _matrix_norm_banded(n_below, n_above, norm, ab, check_finite)
|
260
|
+
elif assume_a in {'lower triangular', 'upper triangular'}:
|
261
|
+
anorm = _matrix_norm_triangular(assume_a, norm, a1, check_finite)
|
262
|
+
else:
|
263
|
+
anorm = _matrix_norm_general(norm, a1, check_finite)
|
264
|
+
|
265
|
+
info, rcond = 0, np.inf
|
266
|
+
|
267
|
+
# Generalized case 'gesv'
|
268
|
+
if assume_a in {'general', 'gen'}:
|
269
|
+
gecon, getrf, getrs = get_lapack_funcs(('gecon', 'getrf', 'getrs'),
|
270
|
+
(a1, b1))
|
271
|
+
lu, ipvt, info = getrf(a1, overwrite_a=overwrite_a)
|
272
|
+
_solve_check(n, info)
|
273
|
+
x, info = getrs(lu, ipvt, b1,
|
274
|
+
trans=trans, overwrite_b=overwrite_b)
|
275
|
+
_solve_check(n, info)
|
276
|
+
rcond, info = gecon(lu, anorm, norm=norm)
|
277
|
+
# Hermitian case 'hesv'
|
278
|
+
elif assume_a in {'hermitian', 'her'}:
|
279
|
+
hecon, hesv, hesv_lw = get_lapack_funcs(('hecon', 'hesv',
|
280
|
+
'hesv_lwork'), (a1, b1))
|
281
|
+
lwork = _compute_lwork(hesv_lw, n, lower)
|
282
|
+
lu, ipvt, x, info = hesv(a1, b1, lwork=lwork,
|
283
|
+
lower=lower,
|
284
|
+
overwrite_a=overwrite_a,
|
285
|
+
overwrite_b=overwrite_b)
|
286
|
+
_solve_check(n, info)
|
287
|
+
rcond, info = hecon(lu, ipvt, anorm, lower=lower)
|
288
|
+
# Symmetric case 'sysv'
|
289
|
+
elif assume_a in {'symmetric', 'sym'}:
|
290
|
+
sycon, sysv, sysv_lw = get_lapack_funcs(('sycon', 'sysv',
|
291
|
+
'sysv_lwork'), (a1, b1))
|
292
|
+
lwork = _compute_lwork(sysv_lw, n, lower)
|
293
|
+
lu, ipvt, x, info = sysv(a1, b1, lwork=lwork,
|
294
|
+
lower=lower,
|
295
|
+
overwrite_a=overwrite_a,
|
296
|
+
overwrite_b=overwrite_b)
|
297
|
+
_solve_check(n, info)
|
298
|
+
rcond, info = sycon(lu, ipvt, anorm, lower=lower)
|
299
|
+
# Diagonal case
|
300
|
+
elif assume_a == 'diagonal':
|
301
|
+
diag_a = np.diag(a1)
|
302
|
+
x = (b1.T / diag_a).T
|
303
|
+
abs_diag_a = np.abs(diag_a)
|
304
|
+
diag_min = abs_diag_a.min()
|
305
|
+
rcond = diag_min if diag_min == 0 else diag_min / abs_diag_a.max()
|
306
|
+
# Tri-diagonal case
|
307
|
+
elif assume_a == 'tridiagonal':
|
308
|
+
a1 = a1.T if transposed else a1
|
309
|
+
dl, d, du = np.diag(a1, -1), np.diag(a1, 0), np.diag(a1, 1)
|
310
|
+
_gttrf, _gttrs, _gtcon = get_lapack_funcs(('gttrf', 'gttrs', 'gtcon'), (a1, b1))
|
311
|
+
dl, d, du, du2, ipiv, info = _gttrf(dl, d, du)
|
312
|
+
_solve_check(n, info)
|
313
|
+
x, info = _gttrs(dl, d, du, du2, ipiv, b1, overwrite_b=overwrite_b)
|
314
|
+
_solve_check(n, info)
|
315
|
+
rcond, info = _gtcon(dl, d, du, du2, ipiv, anorm)
|
316
|
+
# Banded case
|
317
|
+
elif assume_a == 'banded':
|
318
|
+
gbsv, gbcon = get_lapack_funcs(('gbsv', 'gbcon'), (a1, b1))
|
319
|
+
# Next two lines copied from `solve_banded`
|
320
|
+
a2 = np.zeros((2*n_below + n_above + 1, ab.shape[1]), dtype=gbsv.dtype)
|
321
|
+
a2[n_below:, :] = ab
|
322
|
+
lu, piv, x, info = gbsv(n_below, n_above, a2, b1,
|
323
|
+
overwrite_ab=True, overwrite_b=overwrite_b)
|
324
|
+
_solve_check(n, info)
|
325
|
+
rcond, info = gbcon(n_below, n_above, lu, piv, anorm)
|
326
|
+
# Triangular case
|
327
|
+
elif assume_a in {'lower triangular', 'upper triangular'}:
|
328
|
+
lower = assume_a == 'lower triangular'
|
329
|
+
x, info = _solve_triangular(a1, b1, lower=lower, overwrite_b=overwrite_b,
|
330
|
+
trans=transposed)
|
331
|
+
_solve_check(n, info)
|
332
|
+
_trcon = get_lapack_funcs(('trcon'), (a1, b1))
|
333
|
+
rcond, info = _trcon(a1, uplo='L' if lower else 'U')
|
334
|
+
# Positive definite case 'posv'
|
335
|
+
else:
|
336
|
+
pocon, posv = get_lapack_funcs(('pocon', 'posv'),
|
337
|
+
(a1, b1))
|
338
|
+
lu, x, info = posv(a1, b1, lower=lower,
|
339
|
+
overwrite_a=overwrite_a,
|
340
|
+
overwrite_b=overwrite_b)
|
341
|
+
_solve_check(n, info)
|
342
|
+
rcond, info = pocon(lu, anorm)
|
343
|
+
|
344
|
+
_solve_check(n, info, lamch, rcond)
|
345
|
+
|
346
|
+
if b_is_1D:
|
347
|
+
x = x.ravel()
|
348
|
+
|
349
|
+
return x
|
350
|
+
|
351
|
+
|
352
|
+
def _matrix_norm_diagonal(a, check_finite):
|
353
|
+
# Equivalent of dlange for diagonal matrix, assuming
|
354
|
+
# norm is either 'I' or '1' (really just not the Frobenius norm)
|
355
|
+
d = np.diag(a)
|
356
|
+
d = np.asarray_chkfinite(d) if check_finite else d
|
357
|
+
return np.abs(d).max()
|
358
|
+
|
359
|
+
|
360
|
+
def _matrix_norm_tridiagonal(norm, a, check_finite):
|
361
|
+
# Equivalent of dlange for tridiagonal matrix, assuming
|
362
|
+
# norm is either 'I' or '1'
|
363
|
+
if norm == 'I':
|
364
|
+
a = a.T
|
365
|
+
# Context to avoid warning before error in cases like -inf + inf
|
366
|
+
with np.errstate(invalid='ignore'):
|
367
|
+
d = np.abs(np.diag(a))
|
368
|
+
d[1:] += np.abs(np.diag(a, 1))
|
369
|
+
d[:-1] += np.abs(np.diag(a, -1))
|
370
|
+
d = np.asarray_chkfinite(d) if check_finite else d
|
371
|
+
return d.max()
|
372
|
+
|
373
|
+
|
374
|
+
def _matrix_norm_triangular(structure, norm, a, check_finite):
|
375
|
+
a = np.asarray_chkfinite(a) if check_finite else a
|
376
|
+
lantr = get_lapack_funcs('lantr', (a,))
|
377
|
+
return lantr(norm, a, 'L' if structure == 'lower triangular' else 'U' )
|
378
|
+
|
379
|
+
|
380
|
+
def _matrix_norm_banded(kl, ku, norm, ab, check_finite):
|
381
|
+
ab = np.asarray_chkfinite(ab) if check_finite else ab
|
382
|
+
langb = get_lapack_funcs('langb', (ab,))
|
383
|
+
return langb(norm, kl, ku, ab)
|
384
|
+
|
385
|
+
|
386
|
+
def _matrix_norm_general(norm, a, check_finite):
|
387
|
+
a = np.asarray_chkfinite(a) if check_finite else a
|
388
|
+
lange = get_lapack_funcs('lange', (a,))
|
389
|
+
return lange(norm, a)
|
390
|
+
|
391
|
+
|
392
|
+
def _to_banded(n_below, n_above, a):
|
393
|
+
n = a.shape[0]
|
394
|
+
rows = n_above + n_below + 1
|
395
|
+
ab = np.zeros((rows, n), dtype=a.dtype)
|
396
|
+
ab[n_above] = np.diag(a)
|
397
|
+
for i in range(1, n_above + 1):
|
398
|
+
ab[n_above - i, i:] = np.diag(a, i)
|
399
|
+
for i in range(1, n_below + 1):
|
400
|
+
ab[n_above + i, :-i] = np.diag(a, -i)
|
401
|
+
return ab
|
402
|
+
|
403
|
+
|
404
|
+
def _ensure_dtype_cdsz(*arrays):
|
405
|
+
# Ensure that the dtype of arrays is one of the standard types
|
406
|
+
# compatible with LAPACK functions (single or double precision
|
407
|
+
# real or complex).
|
408
|
+
dtype = np.result_type(*arrays)
|
409
|
+
if not np.issubdtype(dtype, np.inexact):
|
410
|
+
return (array.astype(np.float64) for array in arrays)
|
411
|
+
complex = np.issubdtype(dtype, np.complexfloating)
|
412
|
+
if np.finfo(dtype).bits <= 32:
|
413
|
+
dtype = np.complex64 if complex else np.float32
|
414
|
+
elif np.finfo(dtype).bits >= 64:
|
415
|
+
dtype = np.complex128 if complex else np.float64
|
416
|
+
return (array.astype(dtype, copy=False) for array in arrays)
|
417
|
+
|
418
|
+
|
419
|
+
@_apply_over_batch(('a', 2), ('b', '1|2'))
|
420
|
+
def solve_triangular(a, b, trans=0, lower=False, unit_diagonal=False,
|
421
|
+
overwrite_b=False, check_finite=True):
|
422
|
+
"""
|
423
|
+
Solve the equation ``a @ x = b`` for ``x``, where `a` is a triangular matrix.
|
424
|
+
|
425
|
+
Parameters
|
426
|
+
----------
|
427
|
+
a : (M, M) array_like
|
428
|
+
A triangular matrix
|
429
|
+
b : (M,) or (M, N) array_like
|
430
|
+
Right-hand side matrix in ``a x = b``
|
431
|
+
lower : bool, optional
|
432
|
+
Use only data contained in the lower triangle of `a`.
|
433
|
+
Default is to use upper triangle.
|
434
|
+
trans : {0, 1, 2, 'N', 'T', 'C'}, optional
|
435
|
+
Type of system to solve:
|
436
|
+
|
437
|
+
======== =========
|
438
|
+
trans system
|
439
|
+
======== =========
|
440
|
+
0 or 'N' a x = b
|
441
|
+
1 or 'T' a^T x = b
|
442
|
+
2 or 'C' a^H x = b
|
443
|
+
======== =========
|
444
|
+
unit_diagonal : bool, optional
|
445
|
+
If True, diagonal elements of `a` are assumed to be 1 and
|
446
|
+
will not be referenced.
|
447
|
+
overwrite_b : bool, optional
|
448
|
+
Allow overwriting data in `b` (may enhance performance)
|
449
|
+
check_finite : bool, optional
|
450
|
+
Whether to check that the input matrices contain only finite numbers.
|
451
|
+
Disabling may give a performance gain, but may result in problems
|
452
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
453
|
+
|
454
|
+
Returns
|
455
|
+
-------
|
456
|
+
x : (M,) or (M, N) ndarray
|
457
|
+
Solution to the system ``a x = b``. Shape of return matches `b`.
|
458
|
+
|
459
|
+
Raises
|
460
|
+
------
|
461
|
+
LinAlgError
|
462
|
+
If `a` is singular
|
463
|
+
|
464
|
+
Notes
|
465
|
+
-----
|
466
|
+
.. versionadded:: 0.9.0
|
467
|
+
|
468
|
+
Examples
|
469
|
+
--------
|
470
|
+
Solve the lower triangular system a x = b, where::
|
471
|
+
|
472
|
+
[3 0 0 0] [4]
|
473
|
+
a = [2 1 0 0] b = [2]
|
474
|
+
[1 0 1 0] [4]
|
475
|
+
[1 1 1 1] [2]
|
476
|
+
|
477
|
+
>>> import numpy as np
|
478
|
+
>>> from scipy.linalg import solve_triangular
|
479
|
+
>>> a = np.array([[3, 0, 0, 0], [2, 1, 0, 0], [1, 0, 1, 0], [1, 1, 1, 1]])
|
480
|
+
>>> b = np.array([4, 2, 4, 2])
|
481
|
+
>>> x = solve_triangular(a, b, lower=True)
|
482
|
+
>>> x
|
483
|
+
array([ 1.33333333, -0.66666667, 2.66666667, -1.33333333])
|
484
|
+
>>> a.dot(x) # Check the result
|
485
|
+
array([ 4., 2., 4., 2.])
|
486
|
+
|
487
|
+
"""
|
488
|
+
|
489
|
+
a1 = _asarray_validated(a, check_finite=check_finite)
|
490
|
+
b1 = _asarray_validated(b, check_finite=check_finite)
|
491
|
+
|
492
|
+
if len(a1.shape) != 2 or a1.shape[0] != a1.shape[1]:
|
493
|
+
raise ValueError('expected square matrix')
|
494
|
+
|
495
|
+
if a1.shape[0] != b1.shape[0]:
|
496
|
+
raise ValueError(f'shapes of a {a1.shape} and b {b1.shape} are incompatible')
|
497
|
+
|
498
|
+
# accommodate empty arrays
|
499
|
+
if b1.size == 0:
|
500
|
+
dt_nonempty = solve_triangular(
|
501
|
+
np.eye(2, dtype=a1.dtype), np.ones(2, dtype=b1.dtype)
|
502
|
+
).dtype
|
503
|
+
return np.empty_like(b1, dtype=dt_nonempty)
|
504
|
+
|
505
|
+
overwrite_b = overwrite_b or _datacopied(b1, b)
|
506
|
+
|
507
|
+
x, _ = _solve_triangular(a1, b1, trans, lower, unit_diagonal, overwrite_b)
|
508
|
+
return x
|
509
|
+
|
510
|
+
|
511
|
+
# solve_triangular without the input validation
|
512
|
+
def _solve_triangular(a1, b1, trans=0, lower=False, unit_diagonal=False,
|
513
|
+
overwrite_b=False):
|
514
|
+
|
515
|
+
trans = {'N': 0, 'T': 1, 'C': 2}.get(trans, trans)
|
516
|
+
trtrs, = get_lapack_funcs(('trtrs',), (a1, b1))
|
517
|
+
if a1.flags.f_contiguous or trans == 2:
|
518
|
+
x, info = trtrs(a1, b1, overwrite_b=overwrite_b, lower=lower,
|
519
|
+
trans=trans, unitdiag=unit_diagonal)
|
520
|
+
else:
|
521
|
+
# transposed system is solved since trtrs expects Fortran ordering
|
522
|
+
x, info = trtrs(a1.T, b1, overwrite_b=overwrite_b, lower=not lower,
|
523
|
+
trans=not trans, unitdiag=unit_diagonal)
|
524
|
+
|
525
|
+
if info == 0:
|
526
|
+
return x, info
|
527
|
+
if info > 0:
|
528
|
+
raise LinAlgError(f"singular matrix: resolution failed at diagonal {info-1}")
|
529
|
+
raise ValueError(f'illegal value in {-info}-th argument of internal trtrs')
|
530
|
+
|
531
|
+
|
532
|
+
def solve_banded(l_and_u, ab, b, overwrite_ab=False, overwrite_b=False,
|
533
|
+
check_finite=True):
|
534
|
+
"""
|
535
|
+
Solve the equation ``a @ x = b`` for ``x``, where ``a`` is the banded matrix
|
536
|
+
defined by `ab`.
|
537
|
+
|
538
|
+
The matrix a is stored in `ab` using the matrix diagonal ordered form::
|
539
|
+
|
540
|
+
ab[u + i - j, j] == a[i,j]
|
541
|
+
|
542
|
+
Example of `ab` (shape of a is (6,6), `u` =1, `l` =2)::
|
543
|
+
|
544
|
+
* a01 a12 a23 a34 a45
|
545
|
+
a00 a11 a22 a33 a44 a55
|
546
|
+
a10 a21 a32 a43 a54 *
|
547
|
+
a20 a31 a42 a53 * *
|
548
|
+
|
549
|
+
Parameters
|
550
|
+
----------
|
551
|
+
(l, u) : (integer, integer)
|
552
|
+
Number of non-zero lower and upper diagonals
|
553
|
+
ab : (`l` + `u` + 1, M) array_like
|
554
|
+
Banded matrix
|
555
|
+
b : (M,) or (M, K) array_like
|
556
|
+
Right-hand side
|
557
|
+
overwrite_ab : bool, optional
|
558
|
+
Discard data in `ab` (may enhance performance)
|
559
|
+
overwrite_b : bool, optional
|
560
|
+
Discard data in `b` (may enhance performance)
|
561
|
+
check_finite : bool, optional
|
562
|
+
Whether to check that the input matrices contain only finite numbers.
|
563
|
+
Disabling may give a performance gain, but may result in problems
|
564
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
565
|
+
|
566
|
+
Returns
|
567
|
+
-------
|
568
|
+
x : (M,) or (M, K) ndarray
|
569
|
+
The solution to the system a x = b. Returned shape depends on the
|
570
|
+
shape of `b`.
|
571
|
+
|
572
|
+
Examples
|
573
|
+
--------
|
574
|
+
Solve the banded system a x = b, where::
|
575
|
+
|
576
|
+
[5 2 -1 0 0] [0]
|
577
|
+
[1 4 2 -1 0] [1]
|
578
|
+
a = [0 1 3 2 -1] b = [2]
|
579
|
+
[0 0 1 2 2] [2]
|
580
|
+
[0 0 0 1 1] [3]
|
581
|
+
|
582
|
+
There is one nonzero diagonal below the main diagonal (l = 1), and
|
583
|
+
two above (u = 2). The diagonal banded form of the matrix is::
|
584
|
+
|
585
|
+
[* * -1 -1 -1]
|
586
|
+
ab = [* 2 2 2 2]
|
587
|
+
[5 4 3 2 1]
|
588
|
+
[1 1 1 1 *]
|
589
|
+
|
590
|
+
>>> import numpy as np
|
591
|
+
>>> from scipy.linalg import solve_banded
|
592
|
+
>>> ab = np.array([[0, 0, -1, -1, -1],
|
593
|
+
... [0, 2, 2, 2, 2],
|
594
|
+
... [5, 4, 3, 2, 1],
|
595
|
+
... [1, 1, 1, 1, 0]])
|
596
|
+
>>> b = np.array([0, 1, 2, 2, 3])
|
597
|
+
>>> x = solve_banded((1, 2), ab, b)
|
598
|
+
>>> x
|
599
|
+
array([-2.37288136, 3.93220339, -4. , 4.3559322 , -1.3559322 ])
|
600
|
+
|
601
|
+
"""
|
602
|
+
(nlower, nupper) = l_and_u
|
603
|
+
return _solve_banded(nlower, nupper, ab, b, overwrite_ab=overwrite_ab,
|
604
|
+
overwrite_b=overwrite_b, check_finite=check_finite)
|
605
|
+
|
606
|
+
|
607
|
+
@_apply_over_batch(('nlower', 0), ('nupper', 0), ('ab', 2), ('b', '1|2'))
|
608
|
+
def _solve_banded(nlower, nupper, ab, b, overwrite_ab, overwrite_b, check_finite):
|
609
|
+
a1 = _asarray_validated(ab, check_finite=check_finite, as_inexact=True)
|
610
|
+
b1 = _asarray_validated(b, check_finite=check_finite, as_inexact=True)
|
611
|
+
|
612
|
+
# Validate shapes.
|
613
|
+
if a1.shape[-1] != b1.shape[0]:
|
614
|
+
raise ValueError("shapes of ab and b are not compatible.")
|
615
|
+
|
616
|
+
if nlower + nupper + 1 != a1.shape[0]:
|
617
|
+
raise ValueError(
|
618
|
+
f"invalid values for the number of lower and upper diagonals: l+u+1 "
|
619
|
+
f"({nlower + nupper + 1}) does not equal ab.shape[0] ({ab.shape[0]})"
|
620
|
+
)
|
621
|
+
|
622
|
+
# accommodate empty arrays
|
623
|
+
if b1.size == 0:
|
624
|
+
dt = solve(np.eye(1, dtype=a1.dtype), np.ones(1, dtype=b1.dtype)).dtype
|
625
|
+
return np.empty_like(b1, dtype=dt)
|
626
|
+
|
627
|
+
overwrite_b = overwrite_b or _datacopied(b1, b)
|
628
|
+
if a1.shape[-1] == 1:
|
629
|
+
b2 = np.array(b1, copy=(not overwrite_b))
|
630
|
+
# a1.shape[-1] == 1 -> original matrix is 1x1. Typically, the user
|
631
|
+
# will pass u = l = 0 and `a1` will be 1x1. However, the rest of the
|
632
|
+
# function works with unnecessary rows in `a1` as long as
|
633
|
+
# `a1[u + i - j, j] == a[i,j]`. In the 1x1 case, we want i = j = 0,
|
634
|
+
# so the diagonal is in row `u` of `a1`. See gh-8906.
|
635
|
+
b2 /= a1[nupper, 0]
|
636
|
+
return b2
|
637
|
+
if nlower == nupper == 1:
|
638
|
+
overwrite_ab = overwrite_ab or _datacopied(a1, ab)
|
639
|
+
gtsv, = get_lapack_funcs(('gtsv',), (a1, b1))
|
640
|
+
du = a1[0, 1:]
|
641
|
+
d = a1[1, :]
|
642
|
+
dl = a1[2, :-1]
|
643
|
+
du2, d, du, x, info = gtsv(dl, d, du, b1, overwrite_ab, overwrite_ab,
|
644
|
+
overwrite_ab, overwrite_b)
|
645
|
+
else:
|
646
|
+
gbsv, = get_lapack_funcs(('gbsv',), (a1, b1))
|
647
|
+
a2 = np.zeros((2*nlower + nupper + 1, a1.shape[1]), dtype=gbsv.dtype)
|
648
|
+
a2[nlower:, :] = a1
|
649
|
+
lu, piv, x, info = gbsv(nlower, nupper, a2, b1, overwrite_ab=True,
|
650
|
+
overwrite_b=overwrite_b)
|
651
|
+
if info == 0:
|
652
|
+
return x
|
653
|
+
if info > 0:
|
654
|
+
raise LinAlgError("singular matrix")
|
655
|
+
raise ValueError(f'illegal value in {-info}-th argument of internal gbsv/gtsv')
|
656
|
+
|
657
|
+
|
658
|
+
@_apply_over_batch(('a', 2), ('b', '1|2'))
|
659
|
+
def solveh_banded(ab, b, overwrite_ab=False, overwrite_b=False, lower=False,
|
660
|
+
check_finite=True):
|
661
|
+
"""
|
662
|
+
Solve the equation ``a @ x = b`` for ``x``, where ``a`` is the
|
663
|
+
Hermitian positive-definite banded matrix defined by `ab`.
|
664
|
+
|
665
|
+
Uses Thomas' Algorithm, which is more efficient than standard LU
|
666
|
+
factorization, but should only be used for Hermitian positive-definite
|
667
|
+
matrices.
|
668
|
+
|
669
|
+
The matrix ``a`` is stored in `ab` either in lower diagonal or upper
|
670
|
+
diagonal ordered form:
|
671
|
+
|
672
|
+
ab[u + i - j, j] == a[i,j] (if upper form; i <= j)
|
673
|
+
ab[ i - j, j] == a[i,j] (if lower form; i >= j)
|
674
|
+
|
675
|
+
Example of `ab` (shape of ``a`` is (6, 6), number of upper diagonals,
|
676
|
+
``u`` =2)::
|
677
|
+
|
678
|
+
upper form:
|
679
|
+
* * a02 a13 a24 a35
|
680
|
+
* a01 a12 a23 a34 a45
|
681
|
+
a00 a11 a22 a33 a44 a55
|
682
|
+
|
683
|
+
lower form:
|
684
|
+
a00 a11 a22 a33 a44 a55
|
685
|
+
a10 a21 a32 a43 a54 *
|
686
|
+
a20 a31 a42 a53 * *
|
687
|
+
|
688
|
+
Cells marked with * are not used.
|
689
|
+
|
690
|
+
Parameters
|
691
|
+
----------
|
692
|
+
ab : (``u`` + 1, M) array_like
|
693
|
+
Banded matrix
|
694
|
+
b : (M,) or (M, K) array_like
|
695
|
+
Right-hand side
|
696
|
+
overwrite_ab : bool, optional
|
697
|
+
Discard data in `ab` (may enhance performance)
|
698
|
+
overwrite_b : bool, optional
|
699
|
+
Discard data in `b` (may enhance performance)
|
700
|
+
lower : bool, optional
|
701
|
+
Is the matrix in the lower form. (Default is upper form)
|
702
|
+
check_finite : bool, optional
|
703
|
+
Whether to check that the input matrices contain only finite numbers.
|
704
|
+
Disabling may give a performance gain, but may result in problems
|
705
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
706
|
+
|
707
|
+
Returns
|
708
|
+
-------
|
709
|
+
x : (M,) or (M, K) ndarray
|
710
|
+
The solution to the system ``a x = b``. Shape of return matches shape
|
711
|
+
of `b`.
|
712
|
+
|
713
|
+
Notes
|
714
|
+
-----
|
715
|
+
In the case of a non-positive definite matrix ``a``, the solver
|
716
|
+
`solve_banded` may be used.
|
717
|
+
|
718
|
+
Examples
|
719
|
+
--------
|
720
|
+
Solve the banded system ``A x = b``, where::
|
721
|
+
|
722
|
+
[ 4 2 -1 0 0 0] [1]
|
723
|
+
[ 2 5 2 -1 0 0] [2]
|
724
|
+
A = [-1 2 6 2 -1 0] b = [2]
|
725
|
+
[ 0 -1 2 7 2 -1] [3]
|
726
|
+
[ 0 0 -1 2 8 2] [3]
|
727
|
+
[ 0 0 0 -1 2 9] [3]
|
728
|
+
|
729
|
+
>>> import numpy as np
|
730
|
+
>>> from scipy.linalg import solveh_banded
|
731
|
+
|
732
|
+
``ab`` contains the main diagonal and the nonzero diagonals below the
|
733
|
+
main diagonal. That is, we use the lower form:
|
734
|
+
|
735
|
+
>>> ab = np.array([[ 4, 5, 6, 7, 8, 9],
|
736
|
+
... [ 2, 2, 2, 2, 2, 0],
|
737
|
+
... [-1, -1, -1, -1, 0, 0]])
|
738
|
+
>>> b = np.array([1, 2, 2, 3, 3, 3])
|
739
|
+
>>> x = solveh_banded(ab, b, lower=True)
|
740
|
+
>>> x
|
741
|
+
array([ 0.03431373, 0.45938375, 0.05602241, 0.47759104, 0.17577031,
|
742
|
+
0.34733894])
|
743
|
+
|
744
|
+
|
745
|
+
Solve the Hermitian banded system ``H x = b``, where::
|
746
|
+
|
747
|
+
[ 8 2-1j 0 0 ] [ 1 ]
|
748
|
+
H = [2+1j 5 1j 0 ] b = [1+1j]
|
749
|
+
[ 0 -1j 9 -2-1j] [1-2j]
|
750
|
+
[ 0 0 -2+1j 6 ] [ 0 ]
|
751
|
+
|
752
|
+
In this example, we put the upper diagonals in the array ``hb``:
|
753
|
+
|
754
|
+
>>> hb = np.array([[0, 2-1j, 1j, -2-1j],
|
755
|
+
... [8, 5, 9, 6 ]])
|
756
|
+
>>> b = np.array([1, 1+1j, 1-2j, 0])
|
757
|
+
>>> x = solveh_banded(hb, b)
|
758
|
+
>>> x
|
759
|
+
array([ 0.07318536-0.02939412j, 0.11877624+0.17696461j,
|
760
|
+
0.10077984-0.23035393j, -0.00479904-0.09358128j])
|
761
|
+
|
762
|
+
"""
|
763
|
+
a1 = _asarray_validated(ab, check_finite=check_finite)
|
764
|
+
b1 = _asarray_validated(b, check_finite=check_finite)
|
765
|
+
|
766
|
+
# Validate shapes.
|
767
|
+
if a1.shape[-1] != b1.shape[0]:
|
768
|
+
raise ValueError("shapes of ab and b are not compatible.")
|
769
|
+
|
770
|
+
# accommodate empty arrays
|
771
|
+
if b1.size == 0:
|
772
|
+
dt = solve(np.eye(1, dtype=a1.dtype), np.ones(1, dtype=b1.dtype)).dtype
|
773
|
+
return np.empty_like(b1, dtype=dt)
|
774
|
+
|
775
|
+
overwrite_b = overwrite_b or _datacopied(b1, b)
|
776
|
+
overwrite_ab = overwrite_ab or _datacopied(a1, ab)
|
777
|
+
|
778
|
+
if a1.shape[0] == 2:
|
779
|
+
ptsv, = get_lapack_funcs(('ptsv',), (a1, b1))
|
780
|
+
if lower:
|
781
|
+
d = a1[0, :].real
|
782
|
+
e = a1[1, :-1]
|
783
|
+
else:
|
784
|
+
d = a1[1, :].real
|
785
|
+
e = a1[0, 1:].conj()
|
786
|
+
d, du, x, info = ptsv(d, e, b1, overwrite_ab, overwrite_ab,
|
787
|
+
overwrite_b)
|
788
|
+
else:
|
789
|
+
pbsv, = get_lapack_funcs(('pbsv',), (a1, b1))
|
790
|
+
c, x, info = pbsv(a1, b1, lower=lower, overwrite_ab=overwrite_ab,
|
791
|
+
overwrite_b=overwrite_b)
|
792
|
+
if info > 0:
|
793
|
+
raise LinAlgError(f"{info}th leading minor not positive definite")
|
794
|
+
if info < 0:
|
795
|
+
raise ValueError(f'illegal value in {-info}th argument of internal pbsv')
|
796
|
+
return x
|
797
|
+
|
798
|
+
|
799
|
+
def solve_toeplitz(c_or_cr, b, check_finite=True):
|
800
|
+
r"""Solve the equation ``T @ x = b`` for ``x``, where ``T`` is a Toeplitz
|
801
|
+
matrix defined by `c_or_cr`.
|
802
|
+
|
803
|
+
The Toeplitz matrix has constant diagonals, with ``c`` as its first column
|
804
|
+
and ``r`` as its first row. If ``r`` is not given, ``r == conjugate(c)`` is
|
805
|
+
assumed.
|
806
|
+
|
807
|
+
.. warning::
|
808
|
+
|
809
|
+
Beginning in SciPy 1.17, multidimensional input will be treated as a batch,
|
810
|
+
not ``ravel``\ ed. To preserve the existing behavior, ``ravel`` arguments
|
811
|
+
before passing them to `solve_toeplitz`.
|
812
|
+
|
813
|
+
Parameters
|
814
|
+
----------
|
815
|
+
c_or_cr : array_like or tuple of (array_like, array_like)
|
816
|
+
The vector ``c``, or a tuple of arrays (``c``, ``r``). If not
|
817
|
+
supplied, ``r = conjugate(c)`` is assumed; in this case, if c[0] is
|
818
|
+
real, the Toeplitz matrix is Hermitian. r[0] is ignored; the first row
|
819
|
+
of the Toeplitz matrix is ``[c[0], r[1:]]``.
|
820
|
+
b : (M,) or (M, K) array_like
|
821
|
+
Right-hand side in ``T x = b``.
|
822
|
+
check_finite : bool, optional
|
823
|
+
Whether to check that the input matrices contain only finite numbers.
|
824
|
+
Disabling may give a performance gain, but may result in problems
|
825
|
+
(result entirely NaNs) if the inputs do contain infinities or NaNs.
|
826
|
+
|
827
|
+
Returns
|
828
|
+
-------
|
829
|
+
x : (M,) or (M, K) ndarray
|
830
|
+
The solution to the system ``T @ x = b``. Shape of return matches shape
|
831
|
+
of `b`.
|
832
|
+
|
833
|
+
See Also
|
834
|
+
--------
|
835
|
+
toeplitz : Toeplitz matrix
|
836
|
+
|
837
|
+
Notes
|
838
|
+
-----
|
839
|
+
The solution is computed using Levinson-Durbin recursion, which is faster
|
840
|
+
than generic least-squares methods, but can be less numerically stable.
|
841
|
+
|
842
|
+
Examples
|
843
|
+
--------
|
844
|
+
Solve the Toeplitz system ``T @ x = b``, where::
|
845
|
+
|
846
|
+
[ 1 -1 -2 -3] [1]
|
847
|
+
T = [ 3 1 -1 -2] b = [2]
|
848
|
+
[ 6 3 1 -1] [2]
|
849
|
+
[10 6 3 1] [5]
|
850
|
+
|
851
|
+
To specify the Toeplitz matrix, only the first column and the first
|
852
|
+
row are needed.
|
853
|
+
|
854
|
+
>>> import numpy as np
|
855
|
+
>>> c = np.array([1, 3, 6, 10]) # First column of T
|
856
|
+
>>> r = np.array([1, -1, -2, -3]) # First row of T
|
857
|
+
>>> b = np.array([1, 2, 2, 5])
|
858
|
+
|
859
|
+
>>> from scipy.linalg import solve_toeplitz, toeplitz
|
860
|
+
>>> x = solve_toeplitz((c, r), b)
|
861
|
+
>>> x
|
862
|
+
array([ 1.66666667, -1. , -2.66666667, 2.33333333])
|
863
|
+
|
864
|
+
Check the result by creating the full Toeplitz matrix and
|
865
|
+
multiplying it by ``x``. We should get `b`.
|
866
|
+
|
867
|
+
>>> T = toeplitz(c, r)
|
868
|
+
>>> T.dot(x)
|
869
|
+
array([ 1., 2., 2., 5.])
|
870
|
+
|
871
|
+
"""
|
872
|
+
# If numerical stability of this algorithm is a problem, a future
|
873
|
+
# developer might consider implementing other O(N^2) Toeplitz solvers,
|
874
|
+
# such as GKO (https://www.jstor.org/stable/2153371) or Bareiss.
|
875
|
+
c, r = c_or_cr if isinstance(c_or_cr, tuple) else (c_or_cr, np.conjugate(c_or_cr))
|
876
|
+
return _solve_toeplitz(c, r, b, check_finite)
|
877
|
+
|
878
|
+
|
879
|
+
# Can uncomment when `solve_toeplitz` deprecation is done (SciPy 1.17)
|
880
|
+
# @_apply_over_batch(('c', 1), ('r', 1), ('b', '1|2'))
|
881
|
+
def _solve_toeplitz(c, r, b, check_finite):
|
882
|
+
r, c, b, dtype, b_shape = _validate_args_for_toeplitz_ops(
|
883
|
+
(c, r), b, check_finite, keep_b_shape=True)
|
884
|
+
|
885
|
+
# accommodate empty arrays
|
886
|
+
if b.size == 0:
|
887
|
+
return np.empty_like(b)
|
888
|
+
|
889
|
+
# Form a 1-D array of values to be used in the matrix, containing a
|
890
|
+
# reversed copy of r[1:], followed by c.
|
891
|
+
vals = np.concatenate((r[-1:0:-1], c))
|
892
|
+
if b is None:
|
893
|
+
raise ValueError('illegal value, `b` is a required argument')
|
894
|
+
|
895
|
+
if b.ndim == 1:
|
896
|
+
x, _ = levinson(vals, np.ascontiguousarray(b))
|
897
|
+
else:
|
898
|
+
x = np.column_stack([levinson(vals, np.ascontiguousarray(b[:, i]))[0]
|
899
|
+
for i in range(b.shape[1])])
|
900
|
+
x = x.reshape(*b_shape)
|
901
|
+
|
902
|
+
return x
|
903
|
+
|
904
|
+
|
905
|
+
def _get_axis_len(aname, a, axis):
|
906
|
+
ax = axis
|
907
|
+
if ax < 0:
|
908
|
+
ax += a.ndim
|
909
|
+
if 0 <= ax < a.ndim:
|
910
|
+
return a.shape[ax]
|
911
|
+
raise ValueError(f"'{aname}axis' entry is out of bounds")
|
912
|
+
|
913
|
+
|
914
|
+
def solve_circulant(c, b, singular='raise', tol=None,
|
915
|
+
caxis=-1, baxis=0, outaxis=0):
|
916
|
+
"""Solve the equation ``C @ x = b`` for ``x``, where ``C`` is a
|
917
|
+
circulant matrix defined by `c`.
|
918
|
+
|
919
|
+
`C` is the circulant matrix associated with the vector `c`.
|
920
|
+
|
921
|
+
The system is solved by doing division in Fourier space. The
|
922
|
+
calculation is::
|
923
|
+
|
924
|
+
x = ifft(fft(b) / fft(c))
|
925
|
+
|
926
|
+
where `fft` and `ifft` are the fast Fourier transform and its inverse,
|
927
|
+
respectively. For a large vector `c`, this is *much* faster than
|
928
|
+
solving the system with the full circulant matrix.
|
929
|
+
|
930
|
+
Parameters
|
931
|
+
----------
|
932
|
+
c : array_like
|
933
|
+
The coefficients of the circulant matrix.
|
934
|
+
b : array_like
|
935
|
+
Right-hand side matrix in ``a x = b``.
|
936
|
+
singular : str, optional
|
937
|
+
This argument controls how a near singular circulant matrix is
|
938
|
+
handled. If `singular` is "raise" and the circulant matrix is
|
939
|
+
near singular, a `LinAlgError` is raised. If `singular` is
|
940
|
+
"lstsq", the least squares solution is returned. Default is "raise".
|
941
|
+
tol : float, optional
|
942
|
+
If any eigenvalue of the circulant matrix has an absolute value
|
943
|
+
that is less than or equal to `tol`, the matrix is considered to be
|
944
|
+
near singular. If not given, `tol` is set to::
|
945
|
+
|
946
|
+
tol = abs_eigs.max() * abs_eigs.size * np.finfo(np.float64).eps
|
947
|
+
|
948
|
+
where `abs_eigs` is the array of absolute values of the eigenvalues
|
949
|
+
of the circulant matrix.
|
950
|
+
caxis : int
|
951
|
+
When `c` has dimension greater than 1, it is viewed as a collection
|
952
|
+
of circulant vectors. In this case, `caxis` is the axis of `c` that
|
953
|
+
holds the vectors of circulant coefficients.
|
954
|
+
baxis : int
|
955
|
+
When `b` has dimension greater than 1, it is viewed as a collection
|
956
|
+
of vectors. In this case, `baxis` is the axis of `b` that holds the
|
957
|
+
right-hand side vectors.
|
958
|
+
outaxis : int
|
959
|
+
When `c` or `b` are multidimensional, the value returned by
|
960
|
+
`solve_circulant` is multidimensional. In this case, `outaxis` is
|
961
|
+
the axis of the result that holds the solution vectors.
|
962
|
+
|
963
|
+
Returns
|
964
|
+
-------
|
965
|
+
x : ndarray
|
966
|
+
Solution to the system ``C x = b``.
|
967
|
+
|
968
|
+
Raises
|
969
|
+
------
|
970
|
+
LinAlgError
|
971
|
+
If the circulant matrix associated with `c` is near singular.
|
972
|
+
|
973
|
+
See Also
|
974
|
+
--------
|
975
|
+
circulant : circulant matrix
|
976
|
+
|
977
|
+
Notes
|
978
|
+
-----
|
979
|
+
For a 1-D vector `c` with length `m`, and an array `b`
|
980
|
+
with shape ``(m, ...)``,
|
981
|
+
|
982
|
+
solve_circulant(c, b)
|
983
|
+
|
984
|
+
returns the same result as
|
985
|
+
|
986
|
+
solve(circulant(c), b)
|
987
|
+
|
988
|
+
where `solve` and `circulant` are from `scipy.linalg`.
|
989
|
+
|
990
|
+
.. versionadded:: 0.16.0
|
991
|
+
|
992
|
+
Examples
|
993
|
+
--------
|
994
|
+
>>> import numpy as np
|
995
|
+
>>> from scipy.linalg import solve_circulant, solve, circulant, lstsq
|
996
|
+
|
997
|
+
>>> c = np.array([2, 2, 4])
|
998
|
+
>>> b = np.array([1, 2, 3])
|
999
|
+
>>> solve_circulant(c, b)
|
1000
|
+
array([ 0.75, -0.25, 0.25])
|
1001
|
+
|
1002
|
+
Compare that result to solving the system with `scipy.linalg.solve`:
|
1003
|
+
|
1004
|
+
>>> solve(circulant(c), b)
|
1005
|
+
array([ 0.75, -0.25, 0.25])
|
1006
|
+
|
1007
|
+
A singular example:
|
1008
|
+
|
1009
|
+
>>> c = np.array([1, 1, 0, 0])
|
1010
|
+
>>> b = np.array([1, 2, 3, 4])
|
1011
|
+
|
1012
|
+
Calling ``solve_circulant(c, b)`` will raise a `LinAlgError`. For the
|
1013
|
+
least square solution, use the option ``singular='lstsq'``:
|
1014
|
+
|
1015
|
+
>>> solve_circulant(c, b, singular='lstsq')
|
1016
|
+
array([ 0.25, 1.25, 2.25, 1.25])
|
1017
|
+
|
1018
|
+
Compare to `scipy.linalg.lstsq`:
|
1019
|
+
|
1020
|
+
>>> x, resid, rnk, s = lstsq(circulant(c), b)
|
1021
|
+
>>> x
|
1022
|
+
array([ 0.25, 1.25, 2.25, 1.25])
|
1023
|
+
|
1024
|
+
A broadcasting example:
|
1025
|
+
|
1026
|
+
Suppose we have the vectors of two circulant matrices stored in an array
|
1027
|
+
with shape (2, 5), and three `b` vectors stored in an array with shape
|
1028
|
+
(3, 5). For example,
|
1029
|
+
|
1030
|
+
>>> c = np.array([[1.5, 2, 3, 0, 0], [1, 1, 4, 3, 2]])
|
1031
|
+
>>> b = np.arange(15).reshape(-1, 5)
|
1032
|
+
|
1033
|
+
We want to solve all combinations of circulant matrices and `b` vectors,
|
1034
|
+
with the result stored in an array with shape (2, 3, 5). When we
|
1035
|
+
disregard the axes of `c` and `b` that hold the vectors of coefficients,
|
1036
|
+
the shapes of the collections are (2,) and (3,), respectively, which are
|
1037
|
+
not compatible for broadcasting. To have a broadcast result with shape
|
1038
|
+
(2, 3), we add a trivial dimension to `c`: ``c[:, np.newaxis, :]`` has
|
1039
|
+
shape (2, 1, 5). The last dimension holds the coefficients of the
|
1040
|
+
circulant matrices, so when we call `solve_circulant`, we can use the
|
1041
|
+
default ``caxis=-1``. The coefficients of the `b` vectors are in the last
|
1042
|
+
dimension of the array `b`, so we use ``baxis=-1``. If we use the
|
1043
|
+
default `outaxis`, the result will have shape (5, 2, 3), so we'll use
|
1044
|
+
``outaxis=-1`` to put the solution vectors in the last dimension.
|
1045
|
+
|
1046
|
+
>>> x = solve_circulant(c[:, np.newaxis, :], b, baxis=-1, outaxis=-1)
|
1047
|
+
>>> x.shape
|
1048
|
+
(2, 3, 5)
|
1049
|
+
>>> np.set_printoptions(precision=3) # For compact output of numbers.
|
1050
|
+
>>> x
|
1051
|
+
array([[[-0.118, 0.22 , 1.277, -0.142, 0.302],
|
1052
|
+
[ 0.651, 0.989, 2.046, 0.627, 1.072],
|
1053
|
+
[ 1.42 , 1.758, 2.816, 1.396, 1.841]],
|
1054
|
+
[[ 0.401, 0.304, 0.694, -0.867, 0.377],
|
1055
|
+
[ 0.856, 0.758, 1.149, -0.412, 0.831],
|
1056
|
+
[ 1.31 , 1.213, 1.603, 0.042, 1.286]]])
|
1057
|
+
|
1058
|
+
Check by solving one pair of `c` and `b` vectors (cf. ``x[1, 1, :]``):
|
1059
|
+
|
1060
|
+
>>> solve_circulant(c[1], b[1, :])
|
1061
|
+
array([ 0.856, 0.758, 1.149, -0.412, 0.831])
|
1062
|
+
|
1063
|
+
"""
|
1064
|
+
c = np.atleast_1d(c)
|
1065
|
+
nc = _get_axis_len("c", c, caxis)
|
1066
|
+
b = np.atleast_1d(b)
|
1067
|
+
nb = _get_axis_len("b", b, baxis)
|
1068
|
+
if nc != nb:
|
1069
|
+
raise ValueError(f'Shapes of c {c.shape} and b {b.shape} are incompatible')
|
1070
|
+
|
1071
|
+
# accommodate empty arrays
|
1072
|
+
if b.size == 0:
|
1073
|
+
dt = solve_circulant(np.arange(3, dtype=c.dtype),
|
1074
|
+
np.ones(3, dtype=b.dtype)).dtype
|
1075
|
+
return np.empty_like(b, dtype=dt)
|
1076
|
+
|
1077
|
+
fc = np.fft.fft(np.moveaxis(c, caxis, -1), axis=-1)
|
1078
|
+
abs_fc = np.abs(fc)
|
1079
|
+
if tol is None:
|
1080
|
+
# This is the same tolerance as used in np.linalg.matrix_rank.
|
1081
|
+
tol = abs_fc.max(axis=-1) * nc * np.finfo(np.float64).eps
|
1082
|
+
if tol.shape != ():
|
1083
|
+
tol.shape = tol.shape + (1,)
|
1084
|
+
else:
|
1085
|
+
tol = np.atleast_1d(tol)
|
1086
|
+
|
1087
|
+
near_zeros = abs_fc <= tol
|
1088
|
+
is_near_singular = np.any(near_zeros)
|
1089
|
+
if is_near_singular:
|
1090
|
+
if singular == 'raise':
|
1091
|
+
raise LinAlgError("near singular circulant matrix.")
|
1092
|
+
else:
|
1093
|
+
# Replace the small values with 1 to avoid errors in the
|
1094
|
+
# division fb/fc below.
|
1095
|
+
fc[near_zeros] = 1
|
1096
|
+
|
1097
|
+
fb = np.fft.fft(np.moveaxis(b, baxis, -1), axis=-1)
|
1098
|
+
|
1099
|
+
q = fb / fc
|
1100
|
+
|
1101
|
+
if is_near_singular:
|
1102
|
+
# `near_zeros` is a boolean array, same shape as `c`, that is
|
1103
|
+
# True where `fc` is (near) zero. `q` is the broadcasted result
|
1104
|
+
# of fb / fc, so to set the values of `q` to 0 where `fc` is near
|
1105
|
+
# zero, we use a mask that is the broadcast result of an array
|
1106
|
+
# of True values shaped like `b` with `near_zeros`.
|
1107
|
+
mask = np.ones_like(b, dtype=bool) & near_zeros
|
1108
|
+
q[mask] = 0
|
1109
|
+
|
1110
|
+
x = np.fft.ifft(q, axis=-1)
|
1111
|
+
if not (np.iscomplexobj(c) or np.iscomplexobj(b)):
|
1112
|
+
x = x.real
|
1113
|
+
if outaxis != -1:
|
1114
|
+
x = np.moveaxis(x, -1, outaxis)
|
1115
|
+
return x
|
1116
|
+
|
1117
|
+
|
1118
|
+
# matrix inversion
|
1119
|
+
@_apply_over_batch(('a', 2))
|
1120
|
+
def inv(a, overwrite_a=False, check_finite=True):
|
1121
|
+
"""
|
1122
|
+
Compute the inverse of a matrix.
|
1123
|
+
|
1124
|
+
Parameters
|
1125
|
+
----------
|
1126
|
+
a : array_like
|
1127
|
+
Square matrix to be inverted.
|
1128
|
+
overwrite_a : bool, optional
|
1129
|
+
Discard data in `a` (may improve performance). Default is False.
|
1130
|
+
check_finite : bool, optional
|
1131
|
+
Whether to check that the input matrix contains only finite numbers.
|
1132
|
+
Disabling may give a performance gain, but may result in problems
|
1133
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
1134
|
+
|
1135
|
+
Returns
|
1136
|
+
-------
|
1137
|
+
ainv : ndarray
|
1138
|
+
Inverse of the matrix `a`.
|
1139
|
+
|
1140
|
+
Raises
|
1141
|
+
------
|
1142
|
+
LinAlgError
|
1143
|
+
If `a` is singular.
|
1144
|
+
ValueError
|
1145
|
+
If `a` is not square, or not 2D.
|
1146
|
+
|
1147
|
+
Examples
|
1148
|
+
--------
|
1149
|
+
>>> import numpy as np
|
1150
|
+
>>> from scipy import linalg
|
1151
|
+
>>> a = np.array([[1., 2.], [3., 4.]])
|
1152
|
+
>>> linalg.inv(a)
|
1153
|
+
array([[-2. , 1. ],
|
1154
|
+
[ 1.5, -0.5]])
|
1155
|
+
>>> np.dot(a, linalg.inv(a))
|
1156
|
+
array([[ 1., 0.],
|
1157
|
+
[ 0., 1.]])
|
1158
|
+
|
1159
|
+
"""
|
1160
|
+
a1 = _asarray_validated(a, check_finite=check_finite)
|
1161
|
+
if len(a1.shape) != 2 or a1.shape[0] != a1.shape[1]:
|
1162
|
+
raise ValueError('expected square matrix')
|
1163
|
+
|
1164
|
+
# accommodate empty square matrices
|
1165
|
+
if a1.size == 0:
|
1166
|
+
dt = inv(np.eye(2, dtype=a1.dtype)).dtype
|
1167
|
+
return np.empty_like(a1, dtype=dt)
|
1168
|
+
|
1169
|
+
overwrite_a = overwrite_a or _datacopied(a1, a)
|
1170
|
+
getrf, getri, getri_lwork = get_lapack_funcs(('getrf', 'getri',
|
1171
|
+
'getri_lwork'),
|
1172
|
+
(a1,))
|
1173
|
+
lu, piv, info = getrf(a1, overwrite_a=overwrite_a)
|
1174
|
+
if info == 0:
|
1175
|
+
lwork = _compute_lwork(getri_lwork, a1.shape[0])
|
1176
|
+
|
1177
|
+
# XXX: the following line fixes curious SEGFAULT when
|
1178
|
+
# benchmarking 500x500 matrix inverse. This seems to
|
1179
|
+
# be a bug in LAPACK ?getri routine because if lwork is
|
1180
|
+
# minimal (when using lwork[0] instead of lwork[1]) then
|
1181
|
+
# all tests pass. Further investigation is required if
|
1182
|
+
# more such SEGFAULTs occur.
|
1183
|
+
lwork = int(1.01 * lwork)
|
1184
|
+
inv_a, info = getri(lu, piv, lwork=lwork, overwrite_lu=1)
|
1185
|
+
if info > 0:
|
1186
|
+
raise LinAlgError("singular matrix")
|
1187
|
+
if info < 0:
|
1188
|
+
raise ValueError(
|
1189
|
+
f'illegal value in {-info}-th argument of internal getrf|getri'
|
1190
|
+
)
|
1191
|
+
return inv_a
|
1192
|
+
|
1193
|
+
|
1194
|
+
# Determinant
|
1195
|
+
|
1196
|
+
def det(a, overwrite_a=False, check_finite=True):
|
1197
|
+
"""
|
1198
|
+
Compute the determinant of a matrix
|
1199
|
+
|
1200
|
+
The determinant is a scalar that is a function of the associated square
|
1201
|
+
matrix coefficients. The determinant value is zero for singular matrices.
|
1202
|
+
|
1203
|
+
Parameters
|
1204
|
+
----------
|
1205
|
+
a : (..., M, M) array_like
|
1206
|
+
Input array to compute determinants for.
|
1207
|
+
overwrite_a : bool, optional
|
1208
|
+
Allow overwriting data in a (may enhance performance).
|
1209
|
+
check_finite : bool, optional
|
1210
|
+
Whether to check that the input matrix contains only finite numbers.
|
1211
|
+
Disabling may give a performance gain, but may result in problems
|
1212
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
1213
|
+
|
1214
|
+
Returns
|
1215
|
+
-------
|
1216
|
+
det : (...) float or complex
|
1217
|
+
Determinant of `a`. For stacked arrays, a scalar is returned for each
|
1218
|
+
(m, m) slice in the last two dimensions of the input. For example, an
|
1219
|
+
input of shape (p, q, m, m) will produce a result of shape (p, q). If
|
1220
|
+
all dimensions are 1 a scalar is returned regardless of ndim.
|
1221
|
+
|
1222
|
+
Notes
|
1223
|
+
-----
|
1224
|
+
The determinant is computed by performing an LU factorization of the
|
1225
|
+
input with LAPACK routine 'getrf', and then calculating the product of
|
1226
|
+
diagonal entries of the U factor.
|
1227
|
+
|
1228
|
+
Even if the input array is single precision (float32 or complex64), the
|
1229
|
+
result will be returned in double precision (float64 or complex128) to
|
1230
|
+
prevent overflows.
|
1231
|
+
|
1232
|
+
Examples
|
1233
|
+
--------
|
1234
|
+
>>> import numpy as np
|
1235
|
+
>>> from scipy import linalg
|
1236
|
+
>>> a = np.array([[1,2,3], [4,5,6], [7,8,9]]) # A singular matrix
|
1237
|
+
>>> linalg.det(a)
|
1238
|
+
0.0
|
1239
|
+
>>> b = np.array([[0,2,3], [4,5,6], [7,8,9]])
|
1240
|
+
>>> linalg.det(b)
|
1241
|
+
3.0
|
1242
|
+
>>> # An array with the shape (3, 2, 2, 2)
|
1243
|
+
>>> c = np.array([[[[1., 2.], [3., 4.]],
|
1244
|
+
... [[5., 6.], [7., 8.]]],
|
1245
|
+
... [[[9., 10.], [11., 12.]],
|
1246
|
+
... [[13., 14.], [15., 16.]]],
|
1247
|
+
... [[[17., 18.], [19., 20.]],
|
1248
|
+
... [[21., 22.], [23., 24.]]]])
|
1249
|
+
>>> linalg.det(c) # The resulting shape is (3, 2)
|
1250
|
+
array([[-2., -2.],
|
1251
|
+
[-2., -2.],
|
1252
|
+
[-2., -2.]])
|
1253
|
+
>>> linalg.det(c[0, 0]) # Confirm the (0, 0) slice, [[1, 2], [3, 4]]
|
1254
|
+
-2.0
|
1255
|
+
"""
|
1256
|
+
# The goal is to end up with a writable contiguous array to pass to Cython
|
1257
|
+
|
1258
|
+
# First we check and make arrays.
|
1259
|
+
a1 = np.asarray_chkfinite(a) if check_finite else np.asarray(a)
|
1260
|
+
if a1.ndim < 2:
|
1261
|
+
raise ValueError('The input array must be at least two-dimensional.')
|
1262
|
+
if a1.shape[-1] != a1.shape[-2]:
|
1263
|
+
raise ValueError('Last 2 dimensions of the array must be square'
|
1264
|
+
f' but received shape {a1.shape}.')
|
1265
|
+
|
1266
|
+
# Also check if dtype is LAPACK compatible
|
1267
|
+
if a1.dtype.char not in 'fdFD':
|
1268
|
+
dtype_char = lapack_cast_dict[a1.dtype.char]
|
1269
|
+
if not dtype_char: # No casting possible
|
1270
|
+
raise TypeError(f'The dtype "{a1.dtype.name}" cannot be cast '
|
1271
|
+
'to float(32, 64) or complex(64, 128).')
|
1272
|
+
|
1273
|
+
a1 = a1.astype(dtype_char[0]) # makes a copy, free to scratch
|
1274
|
+
overwrite_a = True
|
1275
|
+
|
1276
|
+
# Empty array has determinant 1 because math.
|
1277
|
+
if min(*a1.shape) == 0:
|
1278
|
+
dtyp = np.float64 if a1.dtype.char not in 'FD' else np.complex128
|
1279
|
+
if a1.ndim == 2:
|
1280
|
+
return dtyp(1.0)
|
1281
|
+
else:
|
1282
|
+
return np.ones(shape=a1.shape[:-2], dtype=dtyp)
|
1283
|
+
|
1284
|
+
# Scalar case
|
1285
|
+
if a1.shape[-2:] == (1, 1):
|
1286
|
+
a1 = a1[..., 0, 0]
|
1287
|
+
if a1.ndim == 0:
|
1288
|
+
a1 = a1[()]
|
1289
|
+
# Convert float32 to float64, and complex64 to complex128.
|
1290
|
+
if a1.dtype.char in 'dD':
|
1291
|
+
return a1
|
1292
|
+
return a1.astype('d') if a1.dtype.char == 'f' else a1.astype('D')
|
1293
|
+
|
1294
|
+
# Then check overwrite permission
|
1295
|
+
if not _datacopied(a1, a): # "a" still alive through "a1"
|
1296
|
+
if not overwrite_a:
|
1297
|
+
# Data belongs to "a" so make a copy
|
1298
|
+
a1 = a1.copy(order='C')
|
1299
|
+
# else: Do nothing we'll use "a" if possible
|
1300
|
+
# else: a1 has its own data thus free to scratch
|
1301
|
+
|
1302
|
+
# Then layout checks, might happen that overwrite is allowed but original
|
1303
|
+
# array was read-only or non-C-contiguous.
|
1304
|
+
if not (a1.flags['C_CONTIGUOUS'] and a1.flags['WRITEABLE']):
|
1305
|
+
a1 = a1.copy(order='C')
|
1306
|
+
|
1307
|
+
if a1.ndim == 2:
|
1308
|
+
det = find_det_from_lu(a1)
|
1309
|
+
# Convert float, complex to NumPy scalars
|
1310
|
+
return (np.float64(det) if np.isrealobj(det) else np.complex128(det))
|
1311
|
+
|
1312
|
+
# loop over the stacked array, and avoid overflows for single precision
|
1313
|
+
# Cf. np.linalg.det(np.diag([1e+38, 1e+38]).astype(np.float32))
|
1314
|
+
dtype_char = a1.dtype.char
|
1315
|
+
if dtype_char in 'fF':
|
1316
|
+
dtype_char = 'd' if dtype_char.islower() else 'D'
|
1317
|
+
|
1318
|
+
det = np.empty(a1.shape[:-2], dtype=dtype_char)
|
1319
|
+
for ind in product(*[range(x) for x in a1.shape[:-2]]):
|
1320
|
+
det[ind] = find_det_from_lu(a1[ind])
|
1321
|
+
return det
|
1322
|
+
|
1323
|
+
|
1324
|
+
# Linear Least Squares
|
1325
|
+
@_apply_over_batch(('a', 2), ('b', '1|2'))
|
1326
|
+
def lstsq(a, b, cond=None, overwrite_a=False, overwrite_b=False,
|
1327
|
+
check_finite=True, lapack_driver=None):
|
1328
|
+
"""
|
1329
|
+
Compute least-squares solution to the equation ``a @ x = b``.
|
1330
|
+
|
1331
|
+
Compute a vector x such that the 2-norm ``|b - A x|`` is minimized.
|
1332
|
+
|
1333
|
+
Parameters
|
1334
|
+
----------
|
1335
|
+
a : (M, N) array_like
|
1336
|
+
Left-hand side array
|
1337
|
+
b : (M,) or (M, K) array_like
|
1338
|
+
Right hand side array
|
1339
|
+
cond : float, optional
|
1340
|
+
Cutoff for 'small' singular values; used to determine effective
|
1341
|
+
rank of a. Singular values smaller than
|
1342
|
+
``cond * largest_singular_value`` are considered zero.
|
1343
|
+
overwrite_a : bool, optional
|
1344
|
+
Discard data in `a` (may enhance performance). Default is False.
|
1345
|
+
overwrite_b : bool, optional
|
1346
|
+
Discard data in `b` (may enhance performance). Default is False.
|
1347
|
+
check_finite : bool, optional
|
1348
|
+
Whether to check that the input matrices contain only finite numbers.
|
1349
|
+
Disabling may give a performance gain, but may result in problems
|
1350
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
1351
|
+
lapack_driver : str, optional
|
1352
|
+
Which LAPACK driver is used to solve the least-squares problem.
|
1353
|
+
Options are ``'gelsd'``, ``'gelsy'``, ``'gelss'``. Default
|
1354
|
+
(``'gelsd'``) is a good choice. However, ``'gelsy'`` can be slightly
|
1355
|
+
faster on many problems. ``'gelss'`` was used historically. It is
|
1356
|
+
generally slow but uses less memory.
|
1357
|
+
|
1358
|
+
.. versionadded:: 0.17.0
|
1359
|
+
|
1360
|
+
Returns
|
1361
|
+
-------
|
1362
|
+
x : (N,) or (N, K) ndarray
|
1363
|
+
Least-squares solution.
|
1364
|
+
residues : (K,) ndarray or float
|
1365
|
+
Square of the 2-norm for each column in ``b - a x``, if ``M > N`` and
|
1366
|
+
``rank(A) == n`` (returns a scalar if ``b`` is 1-D). Otherwise a
|
1367
|
+
(0,)-shaped array is returned.
|
1368
|
+
rank : int
|
1369
|
+
Effective rank of `a`.
|
1370
|
+
s : (min(M, N),) ndarray or None
|
1371
|
+
Singular values of `a`. The condition number of ``a`` is
|
1372
|
+
``s[0] / s[-1]``.
|
1373
|
+
|
1374
|
+
Raises
|
1375
|
+
------
|
1376
|
+
LinAlgError
|
1377
|
+
If computation does not converge.
|
1378
|
+
|
1379
|
+
ValueError
|
1380
|
+
When parameters are not compatible.
|
1381
|
+
|
1382
|
+
See Also
|
1383
|
+
--------
|
1384
|
+
scipy.optimize.nnls : linear least squares with non-negativity constraint
|
1385
|
+
|
1386
|
+
Notes
|
1387
|
+
-----
|
1388
|
+
When ``'gelsy'`` is used as a driver, `residues` is set to a (0,)-shaped
|
1389
|
+
array and `s` is always ``None``.
|
1390
|
+
|
1391
|
+
Examples
|
1392
|
+
--------
|
1393
|
+
>>> import numpy as np
|
1394
|
+
>>> from scipy.linalg import lstsq
|
1395
|
+
>>> import matplotlib.pyplot as plt
|
1396
|
+
|
1397
|
+
Suppose we have the following data:
|
1398
|
+
|
1399
|
+
>>> x = np.array([1, 2.5, 3.5, 4, 5, 7, 8.5])
|
1400
|
+
>>> y = np.array([0.3, 1.1, 1.5, 2.0, 3.2, 6.6, 8.6])
|
1401
|
+
|
1402
|
+
We want to fit a quadratic polynomial of the form ``y = a + b*x**2``
|
1403
|
+
to this data. We first form the "design matrix" M, with a constant
|
1404
|
+
column of 1s and a column containing ``x**2``:
|
1405
|
+
|
1406
|
+
>>> M = x[:, np.newaxis]**[0, 2]
|
1407
|
+
>>> M
|
1408
|
+
array([[ 1. , 1. ],
|
1409
|
+
[ 1. , 6.25],
|
1410
|
+
[ 1. , 12.25],
|
1411
|
+
[ 1. , 16. ],
|
1412
|
+
[ 1. , 25. ],
|
1413
|
+
[ 1. , 49. ],
|
1414
|
+
[ 1. , 72.25]])
|
1415
|
+
|
1416
|
+
We want to find the least-squares solution to ``M.dot(p) = y``,
|
1417
|
+
where ``p`` is a vector with length 2 that holds the parameters
|
1418
|
+
``a`` and ``b``.
|
1419
|
+
|
1420
|
+
>>> p, res, rnk, s = lstsq(M, y)
|
1421
|
+
>>> p
|
1422
|
+
array([ 0.20925829, 0.12013861])
|
1423
|
+
|
1424
|
+
Plot the data and the fitted curve.
|
1425
|
+
|
1426
|
+
>>> plt.plot(x, y, 'o', label='data')
|
1427
|
+
>>> xx = np.linspace(0, 9, 101)
|
1428
|
+
>>> yy = p[0] + p[1]*xx**2
|
1429
|
+
>>> plt.plot(xx, yy, label='least squares fit, $y = a + bx^2$')
|
1430
|
+
>>> plt.xlabel('x')
|
1431
|
+
>>> plt.ylabel('y')
|
1432
|
+
>>> plt.legend(framealpha=1, shadow=True)
|
1433
|
+
>>> plt.grid(alpha=0.25)
|
1434
|
+
>>> plt.show()
|
1435
|
+
|
1436
|
+
"""
|
1437
|
+
a1 = _asarray_validated(a, check_finite=check_finite)
|
1438
|
+
b1 = _asarray_validated(b, check_finite=check_finite)
|
1439
|
+
if len(a1.shape) != 2:
|
1440
|
+
raise ValueError('Input array a should be 2D')
|
1441
|
+
m, n = a1.shape
|
1442
|
+
if len(b1.shape) == 2:
|
1443
|
+
nrhs = b1.shape[1]
|
1444
|
+
else:
|
1445
|
+
nrhs = 1
|
1446
|
+
if m != b1.shape[0]:
|
1447
|
+
raise ValueError('Shape mismatch: a and b should have the same number'
|
1448
|
+
f' of rows ({m} != {b1.shape[0]}).')
|
1449
|
+
if m == 0 or n == 0: # Zero-sized problem, confuses LAPACK
|
1450
|
+
x = np.zeros((n,) + b1.shape[1:], dtype=np.common_type(a1, b1))
|
1451
|
+
if n == 0:
|
1452
|
+
residues = np.linalg.norm(b1, axis=0)**2
|
1453
|
+
else:
|
1454
|
+
residues = np.empty((0,))
|
1455
|
+
return x, residues, 0, np.empty((0,))
|
1456
|
+
|
1457
|
+
driver = lapack_driver
|
1458
|
+
if driver is None:
|
1459
|
+
driver = lstsq.default_lapack_driver
|
1460
|
+
if driver not in ('gelsd', 'gelsy', 'gelss'):
|
1461
|
+
raise ValueError(f'LAPACK driver "{driver}" is not found')
|
1462
|
+
|
1463
|
+
lapack_func, lapack_lwork = get_lapack_funcs((driver,
|
1464
|
+
f'{driver}_lwork'),
|
1465
|
+
(a1, b1))
|
1466
|
+
real_data = True if (lapack_func.dtype.kind == 'f') else False
|
1467
|
+
|
1468
|
+
if m < n:
|
1469
|
+
# need to extend b matrix as it will be filled with
|
1470
|
+
# a larger solution matrix
|
1471
|
+
if len(b1.shape) == 2:
|
1472
|
+
b2 = np.zeros((n, nrhs), dtype=lapack_func.dtype)
|
1473
|
+
b2[:m, :] = b1
|
1474
|
+
else:
|
1475
|
+
b2 = np.zeros(n, dtype=lapack_func.dtype)
|
1476
|
+
b2[:m] = b1
|
1477
|
+
b1 = b2
|
1478
|
+
|
1479
|
+
overwrite_a = overwrite_a or _datacopied(a1, a)
|
1480
|
+
overwrite_b = overwrite_b or _datacopied(b1, b)
|
1481
|
+
|
1482
|
+
if cond is None:
|
1483
|
+
cond = np.finfo(lapack_func.dtype).eps
|
1484
|
+
|
1485
|
+
if driver in ('gelss', 'gelsd'):
|
1486
|
+
if driver == 'gelss':
|
1487
|
+
lwork = _compute_lwork(lapack_lwork, m, n, nrhs, cond)
|
1488
|
+
v, x, s, rank, work, info = lapack_func(a1, b1, cond, lwork,
|
1489
|
+
overwrite_a=overwrite_a,
|
1490
|
+
overwrite_b=overwrite_b)
|
1491
|
+
|
1492
|
+
elif driver == 'gelsd':
|
1493
|
+
if real_data:
|
1494
|
+
lwork, iwork = _compute_lwork(lapack_lwork, m, n, nrhs, cond)
|
1495
|
+
x, s, rank, info = lapack_func(a1, b1, lwork,
|
1496
|
+
iwork, cond, False, False)
|
1497
|
+
else: # complex data
|
1498
|
+
lwork, rwork, iwork = _compute_lwork(lapack_lwork, m, n,
|
1499
|
+
nrhs, cond)
|
1500
|
+
x, s, rank, info = lapack_func(a1, b1, lwork, rwork, iwork,
|
1501
|
+
cond, False, False)
|
1502
|
+
if info > 0:
|
1503
|
+
raise LinAlgError("SVD did not converge in Linear Least Squares")
|
1504
|
+
if info < 0:
|
1505
|
+
raise ValueError(
|
1506
|
+
f'illegal value in {-info}-th argument of internal {lapack_driver}'
|
1507
|
+
)
|
1508
|
+
resids = np.asarray([], dtype=x.dtype)
|
1509
|
+
if m > n:
|
1510
|
+
x1 = x[:n]
|
1511
|
+
if rank == n:
|
1512
|
+
resids = np.sum(np.abs(x[n:])**2, axis=0)
|
1513
|
+
x = x1
|
1514
|
+
return x, resids, rank, s
|
1515
|
+
|
1516
|
+
elif driver == 'gelsy':
|
1517
|
+
lwork = _compute_lwork(lapack_lwork, m, n, nrhs, cond)
|
1518
|
+
jptv = np.zeros((a1.shape[1], 1), dtype=np.int32)
|
1519
|
+
v, x, j, rank, info = lapack_func(a1, b1, jptv, cond,
|
1520
|
+
lwork, False, False)
|
1521
|
+
if info < 0:
|
1522
|
+
raise ValueError(f'illegal value in {-info}-th argument of internal gelsy')
|
1523
|
+
if m > n:
|
1524
|
+
x1 = x[:n]
|
1525
|
+
x = x1
|
1526
|
+
return x, np.array([], x.dtype), rank, None
|
1527
|
+
|
1528
|
+
|
1529
|
+
lstsq.default_lapack_driver = 'gelsd'
|
1530
|
+
|
1531
|
+
|
1532
|
+
@_apply_over_batch(('a', 2))
|
1533
|
+
def pinv(a, *, atol=None, rtol=None, return_rank=False, check_finite=True):
|
1534
|
+
"""
|
1535
|
+
Compute the (Moore-Penrose) pseudo-inverse of a matrix.
|
1536
|
+
|
1537
|
+
Calculate a generalized inverse of a matrix using its
|
1538
|
+
singular-value decomposition ``U @ S @ V`` in the economy mode and picking
|
1539
|
+
up only the columns/rows that are associated with significant singular
|
1540
|
+
values.
|
1541
|
+
|
1542
|
+
If ``s`` is the maximum singular value of ``a``, then the
|
1543
|
+
significance cut-off value is determined by ``atol + rtol * s``. Any
|
1544
|
+
singular value below this value is assumed insignificant.
|
1545
|
+
|
1546
|
+
Parameters
|
1547
|
+
----------
|
1548
|
+
a : (M, N) array_like
|
1549
|
+
Matrix to be pseudo-inverted.
|
1550
|
+
atol : float, optional
|
1551
|
+
Absolute threshold term, default value is 0.
|
1552
|
+
|
1553
|
+
.. versionadded:: 1.7.0
|
1554
|
+
|
1555
|
+
rtol : float, optional
|
1556
|
+
Relative threshold term, default value is ``max(M, N) * eps`` where
|
1557
|
+
``eps`` is the machine precision value of the datatype of ``a``.
|
1558
|
+
|
1559
|
+
.. versionadded:: 1.7.0
|
1560
|
+
|
1561
|
+
return_rank : bool, optional
|
1562
|
+
If True, return the effective rank of the matrix.
|
1563
|
+
check_finite : bool, optional
|
1564
|
+
Whether to check that the input matrix contains only finite numbers.
|
1565
|
+
Disabling may give a performance gain, but may result in problems
|
1566
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
1567
|
+
|
1568
|
+
Returns
|
1569
|
+
-------
|
1570
|
+
B : (N, M) ndarray
|
1571
|
+
The pseudo-inverse of matrix `a`.
|
1572
|
+
rank : int
|
1573
|
+
The effective rank of the matrix. Returned if `return_rank` is True.
|
1574
|
+
|
1575
|
+
Raises
|
1576
|
+
------
|
1577
|
+
LinAlgError
|
1578
|
+
If SVD computation does not converge.
|
1579
|
+
|
1580
|
+
See Also
|
1581
|
+
--------
|
1582
|
+
pinvh : Moore-Penrose pseudoinverse of a hermitian matrix.
|
1583
|
+
|
1584
|
+
Notes
|
1585
|
+
-----
|
1586
|
+
If ``A`` is invertible then the Moore-Penrose pseudoinverse is exactly
|
1587
|
+
the inverse of ``A`` [1]_. If ``A`` is not invertible then the
|
1588
|
+
Moore-Penrose pseudoinverse computes the ``x`` solution to ``Ax = b`` such
|
1589
|
+
that ``||Ax - b||`` is minimized [1]_.
|
1590
|
+
|
1591
|
+
References
|
1592
|
+
----------
|
1593
|
+
.. [1] Penrose, R. (1956). On best approximate solutions of linear matrix
|
1594
|
+
equations. Mathematical Proceedings of the Cambridge Philosophical
|
1595
|
+
Society, 52(1), 17-19. doi:10.1017/S0305004100030929
|
1596
|
+
|
1597
|
+
Examples
|
1598
|
+
--------
|
1599
|
+
|
1600
|
+
Given an ``m x n`` matrix ``A`` and an ``n x m`` matrix ``B`` the four
|
1601
|
+
Moore-Penrose conditions are:
|
1602
|
+
|
1603
|
+
1. ``ABA = A`` (``B`` is a generalized inverse of ``A``),
|
1604
|
+
2. ``BAB = B`` (``A`` is a generalized inverse of ``B``),
|
1605
|
+
3. ``(AB)* = AB`` (``AB`` is hermitian),
|
1606
|
+
4. ``(BA)* = BA`` (``BA`` is hermitian) [1]_.
|
1607
|
+
|
1608
|
+
Here, ``A*`` denotes the conjugate transpose. The Moore-Penrose
|
1609
|
+
pseudoinverse is a unique ``B`` that satisfies all four of these
|
1610
|
+
conditions and exists for any ``A``. Note that, unlike the standard
|
1611
|
+
matrix inverse, ``A`` does not have to be a square matrix or have
|
1612
|
+
linearly independent columns/rows.
|
1613
|
+
|
1614
|
+
As an example, we can calculate the Moore-Penrose pseudoinverse of a
|
1615
|
+
random non-square matrix and verify it satisfies the four conditions.
|
1616
|
+
|
1617
|
+
>>> import numpy as np
|
1618
|
+
>>> from scipy import linalg
|
1619
|
+
>>> rng = np.random.default_rng()
|
1620
|
+
>>> A = rng.standard_normal((9, 6))
|
1621
|
+
>>> B = linalg.pinv(A)
|
1622
|
+
>>> np.allclose(A @ B @ A, A) # Condition 1
|
1623
|
+
True
|
1624
|
+
>>> np.allclose(B @ A @ B, B) # Condition 2
|
1625
|
+
True
|
1626
|
+
>>> np.allclose((A @ B).conj().T, A @ B) # Condition 3
|
1627
|
+
True
|
1628
|
+
>>> np.allclose((B @ A).conj().T, B @ A) # Condition 4
|
1629
|
+
True
|
1630
|
+
|
1631
|
+
"""
|
1632
|
+
a = _asarray_validated(a, check_finite=check_finite)
|
1633
|
+
u, s, vh = _decomp_svd.svd(a, full_matrices=False, check_finite=False)
|
1634
|
+
t = u.dtype.char.lower()
|
1635
|
+
maxS = np.max(s, initial=0.)
|
1636
|
+
|
1637
|
+
atol = 0. if atol is None else atol
|
1638
|
+
rtol = max(a.shape) * np.finfo(t).eps if (rtol is None) else rtol
|
1639
|
+
|
1640
|
+
if (atol < 0.) or (rtol < 0.):
|
1641
|
+
raise ValueError("atol and rtol values must be positive.")
|
1642
|
+
|
1643
|
+
val = atol + maxS * rtol
|
1644
|
+
rank = np.sum(s > val)
|
1645
|
+
|
1646
|
+
u = u[:, :rank]
|
1647
|
+
u /= s[:rank]
|
1648
|
+
B = (u @ vh[:rank]).conj().T
|
1649
|
+
|
1650
|
+
if return_rank:
|
1651
|
+
return B, rank
|
1652
|
+
else:
|
1653
|
+
return B
|
1654
|
+
|
1655
|
+
|
1656
|
+
@_apply_over_batch(('a', 2))
|
1657
|
+
def pinvh(a, atol=None, rtol=None, lower=True, return_rank=False,
|
1658
|
+
check_finite=True):
|
1659
|
+
"""
|
1660
|
+
Compute the (Moore-Penrose) pseudo-inverse of a Hermitian matrix.
|
1661
|
+
|
1662
|
+
Calculate a generalized inverse of a complex Hermitian/real symmetric
|
1663
|
+
matrix using its eigenvalue decomposition and including all eigenvalues
|
1664
|
+
with 'large' absolute value.
|
1665
|
+
|
1666
|
+
Parameters
|
1667
|
+
----------
|
1668
|
+
a : (N, N) array_like
|
1669
|
+
Real symmetric or complex hermetian matrix to be pseudo-inverted
|
1670
|
+
|
1671
|
+
atol : float, optional
|
1672
|
+
Absolute threshold term, default value is 0.
|
1673
|
+
|
1674
|
+
.. versionadded:: 1.7.0
|
1675
|
+
|
1676
|
+
rtol : float, optional
|
1677
|
+
Relative threshold term, default value is ``N * eps`` where
|
1678
|
+
``eps`` is the machine precision value of the datatype of ``a``.
|
1679
|
+
|
1680
|
+
.. versionadded:: 1.7.0
|
1681
|
+
|
1682
|
+
lower : bool, optional
|
1683
|
+
Whether the pertinent array data is taken from the lower or upper
|
1684
|
+
triangle of `a`. (Default: lower)
|
1685
|
+
return_rank : bool, optional
|
1686
|
+
If True, return the effective rank of the matrix.
|
1687
|
+
check_finite : bool, optional
|
1688
|
+
Whether to check that the input matrix contains only finite numbers.
|
1689
|
+
Disabling may give a performance gain, but may result in problems
|
1690
|
+
(crashes, non-termination) if the inputs do contain infinities or NaNs.
|
1691
|
+
|
1692
|
+
Returns
|
1693
|
+
-------
|
1694
|
+
B : (N, N) ndarray
|
1695
|
+
The pseudo-inverse of matrix `a`.
|
1696
|
+
rank : int
|
1697
|
+
The effective rank of the matrix. Returned if `return_rank` is True.
|
1698
|
+
|
1699
|
+
Raises
|
1700
|
+
------
|
1701
|
+
LinAlgError
|
1702
|
+
If eigenvalue algorithm does not converge.
|
1703
|
+
|
1704
|
+
See Also
|
1705
|
+
--------
|
1706
|
+
pinv : Moore-Penrose pseudoinverse of a matrix.
|
1707
|
+
|
1708
|
+
Examples
|
1709
|
+
--------
|
1710
|
+
|
1711
|
+
For a more detailed example see `pinv`.
|
1712
|
+
|
1713
|
+
>>> import numpy as np
|
1714
|
+
>>> from scipy.linalg import pinvh
|
1715
|
+
>>> rng = np.random.default_rng()
|
1716
|
+
>>> a = rng.standard_normal((9, 6))
|
1717
|
+
>>> a = np.dot(a, a.T)
|
1718
|
+
>>> B = pinvh(a)
|
1719
|
+
>>> np.allclose(a, a @ B @ a)
|
1720
|
+
True
|
1721
|
+
>>> np.allclose(B, B @ a @ B)
|
1722
|
+
True
|
1723
|
+
|
1724
|
+
"""
|
1725
|
+
a = _asarray_validated(a, check_finite=check_finite)
|
1726
|
+
s, u = _decomp.eigh(a, lower=lower, check_finite=False, driver='ev')
|
1727
|
+
t = u.dtype.char.lower()
|
1728
|
+
maxS = np.max(np.abs(s), initial=0.)
|
1729
|
+
|
1730
|
+
atol = 0. if atol is None else atol
|
1731
|
+
rtol = max(a.shape) * np.finfo(t).eps if (rtol is None) else rtol
|
1732
|
+
|
1733
|
+
if (atol < 0.) or (rtol < 0.):
|
1734
|
+
raise ValueError("atol and rtol values must be positive.")
|
1735
|
+
|
1736
|
+
val = atol + maxS * rtol
|
1737
|
+
above_cutoff = (abs(s) > val)
|
1738
|
+
|
1739
|
+
psigma_diag = 1.0 / s[above_cutoff]
|
1740
|
+
u = u[:, above_cutoff]
|
1741
|
+
|
1742
|
+
B = (u * psigma_diag) @ u.conj().T
|
1743
|
+
|
1744
|
+
if return_rank:
|
1745
|
+
return B, len(psigma_diag)
|
1746
|
+
else:
|
1747
|
+
return B
|
1748
|
+
|
1749
|
+
|
1750
|
+
@_apply_over_batch(('A', 2))
|
1751
|
+
def matrix_balance(A, permute=True, scale=True, separate=False,
|
1752
|
+
overwrite_a=False):
|
1753
|
+
"""
|
1754
|
+
Compute a diagonal similarity transformation for row/column balancing.
|
1755
|
+
|
1756
|
+
The balancing tries to equalize the row and column 1-norms by applying
|
1757
|
+
a similarity transformation such that the magnitude variation of the
|
1758
|
+
matrix entries is reflected to the scaling matrices.
|
1759
|
+
|
1760
|
+
Moreover, if enabled, the matrix is first permuted to isolate the upper
|
1761
|
+
triangular parts of the matrix and, again if scaling is also enabled,
|
1762
|
+
only the remaining subblocks are subjected to scaling.
|
1763
|
+
|
1764
|
+
Parameters
|
1765
|
+
----------
|
1766
|
+
A : (n, n) array_like
|
1767
|
+
Square data matrix for the balancing.
|
1768
|
+
permute : bool, optional
|
1769
|
+
The selector to define whether permutation of A is also performed
|
1770
|
+
prior to scaling.
|
1771
|
+
scale : bool, optional
|
1772
|
+
The selector to turn on and off the scaling. If False, the matrix
|
1773
|
+
will not be scaled.
|
1774
|
+
separate : bool, optional
|
1775
|
+
This switches from returning a full matrix of the transformation
|
1776
|
+
to a tuple of two separate 1-D permutation and scaling arrays.
|
1777
|
+
overwrite_a : bool, optional
|
1778
|
+
This is passed to xGEBAL directly. Essentially, overwrites the result
|
1779
|
+
to the data. It might increase the space efficiency. See LAPACK manual
|
1780
|
+
for details. This is False by default.
|
1781
|
+
|
1782
|
+
Returns
|
1783
|
+
-------
|
1784
|
+
B : (n, n) ndarray
|
1785
|
+
Balanced matrix
|
1786
|
+
T : (n, n) ndarray
|
1787
|
+
A possibly permuted diagonal matrix whose nonzero entries are
|
1788
|
+
integer powers of 2 to avoid numerical truncation errors.
|
1789
|
+
scale, perm : (n,) ndarray
|
1790
|
+
If ``separate`` keyword is set to True then instead of the array
|
1791
|
+
``T`` above, the scaling and the permutation vectors are given
|
1792
|
+
separately as a tuple without allocating the full array ``T``.
|
1793
|
+
|
1794
|
+
Notes
|
1795
|
+
-----
|
1796
|
+
The balanced matrix satisfies the following equality
|
1797
|
+
|
1798
|
+
.. math::
|
1799
|
+
B = T^{-1} A T
|
1800
|
+
|
1801
|
+
The scaling coefficients are approximated to the nearest power of 2
|
1802
|
+
to avoid round-off errors.
|
1803
|
+
|
1804
|
+
This algorithm is particularly useful for eigenvalue and matrix
|
1805
|
+
decompositions and in many cases it is already called by various
|
1806
|
+
LAPACK routines.
|
1807
|
+
|
1808
|
+
The algorithm is based on the well-known technique of [1]_ and has
|
1809
|
+
been modified to account for special cases. See [2]_ for details
|
1810
|
+
which have been implemented since LAPACK v3.5.0. Before this version
|
1811
|
+
there are corner cases where balancing can actually worsen the
|
1812
|
+
conditioning. See [3]_ for such examples.
|
1813
|
+
|
1814
|
+
The code is a wrapper around LAPACK's xGEBAL routine family for matrix
|
1815
|
+
balancing.
|
1816
|
+
|
1817
|
+
.. versionadded:: 0.19.0
|
1818
|
+
|
1819
|
+
References
|
1820
|
+
----------
|
1821
|
+
.. [1] B.N. Parlett and C. Reinsch, "Balancing a Matrix for
|
1822
|
+
Calculation of Eigenvalues and Eigenvectors", Numerische Mathematik,
|
1823
|
+
Vol.13(4), 1969, :doi:`10.1007/BF02165404`
|
1824
|
+
.. [2] R. James, J. Langou, B.R. Lowery, "On matrix balancing and
|
1825
|
+
eigenvector computation", 2014, :arxiv:`1401.5766`
|
1826
|
+
.. [3] D.S. Watkins. A case where balancing is harmful.
|
1827
|
+
Electron. Trans. Numer. Anal, Vol.23, 2006.
|
1828
|
+
|
1829
|
+
Examples
|
1830
|
+
--------
|
1831
|
+
>>> import numpy as np
|
1832
|
+
>>> from scipy import linalg
|
1833
|
+
>>> x = np.array([[1,2,0], [9,1,0.01], [1,2,10*np.pi]])
|
1834
|
+
|
1835
|
+
>>> y, permscale = linalg.matrix_balance(x)
|
1836
|
+
>>> np.abs(x).sum(axis=0) / np.abs(x).sum(axis=1)
|
1837
|
+
array([ 3.66666667, 0.4995005 , 0.91312162])
|
1838
|
+
|
1839
|
+
>>> np.abs(y).sum(axis=0) / np.abs(y).sum(axis=1)
|
1840
|
+
array([ 1.2 , 1.27041742, 0.92658316]) # may vary
|
1841
|
+
|
1842
|
+
>>> permscale # only powers of 2 (0.5 == 2^(-1))
|
1843
|
+
array([[ 0.5, 0. , 0. ], # may vary
|
1844
|
+
[ 0. , 1. , 0. ],
|
1845
|
+
[ 0. , 0. , 1. ]])
|
1846
|
+
|
1847
|
+
"""
|
1848
|
+
|
1849
|
+
A = np.atleast_2d(_asarray_validated(A, check_finite=True))
|
1850
|
+
|
1851
|
+
if not np.equal(*A.shape):
|
1852
|
+
raise ValueError('The data matrix for balancing should be square.')
|
1853
|
+
|
1854
|
+
# accommodate empty arrays
|
1855
|
+
if A.size == 0:
|
1856
|
+
b_n, t_n = matrix_balance(np.eye(2, dtype=A.dtype))
|
1857
|
+
B = np.empty_like(A, dtype=b_n.dtype)
|
1858
|
+
if separate:
|
1859
|
+
scaling = np.ones_like(A, shape=len(A))
|
1860
|
+
perm = np.arange(len(A))
|
1861
|
+
return B, (scaling, perm)
|
1862
|
+
return B, np.empty_like(A, dtype=t_n.dtype)
|
1863
|
+
|
1864
|
+
gebal = get_lapack_funcs(('gebal'), (A,))
|
1865
|
+
B, lo, hi, ps, info = gebal(A, scale=scale, permute=permute,
|
1866
|
+
overwrite_a=overwrite_a)
|
1867
|
+
|
1868
|
+
if info < 0:
|
1869
|
+
raise ValueError('xGEBAL exited with the internal error '
|
1870
|
+
f'"illegal value in argument number {-info}.". See '
|
1871
|
+
'LAPACK documentation for the xGEBAL error codes.')
|
1872
|
+
|
1873
|
+
# Separate the permutations from the scalings and then convert to int
|
1874
|
+
scaling = np.ones_like(ps, dtype=float)
|
1875
|
+
scaling[lo:hi+1] = ps[lo:hi+1]
|
1876
|
+
|
1877
|
+
# gebal uses 1-indexing
|
1878
|
+
ps = ps.astype(int, copy=False) - 1
|
1879
|
+
n = A.shape[0]
|
1880
|
+
perm = np.arange(n)
|
1881
|
+
|
1882
|
+
# LAPACK permutes with the ordering n --> hi, then 0--> lo
|
1883
|
+
if hi < n:
|
1884
|
+
for ind, x in enumerate(ps[hi+1:][::-1], 1):
|
1885
|
+
if n-ind == x:
|
1886
|
+
continue
|
1887
|
+
perm[[x, n-ind]] = perm[[n-ind, x]]
|
1888
|
+
|
1889
|
+
if lo > 0:
|
1890
|
+
for ind, x in enumerate(ps[:lo]):
|
1891
|
+
if ind == x:
|
1892
|
+
continue
|
1893
|
+
perm[[x, ind]] = perm[[ind, x]]
|
1894
|
+
|
1895
|
+
if separate:
|
1896
|
+
return B, (scaling, perm)
|
1897
|
+
|
1898
|
+
# get the inverse permutation
|
1899
|
+
iperm = np.empty_like(perm)
|
1900
|
+
iperm[perm] = np.arange(n)
|
1901
|
+
|
1902
|
+
return B, np.diag(scaling)[iperm, :]
|
1903
|
+
|
1904
|
+
|
1905
|
+
def _validate_args_for_toeplitz_ops(c_or_cr, b, check_finite, keep_b_shape,
|
1906
|
+
enforce_square=True):
|
1907
|
+
"""Validate arguments and format inputs for toeplitz functions
|
1908
|
+
|
1909
|
+
Parameters
|
1910
|
+
----------
|
1911
|
+
c_or_cr : array_like or tuple of (array_like, array_like)
|
1912
|
+
The vector ``c``, or a tuple of arrays (``c``, ``r``). Whatever the
|
1913
|
+
actual shape of ``c``, it will be converted to a 1-D array. If not
|
1914
|
+
supplied, ``r = conjugate(c)`` is assumed; in this case, if c[0] is
|
1915
|
+
real, the Toeplitz matrix is Hermitian. r[0] is ignored; the first row
|
1916
|
+
of the Toeplitz matrix is ``[c[0], r[1:]]``. Whatever the actual shape
|
1917
|
+
of ``r``, it will be converted to a 1-D array.
|
1918
|
+
b : (M,) or (M, K) array_like
|
1919
|
+
Right-hand side in ``T x = b``.
|
1920
|
+
check_finite : bool
|
1921
|
+
Whether to check that the input matrices contain only finite numbers.
|
1922
|
+
Disabling may give a performance gain, but may result in problems
|
1923
|
+
(result entirely NaNs) if the inputs do contain infinities or NaNs.
|
1924
|
+
keep_b_shape : bool
|
1925
|
+
Whether to convert a (M,) dimensional b into a (M, 1) dimensional
|
1926
|
+
matrix.
|
1927
|
+
enforce_square : bool, optional
|
1928
|
+
If True (default), this verifies that the Toeplitz matrix is square.
|
1929
|
+
|
1930
|
+
Returns
|
1931
|
+
-------
|
1932
|
+
r : array
|
1933
|
+
1d array corresponding to the first row of the Toeplitz matrix.
|
1934
|
+
c: array
|
1935
|
+
1d array corresponding to the first column of the Toeplitz matrix.
|
1936
|
+
b: array
|
1937
|
+
(M,), (M, 1) or (M, K) dimensional array, post validation,
|
1938
|
+
corresponding to ``b``.
|
1939
|
+
dtype: numpy datatype
|
1940
|
+
``dtype`` stores the datatype of ``r``, ``c`` and ``b``. If any of
|
1941
|
+
``r``, ``c`` or ``b`` are complex, ``dtype`` is ``np.complex128``,
|
1942
|
+
otherwise, it is ``np.float``.
|
1943
|
+
b_shape: tuple
|
1944
|
+
Shape of ``b`` after passing it through ``_asarray_validated``.
|
1945
|
+
|
1946
|
+
"""
|
1947
|
+
|
1948
|
+
if isinstance(c_or_cr, tuple):
|
1949
|
+
c, r = c_or_cr
|
1950
|
+
c = _asarray_validated(c, check_finite=check_finite)
|
1951
|
+
r = _asarray_validated(r, check_finite=check_finite)
|
1952
|
+
else:
|
1953
|
+
c = _asarray_validated(c_or_cr, check_finite=check_finite)
|
1954
|
+
r = c.conjugate()
|
1955
|
+
|
1956
|
+
if c.ndim > 1 or r.ndim > 1:
|
1957
|
+
msg = ("Beginning in SciPy 1.17, multidimensional input will be treated as a "
|
1958
|
+
"batch, not `ravel`ed. To preserve the existing behavior and silence "
|
1959
|
+
"this warning, `ravel` arguments before passing them to "
|
1960
|
+
"`toeplitz`, `matmul_toeplitz`, and `solve_toeplitz`.")
|
1961
|
+
warnings.warn(msg, FutureWarning, stacklevel=2)
|
1962
|
+
c = c.ravel()
|
1963
|
+
r = r.ravel()
|
1964
|
+
|
1965
|
+
if b is None:
|
1966
|
+
raise ValueError('`b` must be an array, not None.')
|
1967
|
+
|
1968
|
+
b = _asarray_validated(b, check_finite=check_finite)
|
1969
|
+
b_shape = b.shape
|
1970
|
+
|
1971
|
+
is_not_square = r.shape[0] != c.shape[0]
|
1972
|
+
if (enforce_square and is_not_square) or b.shape[0] != r.shape[0]:
|
1973
|
+
raise ValueError('Incompatible dimensions.')
|
1974
|
+
|
1975
|
+
is_cmplx = np.iscomplexobj(r) or np.iscomplexobj(c) or np.iscomplexobj(b)
|
1976
|
+
dtype = np.complex128 if is_cmplx else np.float64
|
1977
|
+
r, c, b = (np.asarray(i, dtype=dtype) for i in (r, c, b))
|
1978
|
+
|
1979
|
+
if b.ndim == 1 and not keep_b_shape:
|
1980
|
+
b = b.reshape(-1, 1)
|
1981
|
+
elif b.ndim != 1:
|
1982
|
+
b = b.reshape(b.shape[0], -1 if b.size > 0 else 0)
|
1983
|
+
|
1984
|
+
return r, c, b, dtype, b_shape
|
1985
|
+
|
1986
|
+
|
1987
|
+
def matmul_toeplitz(c_or_cr, x, check_finite=False, workers=None):
|
1988
|
+
r"""Efficient Toeplitz Matrix-Matrix Multiplication using FFT
|
1989
|
+
|
1990
|
+
This function returns the matrix multiplication between a Toeplitz
|
1991
|
+
matrix and a dense matrix.
|
1992
|
+
|
1993
|
+
The Toeplitz matrix has constant diagonals, with c as its first column
|
1994
|
+
and r as its first row. If r is not given, ``r == conjugate(c)`` is
|
1995
|
+
assumed.
|
1996
|
+
|
1997
|
+
.. warning::
|
1998
|
+
|
1999
|
+
Beginning in SciPy 1.17, multidimensional input will be treated as a batch,
|
2000
|
+
not ``ravel``\ ed. To preserve the existing behavior, ``ravel`` arguments
|
2001
|
+
before passing them to `matmul_toeplitz`.
|
2002
|
+
|
2003
|
+
Parameters
|
2004
|
+
----------
|
2005
|
+
c_or_cr : array_like or tuple of (array_like, array_like)
|
2006
|
+
The vector ``c``, or a tuple of arrays (``c``, ``r``). If not
|
2007
|
+
supplied, ``r = conjugate(c)`` is assumed; in this case, if c[0] is
|
2008
|
+
real, the Toeplitz matrix is Hermitian. r[0] is ignored; the first row
|
2009
|
+
of the Toeplitz matrix is ``[c[0], r[1:]]``.
|
2010
|
+
x : (M,) or (M, K) array_like
|
2011
|
+
Matrix with which to multiply.
|
2012
|
+
check_finite : bool, optional
|
2013
|
+
Whether to check that the input matrices contain only finite numbers.
|
2014
|
+
Disabling may give a performance gain, but may result in problems
|
2015
|
+
(result entirely NaNs) if the inputs do contain infinities or NaNs.
|
2016
|
+
workers : int, optional
|
2017
|
+
To pass to scipy.fft.fft and ifft. Maximum number of workers to use
|
2018
|
+
for parallel computation. If negative, the value wraps around from
|
2019
|
+
``os.cpu_count()``. See scipy.fft.fft for more details.
|
2020
|
+
|
2021
|
+
Returns
|
2022
|
+
-------
|
2023
|
+
T @ x : (M,) or (M, K) ndarray
|
2024
|
+
The result of the matrix multiplication ``T @ x``. Shape of return
|
2025
|
+
matches shape of `x`.
|
2026
|
+
|
2027
|
+
See Also
|
2028
|
+
--------
|
2029
|
+
toeplitz : Toeplitz matrix
|
2030
|
+
solve_toeplitz : Solve a Toeplitz system using Levinson Recursion
|
2031
|
+
|
2032
|
+
Notes
|
2033
|
+
-----
|
2034
|
+
The Toeplitz matrix is embedded in a circulant matrix and the FFT is used
|
2035
|
+
to efficiently calculate the matrix-matrix product.
|
2036
|
+
|
2037
|
+
Because the computation is based on the FFT, integer inputs will
|
2038
|
+
result in floating point outputs. This is unlike NumPy's `matmul`,
|
2039
|
+
which preserves the data type of the input.
|
2040
|
+
|
2041
|
+
This is partly based on the implementation that can be found in [1]_,
|
2042
|
+
licensed under the MIT license. More information about the method can be
|
2043
|
+
found in reference [2]_. References [3]_ and [4]_ have more reference
|
2044
|
+
implementations in Python.
|
2045
|
+
|
2046
|
+
.. versionadded:: 1.6.0
|
2047
|
+
|
2048
|
+
References
|
2049
|
+
----------
|
2050
|
+
.. [1] Jacob R Gardner, Geoff Pleiss, David Bindel, Kilian
|
2051
|
+
Q Weinberger, Andrew Gordon Wilson, "GPyTorch: Blackbox Matrix-Matrix
|
2052
|
+
Gaussian Process Inference with GPU Acceleration" with contributions
|
2053
|
+
from Max Balandat and Ruihan Wu. Available online:
|
2054
|
+
https://github.com/cornellius-gp/gpytorch
|
2055
|
+
|
2056
|
+
.. [2] J. Demmel, P. Koev, and X. Li, "A Brief Survey of Direct Linear
|
2057
|
+
Solvers". In Z. Bai, J. Demmel, J. Dongarra, A. Ruhe, and H. van der
|
2058
|
+
Vorst, editors. Templates for the Solution of Algebraic Eigenvalue
|
2059
|
+
Problems: A Practical Guide. SIAM, Philadelphia, 2000. Available at:
|
2060
|
+
http://www.netlib.org/utk/people/JackDongarra/etemplates/node384.html
|
2061
|
+
|
2062
|
+
.. [3] R. Scheibler, E. Bezzam, I. Dokmanic, Pyroomacoustics: A Python
|
2063
|
+
package for audio room simulations and array processing algorithms,
|
2064
|
+
Proc. IEEE ICASSP, Calgary, CA, 2018.
|
2065
|
+
https://github.com/LCAV/pyroomacoustics/blob/pypi-release/
|
2066
|
+
pyroomacoustics/adaptive/util.py
|
2067
|
+
|
2068
|
+
.. [4] Marano S, Edwards B, Ferrari G and Fah D (2017), "Fitting
|
2069
|
+
Earthquake Spectra: Colored Noise and Incomplete Data", Bulletin of
|
2070
|
+
the Seismological Society of America., January, 2017. Vol. 107(1),
|
2071
|
+
pp. 276-291.
|
2072
|
+
|
2073
|
+
Examples
|
2074
|
+
--------
|
2075
|
+
Multiply the Toeplitz matrix T with matrix x::
|
2076
|
+
|
2077
|
+
[ 1 -1 -2 -3] [1 10]
|
2078
|
+
T = [ 3 1 -1 -2] x = [2 11]
|
2079
|
+
[ 6 3 1 -1] [2 11]
|
2080
|
+
[10 6 3 1] [5 19]
|
2081
|
+
|
2082
|
+
To specify the Toeplitz matrix, only the first column and the first
|
2083
|
+
row are needed.
|
2084
|
+
|
2085
|
+
>>> import numpy as np
|
2086
|
+
>>> c = np.array([1, 3, 6, 10]) # First column of T
|
2087
|
+
>>> r = np.array([1, -1, -2, -3]) # First row of T
|
2088
|
+
>>> x = np.array([[1, 10], [2, 11], [2, 11], [5, 19]])
|
2089
|
+
|
2090
|
+
>>> from scipy.linalg import toeplitz, matmul_toeplitz
|
2091
|
+
>>> matmul_toeplitz((c, r), x)
|
2092
|
+
array([[-20., -80.],
|
2093
|
+
[ -7., -8.],
|
2094
|
+
[ 9., 85.],
|
2095
|
+
[ 33., 218.]])
|
2096
|
+
|
2097
|
+
Check the result by creating the full Toeplitz matrix and
|
2098
|
+
multiplying it by ``x``.
|
2099
|
+
|
2100
|
+
>>> toeplitz(c, r) @ x
|
2101
|
+
array([[-20, -80],
|
2102
|
+
[ -7, -8],
|
2103
|
+
[ 9, 85],
|
2104
|
+
[ 33, 218]])
|
2105
|
+
|
2106
|
+
The full matrix is never formed explicitly, so this routine
|
2107
|
+
is suitable for very large Toeplitz matrices.
|
2108
|
+
|
2109
|
+
>>> n = 1000000
|
2110
|
+
>>> matmul_toeplitz([1] + [0]*(n-1), np.ones(n))
|
2111
|
+
array([1., 1., 1., ..., 1., 1., 1.], shape=(1000000,))
|
2112
|
+
|
2113
|
+
"""
|
2114
|
+
|
2115
|
+
from ..fft import fft, ifft, rfft, irfft
|
2116
|
+
|
2117
|
+
r, c, x, dtype, x_shape = _validate_args_for_toeplitz_ops(
|
2118
|
+
c_or_cr, x, check_finite, keep_b_shape=False, enforce_square=False)
|
2119
|
+
n, m = x.shape
|
2120
|
+
|
2121
|
+
T_nrows = len(c)
|
2122
|
+
T_ncols = len(r)
|
2123
|
+
p = T_nrows + T_ncols - 1 # equivalent to len(embedded_col)
|
2124
|
+
return_shape = (T_nrows,) if len(x_shape) == 1 else (T_nrows, m)
|
2125
|
+
|
2126
|
+
# accommodate empty arrays
|
2127
|
+
if x.size == 0:
|
2128
|
+
return np.empty_like(x, shape=return_shape)
|
2129
|
+
|
2130
|
+
embedded_col = np.concatenate((c, r[-1:0:-1]))
|
2131
|
+
|
2132
|
+
if np.iscomplexobj(embedded_col) or np.iscomplexobj(x):
|
2133
|
+
fft_mat = fft(embedded_col, axis=0, workers=workers).reshape(-1, 1)
|
2134
|
+
fft_x = fft(x, n=p, axis=0, workers=workers)
|
2135
|
+
|
2136
|
+
mat_times_x = ifft(fft_mat*fft_x, axis=0,
|
2137
|
+
workers=workers)[:T_nrows, :]
|
2138
|
+
else:
|
2139
|
+
# Real inputs; using rfft is faster
|
2140
|
+
fft_mat = rfft(embedded_col, axis=0, workers=workers).reshape(-1, 1)
|
2141
|
+
fft_x = rfft(x, n=p, axis=0, workers=workers)
|
2142
|
+
|
2143
|
+
mat_times_x = irfft(fft_mat*fft_x, axis=0,
|
2144
|
+
workers=workers, n=p)[:T_nrows, :]
|
2145
|
+
|
2146
|
+
return mat_times_x.reshape(*return_shape)
|