aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-05-25 17:50:51 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:28 +0100
commit2c2bb0426ceff2ddc9284b506102b967d768dadf (patch)
tree0f9fc7380c0cf1555b63a535a564e0d3caba0c7b /src/utils.h
parent54fee1620387697a5624d9573f541bf0c081ae11 (diff)
PR gradient check
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
index 4433023f..a11cd59e 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -140,6 +140,13 @@ static inline double angle_between(double x1, double y1, double z1,
return acos(cosine);
}
+static inline int within_tolerance(double a, double b, double percent)
+{
+ double tol = a * (percent/100.0);
+ if ( fabs(b-a) < fabs(tol) ) return 1;
+ return 0;
+}
+
/* ----------------------------- Useful macros ------------------------------ */