diff options
author | Pjotr Prins | 2017-10-13 15:23:00 +0000 |
---|---|---|
committer | Pjotr Prins | 2017-10-13 15:27:24 +0000 |
commit | fdb48997ee3ed2b326a92f8e0cc7f72a4b38d8c8 (patch) | |
tree | 5f62e06dbacdec2d4ee60da9112508615d42fc1f /src/debug.cpp | |
parent | 7eca3c49b7790007a4190b73209cab9ffb2bb117 (diff) | |
download | pangemma-fdb48997ee3ed2b326a92f8e0cc7f72a4b38d8c8.tar.gz |
Refactored debug settings
Replaced eigenlib_dgemm with fast_dgemm - 10-30% speed gain for GEMMA
Diffstat (limited to 'src/debug.cpp')
-rw-r--r-- | src/debug.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/debug.cpp b/src/debug.cpp index dacb89d..eb5c041 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -19,36 +19,46 @@ #include "mathfunc.h" static bool debug_mode = false; -static bool debug_no_check = false; -static bool debug_strict = false; +static bool debug_check = false; // check data/algorithms +static bool debug_strict = false; // fail on error +static bool debug_quiet = false; +static uint debug_issue = 0; // github issues +static bool debug_legacy = false; // legacy mode void debug_set_debug_mode(bool setting) { debug_mode = setting; } -void debug_set_no_check_mode(bool setting) {debug_no_check = setting; } +void debug_set_no_check_mode(bool setting) {debug_check = !setting; } void debug_set_strict_mode(bool setting) { debug_strict = setting; } +void debug_set_quiet_mode(bool setting) { debug_quiet = setting; } +void debug_set_issue(uint issue) { debug_issue = issue; } +void debug_set_legacy_mode(bool setting) { debug_legacy = setting; } bool is_debug_mode() { return debug_mode; }; -bool is_no_check_mode() { return debug_no_check; }; +bool is_no_check_mode() { return !debug_check; }; +bool is_check_mode() { return debug_check; }; bool is_strict_mode() { return debug_strict; }; +bool is_quiet_mode() { return debug_quiet; }; +bool is_issue(uint issue) { return issue == debug_issue; }; +bool is_legacy_mode() { return debug_legacy; }; /* Helper function to make sure gsl allocations do their job because gsl_matrix_alloc does not initiatize values (behaviour that changed in GSL2) we introduced a 'strict mode' by initializing the buffer - with NaNs. This happens in STRICT mode without NO-CHECKS - (i.e. -strict option). + with NaNs. This happens when NO-CHECKS is not set + (i.e. -no-checks option). */ gsl_matrix *gsl_matrix_safe_alloc(size_t rows,size_t cols) { gsl_matrix *m = gsl_matrix_alloc(rows,cols); enforce_msg(m,"Not enough memory"); // just to be sure when there is no error handler set - if (debug_strict && !debug_no_check) { + if (is_check_mode()) { gsl_matrix_set_all(m, nan("")); } return m; } // Helper function called by macro validate_K(K, check) -void do_validate_K(const gsl_matrix *K, bool do_check, bool strict, const char *__file, int __line) { - if (do_check) { +void do_validate_K(const gsl_matrix *K, const char *__file, int __line) { + if (is_check_mode()) { // debug_msg("Validating K"); auto eigenvalues = getEigenValues(K); const uint count_small = count_small_values(eigenvalues,EIGEN_MINVALUE); @@ -61,13 +71,13 @@ void do_validate_K(const gsl_matrix *K, bool do_check, bool strict, const char * 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!" ); + fail_at_msg(is_strict_mode(),__file,__line,"K is not symmetric!" ); const bool negative_values = has_negative_values_but_one(eigenvalues); if (negative_values) { warning_at_msg(__file,__line,"K has more than one negative eigenvalues!"); } if (count_small>1 && negative_values && !isMatrixPositiveDefinite(K)) - fail_at_msg(strict,__file,__line,"K is not positive definite!"); + fail_at_msg(is_strict_mode(),__file,__line,"K is not positive definite!"); gsl_vector_free(eigenvalues); } } |