diff --git a/gtsam/inference/EliminationTree.h b/gtsam/inference/EliminationTree.h index e2dab8b80..82480f99e 100644 --- a/gtsam/inference/EliminationTree.h +++ b/gtsam/inference/EliminationTree.h @@ -110,8 +110,8 @@ public: bool equals(const EliminationTree& other, double tol = 1e-9) const; /** Eliminate the factors to a Bayes Net - * @param function The function to use to eliminate, see the static member - * functions of GaussianFactorGraph + * @param function The function to use to eliminate, see the namespace functions + * in GaussianFactorGraph.h * @return The BayesNet resulting from elimination */ typename BayesNet::shared_ptr eliminate(Eliminate function) const; diff --git a/gtsam/inference/JunctionTree.h b/gtsam/inference/JunctionTree.h index f4e591b70..f1e85db0b 100644 --- a/gtsam/inference/JunctionTree.h +++ b/gtsam/inference/JunctionTree.h @@ -30,6 +30,13 @@ namespace gtsam { /** + * In gtsam a junction tree is an intermediate data structure in multifrontal + * variable elimination. Each node is a cluster of factors, along with a + * clique of variables that are eliminated all at once. The tree structure and + * elimination method are exactly analagous to the EliminationTree, except that + * in the JunctionTree, at each node multiple variables are eliminated at the same + * time. + * * A junction tree (or clique-tree) is a cluster-tree where each node k represents a * clique (maximal fully connected subset) of an associated chordal graph, such as a * chordal Bayes net resulting from elimination. In GTSAM the BayesTree is used to @@ -41,15 +48,17 @@ namespace gtsam { public: - // In a junction tree each cluster is associated with a clique + /// In a junction tree each cluster is associated with a clique typedef typename ClusterTree::Cluster Clique; - typedef typename Clique::shared_ptr sharedClique; + typedef typename Clique::shared_ptr sharedClique; ///< Shared pointer to a clique + /// The BayesTree type produced by elimination typedef class BayesTree BayesTree; + /// Shared pointer to this class typedef boost::shared_ptr > shared_ptr; - // And we will frequently refer to a symbolic Bayes tree + /// We will frequently refer to a symbolic Bayes tree, used to find the clique structure typedef gtsam::BayesTree SymbolicBayesTree; private: @@ -73,13 +82,29 @@ namespace gtsam { /** Default constructor */ JunctionTree() {} - /** Construct from a factor graph. Computes a variable index. */ - JunctionTree(const FG& fg); + /** Named constructor to build the junction tree of a factor graph. Note + * that this has to compute the column structure as a VariableIndex, so if you + * already have this precomputed, use the JunctionTree(const FG&, const VariableIndex&) + * constructor instead. + * @param factorGraph The factor graph for which to build the elimination tree + */ + JunctionTree(const FG& factorGraph); - /** Construct from a factor graph and a pre-computed variable index. */ + /** Construct from a factor graph and pre-computed variable index. + * @param factorGraph The factor graph for which to build the junction tree + * @param structure The set of factors involving each variable. If this is not + * precomputed, you can call the JunctionTree(const FG&) + * constructor instead. + */ JunctionTree(const FG& fg, const VariableIndex& variableIndex); - // eliminate the factors in the subgraphs + /** Eliminate the factors in the subgraphs to produce a BayesTree. + * @param function The function used to eliminate, see the namespace functions + * in GaussianFactorGraph.h + * @param cache Whether to cache the intermediate elimination factors for use in ISAM2 - this + * should always be false when called outside of ISAM2 (this will be fixed in the future). + * @return The BayesTree resulting from elimination + */ typename BayesTree::sharedClique eliminate(typename FG::Eliminate function, bool cache = false) const; diff --git a/gtsam/linear/GaussianFactor.h b/gtsam/linear/GaussianFactor.h index 6fb25c106..7f4b90748 100644 --- a/gtsam/linear/GaussianFactor.h +++ b/gtsam/linear/GaussianFactor.h @@ -11,8 +11,8 @@ /** * @file GaussianFactor.h - * @brief Linear Factor....A Gaussian - * @brief linearFactor + * @brief A factor with a quadratic error function - a Gaussian + * @brief GaussianFactor * @author Richard Roberts, Christian Potthast */ @@ -34,7 +34,8 @@ namespace gtsam { template class BayesNet; /** - * Base Class for a linear factor. + * An abstract virtual base class for JacobianFactor and HessianFactor. + * A GaussianFactor has a quadratic error function. * GaussianFactor is non-mutable (all methods const!). * The factor value is exp(-0.5*||Ax-b||^2) */ diff --git a/gtsam/linear/GaussianFactorGraph.h b/gtsam/linear/GaussianFactorGraph.h index a55b679f6..921cb7958 100644 --- a/gtsam/linear/GaussianFactorGraph.h +++ b/gtsam/linear/GaussianFactorGraph.h @@ -32,7 +32,8 @@ namespace gtsam { struct SharedDiagonal; - /** unnormalized error */ + /** unnormalized error + * \todo Make this a member function - affects SubgraphPreconditioner */ template double gaussianError(const FactorGraph& fg, const VectorValues& x) { double total_error = 0.; @@ -42,13 +43,15 @@ namespace gtsam { return total_error; } - /** return A*x-b */ + /** return A*x-b + * \todo Make this a member function - affects SubgraphPreconditioner */ template Errors gaussianErrors(const FactorGraph& fg, const VectorValues& x) { return *gaussianErrors_(fg, x); } - /** shared pointer version */ + /** shared pointer version + * \todo Make this a member function - affects SubgraphPreconditioner */ template boost::shared_ptr gaussianErrors_(const FactorGraph& fg, const VectorValues& x) { boost::shared_ptr e(new Errors);