aboutsummaryrefslogtreecommitdiff
path: root/src/debug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug.cpp')
-rw-r--r--src/debug.cpp18
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()) {