diff options
author | Pjotr Prins | 2018-08-25 11:32:46 +0000 |
---|---|---|
committer | Pjotr Prins | 2018-08-25 11:32:46 +0000 |
commit | be551a1b3c324dc96750cf992b6a5784e2b92ec7 (patch) | |
tree | 01830a02558f85b33fcb6ce7d54d1daab28ca669 /src/mathfunc.cpp | |
parent | a24297bb1cb686d3630db3a0da8fa8a2079ad178 (diff) | |
download | pangemma-be551a1b3c324dc96750cf992b6a5784e2b92ec7.tar.gz |
Number format checking in strict mode. Also fixes #149
Diffstat (limited to 'src/mathfunc.cpp')
-rw-r--r-- | src/mathfunc.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mathfunc.cpp b/src/mathfunc.cpp index 9076c47..7117700 100644 --- a/src/mathfunc.cpp +++ b/src/mathfunc.cpp @@ -26,6 +26,7 @@ #include <iostream> #include <limits.h> #include <map> +#include <regex> #include <set> #include <sstream> #include <stdio.h> @@ -94,6 +95,14 @@ bool has_inf(const gsl_matrix *m) { return false; } +bool is_integer(const std::string & s){ + return std::regex_match(s, std::regex("^[0-9]+$")); +} + +bool is_float(const std::string & s){ + return std::regex_match(s, std::regex("^[+-]?([0-9]*[.])?[0-9]+$")); +} + // calculate variance of a vector double VectorVar(const gsl_vector *v) { double d, m = 0.0, m2 = 0.0; |