Merge branch 'master' into new_wrap_local

release/4.3a0
Alex Cunningham 2012-06-28 16:12:57 +00:00
parent fb00f4b834
commit 4abefa3cbe
26 changed files with 72 additions and 34 deletions

View File

@ -50,6 +50,7 @@ else()
option(GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" ON) option(GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" ON)
endif() endif()
option(GTSAM_BUILD_STATIC_LIBRARY "Enable/Disable building of a static version of gtsam" ON) option(GTSAM_BUILD_STATIC_LIBRARY "Enable/Disable building of a static version of gtsam" ON)
option(GTSAM_BUILD_TYPE_POSTFIXES "Enable/Disable appending the build type to the name of compiled libraries" OFF)
option(GTSAM_USE_QUATERNIONS "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices" OFF) option(GTSAM_USE_QUATERNIONS "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices" OFF)
if(MSVC) if(MSVC)
option(GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" OFF) option(GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" OFF)
@ -170,6 +171,7 @@ print_config_flag(${GTSAM_BUILD_TESTS} "Build Tests
print_config_flag(${GTSAM_BUILD_WRAP} "Build Wrap ") print_config_flag(${GTSAM_BUILD_WRAP} "Build Wrap ")
print_config_flag(${GTSAM_BUILD_SHARED_LIBRARY} "Build shared GTSAM Library ") print_config_flag(${GTSAM_BUILD_SHARED_LIBRARY} "Build shared GTSAM Library ")
print_config_flag(${GTSAM_BUILD_STATIC_LIBRARY} "Build static GTSAM Library ") print_config_flag(${GTSAM_BUILD_STATIC_LIBRARY} "Build static GTSAM Library ")
print_config_flag(${GTSAM_BUILD_TYPE_POSTFIXES} "Put build-type in library name ")
print_config_flag(${GTSAM_BUILD_CONVENIENCE_LIBRARIES} "Build Convenience Libraries ") print_config_flag(${GTSAM_BUILD_CONVENIENCE_LIBRARIES} "Build Convenience Libraries ")
if(GTSAM_UNSTABLE_AVAILABLE) if(GTSAM_UNSTABLE_AVAILABLE)
print_config_flag(${GTSAM_BUILD_UNSTABLE} "Build libgtsam_unstable ") print_config_flag(${GTSAM_BUILD_UNSTABLE} "Build libgtsam_unstable ")

30
gtsam/base/types.cpp Normal file
View File

@ -0,0 +1,30 @@
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file types.h
* @brief Typedefs for easier changing of types
* @author Richard Roberts
* @date Aug 21, 2010
* @addtogroup base
*/
#include <boost/lexical_cast.hpp>
#include <gtsam/base/types.h>
namespace gtsam {
std::string _defaultIndexFormatter(Index j) {
return boost::lexical_cast<std::string>(j);
}
}

View File

@ -21,6 +21,7 @@
#include <cstddef> #include <cstddef>
#include <string>
#include <boost/function/function1.hpp> #include <boost/function/function1.hpp>
namespace gtsam { namespace gtsam {
@ -32,6 +33,11 @@ namespace gtsam {
* to a nonlinear key and then to a Symbol. */ * to a nonlinear key and then to a Symbol. */
typedef boost::function<std::string(Index)> IndexFormatter; typedef boost::function<std::string(Index)> IndexFormatter;
std::string _defaultIndexFormatter(Index j);
/** The default IndexFormatter outputs the index */
static const IndexFormatter DefaultIndexFormatter = &_defaultIndexFormatter;
/** /**
* Helper class that uses templates to select between two types based on * Helper class that uses templates to select between two types based on
* whether TEST_TYPE is const or not. * whether TEST_TYPE is const or not.

View File

@ -64,8 +64,8 @@ namespace gtsam {
/** GTSAM-style print */ /** GTSAM-style print */
void print(const std::string& s = "Discrete Conditional: ", void print(const std::string& s = "Discrete Conditional: ",
const boost::function<std::string(Index)>& formatter const IndexFormatter& formatter
= &(boost::lexical_cast<std::string, Index>)) const { =DefaultIndexFormatter) const {
std::cout << s << std::endl; std::cout << s << std::endl;
IndexConditional::print(s, formatter); IndexConditional::print(s, formatter);
Potentials::print(s); Potentials::print(s);

View File

@ -83,8 +83,8 @@ namespace gtsam {
// print // print
virtual void print(const std::string& s = "DiscreteFactor\n", virtual void print(const std::string& s = "DiscreteFactor\n",
const boost::function<std::string(Index)>& formatter const IndexFormatter& formatter
= &(boost::lexical_cast<std::string, Index>)) const { =DefaultIndexFormatter) const {
IndexFactor::print(s,formatter); IndexFactor::print(s,formatter);
} }

View File

@ -78,7 +78,7 @@ public:
/// print /// print
void print(const std::string& s = "DiscreteFactorGraph", void print(const std::string& s = "DiscreteFactorGraph",
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const; const IndexFormatter& formatter =DefaultIndexFormatter) const;
}; };
// DiscreteFactorGraph // DiscreteFactorGraph

View File

@ -35,7 +35,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
template<class CONDITIONAL> template<class CONDITIONAL>
void BayesNet<CONDITIONAL>::print(const std::string& s, void BayesNet<CONDITIONAL>::print(const std::string& s,
const boost::function<std::string(KeyType)>& formatter) const { const IndexFormatter& formatter) const {
std::cout << s; std::cout << s;
BOOST_REVERSE_FOREACH(sharedConditional conditional, conditionals_) BOOST_REVERSE_FOREACH(sharedConditional conditional, conditionals_)
conditional->print("Conditional", formatter); conditional->print("Conditional", formatter);

View File

@ -91,7 +91,7 @@ public:
/** print */ /** print */
void print(const std::string& s = "", void print(const std::string& s = "",
const boost::function<std::string(KeyType)>& formatter = &(boost::lexical_cast<std::string, KeyType>)) const; const IndexFormatter& formatter = DefaultIndexFormatter) const;
/** print statistics */ /** print statistics */
void printStats(const std::string& s = "") const; void printStats(const std::string& s = "") const;

View File

@ -71,7 +71,7 @@ namespace gtsam {
// A convenience class for a list of shared cliques // A convenience class for a list of shared cliques
struct Cliques : public std::list<sharedClique> { struct Cliques : public std::list<sharedClique> {
void print(const std::string& s = "Cliques", void print(const std::string& s = "Cliques",
const IndexFormatter& indexFormatter = &(boost::lexical_cast<std::string, Index>)) const; const IndexFormatter& indexFormatter = DefaultIndexFormatter) const;
bool equals(const Cliques& other, double tol = 1e-9) const; bool equals(const Cliques& other, double tol = 1e-9) const;
}; };
@ -178,7 +178,7 @@ namespace gtsam {
/** print */ /** print */
void print(const std::string& s = "", void print(const std::string& s = "",
const IndexFormatter& indexFormatter = &(boost::lexical_cast<std::string, Index>) ) const; const IndexFormatter& indexFormatter = DefaultIndexFormatter ) const;
/// @} /// @}
/// @name Standard Interface /// @name Standard Interface
@ -236,7 +236,7 @@ namespace gtsam {
*/ */
/** saves the Tree to a text file in GraphViz format */ /** saves the Tree to a text file in GraphViz format */
void saveGraph(const std::string& s, const IndexFormatter& indexFormatter = &(boost::lexical_cast<std::string, Index>) ) const; void saveGraph(const std::string& s, const IndexFormatter& indexFormatter = DefaultIndexFormatter ) const;
/// @} /// @}
/// @name Advanced Interface /// @name Advanced Interface

View File

@ -93,10 +93,10 @@ namespace gtsam {
} }
/** print this node */ /** print this node */
void print(const std::string& s = "", const IndexFormatter& indexFormatter = &(boost::lexical_cast<std::string, Index>) ) const; void print(const std::string& s = "", const IndexFormatter& indexFormatter = DefaultIndexFormatter ) const;
/** print this node and entire subtree below it */ /** print this node and entire subtree below it */
void printTree(const std::string& indent="", const IndexFormatter& indexFormatter = &(boost::lexical_cast<std::string, Index>) ) const; void printTree(const std::string& indent="", const IndexFormatter& indexFormatter = DefaultIndexFormatter ) const;
/// @} /// @}
/// @name Standard Interface /// @name Standard Interface

View File

@ -72,7 +72,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
template<class FG> template<class FG>
void ClusterTree<FG>::Cluster::print(const std::string& indent, void ClusterTree<FG>::Cluster::print(const std::string& indent,
const boost::function<std::string(KeyType)>& formatter) const { const IndexFormatter& formatter) const {
std::cout << indent; std::cout << indent;
BOOST_FOREACH(const Index key, frontal) BOOST_FOREACH(const Index key, frontal)
std::cout << formatter(key) << " "; std::cout << formatter(key) << " ";
@ -85,7 +85,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
template<class FG> template<class FG>
void ClusterTree<FG>::Cluster::printTree(const std::string& indent, void ClusterTree<FG>::Cluster::printTree(const std::string& indent,
const boost::function<std::string(KeyType)>& formatter) const { const IndexFormatter& formatter) const {
print(indent, formatter); print(indent, formatter);
BOOST_FOREACH(const shared_ptr& child, children_) BOOST_FOREACH(const shared_ptr& child, children_)
child->printTree(indent + " ", formatter); child->printTree(indent + " ", formatter);
@ -96,7 +96,7 @@ namespace gtsam {
* ************************************************************************* */ * ************************************************************************* */
template<class FG> template<class FG>
void ClusterTree<FG>::print(const std::string& str, void ClusterTree<FG>::print(const std::string& str,
const boost::function<std::string(KeyType)>& formatter) const { const IndexFormatter& formatter) const {
std::cout << str << std::endl; std::cout << str << std::endl;
if (root_) root_->printTree("", formatter); if (root_) root_->printTree("", formatter);
} }

View File

@ -78,10 +78,10 @@ namespace gtsam {
Cluster(FRONTALIT firstFrontal, FRONTALIT lastFrontal, SEPARATORIT firstSeparator, SEPARATORIT lastSeparator); Cluster(FRONTALIT firstFrontal, FRONTALIT lastFrontal, SEPARATORIT firstSeparator, SEPARATORIT lastSeparator);
/// print /// print
void print(const std::string& indent, const boost::function<std::string(KeyType)>& formatter = &(boost::lexical_cast<std::string, KeyType>)) const; void print(const std::string& indent, const IndexFormatter& formatter = DefaultIndexFormatter) const;
/// print the enire tree /// print the enire tree
void printTree(const std::string& indent, const boost::function<std::string(KeyType)>& formatter = &(boost::lexical_cast<std::string, KeyType>)) const; void printTree(const std::string& indent, const IndexFormatter& formatter = DefaultIndexFormatter) const;
/// check equality /// check equality
bool equals(const Cluster& other) const; bool equals(const Cluster& other) const;
@ -127,7 +127,7 @@ namespace gtsam {
/// @{ /// @{
/// print the object /// print the object
void print(const std::string& str="", const boost::function<std::string(KeyType)>& formatter = &(boost::lexical_cast<std::string, KeyType>)) const; void print(const std::string& str="", const IndexFormatter& formatter = DefaultIndexFormatter) const;
/** check equality */ /** check equality */
bool equals(const ClusterTree<FG>& other, double tol = 1e-9) const; bool equals(const ClusterTree<FG>& other, double tol = 1e-9) const;

View File

@ -131,8 +131,7 @@ public:
/// @{ /// @{
/** print with optional formatter */ /** print with optional formatter */
void print(const std::string& s = "Conditional", void print(const std::string& s = "Conditional", const IndexFormatter& formatter = DefaultIndexFormatter) const;
const boost::function<std::string(KEY)>& formatter = &(boost::lexical_cast<std::string, KEY>) ) const;
/** check equality */ /** check equality */
template<class DERIVED> template<class DERIVED>
@ -201,7 +200,7 @@ private:
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
void Conditional<KEY>::print(const std::string& s, const boost::function<std::string(KEY)>& formatter) const { void Conditional<KEY>::print(const std::string& s, const IndexFormatter& formatter) const {
std::cout << s << " P("; std::cout << s << " P(";
BOOST_FOREACH(KeyType key, frontals()) std::cout << " " << formatter(key); BOOST_FOREACH(KeyType key, frontals()) std::cout << " " << formatter(key);
if (nrParents()>0) std::cout << " |"; if (nrParents()>0) std::cout << " |";

View File

@ -167,7 +167,7 @@ EliminationTree<FACTOR>::Create(const FactorGraph<DERIVEDFACTOR>& factorGraph) {
/* ************************************************************************* */ /* ************************************************************************* */
template<class FACTORGRAPH> template<class FACTORGRAPH>
void EliminationTree<FACTORGRAPH>::print(const std::string& name, void EliminationTree<FACTORGRAPH>::print(const std::string& name,
const boost::function<std::string(KeyType)>& formatter) const { const IndexFormatter& formatter) const {
std::cout << name << " (" << formatter(key_) << ")" << std::endl; std::cout << name << " (" << formatter(key_) << ")" << std::endl;
BOOST_FOREACH(const sharedFactor& factor, factors_) { BOOST_FOREACH(const sharedFactor& factor, factors_) {
factor->print(name + " ", formatter); } factor->print(name + " ", formatter); }

View File

@ -144,7 +144,7 @@ public:
/** Print the tree to cout */ /** Print the tree to cout */
void print(const std::string& name = "EliminationTree: ", void print(const std::string& name = "EliminationTree: ",
const boost::function<std::string(KeyType)>& formatter = &(boost::lexical_cast<std::string, KeyType>)) const; const IndexFormatter& formatter = DefaultIndexFormatter) const;
/** Test whether the tree is equal to another */ /** Test whether the tree is equal to another */
bool equals(const EliminationTree& other, double tol = 1e-9) const; bool equals(const EliminationTree& other, double tol = 1e-9) const;

View File

@ -57,7 +57,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
template<typename KEY> template<typename KEY>
void Factor<KEY>::print(const std::string& s, void Factor<KEY>::print(const std::string& s,
const boost::function<std::string(KeyType)>& formatter) const { const IndexFormatter& formatter) const {
std::cout << s << " "; std::cout << s << " ";
BOOST_FOREACH(KEY key, keys_) std::cout << " " << formatter(key); BOOST_FOREACH(KEY key, keys_) std::cout << " " << formatter(key);
std::cout << std::endl; std::cout << std::endl;

View File

@ -27,6 +27,7 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/function/function1.hpp> #include <boost/function/function1.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <gtsam/base/types.h>
#include <gtsam/base/FastMap.h> #include <gtsam/base/FastMap.h>
namespace gtsam { namespace gtsam {
@ -193,7 +194,7 @@ public:
/// print /// print
void print(const std::string& s = "Factor", void print(const std::string& s = "Factor",
const boost::function<std::string(KeyType)>& formatter = &(boost::lexical_cast<std::string, KeyType>)) const; const IndexFormatter& formatter = DefaultIndexFormatter) const;
/// check equality /// check equality
bool equals(const This& other, double tol = 1e-9) const; bool equals(const This& other, double tol = 1e-9) const;

View File

@ -49,7 +49,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
template<class FACTOR> template<class FACTOR>
void FactorGraph<FACTOR>::print(const std::string& s, void FactorGraph<FACTOR>::print(const std::string& s,
const boost::function<std::string(KeyType)>& formatter) const { const IndexFormatter& formatter) const {
std::cout << s << std::endl; std::cout << s << std::endl;
std::cout << "size: " << size() << std::endl; std::cout << "size: " << size() << std::endl;
for (size_t i = 0; i < factors_.size(); i++) { for (size_t i = 0; i < factors_.size(); i++) {

View File

@ -139,7 +139,7 @@ template<class CONDITIONAL, class CLIQUE> class BayesTree;
/** print out graph */ /** print out graph */
void print(const std::string& s = "FactorGraph", void print(const std::string& s = "FactorGraph",
const boost::function<std::string(KeyType)>& formatter = &(boost::lexical_cast<std::string, KeyType>)) const; const IndexFormatter& formatter = DefaultIndexFormatter) const;
/** Check equality */ /** Check equality */
bool equals(const This& fg, double tol = 1e-9) const; bool equals(const This& fg, double tol = 1e-9) const;

View File

@ -139,7 +139,7 @@ public:
/** print */ /** print */
void print(const std::string& = "GaussianConditional", void print(const std::string& = "GaussianConditional",
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const; const IndexFormatter& formatter = DefaultIndexFormatter) const;
/** equals function */ /** equals function */
bool equals(const GaussianConditional &cg, double tol = 1e-9) const; bool equals(const GaussianConditional &cg, double tol = 1e-9) const;

View File

@ -55,7 +55,7 @@ namespace gtsam {
/// print /// print
void print(const std::string& = "GaussianDensity", void print(const std::string& = "GaussianDensity",
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const; const IndexFormatter& formatter =DefaultIndexFormatter) const;
/// Mean \f$ \mu = R^{-1} d \f$ /// Mean \f$ \mu = R^{-1} d \f$
Vector mean() const; Vector mean() const;

View File

@ -84,7 +84,7 @@ namespace gtsam {
// Implementing Testable interface // Implementing Testable interface
virtual void print(const std::string& s = "", virtual void print(const std::string& s = "",
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const = 0; const IndexFormatter& formatter = DefaultIndexFormatter) const = 0;
virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const = 0; virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const = 0;

View File

@ -219,7 +219,7 @@ namespace gtsam {
/** Print the factor for debugging and testing (implementing Testable) */ /** Print the factor for debugging and testing (implementing Testable) */
virtual void print(const std::string& s = "", virtual void print(const std::string& s = "",
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const; const IndexFormatter& formatter = DefaultIndexFormatter) const;
/** Compare to another factor for testing (implementing Testable) */ /** Compare to another factor for testing (implementing Testable) */
virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const; virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const;

View File

@ -152,7 +152,7 @@ namespace gtsam {
// Implementing Testable interface // Implementing Testable interface
virtual void print(const std::string& s = "", virtual void print(const std::string& s = "",
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const; const IndexFormatter& formatter = DefaultIndexFormatter) const;
virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const; virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const;
Vector unweighted_error(const VectorValues& c) const; /** (A*x-b) */ Vector unweighted_error(const VectorValues& c) const; /** (A*x-b) */

View File

@ -169,7 +169,7 @@ namespace gtsam {
/** print required by Testable for unit testing */ /** print required by Testable for unit testing */
void print(const std::string& str = "VectorValues: ", void print(const std::string& str = "VectorValues: ",
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const; const IndexFormatter& formatter =DefaultIndexFormatter) const;
/** equals required by Testable for unit testing */ /** equals required by Testable for unit testing */
bool equals(const VectorValues& x, double tol = 1e-9) const; bool equals(const VectorValues& x, double tol = 1e-9) const;

View File

@ -287,7 +287,7 @@ public:
/** print this node */ /** print this node */
void print(const std::string& s = "", void print(const std::string& s = "",
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const { const IndexFormatter& formatter = DefaultIndexFormatter) const {
Base::print(s,formatter); Base::print(s,formatter);
if(cachedFactor_) if(cachedFactor_)
cachedFactor_->print(s + "Cached: ", formatter); cachedFactor_->print(s + "Cached: ", formatter);