From 76d478c0e0a2b486dd4e2aaebd8cd887df457f89 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Thu, 9 Jul 2015 12:07:59 -0700 Subject: [PATCH] Moved testing machinery to correct spot --- gtsam/nonlinear/expressionTesting.h | 33 ----------------------------- gtsam/nonlinear/factorTesting.h | 30 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/gtsam/nonlinear/expressionTesting.h b/gtsam/nonlinear/expressionTesting.h index f2f1c9578..b15592c00 100644 --- a/gtsam/nonlinear/expressionTesting.h +++ b/gtsam/nonlinear/expressionTesting.h @@ -20,44 +20,11 @@ #pragma once #include -#include #include -#include #include -#include - -#include -#include -#include namespace gtsam { -namespace internal { -// CPPUnitLite-style test for linearization of a factor -bool testFactorJacobians(TestResult& result_, const std::string& name_, - const NoiseModelFactor& factor, const gtsam::Values& values, double delta, - double tolerance) { - - // Create expected value by numerical differentiation - JacobianFactor expected = linearizeNumerically(factor, values, delta); - - // Create actual value by linearize - boost::shared_ptr actual = // - boost::dynamic_pointer_cast(factor.linearize(values)); - - // Check cast result and then equality - return actual && assert_equal(expected, *actual, tolerance); -} -} - -/// \brief Check the Jacobians produced by a factor against finite differences. -/// \param factor The factor to test. -/// \param values Values filled in for testing the Jacobians. -/// \param numerical_derivative_step The step to use when computing the numerical derivative Jacobians -/// \param tolerance The numerical tolerance to use when comparing Jacobians. -#define EXPECT_CORRECT_FACTOR_JACOBIANS(factor, values, numerical_derivative_step, tolerance) \ - { EXPECT(gtsam::internal::testFactorJacobians(result_, name_, factor, values, numerical_derivative_step, tolerance)); } - namespace internal { // CPPUnitLite-style test for linearization of an ExpressionFactor template diff --git a/gtsam/nonlinear/factorTesting.h b/gtsam/nonlinear/factorTesting.h index 442b29382..7709e1f1c 100644 --- a/gtsam/nonlinear/factorTesting.h +++ b/gtsam/nonlinear/factorTesting.h @@ -22,6 +22,10 @@ #include #include +#include +#include +#include + namespace gtsam { /** @@ -65,4 +69,30 @@ JacobianFactor linearizeNumerically(const NoiseModelFactor& factor, return JacobianFactor(jacobians, -e); } +namespace internal { +// CPPUnitLite-style test for linearization of a factor +bool testFactorJacobians(TestResult& result_, const std::string& name_, + const NoiseModelFactor& factor, const gtsam::Values& values, double delta, + double tolerance) { + + // Create expected value by numerical differentiation + JacobianFactor expected = linearizeNumerically(factor, values, delta); + + // Create actual value by linearize + boost::shared_ptr actual = // + boost::dynamic_pointer_cast(factor.linearize(values)); + + // Check cast result and then equality + return actual && assert_equal(expected, *actual, tolerance); +} +} + +/// \brief Check the Jacobians produced by a factor against finite differences. +/// \param factor The factor to test. +/// \param values Values filled in for testing the Jacobians. +/// \param numerical_derivative_step The step to use when computing the numerical derivative Jacobians +/// \param tolerance The numerical tolerance to use when comparing Jacobians. +#define EXPECT_CORRECT_FACTOR_JACOBIANS(factor, values, numerical_derivative_step, tolerance) \ + { EXPECT(gtsam::internal::testFactorJacobians(result_, name_, factor, values, numerical_derivative_step, tolerance)); } + } // namespace gtsam