55template<
class Y,
class X=
double>
69template <class X, int N = traits<X>::dimension>
71 std::function<
double(
const X&)> h,
const X& x,
double delta = 1e-5) {
72 double factor = 1.0 / (2.0 * delta);
74 BOOST_STATIC_ASSERT_MSG(
76 "Template argument X must be a manifold type.");
77 BOOST_STATIC_ASSERT_MSG(N>0,
"Template argument X must be fixed-size type or N must be specified.");
83 Eigen::Matrix<double,N,1> g;
85 for (
int j = 0; j < N; j++) {
91 g(j) = (hxplus - hxmin) * factor;
108template <class Y, class X, int N = traits<X>::dimension>
111 std::function<Y(
const X&)> h,
const X& x,
double delta = 1e-5) {
112 typedef typename internal::FixedSizeMatrix<Y,X>::type Matrix;
115 "Template argument Y must be a manifold type.");
119 "Template argument X must be a manifold type.");
120 BOOST_STATIC_ASSERT_MSG(N>0,
"Template argument X must be fixed-size type or N must be specified.");
127 const typename TraitsY::TangentVector zeroY = TraitsY::Local(hx, hx);
128 const size_t m = zeroY.size();
131 Eigen::Matrix<double, N, 1> dx;
135 Matrix H = Matrix::Zero(m, N);
136 const double factor = 1.0 / (2.0 * delta);
137 for (
int j = 0; j < N; j++) {
139 const auto dy1 = TraitsY::Local(hx, h(TraitsX::Retract(x, dx)));
141 const auto dy2 = TraitsY::Local(hx, h(TraitsX::Retract(x, dx)));
143 H.col(j) << (dy1 - dy2) * factor;
149template<
class Y,
class X>
151 double delta = 1e-5) {
152 return numericalDerivative11<Y, X>(std::bind(h, std::placeholders::_1), x,
165template<class Y, class X1, class X2, int N = traits<X1>::dimension>
166typename internal::FixedSizeMatrix<Y,X1>::type
numericalDerivative21(
const std::function<Y(
const X1&,
const X2&)>& h,
167 const X1& x1,
const X2& x2,
double delta = 1e-5) {
169 "Template argument Y must be a manifold type.");
171 "Template argument X1 must be a manifold type.");
172 return numericalDerivative11<Y, X1, N>(
173 std::bind(h, std::placeholders::_1, std::cref(x2)), x1, delta);
177template<
class Y,
class X1,
class X2>
179 const X2& x2,
double delta = 1e-5) {
180 return numericalDerivative21<Y, X1, X2>(
181 std::bind(h, std::placeholders::_1, std::placeholders::_2), x1, x2,
194template<class Y, class X1, class X2, int N = traits<X2>::dimension>
196 const X1& x1,
const X2& x2,
double delta = 1e-5) {
200 "Template argument X2 must be a manifold type.");
201 return numericalDerivative11<Y, X2, N>(
202 std::bind(h, std::cref(x1), std::placeholders::_1), x2, delta);
206template<
class Y,
class X1,
class X2>
208 const X2& x2,
double delta = 1e-5) {
209 return numericalDerivative22<Y, X1, X2>(
210 std::bind(h, std::placeholders::_1, std::placeholders::_2), x1, x2,
225template<class Y, class X1, class X2, class X3, int N = traits<X1>::dimension>
227 std::function<Y(
const X1&,
const X2&,
const X3&)> h,
const X1& x1,
228 const X2& x2,
const X3& x3,
double delta = 1e-5) {
230 "Template argument Y must be a manifold type.");
232 "Template argument X1 must be a manifold type.");
233 return numericalDerivative11<Y, X1, N>(
234 std::bind(h, std::placeholders::_1, std::cref(x2), std::cref(x3)),
238template<
class Y,
class X1,
class X2,
class X3>
239typename internal::FixedSizeMatrix<Y,X1>::type
numericalDerivative31(Y (*h)(
const X1&,
const X2&,
const X3&),
240 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
241 return numericalDerivative31<Y, X1, X2, X3>(
242 std::bind(h, std::placeholders::_1, std::placeholders::_2,
243 std::placeholders::_3),
258template<class Y, class X1, class X2, class X3, int N = traits<X2>::dimension>
260 std::function<Y(
const X1&,
const X2&,
const X3&)> h,
const X1& x1,
261 const X2& x2,
const X3& x3,
double delta = 1e-5) {
263 "Template argument Y must be a manifold type.");
265 "Template argument X2 must be a manifold type.");
266 return numericalDerivative11<Y, X2, N>(
267 std::bind(h, std::cref(x1), std::placeholders::_1, std::cref(x3)),
271template<
class Y,
class X1,
class X2,
class X3>
272inline typename internal::FixedSizeMatrix<Y,X2>::type
numericalDerivative32(Y (*h)(
const X1&,
const X2&,
const X3&),
273 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
274 return numericalDerivative32<Y, X1, X2, X3>(
275 std::bind(h, std::placeholders::_1, std::placeholders::_2,
276 std::placeholders::_3),
291template<class Y, class X1, class X2, class X3, int N = traits<X3>::dimension>
293 std::function<Y(
const X1&,
const X2&,
const X3&)> h,
const X1& x1,
294 const X2& x2,
const X3& x3,
double delta = 1e-5) {
296 "Template argument Y must be a manifold type.");
298 "Template argument X3 must be a manifold type.");
299 return numericalDerivative11<Y, X3, N>(
300 std::bind(h, std::cref(x1), std::cref(x2), std::placeholders::_1),
304template<
class Y,
class X1,
class X2,
class X3>
305inline typename internal::FixedSizeMatrix<Y,X3>::type
numericalDerivative33(Y (*h)(
const X1&,
const X2&,
const X3&),
306 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
307 return numericalDerivative33<Y, X1, X2, X3>(
308 std::bind(h, std::placeholders::_1, std::placeholders::_2,
309 std::placeholders::_3),
324template<class Y, class X1, class X2, class X3, class X4, int N = traits<X1>::dimension>
326 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&)> h,
const X1& x1,
327 const X2& x2,
const X3& x3,
const X4& x4,
double delta = 1e-5) {
329 "Template argument Y must be a manifold type.");
331 "Template argument X1 must be a manifold type.");
332 return numericalDerivative11<Y, X1, N>(
333 std::bind(h, std::placeholders::_1, std::cref(x2), std::cref(x3),
338template<
class Y,
class X1,
class X2,
class X3,
class X4>
339inline typename internal::FixedSizeMatrix<Y,X1>::type
numericalDerivative41(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&),
340 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
double delta = 1e-5) {
341 return numericalDerivative41<Y, X1, X2, X3, X4>(
342 std::bind(h, std::placeholders::_1, std::placeholders::_2,
343 std::placeholders::_3, std::placeholders::_4),
358template<class Y, class X1, class X2, class X3, class X4, int N = traits<X2>::dimension>
360 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&)> h,
const X1& x1,
361 const X2& x2,
const X3& x3,
const X4& x4,
double delta = 1e-5) {
363 "Template argument Y must be a manifold type.");
365 "Template argument X2 must be a manifold type.");
366 return numericalDerivative11<Y, X2, N>(
367 std::bind(h, std::cref(x1), std::placeholders::_1, std::cref(x3),
372template<
class Y,
class X1,
class X2,
class X3,
class X4>
373inline typename internal::FixedSizeMatrix<Y,X2>::type
numericalDerivative42(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&),
374 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
double delta = 1e-5) {
375 return numericalDerivative42<Y, X1, X2, X3, X4>(
376 std::bind(h, std::placeholders::_1, std::placeholders::_2,
377 std::placeholders::_3, std::placeholders::_4),
392template<class Y, class X1, class X2, class X3, class X4, int N = traits<X3>::dimension>
394 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&)> h,
const X1& x1,
395 const X2& x2,
const X3& x3,
const X4& x4,
double delta = 1e-5) {
397 "Template argument Y must be a manifold type.");
399 "Template argument X3 must be a manifold type.");
400 return numericalDerivative11<Y, X3, N>(
401 std::bind(h, std::cref(x1), std::cref(x2), std::placeholders::_1,
406template<
class Y,
class X1,
class X2,
class X3,
class X4>
407inline typename internal::FixedSizeMatrix<Y,X3>::type
numericalDerivative43(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&),
408 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
double delta = 1e-5) {
409 return numericalDerivative43<Y, X1, X2, X3, X4>(
410 std::bind(h, std::placeholders::_1, std::placeholders::_2,
411 std::placeholders::_3, std::placeholders::_4),
426template<class Y, class X1, class X2, class X3, class X4, int N = traits<X4>::dimension>
428 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&)> h,
const X1& x1,
429 const X2& x2,
const X3& x3,
const X4& x4,
double delta = 1e-5) {
431 "Template argument Y must be a manifold type.");
433 "Template argument X4 must be a manifold type.");
434 return numericalDerivative11<Y, X4, N>(
435 std::bind(h, std::cref(x1), std::cref(x2), std::cref(x3),
436 std::placeholders::_1),
440template<
class Y,
class X1,
class X2,
class X3,
class X4>
441inline typename internal::FixedSizeMatrix<Y,X4>::type
numericalDerivative44(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&),
442 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
double delta = 1e-5) {
443 return numericalDerivative44<Y, X1, X2, X3, X4>(
444 std::bind(h, std::placeholders::_1, std::placeholders::_2,
445 std::placeholders::_3, std::placeholders::_4),
461template<class Y, class X1, class X2, class X3, class X4, class X5, int N = traits<X1>::dimension>
463 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&)> h,
const X1& x1,
464 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
466 "Template argument Y must be a manifold type.");
468 "Template argument X1 must be a manifold type.");
469 return numericalDerivative11<Y, X1, N>(
470 std::bind(h, std::placeholders::_1, std::cref(x2), std::cref(x3),
471 std::cref(x4), std::cref(x5)),
475template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5>
476inline typename internal::FixedSizeMatrix<Y,X1>::type
numericalDerivative51(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&),
477 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
478 return numericalDerivative51<Y, X1, X2, X3, X4, X5>(
479 std::bind(h, std::placeholders::_1, std::placeholders::_2,
480 std::placeholders::_3, std::placeholders::_4,
481 std::placeholders::_5),
497template<class Y, class X1, class X2, class X3, class X4, class X5, int N = traits<X2>::dimension>
499 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&)> h,
const X1& x1,
500 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
502 "Template argument Y must be a manifold type.");
504 "Template argument X1 must be a manifold type.");
505 return numericalDerivative11<Y, X2, N>(
506 std::bind(h, std::cref(x1), std::placeholders::_1, std::cref(x3),
507 std::cref(x4), std::cref(x5)),
511template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5>
512inline typename internal::FixedSizeMatrix<Y,X2>::type
numericalDerivative52(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&),
513 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
514 return numericalDerivative52<Y, X1, X2, X3, X4, X5>(
515 std::bind(h, std::placeholders::_1, std::placeholders::_2,
516 std::placeholders::_3, std::placeholders::_4,
517 std::placeholders::_5),
533template<class Y, class X1, class X2, class X3, class X4, class X5, int N = traits<X3>::dimension>
535 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&)> h,
const X1& x1,
536 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
538 "Template argument Y must be a manifold type.");
540 "Template argument X1 must be a manifold type.");
541 return numericalDerivative11<Y, X3, N>(
542 std::bind(h, std::cref(x1), std::cref(x2), std::placeholders::_1,
543 std::cref(x4), std::cref(x5)),
547template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5>
548inline typename internal::FixedSizeMatrix<Y,X3>::type
numericalDerivative53(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&),
549 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
550 return numericalDerivative53<Y, X1, X2, X3, X4, X5>(
551 std::bind(h, std::placeholders::_1, std::placeholders::_2,
552 std::placeholders::_3, std::placeholders::_4,
553 std::placeholders::_5),
569template<class Y, class X1, class X2, class X3, class X4, class X5, int N = traits<X4>::dimension>
571 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&)> h,
const X1& x1,
572 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
574 "Template argument Y must be a manifold type.");
576 "Template argument X1 must be a manifold type.");
577 return numericalDerivative11<Y, X4, N>(
578 std::bind(h, std::cref(x1), std::cref(x2), std::cref(x3),
579 std::placeholders::_1, std::cref(x5)),
583template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5>
584inline typename internal::FixedSizeMatrix<Y,X4>::type
numericalDerivative54(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&),
585 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
586 return numericalDerivative54<Y, X1, X2, X3, X4, X5>(
587 std::bind(h, std::placeholders::_1, std::placeholders::_2,
588 std::placeholders::_3, std::placeholders::_4,
589 std::placeholders::_5),
605template<class Y, class X1, class X2, class X3, class X4, class X5, int N = traits<X5>::dimension>
607 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&)> h,
const X1& x1,
608 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
610 "Template argument Y must be a manifold type.");
612 "Template argument X1 must be a manifold type.");
613 return numericalDerivative11<Y, X5, N>(
614 std::bind(h, std::cref(x1), std::cref(x2), std::cref(x3),
615 std::cref(x4), std::placeholders::_1),
619template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5>
620inline typename internal::FixedSizeMatrix<Y,X5>::type
numericalDerivative55(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&),
621 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
double delta = 1e-5) {
622 return numericalDerivative55<Y, X1, X2, X3, X4, X5>(
623 std::bind(h, std::placeholders::_1, std::placeholders::_2,
624 std::placeholders::_3, std::placeholders::_4,
625 std::placeholders::_5),
642template<class Y, class X1, class X2, class X3, class X4, class X5, class X6, int N = traits<X1>::dimension>
644 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&)> h,
const X1& x1,
645 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
647 "Template argument Y must be a manifold type.");
649 "Template argument X1 must be a manifold type.");
650 return numericalDerivative11<Y, X1, N>(
651 std::bind(h, std::placeholders::_1, std::cref(x2), std::cref(x3),
652 std::cref(x4), std::cref(x5), std::cref(x6)),
656template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5,
class X6>
657inline typename internal::FixedSizeMatrix<Y,X1>::type
numericalDerivative61(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&),
658 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
659 return numericalDerivative61<Y, X1, X2, X3, X4, X5, X6>(
660 std::bind(h, std::placeholders::_1, std::placeholders::_2,
661 std::placeholders::_3, std::placeholders::_4,
662 std::placeholders::_5, std::placeholders::_6),
663 x1, x2, x3, x4, x5, x6);
679template<class Y, class X1, class X2, class X3, class X4, class X5, class X6, int N = traits<X2>::dimension>
681 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&)> h,
const X1& x1,
682 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
684 "Template argument Y must be a manifold type.");
686 "Template argument X1 must be a manifold type.");
687 return numericalDerivative11<Y, X2, N>(
688 std::bind(h, std::cref(x1), std::placeholders::_1, std::cref(x3),
689 std::cref(x4), std::cref(x5), std::cref(x6)),
693template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5,
class X6>
694inline typename internal::FixedSizeMatrix<Y,X2>::type
numericalDerivative62(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&),
695 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
696 return numericalDerivative62<Y, X1, X2, X3, X4, X5, X6>(
697 std::bind(h, std::placeholders::_1, std::placeholders::_2,
698 std::placeholders::_3, std::placeholders::_4,
699 std::placeholders::_5, std::placeholders::_6),
700 x1, x2, x3, x4, x5, x6);
716template<class Y, class X1, class X2, class X3, class X4, class X5, class X6, int N = traits<X3>::dimension>
718 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&)> h,
const X1& x1,
719 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
721 "Template argument Y must be a manifold type.");
723 "Template argument X1 must be a manifold type.");
724 return numericalDerivative11<Y, X3, N>(
725 std::bind(h, std::cref(x1), std::cref(x2), std::placeholders::_1,
726 std::cref(x4), std::cref(x5), std::cref(x6)),
730template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5,
class X6>
731inline typename internal::FixedSizeMatrix<Y,X3>::type
numericalDerivative63(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&),
732 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
733 return numericalDerivative63<Y, X1, X2, X3, X4, X5, X6>(
734 std::bind(h, std::placeholders::_1, std::placeholders::_2,
735 std::placeholders::_3, std::placeholders::_4,
736 std::placeholders::_5, std::placeholders::_6),
737 x1, x2, x3, x4, x5, x6);
753template<class Y, class X1, class X2, class X3, class X4, class X5, class X6, int N = traits<X4>::dimension>
755 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&)> h,
const X1& x1,
756 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
758 "Template argument Y must be a manifold type.");
760 "Template argument X1 must be a manifold type.");
761 return numericalDerivative11<Y, X4, N>(
762 std::bind(h, std::cref(x1), std::cref(x2), std::cref(x3),
763 std::placeholders::_1, std::cref(x5), std::cref(x6)),
767template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5,
class X6>
768inline typename internal::FixedSizeMatrix<Y,X4>::type
numericalDerivative64(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&),
769 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
770 return numericalDerivative64<Y, X1, X2, X3, X4, X5>(
771 std::bind(h, std::placeholders::_1, std::placeholders::_2,
772 std::placeholders::_3, std::placeholders::_4,
773 std::placeholders::_5, std::placeholders::_6),
774 x1, x2, x3, x4, x5, x6);
790template<class Y, class X1, class X2, class X3, class X4, class X5, class X6, int N = traits<X5>::dimension>
792 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&)> h,
const X1& x1,
793 const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
795 "Template argument Y must be a manifold type.");
797 "Template argument X1 must be a manifold type.");
798 return numericalDerivative11<Y, X5, N>(
799 std::bind(h, std::cref(x1), std::cref(x2), std::cref(x3),
800 std::cref(x4), std::placeholders::_1, std::cref(x6)),
804template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5,
class X6>
805inline typename internal::FixedSizeMatrix<Y,X5>::type
numericalDerivative65(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&),
806 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
807 return numericalDerivative65<Y, X1, X2, X3, X4, X5, X6>(
808 std::bind(h, std::placeholders::_1, std::placeholders::_2,
809 std::placeholders::_3, std::placeholders::_4,
810 std::placeholders::_5, std::placeholders::_6),
811 x1, x2, x3, x4, x5, x6);
827template<class Y, class X1, class X2, class X3, class X4, class X5, class X6, int N = traits<X6>::dimension>
829 std::function<Y(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&)> h,
830 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
831 double delta = 1e-5) {
833 "Template argument Y must be a manifold type.");
835 "Template argument X1 must be a manifold type.");
836 return numericalDerivative11<Y, X6, N>(
837 std::bind(h, std::cref(x1), std::cref(x2), std::cref(x3),
838 std::cref(x4), std::cref(x5), std::placeholders::_1),
842template<
class Y,
class X1,
class X2,
class X3,
class X4,
class X5,
class X6>
843inline typename internal::FixedSizeMatrix<Y,X6>::type
numericalDerivative66(Y (*h)(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&),
844 const X1& x1,
const X2& x2,
const X3& x3,
const X4& x4,
const X5& x5,
const X6& x6,
double delta = 1e-5) {
845 return numericalDerivative66<Y, X1, X2, X3, X4, X5, X6>(
846 std::bind(h, std::placeholders::_1, std::placeholders::_2,
847 std::placeholders::_3, std::placeholders::_4,
848 std::placeholders::_5, std::placeholders::_6),
849 x1, x2, x3, x4, x5, x6);
861inline typename internal::FixedSizeMatrix<X,X>::type
numericalHessian(std::function<
double(
const X&)> f,
const X& x,
862 double delta = 1e-5) {
864 "Template argument X must be a manifold type.");
865 typedef Eigen::Matrix<double, traits<X>::dimension, 1> VectorD;
866 typedef std::function<double(
const X&)> F;
867 typedef std::function<VectorD(F,
const X&,
double)> G;
868 G ng =
static_cast<G
>(numericalGradient<X> );
869 return numericalDerivative11<VectorD, X>(
870 std::bind(ng, f, std::placeholders::_1, delta), x, delta);
874inline typename internal::FixedSizeMatrix<X,X>::type
numericalHessian(
double (*f)(
const X&),
const X& x,
double delta =
882template<
class X1,
class X2>
884 const std::function<double(
const X1&,
const X2&)>& f_;
888 typedef typename internal::FixedSizeMatrix<X1>::type Vector;
890 G_x1(
const std::function<
double(
const X1&,
const X2&)>& f,
const X1& x1,
892 f_(f), x1_(x1), delta_(delta) {
894 Vector operator()(
const X2& x2) {
895 return numericalGradient<X1>(
896 std::bind(f_, std::placeholders::_1, std::cref(x2)), x1_, delta_);
900template<
class X1,
class X2>
901inline typename internal::FixedSizeMatrix<X1,X2>::type numericalHessian212(
902 std::function<
double(
const X1&,
const X2&)> f,
const X1& x1,
const X2& x2,
903 double delta = 1e-5) {
904 typedef typename internal::FixedSizeMatrix<X1>::type Vector;
906 return numericalDerivative11<Vector, X2>(
907 std::function<Vector(
const X2&)>(
908 std::bind<Vector>(std::ref(g_x1), std::placeholders::_1)),
912template<
class X1,
class X2>
913inline typename internal::FixedSizeMatrix<X1,X2>::type numericalHessian212(
double (*f)(
const X1&,
const X2&),
914 const X1& x1,
const X2& x2,
double delta = 1e-5) {
915 return numericalHessian212(std::function<
double(
const X1&,
const X2&)>(f),
919template<
class X1,
class X2>
920inline typename internal::FixedSizeMatrix<X1,X1>::type numericalHessian211(
921 std::function<
double(
const X1&,
const X2&)> f,
const X1& x1,
const X2& x2,
922 double delta = 1e-5) {
924 typedef typename internal::FixedSizeMatrix<X1>::type Vector;
926 Vector (*numGrad)(std::function<double(
const X1&)>,
const X1&,
927 double) = &numericalGradient<X1>;
928 std::function<double(
const X1&)> f2(
929 std::bind(f, std::placeholders::_1, std::cref(x2)));
931 return numericalDerivative11<Vector, X1>(
932 std::function<Vector(
const X1&)>(
933 std::bind(numGrad, f2, std::placeholders::_1, delta)),
937template<
class X1,
class X2>
938inline typename internal::FixedSizeMatrix<X1,X1>::type numericalHessian211(
double (*f)(
const X1&,
const X2&),
939 const X1& x1,
const X2& x2,
double delta = 1e-5) {
940 return numericalHessian211(std::function<
double(
const X1&,
const X2&)>(f),
944template<
class X1,
class X2>
945inline typename internal::FixedSizeMatrix<X2,X2>::type numericalHessian222(
946 std::function<
double(
const X1&,
const X2&)> f,
const X1& x1,
const X2& x2,
947 double delta = 1e-5) {
948 typedef typename internal::FixedSizeMatrix<X2>::type Vector;
949 Vector (*numGrad)(std::function<double(
const X2&)>,
const X2&,
950 double) = &numericalGradient<X2>;
951 std::function<double(
const X2&)> f2(
952 std::bind(f, std::cref(x1), std::placeholders::_1));
954 return numericalDerivative11<Vector, X2>(
955 std::function<Vector(
const X2&)>(
956 std::bind(numGrad, f2, std::placeholders::_1, delta)),
960template<
class X1,
class X2>
961inline typename internal::FixedSizeMatrix<X2,X2>::type numericalHessian222(
double (*f)(
const X1&,
const X2&),
962 const X1& x1,
const X2& x2,
double delta = 1e-5) {
963 return numericalHessian222(std::function<
double(
const X1&,
const X2&)>(f),
971template<
class X1,
class X2,
class X3>
973 std::function<
double(
const X1&,
const X2&,
const X3&)> f,
const X1& x1,
974 const X2& x2,
const X3& x3,
double delta = 1e-5) {
975 typedef typename internal::FixedSizeMatrix<X1>::type Vector;
976 Vector (*numGrad)(std::function<double(
const X1&)>,
const X1&,
977 double) = &numericalGradient<X1>;
978 std::function<double(
const X1&)> f2(std::bind(
979 f, std::placeholders::_1, std::cref(x2), std::cref(x3)));
981 return numericalDerivative11<Vector, X1>(
982 std::function<Vector(
const X1&)>(
983 std::bind(numGrad, f2, std::placeholders::_1, delta)),
987template<
class X1,
class X2,
class X3>
988inline typename internal::FixedSizeMatrix<X1,X1>::type
numericalHessian311(
double (*f)(
const X1&,
const X2&,
const X3&),
989 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
991 std::function<
double(
const X1&,
const X2&,
const X3&)>(f), x1, x2, x3,
996template<
class X1,
class X2,
class X3>
997inline typename internal::FixedSizeMatrix<X2,X2>::type numericalHessian322(
998 std::function<
double(
const X1&,
const X2&,
const X3&)> f,
const X1& x1,
999 const X2& x2,
const X3& x3,
double delta = 1e-5) {
1000 typedef typename internal::FixedSizeMatrix<X2>::type Vector;
1001 Vector (*numGrad)(std::function<double(
const X2&)>,
const X2&,
1002 double) = &numericalGradient<X2>;
1003 std::function<double(
const X2&)> f2(std::bind(
1004 f, std::cref(x1), std::placeholders::_1, std::cref(x3)));
1006 return numericalDerivative11<Vector, X2>(
1007 std::function<Vector(
const X2&)>(
1008 std::bind(numGrad, f2, std::placeholders::_1, delta)),
1012template<
class X1,
class X2,
class X3>
1013inline typename internal::FixedSizeMatrix<X2,X2>::type numericalHessian322(
double (*f)(
const X1&,
const X2&,
const X3&),
1014 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
1015 return numericalHessian322(
1016 std::function<
double(
const X1&,
const X2&,
const X3&)>(f), x1, x2, x3,
1021template<
class X1,
class X2,
class X3>
1022inline typename internal::FixedSizeMatrix<X3,X3>::type numericalHessian333(
1023 std::function<
double(
const X1&,
const X2&,
const X3&)> f,
const X1& x1,
1024 const X2& x2,
const X3& x3,
double delta = 1e-5) {
1025 typedef typename internal::FixedSizeMatrix<X3>::type Vector;
1026 Vector (*numGrad)(std::function<double(
const X3&)>,
const X3&,
1027 double) = &numericalGradient<X3>;
1028 std::function<double(
const X3&)> f2(std::bind(
1029 f, std::cref(x1), std::cref(x2), std::placeholders::_1));
1031 return numericalDerivative11<Vector, X3>(
1032 std::function<Vector(
const X3&)>(
1033 std::bind(numGrad, f2, std::placeholders::_1, delta)),
1037template<
class X1,
class X2,
class X3>
1038inline typename internal::FixedSizeMatrix<X3,X3>::type numericalHessian333(
double (*f)(
const X1&,
const X2&,
const X3&),
1039 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
1040 return numericalHessian333(
1041 std::function<
double(
const X1&,
const X2&,
const X3&)>(f), x1, x2, x3,
1046template<
class X1,
class X2,
class X3>
1047inline typename internal::FixedSizeMatrix<X1,X2>::type numericalHessian312(
1048 std::function<
double(
const X1&,
const X2&,
const X3&)> f,
const X1& x1,
1049 const X2& x2,
const X3& x3,
double delta = 1e-5) {
1050 return numericalHessian212<X1, X2>(
1051 std::function<
double(
const X1&,
const X2&)>(
1052 std::bind(f, std::placeholders::_1, std::placeholders::_2,
1057template<
class X1,
class X2,
class X3>
1058inline typename internal::FixedSizeMatrix<X1,X3>::type numericalHessian313(
1059 std::function<
double(
const X1&,
const X2&,
const X3&)> f,
const X1& x1,
1060 const X2& x2,
const X3& x3,
double delta = 1e-5) {
1061 return numericalHessian212<X1, X3>(
1062 std::function<
double(
const X1&,
const X3&)>(
1063 std::bind(f, std::placeholders::_1, std::cref(x2),
1064 std::placeholders::_2)),
1068template<
class X1,
class X2,
class X3>
1069inline typename internal::FixedSizeMatrix<X2,X3>::type numericalHessian323(
1070 std::function<
double(
const X1&,
const X2&,
const X3&)> f,
const X1& x1,
1071 const X2& x2,
const X3& x3,
double delta = 1e-5) {
1072 return numericalHessian212<X2, X3>(
1073 std::function<
double(
const X2&,
const X3&)>(
1074 std::bind(f, std::cref(x1), std::placeholders::_1,
1075 std::placeholders::_2)),
1080template<
class X1,
class X2,
class X3>
1081inline typename internal::FixedSizeMatrix<X1,X2>::type numericalHessian312(
double (*f)(
const X1&,
const X2&,
const X3&),
1082 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
1083 return numericalHessian312(
1084 std::function<
double(
const X1&,
const X2&,
const X3&)>(f), x1, x2, x3,
1088template<
class X1,
class X2,
class X3>
1089inline typename internal::FixedSizeMatrix<X1,X3>::type numericalHessian313(
double (*f)(
const X1&,
const X2&,
const X3&),
1090 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
1091 return numericalHessian313(
1092 std::function<
double(
const X1&,
const X2&,
const X3&)>(f), x1, x2, x3,
1096template<
class X1,
class X2,
class X3>
1097inline typename internal::FixedSizeMatrix<X2,X3>::type numericalHessian323(
double (*f)(
const X1&,
const X2&,
const X3&),
1098 const X1& x1,
const X2& x2,
const X3& x3,
double delta = 1e-5) {
1099 return numericalHessian323(
1100 std::function<
double(
const X1&,
const X2&,
const X3&)>(f), x1, x2, x3,
Base class and basic functions for Lie types.
A non-templated config holding any types of Manifold-group elements.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative61(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &, const X6 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, const X6 &x6, double delta=1e-5)
Compute numerical derivative in argument 1 of 6-argument function.
Definition: numericalDerivative.h:643
internal::FixedSizeMatrix< X1, X1 >::type numericalHessian311(std::function< double(const X1 &, const X2 &, const X3 &)> f, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
Numerical Hessian for tenary functions.
Definition: numericalDerivative.h:972
internal::FixedSizeMatrix< X, X >::type numericalHessian(std::function< double(const X &)> f, const X &x, double delta=1e-5)
Compute numerical Hessian matrix.
Definition: numericalDerivative.h:861
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative21(const std::function< Y(const X1 &, const X2 &)> &h, const X1 &x1, const X2 &x2, double delta=1e-5)
Compute numerical derivative in argument 1 of binary function.
Definition: numericalDerivative.h:166
internal::FixedSizeMatrix< Y, X3 >::type numericalDerivative63(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &, const X6 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, const X6 &x6, double delta=1e-5)
Compute numerical derivative in argument 3 of 6-argument function.
Definition: numericalDerivative.h:717
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative51(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, double delta=1e-5)
Compute numerical derivative in argument 1 of 5-argument function.
Definition: numericalDerivative.h:462
internal::FixedSizeMatrix< Y, X4 >::type numericalDerivative54(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, double delta=1e-5)
Compute numerical derivative in argument 4 of 5-argument function.
Definition: numericalDerivative.h:570
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative41(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, double delta=1e-5)
Compute numerical derivative in argument 1 of 4-argument function.
Definition: numericalDerivative.h:325
internal::FixedSizeMatrix< Y, X4 >::type numericalDerivative64(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &, const X6 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, const X6 &x6, double delta=1e-5)
Compute numerical derivative in argument 4 of 6-argument function.
Definition: numericalDerivative.h:754
internal::FixedSizeMatrix< Y, X6 >::type numericalDerivative66(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &, const X6 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, const X6 &x6, double delta=1e-5)
Compute numerical derivative in argument 6 of 6-argument function.
Definition: numericalDerivative.h:828
internal::FixedSizeMatrix< Y, X3 >::type numericalDerivative33(std::function< Y(const X1 &, const X2 &, const X3 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
Compute numerical derivative in argument 3 of ternary function.
Definition: numericalDerivative.h:292
internal::FixedSizeMatrix< Y, X >::type numericalDerivative11(std::function< Y(const X &)> h, const X &x, double delta=1e-5)
New-style numerical derivatives using manifold_traits.
Definition: numericalDerivative.h:110
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative22(std::function< Y(const X1 &, const X2 &)> h, const X1 &x1, const X2 &x2, double delta=1e-5)
Compute numerical derivative in argument 2 of binary function.
Definition: numericalDerivative.h:195
internal::FixedSizeMatrix< Y, X5 >::type numericalDerivative55(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, double delta=1e-5)
Compute numerical derivative in argument 5 of 5-argument function.
Definition: numericalDerivative.h:606
internal::FixedSizeMatrix< Y, X3 >::type numericalDerivative43(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, double delta=1e-5)
Compute numerical derivative in argument 3 of 4-argument function.
Definition: numericalDerivative.h:393
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative52(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, double delta=1e-5)
Compute numerical derivative in argument 2 of 5-argument function.
Definition: numericalDerivative.h:498
internal::FixedSizeMatrix< Y, X5 >::type numericalDerivative65(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &, const X6 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, const X6 &x6, double delta=1e-5)
Compute numerical derivative in argument 5 of 6-argument function.
Definition: numericalDerivative.h:791
internal::FixedSizeMatrix< Y, X4 >::type numericalDerivative44(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, double delta=1e-5)
Compute numerical derivative in argument 4 of 4-argument function.
Definition: numericalDerivative.h:427
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative31(std::function< Y(const X1 &, const X2 &, const X3 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
Compute numerical derivative in argument 1 of ternary function.
Definition: numericalDerivative.h:226
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative62(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &, const X6 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, const X6 &x6, double delta=1e-5)
Compute numerical derivative in argument 2 of 6-argument function.
Definition: numericalDerivative.h:680
internal::FixedSizeMatrix< Y, X3 >::type numericalDerivative53(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &, const X5 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, double delta=1e-5)
Compute numerical derivative in argument 3 of 5-argument function.
Definition: numericalDerivative.h:534
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative32(std::function< Y(const X1 &, const X2 &, const X3 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
Compute numerical derivative in argument 2 of ternary function.
Definition: numericalDerivative.h:259
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative42(std::function< Y(const X1 &, const X2 &, const X3 &, const X4 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, double delta=1e-5)
Compute numerical derivative in argument 2 of 4-argument function.
Definition: numericalDerivative.h:359
Eigen::Matrix< double, N, 1 > numericalGradient(std::function< double(const X &)> h, const X &x, double delta=1e-5)
Numerically compute gradient of scalar function.
Definition: numericalDerivative.h:70
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
tag to assert a type is a manifold
Definition: Manifold.h:33
Definition: numericalDerivative.h:56
Helper class that computes the derivative of f w.r.t.
Definition: numericalDerivative.h:883