From 29ea1450eb33401cec5102f080735ae9857ffa77 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Thu, 3 May 2012 12:23:34 +0000 Subject: [PATCH] Removed some obsolete code in discrete --- .cproject | 8 +++ gtsam/discrete/DecisionTreeFactor.h | 3 -- gtsam/discrete/DiscreteKey.cpp | 13 ----- gtsam/discrete/DiscreteKey.h | 76 +---------------------------- gtsam/discrete/label_traits.h | 41 ---------------- 5 files changed, 9 insertions(+), 132 deletions(-) delete mode 100644 gtsam/discrete/label_traits.h diff --git a/.cproject b/.cproject index da141d84a..ceda6fadc 100644 --- a/.cproject +++ b/.cproject @@ -793,6 +793,14 @@ true true + + make + -j5 + check + true + true + true + make -j2 diff --git a/gtsam/discrete/DecisionTreeFactor.h b/gtsam/discrete/DecisionTreeFactor.h index a61f12cf5..e98c7020b 100644 --- a/gtsam/discrete/DecisionTreeFactor.h +++ b/gtsam/discrete/DecisionTreeFactor.h @@ -33,9 +33,6 @@ namespace gtsam { typedef DiscreteConditional ConditionalType; typedef boost::shared_ptr shared_ptr; - /// Index label and cardinality - typedef std::pair IndexC; - public: /// @name Standard Constructors diff --git a/gtsam/discrete/DiscreteKey.cpp b/gtsam/discrete/DiscreteKey.cpp index 9ab4207bb..01b025d80 100644 --- a/gtsam/discrete/DiscreteKey.cpp +++ b/gtsam/discrete/DiscreteKey.cpp @@ -14,19 +14,6 @@ namespace gtsam { using namespace std; - bool OldDiscreteKey::equals(const OldDiscreteKey& other, double tol) const { - return (*this == other); - } - - void OldDiscreteKey::print(const string& s) const { - cout << s << *this; - } - - ostream& operator <<(ostream &os, const OldDiscreteKey &key) { - os << key.name_; - return os; - } - DiscreteKeys::DiscreteKeys(const vector& cs) { for (size_t i = 0; i < cs.size(); i++) { string name = boost::str(boost::format("v%1%") % i); diff --git a/gtsam/discrete/DiscreteKey.h b/gtsam/discrete/DiscreteKey.h index 7c2fca817..87e6e96a6 100644 --- a/gtsam/discrete/DiscreteKey.h +++ b/gtsam/discrete/DiscreteKey.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include @@ -16,65 +15,11 @@ namespace gtsam { - typedef std::pair DiscreteKey; - /** * Key type for discrete conditionals * Includes name and cardinality */ - class OldDiscreteKey : std::pair { - - private: - - std::string name_; - - public: - - /** Default constructor */ - OldDiscreteKey() : - std::pair(0,0), name_("default") { - } - - /** Constructor, defaults to binary */ - OldDiscreteKey(Index j, const std::string& name, size_t cardinality = 2) : - std::pair(j,cardinality), name_(name) { - } - - virtual ~OldDiscreteKey() { - } - - // Testable - bool equals(const OldDiscreteKey& other, double tol = 1e-9) const; - void print(const std::string& s = "") const; - - operator Index() const { return first; } - - const std::string& name() const { - return name_; - } - - size_t cardinality() const { - return second; - } - - /** compare 2 keys by their name */ - bool operator <(const OldDiscreteKey& other) const { - return name_ < other.name_; - } - - /** equality */ - bool operator==(const OldDiscreteKey& other) const { - return (first == other.first) && (second == other.second) && (name_ == other.name_); - } - - bool operator!=(const OldDiscreteKey& other) const { - return !(*this == other); - } - - /** provide streaming */ - friend std::ostream& operator <<(std::ostream &os, const OldDiscreteKey &key); - - }; // OldDiscreteKey + typedef std::pair DiscreteKey; /// DiscreteKeys is a set of keys that can be assembled using the & operator struct DiscreteKeys: public std::vector { @@ -111,23 +56,4 @@ namespace gtsam { /// Create a list from two keys DiscreteKeys operator&(const DiscreteKey& key1, const DiscreteKey& key2); - - /// traits class for DiscreteKey for use with DecisionTree/DecisionDiagram - template<> - struct label_traits { - /** get cardinality from type */ - static size_t cardinality(const OldDiscreteKey& key) { - return key.cardinality(); - } - /** compare 2 keys by their name */ - static bool higher(const OldDiscreteKey& a, const OldDiscreteKey& b) { - return a.name() < b.name(); - } - /** hash function */ - static size_t hash_value(const OldDiscreteKey& a) { - boost::hash hasher; - return hasher(a.name()); - } - }; - } diff --git a/gtsam/discrete/label_traits.h b/gtsam/discrete/label_traits.h deleted file mode 100644 index 0a0c39094..000000000 --- a/gtsam/discrete/label_traits.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * label_traits.h - * @brief traits class for labels used in Decision Diagram - * @author Frank Dellaert - * @date Mar 22, 2011 - */ - -#pragma once - -#include -#include - -namespace gtsam { - - /** - * Default traits class for label type, http://www.cantrip.org/traits.html - * Override to provide non-default behavior, see example in Index - */ - template - struct label_traits { - /** default = binary label */ - static size_t cardinality(const T&) { - return 2; - } - /** default higher(a,b) = a hasher; - return hasher(a); - } - }; - - /* custom hash function for labels, no need to specialize this */ - template - std::size_t hash_value(const T& a) { - return label_traits::hash_value(a); - } -}