diff options
author | Pjotr Prins | 2017-08-20 09:20:06 +0000 |
---|---|---|
committer | Pjotr Prins | 2017-08-20 09:20:06 +0000 |
commit | d564a6f16613985340040cc7ab0ffc371cbce3d1 (patch) | |
tree | f1f66a528d48dcdf0b216322b1910f3c575429a9 /src/debug.h | |
parent | 85797beb24da3d591a79fddcff4ab48d702b465f (diff) | |
download | pangemma-d564a6f16613985340040cc7ab0ffc371cbce3d1.tar.gz |
Added checks for K
Diffstat (limited to 'src/debug.h')
-rw-r--r-- | src/debug.h | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/debug.h b/src/debug.h index 3fbe9e0..82dd245 100644 --- a/src/debug.h +++ b/src/debug.h @@ -4,26 +4,49 @@ #include <assert.h> #include <iostream> -// enforce works like assert but also when NDEBUG is set (i.e., it -// always works). enforce_msg prints message instead of expr +#include "gsl/gsl_matrix.h" + +void gemma_gsl_error_handler (const char * reason, + const char * file, + int line, int gsl_errno); + + +// Validation routines +void do_validate_K(const gsl_matrix *K, bool do_check, const char *__file, int __line); #define ROUND(f) round(f * 10000.)/10000 +#define validate_K(K,check) do_validate_K(K,check,__FILE__,__LINE__) + +#define warning_at_msg(__file,__line,msg) cerr << "**** WARNING: " << msg << " in " << __file << " at line " << __line << endl; + +inline void fail_at_msg(const char *__file, int __line, const char *msg) { + std::cerr << "**** FAIL: " << msg << " in " << __file << " at line " << __line << std::endl; + exit(1); +} #if defined NDEBUG + +#define warning_msg(msg) cerr << "**** WARNING: " << msg << endl; #define debug_msg(msg) #define assert_issue(is_issue, expr) -#else -#define debug_msg(msg) cout << "**** DEBUG: " << msg << endl; + +#else // DEBUG + +#define warning_msg(msg) cerr << "**** WARNING: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __PRETTY_FUNCTION__ << endl; +#define debug_msg(msg) cerr << "**** DEBUG: " << msg << " in " << __FILE__ << " at line " << __LINE__ << " in " << __PRETTY_FUNCTION__ << endl; #define assert_issue(is_issue, expr) \ ((is_issue) ? enforce_msg(expr,"FAIL: ISSUE assert") : __ASSERT_VOID_CAST(0)) #endif +// enforce works like assert but also when NDEBUG is set (i.e., it +// always works). enforce_msg prints message instead of expr + /* This prints an "Assertion failed" message and aborts. */ inline void __enforce_fail(const char *__assertion, const char *__file, unsigned int __line, const char *__function) { - std::cout << "ERROR: Enforce failed for " << __assertion << " in " << __file << " at line " << __line << " in " << __function << std::endl; + std::cout << "ERROR: Enforce failed for " << __assertion << " in " << __file << " at line " << __line << " in " << __PRETTY_FUNCTION__ << std::endl; exit(1); } @@ -54,5 +77,4 @@ inline void __enforce_fail(const char *__assertion, const char *__file, : __enforce_fail(gsl_strerror(COMBINE(res, __LINE__)), __FILE__, \ __LINE__, __ASSERT_FUNCTION)) - #endif |