scipy.linalg.null_space¶
- scipy.linalg.null_space(A, rcond=None)[源代码]¶
利用奇异值分解构造A的零空间的正交正交基
- 参数
- A(M,N)类数组
输入数组
- rcond浮动,可选
相对条件号。奇异值
s
小于rcond * max(s)
被认为是零。默认值:浮点EPS*max(M,N)。
- 退货
- Z(n,K)ndarray
A的零空间的标准正交基K=有效零空间的维数,由rcond确定
示例
一维零空间:
>>> from scipy.linalg import null_space >>> A = np.array([[1, 1], [1, 1]]) >>> ns = null_space(A) >>> ns * np.sign(ns[0,0]) # Remove the sign ambiguity of the vector array([[ 0.70710678], [-0.70710678]])
二维零空间:
>>> from numpy.random import default_rng >>> rng = default_rng() >>> B = rng.random((3, 5)) >>> Z = null_space(B) >>> Z.shape (5, 2) >>> np.allclose(B.dot(Z), 0) True
基向量是正交的(最高可达舍入误差):
>>> Z.T.dot(Z) array([[ 1.00000000e+00, 6.92087741e-17], [ 6.92087741e-17, 1.00000000e+00]])