aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test/NumericalDiff.cpp
diff options
context:
space:
mode:
authorGravatar Thomas Capricelli <orzel@freehackers.org>2009-09-28 02:55:30 +0200
committerGravatar Thomas Capricelli <orzel@freehackers.org>2009-09-28 02:55:30 +0200
commit87be19de4aec6f0f04ff3a5f0304ca999cecbd13 (patch)
tree10da9b37e1d17f19b3225a1bb5ceab952e372fb8 /unsupported/test/NumericalDiff.cpp
parent206b5e39723c51eaa9550db04d459ebd07604415 (diff)
central sheme for numerical diff
Diffstat (limited to 'unsupported/test/NumericalDiff.cpp')
-rw-r--r--unsupported/test/NumericalDiff.cpp19
1 files changed, 19 insertions, 0 deletions
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<my_functor,Central> numDiff(functor);
+ numDiff.df(x, jac);
+
+ VERIFY_IS_APPROX(jac, actual_jac);
+}
void test_NumericalDiff()
{
CALL_SUBTEST(test_forward());
+ CALL_SUBTEST(test_central());
}