|
1 | | -# Linear algebra (``numpy.linalg``) |
| 1 | +# 线性代数(``numpy.linalg``) |
2 | 2 |
|
3 | | -The NumPy linear algebra functions rely on BLAS and LAPACK to provide efficient |
4 | | -low level implementations of standard linear algebra algorithms. Those |
5 | | -libraries may be provided by NumPy itself using C versions of a subset of their |
6 | | -reference implementations but, when possible, highly optimized libraries that |
7 | | -take advantage of specialized processor functionality are preferred. Examples |
8 | | -of such libraries are [OpenBLAS](https://www.openblas.net/), MKL (TM), and ATLAS. Because those libraries |
9 | | -are multithreaded and processor dependent, environmental variables and external |
10 | | -packages such as [threadpoolctl](https://github.com/joblib/threadpoolctl) may be needed to control the number of threads |
11 | | -or specify the processor architecture. |
| 3 | +NumPy线性代数函数依赖于BLAS和LAPACK来提供标准线性代数算法的高效低级实现。 |
| 4 | +这些库可以由NumPy本身使用其参考实现子集的C版本提供, |
| 5 | +但如果可能,最好是利用专用处理器功能的高度优化的库。 |
| 6 | +这样的库的例子是[OpenBLAS](https://www.openblas.net/)、MKL(TM)和ATLAS。因为这些库是多线程和处理器相关的, |
| 7 | +所以可能需要环境变量和外部包(如[threadpoolctl](https://github.com/joblib/threadpoolctl))来控制线程数量或指定处理器体系结构。 |
12 | 8 |
|
13 | | -## Matrix and vector products |
| 9 | +## 矩阵和向量积 |
14 | 10 |
|
15 | | -method | description |
| 11 | +方法 | 描述 |
16 | 12 | ---|--- |
17 | | -[dot](https://numpy.org/devdocs/reference/generated/numpy.dot.html#numpy.dot)(a, b[, out]) | Dot product of two arrays. |
18 | | -[linalg.multi_dot](https://numpy.org/devdocs/reference/generated/numpy.linalg.multi_dot.html#numpy.linalg.multi_dot)(arrays) | Compute the dot product of two or more arrays in a single function call, while automatically selecting the fastest evaluation order. |
19 | | -[vdot](https://numpy.org/devdocs/reference/generated/numpy.vdot.html#numpy.vdot)(a, b) | Return the dot product of two vectors. |
20 | | -[inner](https://numpy.org/devdocs/reference/generated/numpy.inner.html#numpy.inner)(a, b) | Inner product of two arrays. |
21 | | -[outer](https://numpy.org/devdocs/reference/generated/numpy.outer.html#numpy.outer)(a, b[, out]) | Compute the outer product of two vectors. |
22 | | -[matmul](https://numpy.org/devdocs/reference/generated/numpy.matmul.html#numpy.matmul)(x1, x2, /[, out, casting, order, …]) | Matrix product of two arrays. |
23 | | -[tensordot](https://numpy.org/devdocs/reference/generated/numpy.tensordot.html#numpy.tensordot)(a, b[, axes]) | Compute tensor dot product along specified axes. |
24 | | -[einsum](https://numpy.org/devdocs/reference/generated/numpy.einsum.html#numpy.einsum)(subscripts, *operands[, out, dtype, …]) | Evaluates the Einstein summation convention on the operands. |
25 | | -[einsum_path](https://numpy.org/devdocs/reference/generated/numpy.einsum_path.html#numpy.einsum_path)(subscripts, *operands[, optimize]) | Evaluates the lowest cost contraction order for an einsum expression by considering the creation of intermediate arrays. |
26 | | -[linalg.matrix_power](https://numpy.org/devdocs/reference/generated/numpy.linalg.matrix_power.html#numpy.linalg.matrix_power)(a, n) | Raise a square matrix to the (integer) power n. |
27 | | -[kron](https://numpy.org/devdocs/reference/generated/numpy.kron.html#numpy.kron)(a, b) | Kronecker product of two arrays. |
28 | | - |
29 | | -## Decompositions |
30 | | - |
31 | | -method | description |
| 13 | +[dot](https://numpy.org/devdocs/reference/generated/numpy.dot.html#numpy.dot)(a, b[, out]) | 两个数组的点积。 |
| 14 | +[linalg.multi_dot](https://numpy.org/devdocs/reference/generated/numpy.linalg.multi_dot.html#numpy.linalg.multi_dot)(arrays) | 在单个函数调用中计算两个或更多数组的点积,同时自动选择最快的求值顺序。 |
| 15 | +[vdot](https://numpy.org/devdocs/reference/generated/numpy.vdot.html#numpy.vdot)(a, b) | 返回两个向量的点积。 |
| 16 | +[inner](https://numpy.org/devdocs/reference/generated/numpy.inner.html#numpy.inner)(a, b) | 两个数组的内积。 |
| 17 | +[outer](https://numpy.org/devdocs/reference/generated/numpy.outer.html#numpy.outer)(a, b[, out]) | 计算两个向量的外积。 |
| 18 | +[matmul](https://numpy.org/devdocs/reference/generated/numpy.matmul.html#numpy.matmul)(x1, x2, /[, out, casting, order, …]) | 两个数组的矩阵乘积。 |
| 19 | +[tensordot](https://numpy.org/devdocs/reference/generated/numpy.tensordot.html#numpy.tensordot)(a, b[, axes]) | 沿指定轴计算张量点积。 |
| 20 | +[einsum](https://numpy.org/devdocs/reference/generated/numpy.einsum.html#numpy.einsum)(subscripts, *operands[, out, dtype, …]) | 计算操作数上的爱因斯坦求和约定。 |
| 21 | +[einsum_path](https://numpy.org/devdocs/reference/generated/numpy.einsum_path.html#numpy.einsum_path)(subscripts, *operands[, optimize]) | 通过考虑中间数组的创建,计算einsum表达式的最低成本压缩顺序。 |
| 22 | +[linalg.matrix_power](https://numpy.org/devdocs/reference/generated/numpy.linalg.matrix_power.html#numpy.linalg.matrix_power)(a, n) | 将方阵提升为(整数)n次方。 |
| 23 | +[kron](https://numpy.org/devdocs/reference/generated/numpy.kron.html#numpy.kron)(a, b) | 两个数组的Kronecker乘积。 |
| 24 | + |
| 25 | +## 分解 |
| 26 | + |
| 27 | +方法 | 描述 |
32 | 28 | ---|--- |
33 | | -[linalg.cholesky](https://numpy.org/devdocs/reference/generated/numpy.linalg.cholesky.html#numpy.linalg.cholesky)(a) | Cholesky decomposition. |
34 | | -[linalg.qr](https://numpy.org/devdocs/reference/generated/numpy.linalg.qr.html#numpy.linalg.qr)(a[, mode]) | Compute the qr factorization of a matrix. |
35 | | -[linalg.svd](https://numpy.org/devdocs/reference/generated/numpy.linalg.svd.html#numpy.linalg.svd)(a[, full_matrices, compute_uv, …]) | Singular Value Decomposition. |
| 29 | +[linalg.cholesky](https://numpy.org/devdocs/reference/generated/numpy.linalg.cholesky.html#numpy.linalg.cholesky)(a) | Cholesky分解 |
| 30 | +[linalg.qr](https://numpy.org/devdocs/reference/generated/numpy.linalg.qr.html#numpy.linalg.qr)(a[, mode]) | 计算矩阵的QR分解。 |
| 31 | +[linalg.svd](https://numpy.org/devdocs/reference/generated/numpy.linalg.svd.html#numpy.linalg.svd)(a[, full_matrices, compute_uv, …]) | 奇异值分解 |
36 | 32 |
|
37 | | -## Matrix eigenvalues |
| 33 | +## 矩阵特征值 |
38 | 34 |
|
39 | | -method | description |
| 35 | +方法 | 描述 |
40 | 36 | ---|--- |
41 | | -[linalg.eig](https://numpy.org/devdocs/reference/generated/numpy.linalg.eig.html#numpy.linalg.eig)(a) | Compute the eigenvalues and right eigenvectors of a square array. |
42 | | -[linalg.eigh](https://numpy.org/devdocs/reference/generated/numpy.linalg.eigh.html#numpy.linalg.eigh)(a[, UPLO]) | Return the eigenvalues and eigenvectors of a complex Hermitian (conjugate symmetric) or a real symmetric matrix. |
43 | | -[linalg.eigvals](https://numpy.org/devdocs/reference/generated/numpy.linalg.eigvals.html#numpy.linalg.eigvals)(a) | Compute the eigenvalues of a general matrix. |
44 | | -[linalg.eigvalsh](https://numpy.org/devdocs/reference/generated/numpy.linalg.eigvalsh.html#numpy.linalg.eigvalsh)(a[, UPLO]) | Compute the eigenvalues of a complex Hermitian or real symmetric matrix. |
| 37 | +[linalg.eig](https://numpy.org/devdocs/reference/generated/numpy.linalg.eig.html#numpy.linalg.eig)(a) | 计算方阵的特征值和右特征向量。 |
| 38 | +[linalg.eigh](https://numpy.org/devdocs/reference/generated/numpy.linalg.eigh.html#numpy.linalg.eigh)(a[, UPLO]) | 返回复数Hermitian(共轭对称)或实对称矩阵的特征值和特征向量。 |
| 39 | +[linalg.eigvals](https://numpy.org/devdocs/reference/generated/numpy.linalg.eigvals.html#numpy.linalg.eigvals)(a) | 计算通用矩阵的特征值。 |
| 40 | +[linalg.eigvalsh](https://numpy.org/devdocs/reference/generated/numpy.linalg.eigvalsh.html#numpy.linalg.eigvalsh)(a[, UPLO]) | 计算复杂的Hermitian或实对称矩阵的特征值。 |
45 | 41 |
|
46 | | -## Norms and other numbers |
| 42 | +## 范数和其他数字 |
47 | 43 |
|
48 | | -method | description |
| 44 | +方法 | 描述 |
49 | 45 | ---|--- |
50 | | -[linalg.norm](https://numpy.org/devdocs/reference/generated/numpy.linalg.norm.html#numpy.linalg.norm)(x[, ord, axis, keepdims]) | Matrix or vector norm. |
51 | | -[linalg.cond](https://numpy.org/devdocs/reference/generated/numpy.linalg.cond.html#numpy.linalg.cond)(x[, p]) | Compute the condition number of a matrix. |
52 | | -[linalg.det](https://numpy.org/devdocs/reference/generated/numpy.linalg.det.html#numpy.linalg.det)(a) | Compute the determinant of an array. |
53 | | -[linalg.matrix_rank](https://numpy.org/devdocs/reference/generated/numpy.linalg.matrix_rank.html#numpy.linalg.matrix_rank)(M[, tol, hermitian]) | Return matrix rank of array using SVD method |
54 | | -[linalg.slogdet](https://numpy.org/devdocs/reference/generated/numpy.linalg.slogdet.html#numpy.linalg.slogdet)(a) | Compute the sign and (natural) logarithm of the determinant of an array. |
55 | | -[trace](https://numpy.org/devdocs/reference/generated/numpy.trace.html#numpy.trace)(a[, offset, axis1, axis2, dtype, out]) | Return the sum along diagonals of the array. |
| 46 | +[linalg.norm](https://numpy.org/devdocs/reference/generated/numpy.linalg.norm.html#numpy.linalg.norm)(x[, ord, axis, keepdims]) | 矩阵或向量范数。 |
| 47 | +[linalg.cond](https://numpy.org/devdocs/reference/generated/numpy.linalg.cond.html#numpy.linalg.cond)(x[, p]) | 计算矩阵的条件数。 |
| 48 | +[linalg.det](https://numpy.org/devdocs/reference/generated/numpy.linalg.det.html#numpy.linalg.det)(a) | 计算数组的行列式。 |
| 49 | +[linalg.matrix_rank](https://numpy.org/devdocs/reference/generated/numpy.linalg.matrix_rank.html#numpy.linalg.matrix_rank)(M[, tol, hermitian]) | 使用SVD方法返回数组的矩阵的rank |
| 50 | +[linalg.slogdet](https://numpy.org/devdocs/reference/generated/numpy.linalg.slogdet.html#numpy.linalg.slogdet)(a) | 计算数组行列式的符号和(自然)对数。 |
| 51 | +[trace](https://numpy.org/devdocs/reference/generated/numpy.trace.html#numpy.trace)(a[, offset, axis1, axis2, dtype, out]) | 返回数组对角线的和。 |
56 | 52 |
|
57 | | -## Solving equations and inverting matrices |
| 53 | +## 解方程和逆矩阵 |
58 | 54 |
|
59 | | -method | description |
| 55 | +方法 | 描述 |
60 | 56 | ---|--- |
61 | | -[linalg.solve](https://numpy.org/devdocs/reference/generated/numpy.linalg.solve.html#numpy.linalg.solve)(a, b) | Solve a linear matrix equation, or system of linear scalar equations. |
62 | | -[linalg.tensorsolve](https://numpy.org/devdocs/reference/generated/numpy.linalg.tensorsolve.html#numpy.linalg.tensorsolve)(a, b[, axes]) | Solve the tensor equation a x = b for x. |
63 | | -[linalg.lstsq](https://numpy.org/devdocs/reference/generated/numpy.linalg.lstsq.html#numpy.linalg.lstsq)(a, b[, rcond]) | Return the least-squares solution to a linear matrix equation. |
64 | | -[linalg.inv](https://numpy.org/devdocs/reference/generated/numpy.linalg.inv.html#numpy.linalg.inv)(a) | Compute the (multiplicative) inverse of a matrix. |
65 | | -[linalg.pinv](https://numpy.org/devdocs/reference/generated/numpy.linalg.pinv.html#numpy.linalg.pinv)(a[, rcond, hermitian]) | Compute the (Moore-Penrose) pseudo-inverse of a matrix. |
66 | | -[linalg.tensorinv](https://numpy.org/devdocs/reference/generated/numpy.linalg.tensorinv.html#numpy.linalg.tensorinv)(a[, ind]) | Compute the ‘inverse’ of an N-dimensional array. |
| 57 | +[linalg.solve](https://numpy.org/devdocs/reference/generated/numpy.linalg.solve.html#numpy.linalg.solve)(a, b) | 求解线性矩阵方程或线性标量方程组。 |
| 58 | +[linalg.tensorsolve](https://numpy.org/devdocs/reference/generated/numpy.linalg.tensorsolve.html#numpy.linalg.tensorsolve)(a, b[, axes]) | 对x求解张量方程a x = b。 |
| 59 | +[linalg.lstsq](https://numpy.org/devdocs/reference/generated/numpy.linalg.lstsq.html#numpy.linalg.lstsq)(a, b[, rcond]) | 返回线性矩阵方程的最小二乘解。 |
| 60 | +[linalg.inv](https://numpy.org/devdocs/reference/generated/numpy.linalg.inv.html#numpy.linalg.inv)(a) | 计算矩阵的(乘法)逆。 |
| 61 | +[linalg.pinv](https://numpy.org/devdocs/reference/generated/numpy.linalg.pinv.html#numpy.linalg.pinv)(a[, rcond, hermitian]) | 计算矩阵的(Moore-Penrose)伪逆。 |
| 62 | +[linalg.tensorinv](https://numpy.org/devdocs/reference/generated/numpy.linalg.tensorinv.html#numpy.linalg.tensorinv)(a[, ind]) | 计算N维数组的“逆”。 |
67 | 63 |
|
68 | | -## Exceptions |
| 64 | +## 例外 |
69 | 65 |
|
70 | | -method | description |
| 66 | +方法 | 描述 |
71 | 67 | ---|--- |
72 | | -[linalg.LinAlgError](https://numpy.org/devdocs/reference/generated/numpy.linalg.LinAlgError.html#numpy.linalg.LinAlgError) | Generic Python-exception-derived object raised by linalg functions. |
73 | | - |
74 | | -## Linear algebra on several matrices at once |
75 | | - |
76 | | -*New in version 1.8.0.* |
77 | | - |
78 | | -Several of the linear algebra routines listed above are able to |
79 | | -compute results for several matrices at once, if they are stacked into |
80 | | -the same array. |
81 | | - |
82 | | -This is indicated in the documentation via input parameter |
83 | | -specifications such as ``a : (..., M, M) array_like``. This means that |
84 | | -if for instance given an input array ``a.shape == (N, M, M)``, it is |
85 | | -interpreted as a “stack” of N matrices, each of size M-by-M. Similar |
86 | | -specification applies to return values, for instance the determinant |
87 | | -has ``det : (...)`` and will in this case return an array of shape |
88 | | -``det(a).shape == (N,)``. This generalizes to linear algebra |
89 | | -operations on higher-dimensional arrays: the last 1 or 2 dimensions of |
90 | | -a multidimensional array are interpreted as vectors or matrices, as |
91 | | -appropriate for each operation. |
| 68 | +[linalg.LinAlgError](https://numpy.org/devdocs/reference/generated/numpy.linalg.LinAlgError.html#numpy.linalg.LinAlgError) | 泛型Python-linalg函数引发的异常派生对象。 |
| 69 | + |
| 70 | +## 一次在多个矩阵上的线性代数 |
| 71 | + |
| 72 | +*1.8.0版中的新功能* |
| 73 | + |
| 74 | +上面列出的几个线性代数例程能够一次计算几个矩阵的结果,如果它们堆叠在同一数组中的话。 |
| 75 | + |
| 76 | +这在文档中通过输入参数规范(如 ``a : (..., M, M) array_like`` )表示。 |
| 77 | +这意味着,例如,如果给定输入数组 ``a.shape == (N, M, M)`` ,则将其解释为N个矩阵的“堆栈”, |
| 78 | +每个矩阵的大小为M×M。类似的规范也适用于返回值, |
| 79 | +例如行列式 ``det : (...)`` 。并且在这种情况下将返回形状 ``det(a).shape == (N,)`` 的数组。 |
| 80 | +这推广到对高维数组的线性代数操作:多维数组的最后1或2维被解释为向量或矩阵,视每个操作而定。 |
0 commit comments