当我试图在Matlab中找到一个具有重复特征值但没有缺陷的矩阵的特征分解时,它并不是返回一个特征向量的正交矩阵。例如:
k = 5;
repeats = 1;
% First generate a random matrix of eignevectors that is orthonormal
V = orth(rand(k));
% Now generate a vector of eigenvalues with the given number of repeats
D = rand(k,1);
for i = 1:repeats
% Put one random valu
我用numpy计算矩阵的特征向量,得到了一些奇怪的结果。然后我决定使用Matlab,一切都很好。
L = np.array(([2,-1,-1],[-1,2,-1],[-1,-1,2]))
Lam,U = np.linalg.eig(L) #compute eigenvalues and vectors
#sort by ascending eigenvalues
I = [i[0] for i in sorted(zip(xrange(len(Lam)),Lam),key=lambda x: x[1])]
Lam = Lam[I]
U = U[:,I]
print U.dot(U.T)
这应该很容易,但我一直在试图找到一个简单的解释,我可以理解。我有一个对象,我想用OpenGL表示为圆锥体。该对象具有x、y、z坐标和速度矢量vx、vy和vz。锥应该指向速度矢量的方向。
因此,我认为我的PyOpenGL代码应该如下所示:
glPushMatrix()
glTranslate(x, y, z)
glPushMatrix()
# do some sort of rotation here #
glutSolidCone(base, height, slices, stacks)
glPopMatrix()
glPopMatrix()
那么,到目前为止,这是正确的吗?我要用什么来
我正在使用特征库()通过奇异值分解函数进行零空间计算。我将输出与matlab中的"Null“函数进行了比较,得到了不同的结果。使用调试器单步执行,并查看由Eigen创建的V矩阵与matlab中的V矩阵,发现有一个奇怪的差异。
V矩阵中的左奇异向量(以下示例中的左3列)几乎相同,但符号互换。右侧的奇异向量(空空间;右下方的3列)根本不是很相似。
你知道这是什么原因吗?我是否错误地使用了SVD函数?代码和示例结果如下。
代码如下:"input“是一个普通的C++数组:
/* Create a matrix with the nessecary size */
MatrixXf A(
给出了3列2行的数据矩阵,由协方差矩阵计算特征向量和特征值。
我试图解释结果,但我无法理解如何解释它们。
创建一个2x3矩阵:
# Create a 2x3 matrix
data = np.around(np.random.uniform(size=(2,3)) * 100)
数据如下:
[
[ 4., 65., 77.],
[68., 12., 89.]
]
# Here each row represents one data point
# and columns represent the features in the data set