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