diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index 555e077b8..cb87a6bcd 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -145,10 +145,6 @@ if (GTSAM_USE_EIGEN_MKL) target_include_directories(gtsam PUBLIC ${MKL_INCLUDE_DIR}) endif() -if(GTSAM_USE_TBB) - target_include_directories(gtsam PUBLIC ${TBB_INCLUDE_DIRS}) -endif() - # Add includes for source directories 'BEFORE' boost and any system include # paths so that the compiler uses GTSAM headers in our source directory instead # of any previously installed GTSAM headers. diff --git a/gtsam/discrete/DecisionTreeFactor.cpp b/gtsam/discrete/DecisionTreeFactor.cpp index 17731453a..7202e6853 100644 --- a/gtsam/discrete/DecisionTreeFactor.cpp +++ b/gtsam/discrete/DecisionTreeFactor.cpp @@ -164,15 +164,23 @@ namespace gtsam { } // create new factor, note we collect keys that are not in frontalKeys - // TODO(frank): why do we need this??? result should contain correct keys!!! + /* + Due to branch merging, the labels in `result` may be missing some keys + E.g. After branch merging, we may get a ADT like: + Leaf [2] 1.0204082 + + This is missing the key values used for branching. + */ + KeyVector difference, frontalKeys_(frontalKeys), keys_(keys()); + // Get the difference of the frontalKeys and the factor keys using set_difference + std::sort(keys_.begin(), keys_.end()); + std::sort(frontalKeys_.begin(), frontalKeys_.end()); + std::set_difference(keys_.begin(), keys_.end(), frontalKeys_.begin(), + frontalKeys_.end(), back_inserter(difference)); + DiscreteKeys dkeys; - for (i = 0; i < keys().size(); i++) { - Key j = keys()[i]; - // TODO(frank): inefficient! - if (std::find(frontalKeys.begin(), frontalKeys.end(), j) != - frontalKeys.end()) - continue; - dkeys.push_back(DiscreteKey(j, cardinality(j))); + for (Key key : difference) { + dkeys.push_back(DiscreteKey(key, cardinality(key))); } return std::make_shared(dkeys, result); } diff --git a/gtsam/discrete/DiscreteBayesTree.h b/gtsam/discrete/DiscreteBayesTree.h index 34f8f5d4a..89baf49a9 100644 --- a/gtsam/discrete/DiscreteBayesTree.h +++ b/gtsam/discrete/DiscreteBayesTree.h @@ -110,4 +110,12 @@ class GTSAM_EXPORT DiscreteBayesTree /// @} }; +/// traits +template <> +struct traits + : public Testable {}; + +template <> +struct traits : public Testable {}; + } // namespace gtsam diff --git a/gtsam/discrete/DiscreteKey.cpp b/gtsam/discrete/DiscreteKey.cpp index 79d11d8a7..17f233695 100644 --- a/gtsam/discrete/DiscreteKey.cpp +++ b/gtsam/discrete/DiscreteKey.cpp @@ -49,6 +49,7 @@ namespace gtsam { void DiscreteKeys::print(const std::string& s, const KeyFormatter& keyFormatter) const { + std::cout << (s.empty() ? "" : s + " ") << std::endl; for (auto&& dkey : *this) { std::cout << DefaultKeyFormatter(dkey.first) << " " << dkey.second << std::endl; diff --git a/gtsam/discrete/tests/testDiscreteMarginals.cpp b/gtsam/discrete/tests/testDiscreteMarginals.cpp index ad9b1b191..76bed2fd6 100644 --- a/gtsam/discrete/tests/testDiscreteMarginals.cpp +++ b/gtsam/discrete/tests/testDiscreteMarginals.cpp @@ -121,7 +121,7 @@ TEST_UNSAFE( DiscreteMarginals, truss ) { Clique expected0(std::make_shared((key[0] | key[2], key[4]) = "2/1 2/1 2/1 2/1")); Clique::shared_ptr actual0 = (*bayesTree)[0]; -// EXPECT(assert_equal(expected0, *actual0)); // TODO, correct but fails + EXPECT(assert_equal(expected0, *actual0)); Clique expected1(std::make_shared((key[1] | key[3], key[4]) = "1/2 1/2 1/2 1/2")); Clique::shared_ptr actual1 = (*bayesTree)[1]; diff --git a/gtsam/geometry/CameraSet.h b/gtsam/geometry/CameraSet.h index 950747102..cf4beb883 100644 --- a/gtsam/geometry/CameraSet.h +++ b/gtsam/geometry/CameraSet.h @@ -438,8 +438,7 @@ class CameraSet : public std::vector> { // (DxD) += (DxZDim) * ( (ZDimxD) - (ZDimx3) * (3xZDim) * (ZDimxD) ) // add contribution of current factor - // TODO(gareth): Eigen doesn't let us pass the expression. Call eval() for - // now... + // Eigen doesn't let us pass the expression so we call eval() augmentedHessian.updateDiagonalBlock( aug_i, ((FiT * diff --git a/gtsam/geometry/Similarity2.h b/gtsam/geometry/Similarity2.h index 3e04aa3a1..6bec716ea 100644 --- a/gtsam/geometry/Similarity2.h +++ b/gtsam/geometry/Similarity2.h @@ -74,7 +74,7 @@ class GTSAM_EXPORT Similarity2 : public LieGroup { bool operator==(const Similarity2& other) const; /// Print with optional string - void print(const std::string& s) const; + void print(const std::string& s = "") const; GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os, const Similarity2& p); diff --git a/gtsam/geometry/Similarity3.cpp b/gtsam/geometry/Similarity3.cpp index a9a369e44..cf2360b08 100644 --- a/gtsam/geometry/Similarity3.cpp +++ b/gtsam/geometry/Similarity3.cpp @@ -171,7 +171,7 @@ Similarity3 Similarity3::Align(const Point3Pairs &abPointPairs) { return internal::align(d_abPointPairs, aRb, centroids); } -Similarity3 Similarity3::Align(const vector &abPosePairs) { +Similarity3 Similarity3::Align(const Pose3Pairs &abPosePairs) { const size_t n = abPosePairs.size(); if (n < 2) throw std::runtime_error("input should have at least 2 pairs of poses"); diff --git a/gtsam/geometry/Similarity3.h b/gtsam/geometry/Similarity3.h index 69b401620..cd4af89bc 100644 --- a/gtsam/geometry/Similarity3.h +++ b/gtsam/geometry/Similarity3.h @@ -75,7 +75,7 @@ class GTSAM_EXPORT Similarity3 : public LieGroup { bool operator==(const Similarity3& other) const; /// Print with optional string - void print(const std::string& s) const; + void print(const std::string& s = "") const; GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os, const Similarity3& p); @@ -133,7 +133,7 @@ class GTSAM_EXPORT Similarity3 : public LieGroup { * computed using the algorithm described here: * http://www5.informatik.uni-erlangen.de/Forschung/Publikationen/2005/Zinsser05-PSR.pdf */ - static Similarity3 Align(const std::vector& abPosePairs); + static Similarity3 Align(const Pose3Pairs& abPosePairs); /// @} /// @name Lie Group diff --git a/gtsam/geometry/geometry.i b/gtsam/geometry/geometry.i index 35c470eca..01161817b 100644 --- a/gtsam/geometry/geometry.i +++ b/gtsam/geometry/geometry.i @@ -1082,6 +1082,7 @@ class Similarity2 { // Standard Interface bool equals(const gtsam::Similarity2& sim, double tol) const; + void print(const std::string& s = "") const; Matrix matrix() const; gtsam::Rot2& rotation(); gtsam::Point2& translation(); @@ -1105,6 +1106,7 @@ class Similarity3 { // Standard Interface bool equals(const gtsam::Similarity3& sim, double tol) const; + void print(const std::string& s = "") const; Matrix matrix() const; gtsam::Rot3& rotation(); gtsam::Point3& translation(); diff --git a/gtsam/hybrid/HybridBayesTree.h b/gtsam/hybrid/HybridBayesTree.h index bc2a0f852..f91e16cbf 100644 --- a/gtsam/hybrid/HybridBayesTree.h +++ b/gtsam/hybrid/HybridBayesTree.h @@ -123,6 +123,10 @@ class GTSAM_EXPORT HybridBayesTree : public BayesTree { }; /// traits +template <> +struct traits : public Testable { +}; + template <> struct traits : public Testable {}; diff --git a/gtsam/hybrid/HybridGaussianISAM.h b/gtsam/hybrid/HybridGaussianISAM.h index 8578f3dc5..ba2de52d2 100644 --- a/gtsam/hybrid/HybridGaussianISAM.h +++ b/gtsam/hybrid/HybridGaussianISAM.h @@ -29,7 +29,8 @@ namespace gtsam { /** - * @brief + * @brief Incremental Smoothing and Mapping (ISAM) algorithm + * for hybrid factor graphs. * * @ingroup hybrid */ diff --git a/gtsam/hybrid/HybridNonlinearFactorGraph.cpp b/gtsam/hybrid/HybridNonlinearFactorGraph.cpp index 2459e4ec9..e51adb9cd 100644 --- a/gtsam/hybrid/HybridNonlinearFactorGraph.cpp +++ b/gtsam/hybrid/HybridNonlinearFactorGraph.cpp @@ -56,8 +56,6 @@ HybridGaussianFactorGraph::shared_ptr HybridNonlinearFactorGraph::linearize( for (auto& f : factors_) { // First check if it is a valid factor if (!f) { - // TODO(dellaert): why? - linearFG->push_back(GaussianFactor::shared_ptr()); continue; } // Check if it is a nonlinear mixture factor diff --git a/gtsam_unstable/partition/FindSeparator-inl.h b/gtsam_unstable/partition/FindSeparator-inl.h index e991c5af2..f4718f7a9 100644 --- a/gtsam_unstable/partition/FindSeparator-inl.h +++ b/gtsam_unstable/partition/FindSeparator-inl.h @@ -39,7 +39,7 @@ namespace gtsam { namespace partition { * whether node j is in the left part of the graph, the right part, or the * separator, respectively */ - std::pair separatorMetis(idx_t n, const sharedInts& xadj, + std::pair separatorMetis(idx_t n, const sharedInts& xadj, const sharedInts& adjncy, const sharedInts& adjwgt, bool verbose) { // control parameters @@ -277,7 +277,7 @@ namespace gtsam { namespace partition { //throw runtime_error("separatorPartitionByMetis:stop for debug"); } - if(result.C.size() != sepsize) { + if(result.C.size() != size_t(sepsize)) { std::cout << "total key: " << keys.size() << " result(A,B,C) = " << result.A.size() << ", " << result.B.size() << ", " << result.C.size() << "; sepsize from Metis = " << sepsize << std::endl; diff --git a/python/gtsam/tests/test_backwards_compatibility.py b/python/gtsam/tests/test_backwards_compatibility.py index 414b65e8c..ca96cdf57 100644 --- a/python/gtsam/tests/test_backwards_compatibility.py +++ b/python/gtsam/tests/test_backwards_compatibility.py @@ -29,7 +29,7 @@ UPRIGHT = Rot3.Ypr(-np.pi / 2, 0.0, -np.pi / 2) class TestBackwardsCompatibility(GtsamTestCase): - """Tests for the backwards compatibility for the Python wrapper.""" + """Tests for backwards compatibility of the Python wrapper.""" def setUp(self): """Setup test fixtures"""