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

Fix differential signature

parent eacc1bb5
Branches
Tags
No related merge requests found
...@@ -7,14 +7,15 @@ ...@@ -7,14 +7,15 @@
namespace numerics { namespace numerics {
template <typename argtype, typename valtype> template <typename argtype, typename valtype>
class ScalarDifferential : public Function<argtype, valtype> { class ScalarDifferential
: public Function<Coordinate<argtype>, Coordinate<valtype>> {
public: public:
ScalarDifferential(Function<Vector<argtype>, valtype>& _func, ScalarDifferential(Function<Vector<argtype>, valtype>& _func,
Differentiator<argtype, valtype>& _diff, Differentiator<argtype, valtype>& _diff,
argtype _h = 1e-8) argtype _h = 1e-8)
: func(_func), diff(_diff), h(_h) {} : func(_func), diff(_diff), h(_h) {}
Vector<valtype> operator()(numerics::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(func, x, Vector<valtype>(x.dimension(), h)); return diff(func, x, Vector<valtype>(x.dimension(), h));
} }
...@@ -30,7 +31,7 @@ class ScalarDifferential : public Function<argtype, valtype> { ...@@ -30,7 +31,7 @@ class ScalarDifferential : public Function<argtype, valtype> {
}; };
template <typename argtype, typename valtype> template <typename argtype, typename valtype>
Function<Vector<argtype>, Vector<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); return ScalarDifferential<argtype, valtype>(func, diff);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment