28 #include <boost/assign/list_of.hpp> 29 #include <boost/assign/std/vector.hpp> 30 #include <boost/assign/std/map.hpp> 37 using namespace gtsam;
66 125.0000, 0.0, -25.0000, 0.0, -100.0000, 0.0, 25.0000,
67 0.0, 125.0000, 0.0, -25.0000, 0.0, -100.0000, -17.5000,
68 -25.0000, 0.0, 25.0000, 0.0, 0.0, 0.0, -5.0000,
69 0.0, -25.0000, 0.0, 25.0000, 0.0, 0.0, 7.5000,
70 -100.0000, 0.0, 0.0, 0.0, 100.0000, 0.0, -20.0000,
71 0.0, -100.0000, 0.0, 0.0, 0.0, 100.0000, 10.0000,
72 25.0000, -17.5000, -5.0000, 7.5000, -20.0000, 10.0000, 8.2500).finished()));
75 0, (
Matrix(4,2) << -1., 0.,
79 1, (
Matrix(4,4) << 1., 0., 0.00, 0.,
82 0., 0., 0.00, -1.).finished(),
83 (
Vector(4) << -0.2, 0.3, 0.2, -0.1).finished(),
84 noiseModel::Diagonal::Sigmas((
Vector(4) << 0.2, 0.2, 0.1, 0.1).finished()));
90 (1, (
Vector(4) << 3.0, 4.0, 5.0, 6.0).finished());
115 double actual = factor.
error(dx);
116 double expected_manual = 0.5 * (f - 2.0 * dx[0].dot(g) + dx[0].transpose() * G.selfadjointView<
Eigen::Upper>() * dx[0]);
131 double f =
dot(g,mu);
145 Matrix G22 = (
Matrix(2,2) << 3.0, 5.0, 5.0, 6.0).finished();
160 double actual = factor.
error(dx);
166 Vector linearExpected(3); linearExpected <<
g1,
g2;
188 Matrix G22 = (
Matrix(2,2) << 3.0, 5.0, 5.0, 6.0).finished();
189 Matrix G23 = (
Matrix(2,3) << 4.0, 6.0, 8.0, 1.0, 2.0, 4.0).finished();
191 Matrix G33 = (
Matrix(3,3) << 1.0, 2.0, 3.0, 2.0, 5.0, 6.0, 3.0, 6.0, 9.0).finished();
208 HessianFactor factor(0, 1, 2, G11, G12, G13, g1, G22, G23, g2, G33, g3, f);
211 double actual = factor.
error(dx);
217 Vector linearExpected(6); linearExpected <<
g1,
g2, g3;
235 Matrix G22 = (
Matrix(2,2) << 3.0, 5.0, 5.0, 6.0).finished();
236 Matrix G23 = (
Matrix(2,3) << 4.0, 6.0, 8.0, 1.0, 2.0, 4.0).finished();
238 Matrix G33 = (
Matrix(3,3) << 1.0, 2.0, 3.0, 2.0, 5.0, 6.0, 3.0, 6.0, 9.0).finished();
256 std::vector<Matrix> Gs;
257 Gs.push_back(G11); Gs.push_back(G12); Gs.push_back(G13); Gs.push_back(G22); Gs.push_back(G23); Gs.push_back(G33);
258 std::vector<Vector> gs;
259 gs.push_back(g1); gs.push_back(g2); gs.push_back(g3);
263 double actual = factor.
error(dx);
269 Vector linearExpected(6); linearExpected <<
g1,
g2, g3;
282 Matrix3 A01 = 3.0 * I_3x3;
285 Matrix3
A21 = 4.0 * I_3x3;
315 boost::tie(expectedConditional, expectedFactor) = jacobian.
eliminate(ordering);
316 CHECK(expectedFactor);
321 boost::tie(actualConditional, actualHessian) =
323 actualConditional->setModel(
false,
Vector3(1,1,1));
326 #ifdef TEST_ERROR_EQUIVALENCE 331 actualHessian->augmentedInformation(), 1
e-9));
352 gfg.
add(1, A01, b0, noiseModel::Diagonal::Sigmas(s0,
true));
353 gfg.
add(0, A10, 1, A11, b1, noiseModel::Diagonal::Sigmas(s1,
true));
354 gfg.
add(1, A21, b2, noiseModel::Diagonal::Sigmas(s2,
true));
357 A0 << A10, Z_3x3, Z_3x3;
361 sigmas << s1, s0, s2;
365 noiseModel::Diagonal::Sigmas(sigmas,
true));
378 boost::tie(expectedConditional, expectedFactor) =
384 boost::tie(actualConditional, actualHessian) =
386 actualConditional->setModel(
false,
Vector3(1,1,1));
389 #ifdef TEST_ERROR_EQUIVALENCE 396 actualHessian->augmentedInformation(), 1
e-9));
433 vector<pair<Key, Matrix> > meas;
434 meas.push_back(make_pair(0, Ax2));
435 meas.push_back(make_pair(1, Al1x1));
436 JacobianFactor combined(meas, b2, noiseModel::Diagonal::Sigmas(sigmas));
442 std::pair<GaussianConditional::shared_ptr, HessianFactor::shared_ptr> actual_Chol =
446 double oldSigma = 0.0894427;
450 ).finished()/oldSigma;
452 -0.20, 0.00,-0.80, 0.00,
453 +0.00,-0.20,+0.00,-0.80
454 ).finished()/oldSigma;
460 double sigma = 0.2236;
463 1.00, 0.00, -1.00, 0.00,
464 0.00, 1.00, +0.00, -1.00
467 JacobianFactor expectedLF(1, Bl1x1, b1, noiseModel::Isotropic::Sigma(2,1.0));
477 0.0, 11.1803399).finished();
480 0.0, -2.23606798).finished();
483 0.0, -8.94427191).finished();
493 125.0000, 0.0, -25.0000, 0.0, -100.0000, 0.0, 25.0000,
494 0.0, 125.0000, 0.0, -25.0000, 0.0, -100.0000, -17.5000,
495 -25.0000, 0.0, 5.0000, 0.0, 20.0000, 0.0, -5.0000,
496 0.0, -25.0000, 0.0, 5.0000, 0.0, 20.0000, 3.5000,
497 -100.0000, 0.0, 20.0000, 0.0, 80.0000, 0.0, -20.0000,
498 0.0, -100.0000, 0.0, 20.0000, 0.0, 80.0000, 14.0000,
499 25.0000, -17.5000, -5.0000, 3.5000, -20.0000, 14.0000, 7.4500).finished();
517 VectorValues expectedG = pair_list_of<Key, Vector>(0, -
g1) (1, -g2);
543 Vector expectedGrad1 = (
Vector(2) << 4.5, 16.1).finished();
581 Matrix2
G = A.transpose() * A;
589 expected.
insert(key, A.inverse() *
b);
Provides additional testing facilities for common data structures.
VectorValues gradientAtZero() const override
eta for Hessian
VectorValues solve()
Solve the system A'*A delta = A'*b in-place, return delta as VectorValues.
static int runAllTests(TestResult &result)
std::pair< boost::shared_ptr< GaussianConditional >, shared_ptr > eliminate(const Ordering &keys)
JacobiRotation< float > G
noiseModel::Diagonal::shared_ptr model
static enum @843 ordering
SymmetricBlockMatrix::constBlock linearTerm(const_iterator j) const
#define DOUBLES_EQUAL(expected, actual, threshold)
static const double sigma
GaussianFactorGraph factors(list_of(factor1)(factor2)(factor3))
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
void g(const string &key, int i)
Matrix augmentedInformation() const override
const SymmetricBlockMatrix & info() const
Return underlying information matrix.
double error(const VectorValues &c) const override
double constantTerm() const
void add(const GaussianFactor &factor)
std::pair< boost::shared_ptr< GaussianConditional >, boost::shared_ptr< HessianFactor > > EliminateCholesky(const GaussianFactorGraph &factors, const Ordering &keys)
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Scalar EIGEN_BLAS_FUNC() dot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
TEST(HessianFactor, Slot)
#define EXPECT(condition)
boost::shared_ptr< This > shared_ptr
A shared_ptr to this class.
Matrix information() const override
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Contains the HessianFactor class, a general quadratic factor.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void hessianDiagonal(double *d) const override
Raw memory access version of hessianDiagonal.
Conditional Gaussian Base class.
Linear Factor Graph where all factors are Gaussians.
constBlock aboveDiagonalBlock(DenseIndex I, DenseIndex J) const
Get block above the diagonal (I, J).
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
#define LONGS_EQUAL(expected, actual)
noiseModel::Diagonal::shared_ptr SharedDiagonal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
#define EXPECT_LONGS_EQUAL(expected, actual)
std::pair< Matrix, Vector > jacobian() const override
Return (dense) matrix associated with factor.
Matrix augmentedInformation() const override
Pose3 g1(Rot3(), Point3(100.0, 0.0, 300.0))
Eigen::SelfAdjointView< constBlock, Eigen::Upper > selfadjointView(DenseIndex I, DenseIndex J) const
Return the square sub-matrix that contains blocks(i:j, i:j).
double error(const VectorValues &c) const override
A Gaussian factor using the canonical parameters (information form)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
Eigen::SelfAdjointView< Block, Eigen::Upper > diagonalBlock(DenseIndex J)
Return the J'th diagonal block as a self adjoint view.
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Vector gradient(Key key, const VectorValues &x) const override
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Pose3 g2(g1.expmap(h *V1_g1))
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
iterator insert(const std::pair< Key, Vector > &key_value)
std::map< Key, Matrix > hessianBlockDiagonal() const override
Return the block diagonal of the Hessian for this factor.
std::uint64_t Key
Integer nonlinear key type.