diff --git a/include/differential.h b/include/differential.h index d2848267fcb5a2e9b40b29c481e413259fb04239..aa6df1bff14180e9d460ac03f6dc10958445da6e 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