aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArun Isaac2021-05-07 16:40:54 +0530
committerArun Isaac2021-05-07 16:40:54 +0530
commit932efe1a370e7a8c9f6c7a2dd0beddb36fb7a601 (patch)
tree43a96bcc3d5cbf4574c23c2d994abecf49fec370 /src
parentcab381b6b9df7ce06e9b98c47a6da94c93d6b41a (diff)
downloadnsmc-932efe1a370e7a8c9f6c7a2dd0beddb36fb7a601.tar.gz
nsmc-932efe1a370e7a8c9f6c7a2dd0beddb36fb7a601.tar.lz
nsmc-932efe1a370e7a8c9f6c7a2dd0beddb36fb7a601.zip
Add rtol? predicate.
* src/utils.sc (rtol?): New function. * include/utils.h (rtol_p): Declare it.
Diffstat (limited to 'src')
-rw-r--r--src/utils.sc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils.sc b/src/utils.sc
index 20452b0..94b7dcd 100644
--- a/src/utils.sc
+++ b/src/utils.sc
@@ -89,6 +89,11 @@ the range [0,pi]."
exact value EXACT."
(return (fabs (- 1 (/ approx exact)))))
+(define (rtol? approx exact rtol) (int double double double)
+ "Return 1 if the approximate value APPROX is within RTOL relative
+tolerance of the exact value EXACT. Else, return 0."
+ (return (< (rerror approx exact) rtol)))
+
(sc-define-syntax (with-root-fsolver solver solver-type function a b body ...)
(with-alloc solver gsl-root-fsolver*
(gsl-root-fsolver-alloc solver-type)