From 99527865c00b74a3a48daa2e1e5eb7c71bd861b5 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Tue, 22 Aug 2017 07:56:07 +0000 Subject: Fixes matrix checks - looking saner now - Matrix checks as described in https://github.com/genetics-statistics/GEMMA/issues/72 - introduces -strict switch which will exit on certain conditions - zero small eigenvalues in EigenDecomp_Zeroed which also checks for negative values - commented out float versions of functions in lapack.cpp (pre-removal) - reverted on disabled regression tests (GEMMA shows its previous behaviour now) --- src/mathfunc.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/mathfunc.h') diff --git a/src/mathfunc.h b/src/mathfunc.h index 8a2ea64..6e20b37 100644 --- a/src/mathfunc.h +++ b/src/mathfunc.h @@ -23,6 +23,9 @@ #include "gsl/gsl_matrix.h" #include "gsl/gsl_vector.h" +#define CONDITIONED_MAXRATIO 2e+6 // based on http://mathworld.wolfram.com/ConditionNumber.html +#define EIGEN_MINVALUE 1e-10 + using namespace std; using namespace Eigen; @@ -34,10 +37,12 @@ void CenterMatrix(gsl_matrix *G, const gsl_vector *w); void CenterMatrix(gsl_matrix *G, const gsl_matrix *W); void StandardizeMatrix(gsl_matrix *G); double ScaleMatrix(gsl_matrix *G); +bool has_negative_values_but_one(const gsl_vector *v); +uint count_small_values(const gsl_vector *v, double min); bool isMatrixPositiveDefinite(const gsl_matrix *G); -bool isMatrixIllConditioned(const gsl_matrix *G, double max_ratio=4.0); +bool isMatrixIllConditioned(const gsl_vector *eigenvalues, double max_ratio=CONDITIONED_MAXRATIO); bool isMatrixSymmetric(const gsl_matrix *G); -bool checkMatrixEigen(const gsl_matrix *G, double min=1e-5); +gsl_vector *getEigenValues(const gsl_matrix *G); double SumVector(const gsl_vector *v); double CenterVector(gsl_vector *y); void CenterVector(gsl_vector *y, const gsl_matrix *W); -- cgit v1.2.3