From 68f1cbdb08af182b96a717b6aa15bd141e810201 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Tue, 6 Nov 2018 00:18:45 -0500 Subject: [PATCH] Refactored templates so we can get rid of FactorGraph include for faster/tighter compile --- gtsam/inference/Ordering.h | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/gtsam/inference/Ordering.h b/gtsam/inference/Ordering.h index ae7a10f44..30cc54c06 100644 --- a/gtsam/inference/Ordering.h +++ b/gtsam/inference/Ordering.h @@ -11,8 +11,10 @@ /** * @file Ordering.h + * @brief Variable ordering for the elimination algorithm * @author Richard Roberts * @author Andrew Melim + * @author Frank Dellaert * @date Sep 2, 2010 */ @@ -21,7 +23,6 @@ #include #include #include -#include #include #include @@ -77,8 +78,8 @@ public: /// Compute a fill-reducing ordering using COLAMD from a factor graph (see details for note on /// performance). This internally builds a VariableIndex so if you already have a VariableIndex, /// it is faster to use COLAMD(const VariableIndex&) - template - static Ordering Colamd(const FactorGraph& graph) { + template + static Ordering Colamd(const FACTOR_GRAPH& graph) { if (graph.empty()) return Ordering(); else @@ -96,8 +97,8 @@ public: /// constrainLast will be ordered in the same order specified in the vector \c /// constrainLast. If \c forceOrder is false, the variables in \c constrainLast will be /// ordered after all the others, but will be rearranged by CCOLAMD to reduce fill-in as well. - template - static Ordering ColamdConstrainedLast(const FactorGraph& graph, + template + static Ordering ColamdConstrainedLast(const FACTOR_GRAPH& graph, const std::vector& constrainLast, bool forceOrder = false) { if (graph.empty()) return Ordering(); @@ -123,8 +124,8 @@ public: /// constrainFirst will be ordered in the same order specified in the vector \c /// constrainFirst. If \c forceOrder is false, the variables in \c constrainFirst will be /// ordered before all the others, but will be rearranged by CCOLAMD to reduce fill-in as well. - template - static Ordering ColamdConstrainedFirst(const FactorGraph& graph, + template + static Ordering ColamdConstrainedFirst(const FACTOR_GRAPH& graph, const std::vector& constrainFirst, bool forceOrder = false) { if (graph.empty()) return Ordering(); @@ -152,8 +153,8 @@ public: /// arbitrary order. Any variables not present in \c groups will be assigned to group 0. This /// function simply fills the \c cmember argument to CCOLAMD with the supplied indices, see the /// CCOLAMD documentation for more information. - template - static Ordering ColamdConstrained(const FactorGraph& graph, + template + static Ordering ColamdConstrained(const FACTOR_GRAPH& graph, const FastMap& groups) { if (graph.empty()) return Ordering(); @@ -172,8 +173,8 @@ public: const VariableIndex& variableIndex, const FastMap& groups); /// Return a natural Ordering. Typically used by iterative solvers - template - static Ordering Natural(const FactorGraph &fg) { + template + static Ordering Natural(const FACTOR_GRAPH &fg) { KeySet src = fg.keys(); std::vector keys(src.begin(), src.end()); std::stable_sort(keys.begin(), keys.end()); @@ -181,15 +182,15 @@ public: } /// METIS Formatting function - template + template static GTSAM_EXPORT void CSRFormat(std::vector& xadj, - std::vector& adj, const FactorGraph& graph); + std::vector& adj, const FACTOR_GRAPH& graph); /// Compute an ordering determined by METIS from a VariableIndex static GTSAM_EXPORT Ordering Metis(const MetisIndex& met); - template - static Ordering Metis(const FactorGraph& graph) { + template + static Ordering Metis(const FACTOR_GRAPH& graph) { return Metis(MetisIndex(graph)); } @@ -197,9 +198,9 @@ public: /// @name Named Constructors @{ - template + template static Ordering Create(OrderingType orderingType, - const FactorGraph& graph) { + const FACTOR_GRAPH& graph) { if (graph.empty()) return Ordering();