我一直在使用 svd 计算来完成此操作
[U, S, V] = svd(A)
,其中我使用 A 的最后一列作为我的零空间近似值。由于 A 变得非常大,我意识到这会减慢我的计算速度。
对于 null(A),文档似乎表明它无论如何都会执行 SVD。另外,如果 A 满级,则该方法不起作用。 SVD 会先找到最大的奇异值,然后找到下一个,依此类推,而我只需要最小的奇异值。
这似乎是一个很大的瓶颈。非常感谢对此的帮助。
我正在使用 MATLAB。
谢谢。
I have been doing this using an svd computation
[U, S, V] = svd(A)
wherein I use the last column of A as my null space approximation. Since A gets really large, I realized that this is slowing down my computation.
For null(A), the documentation seems to suggest that it does an SVD anyways. Also, it does not work if A is full rank. An SVD proceeds by finding the largest singular value, then the next one and so on whereas I just need the smallest one.
This seems to be a big bottleneck. Will really appreciate help on this.
Am using MATLAB.
Thanks.
发布评论
评论(3)
这篇维基百科文章描述了零空间数值计算的三种方法:减少(高斯消元法),SVD 和 QR 分解。简而言之,(1) 归约“由于存在舍入误差的数值精度问题,不适合零空间的实际计算”,(2) SVD 是“最先进的方法”,但它“通常成本大约与相同大小的矩阵的多次矩阵-矩阵乘法相同”,并且(3)数值稳定性和 QR 分解的成本“介于 SVD 和简化方法之间”。
因此,如果 SVD 太慢,您可以给 QR 分解 一个机会。使用您的符号的算法如下:“
A
是一个4xN
矩阵,其中4。使用
A 的 QR 分解'
,我们可以找到一个矩阵,使得A'*P = Q*R = [Q1 Q2]*R
,其中P
是一个置换矩阵,Q
是NxN
和R
为Nx4
矩阵Q1
为 Nx4,由Q 的前 4 列组成。矩阵
Q2
是Nx(N-4)
并且由的最后
自N-4
列组成。 QA*Q2 = 0
,Q2
的列跨越A
的零空间。”Matlab实现:
[Q, R, P] = qr(A', 'matrix');
矩阵的列Q2 = Q(:, 5:end);
给出A
的零空间。This Wikipedia article describes three methods for the numerical computation of the null space: reduction (Gaussian elimination), SVD, and QR decomposition. In brief, (1) reduction is "not suitable for a practical computation of the null space because of numerical accuracy problems in the presence of rounding errors", (2) SVD is the "state-of-the art approach", but it "generally costs about the same as several matrix-matrix multiplications with matrices of the same size", and (3) the numerical stability and the cost of QR decomposition are "between those of the SVD and the reduction approaches".
So if SVD is too slow, you could give a chance to QR decomposition. The algorithm with your notations is as follows: "
A
is a4xN
matrix with4<N
. Using the QR factorization ofA'
, we can find a matrix such thatA'*P = Q*R = [Q1 Q2]*R
, where whereP
is a permutation matrix,Q
isNxN
andR
isNx4
. MatrixQ1
is Nx4 and consists of the first 4 columns ofQ
. MatrixQ2
isNx(N-4)
and is made up of the lastN-4
columns ofQ
. SinceA*Q2 = 0
, the columns ofQ2
span the null space ofA
."Matlab implementation:
[Q, R, P] = qr(A', 'matrix');
The columns of matrixQ2 = Q(:, 5:end);
give the null space ofA
.这个答案建立在您的评论之上,即您真正想做的是解决
Ax = 0
。为此,完整的零空间计算通常效率较低。如果您想要x
的最小二乘近似,请查看 matlab 运算符\
(请参阅help mldivide
)。在其他情况下,通过 svd(A,0) 的“经济”SVD 可能对非方阵有帮助(它不计算完整的 S,而只计算非零块)。
This answers builds on your comment that what you actually want to do is to solve
Ax = 0
. For this purpose, a complete nullspace computation is usually inefficient. If you want a least-squares approximation tox
, have a look into the matlab operator\
(seehelp mldivide
).In other cases, an "economic" SVD via
svd(A,0)
might be helpful for non-square matrices (it does not compute the full S, but only the non-zero block).如果所有点都来自一个平面,则仅使用样本调用 SVD。
If all points are from a plane, call SVD with just a sample.