diff options
author | Pjotr Prins | 2017-10-18 12:36:39 +0000 |
---|---|---|
committer | Pjotr Prins | 2017-10-18 12:36:39 +0000 |
commit | 24a4a5132a07ee6a8717844e3c5862882c88b25a (patch) | |
tree | 00d11c524b256790c8ec1cdcdb9e2da8682bdb69 /src/debug.cpp | |
parent | b3e613a67c2a8cc6c7e910b5120618724392bf7a (diff) | |
download | pangemma-24a4a5132a07ee6a8717844e3c5862882c88b25a.tar.gz |
Tests still pass with safe_alloc (which sets the buffers to NaNs on allocation)
Diffstat (limited to 'src/debug.cpp')
-rw-r--r-- | src/debug.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/debug.cpp b/src/debug.cpp index eb5c041..4db3daf 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -19,7 +19,7 @@ #include "mathfunc.h" static bool debug_mode = false; -static bool debug_check = false; // check data/algorithms +static bool debug_check = true; // check data/algorithms static bool debug_strict = false; // fail on error static bool debug_quiet = false; static uint debug_issue = 0; // github issues @@ -56,6 +56,22 @@ gsl_matrix *gsl_matrix_safe_alloc(size_t rows,size_t cols) { return m; } +/* + 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). +*/ +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()) { + gsl_vector_set_all(v, nan("")); + } + return v; +} + // Helper function called by macro validate_K(K, check) void do_validate_K(const gsl_matrix *K, const char *__file, int __line) { if (is_check_mode()) { |