__init__.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. """
  2. ====================================
  3. Linear algebra (:mod:`scipy.linalg`)
  4. ====================================
  5. .. currentmodule:: scipy.linalg
  6. Linear algebra functions.
  7. .. seealso::
  8. `numpy.linalg` for more linear algebra functions. Note that
  9. although `scipy.linalg` imports most of them, identically named
  10. functions from `scipy.linalg` may offer more or slightly differing
  11. functionality.
  12. Basics
  13. ======
  14. .. autosummary::
  15. :toctree: generated/
  16. inv - Find the inverse of a square matrix
  17. solve - Solve a linear system of equations
  18. solve_banded - Solve a banded linear system
  19. solveh_banded - Solve a Hermitian or symmetric banded system
  20. solve_circulant - Solve a circulant system
  21. solve_triangular - Solve a triangular matrix
  22. solve_toeplitz - Solve a toeplitz matrix
  23. det - Find the determinant of a square matrix
  24. norm - Matrix and vector norm
  25. lstsq - Solve a linear least-squares problem
  26. pinv - Pseudo-inverse (Moore-Penrose) using lstsq
  27. pinv2 - Pseudo-inverse using svd
  28. pinvh - Pseudo-inverse of hermitian matrix
  29. kron - Kronecker product of two arrays
  30. tril - Construct a lower-triangular matrix from a given matrix
  31. triu - Construct an upper-triangular matrix from a given matrix
  32. orthogonal_procrustes - Solve an orthogonal Procrustes problem
  33. matrix_balance - Balance matrix entries with a similarity transformation
  34. subspace_angles - Compute the subspace angles between two matrices
  35. LinAlgError
  36. LinAlgWarning
  37. Eigenvalue Problems
  38. ===================
  39. .. autosummary::
  40. :toctree: generated/
  41. eig - Find the eigenvalues and eigenvectors of a square matrix
  42. eigvals - Find just the eigenvalues of a square matrix
  43. eigh - Find the e-vals and e-vectors of a Hermitian or symmetric matrix
  44. eigvalsh - Find just the eigenvalues of a Hermitian or symmetric matrix
  45. eig_banded - Find the eigenvalues and eigenvectors of a banded matrix
  46. eigvals_banded - Find just the eigenvalues of a banded matrix
  47. eigh_tridiagonal - Find the eigenvalues and eigenvectors of a tridiagonal matrix
  48. eigvalsh_tridiagonal - Find just the eigenvalues of a tridiagonal matrix
  49. Decompositions
  50. ==============
  51. .. autosummary::
  52. :toctree: generated/
  53. lu - LU decomposition of a matrix
  54. lu_factor - LU decomposition returning unordered matrix and pivots
  55. lu_solve - Solve Ax=b using back substitution with output of lu_factor
  56. svd - Singular value decomposition of a matrix
  57. svdvals - Singular values of a matrix
  58. diagsvd - Construct matrix of singular values from output of svd
  59. orth - Construct orthonormal basis for the range of A using svd
  60. null_space - Construct orthonormal basis for the null space of A using svd
  61. ldl - LDL.T decomposition of a Hermitian or a symmetric matrix.
  62. cholesky - Cholesky decomposition of a matrix
  63. cholesky_banded - Cholesky decomp. of a sym. or Hermitian banded matrix
  64. cho_factor - Cholesky decomposition for use in solving a linear system
  65. cho_solve - Solve previously factored linear system
  66. cho_solve_banded - Solve previously factored banded linear system
  67. polar - Compute the polar decomposition.
  68. qr - QR decomposition of a matrix
  69. qr_multiply - QR decomposition and multiplication by Q
  70. qr_update - Rank k QR update
  71. qr_delete - QR downdate on row or column deletion
  72. qr_insert - QR update on row or column insertion
  73. rq - RQ decomposition of a matrix
  74. qz - QZ decomposition of a pair of matrices
  75. ordqz - QZ decomposition of a pair of matrices with reordering
  76. schur - Schur decomposition of a matrix
  77. rsf2csf - Real to complex Schur form
  78. hessenberg - Hessenberg form of a matrix
  79. cdf2rdf - Complex diagonal form to real diagonal block form
  80. .. seealso::
  81. `scipy.linalg.interpolative` -- Interpolative matrix decompositions
  82. Matrix Functions
  83. ================
  84. .. autosummary::
  85. :toctree: generated/
  86. expm - Matrix exponential
  87. logm - Matrix logarithm
  88. cosm - Matrix cosine
  89. sinm - Matrix sine
  90. tanm - Matrix tangent
  91. coshm - Matrix hyperbolic cosine
  92. sinhm - Matrix hyperbolic sine
  93. tanhm - Matrix hyperbolic tangent
  94. signm - Matrix sign
  95. sqrtm - Matrix square root
  96. funm - Evaluating an arbitrary matrix function
  97. expm_frechet - Frechet derivative of the matrix exponential
  98. expm_cond - Relative condition number of expm in the Frobenius norm
  99. fractional_matrix_power - Fractional matrix power
  100. Matrix Equation Solvers
  101. =======================
  102. .. autosummary::
  103. :toctree: generated/
  104. solve_sylvester - Solve the Sylvester matrix equation
  105. solve_continuous_are - Solve the continuous-time algebraic Riccati equation
  106. solve_discrete_are - Solve the discrete-time algebraic Riccati equation
  107. solve_continuous_lyapunov - Solve the continous-time Lyapunov equation
  108. solve_discrete_lyapunov - Solve the discrete-time Lyapunov equation
  109. Sketches and Random Projections
  110. ===============================
  111. .. autosummary::
  112. :toctree: generated/
  113. clarkson_woodruff_transform - Applies the Clarkson Woodruff Sketch (a.k.a CountMin Sketch)
  114. Special Matrices
  115. ================
  116. .. autosummary::
  117. :toctree: generated/
  118. block_diag - Construct a block diagonal matrix from submatrices
  119. circulant - Circulant matrix
  120. companion - Companion matrix
  121. dft - Discrete Fourier transform matrix
  122. hadamard - Hadamard matrix of order 2**n
  123. hankel - Hankel matrix
  124. helmert - Helmert matrix
  125. hilbert - Hilbert matrix
  126. invhilbert - Inverse Hilbert matrix
  127. leslie - Leslie matrix
  128. pascal - Pascal matrix
  129. invpascal - Inverse Pascal matrix
  130. toeplitz - Toeplitz matrix
  131. tri - Construct a matrix filled with ones at and below a given diagonal
  132. Low-level routines
  133. ==================
  134. .. autosummary::
  135. :toctree: generated/
  136. get_blas_funcs
  137. get_lapack_funcs
  138. find_best_blas_type
  139. .. seealso::
  140. `scipy.linalg.blas` -- Low-level BLAS functions
  141. `scipy.linalg.lapack` -- Low-level LAPACK functions
  142. `scipy.linalg.cython_blas` -- Low-level BLAS functions for Cython
  143. `scipy.linalg.cython_lapack` -- Low-level LAPACK functions for Cython
  144. """ # noqa: E501
  145. from __future__ import division, print_function, absolute_import
  146. from .linalg_version import linalg_version as __version__
  147. from .misc import *
  148. from .basic import *
  149. from .decomp import *
  150. from .decomp_lu import *
  151. from ._decomp_ldl import *
  152. from .decomp_cholesky import *
  153. from .decomp_qr import *
  154. from ._decomp_qz import *
  155. from .decomp_svd import *
  156. from .decomp_schur import *
  157. from ._decomp_polar import *
  158. from .matfuncs import *
  159. from .blas import *
  160. from .lapack import *
  161. from .special_matrices import *
  162. from ._solvers import *
  163. from ._procrustes import *
  164. from ._decomp_update import *
  165. from ._sketches import *
  166. __all__ = [s for s in dir() if not s.startswith('_')]
  167. from numpy.dual import register_func
  168. for k in ['norm', 'inv', 'svd', 'solve', 'det', 'eig', 'eigh', 'eigvals',
  169. 'eigvalsh', 'lstsq', 'cholesky']:
  170. try:
  171. register_func(k, eval(k))
  172. except ValueError:
  173. pass
  174. try:
  175. register_func('pinv', pinv2)
  176. except ValueError:
  177. pass
  178. del k, register_func
  179. from scipy._lib._testutils import PytestTester
  180. test = PytestTester(__name__)
  181. del PytestTester