Renamed FactorBase to Factor and ConditionalBase to Conditional

release/4.3a0
Richard Roberts 2011-03-01 19:27:50 +00:00
parent 85ed6c306d
commit 358e003a57
12 changed files with 55 additions and 55 deletions

View File

@ -26,7 +26,7 @@
#include <boost/serialization/nvp.hpp> #include <boost/serialization/nvp.hpp>
#include <gtsam/base/types.h> #include <gtsam/base/types.h>
#include <gtsam/base/Testable.h> #include <gtsam/base/Testable.h>
#include <gtsam/inference/FactorBase.h> #include <gtsam/inference/Factor.h>
#include <gtsam/inference/Permutation.h> #include <gtsam/inference/Permutation.h>
namespace gtsam { namespace gtsam {
@ -47,7 +47,7 @@ namespace gtsam {
* immutable, i.e., practicing functional programming. * immutable, i.e., practicing functional programming.
*/ */
template<typename KEY> template<typename KEY>
class ConditionalBase: public gtsam::FactorBase<KEY>, boost::noncopyable, public Testable<ConditionalBase<KEY> > { class Conditional: public gtsam::Factor<KEY>, boost::noncopyable, public Testable<Conditional<KEY> > {
protected: protected:
@ -62,14 +62,14 @@ protected:
public: public:
typedef KEY Key; typedef KEY Key;
typedef ConditionalBase<Key> This; typedef Conditional<Key> This;
/** /**
* Typedef to the factor type that produces this conditional and that this * Typedef to the factor type that produces this conditional and that this
* conditional can be converted to using a factor constructor. Derived * conditional can be converted to using a factor constructor. Derived
* classes must redefine this. * classes must redefine this.
*/ */
typedef gtsam::FactorBase<Key> FactorType; typedef gtsam::Factor<Key> FactorType;
/** A shared_ptr to this class. Derived classes must redefine this. */ /** A shared_ptr to this class. Derived classes must redefine this. */
typedef boost::shared_ptr<This> shared_ptr; typedef boost::shared_ptr<This> shared_ptr;
@ -87,22 +87,22 @@ public:
typedef boost::iterator_range<const_iterator> Parents; typedef boost::iterator_range<const_iterator> Parents;
/** Empty Constructor to make serialization possible */ /** Empty Constructor to make serialization possible */
ConditionalBase() : nrFrontals_(0) {} Conditional() : nrFrontals_(0) {}
/** No parents */ /** No parents */
ConditionalBase(Key key) : FactorType(key), nrFrontals_(1) {} Conditional(Key key) : FactorType(key), nrFrontals_(1) {}
/** Single parent */ /** Single parent */
ConditionalBase(Key key, Key parent) : FactorType(key, parent), nrFrontals_(1) {} Conditional(Key key, Key parent) : FactorType(key, parent), nrFrontals_(1) {}
/** Two parents */ /** 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 */ /** 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 */ /** Constructor from a frontal variable and a vector of parents */
ConditionalBase(Key key, const std::vector<Key>& parents) : nrFrontals_(1) { Conditional(Key key, const std::vector<Key>& parents) : nrFrontals_(1) {
FactorType::keys_.resize(1 + parents.size()); FactorType::keys_.resize(1 + parents.size());
*(beginFrontals()) = key; *(beginFrontals()) = key;
std::copy(parents.begin(), parents.end(), beginParents()); std::copy(parents.begin(), parents.end(), beginParents());
@ -190,7 +190,7 @@ private:
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
void ConditionalBase<KEY>::print(const std::string& s) const { void Conditional<KEY>::print(const std::string& s) const {
std::cout << s << " P("; std::cout << s << " P(";
BOOST_FOREACH(Key key, frontals()) std::cout << " " << key; BOOST_FOREACH(Key key, frontals()) std::cout << " " << key;
if (nrParents()>0) std::cout << " |"; if (nrParents()>0) std::cout << " |";
@ -200,7 +200,7 @@ void ConditionalBase<KEY>::print(const std::string& s) const {
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
bool ConditionalBase<KEY>::permuteSeparatorWithInverse(const Permutation& inversePermutation) { bool Conditional<KEY>::permuteSeparatorWithInverse(const Permutation& inversePermutation) {
#ifndef NDEBUG #ifndef NDEBUG
BOOST_FOREACH(Key key, frontals()) { assert(key == inversePermutation[key]); } BOOST_FOREACH(Key key, frontals()) { assert(key == inversePermutation[key]); }
#endif #endif
@ -217,7 +217,7 @@ bool ConditionalBase<KEY>::permuteSeparatorWithInverse(const Permutation& invers
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
void ConditionalBase<KEY>::permuteWithInverse(const Permutation& inversePermutation) { void Conditional<KEY>::permuteWithInverse(const Permutation& inversePermutation) {
// The permutation may not move the separators into the frontals // The permutation may not move the separators into the frontals
#ifndef NDEBUG #ifndef NDEBUG
BOOST_FOREACH(const Key frontal, this->frontals()) { BOOST_FOREACH(const Key frontal, this->frontals()) {

View File

@ -10,7 +10,7 @@
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
/** /**
* @file FactorBase-inl.h * @file Factor-inl.h
* @brief * @brief
* @author Richard Roberts * @author Richard Roberts
* @created Sep 1, 2010 * @created Sep 1, 2010
@ -18,7 +18,7 @@
#pragma once #pragma once
#include <gtsam/inference/FactorBase.h> #include <gtsam/inference/Factor.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
@ -31,15 +31,15 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
FactorBase<KEY>::FactorBase(const FactorBase<KEY>& f) : keys_(f.keys_) {} Factor<KEY>::Factor(const Factor<KEY>& f) : keys_(f.keys_) {}
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
FactorBase<KEY>::FactorBase(const ConditionalType& c) : keys_(c.keys()) {} Factor<KEY>::Factor(const ConditionalType& c) : keys_(c.keys()) {}
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
void FactorBase<KEY>::assertInvariants() const { void Factor<KEY>::assertInvariants() const {
#ifndef NDEBUG #ifndef NDEBUG
std::set<Index> uniqueSorted(keys_.begin(), keys_.end()); std::set<Index> uniqueSorted(keys_.begin(), keys_.end());
assert(uniqueSorted.size() == keys_.size()); assert(uniqueSorted.size() == keys_.size());
@ -49,7 +49,7 @@ void FactorBase<KEY>::assertInvariants() const {
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
void FactorBase<KEY>::print(const std::string& s) const { void Factor<KEY>::print(const std::string& s) const {
std::cout << s << " "; std::cout << s << " ";
BOOST_FOREACH(KEY key, keys_) std::cout << " " << key; BOOST_FOREACH(KEY key, keys_) std::cout << " " << key;
std::cout << std::endl; std::cout << std::endl;
@ -57,14 +57,14 @@ void FactorBase<KEY>::print(const std::string& s) const {
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
bool FactorBase<KEY>::equals(const This& other, double tol) const { bool Factor<KEY>::equals(const This& other, double tol) const {
return keys_ == other.keys_; return keys_ == other.keys_;
} }
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
template<class DERIVED> template<class DERIVED>
typename DERIVED::shared_ptr FactorBase<KEY>::Combine(const FactorGraph<DERIVED>& factors, const FastMap<Key, std::vector<Key> >& variableSlots) { typename DERIVED::shared_ptr Factor<KEY>::Combine(const FactorGraph<DERIVED>& factors, const FastMap<Key, std::vector<Key> >& variableSlots) {
typedef const FastMap<Key, std::vector<Key> > VariableSlots; typedef const FastMap<Key, std::vector<Key> > VariableSlots;
typedef typeof(boost::lambda::bind(&VariableSlots::value_type::first, boost::lambda::_1)) FirstGetter; typedef typeof(boost::lambda::bind(&VariableSlots::value_type::first, boost::lambda::_1)) FirstGetter;
typedef boost::transform_iterator< typedef boost::transform_iterator<
@ -79,7 +79,7 @@ typename DERIVED::shared_ptr FactorBase<KEY>::Combine(const FactorGraph<DERIVED>
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
template<class CONDITIONAL> template<class CONDITIONAL>
typename CONDITIONAL::shared_ptr FactorBase<KEY>::eliminateFirst() { typename CONDITIONAL::shared_ptr Factor<KEY>::eliminateFirst() {
assert(!keys_.empty()); assert(!keys_.empty());
assertInvariants(); assertInvariants();
KEY eliminated = keys_.front(); KEY eliminated = keys_.front();
@ -90,7 +90,7 @@ typename CONDITIONAL::shared_ptr FactorBase<KEY>::eliminateFirst() {
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
template<class CONDITIONAL> template<class CONDITIONAL>
typename BayesNet<CONDITIONAL>::shared_ptr FactorBase<KEY>::eliminate(size_t nrFrontals) { typename BayesNet<CONDITIONAL>::shared_ptr Factor<KEY>::eliminate(size_t nrFrontals) {
assert(keys_.size() >= nrFrontals); assert(keys_.size() >= nrFrontals);
assertInvariants(); assertInvariants();
typename BayesNet<CONDITIONAL>::shared_ptr fragment(new BayesNet<CONDITIONAL>()); typename BayesNet<CONDITIONAL>::shared_ptr fragment(new BayesNet<CONDITIONAL>());
@ -105,7 +105,7 @@ typename BayesNet<CONDITIONAL>::shared_ptr FactorBase<KEY>::eliminate(size_t nrF
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
void FactorBase<KEY>::permuteWithInverse(const Permutation& inversePermutation) { void Factor<KEY>::permuteWithInverse(const Permutation& inversePermutation) {
BOOST_FOREACH(KEY& key, keys_) { key = inversePermutation[key]; } BOOST_FOREACH(KEY& key, keys_) { key = inversePermutation[key]; }
} }

View File

@ -10,7 +10,7 @@
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
/** /**
* @file FactorBase.h * @file Factor.h
* @brief The base class for all factors * @brief The base class for all factors
* @author Kai Ni * @author Kai Ni
* @author Frank Dellaert * @author Frank Dellaert
@ -33,7 +33,7 @@
namespace gtsam { namespace gtsam {
template<class KEY> class ConditionalBase; template<class KEY> class Conditional;
/** /**
* This is the base class for all factor types. It is templated on a KEY type, * This is the base class for all factor types. It is templated on a KEY type,
@ -49,21 +49,21 @@ template<class KEY> class ConditionalBase;
* derived class. See IndexFactor, JacobianFactor, etc. for examples. * derived class. See IndexFactor, JacobianFactor, etc. for examples.
*/ */
template<typename KEY> template<typename KEY>
class FactorBase : public Testable<FactorBase<KEY> > { class Factor : public Testable<Factor<KEY> > {
public: public:
typedef KEY Key; typedef KEY Key;
typedef FactorBase<Key> This; typedef Factor<Key> This;
/** /**
* Typedef to the conditional type obtained by eliminating this factor. * Typedef to the conditional type obtained by eliminating this factor.
* Derived classes must redefine this. * Derived classes must redefine this.
*/ */
typedef gtsam::ConditionalBase<Key> ConditionalType; typedef gtsam::Conditional<Key> ConditionalType;
/** A shared_ptr to this class. Derived classes must redefine this. */ /** A shared_ptr to this class. Derived classes must redefine this. */
typedef boost::shared_ptr<FactorBase> shared_ptr; typedef boost::shared_ptr<Factor> shared_ptr;
/** Iterator over keys */ /** Iterator over keys */
typedef std::vector<Index>::iterator iterator; typedef std::vector<Index>::iterator iterator;
@ -83,36 +83,36 @@ protected:
public: public:
/** Copy constructor */ /** Copy constructor */
FactorBase(const This& f); Factor(const This& f);
/** Construct from derived type */ /** Construct from derived type */
FactorBase(const ConditionalType& c); Factor(const ConditionalType& c);
/** Constructor from a collection of keys */ /** Constructor from a collection of keys */
template<class KEYITERATOR> FactorBase(KEYITERATOR beginKey, KEYITERATOR endKey) : template<class KEYITERATOR> Factor(KEYITERATOR beginKey, KEYITERATOR endKey) :
keys_(beginKey, endKey) { assertInvariants(); } keys_(beginKey, endKey) { assertInvariants(); }
/** Default constructor for I/O */ /** Default constructor for I/O */
FactorBase() {} Factor() {}
/** Construct unary factor */ /** Construct unary factor */
FactorBase(Key key) : keys_(1) { Factor(Key key) : keys_(1) {
keys_[0] = key; assertInvariants(); } keys_[0] = key; assertInvariants(); }
/** Construct binary factor */ /** Construct binary factor */
FactorBase(Key key1, Key key2) : keys_(2) { Factor(Key key1, Key key2) : keys_(2) {
keys_[0] = key1; keys_[1] = key2; assertInvariants(); } keys_[0] = key1; keys_[1] = key2; assertInvariants(); }
/** Construct ternary factor */ /** 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(); } keys_[0] = key1; keys_[1] = key2; keys_[2] = key3; assertInvariants(); }
/** Construct 4-way factor */ /** 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(); } keys_[0] = key1; keys_[1] = key2; keys_[2] = key3; keys_[3] = key4; assertInvariants(); }
/** Construct n-way factor */ /** Construct n-way factor */
FactorBase(const std::set<Key>& keys) { Factor(const std::set<Key>& keys) {
BOOST_FOREACH(const Key& key, keys) BOOST_FOREACH(const Key& key, keys)
keys_.push_back(key); keys_.push_back(key);
assertInvariants(); } assertInvariants(); }

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include <gtsam/inference/GenericMultifrontalSolver.h> #include <gtsam/inference/GenericMultifrontalSolver.h>
#include <gtsam/inference/FactorBase-inl.h> #include <gtsam/inference/Factor-inl.h>
#include <gtsam/inference/JunctionTree-inl.h> #include <gtsam/inference/JunctionTree-inl.h>
#include <gtsam/inference/BayesNet-inl.h> #include <gtsam/inference/BayesNet-inl.h>

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include <gtsam/inference/GenericSequentialSolver.h> #include <gtsam/inference/GenericSequentialSolver.h>
#include <gtsam/inference/FactorBase-inl.h> #include <gtsam/inference/Factor-inl.h>
#include <gtsam/inference/EliminationTree-inl.h> #include <gtsam/inference/EliminationTree-inl.h>
#include <gtsam/inference/BayesNet-inl.h> #include <gtsam/inference/BayesNet-inl.h>

View File

@ -21,7 +21,7 @@
#include <boost/assign/std/list.hpp> // for operator += #include <boost/assign/std/list.hpp> // for operator +=
using namespace boost::assign; using namespace boost::assign;
#include <gtsam/inference/ConditionalBase.h> #include <gtsam/inference/Conditional.h>
#include <gtsam/inference/ISAM.h> #include <gtsam/inference/ISAM.h>
#include <gtsam/inference/BayesTree-inl.h> #include <gtsam/inference/BayesTree-inl.h>
#include <gtsam/inference/GenericSequentialSolver-inl.h> #include <gtsam/inference/GenericSequentialSolver-inl.h>

View File

@ -20,6 +20,6 @@
namespace gtsam { namespace gtsam {
template class ConditionalBase<Index>; template class Conditional<Index>;
} }

View File

@ -18,7 +18,7 @@
#pragma once #pragma once
#include <gtsam/inference/ConditionalBase.h> #include <gtsam/inference/Conditional.h>
#include <gtsam/inference/IndexFactor.h> #include <gtsam/inference/IndexFactor.h>
namespace gtsam { namespace gtsam {
@ -28,15 +28,15 @@ namespace gtsam {
* GaussianConditional, and also functions as a symbolic conditional with * GaussianConditional, and also functions as a symbolic conditional with
* Index keys, produced by symbolic elimination of IndexFactor. * 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. * unsigned integer.
*/ */
class IndexConditional : public ConditionalBase<Index> { class IndexConditional : public Conditional<Index> {
public: public:
typedef IndexConditional This; typedef IndexConditional This;
typedef ConditionalBase<Index> Base; typedef Conditional<Index> Base;
typedef IndexFactor FactorType; typedef IndexFactor FactorType;
typedef boost::shared_ptr<IndexConditional> shared_ptr; typedef boost::shared_ptr<IndexConditional> shared_ptr;

View File

@ -17,7 +17,7 @@
*/ */
#include <gtsam/base/FastSet.h> #include <gtsam/base/FastSet.h>
#include <gtsam/inference/FactorBase-inl.h> #include <gtsam/inference/Factor-inl.h>
#include <gtsam/inference/IndexFactor.h> #include <gtsam/inference/IndexFactor.h>
#include <gtsam/inference/IndexConditional.h> #include <gtsam/inference/IndexConditional.h>
#include <gtsam/inference/VariableSlots.h> #include <gtsam/inference/VariableSlots.h>
@ -26,7 +26,7 @@ using namespace std;
namespace gtsam { namespace gtsam {
template class FactorBase<Index>; template class Factor<Index>;
IndexFactor::IndexFactor(const IndexConditional& c) : Base(c) {} IndexFactor::IndexFactor(const IndexConditional& c) : Base(c) {}

View File

@ -18,7 +18,7 @@
#pragma once #pragma once
#include <gtsam/inference/FactorBase.h> #include <gtsam/inference/Factor.h>
namespace gtsam { namespace gtsam {
@ -36,15 +36,15 @@ namespace gtsam {
* this and derived classes calling them separately generally does extra * this and derived classes calling them separately generally does extra
* work. * 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. * integer.
*/ */
class IndexFactor : public FactorBase<Index> { class IndexFactor : public Factor<Index> {
public: public:
typedef IndexFactor This; typedef IndexFactor This;
typedef FactorBase<Index> Base; typedef Factor<Index> Base;
/** Elimination produces an IndexConditional */ /** Elimination produces an IndexConditional */
typedef IndexConditional ConditionalType; typedef IndexConditional ConditionalType;

View File

@ -15,7 +15,7 @@ check_PROGRAMS =
#---------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------
# GTSAM core # GTSAM core
headers += FactorBase.h FactorBase-inl.h ConditionalBase.h headers += Factor.h Factor-inl.h Conditional.h
# Symbolic Inference # Symbolic Inference
sources += SymbolicFactorGraph.cpp SymbolicMultifrontalSolver.cpp SymbolicSequentialSolver.cpp sources += SymbolicFactorGraph.cpp SymbolicMultifrontalSolver.cpp SymbolicSequentialSolver.cpp

View File

@ -118,7 +118,7 @@ namespace gtsam {
* variable. The order of the variables within the factor is not changed. * variable. The order of the variables within the factor is not changed.
*/ */
virtual void permuteWithInverse(const Permutation& inversePermutation) { virtual void permuteWithInverse(const Permutation& inversePermutation) {
FactorBase<Index>::permuteWithInverse(inversePermutation); } Factor<Index>::permuteWithInverse(inversePermutation); }
/** /**
* Combine and eliminate several factors. * Combine and eliminate several factors.