diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/debug.cpp | 18 | ||||
-rw-r--r-- | src/debug.h | 7 | ||||
-rw-r--r-- | src/gemma.cpp | 8 |
3 files changed, 22 insertions, 11 deletions
diff --git a/src/debug.cpp b/src/debug.cpp index 9f9f862..529d603 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -216,7 +216,7 @@ int gsl_matrix_safe_memcpy (gsl_matrix *dest, const gsl_matrix *src) { return gsl_matrix_memcpy(dest,src); } -void do_gsl_matrix_safe_free (gsl_matrix *m, const char *__pretty_function, const char *__file, int __line) { +void do_gsl_matrix_safe_free (gsl_matrix *m, const char *__pretty_function, const char *__file, int __line, bool warn_only) { enforce(m); if (is_strict_mode() && is_check_mode() && is_debug_mode()) { bool has_NaN = has_nan(m); @@ -228,10 +228,18 @@ void do_gsl_matrix_safe_free (gsl_matrix *m, const char *__pretty_function, cons msg += "x"; msg += std::to_string(m->size2); msg += ")"; - if (has_Inf) - warnfail_at_msg(is_strict_mode(),__pretty_function,__file,__line,(msg+" contains Infinite on free!").c_str()); - if (has_NaN) - warnfail_at_msg(is_strict_mode(),__pretty_function,__file,__line,(msg+" contains NaN on free!").c_str()); + if (warn_only) { + if (has_Inf) + warning_at_msg(__file,__line,(msg+" contains Infinite on free!").c_str()); + if (has_NaN) + warning_at_msg(__file,__line,(msg+" contains NaN on free!").c_str()); + } + else { + if (has_Inf) + warnfail_at_msg(is_strict_mode(),__pretty_function,__file,__line,(msg+" contains Infinite on free!").c_str()); + if (has_NaN) + warnfail_at_msg(is_strict_mode(),__pretty_function,__file,__line,(msg+" contains NaN on free!").c_str()); + } } } return gsl_matrix_free(m); diff --git a/src/debug.h b/src/debug.h index a665a37..07adbc2 100644 --- a/src/debug.h +++ b/src/debug.h @@ -64,7 +64,8 @@ void write(const gsl_matrix *m, const char *msg = ""); gsl_matrix *gsl_matrix_safe_alloc(size_t rows,size_t cols); int gsl_matrix_safe_memcpy (gsl_matrix *dest, const gsl_matrix *src); void gsl_matrix_safe_free (gsl_matrix *v); -void do_gsl_matrix_safe_free (gsl_matrix *m, const char *__pretty_function, const char *__file, int __line); +void gsl_matrix_warn_free (gsl_matrix *v); +void do_gsl_matrix_safe_free (gsl_matrix *m, const char *__pretty_function, const char *__file, int __line, bool warn_only); double do_gsl_matrix_safe_get (const gsl_matrix * m, const size_t i, const size_t j, const char *__pretty_function, const char *__file, int __line); #define gsl_matrix_safe_get(m,i,j) do_gsl_matrix_safe_get(m, i, j,__SHOW_FUNC,__FILE__,__LINE__); @@ -186,7 +187,9 @@ inline void __enforce_fail(const char *__assertion, const char *__file, ((std::string(__STRING(fn)) + " " + fn + ": " + msg).c_str())); #define gsl_matrix_safe_free(m) \ - do_gsl_matrix_safe_free(m,__SHOW_FUNC,__FILE__,__LINE__); + do_gsl_matrix_safe_free(m,__SHOW_FUNC,__FILE__,__LINE__,false); +#define gsl_matrix_warn_free(m) \ + do_gsl_matrix_safe_free(m,__SHOW_FUNC,__FILE__,__LINE__,true); #define gsl_vector_safe_free(v) \ do_gsl_vector_safe_free(v,__SHOW_FUNC,__FILE__,__LINE__); diff --git a/src/gemma.cpp b/src/gemma.cpp index f928977..c3caa96 100644 --- a/src/gemma.cpp +++ b/src/gemma.cpp @@ -2837,14 +2837,14 @@ void GEMMA::BatchRun(PARAM &cPar) { // release all matrices and vectors gsl_matrix_safe_free(Y); gsl_matrix_safe_free(W); - gsl_matrix_safe_free(B); - gsl_matrix_safe_free(se_B); - gsl_matrix_safe_free(G); + gsl_matrix_warn_free(B); // sometimes unused + gsl_matrix_warn_free(se_B); + gsl_matrix_warn_free(G); gsl_matrix_safe_free(U); gsl_matrix_safe_free(UtW); gsl_matrix_safe_free(UtY); gsl_vector_safe_free(eval); - gsl_vector_safe_free(env); + gsl_vector_free(env); // sometimes unused } // BSLMM |