gtsam 4.1.1
gtsam
expressionTesting.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
20#pragma once
21
22#include <gtsam/nonlinear/ExpressionFactor.h>
24#include <gtsam/base/Testable.h>
25
26namespace gtsam {
27
28namespace internal {
29// CPPUnitLite-style test for linearization of an ExpressionFactor
30template<typename T>
31bool testExpressionJacobians(const std::string& name_,
32 const gtsam::Expression<T>& expression, const gtsam::Values& values,
33 double nd_step, double tolerance) {
34 // Create factor
35 size_t size = traits<T>::dimension;
36 ExpressionFactor<T> f(noiseModel::Unit::Create(size),
37 expression.value(values), expression);
38 return testFactorJacobians(name_, f, values, nd_step, tolerance);
39}
40} // namespace internal
41} // namespace gtsam
42
48#define EXPECT_CORRECT_EXPRESSION_JACOBIANS(expression, values, numerical_derivative_step, tolerance) \
49 { EXPECT(gtsam::internal::testExpressionJacobians(name_, expression, values, numerical_derivative_step, tolerance)); }
Concept check for values that can be used in unit tests.
Evaluate derivatives of a nonlinear factor numerically.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
static shared_ptr Create(size_t dim)
Create a unit covariance noise model.
Definition: NoiseModel.h:611
Expression class that supports automatic differentiation.
Definition: Expression.h:48
T value(const Values &values, boost::optional< std::vector< Matrix > & > H=boost::none) const
Return value and optional derivatives, reverse AD version Notes: this is not terribly efficient,...
Definition: Expression-inl.h:140
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:63