#### How to find the largest eigenvector of a matrix?

``````vector center;
for(point p in points):
center += p;
center /= points.count;

sumxx = 0;
sumxy = 0;
sumxz = 0;
sumyy = 0;
sumyz = 0;
sumzz = 0;
for(point p in points):
vector s = p - center;
sumxx += s.x * s.x;
sumxy += s.x * s.y;
sumxz += s.x * s.z;
sumyy += s.y * s.y;
sumyz += s.y * s.z;
sumzz += s.z * s.z;

matrix3 mat = invert(matrix3(sumxx, sumxy, sumxz, sumxy, sumyy, sumyz, sumxz, sumyz, sumzz));
vector n;
if (determinant(mat) > 0)
normal = find_largest_eigenvalue
``````
2 个回复

1. 求矩阵`mat`的特征向量
2. 该特征向量应与矩阵的最大特征值相关联
3. 该矩阵是主成分分析的对称协方差矩阵。 特别地，它是对称的。
4. 您的矩阵是3乘3的正方形，如代码中`matrix3 mat = ...`所示，并在（现在已删除）注释中确认。

``````p1 = A(1,2)^2 + A(1,3)^2 + A(2,3)^2
if (p1 == 0)
% A is diagonal.
eig1 = A(1,1)
eig2 = A(2,2)
eig3 = A(3,3)
else
q = (A(1,1) + A(2,2) + A(3,3)) / 3
p2 = (A(1,1) - q)^2 + (A(2,2) - q)^2 + (A(3,3) - q)^2 + 2 * p1
p = sqrt(p2 / 6)
B = (1 / p) * (A - q * I)       % I is the identity matrix
r = determinant(B) / 2

% In exact arithmetic for a symmetric matrix  -1 <= r <= 1
% but computation error can leave it slightly outside this range.
if (r <= -1)
phi = pi / 3
elseif (r >= 1)
phi = 0
else
phi = acos(r) / 3
end

% the eigenvalues satisfy eig3 <= eig2 <= eig1
eig1 = q + 2 * p * cos(phi)
eig3 = q + 2 * p * cos(phi + (2*pi/3))
eig2 = 3 * q - eig1 - eig3     % since trace(A) = eig1 + eig2 + eig3
end
``````

1 从矩阵中找到特征向量

2016-08-28 11:58:17 2 741   c#/ matrix
3 由Python计算的矩阵的特征向量似乎不是特征向量

4 8×8矩阵的特征向量和特征值

5 如何找到具有不同特征值的两个矩阵的公共特征向量

6 Matlab不返回特征向量的正交矩阵

7 非对称矩阵的特征向量

2015-07-24 09:36:32 0 798   opencv
8 稀疏矩阵特征向量的快速计算

9 跟踪1参数矩阵族的特征向量

10 在Java中找到对称矩阵的第二个最小特征向量