为什么eig(A)函数(其中A是一个正半定函数)返回负双精度数? [英] Why does eig(A) function (in which A is a positive semidefinite function) returns negative doubles?
问题描述
如果生成b=randn(10,1)
,则矩阵A=b*b'
必须为正半定矩阵,因此其所有特征值均必须> = 0.
If we generate b=randn(10,1)
, the matrix A=b*b'
must be a positive semi-definite matrix and therefore all its eigenvalues must be >=0.
当我使用eig(A)
函数时,它会返回像-3.6934e-16
和...这样的双精度数(负双精度数).
When I use eig(A)
function, it returns doubles like -3.6934e-16
and ... (negative doubles).
有什么办法可以提高精度?将它们四舍五入为绝对安全吗?
Is there any way to increase the precision? Is it safe to round them to absolute zero?
谢谢.
我删除了不相关的部分.
I removed an irrelevant part.
推荐答案
这只是一个四舍五入的问题,当您有一个向量,其中某些元素比其他元素小16个数量级时,将它们四舍五入是非常安全的在Matlab中为零.
This is just a rounding issue, when you have a vector of which some elements are 16 orders of magnitude smaller than others it is quite safe to just round them to zero in matlab.
这篇关于为什么eig(A)函数(其中A是一个正半定函数)返回负双精度数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!