diff options
author | Pjotr Prins | 2017-10-20 07:52:55 +0000 |
---|---|---|
committer | Pjotr Prins | 2017-10-20 07:52:55 +0000 |
commit | c5de24a7d3928bf5fd45ddcc0daa98f940b83b3c (patch) | |
tree | ce97e05a496c733ed4f65b1a6477642a19608ab5 /src | |
parent | 24a4a5132a07ee6a8717844e3c5862882c88b25a (diff) | |
download | pangemma-c5de24a7d3928bf5fd45ddcc0daa98f940b83b3c.tar.gz |
NaN check only when -debug is used
Diffstat (limited to 'src')
-rw-r--r-- | src/debug.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/debug.cpp b/src/debug.cpp index 4db3daf..6bd834e 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -44,13 +44,13 @@ 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 when NO-CHECKS is not set - (i.e. -no-checks option). + with NaNs. This happens when NO-CHECKS is not set (default) and with + DEBUG (i.e. -debug 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 (is_check_mode()) { + if (is_check_mode() && is_debug_mode()) { gsl_matrix_set_all(m, nan("")); } return m; @@ -60,19 +60,20 @@ gsl_matrix *gsl_matrix_safe_alloc(size_t rows,size_t cols) { Helper function to make sure gsl allocations do their job because gsl_vector_alloc does not initiatize values (behaviour that changed in GSL2) we introduced a 'strict mode' by initializing the buffer - with NaNs. This happens when NO-CHECKS is not set - (i.e. -no-checks option). + with NaNs. This happens when NO-CHECKS is not set and with DEBUG + (i.e. -debug option). */ gsl_vector *gsl_vector_safe_alloc(size_t n) { gsl_vector *v = gsl_vector_alloc(n); enforce_msg(v,"Not enough memory"); // just to be sure when there is no error handler set - if (is_check_mode()) { + if (is_check_mode() && is_debug_mode()) { gsl_vector_set_all(v, nan("")); } return v; } -// Helper function called by macro validate_K(K, check) +// Helper function called by macro validate_K(K, check). K is validated +// unless -no-check option is used. void do_validate_K(const gsl_matrix *K, const char *__file, int __line) { if (is_check_mode()) { // debug_msg("Validating K"); |