Skip to content
Snippets Groups Projects
Commit 04509edd authored by Kevin Höllring's avatar Kevin Höllring
Browse files

Make precision of derivative in nabla configurable

parent 566b46ad
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,8 @@ class ScalarDifferential ...@@ -17,7 +17,8 @@ class ScalarDifferential
Vector<valtype> operator()(Coordinate<argtype> x) const override { Vector<valtype> operator()(Coordinate<argtype> x) const override {
assert(x.dimension() == input_dimension()); 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(); } size_t input_dimension() const override { return func.input_dimension(); }
...@@ -33,8 +34,9 @@ class ScalarDifferential ...@@ -33,8 +34,9 @@ class ScalarDifferential
template <typename argtype, typename valtype> template <typename argtype, typename valtype>
ScalarDifferential<argtype, valtype> ScalarDifferential<argtype, valtype>
nabla(Function<Vector<argtype>, valtype>& func, nabla(Function<Vector<argtype>, valtype>& func,
Differentiator<argtype, valtype>& diff) { Differentiator<argtype, valtype>& diff,
return ScalarDifferential<argtype, valtype>(func, diff); argtype h = 1e-8) {
return ScalarDifferential<argtype, valtype>(func, diff, h);
} }
}; // namespace numerics }; // namespace numerics
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment