aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2017-08-22 08:33:27 +0000
committerPjotr Prins2017-08-22 08:33:27 +0000
commite6c6ed62b2ef3f428c9646d94d3d011286d02922 (patch)
treea737da763e9014200a97145da5deea682c15cf15
parent99527865c00b74a3a48daa2e1e5eb7c71bd861b5 (diff)
downloadpangemma-e6c6ed62b2ef3f428c9646d94d3d011286d02922.tar.gz
EigenDecomp: also show warning on multiple zero values
-rw-r--r--src/lapack.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lapack.cpp b/src/lapack.cpp
index 5b2fc56..b7c6f74 100644
--- a/src/lapack.cpp
+++ b/src/lapack.cpp
@@ -446,15 +446,25 @@ double EigenDecomp_Zeroed(gsl_matrix *G, gsl_matrix *U, gsl_vector *eval,
const size_t flag_largematrix) {
EigenDecomp(G,U,eval,flag_largematrix);
auto d = 0.0;
+ int count_zero_eigenvalues = 0;
int count_negative_eigenvalues = 0;
for (size_t i = 0; i < eval->size; i++) {
if (std::abs(gsl_vector_get(eval, i)) < EIGEN_MINVALUE)
gsl_vector_set(eval, i, 0.0);
- if (gsl_vector_get(eval,i) < 0.0)
+ // checks
+ if (gsl_vector_get(eval,i) == 0.0)
+ count_zero_eigenvalues += 1;
+ if (gsl_vector_get(eval,i) < 0.0) // count smaller than -EIGEN_MINVALUE
count_negative_eigenvalues += 1;
d += gsl_vector_get(eval, i);
}
d /= (double)eval->size;
+ if (count_zero_eigenvalues > 1) {
+ std::string msg = "Matrix G has ";
+ msg += std::to_string(count_zero_eigenvalues);
+ msg += " eigenvalues close to zero";
+ warning_msg(msg);
+ }
if (count_negative_eigenvalues > 0) {
warning_msg("Matrix G has more than one negative eigenvalues!");
}