From d99d047a778d334aaff12bb18baf8e76535ae6ab Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Tue, 1 Mar 2011 16:42:57 +0000 Subject: [PATCH] Renamed typedef name Factor to FactorType --- gtsam/inference/BayesTree-inl.h | 40 +++++++++++++++--------------- gtsam/inference/BayesTree.h | 12 ++++----- gtsam/inference/ConditionalBase.h | 40 +++++++++++++++--------------- gtsam/inference/FactorGraph.h | 8 +++--- gtsam/inference/ISAM-inl.h | 2 +- gtsam/inference/IndexConditional.h | 2 +- gtsam/inference/JunctionTree-inl.h | 6 ++--- gtsam/inference/JunctionTree.h | 2 +- gtsam/linear/GaussianConditional.h | 2 +- gtsam/linear/GaussianISAM.h | 2 +- 10 files changed, 58 insertions(+), 58 deletions(-) diff --git a/gtsam/inference/BayesTree-inl.h b/gtsam/inference/BayesTree-inl.h index 03175dec9..4a4495c15 100644 --- a/gtsam/inference/BayesTree-inl.h +++ b/gtsam/inference/BayesTree-inl.h @@ -296,17 +296,17 @@ namespace gtsam { } // The root conditional - FactorGraph p_R(*R); + FactorGraph p_R(*R); // The parent clique has a CONDITIONAL for each frontal node in Fp // so we can obtain P(Fp|Sp) in factor graph form - FactorGraph p_Fp_Sp(*parent); + FactorGraph p_Fp_Sp(*parent); // If not the base case, obtain the parent shortcut P(Sp|R) as factors - FactorGraph p_Sp_R(parent->shortcut(R)); + FactorGraph p_Sp_R(parent->shortcut(R)); // now combine P(Cp|R) = P(Fp|Sp) * P(Sp|R) - FactorGraph p_Cp_R; + FactorGraph p_Cp_R; p_Cp_R.push_back(p_R); p_Cp_R.push_back(p_Fp_Sp); p_Cp_R.push_back(p_Sp_R); @@ -345,9 +345,9 @@ namespace gtsam { vector(variablesAtBack.begin(), variablesAtBack.end()), R->back()->key() + 1); Permutation::shared_ptr toBackInverse(toBack.inverse()); - BOOST_FOREACH(const typename CONDITIONAL::Factor::shared_ptr& factor, p_Cp_R) { + BOOST_FOREACH(const typename CONDITIONAL::FactorType::shared_ptr& factor, p_Cp_R) { factor->permuteWithInverse(*toBackInverse); } - typename BayesNet::shared_ptr eliminated(EliminationTree::Create(p_Cp_R)->eliminate()); + typename BayesNet::shared_ptr eliminated(EliminationTree::Create(p_Cp_R)->eliminate()); // Take only the conditionals for p(S|R). We check for each variable being // in the separator set because if some separator variables overlap with @@ -380,7 +380,7 @@ namespace gtsam { // Because the root clique could be very big. /* ************************************************************************* */ template - FactorGraph BayesTree::Clique::marginal(shared_ptr R) { + FactorGraph BayesTree::Clique::marginal(shared_ptr R) { // If we are the root, just return this root // NOTE: immediately cast to a factor graph if (R.get()==this) return *R; @@ -391,18 +391,18 @@ namespace gtsam { p_FSR.push_back(*R); assertInvariants(); - return *GenericSequentialSolver(p_FSR).jointFactorGraph(keys()); + return *GenericSequentialSolver(p_FSR).jointFactorGraph(keys()); } /* ************************************************************************* */ // P(C1,C2) = \int_R P(F1|S1) P(S1|R) P(F2|S1) P(S2|R) P(R) /* ************************************************************************* */ template - FactorGraph BayesTree::Clique::joint(shared_ptr C2, shared_ptr R) { + FactorGraph BayesTree::Clique::joint(shared_ptr C2, shared_ptr R) { // For now, assume neither is the root // Combine P(F1|S1), P(S1|R), P(F2|S2), P(S2|R), and P(R) - FactorGraph joint; + FactorGraph joint; if (!isRoot()) joint.push_back(*this); // P(F1|S1) if (!isRoot()) joint.push_back(shortcut(R)); // P(S1|R) if (!C2->isRoot()) joint.push_back(*C2); // P(F2|S2) @@ -420,7 +420,7 @@ namespace gtsam { vector keys12vector; keys12vector.reserve(keys12.size()); keys12vector.insert(keys12vector.begin(), keys12.begin(), keys12.end()); assertInvariants(); - return *GenericSequentialSolver(joint).jointFactorGraph(keys12vector); + return *GenericSequentialSolver(joint).jointFactorGraph(keys12vector); } /* ************************************************************************* */ @@ -729,15 +729,15 @@ namespace gtsam { // First finds clique marginal then marginalizes that /* ************************************************************************* */ template - typename CONDITIONAL::Factor::shared_ptr BayesTree::marginalFactor(Index key) const { + typename CONDITIONAL::FactorType::shared_ptr BayesTree::marginalFactor(Index key) const { // get clique containing key sharedClique clique = (*this)[key]; // calculate or retrieve its marginal - FactorGraph cliqueMarginal = clique->marginal(root_); + FactorGraph cliqueMarginal = clique->marginal(root_); - return GenericSequentialSolver(cliqueMarginal).marginalFactor(key); + return GenericSequentialSolver(cliqueMarginal).marginalFactor(key); } /* ************************************************************************* */ @@ -745,29 +745,29 @@ namespace gtsam { typename BayesNet::shared_ptr BayesTree::marginalBayesNet(Index key) const { // calculate marginal as a factor graph - FactorGraph fg; + FactorGraph fg; fg.push_back(this->marginalFactor(key)); // eliminate factor graph marginal to a Bayes net - return GenericSequentialSolver(fg).eliminate(); + return GenericSequentialSolver(fg).eliminate(); } /* ************************************************************************* */ // Find two cliques, their joint, then marginalizes /* ************************************************************************* */ template - typename FactorGraph::shared_ptr + typename FactorGraph::shared_ptr BayesTree::joint(Index key1, Index key2) const { // get clique C1 and C2 sharedClique C1 = (*this)[key1], C2 = (*this)[key2]; // calculate joint - FactorGraph p_C1C2(C1->joint(C2, root_)); + FactorGraph p_C1C2(C1->joint(C2, root_)); // eliminate remaining factor graph to get requested joint vector key12(2); key12[0] = key1; key12[1] = key2; - return GenericSequentialSolver(p_C1C2).jointFactorGraph(key12); + return GenericSequentialSolver(p_C1C2).jointFactorGraph(key12); } /* ************************************************************************* */ @@ -775,7 +775,7 @@ namespace gtsam { typename BayesNet::shared_ptr BayesTree::jointBayesNet(Index key1, Index key2) const { // eliminate factor graph marginal to a Bayes net - return GenericSequentialSolver(*this->joint(key1, key2)).eliminate(); + return GenericSequentialSolver(*this->joint(key1, key2)).eliminate(); } /* ************************************************************************* */ diff --git a/gtsam/inference/BayesTree.h b/gtsam/inference/BayesTree.h index 4ab5c08ae..8f9a1865a 100644 --- a/gtsam/inference/BayesTree.h +++ b/gtsam/inference/BayesTree.h @@ -63,7 +63,7 @@ namespace gtsam { weak_ptr parent_; std::list children_; std::list separator_; /** separator keys */ - typename CONDITIONAL::Factor::shared_ptr cachedFactor_; + typename CONDITIONAL::FactorType::shared_ptr cachedFactor_; friend class BayesTree; @@ -96,7 +96,7 @@ namespace gtsam { size_t treeSize() const; /** Access the cached factor (this is a hack) */ - typename CONDITIONAL::Factor::shared_ptr& cachedFactor() { return cachedFactor_; } + typename CONDITIONAL::FactorType::shared_ptr& cachedFactor() { return cachedFactor_; } /** print this node and entire subtree below it */ void printTree(const std::string& indent="") const; @@ -116,10 +116,10 @@ namespace gtsam { BayesNet shortcut(shared_ptr root); /** return the marginal P(C) of the clique */ - FactorGraph marginal(shared_ptr root); + FactorGraph marginal(shared_ptr root); /** return the joint P(C1,C2), where C1==this. TODO: not a method? */ - FactorGraph joint(shared_ptr C2, shared_ptr root); + FactorGraph joint(shared_ptr C2, shared_ptr root); }; // \struct Clique @@ -262,7 +262,7 @@ namespace gtsam { CliqueData getCliqueData() const; /** return marginal on any variable */ - typename CONDITIONAL::Factor::shared_ptr marginalFactor(Index key) const; + typename CONDITIONAL::FactorType::shared_ptr marginalFactor(Index key) const; /** * return marginal on any variable, as a Bayes Net @@ -272,7 +272,7 @@ namespace gtsam { typename BayesNet::shared_ptr marginalBayesNet(Index key) const; /** return joint on two variables */ - typename FactorGraph::shared_ptr joint(Index key1, Index key2) const; + typename FactorGraph::shared_ptr joint(Index key1, Index key2) const; /** return joint on two variables as a BayesNet */ typename BayesNet::shared_ptr jointBayesNet(Index key1, Index key2) const; diff --git a/gtsam/inference/ConditionalBase.h b/gtsam/inference/ConditionalBase.h index 4df461200..eb1778e3c 100644 --- a/gtsam/inference/ConditionalBase.h +++ b/gtsam/inference/ConditionalBase.h @@ -69,16 +69,16 @@ public: * conditional can be converted to using a factor constructor. Derived * classes must redefine this. */ - typedef gtsam::FactorBase Factor; + typedef gtsam::FactorBase FactorType; /** A shared_ptr to this class. Derived classes must redefine this. */ typedef boost::shared_ptr shared_ptr; /** Iterator over keys */ - typedef typename Factor::iterator iterator; + typedef typename FactorType::iterator iterator; /** Const iterator over keys */ - typedef typename Factor::const_iterator const_iterator; + typedef typename FactorType::const_iterator const_iterator; /** View of the frontal keys (call frontals()) */ typedef boost::iterator_range Frontals; @@ -90,20 +90,20 @@ public: ConditionalBase() : nrFrontals_(0) {} /** No parents */ - ConditionalBase(Key key) : Factor(key), nrFrontals_(1) {} + ConditionalBase(Key key) : FactorType(key), nrFrontals_(1) {} /** Single parent */ - ConditionalBase(Key key, Key parent) : Factor(key, parent), nrFrontals_(1) {} + ConditionalBase(Key key, Key parent) : FactorType(key, parent), nrFrontals_(1) {} /** Two parents */ - ConditionalBase(Key key, Key parent1, Key parent2) : Factor(key, parent1, parent2), nrFrontals_(1) {} + ConditionalBase(Key key, Key parent1, Key parent2) : FactorType(key, parent1, parent2), nrFrontals_(1) {} /** Three parents */ - ConditionalBase(Key key, Key parent1, Key parent2, Key parent3) : Factor(key, parent1, parent2, parent3), nrFrontals_(1) {} + ConditionalBase(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) { - Factor::keys_.resize(1 + parents.size()); + FactorType::keys_.resize(1 + parents.size()); *(beginFrontals()) = key; std::copy(parents.begin(), parents.end(), beginParents()); } @@ -130,28 +130,28 @@ public: /** check equality */ template bool equals(const DERIVED& c, double tol = 1e-9) const { - return nrFrontals_ == c.nrFrontals_ && Factor::equals(c, tol); } + return nrFrontals_ == c.nrFrontals_ && FactorType::equals(c, tol); } /** return the number of frontals */ size_t nrFrontals() const { return nrFrontals_; } /** return the number of parents */ - size_t nrParents() const { return Factor::keys_.size() - nrFrontals_; } + size_t nrParents() const { return FactorType::keys_.size() - nrFrontals_; } /** Special accessor when there is only one frontal variable. */ - Key key() const { assert(nrFrontals_==1); return Factor::keys_[0]; } + Key key() const { assert(nrFrontals_==1); return FactorType::keys_[0]; } /** Iterators over frontal and parent variables. */ - const_iterator beginFrontals() const { return Factor::keys_.begin(); } - const_iterator endFrontals() const { return Factor::keys_.begin()+nrFrontals_; } - const_iterator beginParents() const { return Factor::keys_.begin()+nrFrontals_; } - const_iterator endParents() const { return Factor::keys_.end(); } + const_iterator beginFrontals() const { return FactorType::keys_.begin(); } + const_iterator endFrontals() const { return FactorType::keys_.begin()+nrFrontals_; } + const_iterator beginParents() const { return FactorType::keys_.begin()+nrFrontals_; } + const_iterator endParents() const { return FactorType::keys_.end(); } /** Mutable iterators and accessors */ - iterator beginFrontals() { return Factor::keys_.begin(); } - iterator endFrontals() { return Factor::keys_.begin()+nrFrontals_; } - iterator beginParents() { return Factor::keys_.begin()+nrFrontals_; } - iterator endParents() { return Factor::keys_.end(); } + iterator beginFrontals() { return FactorType::keys_.begin(); } + iterator endFrontals() { return FactorType::keys_.begin()+nrFrontals_; } + iterator beginParents() { return FactorType::keys_.begin()+nrFrontals_; } + iterator endParents() { return FactorType::keys_.end(); } boost::iterator_range frontals() { return boost::make_iterator_range(beginFrontals(), endFrontals()); } boost::iterator_range parents() { return boost::make_iterator_range(beginParents(), endParents()); } @@ -226,7 +226,7 @@ void ConditionalBase::permuteWithInverse(const Permutation& inversePermutat } } #endif - Factor::permuteWithInverse(inversePermutation); + FactorType::permuteWithInverse(inversePermutation); } } diff --git a/gtsam/inference/FactorGraph.h b/gtsam/inference/FactorGraph.h index 99455b08a..eefd7f09f 100644 --- a/gtsam/inference/FactorGraph.h +++ b/gtsam/inference/FactorGraph.h @@ -41,7 +41,7 @@ namespace gtsam { template class FactorGraph: public Testable > { public: - typedef FACTOR Factor; + typedef FACTOR FactorType; typedef boost::shared_ptr > shared_ptr; typedef typename boost::shared_ptr sharedFactor; typedef typename std::vector::iterator iterator; @@ -115,7 +115,7 @@ namespace gtsam { typename RELATED::shared_ptr ret(new RELATED); ret->reserve(this->size()); BOOST_FOREACH(const sharedFactor& factor, *this) { - typename RELATED::Factor::shared_ptr castedFactor(boost::dynamic_pointer_cast(factor)); + typename RELATED::FactorType::shared_ptr castedFactor(boost::dynamic_pointer_cast(factor)); if(castedFactor) ret->push_back(castedFactor); else @@ -133,11 +133,11 @@ namespace gtsam { typename TARGET::shared_ptr ret(new TARGET); ret->reserve(this->size()); BOOST_FOREACH(const sharedFactor& factor, *this) { - typename TARGET::Factor::shared_ptr castedFactor(boost::dynamic_pointer_cast(factor)); + typename TARGET::FactorType::shared_ptr castedFactor(boost::dynamic_pointer_cast(factor)); if(castedFactor) ret->push_back(castedFactor); else - ret->push_back(typename TARGET::Factor::shared_ptr(new typename TARGET::Factor(*factor))); + ret->push_back(typename TARGET::FactorType::shared_ptr(new typename TARGET::FactorType(*factor))); } return ret; } diff --git a/gtsam/inference/ISAM-inl.h b/gtsam/inference/ISAM-inl.h index 270998878..c204954d6 100644 --- a/gtsam/inference/ISAM-inl.h +++ b/gtsam/inference/ISAM-inl.h @@ -53,7 +53,7 @@ namespace gtsam { factors.push_back(newFactors); // eliminate into a Bayes net - typename BayesNet::shared_ptr bayesNet = GenericSequentialSolver(factors).eliminate(); + typename BayesNet::shared_ptr bayesNet = GenericSequentialSolver(factors).eliminate(); // insert conditionals back in, straight into the topless bayesTree typename BayesNet::const_reverse_iterator rit; diff --git a/gtsam/inference/IndexConditional.h b/gtsam/inference/IndexConditional.h index c6d19eb63..cfea44575 100644 --- a/gtsam/inference/IndexConditional.h +++ b/gtsam/inference/IndexConditional.h @@ -37,7 +37,7 @@ namespace gtsam { typedef IndexConditional This; typedef ConditionalBase Base; - typedef IndexFactor Factor; + typedef IndexFactor FactorType; typedef boost::shared_ptr shared_ptr; /** Empty Constructor to make serialization possible */ diff --git a/gtsam/inference/JunctionTree-inl.h b/gtsam/inference/JunctionTree-inl.h index 22cd239bc..34c30b5ff 100644 --- a/gtsam/inference/JunctionTree-inl.h +++ b/gtsam/inference/JunctionTree-inl.h @@ -89,7 +89,7 @@ namespace gtsam { Index maxVar = 0; for(size_t i=0; ibegin(), fg[i]->end()); + typename FG::FactorType::const_iterator min = std::min_element(fg[i]->begin(), fg[i]->end()); if(min == fg[i]->end()) lowestOrdered[i] = numeric_limits::max(); else { @@ -171,8 +171,8 @@ namespace gtsam { // Now that we know which factors and variables, and where variables // come from and go to, create and eliminate the new joint factor. tic(2, "CombineAndEliminate"); - pair::shared_ptr, typename FG::sharedFactor> eliminated( - FG::Factor::CombineAndEliminate(fg, current->frontal.size())); + pair::shared_ptr, typename FG::sharedFactor> eliminated( + FG::FactorType::CombineAndEliminate(fg, current->frontal.size())); toc(2, "CombineAndEliminate"); assert(std::equal(eliminated.second->begin(), eliminated.second->end(), current->separator.begin())); diff --git a/gtsam/inference/JunctionTree.h b/gtsam/inference/JunctionTree.h index 879e1ff75..97ec12430 100644 --- a/gtsam/inference/JunctionTree.h +++ b/gtsam/inference/JunctionTree.h @@ -46,7 +46,7 @@ namespace gtsam { typedef typename ClusterTree::Cluster Clique; typedef typename Clique::shared_ptr sharedClique; - typedef class BayesTree BayesTree; + typedef class BayesTree BayesTree; typedef boost::shared_ptr > shared_ptr; diff --git a/gtsam/linear/GaussianConditional.h b/gtsam/linear/GaussianConditional.h index a9c788bce..c6cc7ef23 100644 --- a/gtsam/linear/GaussianConditional.h +++ b/gtsam/linear/GaussianConditional.h @@ -42,7 +42,7 @@ class GaussianFactor; class GaussianConditional : public IndexConditional { public: - typedef GaussianFactor Factor; + typedef GaussianFactor FactorType; typedef boost::shared_ptr shared_ptr; /** Store the conditional matrix as upper-triangular column-major */ diff --git a/gtsam/linear/GaussianISAM.h b/gtsam/linear/GaussianISAM.h index 37653c485..abbfb6a5a 100644 --- a/gtsam/linear/GaussianISAM.h +++ b/gtsam/linear/GaussianISAM.h @@ -45,7 +45,7 @@ public: // update dimensions BOOST_FOREACH(const typename FACTORGRAPH::sharedFactor& factor, newFactors) { - for(typename FACTORGRAPH::Factor::const_iterator key = factor->begin(); key != factor->end(); ++key) { + for(typename FACTORGRAPH::FactorType::const_iterator key = factor->begin(); key != factor->end(); ++key) { if(*key >= dims_.size()) dims_.resize(*key + 1); if(dims_[*key] == 0)