boost::bind and placeholders
parent
178a022966
commit
5a257ff36b
|
@ -25,10 +25,10 @@
|
||||||
#include <gtsam/base/Testable.h>
|
#include <gtsam/base/Testable.h>
|
||||||
|
|
||||||
#include <CppUnitLite/TestHarness.h>
|
#include <CppUnitLite/TestHarness.h>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
using namespace boost::placeholders;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
noiseModel::Diagonal::shared_ptr model = noiseModel::Unit::Create(1);
|
noiseModel::Diagonal::shared_ptr model = noiseModel::Unit::Create(1);
|
||||||
|
@ -119,8 +119,8 @@ TEST(Chebyshev2, InterpolateVector) {
|
||||||
EXPECT(assert_equal(expected, fx(X, actualH), 1e-9));
|
EXPECT(assert_equal(expected, fx(X, actualH), 1e-9));
|
||||||
|
|
||||||
// Check derivative
|
// Check derivative
|
||||||
std::function<Vector2(ParameterMatrix<2>)> f = boost::bind(
|
std::function<Vector2(ParameterMatrix<2>)> f = std::bind(
|
||||||
&Chebyshev2::VectorEvaluationFunctor<2>::operator(), fx, _1, nullptr);
|
&Chebyshev2::VectorEvaluationFunctor<2>::operator(), fx, std::placeholders::_1, nullptr);
|
||||||
Matrix numericalH =
|
Matrix numericalH =
|
||||||
numericalDerivative11<Vector2, ParameterMatrix<2>, 2 * N>(f, X);
|
numericalDerivative11<Vector2, ParameterMatrix<2>, 2 * N>(f, X);
|
||||||
EXPECT(assert_equal(numericalH, actualH, 1e-9));
|
EXPECT(assert_equal(numericalH, actualH, 1e-9));
|
||||||
|
@ -378,7 +378,7 @@ TEST(Chebyshev2, VectorDerivativeFunctor) {
|
||||||
|
|
||||||
// Test Jacobian
|
// Test Jacobian
|
||||||
Matrix expectedH = numericalDerivative11<Vector2, ParameterMatrix<M>, M * N>(
|
Matrix expectedH = numericalDerivative11<Vector2, ParameterMatrix<M>, M * N>(
|
||||||
boost::bind(&VecD::operator(), fx, _1, nullptr), X);
|
std::bind(&VecD::operator(), fx, std::placeholders::_1, nullptr), X);
|
||||||
EXPECT(assert_equal(expectedH, actualH, 1e-7));
|
EXPECT(assert_equal(expectedH, actualH, 1e-7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ TEST(Chebyshev2, VectorDerivativeFunctor2) {
|
||||||
VecD vecd(N, points(0), 0, T);
|
VecD vecd(N, points(0), 0, T);
|
||||||
vecd(X, actualH);
|
vecd(X, actualH);
|
||||||
Matrix expectedH = numericalDerivative11<Vector1, ParameterMatrix<M>, M * N>(
|
Matrix expectedH = numericalDerivative11<Vector1, ParameterMatrix<M>, M * N>(
|
||||||
boost::bind(&VecD::operator(), vecd, _1, nullptr), X);
|
std::bind(&VecD::operator(), vecd, std::placeholders::_1, nullptr), X);
|
||||||
EXPECT(assert_equal(expectedH, actualH, 1e-6));
|
EXPECT(assert_equal(expectedH, actualH, 1e-6));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ TEST(Chebyshev2, ComponentDerivativeFunctor) {
|
||||||
EXPECT_DOUBLES_EQUAL(0, fx(X, actualH), 1e-8);
|
EXPECT_DOUBLES_EQUAL(0, fx(X, actualH), 1e-8);
|
||||||
|
|
||||||
Matrix expectedH = numericalDerivative11<double, ParameterMatrix<M>, M * N>(
|
Matrix expectedH = numericalDerivative11<double, ParameterMatrix<M>, M * N>(
|
||||||
boost::bind(&CompFunc::operator(), fx, _1, nullptr), X);
|
std::bind(&CompFunc::operator(), fx, std::placeholders::_1, nullptr), X);
|
||||||
EXPECT(assert_equal(expectedH, actualH, 1e-7));
|
EXPECT(assert_equal(expectedH, actualH, 1e-7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue