From 87be19de4aec6f0f04ff3a5f0304ca999cecbd13 Mon Sep 17 00:00:00 2001 From: Thomas Capricelli Date: Mon, 28 Sep 2009 02:55:30 +0200 Subject: central sheme for numerical diff --- unsupported/test/NumericalDiff.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'unsupported/test/NumericalDiff.cpp') diff --git a/unsupported/test/NumericalDiff.cpp b/unsupported/test/NumericalDiff.cpp index 1bc9e614a..ba9f4331d 100644 --- a/unsupported/test/NumericalDiff.cpp +++ b/unsupported/test/NumericalDiff.cpp @@ -88,8 +88,27 @@ void test_forward() VERIFY_IS_APPROX(jac, actual_jac); } +void test_central() +{ + VectorXd x(3); + MatrixXd jac(15,3); + MatrixXd actual_jac(15,3); + my_functor functor; + + x << 0.082, 1.13, 2.35; + + // real one + functor.df(x, actual_jac); + + // using NumericalDiff + NumericalDiff numDiff(functor); + numDiff.df(x, jac); + + VERIFY_IS_APPROX(jac, actual_jac); +} void test_NumericalDiff() { CALL_SUBTEST(test_forward()); + CALL_SUBTEST(test_central()); } -- cgit v1.2.3