diff --git a/.cproject b/.cproject index 872909c06..2145af336 100644 --- a/.cproject +++ b/.cproject @@ -1,7 +1,5 @@ - - - + @@ -309,14 +307,6 @@ true true - - make - -j2 - testGaussianFactor.run - true - true - true - make -j2 @@ -343,6 +333,7 @@ make + tests/testBayesTree.run true false @@ -350,6 +341,7 @@ make + testBinaryBayesNet.run true false @@ -397,6 +389,7 @@ make + testSymbolicBayesNet.run true false @@ -404,6 +397,7 @@ make + tests/testSymbolicFactor.run true false @@ -411,6 +405,7 @@ make + testSymbolicFactorGraph.run true false @@ -426,11 +421,20 @@ make + tests/testBayesTree true false true + + make + -j2 + testGaussianFactor.run + true + true + true + make -j5 @@ -527,22 +531,6 @@ false true - - make - -j2 - all - true - true - true - - - make - -j2 - clean - true - true - true - make -j2 @@ -559,6 +547,22 @@ true true + + make + -j2 + all + true + true + true + + + make + -j2 + clean + true + true + true + make -j2 @@ -583,34 +587,26 @@ true true - + make - -j5 - testValues.run + -j2 + all true true true - + make - -j5 - testOrdering.run + -j2 + check true true true - + make - -j5 - testKey.run - true - true - true - - - make - -j5 - testLinearContainerFactor.run + -j2 + clean true true true @@ -695,26 +691,34 @@ true true - + make - -j2 - all + -j5 + testValues.run true true true - + make - -j2 - check + -j5 + testOrdering.run true true true - + make - -j2 - clean + -j5 + testKey.run + true + true + true + + + make + -j5 + testLinearContainerFactor.run true true true @@ -919,6 +923,14 @@ true true + + make + -j5 + testBayesTreeOperations.run + true + true + true + make -j5 @@ -1073,6 +1085,7 @@ make + testGraph.run true false @@ -1080,6 +1093,7 @@ make + testJunctionTree.run true false @@ -1087,6 +1101,7 @@ make + testSymbolicBayesNetB.run true false @@ -1254,6 +1269,7 @@ make + testErrors.run true false @@ -1299,14 +1315,6 @@ true true - - make - -j2 - testGaussianFactor.run - true - true - true - make -j2 @@ -1387,6 +1395,14 @@ true true + + make + -j2 + testGaussianFactor.run + true + true + true + make -j2 @@ -1701,7 +1717,6 @@ make - testSimulated2DOriented.run true false @@ -1741,7 +1756,6 @@ make - testSimulated2D.run true false @@ -1749,7 +1763,6 @@ make - testSimulated3D.run true false @@ -1949,7 +1962,6 @@ make - tests/testGaussianISAM2 true false @@ -1971,102 +1983,6 @@ true true - - make - -j2 - testRot3.run - true - true - true - - - make - -j2 - testRot2.run - true - true - true - - - make - -j2 - testPose3.run - true - true - true - - - make - -j2 - timeRot3.run - true - true - true - - - make - -j2 - testPose2.run - true - true - true - - - make - -j2 - testCal3_S2.run - true - true - true - - - make - -j2 - testSimpleCamera.run - true - true - true - - - make - -j2 - testHomography2.run - true - true - true - - - make - -j2 - testCalibratedCamera.run - true - true - true - - - make - -j2 - check - true - true - true - - - make - -j2 - clean - true - true - true - - - make - -j2 - testPoint2.run - true - true - true - make -j3 @@ -2268,6 +2184,7 @@ cpack + -G DEB true false @@ -2275,6 +2192,7 @@ cpack + -G RPM true false @@ -2282,6 +2200,7 @@ cpack + -G TGZ true false @@ -2289,6 +2208,7 @@ cpack + --config CPackSourceConfig.cmake true false @@ -2430,34 +2350,98 @@ true true - + make - -j5 - testSpirit.run + -j2 + testRot3.run true true true - + make - -j5 - testWrap.run + -j2 + testRot2.run true true true - + make - -j5 - check.wrap + -j2 + testPose3.run true true true - + make - -j5 - wrap + -j2 + timeRot3.run + true + true + true + + + make + -j2 + testPose2.run + true + true + true + + + make + -j2 + testCal3_S2.run + true + true + true + + + make + -j2 + testSimpleCamera.run + true + true + true + + + make + -j2 + testHomography2.run + true + true + true + + + make + -j2 + testCalibratedCamera.run + true + true + true + + + make + -j2 + check + true + true + true + + + make + -j2 + clean + true + true + true + + + make + -j2 + testPoint2.run true true true @@ -2501,6 +2485,38 @@ false true + + make + -j5 + testSpirit.run + true + true + true + + + make + -j5 + testWrap.run + true + true + true + + + make + -j5 + check.wrap + true + true + true + + + make + -j5 + wrap + true + true + true + diff --git a/gtsam_unstable/linear/tests/testBayesTreeOperations.cpp b/gtsam_unstable/linear/tests/testBayesTreeOperations.cpp index b1c833f2c..cccd47aac 100644 --- a/gtsam_unstable/linear/tests/testBayesTreeOperations.cpp +++ b/gtsam_unstable/linear/tests/testBayesTreeOperations.cpp @@ -10,6 +10,9 @@ #include #include +#include + +#include using namespace gtsam; @@ -17,8 +20,15 @@ SharedDiagonal model2 = noiseModel::Diagonal::Sigmas(ones(2)); SharedDiagonal model4 = noiseModel::Diagonal::Sigmas(ones(4)); SharedDiagonal model6 = noiseModel::Diagonal::Sigmas(ones(6)); +using namespace std; + +using symbol_shorthand::X; +using symbol_shorthand::L; + +static const double tol = 1e-4; + /* ************************************************************************* */ -TEST( testLinearTools, splitFactor ) { +TEST( testBayesTreeOperations, splitFactor ) { // Build upper-triangular system JacobianFactor initFactor( @@ -120,6 +130,107 @@ TEST_UNSAFE( testLinearTools, splitFactor2 ) { EXPECT(assert_equal(expSplit, actSplit)); } +/* ************************************************************************* */ +// Some numbers that should be consistent among all smoother tests + +//static double sigmax1 = 0.786153, /*sigmax2 = 1.0/1.47292,*/ sigmax3 = 0.671512, sigmax4 = +// 0.669534 /*, sigmax5 = sigmax3, sigmax6 = sigmax2*/, sigmax7 = sigmax1; + +/* ************************************************************************* */ +TEST( testBayesTreeOperations, liquefy ) { + using namespace example; + + // Create smoother with 7 nodes + Ordering ordering; + ordering += X(1),X(3),X(5),X(7),X(2),X(6),X(4); + GaussianFactorGraph smoother = createSmoother(7, ordering).first; + + // Create the Bayes tree + GaussianBayesTree bayesTree = *GaussianMultifrontalSolver(smoother).eliminate(); +// bayesTree.print("Full tree"); + + SharedDiagonal unit6 = noiseModel::Diagonal::Sigmas(Vector_(ones(6))); + SharedDiagonal unit4 = noiseModel::Diagonal::Sigmas(Vector_(ones(4))); + SharedDiagonal unit2 = noiseModel::Diagonal::Sigmas(Vector_(ones(2))); + + // Liquefy the tree back into a graph + { + GaussianFactorGraph actGraph = liquefy(bayesTree, false); // Doesn't split conditionals + GaussianFactorGraph expGraph; + + Matrix A12 = Matrix_(6, 2, + 1.73205081, 0.0, + 0.0, 1.73205081, + 0.0, 0.0, + 0.0, 0.0, + 0.0, 0.0, + 0.0, 0.0); + + Matrix A15 = Matrix_(6, 2, + -0.577350269, 0.0, + 0.0, -0.577350269, + 1.47196014, 0.0, + 0.0, 1.47196014, + 0.0, 0.0, + 0.0, 0.0); + + Matrix A16 = Matrix_(6, 2, + -0.577350269, 0.0, + 0.0, -0.577350269, + -0.226455407, 0.0, + 0.0, -0.226455407, + 1.49357599, 0.0, + 0.0, 1.49357599); + expGraph.add(2, A12, 5, A15, 6, A16, zeros(6,1), unit6); + + Matrix A21 = Matrix_(4, 2, + 1.73205081, 0.0, + 0.0, 1.73205081, + 0.0, 0.0, + 0.0, 0.0); + + Matrix A24 = Matrix_(4, 2, + -0.577350269, 0.0, + 0.0, -0.577350269, + 1.47196014, 0.0, + 0.0, 1.47196014); + + Matrix A26 = Matrix_(4, 2, + -0.577350269, 0.0, + 0.0, -0.577350269, + -0.226455407, 0.0, + 0.0, -0.226455407); + + expGraph.add(1, A21, 4, A24, 6, A26, zeros(4,1), unit4); + + Matrix A30 = Matrix_(2, 2, + 1.41421356, 0.0, + 0.0, 1.41421356); + + Matrix A34 = Matrix_(2, 2, + -0.707106781, 0.0, + 0.0, -0.707106781); + + expGraph.add(0, A30, 4, A34, zeros(2,1), unit2); + + Matrix A43 = Matrix_(2, 2, + 1.41421356, 0.0, + 0.0, 1.41421356); + Matrix A45 = Matrix_(2, 2, + -0.707106781, 0.0, + 0.0, -0.707106781); + + expGraph.add(3, A43, 5, A45, zeros(2,1), unit2); + + EXPECT(assert_equal(expGraph, actGraph)); + LONGS_EQUAL(4, actGraph.size()); + EXPECT(assert_equal(*expGraph.at(0), *actGraph.at(0))); + EXPECT(assert_equal(*expGraph.at(1), *actGraph.at(1))); + EXPECT(assert_equal(*expGraph.at(2), *actGraph.at(2))); + EXPECT(assert_equal(*expGraph.at(3), *actGraph.at(3))); + } +} + /* ************************************************************************* */ int main() { TestResult tr; return TestRegistry::runAllTests(tr); } /* ************************************************************************* */