Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2==================================== 

3Linear algebra (:mod:`scipy.linalg`) 

4==================================== 

5 

6.. currentmodule:: scipy.linalg 

7 

8Linear algebra functions. 

9 

10.. eventually, we should replace the numpy.linalg HTML link with just `numpy.linalg` 

11 

12.. seealso:: 

13 

14 `numpy.linalg <https://www.numpy.org/devdocs/reference/routines.linalg.html>`__ 

15 for more linear algebra functions. Note that 

16 although `scipy.linalg` imports most of them, identically named 

17 functions from `scipy.linalg` may offer more or slightly differing 

18 functionality. 

19 

20 

21Basics 

22====== 

23 

24.. autosummary:: 

25 :toctree: generated/ 

26 

27 inv - Find the inverse of a square matrix 

28 solve - Solve a linear system of equations 

29 solve_banded - Solve a banded linear system 

30 solveh_banded - Solve a Hermitian or symmetric banded system 

31 solve_circulant - Solve a circulant system 

32 solve_triangular - Solve a triangular matrix 

33 solve_toeplitz - Solve a toeplitz matrix 

34 det - Find the determinant of a square matrix 

35 norm - Matrix and vector norm 

36 lstsq - Solve a linear least-squares problem 

37 pinv - Pseudo-inverse (Moore-Penrose) using lstsq 

38 pinv2 - Pseudo-inverse using svd 

39 pinvh - Pseudo-inverse of hermitian matrix 

40 kron - Kronecker product of two arrays 

41 khatri_rao - Khatri-Rao product of two arrays 

42 tril - Construct a lower-triangular matrix from a given matrix 

43 triu - Construct an upper-triangular matrix from a given matrix 

44 orthogonal_procrustes - Solve an orthogonal Procrustes problem 

45 matrix_balance - Balance matrix entries with a similarity transformation 

46 subspace_angles - Compute the subspace angles between two matrices 

47 LinAlgError 

48 LinAlgWarning 

49 

50Eigenvalue Problems 

51=================== 

52 

53.. autosummary:: 

54 :toctree: generated/ 

55 

56 eig - Find the eigenvalues and eigenvectors of a square matrix 

57 eigvals - Find just the eigenvalues of a square matrix 

58 eigh - Find the e-vals and e-vectors of a Hermitian or symmetric matrix 

59 eigvalsh - Find just the eigenvalues of a Hermitian or symmetric matrix 

60 eig_banded - Find the eigenvalues and eigenvectors of a banded matrix 

61 eigvals_banded - Find just the eigenvalues of a banded matrix 

62 eigh_tridiagonal - Find the eigenvalues and eigenvectors of a tridiagonal matrix 

63 eigvalsh_tridiagonal - Find just the eigenvalues of a tridiagonal matrix 

64 

65Decompositions 

66============== 

67 

68.. autosummary:: 

69 :toctree: generated/ 

70 

71 lu - LU decomposition of a matrix 

72 lu_factor - LU decomposition returning unordered matrix and pivots 

73 lu_solve - Solve Ax=b using back substitution with output of lu_factor 

74 svd - Singular value decomposition of a matrix 

75 svdvals - Singular values of a matrix 

76 diagsvd - Construct matrix of singular values from output of svd 

77 orth - Construct orthonormal basis for the range of A using svd 

78 null_space - Construct orthonormal basis for the null space of A using svd 

79 ldl - LDL.T decomposition of a Hermitian or a symmetric matrix. 

80 cholesky - Cholesky decomposition of a matrix 

81 cholesky_banded - Cholesky decomp. of a sym. or Hermitian banded matrix 

82 cho_factor - Cholesky decomposition for use in solving a linear system 

83 cho_solve - Solve previously factored linear system 

84 cho_solve_banded - Solve previously factored banded linear system 

85 polar - Compute the polar decomposition. 

86 qr - QR decomposition of a matrix 

87 qr_multiply - QR decomposition and multiplication by Q 

88 qr_update - Rank k QR update 

89 qr_delete - QR downdate on row or column deletion 

90 qr_insert - QR update on row or column insertion 

91 rq - RQ decomposition of a matrix 

92 qz - QZ decomposition of a pair of matrices 

93 ordqz - QZ decomposition of a pair of matrices with reordering 

94 schur - Schur decomposition of a matrix 

95 rsf2csf - Real to complex Schur form 

96 hessenberg - Hessenberg form of a matrix 

97 cdf2rdf - Complex diagonal form to real diagonal block form 

98 cossin - Cosine sine decomposition of a unitary or orthogonal matrix 

99 

100.. seealso:: 

101 

102 `scipy.linalg.interpolative` -- Interpolative matrix decompositions 

103 

104 

105Matrix Functions 

106================ 

107 

108.. autosummary:: 

109 :toctree: generated/ 

110 

111 expm - Matrix exponential 

112 logm - Matrix logarithm 

113 cosm - Matrix cosine 

114 sinm - Matrix sine 

115 tanm - Matrix tangent 

116 coshm - Matrix hyperbolic cosine 

117 sinhm - Matrix hyperbolic sine 

118 tanhm - Matrix hyperbolic tangent 

119 signm - Matrix sign 

120 sqrtm - Matrix square root 

121 funm - Evaluating an arbitrary matrix function 

122 expm_frechet - Frechet derivative of the matrix exponential 

123 expm_cond - Relative condition number of expm in the Frobenius norm 

124 fractional_matrix_power - Fractional matrix power 

125 

126 

127Matrix Equation Solvers 

128======================= 

129 

130.. autosummary:: 

131 :toctree: generated/ 

132 

133 solve_sylvester - Solve the Sylvester matrix equation 

134 solve_continuous_are - Solve the continuous-time algebraic Riccati equation 

135 solve_discrete_are - Solve the discrete-time algebraic Riccati equation 

136 solve_continuous_lyapunov - Solve the continuous-time Lyapunov equation 

137 solve_discrete_lyapunov - Solve the discrete-time Lyapunov equation 

138 

139 

140Sketches and Random Projections 

141=============================== 

142 

143.. autosummary:: 

144 :toctree: generated/ 

145 

146 clarkson_woodruff_transform - Applies the Clarkson Woodruff Sketch (a.k.a CountMin Sketch) 

147 

148Special Matrices 

149================ 

150 

151.. autosummary:: 

152 :toctree: generated/ 

153 

154 block_diag - Construct a block diagonal matrix from submatrices 

155 circulant - Circulant matrix 

156 companion - Companion matrix 

157 convolution_matrix - Convolution matrix 

158 dft - Discrete Fourier transform matrix 

159 fiedler - Fiedler matrix 

160 fiedler_companion - Fiedler companion matrix 

161 hadamard - Hadamard matrix of order 2**n 

162 hankel - Hankel matrix 

163 helmert - Helmert matrix 

164 hilbert - Hilbert matrix 

165 invhilbert - Inverse Hilbert matrix 

166 leslie - Leslie matrix 

167 pascal - Pascal matrix 

168 invpascal - Inverse Pascal matrix 

169 toeplitz - Toeplitz matrix 

170 tri - Construct a matrix filled with ones at and below a given diagonal 

171 

172Low-level routines 

173================== 

174 

175.. autosummary:: 

176 :toctree: generated/ 

177 

178 get_blas_funcs 

179 get_lapack_funcs 

180 find_best_blas_type 

181 

182.. seealso:: 

183 

184 `scipy.linalg.blas` -- Low-level BLAS functions 

185 

186 `scipy.linalg.lapack` -- Low-level LAPACK functions 

187 

188 `scipy.linalg.cython_blas` -- Low-level BLAS functions for Cython 

189 

190 `scipy.linalg.cython_lapack` -- Low-level LAPACK functions for Cython 

191 

192""" # noqa: E501 

193 

194from .misc import * 

195from .basic import * 

196from .decomp import * 

197from .decomp_lu import * 

198from ._decomp_ldl import * 

199from .decomp_cholesky import * 

200from .decomp_qr import * 

201from ._decomp_qz import * 

202from .decomp_svd import * 

203from .decomp_schur import * 

204from ._decomp_polar import * 

205from .matfuncs import * 

206from .blas import * 

207from .lapack import * 

208from .special_matrices import * 

209from ._solvers import * 

210from ._procrustes import * 

211from ._decomp_update import * 

212from ._sketches import * 

213from ._decomp_cossin import * 

214 

215__all__ = [s for s in dir() if not s.startswith('_')] 

216 

217 

218from scipy._lib._testutils import PytestTester 

219test = PytestTester(__name__) 

220del PytestTester