Got rid of boost::assign in many tests
							parent
							
								
									d2f0cf5cc7
								
							
						
					
					
						commit
						017cd8f8a2
					
				|  | @ -16,17 +16,14 @@ | |||
|  * @brief unit tests for DSFMap | ||||
|  */ | ||||
| 
 | ||||
| #include <CppUnitLite/TestHarness.h> | ||||
| #include <gtsam/base/DSFMap.h> | ||||
| 
 | ||||
| #include <boost/assign/std/list.hpp> | ||||
| #include <boost/assign/std/set.hpp> | ||||
| using namespace boost::assign; | ||||
| 
 | ||||
| #include <CppUnitLite/TestHarness.h> | ||||
| 
 | ||||
| #include <iostream> | ||||
| #include <list> | ||||
| #include <map> | ||||
| #include <set> | ||||
| 
 | ||||
| using namespace std; | ||||
| using namespace gtsam; | ||||
| 
 | ||||
| /* ************************************************************************* */ | ||||
|  | @ -65,9 +62,8 @@ TEST(DSFMap, merge3) { | |||
| TEST(DSFMap, mergePairwiseMatches) { | ||||
| 
 | ||||
|   // Create some "matches"
 | ||||
|   typedef pair<size_t,size_t> Match; | ||||
|   list<Match> matches; | ||||
|   matches += Match(1,2), Match(2,3), Match(4,5), Match(4,6); | ||||
|   typedef std::pair<size_t, size_t> Match; | ||||
|   const std::list<Match> matches{{1, 2}, {2, 3}, {4, 5}, {4, 6}}; | ||||
| 
 | ||||
|   // Merge matches
 | ||||
|   DSFMap<size_t> dsf; | ||||
|  | @ -86,18 +82,17 @@ TEST(DSFMap, mergePairwiseMatches) { | |||
| TEST(DSFMap, mergePairwiseMatches2) { | ||||
| 
 | ||||
|   // Create some measurements with image index and feature index
 | ||||
|   typedef pair<size_t,size_t> Measurement; | ||||
|   typedef std::pair<size_t,size_t> Measurement; | ||||
|   Measurement m11(1,1),m12(1,2),m14(1,4); // in image 1
 | ||||
|   Measurement m22(2,2),m23(2,3),m25(2,5),m26(2,6); // in image 2
 | ||||
| 
 | ||||
|   // Add them all
 | ||||
|   list<Measurement> measurements; | ||||
|   measurements += m11,m12,m14, m22,m23,m25,m26; | ||||
|   const std::list<Measurement> measurements{m11, m12, m14, m22, m23, m25, m26}; | ||||
| 
 | ||||
|   // Create some "matches"
 | ||||
|   typedef pair<Measurement,Measurement> Match; | ||||
|   list<Match> matches; | ||||
|   matches += Match(m11,m22), Match(m12,m23), Match(m14,m25), Match(m14,m26); | ||||
|   typedef std::pair<Measurement, Measurement> Match; | ||||
|   const std::list<Match> matches{ | ||||
|       {m11, m22}, {m12, m23}, {m14, m25}, {m14, m26}}; | ||||
| 
 | ||||
|   // Merge matches
 | ||||
|   DSFMap<Measurement> dsf; | ||||
|  | @ -114,26 +109,16 @@ TEST(DSFMap, mergePairwiseMatches2) { | |||
| /* ************************************************************************* */ | ||||
| TEST(DSFMap, sets){ | ||||
|   // Create some "matches"
 | ||||
|   typedef pair<size_t,size_t> Match; | ||||
|   list<Match> matches; | ||||
|   matches += Match(1,2), Match(2,3), Match(4,5), Match(4,6); | ||||
|   typedef const std::pair<size_t,size_t> Match; | ||||
|   const std::list<Match> matches{{1, 2}, {2, 3}, {4, 5}, {4, 6}}; | ||||
| 
 | ||||
|   // Merge matches
 | ||||
|   DSFMap<size_t> dsf; | ||||
|   for(const Match& m: matches) | ||||
|     dsf.merge(m.first,m.second); | ||||
| 
 | ||||
|   map<size_t, set<size_t> > sets = dsf.sets(); | ||||
|   set<size_t> s1, s2; | ||||
|   s1 += 1,2,3; | ||||
|   s2 += 4,5,6; | ||||
| 
 | ||||
|   /*for(key_pair st: sets){
 | ||||
|     cout << "Set " << st.first << " :{"; | ||||
|     for(const size_t s: st.second) | ||||
|       cout << s << ", "; | ||||
|     cout << "}" << endl; | ||||
|   }*/ | ||||
|   std::map<size_t, std::set<size_t> > sets = dsf.sets(); | ||||
|   const std::set<size_t> s1{1, 2, 3}, s2{4, 5, 6}; | ||||
| 
 | ||||
|   EXPECT(s1 == sets[1]); | ||||
|   EXPECT(s2 == sets[4]); | ||||
|  |  | |||
|  | @ -21,14 +21,15 @@ | |||
| #include <CppUnitLite/TestHarness.h> | ||||
| 
 | ||||
| #include <boost/make_shared.hpp> | ||||
| #include <boost/assign/std/list.hpp> | ||||
| #include <boost/assign/std/set.hpp> | ||||
| #include <boost/assign/std/vector.hpp> | ||||
| using namespace boost::assign; | ||||
| 
 | ||||
| #include <iostream> | ||||
| #include <set> | ||||
| #include <list> | ||||
| #include <utility> | ||||
| 
 | ||||
| using namespace std; | ||||
| using std::pair; | ||||
| using std::map; | ||||
| using std::vector; | ||||
| using namespace gtsam; | ||||
| 
 | ||||
| /* ************************************************************************* */ | ||||
|  | @ -64,8 +65,8 @@ TEST(DSFBase, mergePairwiseMatches) { | |||
| 
 | ||||
|   // Create some "matches"
 | ||||
|   typedef pair<size_t,size_t> Match; | ||||
|   vector<Match> matches; | ||||
|   matches += Match(1,2), Match(2,3), Match(4,5), Match(4,6); | ||||
|   const vector<Match> matches{Match(1, 2), Match(2, 3), Match(4, 5), | ||||
|                               Match(4, 6)}; | ||||
| 
 | ||||
|   // Merge matches
 | ||||
|   DSFBase dsf(7); // We allow for keys 0..6
 | ||||
|  | @ -85,7 +86,7 @@ TEST(DSFBase, mergePairwiseMatches) { | |||
| /* ************************************************************************* */ | ||||
| TEST(DSFVector, merge2) { | ||||
|   boost::shared_ptr<DSFBase::V> v = boost::make_shared<DSFBase::V>(5); | ||||
|   std::vector<size_t> keys; keys += 1, 3; | ||||
|   const std::vector<size_t> keys {1, 3}; | ||||
|   DSFVector dsf(v, keys); | ||||
|   dsf.merge(1,3); | ||||
|   EXPECT(dsf.find(1) == dsf.find(3)); | ||||
|  | @ -95,10 +96,10 @@ TEST(DSFVector, merge2) { | |||
| TEST(DSFVector, sets) { | ||||
|   DSFVector dsf(2); | ||||
|   dsf.merge(0,1); | ||||
|   map<size_t, set<size_t> > sets = dsf.sets(); | ||||
|   map<size_t, std::set<size_t> > sets = dsf.sets(); | ||||
|   LONGS_EQUAL(1, sets.size()); | ||||
| 
 | ||||
|   set<size_t> expected; expected += 0, 1; | ||||
|   const std::set<size_t> expected{0, 1}; | ||||
|   EXPECT(expected == sets[dsf.find(0)]); | ||||
| } | ||||
| 
 | ||||
|  | @ -109,7 +110,7 @@ TEST(DSFVector, arrays) { | |||
|   map<size_t, vector<size_t> > arrays = dsf.arrays(); | ||||
|   LONGS_EQUAL(1, arrays.size()); | ||||
| 
 | ||||
|   vector<size_t> expected; expected += 0, 1; | ||||
|   const vector<size_t> expected{0, 1}; | ||||
|   EXPECT(expected == arrays[dsf.find(0)]); | ||||
| } | ||||
| 
 | ||||
|  | @ -118,10 +119,10 @@ TEST(DSFVector, sets2) { | |||
|   DSFVector dsf(3); | ||||
|   dsf.merge(0,1); | ||||
|   dsf.merge(1,2); | ||||
|   map<size_t, set<size_t> > sets = dsf.sets(); | ||||
|   map<size_t, std::set<size_t> > sets = dsf.sets(); | ||||
|   LONGS_EQUAL(1, sets.size()); | ||||
| 
 | ||||
|   set<size_t> expected; expected += 0, 1, 2; | ||||
|   const std::set<size_t> expected{0, 1, 2}; | ||||
|   EXPECT(expected == sets[dsf.find(0)]); | ||||
| } | ||||
| 
 | ||||
|  | @ -133,7 +134,7 @@ TEST(DSFVector, arrays2) { | |||
|   map<size_t, vector<size_t> > arrays = dsf.arrays(); | ||||
|   LONGS_EQUAL(1, arrays.size()); | ||||
| 
 | ||||
|   vector<size_t> expected; expected += 0, 1, 2; | ||||
|   const vector<size_t> expected{0, 1, 2}; | ||||
|   EXPECT(expected == arrays[dsf.find(0)]); | ||||
| } | ||||
| 
 | ||||
|  | @ -141,10 +142,10 @@ TEST(DSFVector, arrays2) { | |||
| TEST(DSFVector, sets3) { | ||||
|   DSFVector dsf(3); | ||||
|   dsf.merge(0,1); | ||||
|   map<size_t, set<size_t> > sets = dsf.sets(); | ||||
|   map<size_t, std::set<size_t> > sets = dsf.sets(); | ||||
|   LONGS_EQUAL(2, sets.size()); | ||||
| 
 | ||||
|   set<size_t> expected; expected += 0, 1; | ||||
|   const std::set<size_t> expected{0, 1}; | ||||
|   EXPECT(expected == sets[dsf.find(0)]); | ||||
| } | ||||
| 
 | ||||
|  | @ -155,7 +156,7 @@ TEST(DSFVector, arrays3) { | |||
|   map<size_t, vector<size_t> > arrays = dsf.arrays(); | ||||
|   LONGS_EQUAL(2, arrays.size()); | ||||
| 
 | ||||
|   vector<size_t> expected; expected += 0, 1; | ||||
|   const vector<size_t> expected{0, 1}; | ||||
|   EXPECT(expected == arrays[dsf.find(0)]); | ||||
| } | ||||
| 
 | ||||
|  | @ -163,10 +164,10 @@ TEST(DSFVector, arrays3) { | |||
| TEST(DSFVector, set) { | ||||
|   DSFVector dsf(3); | ||||
|   dsf.merge(0,1); | ||||
|   set<size_t> set = dsf.set(0); | ||||
|   std::set<size_t> set = dsf.set(0); | ||||
|   LONGS_EQUAL(2, set.size()); | ||||
| 
 | ||||
|   std::set<size_t> expected; expected += 0, 1; | ||||
|   const std::set<size_t> expected{0, 1}; | ||||
|   EXPECT(expected == set); | ||||
| } | ||||
| 
 | ||||
|  | @ -175,10 +176,10 @@ TEST(DSFVector, set2) { | |||
|   DSFVector dsf(3); | ||||
|   dsf.merge(0,1); | ||||
|   dsf.merge(1,2); | ||||
|   set<size_t> set = dsf.set(0); | ||||
|   std::set<size_t> set = dsf.set(0); | ||||
|   LONGS_EQUAL(3, set.size()); | ||||
| 
 | ||||
|   std::set<size_t> expected; expected += 0, 1, 2; | ||||
|   const std::set<size_t> expected{0, 1, 2}; | ||||
|   EXPECT(expected == set); | ||||
| } | ||||
| 
 | ||||
|  | @ -195,13 +196,12 @@ TEST(DSFVector, isSingleton) { | |||
| TEST(DSFVector, mergePairwiseMatches) { | ||||
| 
 | ||||
|   // Create some measurements
 | ||||
|   vector<size_t> keys; | ||||
|   keys += 1,2,3,4,5,6; | ||||
|   const vector<size_t> keys{1, 2, 3, 4, 5, 6}; | ||||
| 
 | ||||
|   // Create some "matches"
 | ||||
|   typedef pair<size_t,size_t> Match; | ||||
|   vector<Match> matches; | ||||
|   matches += Match(1,2), Match(2,3), Match(4,5), Match(4,6); | ||||
|   const vector<Match> matches{Match(1, 2), Match(2, 3), Match(4, 5), | ||||
|                               Match(4, 6)}; | ||||
| 
 | ||||
|   // Merge matches
 | ||||
|   DSFVector dsf(keys); | ||||
|  | @ -209,13 +209,13 @@ TEST(DSFVector, mergePairwiseMatches) { | |||
|     dsf.merge(m.first,m.second); | ||||
| 
 | ||||
|   // Check that we have two connected components, 1,2,3 and 4,5,6
 | ||||
|   map<size_t, set<size_t> > sets = dsf.sets(); | ||||
|   map<size_t, std::set<size_t> > sets = dsf.sets(); | ||||
|   LONGS_EQUAL(2, sets.size()); | ||||
|   set<size_t> expected1; expected1 += 1,2,3; | ||||
|   set<size_t> actual1 = sets[dsf.find(2)]; | ||||
|   const std::set<size_t> expected1{1, 2, 3}; | ||||
|   std::set<size_t> actual1 = sets[dsf.find(2)]; | ||||
|   EXPECT(expected1 == actual1); | ||||
|   set<size_t> expected2; expected2 += 4,5,6; | ||||
|   set<size_t> actual2 = sets[dsf.find(5)]; | ||||
|   const std::set<size_t> expected2{4, 5, 6}; | ||||
|   std::set<size_t> actual2 = sets[dsf.find(5)]; | ||||
|   EXPECT(expected2 == actual2); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,12 +11,8 @@ | |||
| #include <gtsam/base/FastSet.h> | ||||
| #include <gtsam/base/FastVector.h> | ||||
| 
 | ||||
| #include <boost/assign/std/vector.hpp> | ||||
| #include <boost/assign/std/set.hpp> | ||||
| 
 | ||||
| #include <CppUnitLite/TestHarness.h> | ||||
| 
 | ||||
| using namespace boost::assign; | ||||
| using namespace gtsam; | ||||
| 
 | ||||
| /* ************************************************************************* */ | ||||
|  | @ -25,7 +21,7 @@ TEST( testFastContainers, KeySet ) { | |||
|   KeyVector init_vector {2, 3, 4, 5}; | ||||
| 
 | ||||
|   KeySet actSet(init_vector); | ||||
|   KeySet expSet; expSet += 2, 3, 4, 5; | ||||
|   KeySet expSet{2, 3, 4, 5}; | ||||
|   EXPECT(actSet == expSet); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,14 +17,12 @@ | |||
| 
 | ||||
| #include <CppUnitLite/TestHarness.h> | ||||
| #include <gtsam/base/SymmetricBlockMatrix.h> | ||||
| #include <boost/assign/list_of.hpp> | ||||
| 
 | ||||
| using namespace std; | ||||
| using namespace gtsam; | ||||
| using boost::assign::list_of; | ||||
| 
 | ||||
| static SymmetricBlockMatrix testBlockMatrix( | ||||
|   list_of(3)(2)(1), | ||||
|   std::vector<size_t>{3, 2, 1}, | ||||
|   (Matrix(6, 6) << | ||||
|   1, 2, 3, 4, 5, 6, | ||||
|   2, 8, 9, 10, 11, 12, | ||||
|  | @ -101,7 +99,8 @@ TEST(SymmetricBlockMatrix, Ranges) | |||
| /* ************************************************************************* */ | ||||
| TEST(SymmetricBlockMatrix, expressions) | ||||
| { | ||||
|   SymmetricBlockMatrix expected1(list_of(2)(3)(1), (Matrix(6, 6) << | ||||
|   const std::vector<size_t> dimensions{2, 3, 1}; | ||||
|   SymmetricBlockMatrix expected1(dimensions, (Matrix(6, 6) << | ||||
|     0, 0, 0, 0, 0, 0, | ||||
|     0, 0, 0, 0, 0, 0, | ||||
|     0, 0, 4, 6, 8, 0, | ||||
|  | @ -109,7 +108,7 @@ TEST(SymmetricBlockMatrix, expressions) | |||
|     0, 0, 0, 0, 16, 0, | ||||
|     0, 0, 0, 0, 0, 0).finished()); | ||||
| 
 | ||||
|   SymmetricBlockMatrix expected2(list_of(2)(3)(1), (Matrix(6, 6) << | ||||
|   SymmetricBlockMatrix expected2(dimensions, (Matrix(6, 6) << | ||||
|     0, 0, 10, 15, 20, 0, | ||||
|     0, 0, 12, 18, 24, 0, | ||||
|     0, 0, 0, 0, 0, 0, | ||||
|  | @ -120,32 +119,32 @@ TEST(SymmetricBlockMatrix, expressions) | |||
|   Matrix a = (Matrix(1, 3) << 2, 3, 4).finished(); | ||||
|   Matrix b = (Matrix(1, 2) << 5, 6).finished(); | ||||
| 
 | ||||
|   SymmetricBlockMatrix bm1(list_of(2)(3)(1)); | ||||
|   SymmetricBlockMatrix bm1(dimensions); | ||||
|   bm1.setZero(); | ||||
|   bm1.diagonalBlock(1).rankUpdate(a.transpose()); | ||||
|   EXPECT(assert_equal(Matrix(expected1.selfadjointView()), bm1.selfadjointView())); | ||||
| 
 | ||||
|   SymmetricBlockMatrix bm2(list_of(2)(3)(1)); | ||||
|   SymmetricBlockMatrix bm2(dimensions); | ||||
|   bm2.setZero(); | ||||
|   bm2.updateOffDiagonalBlock(0, 1, b.transpose() * a); | ||||
|   EXPECT(assert_equal(Matrix(expected2.selfadjointView()), bm2.selfadjointView())); | ||||
| 
 | ||||
|   SymmetricBlockMatrix bm3(list_of(2)(3)(1)); | ||||
|   SymmetricBlockMatrix bm3(dimensions); | ||||
|   bm3.setZero(); | ||||
|   bm3.updateOffDiagonalBlock(1, 0, a.transpose() * b); | ||||
|   EXPECT(assert_equal(Matrix(expected2.selfadjointView()), bm3.selfadjointView())); | ||||
| 
 | ||||
|   SymmetricBlockMatrix bm4(list_of(2)(3)(1)); | ||||
|   SymmetricBlockMatrix bm4(dimensions); | ||||
|   bm4.setZero(); | ||||
|   bm4.updateDiagonalBlock(1, expected1.diagonalBlock(1)); | ||||
|   EXPECT(assert_equal(Matrix(expected1.selfadjointView()), bm4.selfadjointView())); | ||||
| 
 | ||||
|   SymmetricBlockMatrix bm5(list_of(2)(3)(1)); | ||||
|   SymmetricBlockMatrix bm5(dimensions); | ||||
|   bm5.setZero(); | ||||
|   bm5.updateOffDiagonalBlock(0, 1, expected2.aboveDiagonalBlock(0, 1)); | ||||
|   EXPECT(assert_equal(Matrix(expected2.selfadjointView()), bm5.selfadjointView())); | ||||
| 
 | ||||
|   SymmetricBlockMatrix bm6(list_of(2)(3)(1)); | ||||
|   SymmetricBlockMatrix bm6(dimensions); | ||||
|   bm6.setZero(); | ||||
|   bm6.updateOffDiagonalBlock(1, 0, expected2.aboveDiagonalBlock(0, 1).transpose()); | ||||
|   EXPECT(assert_equal(Matrix(expected2.selfadjointView()), bm6.selfadjointView())); | ||||
|  | @ -162,7 +161,8 @@ TEST(SymmetricBlockMatrix, inverseInPlace) { | |||
|   inputMatrix += c * c.transpose(); | ||||
|   const Matrix expectedInverse = inputMatrix.inverse(); | ||||
| 
 | ||||
|   SymmetricBlockMatrix symmMatrix(list_of(2)(1), inputMatrix); | ||||
|   const std::vector<size_t> dimensions{2, 1}; | ||||
|   SymmetricBlockMatrix symmMatrix(dimensions, inputMatrix); | ||||
|   // invert in place
 | ||||
|   symmMatrix.invertInPlace(); | ||||
|   EXPECT(assert_equal(expectedInverse, symmMatrix.selfadjointView())); | ||||
|  |  | |||
|  | @ -23,16 +23,13 @@ | |||
| #include <list> | ||||
| #include <boost/shared_ptr.hpp> | ||||
| #include <boost/make_shared.hpp> | ||||
| #include <boost/assign/std/list.hpp> | ||||
| 
 | ||||
| using boost::assign::operator+=; | ||||
| using namespace std; | ||||
| using namespace gtsam; | ||||
| 
 | ||||
| struct TestNode { | ||||
|   typedef boost::shared_ptr<TestNode> shared_ptr; | ||||
|   int data; | ||||
|   vector<shared_ptr> children; | ||||
|   std::vector<shared_ptr> children; | ||||
|   TestNode() : data(-1) {} | ||||
|   TestNode(int data) : data(data) {} | ||||
| }; | ||||
|  | @ -110,10 +107,8 @@ TEST(treeTraversal, DepthFirst) | |||
|   TestForest testForest = makeTestForest(); | ||||
| 
 | ||||
|   // Expected visit order
 | ||||
|   std::list<int> preOrderExpected; | ||||
|   preOrderExpected += 0, 2, 3, 4, 1; | ||||
|   std::list<int> postOrderExpected; | ||||
|   postOrderExpected += 2, 4, 3, 0, 1; | ||||
|   const std::list<int> preOrderExpected{0, 2, 3, 4, 1}; | ||||
|   const std::list<int> postOrderExpected{2, 4, 3, 0, 1}; | ||||
| 
 | ||||
|   // Actual visit order
 | ||||
|   PreOrderVisitor preVisitor; | ||||
|  | @ -135,8 +130,7 @@ TEST(treeTraversal, CloneForest) | |||
|   testForest2.roots_ = treeTraversal::CloneForest(testForest1); | ||||
| 
 | ||||
|   // Check that the original and clone both are expected
 | ||||
|   std::list<int> preOrder1Expected; | ||||
|   preOrder1Expected += 0, 2, 3, 4, 1; | ||||
|   const std::list<int> preOrder1Expected{0, 2, 3, 4, 1}; | ||||
|   std::list<int> preOrder1Actual = getPreorder(testForest1); | ||||
|   std::list<int> preOrder2Actual = getPreorder(testForest2); | ||||
|   EXPECT(assert_container_equality(preOrder1Expected, preOrder1Actual)); | ||||
|  | @ -144,8 +138,7 @@ TEST(treeTraversal, CloneForest) | |||
| 
 | ||||
|   // Modify clone - should not modify original
 | ||||
|   testForest2.roots_[0]->children[1]->data = 10; | ||||
|   std::list<int> preOrderModifiedExpected; | ||||
|   preOrderModifiedExpected += 0, 2, 10, 4, 1; | ||||
|   const std::list<int> preOrderModifiedExpected{0, 2, 10, 4, 1}; | ||||
| 
 | ||||
|   // Check that original is the same and only the clone is modified
 | ||||
|   std::list<int> preOrder1ModActual = getPreorder(testForest1); | ||||
|  |  | |||
|  | @ -18,14 +18,14 @@ | |||
| 
 | ||||
| #include <CppUnitLite/TestHarness.h> | ||||
| #include <gtsam/base/VerticalBlockMatrix.h> | ||||
| #include <boost/assign/list_of.hpp> | ||||
| 
 | ||||
| using namespace std; | ||||
| #include<list> | ||||
| #include<vector> | ||||
| 
 | ||||
| using namespace gtsam; | ||||
| using boost::assign::list_of; | ||||
| 
 | ||||
| list<size_t> L = list_of(3)(2)(1); | ||||
| vector<size_t> dimensions(L.begin(),L.end()); | ||||
| const std::list<size_t> L{3, 2, 1}; | ||||
| const std::vector<size_t> dimensions(L.begin(), L.end()); | ||||
| 
 | ||||
| //*****************************************************************************
 | ||||
| TEST(VerticalBlockMatrix, Constructor1) { | ||||
|  |  | |||
|  | @ -399,13 +399,9 @@ TEST(ADT, factor_graph) { | |||
| /* ************************************************************************* */ | ||||
| // test equality
 | ||||
| TEST(ADT, equality_noparser) { | ||||
|   DiscreteKey A(0, 2), B(1, 2); | ||||
|   Signature::Table tableA, tableB; | ||||
|   Signature::Row rA, rB; | ||||
|   rA += 80, 20; | ||||
|   rB += 60, 40; | ||||
|   tableA += rA; | ||||
|   tableB += rB; | ||||
|   const DiscreteKey A(0, 2), B(1, 2); | ||||
|   const Signature::Row rA{80, 20}, rB{60, 40}; | ||||
|   const Signature::Table tableA{rA}, tableB{rB}; | ||||
| 
 | ||||
|   // Check straight equality
 | ||||
|   ADT pA1 = create(A % tableA); | ||||
|  | @ -520,9 +516,9 @@ TEST(ADT, elimination) { | |||
| 
 | ||||
|     // normalize
 | ||||
|     ADT actual = f1 / actualSum; | ||||
|     vector<double> cpt; | ||||
|     cpt += 1.0 / 3, 2.0 / 3, 3.0 / 7, 4.0 / 7, 5.0 / 11, 6.0 / 11,  //
 | ||||
|         1.0 / 9, 8.0 / 9, 3.0 / 6, 3.0 / 6, 5.0 / 10, 5.0 / 10; | ||||
|     const vector<double> cpt{ | ||||
|         1.0 / 3, 2.0 / 3, 3.0 / 7, 4.0 / 7, 5.0 / 11, 6.0 / 11,  //
 | ||||
|         1.0 / 9, 8.0 / 9, 3.0 / 6, 3.0 / 6, 5.0 / 10, 5.0 / 10}; | ||||
|     ADT expected(A & B & C, cpt); | ||||
|     CHECK(assert_equal(expected, actual)); | ||||
|   } | ||||
|  | @ -535,9 +531,9 @@ TEST(ADT, elimination) { | |||
| 
 | ||||
|     // normalize
 | ||||
|     ADT actual = f1 / actualSum; | ||||
|     vector<double> cpt; | ||||
|     cpt += 1.0 / 21, 2.0 / 21, 3.0 / 21, 4.0 / 21, 5.0 / 21, 6.0 / 21,  //
 | ||||
|         1.0 / 25, 8.0 / 25, 3.0 / 25, 3.0 / 25, 5.0 / 25, 5.0 / 25; | ||||
|     const vector<double> cpt{ | ||||
|         1.0 / 21, 2.0 / 21, 3.0 / 21, 4.0 / 21, 5.0 / 21, 6.0 / 21,  //
 | ||||
|         1.0 / 25, 8.0 / 25, 3.0 / 25, 3.0 / 25, 5.0 / 25, 5.0 / 25}; | ||||
|     ADT expected(A & B & C, cpt); | ||||
|     CHECK(assert_equal(expected, actual)); | ||||
|   } | ||||
|  |  | |||
|  | @ -26,7 +26,9 @@ | |||
| #include <gtsam/discrete/DecisionTree-inl.h> | ||||
| #include <gtsam/discrete/Signature.h> | ||||
| 
 | ||||
| using namespace std; | ||||
| using std::vector; | ||||
| using std::string; | ||||
| using std::map; | ||||
| using namespace gtsam; | ||||
| 
 | ||||
| template <typename T> | ||||
|  | @ -280,8 +282,7 @@ TEST(DecisionTree, Compose) { | |||
|   DT f1(B, DT(A, 0, 1), DT(A, 2, 3)); | ||||
| 
 | ||||
|   // Create from string
 | ||||
|   vector<DT::LabelC> keys; | ||||
|   keys += DT::LabelC(A, 2), DT::LabelC(B, 2); | ||||
|   vector<DT::LabelC> keys{DT::LabelC(A, 2), DT::LabelC(B, 2)}; | ||||
|   DT f2(keys, "0 2 1 3"); | ||||
|   EXPECT(assert_equal(f2, f1, 1e-9)); | ||||
| 
 | ||||
|  | @ -291,7 +292,7 @@ TEST(DecisionTree, Compose) { | |||
|   DOT(f4); | ||||
| 
 | ||||
|   // a bigger tree
 | ||||
|   keys += DT::LabelC(C, 2); | ||||
|   keys.push_back(DT::LabelC(C, 2)); | ||||
|   DT f5(keys, "0 4 2 6 1 5 3 7"); | ||||
|   EXPECT(assert_equal(f5, f4, 1e-9)); | ||||
|   DOT(f5); | ||||
|  | @ -322,7 +323,7 @@ TEST(DecisionTree, Containers) { | |||
| /* ************************************************************************** */ | ||||
| // Test nrAssignments.
 | ||||
| TEST(DecisionTree, NrAssignments) { | ||||
|   pair<string, size_t> A("A", 2), B("B", 2), C("C", 2); | ||||
|   const std::pair<string, size_t> A("A", 2), B("B", 2), C("C", 2); | ||||
|   DT tree({A, B, C}, "1 1 1 1 1 1 1 1"); | ||||
|   EXPECT(tree.root_->isLeaf()); | ||||
|   auto leaf = boost::dynamic_pointer_cast<const DT::Leaf>(tree.root_); | ||||
|  | @ -472,8 +473,8 @@ TEST(DecisionTree, unzip) { | |||
| // Test thresholding.
 | ||||
| TEST(DecisionTree, threshold) { | ||||
|   // Create three level tree
 | ||||
|   vector<DT::LabelC> keys; | ||||
|   keys += DT::LabelC("C", 2), DT::LabelC("B", 2), DT::LabelC("A", 2); | ||||
|   const vector<DT::LabelC> keys{DT::LabelC("C", 2), DT::LabelC("B", 2), | ||||
|                                 DT::LabelC("A", 2)}; | ||||
|   DT tree(keys, "0 1 2 3 4 5 6 7"); | ||||
| 
 | ||||
|   // Check number of leaves equal to zero
 | ||||
|  | @ -495,8 +496,8 @@ TEST(DecisionTree, threshold) { | |||
| // Test apply with assignment.
 | ||||
| TEST(DecisionTree, ApplyWithAssignment) { | ||||
|   // Create three level tree
 | ||||
|   vector<DT::LabelC> keys; | ||||
|   keys += DT::LabelC("C", 2), DT::LabelC("B", 2), DT::LabelC("A", 2); | ||||
|   const vector<DT::LabelC> keys{DT::LabelC("C", 2), DT::LabelC("B", 2), | ||||
|                                 DT::LabelC("A", 2)}; | ||||
|   DT tree(keys, "1 2 3 4 5 6 7 8"); | ||||
| 
 | ||||
|   DecisionTree<string, double> probTree( | ||||
|  |  | |||
|  | @ -53,12 +53,8 @@ TEST(DiscreteConditional, constructors) { | |||
| TEST(DiscreteConditional, constructors_alt_interface) { | ||||
|   DiscreteKey X(0, 2), Y(2, 3), Z(1, 2);  // watch ordering !
 | ||||
| 
 | ||||
|   Signature::Table table; | ||||
|   Signature::Row r1, r2, r3; | ||||
|   r1 += 1.0, 1.0; | ||||
|   r2 += 2.0, 3.0; | ||||
|   r3 += 1.0, 4.0; | ||||
|   table += r1, r2, r3; | ||||
|   const Signature::Row r1{1, 1}, r2{2, 3}, r3{1, 4}; | ||||
|   const Signature::Table table{r1, r2, r3}; | ||||
|   DiscreteConditional actual1(X, {Y}, table); | ||||
| 
 | ||||
|   DecisionTreeFactor f1(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8"); | ||||
|  |  | |||
|  | @ -183,8 +183,7 @@ TEST_UNSAFE(DiscreteMarginals, truss2) { | |||
|     F[j] /= sum; | ||||
| 
 | ||||
|     // Marginals
 | ||||
|     vector<double> table; | ||||
|     table += F[j], T[j]; | ||||
|     const vector<double> table{F[j], T[j]}; | ||||
|     DecisionTreeFactor expectedM(key[j], table); | ||||
|     DiscreteFactor::shared_ptr actualM = marginals(j); | ||||
|     EXPECT(assert_equal( | ||||
|  |  | |||
|  | @ -20,12 +20,9 @@ | |||
| #include <gtsam/geometry/OrientedPlane3.h> | ||||
| #include <gtsam/base/numericalDerivative.h> | ||||
| #include <CppUnitLite/TestHarness.h> | ||||
| #include <boost/assign/std/vector.hpp> | ||||
| 
 | ||||
| using namespace boost::assign; | ||||
| using namespace std::placeholders; | ||||
| using namespace gtsam; | ||||
| using namespace std; | ||||
| using boost::none; | ||||
| 
 | ||||
| GTSAM_CONCEPT_TESTABLE_INST(OrientedPlane3) | ||||
|  |  | |||
|  | @ -23,12 +23,10 @@ | |||
| #include <gtsam/geometry/Pose2.h> | ||||
| #include <gtsam/geometry/Rot2.h> | ||||
| 
 | ||||
| #include <boost/assign/std/vector.hpp>  // for operator += | ||||
| #include <boost/optional.hpp> | ||||
| #include <cmath> | ||||
| #include <iostream> | ||||
| 
 | ||||
| using namespace boost::assign; | ||||
| using namespace gtsam; | ||||
| using namespace std; | ||||
| 
 | ||||
|  | @ -749,11 +747,10 @@ namespace align_3 { | |||
| TEST(Pose2, align_3) { | ||||
|   using namespace align_3; | ||||
| 
 | ||||
|   Point2Pairs ab_pairs; | ||||
|   Point2Pair ab1(make_pair(a1, b1)); | ||||
|   Point2Pair ab2(make_pair(a2, b2)); | ||||
|   Point2Pair ab3(make_pair(a3, b3)); | ||||
|   ab_pairs += ab1, ab2, ab3; | ||||
|   const Point2Pairs ab_pairs{ab1, ab2, ab3}; | ||||
| 
 | ||||
|   boost::optional<Pose2> aTb = Pose2::Align(ab_pairs); | ||||
|   EXPECT(assert_equal(expected, *aTb)); | ||||
|  | @ -778,9 +775,7 @@ namespace { | |||
| TEST(Pose2, align_4) { | ||||
|   using namespace align_3; | ||||
| 
 | ||||
|   Point2Vector as, bs; | ||||
|   as += a1, a2, a3; | ||||
|   bs += b3, b1, b2;  // note in 3,1,2 order !
 | ||||
|   Point2Vector as{a1, a2, a3}, bs{b3, b1, b2};  // note in 3,1,2 order !
 | ||||
| 
 | ||||
|   Triangle t1; t1.i_=0; t1.j_=1; t1.k_=2; | ||||
|   Triangle t2; t2.i_=1; t2.j_=2; t2.k_=0; | ||||
|  |  | |||
|  | @ -20,15 +20,13 @@ | |||
| #include <gtsam/base/lieProxies.h> | ||||
| #include <gtsam/base/TestableAssertions.h> | ||||
| 
 | ||||
| #include <boost/assign/std/vector.hpp> // for operator += | ||||
| using namespace boost::assign; | ||||
| using namespace std::placeholders; | ||||
| 
 | ||||
| #include <CppUnitLite/TestHarness.h> | ||||
| #include <cmath> | ||||
| 
 | ||||
| using namespace std; | ||||
| using namespace gtsam; | ||||
| using namespace std::placeholders; | ||||
| 
 | ||||
| GTSAM_CONCEPT_TESTABLE_INST(Pose3) | ||||
| GTSAM_CONCEPT_LIE_INST(Pose3) | ||||
|  | @ -809,11 +807,10 @@ TEST( Pose3, adjointMap) { | |||
| TEST(Pose3, Align1) { | ||||
|   Pose3 expected(Rot3(), Point3(10,10,0)); | ||||
| 
 | ||||
|   vector<Point3Pair> correspondences; | ||||
|   Point3Pair ab1(make_pair(Point3(10,10,0), Point3(0,0,0))); | ||||
|   Point3Pair ab2(make_pair(Point3(30,20,0), Point3(20,10,0))); | ||||
|   Point3Pair ab3(make_pair(Point3(20,30,0), Point3(10,20,0))); | ||||
|   correspondences += ab1, ab2, ab3; | ||||
|   Point3Pair ab1(Point3(10,10,0), Point3(0,0,0)); | ||||
|   Point3Pair ab2(Point3(30,20,0), Point3(20,10,0)); | ||||
|   Point3Pair ab3(Point3(20,30,0), Point3(10,20,0)); | ||||
|   const vector<Point3Pair> correspondences{ab1, ab2, ab3}; | ||||
| 
 | ||||
|   boost::optional<Pose3> actual = Pose3::Align(correspondences); | ||||
|   EXPECT(assert_equal(expected, *actual)); | ||||
|  | @ -825,15 +822,12 @@ TEST(Pose3, Align2) { | |||
|   Rot3 R = Rot3::RzRyRx(0.3, 0.2, 0.1); | ||||
|   Pose3 expected(R, t); | ||||
| 
 | ||||
|   vector<Point3Pair> correspondences; | ||||
|   Point3 p1(0,0,1), p2(10,0,2), p3(20,-10,30); | ||||
|   Point3 q1 = expected.transformFrom(p1), | ||||
|          q2 = expected.transformFrom(p2), | ||||
|          q3 = expected.transformFrom(p3); | ||||
|   Point3Pair ab1(make_pair(q1, p1)); | ||||
|   Point3Pair ab2(make_pair(q2, p2)); | ||||
|   Point3Pair ab3(make_pair(q3, p3)); | ||||
|   correspondences += ab1, ab2, ab3; | ||||
|   const Point3Pair ab1{q1, p1}, ab2{q2, p2}, ab3{q3, p3}; | ||||
|   const vector<Point3Pair> correspondences{ab1, ab2, ab3}; | ||||
| 
 | ||||
|   boost::optional<Pose3> actual = Pose3::Align(correspondences); | ||||
|   EXPECT(assert_equal(expected, *actual, 1e-5)); | ||||
|  |  | |||
|  | @ -36,7 +36,6 @@ | |||
| #include <cmath> | ||||
| #include <random> | ||||
| 
 | ||||
| using namespace boost::assign; | ||||
| using namespace std::placeholders; | ||||
| using namespace gtsam; | ||||
| using namespace std; | ||||
|  | @ -51,9 +50,8 @@ Point3 point3_(const Unit3& p) { | |||
| } | ||||
| 
 | ||||
| TEST(Unit3, point3) { | ||||
|   vector<Point3> ps; | ||||
|   ps += Point3(1, 0, 0), Point3(0, 1, 0), Point3(0, 0, 1), Point3(1, 1, 0) | ||||
|       / sqrt(2.0); | ||||
|   const vector<Point3> ps{Point3(1, 0, 0), Point3(0, 1, 0), Point3(0, 0, 1), | ||||
|                           Point3(1, 1, 0) / sqrt(2.0)}; | ||||
|   Matrix actualH, expectedH; | ||||
|   for(Point3 p: ps) { | ||||
|     Unit3 s(p); | ||||
|  |  | |||
|  | @ -42,17 +42,11 @@ | |||
| 
 | ||||
| #include <CppUnitLite/TestHarness.h> | ||||
| 
 | ||||
| #include <boost/shared_ptr.hpp> | ||||
| #include <boost/tuple/tuple.hpp> | ||||
| #include <boost/assign/std/vector.hpp> | ||||
| 
 | ||||
| #include <cmath> | ||||
| #include <list> | ||||
| #include <utility> | ||||
| #include <vector> | ||||
| 
 | ||||
| using namespace boost::assign; | ||||
| 
 | ||||
| #include <iostream> | ||||
| 
 | ||||
| using namespace std; | ||||
|  | @ -79,8 +73,7 @@ TEST( GaussianJunctionTreeB, constructor2 ) { | |||
|   // linearize
 | ||||
|   GaussianFactorGraph::shared_ptr fg = nlfg.linearize(values); | ||||
| 
 | ||||
|   Ordering ordering; | ||||
|   ordering += X(1), X(3), X(5), X(7), X(2), X(6), X(4); | ||||
|   const Ordering ordering {X(1), X(3), X(5), X(7), X(2), X(6), X(4)}; | ||||
| 
 | ||||
|   // create an ordering
 | ||||
|   GaussianEliminationTree etree(*fg, ordering); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue