Merge branch 'master' into new_wrap_local
parent
fb00f4b834
commit
4abefa3cbe
|
@ -50,6 +50,7 @@ else()
|
|||
option(GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" ON)
|
||||
endif()
|
||||
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)
|
||||
if(MSVC)
|
||||
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_SHARED_LIBRARY} "Build shared 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 ")
|
||||
if(GTSAM_UNSTABLE_AVAILABLE)
|
||||
print_config_flag(${GTSAM_BUILD_UNSTABLE} "Build libgtsam_unstable ")
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
|
||||
#include <string>
|
||||
#include <boost/function/function1.hpp>
|
||||
|
||||
namespace gtsam {
|
||||
|
@ -32,6 +33,11 @@ namespace gtsam {
|
|||
* to a nonlinear key and then to a Symbol. */
|
||||
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
|
||||
* whether TEST_TYPE is const or not.
|
||||
|
|
|
@ -64,8 +64,8 @@ namespace gtsam {
|
|||
|
||||
/** GTSAM-style print */
|
||||
void print(const std::string& s = "Discrete Conditional: ",
|
||||
const boost::function<std::string(Index)>& formatter
|
||||
= &(boost::lexical_cast<std::string, Index>)) const {
|
||||
const IndexFormatter& formatter
|
||||
=DefaultIndexFormatter) const {
|
||||
std::cout << s << std::endl;
|
||||
IndexConditional::print(s, formatter);
|
||||
Potentials::print(s);
|
||||
|
|
|
@ -83,8 +83,8 @@ namespace gtsam {
|
|||
|
||||
// print
|
||||
virtual void print(const std::string& s = "DiscreteFactor\n",
|
||||
const boost::function<std::string(Index)>& formatter
|
||||
= &(boost::lexical_cast<std::string, Index>)) const {
|
||||
const IndexFormatter& formatter
|
||||
=DefaultIndexFormatter) const {
|
||||
IndexFactor::print(s,formatter);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
/// print
|
||||
void print(const std::string& s = "DiscreteFactorGraph",
|
||||
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const;
|
||||
const IndexFormatter& formatter =DefaultIndexFormatter) const;
|
||||
};
|
||||
// DiscreteFactorGraph
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace gtsam {
|
|||
/* ************************************************************************* */
|
||||
template<class CONDITIONAL>
|
||||
void BayesNet<CONDITIONAL>::print(const std::string& s,
|
||||
const boost::function<std::string(KeyType)>& formatter) const {
|
||||
const IndexFormatter& formatter) const {
|
||||
std::cout << s;
|
||||
BOOST_REVERSE_FOREACH(sharedConditional conditional, conditionals_)
|
||||
conditional->print("Conditional", formatter);
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
/** print */
|
||||
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 */
|
||||
void printStats(const std::string& s = "") const;
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace gtsam {
|
|||
// A convenience class for a list of shared cliques
|
||||
struct Cliques : public std::list<sharedClique> {
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -178,7 +178,7 @@ namespace gtsam {
|
|||
|
||||
/** print */
|
||||
void print(const std::string& s = "",
|
||||
const IndexFormatter& indexFormatter = &(boost::lexical_cast<std::string, Index>) ) const;
|
||||
const IndexFormatter& indexFormatter = DefaultIndexFormatter ) const;
|
||||
|
||||
/// @}
|
||||
/// @name Standard Interface
|
||||
|
@ -236,7 +236,7 @@ namespace gtsam {
|
|||
*/
|
||||
|
||||
/** 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
|
||||
|
|
|
@ -93,10 +93,10 @@ namespace gtsam {
|
|||
}
|
||||
|
||||
/** 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 */
|
||||
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
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace gtsam {
|
|||
/* ************************************************************************* */
|
||||
template<class FG>
|
||||
void ClusterTree<FG>::Cluster::print(const std::string& indent,
|
||||
const boost::function<std::string(KeyType)>& formatter) const {
|
||||
const IndexFormatter& formatter) const {
|
||||
std::cout << indent;
|
||||
BOOST_FOREACH(const Index key, frontal)
|
||||
std::cout << formatter(key) << " ";
|
||||
|
@ -85,7 +85,7 @@ namespace gtsam {
|
|||
/* ************************************************************************* */
|
||||
template<class FG>
|
||||
void ClusterTree<FG>::Cluster::printTree(const std::string& indent,
|
||||
const boost::function<std::string(KeyType)>& formatter) const {
|
||||
const IndexFormatter& formatter) const {
|
||||
print(indent, formatter);
|
||||
BOOST_FOREACH(const shared_ptr& child, children_)
|
||||
child->printTree(indent + " ", formatter);
|
||||
|
@ -96,7 +96,7 @@ namespace gtsam {
|
|||
* ************************************************************************* */
|
||||
template<class FG>
|
||||
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;
|
||||
if (root_) root_->printTree("", formatter);
|
||||
}
|
||||
|
|
|
@ -78,10 +78,10 @@ namespace gtsam {
|
|||
Cluster(FRONTALIT firstFrontal, FRONTALIT lastFrontal, SEPARATORIT firstSeparator, SEPARATORIT lastSeparator);
|
||||
|
||||
/// 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
|
||||
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
|
||||
bool equals(const Cluster& other) const;
|
||||
|
@ -127,7 +127,7 @@ namespace gtsam {
|
|||
/// @{
|
||||
|
||||
/// 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 */
|
||||
bool equals(const ClusterTree<FG>& other, double tol = 1e-9) const;
|
||||
|
|
|
@ -131,8 +131,7 @@ public:
|
|||
/// @{
|
||||
|
||||
/** print with optional formatter */
|
||||
void print(const std::string& s = "Conditional",
|
||||
const boost::function<std::string(KEY)>& formatter = &(boost::lexical_cast<std::string, KEY>) ) const;
|
||||
void print(const std::string& s = "Conditional", const IndexFormatter& formatter = DefaultIndexFormatter) const;
|
||||
|
||||
/** check equality */
|
||||
template<class DERIVED>
|
||||
|
@ -201,7 +200,7 @@ private:
|
|||
|
||||
/* ************************************************************************* */
|
||||
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(";
|
||||
BOOST_FOREACH(KeyType key, frontals()) std::cout << " " << formatter(key);
|
||||
if (nrParents()>0) std::cout << " |";
|
||||
|
|
|
@ -167,7 +167,7 @@ EliminationTree<FACTOR>::Create(const FactorGraph<DERIVEDFACTOR>& factorGraph) {
|
|||
/* ************************************************************************* */
|
||||
template<class FACTORGRAPH>
|
||||
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;
|
||||
BOOST_FOREACH(const sharedFactor& factor, factors_) {
|
||||
factor->print(name + " ", formatter); }
|
||||
|
|
|
@ -144,7 +144,7 @@ public:
|
|||
|
||||
/** Print the tree to cout */
|
||||
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 */
|
||||
bool equals(const EliminationTree& other, double tol = 1e-9) const;
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace gtsam {
|
|||
/* ************************************************************************* */
|
||||
template<typename KEY>
|
||||
void Factor<KEY>::print(const std::string& s,
|
||||
const boost::function<std::string(KeyType)>& formatter) const {
|
||||
const IndexFormatter& formatter) const {
|
||||
std::cout << s << " ";
|
||||
BOOST_FOREACH(KEY key, keys_) std::cout << " " << formatter(key);
|
||||
std::cout << std::endl;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <boost/foreach.hpp>
|
||||
#include <boost/function/function1.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <gtsam/base/types.h>
|
||||
#include <gtsam/base/FastMap.h>
|
||||
|
||||
namespace gtsam {
|
||||
|
@ -193,7 +194,7 @@ public:
|
|||
|
||||
/// print
|
||||
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
|
||||
bool equals(const This& other, double tol = 1e-9) const;
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace gtsam {
|
|||
/* ************************************************************************* */
|
||||
template<class FACTOR>
|
||||
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 << "size: " << size() << std::endl;
|
||||
for (size_t i = 0; i < factors_.size(); i++) {
|
||||
|
|
|
@ -139,7 +139,7 @@ template<class CONDITIONAL, class CLIQUE> class BayesTree;
|
|||
|
||||
/** print out graph */
|
||||
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 */
|
||||
bool equals(const This& fg, double tol = 1e-9) const;
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
|
||||
/** print */
|
||||
void print(const std::string& = "GaussianConditional",
|
||||
const IndexFormatter& formatter = &(boost::lexical_cast<std::string, Index>)) const;
|
||||
const IndexFormatter& formatter = DefaultIndexFormatter) const;
|
||||
|
||||
/** equals function */
|
||||
bool equals(const GaussianConditional &cg, double tol = 1e-9) const;
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace gtsam {
|
|||
|
||||
/// print
|
||||
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$
|
||||
Vector mean() const;
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace gtsam {
|
|||
|
||||
// Implementing Testable interface
|
||||
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;
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace gtsam {
|
|||
|
||||
/** Print the factor for debugging and testing (implementing Testable) */
|
||||
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) */
|
||||
virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const;
|
||||
|
|
|
@ -152,7 +152,7 @@ namespace gtsam {
|
|||
|
||||
// Implementing Testable interface
|
||||
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;
|
||||
|
||||
Vector unweighted_error(const VectorValues& c) const; /** (A*x-b) */
|
||||
|
|
|
@ -169,7 +169,7 @@ namespace gtsam {
|
|||
|
||||
/** print required by Testable for unit testing */
|
||||
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 */
|
||||
bool equals(const VectorValues& x, double tol = 1e-9) const;
|
||||
|
|
|
@ -287,7 +287,7 @@ public:
|
|||
|
||||
/** print this node */
|
||||
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);
|
||||
if(cachedFactor_)
|
||||
cachedFactor_->print(s + "Cached: ", formatter);
|
||||
|
|
Loading…
Reference in New Issue