Renamed FactorBase to Factor and ConditionalBase to Conditional
parent
85ed6c306d
commit
358e003a57
|
|
@ -26,7 +26,7 @@
|
|||
#include <boost/serialization/nvp.hpp>
|
||||
#include <gtsam/base/types.h>
|
||||
#include <gtsam/base/Testable.h>
|
||||
#include <gtsam/inference/FactorBase.h>
|
||||
#include <gtsam/inference/Factor.h>
|
||||
#include <gtsam/inference/Permutation.h>
|
||||
|
||||
namespace gtsam {
|
||||
|
|
@ -47,7 +47,7 @@ namespace gtsam {
|
|||
* immutable, i.e., practicing functional programming.
|
||||
*/
|
||||
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:
|
||||
|
||||
|
|
@ -62,14 +62,14 @@ protected:
|
|||
public:
|
||||
|
||||
typedef KEY Key;
|
||||
typedef ConditionalBase<Key> This;
|
||||
typedef Conditional<Key> 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<Key> FactorType;
|
||||
typedef gtsam::Factor<Key> FactorType;
|
||||
|
||||
/** A shared_ptr to this class. Derived classes must redefine this. */
|
||||
typedef boost::shared_ptr<This> shared_ptr;
|
||||
|
|
@ -87,22 +87,22 @@ public:
|
|||
typedef boost::iterator_range<const_iterator> 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<Key>& parents) : nrFrontals_(1) {
|
||||
Conditional(Key key, const std::vector<Key>& parents) : nrFrontals_(1) {
|
||||
FactorType::keys_.resize(1 + parents.size());
|
||||
*(beginFrontals()) = key;
|
||||
std::copy(parents.begin(), parents.end(), beginParents());
|
||||
|
|
@ -190,7 +190,7 @@ private:
|
|||
|
||||
/* ************************************************************************* */
|
||||
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(";
|
||||
BOOST_FOREACH(Key key, frontals()) std::cout << " " << key;
|
||||
if (nrParents()>0) std::cout << " |";
|
||||
|
|
@ -200,7 +200,7 @@ void ConditionalBase<KEY>::print(const std::string& s) const {
|
|||
|
||||
/* ************************************************************************* */
|
||||
template<typename KEY>
|
||||
bool ConditionalBase<KEY>::permuteSeparatorWithInverse(const Permutation& inversePermutation) {
|
||||
bool Conditional<KEY>::permuteSeparatorWithInverse(const Permutation& inversePermutation) {
|
||||
#ifndef NDEBUG
|
||||
BOOST_FOREACH(Key key, frontals()) { assert(key == inversePermutation[key]); }
|
||||
#endif
|
||||
|
|
@ -217,7 +217,7 @@ bool ConditionalBase<KEY>::permuteSeparatorWithInverse(const Permutation& invers
|
|||
|
||||
/* ************************************************************************* */
|
||||
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
|
||||
#ifndef NDEBUG
|
||||
BOOST_FOREACH(const Key frontal, this->frontals()) {
|
||||
|
|
@ -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 <gtsam/inference/FactorBase.h>
|
||||
#include <gtsam/inference/Factor.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
|
@ -31,15 +31,15 @@ namespace gtsam {
|
|||
|
||||
/* ************************************************************************* */
|
||||
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>
|
||||
FactorBase<KEY>::FactorBase(const ConditionalType& c) : keys_(c.keys()) {}
|
||||
Factor<KEY>::Factor(const ConditionalType& c) : keys_(c.keys()) {}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<typename KEY>
|
||||
void FactorBase<KEY>::assertInvariants() const {
|
||||
void Factor<KEY>::assertInvariants() const {
|
||||
#ifndef NDEBUG
|
||||
std::set<Index> uniqueSorted(keys_.begin(), keys_.end());
|
||||
assert(uniqueSorted.size() == keys_.size());
|
||||
|
|
@ -49,7 +49,7 @@ void FactorBase<KEY>::assertInvariants() const {
|
|||
|
||||
/* ************************************************************************* */
|
||||
template<typename KEY>
|
||||
void FactorBase<KEY>::print(const std::string& s) const {
|
||||
void Factor<KEY>::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<KEY>::print(const std::string& s) const {
|
|||
|
||||
/* ************************************************************************* */
|
||||
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_;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<typename KEY>
|
||||
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 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<KEY>::Combine(const FactorGraph<DERIVED>
|
|||
/* ************************************************************************* */
|
||||
template<typename KEY>
|
||||
template<class CONDITIONAL>
|
||||
typename CONDITIONAL::shared_ptr FactorBase<KEY>::eliminateFirst() {
|
||||
typename CONDITIONAL::shared_ptr Factor<KEY>::eliminateFirst() {
|
||||
assert(!keys_.empty());
|
||||
assertInvariants();
|
||||
KEY eliminated = keys_.front();
|
||||
|
|
@ -90,7 +90,7 @@ typename CONDITIONAL::shared_ptr FactorBase<KEY>::eliminateFirst() {
|
|||
/* ************************************************************************* */
|
||||
template<typename KEY>
|
||||
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);
|
||||
assertInvariants();
|
||||
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>
|
||||
void FactorBase<KEY>::permuteWithInverse(const Permutation& inversePermutation) {
|
||||
void Factor<KEY>::permuteWithInverse(const Permutation& inversePermutation) {
|
||||
BOOST_FOREACH(KEY& key, keys_) { key = inversePermutation[key]; }
|
||||
}
|
||||
|
||||
|
|
@ -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 KEY> class ConditionalBase;
|
||||
template<class KEY> class Conditional;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
template<typename KEY>
|
||||
class FactorBase : public Testable<FactorBase<KEY> > {
|
||||
class Factor : public Testable<Factor<KEY> > {
|
||||
|
||||
public:
|
||||
|
||||
typedef KEY Key;
|
||||
typedef FactorBase<Key> This;
|
||||
typedef Factor<Key> This;
|
||||
|
||||
/**
|
||||
* Typedef to the conditional type obtained by eliminating this factor.
|
||||
* 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. */
|
||||
typedef boost::shared_ptr<FactorBase> shared_ptr;
|
||||
typedef boost::shared_ptr<Factor> shared_ptr;
|
||||
|
||||
/** Iterator over keys */
|
||||
typedef std::vector<Index>::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<class KEYITERATOR> FactorBase(KEYITERATOR beginKey, KEYITERATOR endKey) :
|
||||
template<class KEYITERATOR> 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<Key>& keys) {
|
||||
Factor(const std::set<Key>& keys) {
|
||||
BOOST_FOREACH(const Key& key, keys)
|
||||
keys_.push_back(key);
|
||||
assertInvariants(); }
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#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/BayesNet-inl.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#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/BayesNet-inl.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include <boost/assign/std/list.hpp> // for operator +=
|
||||
using namespace boost::assign;
|
||||
|
||||
#include <gtsam/inference/ConditionalBase.h>
|
||||
#include <gtsam/inference/Conditional.h>
|
||||
#include <gtsam/inference/ISAM.h>
|
||||
#include <gtsam/inference/BayesTree-inl.h>
|
||||
#include <gtsam/inference/GenericSequentialSolver-inl.h>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@
|
|||
|
||||
namespace gtsam {
|
||||
|
||||
template class ConditionalBase<Index>;
|
||||
template class Conditional<Index>;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <gtsam/inference/ConditionalBase.h>
|
||||
#include <gtsam/inference/Conditional.h>
|
||||
#include <gtsam/inference/IndexFactor.h>
|
||||
|
||||
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<Index> {
|
||||
class IndexConditional : public Conditional<Index> {
|
||||
|
||||
public:
|
||||
|
||||
typedef IndexConditional This;
|
||||
typedef ConditionalBase<Index> Base;
|
||||
typedef Conditional<Index> Base;
|
||||
typedef IndexFactor FactorType;
|
||||
typedef boost::shared_ptr<IndexConditional> shared_ptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#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/IndexConditional.h>
|
||||
#include <gtsam/inference/VariableSlots.h>
|
||||
|
|
@ -26,7 +26,7 @@ using namespace std;
|
|||
|
||||
namespace gtsam {
|
||||
|
||||
template class FactorBase<Index>;
|
||||
template class Factor<Index>;
|
||||
|
||||
IndexFactor::IndexFactor(const IndexConditional& c) : Base(c) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <gtsam/inference/FactorBase.h>
|
||||
#include <gtsam/inference/Factor.h>
|
||||
|
||||
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<Index> {
|
||||
class IndexFactor : public Factor<Index> {
|
||||
|
||||
public:
|
||||
|
||||
typedef IndexFactor This;
|
||||
typedef FactorBase<Index> Base;
|
||||
typedef Factor<Index> Base;
|
||||
|
||||
/** Elimination produces an IndexConditional */
|
||||
typedef IndexConditional ConditionalType;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<Index>::permuteWithInverse(inversePermutation); }
|
||||
Factor<Index>::permuteWithInverse(inversePermutation); }
|
||||
|
||||
/**
|
||||
* Combine and eliminate several factors.
|
||||
|
|
|
|||
Loading…
Reference in New Issue