From 04509edd4b0966664ee7ad144e92f23d9a714858 Mon Sep 17 00:00:00 2001
From: Kevin <kevin.hoellring@fau.de>
Date: Tue, 26 Nov 2019 08:19:24 +0100
Subject: [PATCH] Make precision of derivative in nabla configurable

---
 include/differential.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/differential.h b/include/differential.h
index d284826..aa6df1b 100644
--- a/include/differential.h
+++ b/include/differential.h
@@ -17,7 +17,8 @@ class ScalarDifferential
 
     Vector<valtype> operator()(Coordinate<argtype> x) const override {
         assert(x.dimension() == input_dimension());
-        return diff.diff(func, x, Vector<valtype>(x.dimension(), h));
+	Vector<valtype> offset(x.dimension(), h);
+        return diff.diff(func, x, offset);
     }
 
     size_t input_dimension() const override { return func.input_dimension(); }
@@ -33,8 +34,9 @@ class ScalarDifferential
 template <typename argtype, typename valtype>
 ScalarDifferential<argtype, valtype>
 nabla(Function<Vector<argtype>, valtype>& func,
-      Differentiator<argtype, valtype>& diff) {
-    return ScalarDifferential<argtype, valtype>(func, diff);
+      Differentiator<argtype, valtype>& diff,
+      argtype h = 1e-8) {
+    return ScalarDifferential<argtype, valtype>(func, diff, h);
 }
 
 }; // namespace numerics
-- 
GitLab