diff options
author | Peter Carbonetto | 2017-08-22 10:04:18 -0500 |
---|---|---|
committer | GitHub | 2017-08-22 10:04:18 -0500 |
commit | 2554242d10b9a7b58bd6c7df82a10e747b6cc0eb (patch) | |
tree | ef6a14e0f5d54c97f17aab9e28ddf464754372d7 /src/debug.cpp | |
parent | c7cbd8b2d5a06b7b86733719315f9da1638cb32e (diff) | |
parent | 48da44bf2da05f76008b083923ddf5701b9c029a (diff) | |
download | pangemma-2554242d10b9a7b58bd6c7df82a10e747b6cc0eb.tar.gz |
Merge pull request #76 from genenetwork/merge-checkK
Fixes matrix checks---looking saner now.
Diffstat (limited to 'src/debug.cpp')
-rw-r--r-- | src/debug.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/debug.cpp b/src/debug.cpp index 4e37538..da0d06f 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -19,12 +19,27 @@ #include "mathfunc.h" // Helper function called by macro validate_K(K, check) -void do_validate_K(const gsl_matrix *K, bool do_check, const char *__file, int __line) { +void do_validate_K(const gsl_matrix *K, bool do_check, bool strict, const char *__file, int __line) { if (do_check) { - debug_msg("Validating K"); - if (!checkMatrixEigen(K)) warning_at_msg(__file,__line,"K has small or negative eigenvalues!"); - if (!isMatrixIllConditioned(K)) warning_at_msg(__file,__line,"K is ill conditioned!") if (!isMatrixSymmetric(K)) fail_at_msg(__file,__line,"K is not symmetric!" ); - if (!isMatrixPositiveDefinite(K)) fail_at_msg(__file,__line,"K is not positive definite!"); -; + // debug_msg("Validating K"); + auto eigenvalues = getEigenValues(K); + uint count_small; + if (count_small = count_small_values(eigenvalues,EIGEN_MINVALUE)>1) { + std::string msg = "K has "; + msg += std::to_string(count_small); + msg += " eigenvalues close to zero"; + warning_at_msg(__file,__line,msg); + } + if (!isMatrixIllConditioned(eigenvalues)) + warning_at_msg(__file,__line,"K is ill conditioned!"); + if (!isMatrixSymmetric(K)) + fail_at_msg(strict,__file,__line,"K is not symmetric!" ); + bool negative_values; + if (negative_values = has_negative_values_but_one(eigenvalues)) { + warning_at_msg(__file,__line,"K has more than one negative eigenvalues!"); + } + if (count_small>=0 && negative_values && !isMatrixPositiveDefinite(K)) + fail_at_msg(strict,__file,__line,"K is not positive definite!"); + gsl_vector_free(eigenvalues); } } |