转自:
https://my.oschina.net/duluo180/blog/736587
总得来说,SVD eig 得到的特征值/奇异值是一样的,eig排列是降序,svd排列是升序;
SVD的右奇异向量是A'*A的特征向量
SVD的左奇异向量是A*A'的特征向量
另外,SVD可以用于非方阵的分解,而eig只能用于方阵的分解
Note that eigenvectors are not unique. Multiplying by any constant, including -1 (which simply changes the sign), gives another valid eigenvector. This is clear given the definition of an eigenvector:
A·v = λ·vMATLAB chooses to normalize the eigenvectors to have a norm of 1.0, the sign is arbitrary:
For eig(A), the eigenvectors are scaled so that the norm of each is 1.0. For eig(A,B), eig(A,'nobalance'), and eig(A,B,flag), the eigenvectors are not normalized
Now as you know, SVD and eigendecomposition are related. Below is some code to test this fact. Note that svd and eig return results in different order (one sorted high to low, the other in reverse):
% some random matrixA = rand(5);% singular value decomposition[U,S,V] = svd(A); % 得到的奇异值是升序% eigenvectors of A'*A are the same as the right-singular vectors% A'*A 的特征向量 是A的右奇异向量[V2,D2] = eig(A'*A); % 得到的特征值是降序[D2,ord] = sort(diag(D2), 'descend');S2 = diag(sqrt(D2));V2 = V2(:,ord);% eigenvectors of A*A' are the same as the left-singular vectors% A*A' 的特征向量 是A的左奇异向量[U2,D2] = eig(A*A');[D2,ord] = sort(diag(D2), 'descend');S3 = diag(sqrt(D2));U2 = U2(:,ord);% check resultsAU*S*V'U2*S2*V2'I get very similar results (ignoring minor floating-point errors):
>> norm(A - U*S*V')ans = 7.5771e-16>> norm(A - U2*S2*V2')ans = 3.2841e-14EDIT:
To get consistent results, one usually adopts a convention of requiring that the first element in each eigenvector be of a certain sign. That way if you get an eigenvector that does not follow this rule, you multiply it by -1 to flip the sign...
You can reconstruct A from its eigenvectors only if A is normal (A'*A==A*A'). You can reconstruct A from its singular vectors for any matrix A.