diff --git a/gtsam/inference/ConditionalBase.h b/gtsam/inference/Conditional.h similarity index 88% rename from gtsam/inference/ConditionalBase.h rename to gtsam/inference/Conditional.h index eb1778e3c..9acdca629 100644 --- a/gtsam/inference/ConditionalBase.h +++ b/gtsam/inference/Conditional.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include namespace gtsam { @@ -47,7 +47,7 @@ namespace gtsam { * immutable, i.e., practicing functional programming. */ template -class ConditionalBase: public gtsam::FactorBase, boost::noncopyable, public Testable > { +class Conditional: public gtsam::Factor, boost::noncopyable, public Testable > { protected: @@ -62,14 +62,14 @@ protected: public: typedef KEY Key; - typedef ConditionalBase This; + typedef Conditional This; /** * Typedef to the factor type that produces this conditional and that this * conditional can be converted to using a factor constructor. Derived * classes must redefine this. */ - typedef gtsam::FactorBase FactorType; + typedef gtsam::Factor FactorType; /** A shared_ptr to this class. Derived classes must redefine this. */ typedef boost::shared_ptr shared_ptr; @@ -87,22 +87,22 @@ public: typedef boost::iterator_range Parents; /** Empty Constructor to make serialization possible */ - ConditionalBase() : nrFrontals_(0) {} + Conditional() : nrFrontals_(0) {} /** No parents */ - ConditionalBase(Key key) : FactorType(key), nrFrontals_(1) {} + Conditional(Key key) : FactorType(key), nrFrontals_(1) {} /** Single parent */ - ConditionalBase(Key key, Key parent) : FactorType(key, parent), nrFrontals_(1) {} + Conditional(Key key, Key parent) : FactorType(key, parent), nrFrontals_(1) {} /** Two parents */ - ConditionalBase(Key key, Key parent1, Key parent2) : FactorType(key, parent1, parent2), nrFrontals_(1) {} + Conditional(Key key, Key parent1, Key parent2) : FactorType(key, parent1, parent2), nrFrontals_(1) {} /** Three parents */ - ConditionalBase(Key key, Key parent1, Key parent2, Key parent3) : FactorType(key, parent1, parent2, parent3), nrFrontals_(1) {} + Conditional(Key key, Key parent1, Key parent2, Key parent3) : FactorType(key, parent1, parent2, parent3), nrFrontals_(1) {} /** Constructor from a frontal variable and a vector of parents */ - ConditionalBase(Key key, const std::vector& parents) : nrFrontals_(1) { + Conditional(Key key, const std::vector& parents) : nrFrontals_(1) { FactorType::keys_.resize(1 + parents.size()); *(beginFrontals()) = key; std::copy(parents.begin(), parents.end(), beginParents()); @@ -190,7 +190,7 @@ private: /* ************************************************************************* */ template -void ConditionalBase::print(const std::string& s) const { +void Conditional::print(const std::string& s) const { std::cout << s << " P("; BOOST_FOREACH(Key key, frontals()) std::cout << " " << key; if (nrParents()>0) std::cout << " |"; @@ -200,7 +200,7 @@ void ConditionalBase::print(const std::string& s) const { /* ************************************************************************* */ template -bool ConditionalBase::permuteSeparatorWithInverse(const Permutation& inversePermutation) { +bool Conditional::permuteSeparatorWithInverse(const Permutation& inversePermutation) { #ifndef NDEBUG BOOST_FOREACH(Key key, frontals()) { assert(key == inversePermutation[key]); } #endif @@ -217,7 +217,7 @@ bool ConditionalBase::permuteSeparatorWithInverse(const Permutation& invers /* ************************************************************************* */ template -void ConditionalBase::permuteWithInverse(const Permutation& inversePermutation) { +void Conditional::permuteWithInverse(const Permutation& inversePermutation) { // The permutation may not move the separators into the frontals #ifndef NDEBUG BOOST_FOREACH(const Key frontal, this->frontals()) { diff --git a/gtsam/inference/FactorBase-inl.h b/gtsam/inference/Factor-inl.h similarity index 81% rename from gtsam/inference/FactorBase-inl.h rename to gtsam/inference/Factor-inl.h index 16587b6eb..2c42ad05f 100644 --- a/gtsam/inference/FactorBase-inl.h +++ b/gtsam/inference/Factor-inl.h @@ -10,7 +10,7 @@ * -------------------------------------------------------------------------- */ /** - * @file FactorBase-inl.h + * @file Factor-inl.h * @brief * @author Richard Roberts * @created Sep 1, 2010 @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include @@ -31,15 +31,15 @@ namespace gtsam { /* ************************************************************************* */ template -FactorBase::FactorBase(const FactorBase& f) : keys_(f.keys_) {} +Factor::Factor(const Factor& f) : keys_(f.keys_) {} /* ************************************************************************* */ template -FactorBase::FactorBase(const ConditionalType& c) : keys_(c.keys()) {} +Factor::Factor(const ConditionalType& c) : keys_(c.keys()) {} /* ************************************************************************* */ template -void FactorBase::assertInvariants() const { +void Factor::assertInvariants() const { #ifndef NDEBUG std::set uniqueSorted(keys_.begin(), keys_.end()); assert(uniqueSorted.size() == keys_.size()); @@ -49,7 +49,7 @@ void FactorBase::assertInvariants() const { /* ************************************************************************* */ template -void FactorBase::print(const std::string& s) const { +void Factor::print(const std::string& s) const { std::cout << s << " "; BOOST_FOREACH(KEY key, keys_) std::cout << " " << key; std::cout << std::endl; @@ -57,14 +57,14 @@ void FactorBase::print(const std::string& s) const { /* ************************************************************************* */ template -bool FactorBase::equals(const This& other, double tol) const { +bool Factor::equals(const This& other, double tol) const { return keys_ == other.keys_; } /* ************************************************************************* */ template template -typename DERIVED::shared_ptr FactorBase::Combine(const FactorGraph& factors, const FastMap >& variableSlots) { +typename DERIVED::shared_ptr Factor::Combine(const FactorGraph& factors, const FastMap >& variableSlots) { typedef const FastMap > VariableSlots; typedef typeof(boost::lambda::bind(&VariableSlots::value_type::first, boost::lambda::_1)) FirstGetter; typedef boost::transform_iterator< @@ -79,7 +79,7 @@ typename DERIVED::shared_ptr FactorBase::Combine(const FactorGraph /* ************************************************************************* */ template template -typename CONDITIONAL::shared_ptr FactorBase::eliminateFirst() { +typename CONDITIONAL::shared_ptr Factor::eliminateFirst() { assert(!keys_.empty()); assertInvariants(); KEY eliminated = keys_.front(); @@ -90,7 +90,7 @@ typename CONDITIONAL::shared_ptr FactorBase::eliminateFirst() { /* ************************************************************************* */ template template -typename BayesNet::shared_ptr FactorBase::eliminate(size_t nrFrontals) { +typename BayesNet::shared_ptr Factor::eliminate(size_t nrFrontals) { assert(keys_.size() >= nrFrontals); assertInvariants(); typename BayesNet::shared_ptr fragment(new BayesNet()); @@ -105,7 +105,7 @@ typename BayesNet::shared_ptr FactorBase::eliminate(size_t nrF /* ************************************************************************* */ template -void FactorBase::permuteWithInverse(const Permutation& inversePermutation) { +void Factor::permuteWithInverse(const Permutation& inversePermutation) { BOOST_FOREACH(KEY& key, keys_) { key = inversePermutation[key]; } } diff --git a/gtsam/inference/FactorBase.h b/gtsam/inference/Factor.h similarity index 87% rename from gtsam/inference/FactorBase.h rename to gtsam/inference/Factor.h index 64a191900..3d5c41cba 100644 --- a/gtsam/inference/FactorBase.h +++ b/gtsam/inference/Factor.h @@ -10,7 +10,7 @@ * -------------------------------------------------------------------------- */ /** - * @file FactorBase.h + * @file Factor.h * @brief The base class for all factors * @author Kai Ni * @author Frank Dellaert @@ -33,7 +33,7 @@ namespace gtsam { -template class ConditionalBase; +template class Conditional; /** * This is the base class for all factor types. It is templated on a KEY type, @@ -49,21 +49,21 @@ template class ConditionalBase; * derived class. See IndexFactor, JacobianFactor, etc. for examples. */ template -class FactorBase : public Testable > { +class Factor : public Testable > { public: typedef KEY Key; - typedef FactorBase This; + typedef Factor This; /** * Typedef to the conditional type obtained by eliminating this factor. * Derived classes must redefine this. */ - typedef gtsam::ConditionalBase ConditionalType; + typedef gtsam::Conditional ConditionalType; /** A shared_ptr to this class. Derived classes must redefine this. */ - typedef boost::shared_ptr shared_ptr; + typedef boost::shared_ptr shared_ptr; /** Iterator over keys */ typedef std::vector::iterator iterator; @@ -83,36 +83,36 @@ protected: public: /** Copy constructor */ - FactorBase(const This& f); + Factor(const This& f); /** Construct from derived type */ - FactorBase(const ConditionalType& c); + Factor(const ConditionalType& c); /** Constructor from a collection of keys */ - template FactorBase(KEYITERATOR beginKey, KEYITERATOR endKey) : + template Factor(KEYITERATOR beginKey, KEYITERATOR endKey) : keys_(beginKey, endKey) { assertInvariants(); } /** Default constructor for I/O */ - FactorBase() {} + Factor() {} /** Construct unary factor */ - FactorBase(Key key) : keys_(1) { + Factor(Key key) : keys_(1) { keys_[0] = key; assertInvariants(); } /** Construct binary factor */ - FactorBase(Key key1, Key key2) : keys_(2) { + Factor(Key key1, Key key2) : keys_(2) { keys_[0] = key1; keys_[1] = key2; assertInvariants(); } /** Construct ternary factor */ - FactorBase(Key key1, Key key2, Key key3) : keys_(3) { + Factor(Key key1, Key key2, Key key3) : keys_(3) { keys_[0] = key1; keys_[1] = key2; keys_[2] = key3; assertInvariants(); } /** Construct 4-way factor */ - FactorBase(Key key1, Key key2, Key key3, Key key4) : keys_(4) { + Factor(Key key1, Key key2, Key key3, Key key4) : keys_(4) { keys_[0] = key1; keys_[1] = key2; keys_[2] = key3; keys_[3] = key4; assertInvariants(); } /** Construct n-way factor */ - FactorBase(const std::set& keys) { + Factor(const std::set& keys) { BOOST_FOREACH(const Key& key, keys) keys_.push_back(key); assertInvariants(); } diff --git a/gtsam/inference/GenericMultifrontalSolver-inl.h b/gtsam/inference/GenericMultifrontalSolver-inl.h index 918f500b3..58a8b22b1 100644 --- a/gtsam/inference/GenericMultifrontalSolver-inl.h +++ b/gtsam/inference/GenericMultifrontalSolver-inl.h @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include #include diff --git a/gtsam/inference/GenericSequentialSolver-inl.h b/gtsam/inference/GenericSequentialSolver-inl.h index e885f39de..dbeb7769b 100644 --- a/gtsam/inference/GenericSequentialSolver-inl.h +++ b/gtsam/inference/GenericSequentialSolver-inl.h @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include #include diff --git a/gtsam/inference/ISAM-inl.h b/gtsam/inference/ISAM-inl.h index c204954d6..fe6d37749 100644 --- a/gtsam/inference/ISAM-inl.h +++ b/gtsam/inference/ISAM-inl.h @@ -21,7 +21,7 @@ #include // for operator += using namespace boost::assign; -#include +#include #include #include #include diff --git a/gtsam/inference/IndexConditional.cpp b/gtsam/inference/IndexConditional.cpp index bf176d6be..df7526b8a 100644 --- a/gtsam/inference/IndexConditional.cpp +++ b/gtsam/inference/IndexConditional.cpp @@ -20,6 +20,6 @@ namespace gtsam { -template class ConditionalBase; +template class Conditional; } diff --git a/gtsam/inference/IndexConditional.h b/gtsam/inference/IndexConditional.h index cfea44575..1aa20be9e 100644 --- a/gtsam/inference/IndexConditional.h +++ b/gtsam/inference/IndexConditional.h @@ -18,7 +18,7 @@ #pragma once -#include +#include #include namespace gtsam { @@ -28,15 +28,15 @@ namespace gtsam { * GaussianConditional, and also functions as a symbolic conditional with * Index keys, produced by symbolic elimination of IndexFactor. * - * It derives from ConditionalBase with a key type of Index, which is an + * It derives from Conditional with a key type of Index, which is an * unsigned integer. */ - class IndexConditional : public ConditionalBase { + class IndexConditional : public Conditional { public: typedef IndexConditional This; - typedef ConditionalBase Base; + typedef Conditional Base; typedef IndexFactor FactorType; typedef boost::shared_ptr shared_ptr; diff --git a/gtsam/inference/IndexFactor.cpp b/gtsam/inference/IndexFactor.cpp index 41d4773a5..1b483ac9c 100644 --- a/gtsam/inference/IndexFactor.cpp +++ b/gtsam/inference/IndexFactor.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include #include @@ -26,7 +26,7 @@ using namespace std; namespace gtsam { -template class FactorBase; +template class Factor; IndexFactor::IndexFactor(const IndexConditional& c) : Base(c) {} diff --git a/gtsam/inference/IndexFactor.h b/gtsam/inference/IndexFactor.h index 166c93416..54c9eec4f 100644 --- a/gtsam/inference/IndexFactor.h +++ b/gtsam/inference/IndexFactor.h @@ -18,7 +18,7 @@ #pragma once -#include +#include namespace gtsam { @@ -36,15 +36,15 @@ namespace gtsam { * this and derived classes calling them separately generally does extra * work. * - * It derives from FactorBase with a key type of Index, which is an unsigned + * It derives from Factor with a key type of Index, which is an unsigned * integer. */ - class IndexFactor : public FactorBase { + class IndexFactor : public Factor { public: typedef IndexFactor This; - typedef FactorBase Base; + typedef Factor Base; /** Elimination produces an IndexConditional */ typedef IndexConditional ConditionalType; diff --git a/gtsam/inference/Makefile.am b/gtsam/inference/Makefile.am index 6603328db..6b0a666b5 100644 --- a/gtsam/inference/Makefile.am +++ b/gtsam/inference/Makefile.am @@ -15,7 +15,7 @@ check_PROGRAMS = #---------------------------------------------------------------------------------------------------- # GTSAM core -headers += FactorBase.h FactorBase-inl.h ConditionalBase.h +headers += Factor.h Factor-inl.h Conditional.h # Symbolic Inference sources += SymbolicFactorGraph.cpp SymbolicMultifrontalSolver.cpp SymbolicSequentialSolver.cpp diff --git a/gtsam/linear/HessianFactor.h b/gtsam/linear/HessianFactor.h index b86612aec..839b714b1 100644 --- a/gtsam/linear/HessianFactor.h +++ b/gtsam/linear/HessianFactor.h @@ -118,7 +118,7 @@ namespace gtsam { * variable. The order of the variables within the factor is not changed. */ virtual void permuteWithInverse(const Permutation& inversePermutation) { - FactorBase::permuteWithInverse(inversePermutation); } + Factor::permuteWithInverse(inversePermutation); } /** * Combine and eliminate several factors.