[eigen] What is the most reliable way to check if a symmetric matrix is positive semi-definite |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: "[eigen] mailing list" <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] What is the most reliable way to check if a symmetric matrix is positive semi-definite
- From: Dale Lukas Peterson <hazelnusse@xxxxxxxxx>
- Date: Tue, 18 Jun 2013 21:09:20 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=UcYk5utKHISbLQwzL2Vyq8TdmEJYLITTCL/BVz8OYNs=; b=iv3w8WM24pm7CpfCy2Oes2ZS/q+xaiPK2RSo2JKGhPqqMr0tPGwUr+i775sEoWDlmn WtfY4puWYAYmUGMrl37r/7cfnqk82e3/S6DuuH27mRq2GcAq10TTU7q/vTaPopLaYyBK sMM5Wbm6tQoiFa1d7YzyoG9GcSWLPXg5eSl/2Qzjg1ENLd65WNvz2LPQpdoij4JaXMl/ bcO74woiXSKSVnSIh9RrSAI3k2sp7Dpyr1Rt0eM/GdG5qSfUnt1Be7jIEg00NxhhG+Mj VoTBAcHjGFhvsOSmuHfeeu4BCaB5iLm7GrI/v4arQpsLGDugcec6tG0/rKV4xi6Tp+jF pt7g==
In some function parameter input validation code, I was using
SelfAdjointEigenSolver to compute eigenvalues and verify all have real
part >= 0 (i.e., the matrix is positive semi-definite). When calling
the function with a Matrix A = B * B.transpose(), my test was failing
with one of the eigenvalues very close to zero but slightly negative
(-7.707116279041277e-17). The check I was dong was like:
evals_A = AselfadjointView<Eigen::Lower>().eigenvalues();
if ((evals_A.real().array() < 0).any())
throw std::invalid_argument("A must be positive semi-definite.");
I can imaging going through each eigenvalue and checking more
carefully and letting things pass if the eigenvalues is within some
tolerance of 0, but I was wondering if perhaps I am doing things in a
bad way.
Does anybody have any recommendations for a robust and clean way to
check for positive-semi-definiteness using Eigen?
Luke
--
“People call me a perfectionist, but I'm not. I'm a rightist. I do
something until it's right, and then I move on to the next thing.”
― James Cameron