Merge branch 'develop' into feature/remove_boost_in_Values

release/4.3a0
Frank Dellaert 2023-01-22 21:32:27 -08:00
commit 3b94469ce2
414 changed files with 1704 additions and 1771 deletions

View File

@ -271,7 +271,7 @@ color{red}{// Make 'private' any typedefs that must be redefined in derived
\begin_layout Plain Layout \begin_layout Plain Layout
typedef boost::shared_ptr<This> shared_ptr; ///< Shared pointer to typedef std::shared_ptr<This> shared_ptr; ///< Shared pointer to
this this
\end_layout \end_layout
@ -304,7 +304,7 @@ color{red}{// Make 'public' the typedefs that will be valid in the derived
\begin_layout Plain Layout \begin_layout Plain Layout
typedef boost::shared_ptr<FACTOR> sharedFactor; ///< Shared pointer typedef std::shared_ptr<FACTOR> sharedFactor; ///< Shared pointer
to a factor to a factor
\end_layout \end_layout

View File

@ -20,7 +20,6 @@
#include <gtsam/nonlinear/LevenbergMarquardtOptimizer.h> #include <gtsam/nonlinear/LevenbergMarquardtOptimizer.h>
#include <gtsam/geometry/PinholeCamera.h> #include <gtsam/geometry/PinholeCamera.h>
#include <gtsam/geometry/Cal3_S2.h> #include <gtsam/geometry/Cal3_S2.h>
#include <boost/make_shared.hpp>
using namespace gtsam; using namespace gtsam;
using namespace gtsam::noiseModel; using namespace gtsam::noiseModel;
@ -70,7 +69,7 @@ int main(int argc, char* argv[]) {
/* 2. add factors to the graph */ /* 2. add factors to the graph */
// add measurement factors // add measurement factors
SharedDiagonal measurementNoise = Diagonal::Sigmas(Vector2(0.5, 0.5)); SharedDiagonal measurementNoise = Diagonal::Sigmas(Vector2(0.5, 0.5));
boost::shared_ptr<ResectioningFactor> factor; std::shared_ptr<ResectioningFactor> factor;
graph.emplace_shared<ResectioningFactor>(measurementNoise, X(1), calib, graph.emplace_shared<ResectioningFactor>(measurementNoise, X(1), calib,
Point2(55, 45), Point3(10, 10, 0)); Point2(55, 45), Point3(10, 10, 0));
graph.emplace_shared<ResectioningFactor>(measurementNoise, X(1), calib, graph.emplace_shared<ResectioningFactor>(measurementNoise, X(1), calib,

View File

@ -95,7 +95,7 @@ Vector10 readInitialState(ifstream& file) {
return initial_state; return initial_state;
} }
boost::shared_ptr<PreintegratedCombinedMeasurements::Params> imuParams() { std::shared_ptr<PreintegratedCombinedMeasurements::Params> imuParams() {
// We use the sensor specs to build the noise model for the IMU factor. // We use the sensor specs to build the noise model for the IMU factor.
double accel_noise_sigma = 0.0003924; double accel_noise_sigma = 0.0003924;
double gyro_noise_sigma = 0.000205689024915; double gyro_noise_sigma = 0.000205689024915;

View File

@ -61,7 +61,7 @@ using symbol_shorthand::X; // for poses
/* ************************************************************************* */ /* ************************************************************************* */
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
// Define the camera calibration parameters // Define the camera calibration parameters
auto K = boost::make_shared<Cal3Fisheye>( auto K = std::make_shared<Cal3Fisheye>(
278.66, 278.48, 0.0, 319.75, 241.96, -0.013721808247486035, 278.66, 278.48, 0.0, 319.75, 241.96, -0.013721808247486035,
0.020727425669427896, -0.012786476702685545, 0.0025242267320687625); 0.020727425669427896, -0.012786476702685545, 0.0025242267320687625);

View File

@ -82,7 +82,7 @@ po::variables_map parseOptions(int argc, char* argv[]) {
return vm; return vm;
} }
boost::shared_ptr<PreintegratedCombinedMeasurements::Params> imuParams() { std::shared_ptr<PreintegratedCombinedMeasurements::Params> imuParams() {
// We use the sensor specs to build the noise model for the IMU factor. // We use the sensor specs to build the noise model for the IMU factor.
double accel_noise_sigma = 0.0003924; double accel_noise_sigma = 0.0003924;
double gyro_noise_sigma = 0.000205689024915; double gyro_noise_sigma = 0.000205689024915;

View File

@ -115,7 +115,7 @@ int main(int argc, char* argv[]) {
Vector6 covvec; Vector6 covvec;
covvec << 0.1, 0.1, 0.1, 0.1, 0.1, 0.1; covvec << 0.1, 0.1, 0.1, 0.1, 0.1, 0.1;
auto cov = noiseModel::Diagonal::Variances(covvec); auto cov = noiseModel::Diagonal::Variances(covvec);
auto f = boost::make_shared<BetweenFactor<imuBias::ConstantBias> >( auto f = std::make_shared<BetweenFactor<imuBias::ConstantBias> >(
b1, b2, imuBias::ConstantBias(), cov); b1, b2, imuBias::ConstantBias(), cov);
newgraph.add(f); newgraph.add(f);
initialEstimate.insert(biasKey, imuBias::ConstantBias()); initialEstimate.insert(biasKey, imuBias::ConstantBias());

View File

@ -76,7 +76,7 @@ class UnaryFactor: public NoiseModelFactorN<Pose2> {
using NoiseModelFactor1<Pose2>::evaluateError; using NoiseModelFactor1<Pose2>::evaluateError;
/// shorthand for a smart pointer to a factor /// shorthand for a smart pointer to a factor
typedef boost::shared_ptr<UnaryFactor> shared_ptr; typedef std::shared_ptr<UnaryFactor> shared_ptr;
// The constructor requires the variable key, the (X, Y) measurement value, and the noise model // The constructor requires the variable key, the (X, Y) measurement value, and the noise model
UnaryFactor(Key j, double x, double y, const SharedNoiseModel& model): UnaryFactor(Key j, double x, double y, const SharedNoiseModel& model):
@ -105,7 +105,7 @@ class UnaryFactor: public NoiseModelFactorN<Pose2> {
// circumstances, the following code that employs the default copy constructor should // circumstances, the following code that employs the default copy constructor should
// work fine. // work fine.
gtsam::NonlinearFactor::shared_ptr clone() const override { gtsam::NonlinearFactor::shared_ptr clone() const override {
return boost::static_pointer_cast<gtsam::NonlinearFactor>( return std::static_pointer_cast<gtsam::NonlinearFactor>(
gtsam::NonlinearFactor::shared_ptr(new UnaryFactor(*this))); } gtsam::NonlinearFactor::shared_ptr(new UnaryFactor(*this))); }
// Additionally, we encourage you the use of unit testing your custom factors, // Additionally, we encourage you the use of unit testing your custom factors,

View File

@ -69,7 +69,7 @@ int main(int argc, char** argv) {
// addition, the *type* of the iterativeParams decides on the type of // addition, the *type* of the iterativeParams decides on the type of
// iterative solver, in this case the SPCG (subgraph PCG) // iterative solver, in this case the SPCG (subgraph PCG)
parameters.linearSolverType = NonlinearOptimizerParams::Iterative; parameters.linearSolverType = NonlinearOptimizerParams::Iterative;
parameters.iterativeParams = boost::make_shared<SubgraphSolverParameters>(); parameters.iterativeParams = std::make_shared<SubgraphSolverParameters>();
LevenbergMarquardtOptimizer optimizer(graph, initialEstimate, parameters); LevenbergMarquardtOptimizer optimizer(graph, initialEstimate, parameters);
Values result = optimizer.optimize(); Values result = optimizer.optimize();

View File

@ -65,9 +65,9 @@ int main(const int argc, const char *argv[]) {
simpleInitial.insert(key, initial->at(k)); simpleInitial.insert(key, initial->at(k));
} }
NonlinearFactorGraph simpleGraph; NonlinearFactorGraph simpleGraph;
for(const boost::shared_ptr<NonlinearFactor>& factor: *graph) { for(const std::shared_ptr<NonlinearFactor>& factor: *graph) {
boost::shared_ptr<BetweenFactor<Pose3> > pose3Between = std::shared_ptr<BetweenFactor<Pose3> > pose3Between =
boost::dynamic_pointer_cast<BetweenFactor<Pose3> >(factor); std::dynamic_pointer_cast<BetweenFactor<Pose3> >(factor);
if (pose3Between){ if (pose3Between){
Key key1, key2; Key key1, key2;
if(add){ if(add){

View File

@ -112,7 +112,7 @@ int main(int argc, char* argv[]) {
for (size_t j = 0; j < points.size(); ++j) { for (size_t j = 0; j < points.size(); ++j) {
// The graph stores Factor shared_ptrs, so we cast back to a SmartFactor first // The graph stores Factor shared_ptrs, so we cast back to a SmartFactor first
SmartFactor::shared_ptr smart = boost::dynamic_pointer_cast<SmartFactor>(graph[j]); SmartFactor::shared_ptr smart = std::dynamic_pointer_cast<SmartFactor>(graph[j]);
if (smart) { if (smart) {
// The output of point() is in std::optional<Point3>, as sometimes // The output of point() is in std::optional<Point3>, as sometimes
// the triangulation operation inside smart factor will encounter degeneracy. // the triangulation operation inside smart factor will encounter degeneracy.

View File

@ -93,9 +93,9 @@ int main(int argc, char* argv[]) {
parameters.relativeErrorTol = 1e-10; parameters.relativeErrorTol = 1e-10;
parameters.maxIterations = 500; parameters.maxIterations = 500;
PCGSolverParameters::shared_ptr pcg = PCGSolverParameters::shared_ptr pcg =
boost::make_shared<PCGSolverParameters>(); std::make_shared<PCGSolverParameters>();
pcg->preconditioner_ = pcg->preconditioner_ =
boost::make_shared<BlockJacobiPreconditionerParameters>(); std::make_shared<BlockJacobiPreconditionerParameters>();
// Following is crucial: // Following is crucial:
pcg->setEpsilon_abs(1e-10); pcg->setEpsilon_abs(1e-10);
pcg->setEpsilon_rel(1e-10); pcg->setEpsilon_rel(1e-10);
@ -108,7 +108,7 @@ int main(int argc, char* argv[]) {
result.print("Final results:\n"); result.print("Final results:\n");
Values landmark_result; Values landmark_result;
for (size_t j = 0; j < points.size(); ++j) { for (size_t j = 0; j < points.size(); ++j) {
auto smart = boost::dynamic_pointer_cast<SmartFactor>(graph[j]); auto smart = std::dynamic_pointer_cast<SmartFactor>(graph[j]);
if (smart) { if (smart) {
std::optional<Point3> point = smart->point(result); std::optional<Point3> point = smart->point(result);
if (point) // ignore if std::optional return nullptr if (point) // ignore if std::optional return nullptr

View File

@ -79,7 +79,7 @@ double chi2_red(const gtsam::NonlinearFactorGraph& graph, const gtsam::Values& c
// the factor graph already includes a factor for the prior/equality constraint. // the factor graph already includes a factor for the prior/equality constraint.
// double dof = graph.size() - config.size(); // double dof = graph.size() - config.size();
int graph_dim = 0; int graph_dim = 0;
for(const boost::shared_ptr<gtsam::NonlinearFactor>& nlf: graph) { for(const std::shared_ptr<gtsam::NonlinearFactor>& nlf: graph) {
graph_dim += (int)nlf->dim(); graph_dim += (int)nlf->dim();
} }
double dof = double(graph_dim) - double(config.dim()); // kaess: changed to dim double dof = double(graph_dim) - double(config.dim()); // kaess: changed to dim
@ -259,7 +259,7 @@ void runIncremental()
while(nextMeasurement < datasetMeasurements.size()) while(nextMeasurement < datasetMeasurements.size())
{ {
if(BetweenFactor<Pose>::shared_ptr factor = if(BetweenFactor<Pose>::shared_ptr factor =
boost::dynamic_pointer_cast<BetweenFactor<Pose> >(datasetMeasurements[nextMeasurement])) std::dynamic_pointer_cast<BetweenFactor<Pose> >(datasetMeasurements[nextMeasurement]))
{ {
Key key1 = factor->key<1>(), key2 = factor->key<2>(); Key key1 = factor->key<1>(), key2 = factor->key<2>();
if(((int)key1 >= firstStep && key1 < key2) || ((int)key2 >= firstStep && key2 < key1)) { if(((int)key1 >= firstStep && key1 < key2) || ((int)key2 >= firstStep && key2 < key1)) {
@ -310,7 +310,7 @@ void runIncremental()
NonlinearFactor::shared_ptr measurementf = datasetMeasurements[nextMeasurement]; NonlinearFactor::shared_ptr measurementf = datasetMeasurements[nextMeasurement];
if(BetweenFactor<Pose>::shared_ptr factor = if(BetweenFactor<Pose>::shared_ptr factor =
boost::dynamic_pointer_cast<BetweenFactor<Pose> >(measurementf)) std::dynamic_pointer_cast<BetweenFactor<Pose> >(measurementf))
{ {
// Stop collecting measurements that are for future steps // Stop collecting measurements that are for future steps
if(factor->key<1>() > step || factor->key<2>() > step) if(factor->key<1>() > step || factor->key<2>() > step)
@ -346,7 +346,7 @@ void runIncremental()
} }
} }
else if(BearingRangeFactor<Pose, Point2>::shared_ptr factor = else if(BearingRangeFactor<Pose, Point2>::shared_ptr factor =
boost::dynamic_pointer_cast<BearingRangeFactor<Pose, Point2> >(measurementf)) std::dynamic_pointer_cast<BearingRangeFactor<Pose, Point2> >(measurementf))
{ {
Key poseKey = factor->keys()[0], lmKey = factor->keys()[1]; Key poseKey = factor->keys()[0], lmKey = factor->keys()[1];

View File

@ -122,7 +122,7 @@ int main(int argc, char* argv[]) {
Matrix errorsDLTOpt = Matrix::Zero(nrTrials, 3); Matrix errorsDLTOpt = Matrix::Zero(nrTrials, 3);
double rank_tol = 1e-9; double rank_tol = 1e-9;
boost::shared_ptr<Cal3_S2> calib = boost::make_shared<Cal3_S2>(); std::shared_ptr<Cal3_S2> calib = std::make_shared<Cal3_S2>();
std::chrono::nanoseconds durationDLT; std::chrono::nanoseconds durationDLT;
std::chrono::nanoseconds durationDLTOpt; std::chrono::nanoseconds durationDLTOpt;
std::chrono::nanoseconds durationLOST; std::chrono::nanoseconds durationLOST;

View File

@ -17,8 +17,8 @@
*/ */
#include <gtsam/base/DSFVector.h> #include <gtsam/base/DSFVector.h>
#include <boost/make_shared.hpp>
#include <algorithm> #include <algorithm>
#include <cassert>
using namespace std; using namespace std;
@ -26,14 +26,14 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
DSFBase::DSFBase(const size_t numNodes) { DSFBase::DSFBase(const size_t numNodes) {
v_ = boost::make_shared < V > (numNodes); v_ = std::make_shared < V > (numNodes);
int index = 0; int index = 0;
for (V::iterator it = v_->begin(); it != v_->end(); it++, index++) for (V::iterator it = v_->begin(); it != v_->end(); it++, index++)
*it = index; *it = index;
} }
/* ************************************************************************* */ /* ************************************************************************* */
DSFBase::DSFBase(const boost::shared_ptr<V>& v_in) { DSFBase::DSFBase(const std::shared_ptr<V>& v_in) {
v_ = v_in; v_ = v_in;
int index = 0; int index = 0;
for (V::iterator it = v_->begin(); it != v_->end(); it++, index++) for (V::iterator it = v_->begin(); it != v_->end(); it++, index++)
@ -69,7 +69,7 @@ DSFVector::DSFVector(const std::vector<size_t>& keys) :
} }
/* ************************************************************************* */ /* ************************************************************************* */
DSFVector::DSFVector(const boost::shared_ptr<V>& v_in, DSFVector::DSFVector(const std::shared_ptr<V>& v_in,
const std::vector<size_t>& keys) : const std::vector<size_t>& keys) :
DSFBase(v_in), keys_(keys) { DSFBase(v_in), keys_(keys) {
assert(*(std::max_element(keys.begin(), keys.end()))<v_in->size()); assert(*(std::max_element(keys.begin(), keys.end()))<v_in->size());

View File

@ -21,7 +21,7 @@
#include <gtsam/dllexport.h> #include <gtsam/dllexport.h>
#include <gtsam/global_includes.h> #include <gtsam/global_includes.h>
#include <boost/shared_ptr.hpp> #include <memory>
#include <vector> #include <vector>
#include <set> #include <set>
@ -41,14 +41,14 @@ public:
typedef std::vector<size_t> V; ///< Vector of ints typedef std::vector<size_t> V; ///< Vector of ints
private: private:
boost::shared_ptr<V> v_;///< Stores parent pointers, representative iff v[i]==i std::shared_ptr<V> v_;///< Stores parent pointers, representative iff v[i]==i
public: public:
/// Constructor that allocates new memory, allows for keys 0...numNodes-1. /// Constructor that allocates new memory, allows for keys 0...numNodes-1.
DSFBase(const size_t numNodes); DSFBase(const size_t numNodes);
/// Constructor that uses an existing, pre-allocated vector. /// Constructor that uses an existing, pre-allocated vector.
DSFBase(const boost::shared_ptr<V>& v_in); DSFBase(const std::shared_ptr<V>& v_in);
/// Find the label of the set in which {key} lives. /// Find the label of the set in which {key} lives.
size_t find(size_t key) const; size_t find(size_t key) const;
@ -74,7 +74,7 @@ public:
DSFVector(const std::vector<size_t>& keys); DSFVector(const std::vector<size_t>& keys);
/// Constructor that uses existing vectors. /// Constructor that uses existing vectors.
DSFVector(const boost::shared_ptr<V>& v_in, const std::vector<size_t>& keys); DSFVector(const std::shared_ptr<V>& v_in, const std::vector<size_t>& keys);
// All operations below loop over all keys and hence are *at least* O(n) // All operations below loop over all keys and hence are *at least* O(n)

View File

@ -23,7 +23,6 @@
#include <gtsam/base/types.h> #include <gtsam/base/types.h>
#include <gtsam/base/Value.h> #include <gtsam/base/Value.h>
#include <boost/make_shared.hpp>
#include <boost/pool/pool_alloc.hpp> #include <boost/pool/pool_alloc.hpp>
#include <cmath> #include <cmath>
@ -114,8 +113,8 @@ public:
/** /**
* Clone this value (normal clone on the heap, delete with 'delete' operator) * Clone this value (normal clone on the heap, delete with 'delete' operator)
*/ */
boost::shared_ptr<Value> clone() const override { std::shared_ptr<Value> clone() const override {
return boost::allocate_shared<GenericValue>(Eigen::aligned_allocator<GenericValue>(), *this); return std::allocate_shared<GenericValue>(Eigen::aligned_allocator<GenericValue>(), *this);
} }
/// Generic Value interface version of retract /// Generic Value interface version of retract

View File

@ -21,7 +21,6 @@
#include <gtsam/config.h> // Configuration from CMake #include <gtsam/config.h> // Configuration from CMake
#include <gtsam/base/Vector.h> #include <gtsam/base/Vector.h>
#include <boost/make_shared.hpp>
#include <boost/serialization/nvp.hpp> #include <boost/serialization/nvp.hpp>
#include <boost/serialization/assume_abstract.hpp> #include <boost/serialization/assume_abstract.hpp>
#include <memory> #include <memory>
@ -45,7 +44,7 @@ namespace gtsam {
virtual void deallocate_() const = 0; virtual void deallocate_() const = 0;
/** Clone this value (normal clone on the heap, delete with 'delete' operator) */ /** Clone this value (normal clone on the heap, delete with 'delete' operator) */
virtual boost::shared_ptr<Value> clone() const = 0; virtual std::shared_ptr<Value> clone() const = 0;
/** Compare this Value with another for equality. */ /** Compare this Value with another for equality. */
virtual bool equals_(const Value& other, double tol = 1e-9) const = 0; virtual bool equals_(const Value& other, double tol = 1e-9) const = 0;

View File

@ -21,7 +21,6 @@
#include <Eigen/Core> #include <Eigen/Core>
#include <boost/make_shared.hpp>
#include <type_traits> #include <type_traits>
@ -34,7 +33,7 @@ namespace gtsam {
namespace gtsam { namespace gtsam {
/** /**
* Add our own `make_shared` as a layer of wrapping on `boost::make_shared` * Add our own `make_shared` as a layer of wrapping on `std::make_shared`
* This solves the problem with the stock `make_shared` that custom alignment is not respected, causing SEGFAULTs * This solves the problem with the stock `make_shared` that custom alignment is not respected, causing SEGFAULTs
* at runtime, which is notoriously hard to debug. * at runtime, which is notoriously hard to debug.
* *
@ -46,22 +45,22 @@ namespace gtsam {
* *
* This function declaration will only be taken when the above condition is true, so if some object does not need to * This function declaration will only be taken when the above condition is true, so if some object does not need to
* be aligned, `gtsam::make_shared` will fall back to the next definition, which is a simple wrapper for * be aligned, `gtsam::make_shared` will fall back to the next definition, which is a simple wrapper for
* `boost::make_shared`. * `std::make_shared`.
* *
* @tparam T The type of object being constructed * @tparam T The type of object being constructed
* @tparam Args Type of the arguments of the constructor * @tparam Args Type of the arguments of the constructor
* @param args Arguments of the constructor * @param args Arguments of the constructor
* @return The object created as a boost::shared_ptr<T> * @return The object created as a std::shared_ptr<T>
*/ */
template<typename T, typename ... Args> template<typename T, typename ... Args>
gtsam::enable_if_t<needs_eigen_aligned_allocator<T>::value, boost::shared_ptr<T>> make_shared(Args &&... args) { gtsam::enable_if_t<needs_eigen_aligned_allocator<T>::value, std::shared_ptr<T>> make_shared(Args &&... args) {
return boost::allocate_shared<T>(Eigen::aligned_allocator<T>(), std::forward<Args>(args)...); return std::allocate_shared<T>(Eigen::aligned_allocator<T>(), std::forward<Args>(args)...);
} }
/// Fall back to the boost version if no need for alignment /// Fall back to the boost version if no need for alignment
template<typename T, typename ... Args> template<typename T, typename ... Args>
gtsam::enable_if_t<!needs_eigen_aligned_allocator<T>::value, boost::shared_ptr<T>> make_shared(Args &&... args) { gtsam::enable_if_t<!needs_eigen_aligned_allocator<T>::value, std::shared_ptr<T>> make_shared(Args &&... args) {
return boost::make_shared<T>(std::forward<Args>(args)...); return std::make_shared<T>(std::forward<Args>(args)...);
} }
} }

View File

@ -1,6 +1,13 @@
// Functionality to serialize std::optional<T> to boost::archive /* ----------------------------------------------------------------------------
// Following this: * Use, modification and distribution is subject to the Boost Software
// PR: https://github.com/boostorg/serialization/pull/148/files# * License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
* See http://www.boost.org for updates, documentation, and revision history.
* Functionality to serialize std::optional<T> to boost::archive
* Inspired from this PR: https://github.com/boostorg/serialization/pull/163
* ---------------------------------------------------------------------------- */
#pragma once #pragma once
#include <optional> #include <optional>
@ -88,8 +95,6 @@ void serialize(Archive& ar, std::optional<T>& t, const unsigned int version) {
boost::serialization::split_free(ar, t, version); boost::serialization::split_free(ar, t, version);
} }
// derive boost::xml_archive_impl for archiving std::optional<T> with xml
} // namespace serialization } // namespace serialization
} // namespace boost } // namespace boost

View File

@ -20,7 +20,6 @@
#include <CppUnitLite/TestHarness.h> #include <CppUnitLite/TestHarness.h>
#include <boost/make_shared.hpp>
#include <iostream> #include <iostream>
#include <set> #include <set>
@ -85,7 +84,7 @@ TEST(DSFBase, mergePairwiseMatches) {
/* ************************************************************************* */ /* ************************************************************************* */
TEST(DSFVector, merge2) { TEST(DSFVector, merge2) {
boost::shared_ptr<DSFBase::V> v = boost::make_shared<DSFBase::V>(5); std::shared_ptr<DSFBase::V> v = std::make_shared<DSFBase::V>(5);
const std::vector<size_t> keys {1, 3}; const std::vector<size_t> keys {1, 3};
DSFVector dsf(v, keys); DSFVector dsf(v, keys);
dsf.merge(1,3); dsf.merge(1,3);

View File

@ -21,13 +21,12 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include <boost/shared_ptr.hpp> #include <memory>
#include <boost/make_shared.hpp>
using namespace gtsam; using namespace gtsam;
struct TestNode { struct TestNode {
typedef boost::shared_ptr<TestNode> shared_ptr; typedef std::shared_ptr<TestNode> shared_ptr;
int data; int data;
std::vector<shared_ptr> children; std::vector<shared_ptr> children;
TestNode() : data(-1) {} TestNode() : data(-1) {}
@ -48,11 +47,11 @@ TestForest makeTestForest() {
// | // |
// 4 // 4
TestForest forest; TestForest forest;
forest.roots_.push_back(boost::make_shared<TestNode>(0)); forest.roots_.push_back(std::make_shared<TestNode>(0));
forest.roots_.push_back(boost::make_shared<TestNode>(1)); forest.roots_.push_back(std::make_shared<TestNode>(1));
forest.roots_[0]->children.push_back(boost::make_shared<TestNode>(2)); forest.roots_[0]->children.push_back(std::make_shared<TestNode>(2));
forest.roots_[0]->children.push_back(boost::make_shared<TestNode>(3)); forest.roots_[0]->children.push_back(std::make_shared<TestNode>(3));
forest.roots_[0]->children[1]->children.push_back(boost::make_shared<TestNode>(4)); forest.roots_[0]->children[1]->children.push_back(std::make_shared<TestNode>(4));
return forest; return forest;
} }

View File

@ -34,9 +34,9 @@
namespace gtsam { namespace gtsam {
namespace internal { namespace internal {
GTSAM_EXPORT boost::shared_ptr<TimingOutline> gTimingRoot( GTSAM_EXPORT std::shared_ptr<TimingOutline> gTimingRoot(
new TimingOutline("Total", getTicTocID("Total"))); new TimingOutline("Total", getTicTocID("Total")));
GTSAM_EXPORT boost::weak_ptr<TimingOutline> gCurrentTimer(gTimingRoot); GTSAM_EXPORT std::weak_ptr<TimingOutline> gCurrentTimer(gTimingRoot);
/* ************************************************************************* */ /* ************************************************************************* */
// Implementation of TimingOutline // Implementation of TimingOutline
@ -83,7 +83,7 @@ void TimingOutline::print(const std::string& outline) const {
<< n_ << " times, " << wall() << " wall, " << secs() << " children, min: " << n_ << " times, " << wall() << " wall, " << secs() << " children, min: "
<< min() << " max: " << max() << ")\n"; << min() << " max: " << max() << ")\n";
// Order children // Order children
typedef FastMap<size_t, boost::shared_ptr<TimingOutline> > ChildOrder; typedef FastMap<size_t, std::shared_ptr<TimingOutline> > ChildOrder;
ChildOrder childOrder; ChildOrder childOrder;
for(const ChildMap::value_type& child: children_) { for(const ChildMap::value_type& child: children_) {
childOrder[child.second->myOrder_] = child.second; childOrder[child.second->myOrder_] = child.second;
@ -141,10 +141,10 @@ void TimingOutline::print2(const std::string& outline,
} }
/* ************************************************************************* */ /* ************************************************************************* */
const boost::shared_ptr<TimingOutline>& TimingOutline::child(size_t child, const std::shared_ptr<TimingOutline>& TimingOutline::child(size_t child,
const std::string& label, const boost::weak_ptr<TimingOutline>& thisPtr) { const std::string& label, const std::weak_ptr<TimingOutline>& thisPtr) {
assert(thisPtr.lock().get() == this); assert(thisPtr.lock().get() == this);
boost::shared_ptr<TimingOutline>& result = children_[child]; std::shared_ptr<TimingOutline>& result = children_[child];
if (!result) { if (!result) {
// Create child if necessary // Create child if necessary
result.reset(new TimingOutline(label, child)); result.reset(new TimingOutline(label, child));
@ -236,7 +236,7 @@ size_t getTicTocID(const char *descriptionC) {
/* ************************************************************************* */ /* ************************************************************************* */
void tic(size_t id, const char *labelC) { void tic(size_t id, const char *labelC) {
const std::string label(labelC); const std::string label(labelC);
boost::shared_ptr<TimingOutline> node = // std::shared_ptr<TimingOutline> node = //
gCurrentTimer.lock()->child(id, label, gCurrentTimer); gCurrentTimer.lock()->child(id, label, gCurrentTimer);
gCurrentTimer = node; gCurrentTimer = node;
node->tic(); node->tic();
@ -244,7 +244,7 @@ void tic(size_t id, const char *labelC) {
/* ************************************************************************* */ /* ************************************************************************* */
void toc(size_t id, const char *label) { void toc(size_t id, const char *label) {
boost::shared_ptr<TimingOutline> current(gCurrentTimer.lock()); std::shared_ptr<TimingOutline> current(gCurrentTimer.lock());
if (id != current->id_) { if (id != current->id_) {
gTimingRoot->print(); gTimingRoot->print();
throw std::invalid_argument( throw std::invalid_argument(

View File

@ -21,8 +21,6 @@
#include <gtsam/dllexport.h> #include <gtsam/dllexport.h>
#include <gtsam/config.h> // for GTSAM_USE_TBB #include <gtsam/config.h> // for GTSAM_USE_TBB
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/version.hpp> #include <boost/version.hpp>
#include <cstddef> #include <cstddef>
@ -157,8 +155,8 @@ namespace gtsam {
std::string label_; std::string label_;
// Tree structure // Tree structure
boost::weak_ptr<TimingOutline> parent_; ///< parent pointer std::weak_ptr<TimingOutline> parent_; ///< parent pointer
typedef FastMap<size_t, boost::shared_ptr<TimingOutline> > ChildMap; typedef FastMap<size_t, std::shared_ptr<TimingOutline> > ChildMap;
ChildMap children_; ///< subtrees ChildMap children_; ///< subtrees
#ifdef GTSAM_USING_NEW_BOOST_TIMERS #ifdef GTSAM_USING_NEW_BOOST_TIMERS
@ -184,8 +182,8 @@ namespace gtsam {
double mean() const { return self() / double(n_); } ///< mean self time, in seconds double mean() const { return self() / double(n_); } ///< mean self time, in seconds
GTSAM_EXPORT void print(const std::string& outline = "") const; GTSAM_EXPORT void print(const std::string& outline = "") const;
GTSAM_EXPORT void print2(const std::string& outline = "", const double parentTotal = -1.0) const; GTSAM_EXPORT void print2(const std::string& outline = "", const double parentTotal = -1.0) const;
GTSAM_EXPORT const boost::shared_ptr<TimingOutline>& GTSAM_EXPORT const std::shared_ptr<TimingOutline>&
child(size_t child, const std::string& label, const boost::weak_ptr<TimingOutline>& thisPtr); child(size_t child, const std::string& label, const std::weak_ptr<TimingOutline>& thisPtr);
GTSAM_EXPORT void tic(); GTSAM_EXPORT void tic();
GTSAM_EXPORT void toc(); GTSAM_EXPORT void toc();
GTSAM_EXPORT void finishedIteration(); GTSAM_EXPORT void finishedIteration();
@ -216,8 +214,8 @@ namespace gtsam {
} }
}; };
GTSAM_EXTERN_EXPORT boost::shared_ptr<TimingOutline> gTimingRoot; GTSAM_EXTERN_EXPORT std::shared_ptr<TimingOutline> gTimingRoot;
GTSAM_EXTERN_EXPORT boost::weak_ptr<TimingOutline> gCurrentTimer; GTSAM_EXTERN_EXPORT std::weak_ptr<TimingOutline> gCurrentTimer;
} }
// Tic and toc functions that are always active (whether or not ENABLE_TIMING is defined) // Tic and toc functions that are always active (whether or not ENABLE_TIMING is defined)
@ -260,7 +258,7 @@ inline void tictoc_print2_() {
// get a node by label and assign it to variable // get a node by label and assign it to variable
#define tictoc_getNode(variable, label) \ #define tictoc_getNode(variable, label) \
static const size_t label##_id_getnode = ::gtsam::internal::getTicTocID(#label); \ static const size_t label##_id_getnode = ::gtsam::internal::getTicTocID(#label); \
const boost::shared_ptr<const ::gtsam::internal::TimingOutline> variable = \ const std::shared_ptr<const ::gtsam::internal::TimingOutline> variable = \
::gtsam::internal::gCurrentTimer.lock()->child(label##_id_getnode, #label, ::gtsam::internal::gCurrentTimer); ::gtsam::internal::gCurrentTimer.lock()->child(label##_id_getnode, #label, ::gtsam::internal::gCurrentTimer);
// reset // reset

View File

@ -27,8 +27,7 @@
#include <stack> #include <stack>
#include <vector> #include <vector>
#include <string> #include <string>
#include <boost/shared_ptr.hpp> #include <memory>
#include <boost/make_shared.hpp>
namespace gtsam { namespace gtsam {
@ -41,10 +40,10 @@ namespace {
template<typename NODE, typename DATA> template<typename NODE, typename DATA>
struct TraversalNode { struct TraversalNode {
bool expanded; bool expanded;
const boost::shared_ptr<NODE>& treeNode; const std::shared_ptr<NODE>& treeNode;
DATA& parentData; DATA& parentData;
typename FastList<DATA>::iterator dataPointer; typename FastList<DATA>::iterator dataPointer;
TraversalNode(const boost::shared_ptr<NODE>& _treeNode, DATA& _parentData) : TraversalNode(const std::shared_ptr<NODE>& _treeNode, DATA& _parentData) :
expanded(false), treeNode(_treeNode), parentData(_parentData) { expanded(false), treeNode(_treeNode), parentData(_parentData) {
} }
}; };
@ -52,7 +51,7 @@ struct TraversalNode {
// Do nothing - default argument for post-visitor for tree traversal // Do nothing - default argument for post-visitor for tree traversal
struct no_op { struct no_op {
template<typename NODE, typename DATA> template<typename NODE, typename DATA>
void operator()(const boost::shared_ptr<NODE>& node, const DATA& data) { void operator()(const std::shared_ptr<NODE>& node, const DATA& data) {
} }
}; };
@ -78,7 +77,7 @@ void DepthFirstForest(FOREST& forest, DATA& rootData, VISITOR_PRE& visitorPre,
VISITOR_POST& visitorPost) { VISITOR_POST& visitorPost) {
// Typedefs // Typedefs
typedef typename FOREST::Node Node; typedef typename FOREST::Node Node;
typedef boost::shared_ptr<Node> sharedNode; typedef std::shared_ptr<Node> sharedNode;
// Depth first traversal stack // Depth first traversal stack
typedef TraversalNode<typename FOREST::Node, DATA> TraversalNode; typedef TraversalNode<typename FOREST::Node, DATA> TraversalNode;
@ -169,29 +168,29 @@ void DepthFirstForestParallel(FOREST& forest, DATA& rootData,
/** Traversal function for CloneForest */ /** Traversal function for CloneForest */
namespace { namespace {
template<typename NODE> template<typename NODE>
boost::shared_ptr<NODE> CloneForestVisitorPre( std::shared_ptr<NODE> CloneForestVisitorPre(
const boost::shared_ptr<NODE>& node, const std::shared_ptr<NODE>& node,
const boost::shared_ptr<NODE>& parentPointer) { const std::shared_ptr<NODE>& parentPointer) {
// Clone the current node and add it to its cloned parent // Clone the current node and add it to its cloned parent
boost::shared_ptr<NODE> clone = boost::make_shared<NODE>(*node); std::shared_ptr<NODE> clone = std::make_shared<NODE>(*node);
clone->children.clear(); clone->children.clear();
parentPointer->children.push_back(clone); parentPointer->children.push_back(clone);
return clone; return clone;
} }
} }
/** Clone a tree, copy-constructing new nodes (calling boost::make_shared) and setting up child /** Clone a tree, copy-constructing new nodes (calling std::make_shared) and setting up child
* pointers for a clone of the original tree. * pointers for a clone of the original tree.
* @param forest The forest of trees to clone. The method \c forest.roots() should exist and * @param forest The forest of trees to clone. The method \c forest.roots() should exist and
* return a collection of shared pointers to \c FOREST::Node. * return a collection of shared pointers to \c FOREST::Node.
* @return The new collection of roots. */ * @return The new collection of roots. */
template<class FOREST> template<class FOREST>
FastVector<boost::shared_ptr<typename FOREST::Node> > CloneForest( FastVector<std::shared_ptr<typename FOREST::Node> > CloneForest(
const FOREST& forest) { const FOREST& forest) {
typedef typename FOREST::Node Node; typedef typename FOREST::Node Node;
boost::shared_ptr<Node> rootContainer = boost::make_shared<Node>(); std::shared_ptr<Node> rootContainer = std::make_shared<Node>();
DepthFirstForest(forest, rootContainer, CloneForestVisitorPre<Node>); DepthFirstForest(forest, rootContainer, CloneForestVisitorPre<Node>);
return FastVector<boost::shared_ptr<Node> >(rootContainer->children.begin(), return FastVector<std::shared_ptr<Node> >(rootContainer->children.begin(),
rootContainer->children.end()); rootContainer->children.end());
} }
@ -204,7 +203,7 @@ struct PrintForestVisitorPre {
formatter(formatter) { formatter(formatter) {
} }
template<typename NODE> std::string operator()( template<typename NODE> std::string operator()(
const boost::shared_ptr<NODE>& node, const std::string& parentString) { const std::shared_ptr<NODE>& node, const std::string& parentString) {
// Print the current node // Print the current node
node->print(parentString + "-", formatter); node->print(parentString + "-", formatter);
// Increment the indentation // Increment the indentation

View File

@ -18,8 +18,7 @@
#include <gtsam/global_includes.h> #include <gtsam/global_includes.h>
#include <boost/shared_ptr.hpp> #include <memory>
#include <boost/make_shared.hpp>
#ifdef GTSAM_USE_TBB #ifdef GTSAM_USE_TBB
#include <tbb/task_group.h> // tbb::task_group #include <tbb/task_group.h> // tbb::task_group
@ -37,8 +36,8 @@ namespace gtsam {
class PreOrderTask class PreOrderTask
{ {
public: public:
const boost::shared_ptr<NODE>& treeNode; const std::shared_ptr<NODE>& treeNode;
boost::shared_ptr<DATA> myData; std::shared_ptr<DATA> myData;
VISITOR_PRE& visitorPre; VISITOR_PRE& visitorPre;
VISITOR_POST& visitorPost; VISITOR_POST& visitorPost;
int problemSizeThreshold; int problemSizeThreshold;
@ -48,7 +47,7 @@ namespace gtsam {
// Keep track of order phase across multiple calls to the same functor // Keep track of order phase across multiple calls to the same functor
mutable bool isPostOrderPhase; mutable bool isPostOrderPhase;
PreOrderTask(const boost::shared_ptr<NODE>& treeNode, const boost::shared_ptr<DATA>& myData, PreOrderTask(const std::shared_ptr<NODE>& treeNode, const std::shared_ptr<DATA>& myData,
VISITOR_PRE& visitorPre, VISITOR_POST& visitorPost, int problemSizeThreshold, VISITOR_PRE& visitorPre, VISITOR_POST& visitorPost, int problemSizeThreshold,
tbb::task_group& tg, bool makeNewTasks = true) tbb::task_group& tg, bool makeNewTasks = true)
: treeNode(treeNode), : treeNode(treeNode),
@ -77,12 +76,12 @@ namespace gtsam {
// If we have child tasks, start subtasks and wait for them to complete // If we have child tasks, start subtasks and wait for them to complete
tbb::task_group ctg; tbb::task_group ctg;
for(const boost::shared_ptr<NODE>& child: treeNode->children) for(const std::shared_ptr<NODE>& child: treeNode->children)
{ {
// Process child in a subtask. Important: Run visitorPre before calling // Process child in a subtask. Important: Run visitorPre before calling
// allocate_child so that if visitorPre throws an exception, we will not have // allocate_child so that if visitorPre throws an exception, we will not have
// allocated an extra child, this causes a TBB error. // allocated an extra child, this causes a TBB error.
boost::shared_ptr<DATA> childData = boost::allocate_shared<DATA>( std::shared_ptr<DATA> childData = std::allocate_shared<DATA>(
tbb::scalable_allocator<DATA>(), visitorPre(child, *myData)); tbb::scalable_allocator<DATA>(), visitorPre(child, *myData));
ctg.run(PreOrderTask(child, childData, visitorPre, visitorPost, ctg.run(PreOrderTask(child, childData, visitorPre, visitorPost,
problemSizeThreshold, ctg, overThreshold)); problemSizeThreshold, ctg, overThreshold));
@ -107,9 +106,9 @@ namespace gtsam {
} }
} }
void processNodeRecursively(const boost::shared_ptr<NODE>& node, DATA& myData) const void processNodeRecursively(const std::shared_ptr<NODE>& node, DATA& myData) const
{ {
for(const boost::shared_ptr<NODE>& child: node->children) for(const std::shared_ptr<NODE>& child: node->children)
{ {
DATA childData = visitorPre(child, myData); DATA childData = visitorPre(child, myData);
processNodeRecursively(child, childData); processNodeRecursively(child, childData);
@ -140,9 +139,9 @@ namespace gtsam {
{ {
typedef PreOrderTask<NODE, DATA, VISITOR_PRE, VISITOR_POST> PreOrderTask; typedef PreOrderTask<NODE, DATA, VISITOR_PRE, VISITOR_POST> PreOrderTask;
// Create data and tasks for our children // Create data and tasks for our children
for(const boost::shared_ptr<NODE>& root: roots) for(const std::shared_ptr<NODE>& root: roots)
{ {
boost::shared_ptr<DATA> rootData = boost::allocate_shared<DATA>(tbb::scalable_allocator<DATA>(), visitorPre(root, myData)); std::shared_ptr<DATA> rootData = std::allocate_shared<DATA>(tbb::scalable_allocator<DATA>(), visitorPre(root, myData));
tg.run(PreOrderTask(root, rootData, visitorPre, visitorPost, problemSizeThreshold, tg)); tg.run(PreOrderTask(root, rootData, visitorPre, visitorPost, problemSizeThreshold, tg));
} }
} }

View File

@ -55,7 +55,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
namespace internal { namespace internal {
template<class NODE> template<class NODE>
ForestStatistics* statisticsVisitor(const boost::shared_ptr<NODE>& node, ForestStatistics* stats) ForestStatistics* statisticsVisitor(const std::shared_ptr<NODE>& node, ForestStatistics* stats)
{ {
(*stats->problemSizeHistogram[node->problemSize()]) ++; (*stats->problemSizeHistogram[node->problemSize()]) ++;
(*stats->numberOfChildrenHistogram[(int)node->children.size()]) ++; (*stats->numberOfChildrenHistogram[(int)node->children.size()]) ++;
@ -63,7 +63,7 @@ namespace gtsam {
{ {
int largestProblemSize = 0; int largestProblemSize = 0;
int secondLargestProblemSize = 0; int secondLargestProblemSize = 0;
for(const boost::shared_ptr<NODE>& child: node->children) for(const std::shared_ptr<NODE>& child: node->children)
{ {
if (child->problemSize() > largestProblemSize) if (child->problemSize() > largestProblemSize)
{ {

View File

@ -279,7 +279,7 @@ namespace gtsam {
/** /**
* A SFINAE trait to mark classes that need special alignment. * A SFINAE trait to mark classes that need special alignment.
* *
* This is required to make boost::make_shared and etc respect alignment, which is essential for the Python * This is required to make std::make_shared and etc respect alignment, which is essential for the Python
* wrappers to work properly. * wrappers to work properly.
* *
* Explanation * Explanation

View File

@ -94,7 +94,7 @@ TEST(Basis, Manual) {
auto linearizedFactor = predictFactor.linearize(values); auto linearizedFactor = predictFactor.linearize(values);
auto linearizedJacobianFactor = auto linearizedJacobianFactor =
boost::dynamic_pointer_cast<JacobianFactor>(linearizedFactor); std::dynamic_pointer_cast<JacobianFactor>(linearizedFactor);
CHECK(linearizedJacobianFactor); // makes sure it's indeed a JacobianFactor CHECK(linearizedJacobianFactor); // makes sure it's indeed a JacobianFactor
EXPECT(assert_equal(linearFactor, *linearizedJacobianFactor, 1e-9)); EXPECT(assert_equal(linearFactor, *linearizedJacobianFactor, 1e-9));
} }

View File

@ -23,7 +23,6 @@
#include <algorithm> #include <algorithm>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/make_shared.hpp>
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
@ -183,7 +182,7 @@ namespace gtsam {
*/ */
size_t allSame_; size_t allSame_;
using ChoicePtr = boost::shared_ptr<const Choice>; using ChoicePtr = std::shared_ptr<const Choice>;
public: public:
/// Default constructor for serialization. /// Default constructor for serialization.
@ -207,10 +206,10 @@ namespace gtsam {
for(auto branch: f->branches()) { for(auto branch: f->branches()) {
assert(branch->isLeaf()); assert(branch->isLeaf());
nrAssignments += nrAssignments +=
boost::dynamic_pointer_cast<const Leaf>(branch)->nrAssignments(); std::dynamic_pointer_cast<const Leaf>(branch)->nrAssignments();
} }
NodePtr newLeaf( NodePtr newLeaf(
new Leaf(boost::dynamic_pointer_cast<const Leaf>(f0)->constant(), new Leaf(std::dynamic_pointer_cast<const Leaf>(f0)->constant(),
nrAssignments)); nrAssignments));
return newLeaf; return newLeaf;
} else } else
@ -387,14 +386,14 @@ namespace gtsam {
/// apply unary operator. /// apply unary operator.
NodePtr apply(const Unary& op) const override { NodePtr apply(const Unary& op) const override {
auto r = boost::make_shared<Choice>(label_, *this, op); auto r = std::make_shared<Choice>(label_, *this, op);
return Unique(r); return Unique(r);
} }
/// Apply unary operator with assignment /// Apply unary operator with assignment
NodePtr apply(const UnaryAssignment& op, NodePtr apply(const UnaryAssignment& op,
const Assignment<L>& assignment) const override { const Assignment<L>& assignment) const override {
auto r = boost::make_shared<Choice>(label_, *this, op, assignment); auto r = std::make_shared<Choice>(label_, *this, op, assignment);
return Unique(r); return Unique(r);
} }
@ -409,7 +408,7 @@ namespace gtsam {
// If second argument of binary op is Leaf node, recurse on branches // If second argument of binary op is Leaf node, recurse on branches
NodePtr apply_g_op_fL(const Leaf& fL, const Binary& op) const override { NodePtr apply_g_op_fL(const Leaf& fL, const Binary& op) const override {
auto h = boost::make_shared<Choice>(label(), nrChoices()); auto h = std::make_shared<Choice>(label(), nrChoices());
for (auto&& branch : branches_) for (auto&& branch : branches_)
h->push_back(fL.apply_f_op_g(*branch, op)); h->push_back(fL.apply_f_op_g(*branch, op));
return Unique(h); return Unique(h);
@ -417,14 +416,14 @@ namespace gtsam {
// If second argument of binary op is Choice, call constructor // If second argument of binary op is Choice, call constructor
NodePtr apply_g_op_fC(const Choice& fC, const Binary& op) const override { NodePtr apply_g_op_fC(const Choice& fC, const Binary& op) const override {
auto h = boost::make_shared<Choice>(fC, *this, op); auto h = std::make_shared<Choice>(fC, *this, op);
return Unique(h); return Unique(h);
} }
// If second argument of binary op is Leaf // If second argument of binary op is Leaf
template<typename OP> template<typename OP>
NodePtr apply_fC_op_gL(const Leaf& gL, OP op) const { NodePtr apply_fC_op_gL(const Leaf& gL, OP op) const {
auto h = boost::make_shared<Choice>(label(), nrChoices()); auto h = std::make_shared<Choice>(label(), nrChoices());
for (auto&& branch : branches_) for (auto&& branch : branches_)
h->push_back(branch->apply_f_op_g(gL, op)); h->push_back(branch->apply_f_op_g(gL, op));
return Unique(h); return Unique(h);
@ -435,7 +434,7 @@ namespace gtsam {
if (label_ == label) return branches_[index]; // choose branch if (label_ == label) return branches_[index]; // choose branch
// second case, not label of interest, just recurse // second case, not label of interest, just recurse
auto r = boost::make_shared<Choice>(label_, branches_.size()); auto r = std::make_shared<Choice>(label_, branches_.size());
for (auto&& branch : branches_) for (auto&& branch : branches_)
r->push_back(branch->choose(label, index)); r->push_back(branch->choose(label, index));
return Unique(r); return Unique(r);
@ -476,7 +475,7 @@ namespace gtsam {
/****************************************************************************/ /****************************************************************************/
template <typename L, typename Y> template <typename L, typename Y>
DecisionTree<L, Y>::DecisionTree(const L& label, const Y& y1, const Y& y2) { DecisionTree<L, Y>::DecisionTree(const L& label, const Y& y1, const Y& y2) {
auto a = boost::make_shared<Choice>(label, 2); auto a = std::make_shared<Choice>(label, 2);
NodePtr l1(new Leaf(y1)), l2(new Leaf(y2)); NodePtr l1(new Leaf(y1)), l2(new Leaf(y2));
a->push_back(l1); a->push_back(l1);
a->push_back(l2); a->push_back(l2);
@ -489,7 +488,7 @@ namespace gtsam {
const Y& y2) { const Y& y2) {
if (labelC.second != 2) throw std::invalid_argument( if (labelC.second != 2) throw std::invalid_argument(
"DecisionTree: binary constructor called with non-binary label"); "DecisionTree: binary constructor called with non-binary label");
auto a = boost::make_shared<Choice>(labelC.first, 2); auto a = std::make_shared<Choice>(labelC.first, 2);
NodePtr l1(new Leaf(y1)), l2(new Leaf(y2)); NodePtr l1(new Leaf(y1)), l2(new Leaf(y2));
a->push_back(l1); a->push_back(l1);
a->push_back(l2); a->push_back(l2);
@ -568,8 +567,8 @@ namespace gtsam {
for (Iterator it = begin; it != end; it++) { for (Iterator it = begin; it != end; it++) {
if (it->root_->isLeaf()) if (it->root_->isLeaf())
continue; continue;
boost::shared_ptr<const Choice> c = std::shared_ptr<const Choice> c =
boost::dynamic_pointer_cast<const Choice>(it->root_); std::dynamic_pointer_cast<const Choice>(it->root_);
if (!highestLabel || c->label() > *highestLabel) { if (!highestLabel || c->label() > *highestLabel) {
highestLabel = c->label(); highestLabel = c->label();
nrChoices = c->nrChoices(); nrChoices = c->nrChoices();
@ -578,14 +577,14 @@ namespace gtsam {
// if label is already in correct order, just put together a choice on label // if label is already in correct order, just put together a choice on label
if (!nrChoices || !highestLabel || label > *highestLabel) { if (!nrChoices || !highestLabel || label > *highestLabel) {
auto choiceOnLabel = boost::make_shared<Choice>(label, end - begin); auto choiceOnLabel = std::make_shared<Choice>(label, end - begin);
for (Iterator it = begin; it != end; it++) for (Iterator it = begin; it != end; it++)
choiceOnLabel->push_back(it->root_); choiceOnLabel->push_back(it->root_);
return Choice::Unique(choiceOnLabel); return Choice::Unique(choiceOnLabel);
} else { } else {
// Set up a new choice on the highest label // Set up a new choice on the highest label
auto choiceOnHighestLabel = auto choiceOnHighestLabel =
boost::make_shared<Choice>(*highestLabel, nrChoices); std::make_shared<Choice>(*highestLabel, nrChoices);
// now, for all possible values of highestLabel // now, for all possible values of highestLabel
for (size_t index = 0; index < nrChoices; index++) { for (size_t index = 0; index < nrChoices; index++) {
// make a new set of functions for composing by iterating over the given // make a new set of functions for composing by iterating over the given
@ -647,7 +646,7 @@ namespace gtsam {
<< std::endl; << std::endl;
throw std::invalid_argument("DecisionTree::create invalid argument"); throw std::invalid_argument("DecisionTree::create invalid argument");
} }
auto choice = boost::make_shared<Choice>(begin->first, endY - beginY); auto choice = std::make_shared<Choice>(begin->first, endY - beginY);
for (ValueIt y = beginY; y != endY; y++) for (ValueIt y = beginY; y != endY; y++)
choice->push_back(NodePtr(new Leaf(*y))); choice->push_back(NodePtr(new Leaf(*y)));
return Choice::Unique(choice); return Choice::Unique(choice);
@ -678,13 +677,13 @@ namespace gtsam {
// functions. // functions.
// If leaf, apply unary conversion "op" and create a unique leaf. // If leaf, apply unary conversion "op" and create a unique leaf.
using MXLeaf = typename DecisionTree<M, X>::Leaf; using MXLeaf = typename DecisionTree<M, X>::Leaf;
if (auto leaf = boost::dynamic_pointer_cast<const MXLeaf>(f)) { if (auto leaf = std::dynamic_pointer_cast<const MXLeaf>(f)) {
return NodePtr(new Leaf(Y_of_X(leaf->constant()), leaf->nrAssignments())); return NodePtr(new Leaf(Y_of_X(leaf->constant()), leaf->nrAssignments()));
} }
// Check if Choice // Check if Choice
using MXChoice = typename DecisionTree<M, X>::Choice; using MXChoice = typename DecisionTree<M, X>::Choice;
auto choice = boost::dynamic_pointer_cast<const MXChoice>(f); auto choice = std::dynamic_pointer_cast<const MXChoice>(f);
if (!choice) throw std::invalid_argument( if (!choice) throw std::invalid_argument(
"DecisionTree::convertFrom: Invalid NodePtr"); "DecisionTree::convertFrom: Invalid NodePtr");
@ -720,11 +719,11 @@ namespace gtsam {
/// Do a depth-first visit on the tree rooted at node. /// Do a depth-first visit on the tree rooted at node.
void operator()(const typename DecisionTree<L, Y>::NodePtr& node) const { void operator()(const typename DecisionTree<L, Y>::NodePtr& node) const {
using Leaf = typename DecisionTree<L, Y>::Leaf; using Leaf = typename DecisionTree<L, Y>::Leaf;
if (auto leaf = boost::dynamic_pointer_cast<const Leaf>(node)) if (auto leaf = std::dynamic_pointer_cast<const Leaf>(node))
return f(leaf->constant()); return f(leaf->constant());
using Choice = typename DecisionTree<L, Y>::Choice; using Choice = typename DecisionTree<L, Y>::Choice;
auto choice = boost::dynamic_pointer_cast<const Choice>(node); auto choice = std::dynamic_pointer_cast<const Choice>(node);
if (!choice) if (!choice)
throw std::invalid_argument("DecisionTree::Visit: Invalid NodePtr"); throw std::invalid_argument("DecisionTree::Visit: Invalid NodePtr");
for (auto&& branch : choice->branches()) (*this)(branch); // recurse! for (auto&& branch : choice->branches()) (*this)(branch); // recurse!
@ -757,11 +756,11 @@ namespace gtsam {
/// Do a depth-first visit on the tree rooted at node. /// Do a depth-first visit on the tree rooted at node.
void operator()(const typename DecisionTree<L, Y>::NodePtr& node) const { void operator()(const typename DecisionTree<L, Y>::NodePtr& node) const {
using Leaf = typename DecisionTree<L, Y>::Leaf; using Leaf = typename DecisionTree<L, Y>::Leaf;
if (auto leaf = boost::dynamic_pointer_cast<const Leaf>(node)) if (auto leaf = std::dynamic_pointer_cast<const Leaf>(node))
return f(*leaf); return f(*leaf);
using Choice = typename DecisionTree<L, Y>::Choice; using Choice = typename DecisionTree<L, Y>::Choice;
auto choice = boost::dynamic_pointer_cast<const Choice>(node); auto choice = std::dynamic_pointer_cast<const Choice>(node);
if (!choice) if (!choice)
throw std::invalid_argument("DecisionTree::VisitLeaf: Invalid NodePtr"); throw std::invalid_argument("DecisionTree::VisitLeaf: Invalid NodePtr");
for (auto&& branch : choice->branches()) (*this)(branch); // recurse! for (auto&& branch : choice->branches()) (*this)(branch); // recurse!
@ -792,11 +791,11 @@ namespace gtsam {
/// Do a depth-first visit on the tree rooted at node. /// Do a depth-first visit on the tree rooted at node.
void operator()(const typename DecisionTree<L, Y>::NodePtr& node) { void operator()(const typename DecisionTree<L, Y>::NodePtr& node) {
using Leaf = typename DecisionTree<L, Y>::Leaf; using Leaf = typename DecisionTree<L, Y>::Leaf;
if (auto leaf = boost::dynamic_pointer_cast<const Leaf>(node)) if (auto leaf = std::dynamic_pointer_cast<const Leaf>(node))
return f(assignment, leaf->constant()); return f(assignment, leaf->constant());
using Choice = typename DecisionTree<L, Y>::Choice; using Choice = typename DecisionTree<L, Y>::Choice;
auto choice = boost::dynamic_pointer_cast<const Choice>(node); auto choice = std::dynamic_pointer_cast<const Choice>(node);
if (!choice) if (!choice)
throw std::invalid_argument("DecisionTree::VisitWith: Invalid NodePtr"); throw std::invalid_argument("DecisionTree::VisitWith: Invalid NodePtr");
for (size_t i = 0; i < choice->nrChoices(); i++) { for (size_t i = 0; i < choice->nrChoices(); i++) {

View File

@ -24,7 +24,7 @@
#include <gtsam/discrete/Assignment.h> #include <gtsam/discrete/Assignment.h>
#include <boost/serialization/nvp.hpp> #include <boost/serialization/nvp.hpp>
#include <boost/shared_ptr.hpp> #include <memory>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <map> #include <map>
@ -70,7 +70,7 @@ namespace gtsam {
/** ------------------------ Node base class --------------------------- */ /** ------------------------ Node base class --------------------------- */
struct Node { struct Node {
using Ptr = boost::shared_ptr<const Node>; using Ptr = std::shared_ptr<const Node>;
#ifdef DT_DEBUG_MEMORY #ifdef DT_DEBUG_MEMORY
static int nrNodes; static int nrNodes;

View File

@ -22,7 +22,6 @@
#include <gtsam/discrete/DecisionTreeFactor.h> #include <gtsam/discrete/DecisionTreeFactor.h>
#include <gtsam/discrete/DiscreteConditional.h> #include <gtsam/discrete/DiscreteConditional.h>
#include <boost/make_shared.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <utility> #include <utility>
@ -127,7 +126,7 @@ namespace gtsam {
Key j = keys()[i]; Key j = keys()[i];
dkeys.push_back(DiscreteKey(j, cardinality(j))); dkeys.push_back(DiscreteKey(j, cardinality(j)));
} }
return boost::make_shared<DecisionTreeFactor>(dkeys, result); return std::make_shared<DecisionTreeFactor>(dkeys, result);
} }
/* ************************************************************************ */ /* ************************************************************************ */
@ -160,7 +159,7 @@ namespace gtsam {
continue; continue;
dkeys.push_back(DiscreteKey(j, cardinality(j))); dkeys.push_back(DiscreteKey(j, cardinality(j)));
} }
return boost::make_shared<DecisionTreeFactor>(dkeys, result); return std::make_shared<DecisionTreeFactor>(dkeys, result);
} }
/* ************************************************************************ */ /* ************************************************************************ */

View File

@ -24,7 +24,7 @@
#include <gtsam/inference/Ordering.h> #include <gtsam/inference/Ordering.h>
#include <algorithm> #include <algorithm>
#include <boost/shared_ptr.hpp> #include <memory>
#include <map> #include <map>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
@ -47,7 +47,7 @@ namespace gtsam {
// typedefs needed to play nice with gtsam // typedefs needed to play nice with gtsam
typedef DecisionTreeFactor This; typedef DecisionTreeFactor This;
typedef DiscreteFactor Base; ///< Typedef to base class typedef DiscreteFactor Base; ///< Typedef to base class
typedef boost::shared_ptr<DecisionTreeFactor> shared_ptr; typedef std::shared_ptr<DecisionTreeFactor> shared_ptr;
typedef AlgebraicDecisionTree<Key> ADT; typedef AlgebraicDecisionTree<Key> ADT;
protected: protected:

View File

@ -20,7 +20,6 @@
#include <gtsam/discrete/DiscreteConditional.h> #include <gtsam/discrete/DiscreteConditional.h>
#include <gtsam/inference/FactorGraph-inst.h> #include <gtsam/inference/FactorGraph-inst.h>
#include <boost/make_shared.hpp>
#include <boost/range/adaptor/reversed.hpp> #include <boost/range/adaptor/reversed.hpp>
namespace gtsam { namespace gtsam {

View File

@ -23,7 +23,7 @@
#include <gtsam/inference/BayesNet.h> #include <gtsam/inference/BayesNet.h>
#include <gtsam/inference/FactorGraph.h> #include <gtsam/inference/FactorGraph.h>
#include <boost/shared_ptr.hpp> #include <memory>
#include <map> #include <map>
#include <string> #include <string>
#include <utility> #include <utility>
@ -40,8 +40,8 @@ class GTSAM_EXPORT DiscreteBayesNet: public BayesNet<DiscreteConditional> {
typedef BayesNet<DiscreteConditional> Base; typedef BayesNet<DiscreteConditional> Base;
typedef DiscreteBayesNet This; typedef DiscreteBayesNet This;
typedef DiscreteConditional ConditionalType; typedef DiscreteConditional ConditionalType;
typedef boost::shared_ptr<This> shared_ptr; typedef std::shared_ptr<This> shared_ptr;
typedef boost::shared_ptr<ConditionalType> sharedConditional; typedef std::shared_ptr<ConditionalType> sharedConditional;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{

View File

@ -42,12 +42,12 @@ class GTSAM_EXPORT DiscreteBayesTreeClique
typedef DiscreteBayesTreeClique This; typedef DiscreteBayesTreeClique This;
typedef BayesTreeCliqueBase<DiscreteBayesTreeClique, DiscreteFactorGraph> typedef BayesTreeCliqueBase<DiscreteBayesTreeClique, DiscreteFactorGraph>
Base; Base;
typedef boost::shared_ptr<This> shared_ptr; typedef std::shared_ptr<This> shared_ptr;
typedef boost::weak_ptr<This> weak_ptr; typedef std::weak_ptr<This> weak_ptr;
DiscreteBayesTreeClique() {} DiscreteBayesTreeClique() {}
virtual ~DiscreteBayesTreeClique() {} virtual ~DiscreteBayesTreeClique() {}
DiscreteBayesTreeClique( DiscreteBayesTreeClique(
const boost::shared_ptr<DiscreteConditional>& conditional) const std::shared_ptr<DiscreteConditional>& conditional)
: Base(conditional) {} : Base(conditional) {}
/// print index signature only /// print index signature only
@ -73,7 +73,7 @@ class GTSAM_EXPORT DiscreteBayesTree
public: public:
typedef DiscreteBayesTree This; typedef DiscreteBayesTree This;
typedef boost::shared_ptr<This> shared_ptr; typedef std::shared_ptr<This> shared_ptr;
/// @name Standard interface /// @name Standard interface
/// @{ /// @{

View File

@ -23,7 +23,6 @@
#include <gtsam/hybrid/HybridValues.h> #include <gtsam/hybrid/HybridValues.h>
#include <algorithm> #include <algorithm>
#include <boost/make_shared.hpp>
#include <random> #include <random>
#include <set> #include <set>
#include <stdexcept> #include <stdexcept>
@ -195,7 +194,7 @@ DiscreteConditional::shared_ptr DiscreteConditional::choose(
dKeys.emplace_back(j, this->cardinality(j)); dKeys.emplace_back(j, this->cardinality(j));
} }
} }
return boost::make_shared<DiscreteConditional>(nrFrontals(), dKeys, adt); return std::make_shared<DiscreteConditional>(nrFrontals(), dKeys, adt);
} }
/* ************************************************************************** */ /* ************************************************************************** */
@ -220,7 +219,7 @@ DecisionTreeFactor::shared_ptr DiscreteConditional::likelihood(
for (Key j : parents()) { for (Key j : parents()) {
discreteKeys.emplace_back(j, this->cardinality(j)); discreteKeys.emplace_back(j, this->cardinality(j));
} }
return boost::make_shared<DecisionTreeFactor>(discreteKeys, adt); return std::make_shared<DecisionTreeFactor>(discreteKeys, adt);
} }
/* ****************************************************************************/ /* ****************************************************************************/

View File

@ -22,8 +22,7 @@
#include <gtsam/discrete/DecisionTreeFactor.h> #include <gtsam/discrete/DecisionTreeFactor.h>
#include <gtsam/discrete/Signature.h> #include <gtsam/discrete/Signature.h>
#include <boost/make_shared.hpp> #include <memory>
#include <boost/shared_ptr.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
@ -41,7 +40,7 @@ class GTSAM_EXPORT DiscreteConditional
public: public:
// typedefs needed to play nice with gtsam // typedefs needed to play nice with gtsam
typedef DiscreteConditional This; ///< Typedef to this class typedef DiscreteConditional This; ///< Typedef to this class
typedef boost::shared_ptr<This> shared_ptr; ///< shared_ptr to this class typedef std::shared_ptr<This> shared_ptr; ///< shared_ptr to this class
typedef DecisionTreeFactor BaseFactor; ///< Typedef to our factor base class typedef DecisionTreeFactor BaseFactor; ///< Typedef to our factor base class
typedef Conditional<BaseFactor, This> typedef Conditional<BaseFactor, This>
BaseConditional; ///< Typedef to our conditional base class BaseConditional; ///< Typedef to our conditional base class

View File

@ -34,7 +34,7 @@ namespace gtsam {
public: public:
typedef EliminationTree<DiscreteBayesNet, DiscreteFactorGraph> Base; ///< Base class typedef EliminationTree<DiscreteBayesNet, DiscreteFactorGraph> Base; ///< Base class
typedef DiscreteEliminationTree This; ///< This class typedef DiscreteEliminationTree This; ///< This class
typedef boost::shared_ptr<This> shared_ptr; ///< Shared pointer to this class typedef std::shared_ptr<This> shared_ptr; ///< Shared pointer to this class
/** /**
* Build the elimination tree of a factor graph using pre-computed column structure. * Build the elimination tree of a factor graph using pre-computed column structure.

View File

@ -41,7 +41,7 @@ public:
// typedefs needed to play nice with gtsam // typedefs needed to play nice with gtsam
typedef DiscreteFactor This; ///< This class typedef DiscreteFactor This; ///< This class
typedef boost::shared_ptr<DiscreteFactor> shared_ptr; ///< shared_ptr to this class typedef std::shared_ptr<DiscreteFactor> shared_ptr; ///< shared_ptr to this class
typedef Factor Base; ///< Our base class typedef Factor Base; ///< Our base class
using Values = DiscreteValues; ///< backwards compatibility using Values = DiscreteValues; ///< backwards compatibility

View File

@ -54,7 +54,7 @@ namespace gtsam {
DiscreteKeys DiscreteFactorGraph::discreteKeys() const { DiscreteKeys DiscreteFactorGraph::discreteKeys() const {
DiscreteKeys result; DiscreteKeys result;
for (auto&& factor : *this) { for (auto&& factor : *this) {
if (auto p = boost::dynamic_pointer_cast<DecisionTreeFactor>(factor)) { if (auto p = std::dynamic_pointer_cast<DecisionTreeFactor>(factor)) {
DiscreteKeys factor_keys = p->discreteKeys(); DiscreteKeys factor_keys = p->discreteKeys();
result.insert(result.end(), factor_keys.begin(), factor_keys.end()); result.insert(result.end(), factor_keys.begin(), factor_keys.end());
} }
@ -136,12 +136,12 @@ namespace gtsam {
// Make lookup with product // Make lookup with product
gttic(lookup); gttic(lookup);
size_t nrFrontals = frontalKeys.size(); size_t nrFrontals = frontalKeys.size();
auto lookup = boost::make_shared<DiscreteLookupTable>(nrFrontals, auto lookup = std::make_shared<DiscreteLookupTable>(nrFrontals,
orderedKeys, product); orderedKeys, product);
gttoc(lookup); gttoc(lookup);
return std::make_pair( return std::make_pair(
boost::dynamic_pointer_cast<DiscreteConditional>(lookup), max); std::dynamic_pointer_cast<DiscreteConditional>(lookup), max);
} }
/* ************************************************************************ */ /* ************************************************************************ */
@ -220,7 +220,7 @@ namespace gtsam {
// now divide product/sum to get conditional // now divide product/sum to get conditional
gttic(divide); gttic(divide);
auto conditional = auto conditional =
boost::make_shared<DiscreteConditional>(product, *sum, orderedKeys); std::make_shared<DiscreteConditional>(product, *sum, orderedKeys);
gttoc(divide); gttoc(divide);
return std::make_pair(conditional, sum); return std::make_pair(conditional, sum);

View File

@ -25,7 +25,6 @@
#include <gtsam/inference/Ordering.h> #include <gtsam/inference/Ordering.h>
#include <gtsam/base/FastSet.h> #include <gtsam/base/FastSet.h>
#include <boost/make_shared.hpp>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -48,7 +47,7 @@ class DiscreteJunctionTree;
* @return GTSAM_EXPORT * @return GTSAM_EXPORT
* @ingroup discrete * @ingroup discrete
*/ */
GTSAM_EXPORT std::pair<boost::shared_ptr<DiscreteConditional>, DecisionTreeFactor::shared_ptr> GTSAM_EXPORT std::pair<std::shared_ptr<DiscreteConditional>, DecisionTreeFactor::shared_ptr>
EliminateDiscrete(const DiscreteFactorGraph& factors, const Ordering& keys); EliminateDiscrete(const DiscreteFactorGraph& factors, const Ordering& keys);
/* ************************************************************************* */ /* ************************************************************************* */
@ -62,8 +61,8 @@ template<> struct EliminationTraits<DiscreteFactorGraph>
typedef DiscreteBayesTree BayesTreeType; ///< Type of Bayes tree typedef DiscreteBayesTree BayesTreeType; ///< Type of Bayes tree
typedef DiscreteJunctionTree JunctionTreeType; ///< Type of Junction tree typedef DiscreteJunctionTree JunctionTreeType; ///< Type of Junction tree
/// The default dense elimination function /// The default dense elimination function
static std::pair<boost::shared_ptr<ConditionalType>, static std::pair<std::shared_ptr<ConditionalType>,
boost::shared_ptr<FactorType> > std::shared_ptr<FactorType> >
DefaultEliminate(const FactorGraphType& factors, const Ordering& keys) { DefaultEliminate(const FactorGraphType& factors, const Ordering& keys) {
return EliminateDiscrete(factors, keys); return EliminateDiscrete(factors, keys);
} }
@ -89,7 +88,7 @@ class GTSAM_EXPORT DiscreteFactorGraph
using Base = FactorGraph<DiscreteFactor>; ///< base factor graph type using Base = FactorGraph<DiscreteFactor>; ///< base factor graph type
using BaseEliminateable = using BaseEliminateable =
EliminateableFactorGraph<This>; ///< for elimination EliminateableFactorGraph<This>; ///< for elimination
using shared_ptr = boost::shared_ptr<This>; ///< shared_ptr to This using shared_ptr = std::shared_ptr<This>; ///< shared_ptr to This
using Values = DiscreteValues; ///< backwards compatibility using Values = DiscreteValues; ///< backwards compatibility

View File

@ -53,7 +53,7 @@ namespace gtsam {
public: public:
typedef JunctionTree<DiscreteBayesTree, DiscreteFactorGraph> Base; ///< Base class typedef JunctionTree<DiscreteBayesTree, DiscreteFactorGraph> Base; ///< Base class
typedef DiscreteJunctionTree This; ///< This class typedef DiscreteJunctionTree This; ///< This class
typedef boost::shared_ptr<This> shared_ptr; ///< Shared pointer to this class typedef std::shared_ptr<This> shared_ptr; ///< Shared pointer to this class
/** /**
* Build the elimination tree of a factor graph using precomputed column structure. * Build the elimination tree of a factor graph using precomputed column structure.

View File

@ -106,7 +106,7 @@ DiscreteLookupDAG DiscreteLookupDAG::FromBayesNet(
DiscreteLookupDAG dag; DiscreteLookupDAG dag;
for (auto&& conditional : bayesNet) { for (auto&& conditional : bayesNet) {
if (auto lookupTable = if (auto lookupTable =
boost::dynamic_pointer_cast<DiscreteLookupTable>(conditional)) { std::dynamic_pointer_cast<DiscreteLookupTable>(conditional)) {
dag.push_back(lookupTable); dag.push_back(lookupTable);
} else { } else {
throw std::runtime_error( throw std::runtime_error(

View File

@ -21,7 +21,7 @@
#include <gtsam/inference/BayesNet.h> #include <gtsam/inference/BayesNet.h>
#include <gtsam/inference/FactorGraph.h> #include <gtsam/inference/FactorGraph.h>
#include <boost/shared_ptr.hpp> #include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -40,7 +40,7 @@ class DiscreteBayesNet;
class GTSAM_EXPORT DiscreteLookupTable : public DiscreteConditional { class GTSAM_EXPORT DiscreteLookupTable : public DiscreteConditional {
public: public:
using This = DiscreteLookupTable; using This = DiscreteLookupTable;
using shared_ptr = boost::shared_ptr<This>; using shared_ptr = std::shared_ptr<This>;
using BaseConditional = Conditional<DecisionTreeFactor, This>; using BaseConditional = Conditional<DecisionTreeFactor, This>;
/** /**
@ -78,7 +78,7 @@ class GTSAM_EXPORT DiscreteLookupDAG : public BayesNet<DiscreteLookupTable> {
public: public:
using Base = BayesNet<DiscreteLookupTable>; using Base = BayesNet<DiscreteLookupTable>;
using This = DiscreteLookupDAG; using This = DiscreteLookupDAG;
using shared_ptr = boost::shared_ptr<This>; using shared_ptr = std::shared_ptr<This>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{

View File

@ -326,7 +326,7 @@ TEST(DecisionTree, NrAssignments) {
const std::pair<string, size_t> A("A", 2), B("B", 2), C("C", 2); const std::pair<string, size_t> A("A", 2), B("B", 2), C("C", 2);
DT tree({A, B, C}, "1 1 1 1 1 1 1 1"); DT tree({A, B, C}, "1 1 1 1 1 1 1 1");
EXPECT(tree.root_->isLeaf()); EXPECT(tree.root_->isLeaf());
auto leaf = boost::dynamic_pointer_cast<const DT::Leaf>(tree.root_); auto leaf = std::dynamic_pointer_cast<const DT::Leaf>(tree.root_);
EXPECT_LONGS_EQUAL(8, leaf->nrAssignments()); EXPECT_LONGS_EQUAL(8, leaf->nrAssignments());
DT tree2({C, B, A}, "1 1 1 2 3 4 5 5"); DT tree2({C, B, A}, "1 1 1 2 3 4 5 5");
@ -344,20 +344,20 @@ TEST(DecisionTree, NrAssignments) {
1 1 Leaf 5 1 1 Leaf 5
*/ */
auto root = boost::dynamic_pointer_cast<const DT::Choice>(tree2.root_); auto root = std::dynamic_pointer_cast<const DT::Choice>(tree2.root_);
CHECK(root); CHECK(root);
auto choice0 = boost::dynamic_pointer_cast<const DT::Choice>(root->branches()[0]); auto choice0 = std::dynamic_pointer_cast<const DT::Choice>(root->branches()[0]);
CHECK(choice0); CHECK(choice0);
EXPECT(choice0->branches()[0]->isLeaf()); EXPECT(choice0->branches()[0]->isLeaf());
auto choice00 = boost::dynamic_pointer_cast<const DT::Leaf>(choice0->branches()[0]); auto choice00 = std::dynamic_pointer_cast<const DT::Leaf>(choice0->branches()[0]);
CHECK(choice00); CHECK(choice00);
EXPECT_LONGS_EQUAL(2, choice00->nrAssignments()); EXPECT_LONGS_EQUAL(2, choice00->nrAssignments());
auto choice1 = boost::dynamic_pointer_cast<const DT::Choice>(root->branches()[1]); auto choice1 = std::dynamic_pointer_cast<const DT::Choice>(root->branches()[1]);
CHECK(choice1); CHECK(choice1);
auto choice10 = boost::dynamic_pointer_cast<const DT::Choice>(choice1->branches()[0]); auto choice10 = std::dynamic_pointer_cast<const DT::Choice>(choice1->branches()[0]);
CHECK(choice10); CHECK(choice10);
auto choice11 = boost::dynamic_pointer_cast<const DT::Leaf>(choice1->branches()[1]); auto choice11 = std::dynamic_pointer_cast<const DT::Leaf>(choice1->branches()[1]);
CHECK(choice11); CHECK(choice11);
EXPECT(choice11->isLeaf()); EXPECT(choice11->isLeaf());
EXPECT_LONGS_EQUAL(2, choice11->nrAssignments()); EXPECT_LONGS_EQUAL(2, choice11->nrAssignments());

View File

@ -42,13 +42,13 @@ TEST(DiscreteBayesNet, bayesNet) {
DiscreteBayesNet bayesNet; DiscreteBayesNet bayesNet;
DiscreteKey Parent(0, 2), Child(1, 2); DiscreteKey Parent(0, 2), Child(1, 2);
auto prior = boost::make_shared<DiscreteConditional>(Parent % "6/4"); auto prior = std::make_shared<DiscreteConditional>(Parent % "6/4");
CHECK(assert_equal(ADT({Parent}, "0.6 0.4"), CHECK(assert_equal(ADT({Parent}, "0.6 0.4"),
(ADT)*prior)); (ADT)*prior));
bayesNet.push_back(prior); bayesNet.push_back(prior);
auto conditional = auto conditional =
boost::make_shared<DiscreteConditional>(Child | Parent = "7/3 8/2"); std::make_shared<DiscreteConditional>(Child | Parent = "7/3 8/2");
EXPECT_LONGS_EQUAL(1, *(conditional->beginFrontals())); EXPECT_LONGS_EQUAL(1, *(conditional->beginFrontals()));
ADT expected(Child & Parent, "0.7 0.8 0.3 0.2"); ADT expected(Child & Parent, "0.7 0.8 0.3 0.2");
CHECK(assert_equal(expected, (ADT)*conditional)); CHECK(assert_equal(expected, (ADT)*conditional));

View File

@ -34,7 +34,7 @@ static constexpr bool debug = false;
struct TestFixture { struct TestFixture {
vector<DiscreteKey> keys; vector<DiscreteKey> keys;
DiscreteBayesNet bayesNet; DiscreteBayesNet bayesNet;
boost::shared_ptr<DiscreteBayesTree> bayesTree; std::shared_ptr<DiscreteBayesTree> bayesTree;
/** /**
* Create a thin-tree Bayesnet, a la Jean-Guillaume Durand (former student), * Create a thin-tree Bayesnet, a la Jean-Guillaume Durand (former student),

View File

@ -23,7 +23,6 @@
#include <gtsam/discrete/DiscreteConditional.h> #include <gtsam/discrete/DiscreteConditional.h>
#include <gtsam/inference/Symbol.h> #include <gtsam/inference/Symbol.h>
#include <boost/make_shared.hpp>
using namespace std; using namespace std;
using namespace gtsam; using namespace gtsam;

View File

@ -119,11 +119,11 @@ TEST_UNSAFE( DiscreteMarginals, truss ) {
// bayesTree->print("Bayes Tree"); // bayesTree->print("Bayes Tree");
typedef DiscreteBayesTreeClique Clique; typedef DiscreteBayesTreeClique Clique;
Clique expected0(boost::make_shared<DiscreteConditional>((key[0] | key[2], key[4]) = "2/1 2/1 2/1 2/1")); Clique expected0(std::make_shared<DiscreteConditional>((key[0] | key[2], key[4]) = "2/1 2/1 2/1 2/1"));
Clique::shared_ptr actual0 = (*bayesTree)[0]; Clique::shared_ptr actual0 = (*bayesTree)[0];
// EXPECT(assert_equal(expected0, *actual0)); // TODO, correct but fails // EXPECT(assert_equal(expected0, *actual0)); // TODO, correct but fails
Clique expected1(boost::make_shared<DiscreteConditional>((key[1] | key[3], key[4]) = "1/2 1/2 1/2 1/2")); Clique expected1(std::make_shared<DiscreteConditional>((key[1] | key[3], key[4]) = "1/2 1/2 1/2 1/2"));
Clique::shared_ptr actual1 = (*bayesTree)[1]; Clique::shared_ptr actual1 = (*bayesTree)[1];
// EXPECT(assert_equal(expected1, *actual1)); // TODO, correct but fails // EXPECT(assert_equal(expected1, *actual1)); // TODO, correct but fails
@ -133,12 +133,12 @@ TEST_UNSAFE( DiscreteMarginals, truss ) {
// test 0 // test 0
DecisionTreeFactor expectedM0(key[0],"0.666667 0.333333"); DecisionTreeFactor expectedM0(key[0],"0.666667 0.333333");
DiscreteFactor::shared_ptr actualM0 = marginals(0); DiscreteFactor::shared_ptr actualM0 = marginals(0);
EXPECT(assert_equal(expectedM0, *boost::dynamic_pointer_cast<DecisionTreeFactor>(actualM0),1e-5)); EXPECT(assert_equal(expectedM0, *std::dynamic_pointer_cast<DecisionTreeFactor>(actualM0),1e-5));
// test 1 // test 1
DecisionTreeFactor expectedM1(key[1],"0.333333 0.666667"); DecisionTreeFactor expectedM1(key[1],"0.333333 0.666667");
DiscreteFactor::shared_ptr actualM1 = marginals(1); DiscreteFactor::shared_ptr actualM1 = marginals(1);
EXPECT(assert_equal(expectedM1, *boost::dynamic_pointer_cast<DecisionTreeFactor>(actualM1),1e-5)); EXPECT(assert_equal(expectedM1, *std::dynamic_pointer_cast<DecisionTreeFactor>(actualM1),1e-5));
} }
/* ************************************************************************* */ /* ************************************************************************* */
@ -187,7 +187,7 @@ TEST_UNSAFE(DiscreteMarginals, truss2) {
DecisionTreeFactor expectedM(key[j], table); DecisionTreeFactor expectedM(key[j], table);
DiscreteFactor::shared_ptr actualM = marginals(j); DiscreteFactor::shared_ptr actualM = marginals(j);
EXPECT(assert_equal( EXPECT(assert_equal(
expectedM, *boost::dynamic_pointer_cast<DecisionTreeFactor>(actualM))); expectedM, *std::dynamic_pointer_cast<DecisionTreeFactor>(actualM)));
} }
} }

View File

@ -75,7 +75,7 @@ class GTSAM_EXPORT Cal3 {
public: public:
enum { dimension = 5 }; enum { dimension = 5 };
///< shared pointer to calibration object ///< shared pointer to calibration object
using shared_ptr = boost::shared_ptr<Cal3>; using shared_ptr = std::shared_ptr<Cal3>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{

View File

@ -42,7 +42,7 @@ class GTSAM_EXPORT Cal3Bundler : public Cal3 {
enum { dimension = 3 }; enum { dimension = 3 };
///< shared pointer to stereo calibration object ///< shared pointer to stereo calibration object
using shared_ptr = boost::shared_ptr<Cal3Bundler>; using shared_ptr = std::shared_ptr<Cal3Bundler>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{

View File

@ -21,7 +21,7 @@
#pragma once #pragma once
#include <gtsam/geometry/Cal3DS2_Base.h> #include <gtsam/geometry/Cal3DS2_Base.h>
#include <boost/shared_ptr.hpp> #include <memory>
namespace gtsam { namespace gtsam {
@ -39,7 +39,7 @@ class GTSAM_EXPORT Cal3DS2 : public Cal3DS2_Base {
enum { dimension = 9 }; enum { dimension = 9 };
///< shared pointer to stereo calibration object ///< shared pointer to stereo calibration object
using shared_ptr = boost::shared_ptr<Cal3DS2>; using shared_ptr = std::shared_ptr<Cal3DS2>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{
@ -94,8 +94,8 @@ class GTSAM_EXPORT Cal3DS2 : public Cal3DS2_Base {
/// @{ /// @{
/// @return a deep copy of this object /// @return a deep copy of this object
boost::shared_ptr<Base> clone() const override { std::shared_ptr<Base> clone() const override {
return boost::shared_ptr<Base>(new Cal3DS2(*this)); return std::shared_ptr<Base>(new Cal3DS2(*this));
} }
/// @} /// @}

View File

@ -21,7 +21,7 @@
#include <gtsam/geometry/Cal3.h> #include <gtsam/geometry/Cal3.h>
#include <gtsam/geometry/Point2.h> #include <gtsam/geometry/Point2.h>
#include <boost/shared_ptr.hpp> #include <memory>
namespace gtsam { namespace gtsam {
@ -49,7 +49,7 @@ class GTSAM_EXPORT Cal3DS2_Base : public Cal3 {
enum { dimension = 9 }; enum { dimension = 9 };
///< shared pointer to stereo calibration object ///< shared pointer to stereo calibration object
using shared_ptr = boost::shared_ptr<Cal3DS2_Base>; using shared_ptr = std::shared_ptr<Cal3DS2_Base>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{
@ -146,8 +146,8 @@ class GTSAM_EXPORT Cal3DS2_Base : public Cal3 {
/// @{ /// @{
/// @return a deep copy of this object /// @return a deep copy of this object
virtual boost::shared_ptr<Cal3DS2_Base> clone() const { virtual std::shared_ptr<Cal3DS2_Base> clone() const {
return boost::shared_ptr<Cal3DS2_Base>(new Cal3DS2_Base(*this)); return std::shared_ptr<Cal3DS2_Base>(new Cal3DS2_Base(*this));
} }
/// @} /// @}

View File

@ -22,7 +22,7 @@
#include <gtsam/geometry/Cal3.h> #include <gtsam/geometry/Cal3.h>
#include <gtsam/geometry/Point2.h> #include <gtsam/geometry/Point2.h>
#include <boost/shared_ptr.hpp> #include <memory>
#include <string> #include <string>
@ -57,7 +57,7 @@ class GTSAM_EXPORT Cal3Fisheye : public Cal3 {
public: public:
enum { dimension = 9 }; enum { dimension = 9 };
///< shared pointer to fisheye calibration object ///< shared pointer to fisheye calibration object
using shared_ptr = boost::shared_ptr<Cal3Fisheye>; using shared_ptr = std::shared_ptr<Cal3Fisheye>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{
@ -174,8 +174,8 @@ class GTSAM_EXPORT Cal3Fisheye : public Cal3 {
/// @{ /// @{
/// @return a deep copy of this object /// @return a deep copy of this object
virtual boost::shared_ptr<Cal3Fisheye> clone() const { virtual std::shared_ptr<Cal3Fisheye> clone() const {
return boost::shared_ptr<Cal3Fisheye>(new Cal3Fisheye(*this)); return std::shared_ptr<Cal3Fisheye>(new Cal3Fisheye(*this));
} }
/// @} /// @}

View File

@ -53,7 +53,7 @@ class GTSAM_EXPORT Cal3Unified : public Cal3DS2_Base {
enum { dimension = 10 }; enum { dimension = 10 };
///< shared pointer to stereo calibration object ///< shared pointer to stereo calibration object
using shared_ptr = boost::shared_ptr<Cal3Unified>; using shared_ptr = std::shared_ptr<Cal3Unified>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{

View File

@ -36,7 +36,7 @@ class GTSAM_EXPORT Cal3_S2 : public Cal3 {
enum { dimension = 5 }; enum { dimension = 5 };
///< shared pointer to calibration object ///< shared pointer to calibration object
using shared_ptr = boost::shared_ptr<Cal3_S2>; using shared_ptr = std::shared_ptr<Cal3_S2>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{

View File

@ -35,7 +35,7 @@ class GTSAM_EXPORT Cal3_S2Stereo : public Cal3_S2 {
enum { dimension = 6 }; enum { dimension = 6 };
///< shared pointer to stereo calibration object ///< shared pointer to stereo calibration object
using shared_ptr = boost::shared_ptr<Cal3_S2Stereo>; using shared_ptr = std::shared_ptr<Cal3_S2Stereo>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{

View File

@ -21,7 +21,6 @@
#include <gtsam/geometry/CalibratedCamera.h> #include <gtsam/geometry/CalibratedCamera.h>
#include <gtsam/geometry/Point2.h> #include <gtsam/geometry/Point2.h>
#include <boost/make_shared.hpp>
namespace gtsam { namespace gtsam {
@ -245,7 +244,7 @@ class PinholePose: public PinholeBaseK<CALIBRATION> {
private: private:
typedef PinholeBaseK<CALIBRATION> Base; ///< base class has 3D pose as private member typedef PinholeBaseK<CALIBRATION> Base; ///< base class has 3D pose as private member
boost::shared_ptr<CALIBRATION> K_; ///< shared pointer to fixed calibration std::shared_ptr<CALIBRATION> K_; ///< shared pointer to fixed calibration
public: public:
@ -266,7 +265,7 @@ public:
} }
/** constructor with pose and calibration */ /** constructor with pose and calibration */
PinholePose(const Pose3& pose, const boost::shared_ptr<CALIBRATION>& K) : PinholePose(const Pose3& pose, const std::shared_ptr<CALIBRATION>& K) :
Base(pose), K_(K) { Base(pose), K_(K) {
} }
@ -281,14 +280,14 @@ public:
* (theta 0 = looking in direction of positive X axis) * (theta 0 = looking in direction of positive X axis)
* @param height camera height * @param height camera height
*/ */
static PinholePose Level(const boost::shared_ptr<CALIBRATION>& K, static PinholePose Level(const std::shared_ptr<CALIBRATION>& K,
const Pose2& pose2, double height) { const Pose2& pose2, double height) {
return PinholePose(Base::LevelPose(pose2, height), K); return PinholePose(Base::LevelPose(pose2, height), K);
} }
/// PinholePose::level with default calibration /// PinholePose::level with default calibration
static PinholePose Level(const Pose2& pose2, double height) { static PinholePose Level(const Pose2& pose2, double height) {
return PinholePose::Level(boost::make_shared<CALIBRATION>(), pose2, height); return PinholePose::Level(std::make_shared<CALIBRATION>(), pose2, height);
} }
/** /**
@ -301,8 +300,8 @@ public:
* @param K optional calibration parameter * @param K optional calibration parameter
*/ */
static PinholePose Lookat(const Point3& eye, const Point3& target, static PinholePose Lookat(const Point3& eye, const Point3& target,
const Point3& upVector, const boost::shared_ptr<CALIBRATION>& K = const Point3& upVector, const std::shared_ptr<CALIBRATION>& K =
boost::make_shared<CALIBRATION>()) { std::make_shared<CALIBRATION>()) {
return PinholePose(Base::LookatPose(eye, target, upVector), K); return PinholePose(Base::LookatPose(eye, target, upVector), K);
} }
@ -362,7 +361,7 @@ public:
} }
/// return shared pointer to calibration /// return shared pointer to calibration
const boost::shared_ptr<CALIBRATION>& sharedCalibration() const { const std::shared_ptr<CALIBRATION>& sharedCalibration() const {
return K_; return K_;
} }

View File

@ -42,7 +42,7 @@ class GTSAM_EXPORT EmptyCal {
enum { dimension = 0 }; enum { dimension = 0 };
EmptyCal() {} EmptyCal() {}
virtual ~EmptyCal() = default; virtual ~EmptyCal() = default;
using shared_ptr = boost::shared_ptr<EmptyCal>; using shared_ptr = std::shared_ptr<EmptyCal>;
/// return DOF, dimensionality of tangent space /// return DOF, dimensionality of tangent space
inline static size_t Dim() { return dimension; } inline static size_t Dim() { return dimension; }
@ -87,11 +87,11 @@ class GTSAM_EXPORT SphericalCamera {
/// Default constructor /// Default constructor
SphericalCamera() SphericalCamera()
: pose_(Pose3()), emptyCal_(boost::make_shared<EmptyCal>()) {} : pose_(Pose3()), emptyCal_(std::make_shared<EmptyCal>()) {}
/// Constructor with pose /// Constructor with pose
explicit SphericalCamera(const Pose3& pose) explicit SphericalCamera(const Pose3& pose)
: pose_(pose), emptyCal_(boost::make_shared<EmptyCal>()) {} : pose_(pose), emptyCal_(std::make_shared<EmptyCal>()) {}
/// Constructor with empty intrinsics (needed for smart factors) /// Constructor with empty intrinsics (needed for smart factors)
explicit SphericalCamera(const Pose3& pose, explicit SphericalCamera(const Pose3& pose,

View File

@ -33,7 +33,7 @@ using namespace gtsam;
typedef PinholePose<Cal3_S2> Camera; typedef PinholePose<Cal3_S2> Camera;
static const Cal3_S2::shared_ptr K = boost::make_shared<Cal3_S2>(625, 625, 0, 0, 0); static const Cal3_S2::shared_ptr K = std::make_shared<Cal3_S2>(625, 625, 0, 0, 0);
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5)); static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5));
static const Camera camera(pose, K); static const Camera camera(pose, K);
@ -263,8 +263,8 @@ TEST( PinholePose, range1) {
/* ************************************************************************* */ /* ************************************************************************* */
typedef PinholePose<Cal3Bundler> Camera2; typedef PinholePose<Cal3Bundler> Camera2;
static const boost::shared_ptr<Cal3Bundler> K2 = static const std::shared_ptr<Cal3Bundler> K2 =
boost::make_shared<Cal3Bundler>(625, 1e-3, 1e-3); std::make_shared<Cal3Bundler>(625, 1e-3, 1e-3);
static const Camera2 camera2(pose1, K2); static const Camera2 camera2(pose1, K2);
static double range2(const Camera& camera, const Camera2& camera2) { static double range2(const Camera& camera, const Camera2& camera2) {
return camera.range<Cal3Bundler>(camera2); return camera.range<Cal3Bundler>(camera2);

View File

@ -89,7 +89,7 @@ static Point3 landmark(0, 0, 5);
/* ************************************************************************* */ /* ************************************************************************* */
static StereoPoint2 project3(const Pose3& pose, const Point3& point, const Cal3_S2Stereo& K) { static StereoPoint2 project3(const Pose3& pose, const Point3& point, const Cal3_S2Stereo& K) {
return StereoCamera(pose, boost::make_shared<Cal3_S2Stereo>(K)).project(point); return StereoCamera(pose, std::make_shared<Cal3_S2Stereo>(K)).project(point);
} }
/* ************************************************************************* */ /* ************************************************************************* */
@ -150,7 +150,7 @@ TEST( StereoCamera, backproject_case2)
} }
static Point3 backproject3(const Pose3& pose, const StereoPoint2& point, const Cal3_S2Stereo& K) { static Point3 backproject3(const Pose3& pose, const StereoPoint2& point, const Cal3_S2Stereo& K) {
return StereoCamera(pose, boost::make_shared<Cal3_S2Stereo>(K)).backproject(point); return StereoCamera(pose, std::make_shared<Cal3_S2Stereo>(K)).backproject(point);
} }
/* ************************************************************************* */ /* ************************************************************************* */

View File

@ -35,8 +35,8 @@ using namespace gtsam;
// Some common constants // Some common constants
static const boost::shared_ptr<Cal3_S2> kSharedCal = // static const std::shared_ptr<Cal3_S2> kSharedCal = //
boost::make_shared<Cal3_S2>(1500, 1200, 0.1, 640, 480); std::make_shared<Cal3_S2>(1500, 1200, 0.1, 640, 480);
// Looking along X-axis, 1 meter above ground plane (x-y) // Looking along X-axis, 1 meter above ground plane (x-y)
static const Rot3 upright = Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2); static const Rot3 upright = Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2);
@ -159,8 +159,8 @@ TEST(triangulation, twoCamerasLOSTvsDLT) {
//****************************************************************************** //******************************************************************************
// Simple test with a well-behaved two camera situation with Cal3DS2 calibration. // Simple test with a well-behaved two camera situation with Cal3DS2 calibration.
TEST(triangulation, twoPosesCal3DS2) { TEST(triangulation, twoPosesCal3DS2) {
static const boost::shared_ptr<Cal3DS2> sharedDistortedCal = // static const std::shared_ptr<Cal3DS2> sharedDistortedCal = //
boost::make_shared<Cal3DS2>(1500, 1200, 0, 640, 480, -.3, 0.1, 0.0001, std::make_shared<Cal3DS2>(1500, 1200, 0, 640, 480, -.3, 0.1, 0.0001,
-0.0003); -0.0003);
PinholeCamera<Cal3DS2> camera1Distorted(kPose1, *sharedDistortedCal); PinholeCamera<Cal3DS2> camera1Distorted(kPose1, *sharedDistortedCal);
@ -212,8 +212,8 @@ TEST(triangulation, twoPosesCal3DS2) {
// calibration. // calibration.
TEST(triangulation, twoPosesFisheye) { TEST(triangulation, twoPosesFisheye) {
using Calibration = Cal3Fisheye; using Calibration = Cal3Fisheye;
static const boost::shared_ptr<Calibration> sharedDistortedCal = // static const std::shared_ptr<Calibration> sharedDistortedCal = //
boost::make_shared<Calibration>(1500, 1200, .1, 640, 480, -.3, 0.1, std::make_shared<Calibration>(1500, 1200, .1, 640, 480, -.3, 0.1,
0.0001, -0.0003); 0.0001, -0.0003);
PinholeCamera<Calibration> camera1Distorted(kPose1, *sharedDistortedCal); PinholeCamera<Calibration> camera1Distorted(kPose1, *sharedDistortedCal);
@ -263,8 +263,8 @@ TEST(triangulation, twoPosesFisheye) {
//****************************************************************************** //******************************************************************************
// Similar, but now with Bundler calibration // Similar, but now with Bundler calibration
TEST(triangulation, twoPosesBundler) { TEST(triangulation, twoPosesBundler) {
boost::shared_ptr<Cal3Bundler> bundlerCal = // std::shared_ptr<Cal3Bundler> bundlerCal = //
boost::make_shared<Cal3Bundler>(1500, 0.1, 0.2, 640, 480); std::make_shared<Cal3Bundler>(1500, 0.1, 0.2, 640, 480);
PinholeCamera<Cal3Bundler> camera1(kPose1, *bundlerCal); PinholeCamera<Cal3Bundler> camera1(kPose1, *bundlerCal);
PinholeCamera<Cal3Bundler> camera2(kPose2, *bundlerCal); PinholeCamera<Cal3Bundler> camera2(kPose2, *bundlerCal);
@ -597,7 +597,7 @@ TEST(triangulation, onePose) {
//****************************************************************************** //******************************************************************************
TEST(triangulation, StereoTriangulateNonlinear) { TEST(triangulation, StereoTriangulateNonlinear) {
auto stereoK = boost::make_shared<Cal3_S2Stereo>(1733.75, 1733.75, 0, 689.645, auto stereoK = std::make_shared<Cal3_S2Stereo>(1733.75, 1733.75, 0, 689.645,
508.835, 0.0699612); 508.835, 0.0699612);
// two camera kPoses m1, m2 // two camera kPoses m1, m2

View File

@ -123,7 +123,7 @@ GTSAM_EXPORT Point3 triangulateLOST(const std::vector<Pose3>& poses,
*/ */
template<class CALIBRATION> template<class CALIBRATION>
std::pair<NonlinearFactorGraph, Values> triangulationGraph( std::pair<NonlinearFactorGraph, Values> triangulationGraph(
const std::vector<Pose3>& poses, boost::shared_ptr<CALIBRATION> sharedCal, const std::vector<Pose3>& poses, std::shared_ptr<CALIBRATION> sharedCal,
const Point2Vector& measurements, Key landmarkKey, const Point2Vector& measurements, Key landmarkKey,
const Point3& initialEstimate, const Point3& initialEstimate,
const SharedNoiseModel& model = noiseModel::Unit::Create(2)) { const SharedNoiseModel& model = noiseModel::Unit::Create(2)) {
@ -188,7 +188,7 @@ GTSAM_EXPORT Point3 optimize(const NonlinearFactorGraph& graph,
*/ */
template<class CALIBRATION> template<class CALIBRATION>
Point3 triangulateNonlinear(const std::vector<Pose3>& poses, Point3 triangulateNonlinear(const std::vector<Pose3>& poses,
boost::shared_ptr<CALIBRATION> sharedCal, std::shared_ptr<CALIBRATION> sharedCal,
const Point2Vector& measurements, const Point3& initialEstimate, const Point2Vector& measurements, const Point3& initialEstimate,
const SharedNoiseModel& model = nullptr) { const SharedNoiseModel& model = nullptr) {
@ -236,7 +236,7 @@ projectionMatricesFromCameras(const CameraSet<CAMERA> &cameras) {
// overload, assuming pinholePose // overload, assuming pinholePose
template<class CALIBRATION> template<class CALIBRATION>
std::vector<Matrix34, Eigen::aligned_allocator<Matrix34>> projectionMatricesFromPoses( std::vector<Matrix34, Eigen::aligned_allocator<Matrix34>> projectionMatricesFromPoses(
const std::vector<Pose3> &poses, boost::shared_ptr<CALIBRATION> sharedCal) { const std::vector<Pose3> &poses, std::shared_ptr<CALIBRATION> sharedCal) {
std::vector<Matrix34, Eigen::aligned_allocator<Matrix34>> projection_matrices; std::vector<Matrix34, Eigen::aligned_allocator<Matrix34>> projection_matrices;
for (size_t i = 0; i < poses.size(); i++) { for (size_t i = 0; i < poses.size(); i++) {
PinholePose<CALIBRATION> camera(poses.at(i), sharedCal); PinholePose<CALIBRATION> camera(poses.at(i), sharedCal);
@ -422,7 +422,7 @@ inline Point3Vector calibrateMeasurements(
*/ */
template <class CALIBRATION> template <class CALIBRATION>
Point3 triangulatePoint3(const std::vector<Pose3>& poses, Point3 triangulatePoint3(const std::vector<Pose3>& poses,
boost::shared_ptr<CALIBRATION> sharedCal, std::shared_ptr<CALIBRATION> sharedCal,
const Point2Vector& measurements, const Point2Vector& measurements,
double rank_tol = 1e-9, bool optimize = false, double rank_tol = 1e-9, bool optimize = false,
const SharedNoiseModel& model = nullptr, const SharedNoiseModel& model = nullptr,

View File

@ -106,7 +106,7 @@ GaussianConditional::shared_ptr GaussianMixture::operator()(
const DiscreteValues &discreteValues) const { const DiscreteValues &discreteValues) const {
auto &ptr = conditionals_(discreteValues); auto &ptr = conditionals_(discreteValues);
if (!ptr) return nullptr; if (!ptr) return nullptr;
auto conditional = boost::dynamic_pointer_cast<GaussianConditional>(ptr); auto conditional = std::dynamic_pointer_cast<GaussianConditional>(ptr);
if (conditional) if (conditional)
return conditional; return conditional;
else else
@ -185,7 +185,7 @@ bool GaussianMixture::allFrontalsGiven(const VectorValues &given) const {
} }
/* ************************************************************************* */ /* ************************************************************************* */
boost::shared_ptr<GaussianMixtureFactor> GaussianMixture::likelihood( std::shared_ptr<GaussianMixtureFactor> GaussianMixture::likelihood(
const VectorValues &given) const { const VectorValues &given) const {
if (!allFrontalsGiven(given)) { if (!allFrontalsGiven(given)) {
throw std::runtime_error( throw std::runtime_error(
@ -208,12 +208,12 @@ boost::shared_ptr<GaussianMixtureFactor> GaussianMixture::likelihood(
gfg.push_back(likelihood_m); gfg.push_back(likelihood_m);
Vector c(1); Vector c(1);
c << std::sqrt(2.0 * Cgm_Kgcm); c << std::sqrt(2.0 * Cgm_Kgcm);
auto constantFactor = boost::make_shared<JacobianFactor>(c); auto constantFactor = std::make_shared<JacobianFactor>(c);
gfg.push_back(constantFactor); gfg.push_back(constantFactor);
return boost::make_shared<JacobianFactor>(gfg); return std::make_shared<JacobianFactor>(gfg);
} }
}); });
return boost::make_shared<GaussianMixtureFactor>( return std::make_shared<GaussianMixtureFactor>(
continuousParentKeys, discreteParentKeys, likelihoods); continuousParentKeys, discreteParentKeys, likelihoods);
} }
@ -252,7 +252,7 @@ GaussianMixture::prunerFunc(const DecisionTreeFactor &decisionTree) {
if (gaussianMixtureKeySet == decisionTreeKeySet) { if (gaussianMixtureKeySet == decisionTreeKeySet) {
if (decisionTree(values) == 0.0) { if (decisionTree(values) == 0.0) {
// empty aka null pointer // empty aka null pointer
boost::shared_ptr<GaussianConditional> null; std::shared_ptr<GaussianConditional> null;
return null; return null;
} else { } else {
return conditional; return conditional;

View File

@ -55,7 +55,7 @@ class GTSAM_EXPORT GaussianMixture
public Conditional<HybridFactor, GaussianMixture> { public Conditional<HybridFactor, GaussianMixture> {
public: public:
using This = GaussianMixture; using This = GaussianMixture;
using shared_ptr = boost::shared_ptr<GaussianMixture>; using shared_ptr = std::shared_ptr<GaussianMixture>;
using BaseFactor = HybridFactor; using BaseFactor = HybridFactor;
using BaseConditional = Conditional<HybridFactor, GaussianMixture>; using BaseConditional = Conditional<HybridFactor, GaussianMixture>;
@ -164,7 +164,7 @@ class GTSAM_EXPORT GaussianMixture
* Create a likelihood factor for a Gaussian mixture, return a Mixture factor * Create a likelihood factor for a Gaussian mixture, return a Mixture factor
* on the parents. * on the parents.
*/ */
boost::shared_ptr<GaussianMixtureFactor> likelihood( std::shared_ptr<GaussianMixtureFactor> likelihood(
const VectorValues &given) const; const VectorValues &given) const;
/// Getter for the underlying Conditionals DecisionTree /// Getter for the underlying Conditionals DecisionTree

View File

@ -48,9 +48,9 @@ class GTSAM_EXPORT GaussianMixtureFactor : public HybridFactor {
public: public:
using Base = HybridFactor; using Base = HybridFactor;
using This = GaussianMixtureFactor; using This = GaussianMixtureFactor;
using shared_ptr = boost::shared_ptr<This>; using shared_ptr = std::shared_ptr<This>;
using sharedFactor = boost::shared_ptr<GaussianFactor>; using sharedFactor = std::shared_ptr<GaussianFactor>;
/// typedef for Decision Tree of Gaussian factors and log-constant. /// typedef for Decision Tree of Gaussian factors and log-constant.
using Factors = DecisionTree<Key, sharedFactor>; using Factors = DecisionTree<Key, sharedFactor>;

View File

@ -52,7 +52,7 @@ DecisionTreeFactor::shared_ptr HybridBayesNet::discreteConditionals() const {
dtFactor = dtFactor * f; dtFactor = dtFactor * f;
} }
} }
return boost::make_shared<DecisionTreeFactor>(dtFactor); return std::make_shared<DecisionTreeFactor>(dtFactor);
} }
/* ************************************************************************* */ /* ************************************************************************* */
@ -155,16 +155,16 @@ void HybridBayesNet::updateDiscreteConditionals(
// Apply prunerFunc to the underlying AlgebraicDecisionTree // Apply prunerFunc to the underlying AlgebraicDecisionTree
auto discreteTree = auto discreteTree =
boost::dynamic_pointer_cast<DecisionTreeFactor::ADT>(discrete); std::dynamic_pointer_cast<DecisionTreeFactor::ADT>(discrete);
DecisionTreeFactor::ADT prunedDiscreteTree = DecisionTreeFactor::ADT prunedDiscreteTree =
discreteTree->apply(prunerFunc(prunedDecisionTree, *conditional)); discreteTree->apply(prunerFunc(prunedDecisionTree, *conditional));
// Create the new (hybrid) conditional // Create the new (hybrid) conditional
KeyVector frontals(discrete->frontals().begin(), KeyVector frontals(discrete->frontals().begin(),
discrete->frontals().end()); discrete->frontals().end());
auto prunedDiscrete = boost::make_shared<DiscreteLookupTable>( auto prunedDiscrete = std::make_shared<DiscreteLookupTable>(
frontals.size(), conditional->discreteKeys(), prunedDiscreteTree); frontals.size(), conditional->discreteKeys(), prunedDiscreteTree);
conditional = boost::make_shared<HybridConditional>(prunedDiscrete); conditional = std::make_shared<HybridConditional>(prunedDiscrete);
// Add it back to the BayesNet // Add it back to the BayesNet
this->at(i) = conditional; this->at(i) = conditional;
@ -194,7 +194,7 @@ HybridBayesNet HybridBayesNet::prune(size_t maxNrLeaves) {
for (auto &&conditional : *this) { for (auto &&conditional : *this) {
if (auto gm = conditional->asMixture()) { if (auto gm = conditional->asMixture()) {
// Make a copy of the Gaussian mixture and prune it! // Make a copy of the Gaussian mixture and prune it!
auto prunedGaussianMixture = boost::make_shared<GaussianMixture>(*gm); auto prunedGaussianMixture = std::make_shared<GaussianMixture>(*gm);
prunedGaussianMixture->prune(decisionTree); // imperative :-( prunedGaussianMixture->prune(decisionTree); // imperative :-(
// Type-erase and add to the pruned Bayes Net fragment. // Type-erase and add to the pruned Bayes Net fragment.

View File

@ -37,8 +37,8 @@ class GTSAM_EXPORT HybridBayesNet : public BayesNet<HybridConditional> {
using Base = BayesNet<HybridConditional>; using Base = BayesNet<HybridConditional>;
using This = HybridBayesNet; using This = HybridBayesNet;
using ConditionalType = HybridConditional; using ConditionalType = HybridConditional;
using shared_ptr = boost::shared_ptr<HybridBayesNet>; using shared_ptr = std::shared_ptr<HybridBayesNet>;
using sharedConditional = boost::shared_ptr<ConditionalType>; using sharedConditional = std::shared_ptr<ConditionalType>;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{
@ -66,7 +66,7 @@ class GTSAM_EXPORT HybridBayesNet : public BayesNet<HybridConditional> {
* *
* This is the "native" push back, as this class stores hybrid conditionals. * This is the "native" push back, as this class stores hybrid conditionals.
*/ */
void push_back(boost::shared_ptr<HybridConditional> conditional) { void push_back(std::shared_ptr<HybridConditional> conditional) {
factors_.push_back(conditional); factors_.push_back(conditional);
} }
@ -80,8 +80,8 @@ class GTSAM_EXPORT HybridBayesNet : public BayesNet<HybridConditional> {
*/ */
template <class Conditional> template <class Conditional>
void emplace_back(Conditional *conditional) { void emplace_back(Conditional *conditional) {
factors_.push_back(boost::make_shared<HybridConditional>( factors_.push_back(std::make_shared<HybridConditional>(
boost::shared_ptr<Conditional>(conditional))); std::shared_ptr<Conditional>(conditional)));
} }
/** /**
@ -93,12 +93,12 @@ class GTSAM_EXPORT HybridBayesNet : public BayesNet<HybridConditional> {
* *
* Example: * Example:
* auto shared_ptr_to_a_conditional = * auto shared_ptr_to_a_conditional =
* boost::make_shared<GaussianMixture>(...); * std::make_shared<GaussianMixture>(...);
* hbn.push_back(shared_ptr_to_a_conditional); * hbn.push_back(shared_ptr_to_a_conditional);
*/ */
void push_back(HybridConditional &&conditional) { void push_back(HybridConditional &&conditional) {
factors_.push_back( factors_.push_back(
boost::make_shared<HybridConditional>(std::move(conditional))); std::make_shared<HybridConditional>(std::move(conditional)));
} }
/** /**

View File

@ -114,13 +114,13 @@ struct HybridAssignmentData {
conditional = hybrid_conditional->asGaussian(); conditional = hybrid_conditional->asGaussian();
} else { } else {
// Discrete only conditional, so we set to empty gaussian conditional // Discrete only conditional, so we set to empty gaussian conditional
conditional = boost::make_shared<GaussianConditional>(); conditional = std::make_shared<GaussianConditional>();
} }
GaussianBayesTree::sharedNode clique; GaussianBayesTree::sharedNode clique;
if (conditional) { if (conditional) {
// Create the GaussianClique for the current node // Create the GaussianClique for the current node
clique = boost::make_shared<GaussianBayesTree::Node>(conditional); clique = std::make_shared<GaussianBayesTree::Node>(conditional);
// Add the current clique to the GaussianBayesTree. // Add the current clique to the GaussianBayesTree.
parentData.gaussianbayesTree_->addClique(clique, parentData.gaussianbayesTree_->addClique(clique,
parentData.parentClique_); parentData.parentClique_);

View File

@ -48,10 +48,10 @@ class GTSAM_EXPORT HybridBayesTreeClique
typedef HybridBayesTreeClique This; typedef HybridBayesTreeClique This;
typedef BayesTreeCliqueBase<HybridBayesTreeClique, HybridGaussianFactorGraph> typedef BayesTreeCliqueBase<HybridBayesTreeClique, HybridGaussianFactorGraph>
Base; Base;
typedef boost::shared_ptr<This> shared_ptr; typedef std::shared_ptr<This> shared_ptr;
typedef boost::weak_ptr<This> weak_ptr; typedef std::weak_ptr<This> weak_ptr;
HybridBayesTreeClique() {} HybridBayesTreeClique() {}
HybridBayesTreeClique(const boost::shared_ptr<HybridConditional>& conditional) HybridBayesTreeClique(const std::shared_ptr<HybridConditional>& conditional)
: Base(conditional) {} : Base(conditional) {}
///< Copy constructor ///< Copy constructor
HybridBayesTreeClique(const HybridBayesTreeClique& clique) : Base(clique) {} HybridBayesTreeClique(const HybridBayesTreeClique& clique) : Base(clique) {}
@ -67,7 +67,7 @@ class GTSAM_EXPORT HybridBayesTree : public BayesTree<HybridBayesTreeClique> {
public: public:
typedef HybridBayesTree This; typedef HybridBayesTree This;
typedef boost::shared_ptr<This> shared_ptr; typedef std::shared_ptr<This> shared_ptr;
/// @name Standard interface /// @name Standard interface
/// @{ /// @{
@ -142,14 +142,14 @@ class BayesTreeOrphanWrapper<HybridBayesTreeClique> : public HybridConditional {
typedef HybridBayesTreeClique CliqueType; typedef HybridBayesTreeClique CliqueType;
typedef HybridConditional Base; typedef HybridConditional Base;
boost::shared_ptr<CliqueType> clique; std::shared_ptr<CliqueType> clique;
/** /**
* @brief Construct a new Bayes Tree Orphan Wrapper object. * @brief Construct a new Bayes Tree Orphan Wrapper object.
* *
* @param clique Bayes tree clique. * @param clique Bayes tree clique.
*/ */
BayesTreeOrphanWrapper(const boost::shared_ptr<CliqueType>& clique) BayesTreeOrphanWrapper(const std::shared_ptr<CliqueType>& clique)
: clique(clique) { : clique(clique) {
// Store parent keys in our base type factor so that eliminating those // Store parent keys in our base type factor so that eliminating those
// parent keys will pull this subtree into the elimination. // parent keys will pull this subtree into the elimination.

View File

@ -39,7 +39,7 @@ HybridConditional::HybridConditional(const KeyVector &continuousFrontals,
/* ************************************************************************ */ /* ************************************************************************ */
HybridConditional::HybridConditional( HybridConditional::HybridConditional(
const boost::shared_ptr<GaussianConditional> &continuousConditional) const std::shared_ptr<GaussianConditional> &continuousConditional)
: HybridConditional(continuousConditional->keys(), {}, : HybridConditional(continuousConditional->keys(), {},
continuousConditional->nrFrontals()) { continuousConditional->nrFrontals()) {
inner_ = continuousConditional; inner_ = continuousConditional;
@ -47,7 +47,7 @@ HybridConditional::HybridConditional(
/* ************************************************************************ */ /* ************************************************************************ */
HybridConditional::HybridConditional( HybridConditional::HybridConditional(
const boost::shared_ptr<DiscreteConditional> &discreteConditional) const std::shared_ptr<DiscreteConditional> &discreteConditional)
: HybridConditional({}, discreteConditional->discreteKeys(), : HybridConditional({}, discreteConditional->discreteKeys(),
discreteConditional->nrFrontals()) { discreteConditional->nrFrontals()) {
inner_ = discreteConditional; inner_ = discreteConditional;
@ -55,7 +55,7 @@ HybridConditional::HybridConditional(
/* ************************************************************************ */ /* ************************************************************************ */
HybridConditional::HybridConditional( HybridConditional::HybridConditional(
const boost::shared_ptr<GaussianMixture> &gaussianMixture) const std::shared_ptr<GaussianMixture> &gaussianMixture)
: BaseFactor(KeyVector(gaussianMixture->keys().begin(), : BaseFactor(KeyVector(gaussianMixture->keys().begin(),
gaussianMixture->keys().begin() + gaussianMixture->keys().begin() +
gaussianMixture->nrContinuous()), gaussianMixture->nrContinuous()),

View File

@ -25,8 +25,7 @@
#include <gtsam/inference/Key.h> #include <gtsam/inference/Key.h>
#include <gtsam/linear/GaussianConditional.h> #include <gtsam/linear/GaussianConditional.h>
#include <boost/make_shared.hpp> #include <memory>
#include <boost/shared_ptr.hpp>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <typeinfo> #include <typeinfo>
@ -63,14 +62,14 @@ class GTSAM_EXPORT HybridConditional
public: public:
// typedefs needed to play nice with gtsam // typedefs needed to play nice with gtsam
typedef HybridConditional This; ///< Typedef to this class typedef HybridConditional This; ///< Typedef to this class
typedef boost::shared_ptr<This> shared_ptr; ///< shared_ptr to this class typedef std::shared_ptr<This> shared_ptr; ///< shared_ptr to this class
typedef HybridFactor BaseFactor; ///< Typedef to our factor base class typedef HybridFactor BaseFactor; ///< Typedef to our factor base class
typedef Conditional<BaseFactor, This> typedef Conditional<BaseFactor, This>
BaseConditional; ///< Typedef to our conditional base class BaseConditional; ///< Typedef to our conditional base class
protected: protected:
/// Type-erased pointer to the inner type /// Type-erased pointer to the inner type
boost::shared_ptr<Factor> inner_; std::shared_ptr<Factor> inner_;
public: public:
/// @name Standard Constructors /// @name Standard Constructors
@ -111,7 +110,7 @@ class GTSAM_EXPORT HybridConditional
* HybridConditional. * HybridConditional.
*/ */
HybridConditional( HybridConditional(
const boost::shared_ptr<GaussianConditional>& continuousConditional); const std::shared_ptr<GaussianConditional>& continuousConditional);
/** /**
* @brief Construct a new Hybrid Conditional object * @brief Construct a new Hybrid Conditional object
@ -120,7 +119,7 @@ class GTSAM_EXPORT HybridConditional
* HybridConditional. * HybridConditional.
*/ */
HybridConditional( HybridConditional(
const boost::shared_ptr<DiscreteConditional>& discreteConditional); const std::shared_ptr<DiscreteConditional>& discreteConditional);
/** /**
* @brief Construct a new Hybrid Conditional object * @brief Construct a new Hybrid Conditional object
@ -128,7 +127,7 @@ class GTSAM_EXPORT HybridConditional
* @param gaussianMixture Gaussian Mixture Conditional used to create the * @param gaussianMixture Gaussian Mixture Conditional used to create the
* HybridConditional. * HybridConditional.
*/ */
HybridConditional(const boost::shared_ptr<GaussianMixture>& gaussianMixture); HybridConditional(const std::shared_ptr<GaussianMixture>& gaussianMixture);
/// @} /// @}
/// @name Testable /// @name Testable
@ -152,7 +151,7 @@ class GTSAM_EXPORT HybridConditional
* @return GaussianMixture::shared_ptr otherwise * @return GaussianMixture::shared_ptr otherwise
*/ */
GaussianMixture::shared_ptr asMixture() const { GaussianMixture::shared_ptr asMixture() const {
return boost::dynamic_pointer_cast<GaussianMixture>(inner_); return std::dynamic_pointer_cast<GaussianMixture>(inner_);
} }
/** /**
@ -161,7 +160,7 @@ class GTSAM_EXPORT HybridConditional
* @return GaussianConditional::shared_ptr otherwise * @return GaussianConditional::shared_ptr otherwise
*/ */
GaussianConditional::shared_ptr asGaussian() const { GaussianConditional::shared_ptr asGaussian() const {
return boost::dynamic_pointer_cast<GaussianConditional>(inner_); return std::dynamic_pointer_cast<GaussianConditional>(inner_);
} }
/** /**
@ -170,11 +169,11 @@ class GTSAM_EXPORT HybridConditional
* @return DiscreteConditional::shared_ptr * @return DiscreteConditional::shared_ptr
*/ */
DiscreteConditional::shared_ptr asDiscrete() const { DiscreteConditional::shared_ptr asDiscrete() const {
return boost::dynamic_pointer_cast<DiscreteConditional>(inner_); return std::dynamic_pointer_cast<DiscreteConditional>(inner_);
} }
/// Get the type-erased pointer to the inner type /// Get the type-erased pointer to the inner type
boost::shared_ptr<Factor> inner() const { return inner_; } std::shared_ptr<Factor> inner() const { return inner_; }
/// Return the error of the underlying conditional. /// Return the error of the underlying conditional.
double error(const HybridValues& values) const override; double error(const HybridValues& values) const override;

View File

@ -37,7 +37,7 @@ class GTSAM_EXPORT HybridEliminationTree
typedef EliminationTree<HybridBayesNet, HybridGaussianFactorGraph> typedef EliminationTree<HybridBayesNet, HybridGaussianFactorGraph>
Base; ///< Base class Base; ///< Base class
typedef HybridEliminationTree This; ///< This class typedef HybridEliminationTree This; ///< This class
typedef boost::shared_ptr<This> shared_ptr; ///< Shared pointer to this class typedef std::shared_ptr<This> shared_ptr; ///< Shared pointer to this class
/// @name Constructors /// @name Constructors
/// @{ /// @{

View File

@ -64,7 +64,7 @@ class GTSAM_EXPORT HybridFactor : public Factor {
public: public:
// typedefs needed to play nice with gtsam // typedefs needed to play nice with gtsam
typedef HybridFactor This; ///< This class typedef HybridFactor This; ///< This class
typedef boost::shared_ptr<HybridFactor> typedef std::shared_ptr<HybridFactor>
shared_ptr; ///< shared_ptr to this class shared_ptr; ///< shared_ptr to this class
typedef Factor Base; ///< Our base class typedef Factor Base; ///< Our base class

View File

@ -28,12 +28,12 @@ namespace gtsam {
std::set<DiscreteKey> HybridFactorGraph::discreteKeys() const { std::set<DiscreteKey> HybridFactorGraph::discreteKeys() const {
std::set<DiscreteKey> keys; std::set<DiscreteKey> keys;
for (auto& factor : factors_) { for (auto& factor : factors_) {
if (auto p = boost::dynamic_pointer_cast<DecisionTreeFactor>(factor)) { if (auto p = std::dynamic_pointer_cast<DecisionTreeFactor>(factor)) {
for (const DiscreteKey& key : p->discreteKeys()) { for (const DiscreteKey& key : p->discreteKeys()) {
keys.insert(key); keys.insert(key);
} }
} }
if (auto p = boost::dynamic_pointer_cast<HybridFactor>(factor)) { if (auto p = std::dynamic_pointer_cast<HybridFactor>(factor)) {
for (const DiscreteKey& key : p->discreteKeys()) { for (const DiscreteKey& key : p->discreteKeys()) {
keys.insert(key); keys.insert(key);
} }
@ -65,7 +65,7 @@ std::unordered_map<Key, DiscreteKey> HybridFactorGraph::discreteKeyMap() const {
const KeySet HybridFactorGraph::continuousKeySet() const { const KeySet HybridFactorGraph::continuousKeySet() const {
KeySet keys; KeySet keys;
for (auto& factor : factors_) { for (auto& factor : factors_) {
if (auto p = boost::dynamic_pointer_cast<HybridFactor>(factor)) { if (auto p = std::dynamic_pointer_cast<HybridFactor>(factor)) {
for (const Key& key : p->continuousKeys()) { for (const Key& key : p->continuousKeys()) {
keys.insert(key); keys.insert(key);
} }

View File

@ -30,7 +30,7 @@ namespace gtsam {
class DiscreteFactor; class DiscreteFactor;
class Ordering; class Ordering;
using SharedFactor = boost::shared_ptr<Factor>; using SharedFactor = std::shared_ptr<Factor>;
/** /**
* Hybrid Factor Graph * Hybrid Factor Graph
@ -40,7 +40,7 @@ class HybridFactorGraph : public FactorGraph<Factor> {
public: public:
using Base = FactorGraph<Factor>; using Base = FactorGraph<Factor>;
using This = HybridFactorGraph; ///< this class using This = HybridFactorGraph; ///< this class
using shared_ptr = boost::shared_ptr<This>; ///< shared_ptr to This using shared_ptr = std::shared_ptr<This>; ///< shared_ptr to This
using Values = gtsam::Values; ///< backwards compatibility using Values = gtsam::Values; ///< backwards compatibility
using Indices = KeyVector; ///> map from keys to values using Indices = KeyVector; ///> map from keys to values

View File

@ -57,12 +57,12 @@ template class EliminateableFactorGraph<HybridGaussianFactorGraph>;
using OrphanWrapper = BayesTreeOrphanWrapper<HybridBayesTree::Clique>; using OrphanWrapper = BayesTreeOrphanWrapper<HybridBayesTree::Clique>;
using boost::dynamic_pointer_cast; using std::dynamic_pointer_cast;
/* ************************************************************************ */ /* ************************************************************************ */
// Throw a runtime exception for method specified in string s, and factor f: // Throw a runtime exception for method specified in string s, and factor f:
static void throwRuntimeError(const std::string &s, static void throwRuntimeError(const std::string &s,
const boost::shared_ptr<Factor> &f) { const std::shared_ptr<Factor> &f) {
auto &fr = *f; auto &fr = *f;
throw std::runtime_error(s + " not implemented for factor type " + throw std::runtime_error(s + " not implemented for factor type " +
demangle(typeid(fr).name()) + "."); demangle(typeid(fr).name()) + ".");
@ -135,7 +135,7 @@ GaussianFactorGraphTree HybridGaussianFactorGraph::assembleGraphTree() const {
} }
/* ************************************************************************ */ /* ************************************************************************ */
static std::pair<HybridConditional::shared_ptr, boost::shared_ptr<Factor>> static std::pair<HybridConditional::shared_ptr, std::shared_ptr<Factor>>
continuousElimination(const HybridGaussianFactorGraph &factors, continuousElimination(const HybridGaussianFactorGraph &factors,
const Ordering &frontalKeys) { const Ordering &frontalKeys) {
GaussianFactorGraph gfg; GaussianFactorGraph gfg;
@ -155,11 +155,11 @@ continuousElimination(const HybridGaussianFactorGraph &factors,
} }
auto result = EliminatePreferCholesky(gfg, frontalKeys); auto result = EliminatePreferCholesky(gfg, frontalKeys);
return {boost::make_shared<HybridConditional>(result.first), result.second}; return {std::make_shared<HybridConditional>(result.first), result.second};
} }
/* ************************************************************************ */ /* ************************************************************************ */
static std::pair<HybridConditional::shared_ptr, boost::shared_ptr<Factor>> static std::pair<HybridConditional::shared_ptr, std::shared_ptr<Factor>>
discreteElimination(const HybridGaussianFactorGraph &factors, discreteElimination(const HybridGaussianFactorGraph &factors,
const Ordering &frontalKeys) { const Ordering &frontalKeys) {
DiscreteFactorGraph dfg; DiscreteFactorGraph dfg;
@ -182,7 +182,7 @@ discreteElimination(const HybridGaussianFactorGraph &factors,
// NOTE: This does sum-product. For max-product, use EliminateForMPE. // NOTE: This does sum-product. For max-product, use EliminateForMPE.
auto result = EliminateDiscrete(dfg, frontalKeys); auto result = EliminateDiscrete(dfg, frontalKeys);
return {boost::make_shared<HybridConditional>(result.first), result.second}; return {std::make_shared<HybridConditional>(result.first), result.second};
} }
/* ************************************************************************ */ /* ************************************************************************ */
@ -201,7 +201,7 @@ GaussianFactorGraphTree removeEmpty(const GaussianFactorGraphTree &sum) {
} }
/* ************************************************************************ */ /* ************************************************************************ */
static std::pair<HybridConditional::shared_ptr, boost::shared_ptr<Factor>> static std::pair<HybridConditional::shared_ptr, std::shared_ptr<Factor>>
hybridElimination(const HybridGaussianFactorGraph &factors, hybridElimination(const HybridGaussianFactorGraph &factors,
const Ordering &frontalKeys, const Ordering &frontalKeys,
const KeyVector &continuousSeparator, const KeyVector &continuousSeparator,
@ -220,7 +220,7 @@ hybridElimination(const HybridGaussianFactorGraph &factors,
// FG has a nullptr as we're looping over the factors. // FG has a nullptr as we're looping over the factors.
factorGraphTree = removeEmpty(factorGraphTree); factorGraphTree = removeEmpty(factorGraphTree);
using Result = std::pair<boost::shared_ptr<GaussianConditional>, using Result = std::pair<std::shared_ptr<GaussianConditional>,
GaussianMixtureFactor::sharedFactor>; GaussianMixtureFactor::sharedFactor>;
// This is the elimination method on the leaf nodes // This is the elimination method on the leaf nodes
@ -256,7 +256,7 @@ hybridElimination(const HybridGaussianFactorGraph &factors,
std::tie(conditionals, newFactors) = unzip(eliminationResults); std::tie(conditionals, newFactors) = unzip(eliminationResults);
// Create the GaussianMixture from the conditionals // Create the GaussianMixture from the conditionals
auto gaussianMixture = boost::make_shared<GaussianMixture>( auto gaussianMixture = std::make_shared<GaussianMixture>(
frontalKeys, continuousSeparator, discreteSeparator, conditionals); frontalKeys, continuousSeparator, discreteSeparator, conditionals);
if (continuousSeparator.empty()) { if (continuousSeparator.empty()) {
@ -275,8 +275,8 @@ hybridElimination(const HybridGaussianFactorGraph &factors,
}; };
DecisionTree<Key, double> probabilities(eliminationResults, probability); DecisionTree<Key, double> probabilities(eliminationResults, probability);
return {boost::make_shared<HybridConditional>(gaussianMixture), return {std::make_shared<HybridConditional>(gaussianMixture),
boost::make_shared<DecisionTreeFactor>(discreteSeparator, std::make_shared<DecisionTreeFactor>(discreteSeparator,
probabilities)}; probabilities)};
} else { } else {
// Otherwise, we create a resulting GaussianMixtureFactor on the separator, // Otherwise, we create a resulting GaussianMixtureFactor on the separator,
@ -286,7 +286,7 @@ hybridElimination(const HybridGaussianFactorGraph &factors,
auto correct = [&](const Result &pair) -> GaussianFactor::shared_ptr { auto correct = [&](const Result &pair) -> GaussianFactor::shared_ptr {
const auto &factor = pair.second; const auto &factor = pair.second;
if (!factor) return factor; // TODO(dellaert): not loving this. if (!factor) return factor; // TODO(dellaert): not loving this.
auto hf = boost::dynamic_pointer_cast<HessianFactor>(factor); auto hf = std::dynamic_pointer_cast<HessianFactor>(factor);
if (!hf) throw std::runtime_error("Expected HessianFactor!"); if (!hf) throw std::runtime_error("Expected HessianFactor!");
hf->constantTerm() += 2.0 * pair.first->logNormalizationConstant(); hf->constantTerm() += 2.0 * pair.first->logNormalizationConstant();
return hf; return hf;
@ -294,10 +294,10 @@ hybridElimination(const HybridGaussianFactorGraph &factors,
GaussianMixtureFactor::Factors correctedFactors(eliminationResults, GaussianMixtureFactor::Factors correctedFactors(eliminationResults,
correct); correct);
const auto mixtureFactor = boost::make_shared<GaussianMixtureFactor>( const auto mixtureFactor = std::make_shared<GaussianMixtureFactor>(
continuousSeparator, discreteSeparator, newFactors); continuousSeparator, discreteSeparator, newFactors);
return {boost::make_shared<HybridConditional>(gaussianMixture), return {std::make_shared<HybridConditional>(gaussianMixture),
mixtureFactor}; mixtureFactor};
} }
} }
@ -316,7 +316,7 @@ hybridElimination(const HybridGaussianFactorGraph &factors,
* eliminate a discrete variable (as specified in the ordering), the result will * eliminate a discrete variable (as specified in the ordering), the result will
* be INCORRECT and there will be NO error raised. * be INCORRECT and there will be NO error raised.
*/ */
std::pair<HybridConditional::shared_ptr, boost::shared_ptr<Factor>> // std::pair<HybridConditional::shared_ptr, std::shared_ptr<Factor>> //
EliminateHybrid(const HybridGaussianFactorGraph &factors, EliminateHybrid(const HybridGaussianFactorGraph &factors,
const Ordering &frontalKeys) { const Ordering &frontalKeys) {
// NOTE: Because we are in the Conditional Gaussian regime there are only // NOTE: Because we are in the Conditional Gaussian regime there are only

View File

@ -52,7 +52,7 @@ class HybridValues;
* @ingroup hybrid * @ingroup hybrid
*/ */
GTSAM_EXPORT GTSAM_EXPORT
std::pair<boost::shared_ptr<HybridConditional>, boost::shared_ptr<Factor>> std::pair<std::shared_ptr<HybridConditional>, std::shared_ptr<Factor>>
EliminateHybrid(const HybridGaussianFactorGraph& factors, const Ordering& keys); EliminateHybrid(const HybridGaussianFactorGraph& factors, const Ordering& keys);
/** /**
@ -80,8 +80,8 @@ struct EliminationTraits<HybridGaussianFactorGraph> {
typedef HybridBayesTree BayesTreeType; ///< Type of Bayes tree typedef HybridBayesTree BayesTreeType; ///< Type of Bayes tree
typedef HybridJunctionTree JunctionTreeType; ///< Type of Junction tree typedef HybridJunctionTree JunctionTreeType; ///< Type of Junction tree
/// The default dense elimination function /// The default dense elimination function
static std::pair<boost::shared_ptr<ConditionalType>, static std::pair<std::shared_ptr<ConditionalType>,
boost::shared_ptr<FactorType>> std::shared_ptr<FactorType>>
DefaultEliminate(const FactorGraphType& factors, const Ordering& keys) { DefaultEliminate(const FactorGraphType& factors, const Ordering& keys) {
return EliminateHybrid(factors, keys); return EliminateHybrid(factors, keys);
} }
@ -114,7 +114,7 @@ class GTSAM_EXPORT HybridGaussianFactorGraph
using This = HybridGaussianFactorGraph; ///< this class using This = HybridGaussianFactorGraph; ///< this class
using BaseEliminateable = using BaseEliminateable =
EliminateableFactorGraph<This>; ///< for elimination EliminateableFactorGraph<This>; ///< for elimination
using shared_ptr = boost::shared_ptr<This>; ///< shared_ptr to This using shared_ptr = std::shared_ptr<This>; ///< shared_ptr to This
using Values = gtsam::Values; ///< backwards compatibility using Values = gtsam::Values; ///< backwards compatibility
using Indices = KeyVector; ///< map from keys to values using Indices = KeyVector; ///< map from keys to values

View File

@ -89,7 +89,7 @@ void HybridGaussianISAM::updateInternal(
// Add the orphaned subtrees // Add the orphaned subtrees
for (const sharedClique& orphan : *orphans) { for (const sharedClique& orphan : *orphans) {
factors += boost::make_shared<BayesTreeOrphanWrapper<Node>>(orphan); factors += std::make_shared<BayesTreeOrphanWrapper<Node>>(orphan);
} }
const VariableIndex index(factors); const VariableIndex index(factors);

View File

@ -37,7 +37,7 @@ class GTSAM_EXPORT HybridGaussianISAM : public ISAM<HybridBayesTree> {
public: public:
typedef ISAM<HybridBayesTree> Base; typedef ISAM<HybridBayesTree> Base;
typedef HybridGaussianISAM This; typedef HybridGaussianISAM This;
typedef boost::shared_ptr<This> shared_ptr; typedef std::shared_ptr<This> shared_ptr;
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{

View File

@ -50,23 +50,23 @@ struct HybridConstructorTraversalData {
// Pre-order visitor function // Pre-order visitor function
static HybridConstructorTraversalData ConstructorTraversalVisitorPre( static HybridConstructorTraversalData ConstructorTraversalVisitorPre(
const boost::shared_ptr<HybridEliminationTree::Node>& node, const std::shared_ptr<HybridEliminationTree::Node>& node,
HybridConstructorTraversalData& parentData) { HybridConstructorTraversalData& parentData) {
// On the pre-order pass, before children have been visited, we just set up // On the pre-order pass, before children have been visited, we just set up
// a traversal data structure with its own JT node, and create a child // a traversal data structure with its own JT node, and create a child
// pointer in its parent. // pointer in its parent.
HybridConstructorTraversalData data = HybridConstructorTraversalData data =
HybridConstructorTraversalData(&parentData); HybridConstructorTraversalData(&parentData);
data.junctionTreeNode = boost::make_shared<Node>(node->key, node->factors); data.junctionTreeNode = std::make_shared<Node>(node->key, node->factors);
parentData.junctionTreeNode->addChild(data.junctionTreeNode); parentData.junctionTreeNode->addChild(data.junctionTreeNode);
// Add all the discrete keys in the hybrid factors to the current data // Add all the discrete keys in the hybrid factors to the current data
for (const auto& f : node->factors) { for (const auto& f : node->factors) {
if (auto hf = boost::dynamic_pointer_cast<HybridFactor>(f)) { if (auto hf = std::dynamic_pointer_cast<HybridFactor>(f)) {
for (auto& k : hf->discreteKeys()) { for (auto& k : hf->discreteKeys()) {
data.discreteKeys.insert(k.first); data.discreteKeys.insert(k.first);
} }
} else if (auto hf = boost::dynamic_pointer_cast<DecisionTreeFactor>(f)) { } else if (auto hf = std::dynamic_pointer_cast<DecisionTreeFactor>(f)) {
for (auto& k : hf->discreteKeys()) { for (auto& k : hf->discreteKeys()) {
data.discreteKeys.insert(k.first); data.discreteKeys.insert(k.first);
} }
@ -78,7 +78,7 @@ struct HybridConstructorTraversalData {
// Post-order visitor function // Post-order visitor function
static void ConstructorTraversalVisitorPost( static void ConstructorTraversalVisitorPost(
const boost::shared_ptr<HybridEliminationTree::Node>& node, const std::shared_ptr<HybridEliminationTree::Node>& node,
const HybridConstructorTraversalData& data) { const HybridConstructorTraversalData& data) {
// In this post-order visitor, we combine the symbolic elimination results // In this post-order visitor, we combine the symbolic elimination results
// from the elimination tree children and symbolically eliminate the current // from the elimination tree children and symbolically eliminate the current
@ -162,7 +162,7 @@ HybridJunctionTree::HybridJunctionTree(
typedef HybridConstructorTraversalData Data; typedef HybridConstructorTraversalData Data;
Data rootData(0); Data rootData(0);
rootData.junctionTreeNode = rootData.junctionTreeNode =
boost::make_shared<typename Base::Node>(); // Make a dummy node to gather std::make_shared<typename Base::Node>(); // Make a dummy node to gather
// the junction tree roots // the junction tree roots
treeTraversal::DepthFirstForest(eliminationTree, rootData, treeTraversal::DepthFirstForest(eliminationTree, rootData,
Data::ConstructorTraversalVisitorPre, Data::ConstructorTraversalVisitorPre,

View File

@ -56,7 +56,7 @@ class GTSAM_EXPORT HybridJunctionTree
typedef JunctionTree<HybridBayesTree, HybridGaussianFactorGraph> typedef JunctionTree<HybridBayesTree, HybridGaussianFactorGraph>
Base; ///< Base class Base; ///< Base class
typedef HybridJunctionTree This; ///< This class typedef HybridJunctionTree This; ///< This class
typedef boost::shared_ptr<This> shared_ptr; ///< Shared pointer to this class typedef std::shared_ptr<This> shared_ptr; ///< Shared pointer to this class
/** /**
* Build the elimination tree of a factor graph using precomputed column * Build the elimination tree of a factor graph using precomputed column

View File

@ -43,10 +43,10 @@ void HybridNonlinearFactorGraph::print(const std::string& s,
/* ************************************************************************* */ /* ************************************************************************* */
HybridGaussianFactorGraph::shared_ptr HybridNonlinearFactorGraph::linearize( HybridGaussianFactorGraph::shared_ptr HybridNonlinearFactorGraph::linearize(
const Values& continuousValues) const { const Values& continuousValues) const {
using boost::dynamic_pointer_cast; using std::dynamic_pointer_cast;
// create an empty linear FG // create an empty linear FG
auto linearFG = boost::make_shared<HybridGaussianFactorGraph>(); auto linearFG = std::make_shared<HybridGaussianFactorGraph>();
linearFG->reserve(size()); linearFG->reserve(size());

View File

@ -35,7 +35,7 @@ class GTSAM_EXPORT HybridNonlinearFactorGraph : public HybridFactorGraph {
public: public:
using Base = HybridFactorGraph; using Base = HybridFactorGraph;
using This = HybridNonlinearFactorGraph; ///< this class using This = HybridNonlinearFactorGraph; ///< this class
using shared_ptr = boost::shared_ptr<This>; ///< shared_ptr to This using shared_ptr = std::shared_ptr<This>; ///< shared_ptr to This
using Values = gtsam::Values; ///< backwards compatibility using Values = gtsam::Values; ///< backwards compatibility
using Indices = KeyVector; ///> map from keys to values using Indices = KeyVector; ///> map from keys to values
@ -74,7 +74,7 @@ class GTSAM_EXPORT HybridNonlinearFactorGraph : public HybridFactorGraph {
* @param continuousValues: Dictionary of continuous values. * @param continuousValues: Dictionary of continuous values.
* @return HybridGaussianFactorGraph::shared_ptr * @return HybridGaussianFactorGraph::shared_ptr
*/ */
boost::shared_ptr<HybridGaussianFactorGraph> linearize( std::shared_ptr<HybridGaussianFactorGraph> linearize(
const Values& continuousValues) const; const Values& continuousValues) const;
/// @} /// @}
}; };

View File

@ -50,7 +50,7 @@ void HybridNonlinearISAM::update(const HybridNonlinearFactorGraph& newFactors,
// TODO: optimize for whole config? // TODO: optimize for whole config?
linPoint_.insert(initialValues); linPoint_.insert(initialValues);
boost::shared_ptr<HybridGaussianFactorGraph> linearizedNewFactors = std::shared_ptr<HybridGaussianFactorGraph> linearizedNewFactors =
newFactors.linearize(linPoint_); newFactors.linearize(linPoint_);
// Update ISAM // Update ISAM

View File

@ -42,7 +42,7 @@ void HybridSmoother::update(HybridGaussianFactorGraph graph,
bayesNetFragment->prune(*maxNrLeaves); bayesNetFragment->prune(*maxNrLeaves);
// Set the bayes net fragment to the pruned version // Set the bayes net fragment to the pruned version
bayesNetFragment = bayesNetFragment =
boost::make_shared<HybridBayesNet>(prunedBayesNetFragment); std::make_shared<HybridBayesNet>(prunedBayesNetFragment);
} }
// Add the partial bayes net to the posterior bayes net. // Add the partial bayes net to the posterior bayes net.

View File

@ -49,8 +49,8 @@ class MixtureFactor : public HybridFactor {
public: public:
using Base = HybridFactor; using Base = HybridFactor;
using This = MixtureFactor; using This = MixtureFactor;
using shared_ptr = boost::shared_ptr<MixtureFactor>; using shared_ptr = std::shared_ptr<MixtureFactor>;
using sharedFactor = boost::shared_ptr<NonlinearFactor>; using sharedFactor = std::shared_ptr<NonlinearFactor>;
/** /**
* @brief typedef for DecisionTree which has Keys as node labels and * @brief typedef for DecisionTree which has Keys as node labels and
@ -97,7 +97,7 @@ class MixtureFactor : public HybridFactor {
*/ */
template <typename FACTOR> template <typename FACTOR>
MixtureFactor(const KeyVector& keys, const DiscreteKeys& discreteKeys, MixtureFactor(const KeyVector& keys, const DiscreteKeys& discreteKeys,
const std::vector<boost::shared_ptr<FACTOR>>& factors, const std::vector<std::shared_ptr<FACTOR>>& factors,
bool normalized = false) bool normalized = false)
: Base(keys, discreteKeys), normalized_(normalized) { : Base(keys, discreteKeys), normalized_(normalized) {
std::vector<NonlinearFactor::shared_ptr> nonlinear_factors; std::vector<NonlinearFactor::shared_ptr> nonlinear_factors;
@ -108,7 +108,7 @@ class MixtureFactor : public HybridFactor {
std::copy(f->keys().begin(), f->keys().end(), std::copy(f->keys().begin(), f->keys().end(),
std::inserter(factor_keys_set, factor_keys_set.end())); std::inserter(factor_keys_set, factor_keys_set.end()));
if (auto nf = boost::dynamic_pointer_cast<NonlinearFactor>(f)) { if (auto nf = std::dynamic_pointer_cast<NonlinearFactor>(f)) {
nonlinear_factors.push_back(nf); nonlinear_factors.push_back(nf);
} else { } else {
throw std::runtime_error( throw std::runtime_error(
@ -237,7 +237,7 @@ class MixtureFactor : public HybridFactor {
} }
/// Linearize all the continuous factors to get a GaussianMixtureFactor. /// Linearize all the continuous factors to get a GaussianMixtureFactor.
boost::shared_ptr<GaussianMixtureFactor> linearize( std::shared_ptr<GaussianMixtureFactor> linearize(
const Values& continuousValues) const { const Values& continuousValues) const {
// functional to linearize each factor in the decision tree // functional to linearize each factor in the decision tree
auto linearizeDT = [continuousValues](const sharedFactor& factor) { auto linearizeDT = [continuousValues](const sharedFactor& factor) {
@ -247,7 +247,7 @@ class MixtureFactor : public HybridFactor {
DecisionTree<Key, GaussianFactor::shared_ptr> linearized_factors( DecisionTree<Key, GaussianFactor::shared_ptr> linearized_factors(
factors_, linearizeDT); factors_, linearizeDT);
return boost::make_shared<GaussianMixtureFactor>( return std::make_shared<GaussianMixtureFactor>(
continuousKeys_, discreteKeys_, linearized_factors); continuousKeys_, discreteKeys_, linearized_factors);
} }
@ -266,13 +266,13 @@ class MixtureFactor : public HybridFactor {
// If this is a NoiseModelFactor, we'll use its noiseModel to // If this is a NoiseModelFactor, we'll use its noiseModel to
// otherwise noiseModelFactor will be nullptr // otherwise noiseModelFactor will be nullptr
if (auto noiseModelFactor = if (auto noiseModelFactor =
boost::dynamic_pointer_cast<NoiseModelFactor>(factor)) { std::dynamic_pointer_cast<NoiseModelFactor>(factor)) {
// If dynamic cast to NoiseModelFactor succeeded, see if the noise model // If dynamic cast to NoiseModelFactor succeeded, see if the noise model
// is Gaussian // is Gaussian
auto noiseModel = noiseModelFactor->noiseModel(); auto noiseModel = noiseModelFactor->noiseModel();
auto gaussianNoiseModel = auto gaussianNoiseModel =
boost::dynamic_pointer_cast<noiseModel::Gaussian>(noiseModel); std::dynamic_pointer_cast<noiseModel::Gaussian>(noiseModel);
if (gaussianNoiseModel) { if (gaussianNoiseModel) {
// If the noise model is Gaussian, retrieve the information matrix // If the noise model is Gaussian, retrieve the information matrix
infoMat = gaussianNoiseModel->information(); infoMat = gaussianNoiseModel->information();

View File

@ -59,9 +59,9 @@ inline HybridGaussianFactorGraph::shared_ptr makeSwitchingChain(
for (size_t t = 1; t < n; t++) { for (size_t t = 1; t < n; t++) {
hfg.add(GaussianMixtureFactor( hfg.add(GaussianMixtureFactor(
{keyFunc(t), keyFunc(t + 1)}, {{dKeyFunc(t), 2}}, {keyFunc(t), keyFunc(t + 1)}, {{dKeyFunc(t), 2}},
{boost::make_shared<JacobianFactor>(keyFunc(t), I_3x3, keyFunc(t + 1), {std::make_shared<JacobianFactor>(keyFunc(t), I_3x3, keyFunc(t + 1),
I_3x3, Z_3x1), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(keyFunc(t), I_3x3, keyFunc(t + 1), std::make_shared<JacobianFactor>(keyFunc(t), I_3x3, keyFunc(t + 1),
I_3x3, Vector3::Ones())})); I_3x3, Vector3::Ones())}));
if (t > 1) { if (t > 1) {
@ -70,7 +70,7 @@ inline HybridGaussianFactorGraph::shared_ptr makeSwitchingChain(
} }
} }
return boost::make_shared<HybridGaussianFactorGraph>(std::move(hfg)); return std::make_shared<HybridGaussianFactorGraph>(std::move(hfg));
} }
/** /**
@ -161,7 +161,7 @@ struct Switching {
auto motion_models = motionModels(k, between_sigma); auto motion_models = motionModels(k, between_sigma);
std::vector<NonlinearFactor::shared_ptr> components; std::vector<NonlinearFactor::shared_ptr> components;
for (auto &&f : motion_models) { for (auto &&f : motion_models) {
components.push_back(boost::dynamic_pointer_cast<NonlinearFactor>(f)); components.push_back(std::dynamic_pointer_cast<NonlinearFactor>(f));
} }
nonlinearFactorGraph.emplace_shared<MixtureFactor>( nonlinearFactorGraph.emplace_shared<MixtureFactor>(
keys, DiscreteKeys{modes[k]}, components); keys, DiscreteKeys{modes[k]}, components);
@ -192,9 +192,9 @@ struct Switching {
double sigma = 1.0) { double sigma = 1.0) {
auto noise_model = noiseModel::Isotropic::Sigma(1, sigma); auto noise_model = noiseModel::Isotropic::Sigma(1, sigma);
auto still = auto still =
boost::make_shared<MotionModel>(X(k), X(k + 1), 0.0, noise_model), std::make_shared<MotionModel>(X(k), X(k + 1), 0.0, noise_model),
moving = moving =
boost::make_shared<MotionModel>(X(k), X(k + 1), 1.0, noise_model); std::make_shared<MotionModel>(X(k), X(k + 1), 1.0, noise_model);
return {still, moving}; return {still, moving};
} }

View File

@ -185,7 +185,7 @@ TEST(GaussianMixture, Likelihood2) {
{ {
// We have a JacobianFactor // We have a JacobianFactor
const auto gf1 = (*likelihood)(assignment1); const auto gf1 = (*likelihood)(assignment1);
const auto jf1 = boost::dynamic_pointer_cast<JacobianFactor>(gf1); const auto jf1 = std::dynamic_pointer_cast<JacobianFactor>(gf1);
CHECK(jf1); CHECK(jf1);
// It has 2 rows, not 1! // It has 2 rows, not 1!

View File

@ -58,11 +58,11 @@ TEST(GaussianMixtureFactor, Sum) {
sigmas << 1, 2; sigmas << 1, 2;
auto model = noiseModel::Diagonal::Sigmas(sigmas, true); auto model = noiseModel::Diagonal::Sigmas(sigmas, true);
auto f10 = boost::make_shared<JacobianFactor>(X(1), A1, X(2), A2, b); auto f10 = std::make_shared<JacobianFactor>(X(1), A1, X(2), A2, b);
auto f11 = boost::make_shared<JacobianFactor>(X(1), A1, X(2), A2, b); auto f11 = std::make_shared<JacobianFactor>(X(1), A1, X(2), A2, b);
auto f20 = boost::make_shared<JacobianFactor>(X(1), A1, X(3), A3, b); auto f20 = std::make_shared<JacobianFactor>(X(1), A1, X(3), A3, b);
auto f21 = boost::make_shared<JacobianFactor>(X(1), A1, X(3), A3, b); auto f21 = std::make_shared<JacobianFactor>(X(1), A1, X(3), A3, b);
auto f22 = boost::make_shared<JacobianFactor>(X(1), A1, X(3), A3, b); auto f22 = std::make_shared<JacobianFactor>(X(1), A1, X(3), A3, b);
std::vector<GaussianFactor::shared_ptr> factorsA{f10, f11}; std::vector<GaussianFactor::shared_ptr> factorsA{f10, f11};
std::vector<GaussianFactor::shared_ptr> factorsB{f20, f21, f22}; std::vector<GaussianFactor::shared_ptr> factorsB{f20, f21, f22};
@ -98,8 +98,8 @@ TEST(GaussianMixtureFactor, Printing) {
auto A1 = Matrix::Zero(2, 1); auto A1 = Matrix::Zero(2, 1);
auto A2 = Matrix::Zero(2, 2); auto A2 = Matrix::Zero(2, 2);
auto b = Matrix::Zero(2, 1); auto b = Matrix::Zero(2, 1);
auto f10 = boost::make_shared<JacobianFactor>(X(1), A1, X(2), A2, b); auto f10 = std::make_shared<JacobianFactor>(X(1), A1, X(2), A2, b);
auto f11 = boost::make_shared<JacobianFactor>(X(1), A1, X(2), A2, b); auto f11 = std::make_shared<JacobianFactor>(X(1), A1, X(2), A2, b);
std::vector<GaussianFactor::shared_ptr> factors{f10, f11}; std::vector<GaussianFactor::shared_ptr> factors{f10, f11};
GaussianMixtureFactor mixtureFactor({X(1), X(2)}, {m1}, factors); GaussianMixtureFactor mixtureFactor({X(1), X(2)}, {m1}, factors);
@ -145,7 +145,7 @@ TEST(GaussianMixtureFactor, GaussianMixture) {
dKeys.emplace_back(M(0), 2); dKeys.emplace_back(M(0), 2);
dKeys.emplace_back(M(1), 2); dKeys.emplace_back(M(1), 2);
auto gaussians = boost::make_shared<GaussianConditional>(); auto gaussians = std::make_shared<GaussianConditional>();
GaussianMixture::Conditionals conditionals(gaussians); GaussianMixture::Conditionals conditionals(gaussians);
GaussianMixture gm({}, keys, dKeys, conditionals); GaussianMixture gm({}, keys, dKeys, conditionals);
@ -165,8 +165,8 @@ TEST(GaussianMixtureFactor, Error) {
auto b = Vector2::Zero(); auto b = Vector2::Zero();
auto f0 = boost::make_shared<JacobianFactor>(X(1), A01, X(2), A02, b); auto f0 = std::make_shared<JacobianFactor>(X(1), A01, X(2), A02, b);
auto f1 = boost::make_shared<JacobianFactor>(X(1), A11, X(2), A12, b); auto f1 = std::make_shared<JacobianFactor>(X(1), A11, X(2), A12, b);
std::vector<GaussianFactor::shared_ptr> factors{f0, f1}; std::vector<GaussianFactor::shared_ptr> factors{f0, f1};
GaussianMixtureFactor mixtureFactor({X(1), X(2)}, {m1}, factors); GaussianMixtureFactor mixtureFactor({X(1), X(2)}, {m1}, factors);

View File

@ -99,9 +99,9 @@ TEST(HybridBayesNet, evaluateHybrid) {
const SharedDiagonal model0 = noiseModel::Diagonal::Sigmas(Vector1(2.0)), const SharedDiagonal model0 = noiseModel::Diagonal::Sigmas(Vector1(2.0)),
model1 = noiseModel::Diagonal::Sigmas(Vector1(3.0)); model1 = noiseModel::Diagonal::Sigmas(Vector1(3.0));
const auto conditional0 = boost::make_shared<GaussianConditional>( const auto conditional0 = std::make_shared<GaussianConditional>(
X(1), Vector1::Constant(5), I_1x1, model0), X(1), Vector1::Constant(5), I_1x1, model0),
conditional1 = boost::make_shared<GaussianConditional>( conditional1 = std::make_shared<GaussianConditional>(
X(1), Vector1::Constant(2), I_1x1, model1); X(1), Vector1::Constant(2), I_1x1, model1);
// Create hybrid Bayes net. // Create hybrid Bayes net.
@ -289,7 +289,7 @@ TEST(HybridBayesNet, UpdateDiscreteConditionals) {
size_t maxNrLeaves = 3; size_t maxNrLeaves = 3;
auto discreteConditionals = posterior->discreteConditionals(); auto discreteConditionals = posterior->discreteConditionals();
const DecisionTreeFactor::shared_ptr prunedDecisionTree = const DecisionTreeFactor::shared_ptr prunedDecisionTree =
boost::make_shared<DecisionTreeFactor>( std::make_shared<DecisionTreeFactor>(
discreteConditionals->prune(maxNrLeaves)); discreteConditionals->prune(maxNrLeaves));
EXPECT_LONGS_EQUAL(maxNrLeaves + 2 /*2 zero leaves*/, EXPECT_LONGS_EQUAL(maxNrLeaves + 2 /*2 zero leaves*/,
@ -317,7 +317,7 @@ TEST(HybridBayesNet, UpdateDiscreteConditionals) {
// Get the pruned discrete conditionals as an AlgebraicDecisionTree // Get the pruned discrete conditionals as an AlgebraicDecisionTree
auto pruned_discrete_conditionals = posterior->at(4)->asDiscrete(); auto pruned_discrete_conditionals = posterior->at(4)->asDiscrete();
auto discrete_conditional_tree = auto discrete_conditional_tree =
boost::dynamic_pointer_cast<DecisionTreeFactor::ADT>( std::dynamic_pointer_cast<DecisionTreeFactor::ADT>(
pruned_discrete_conditionals); pruned_discrete_conditionals);
// The checker functor verifies the values for us. // The checker functor verifies the values for us.
@ -331,9 +331,9 @@ TEST(HybridBayesNet, Sampling) {
auto noise_model = noiseModel::Diagonal::Sigmas(Vector1(1.0)); auto noise_model = noiseModel::Diagonal::Sigmas(Vector1(1.0));
auto zero_motion = auto zero_motion =
boost::make_shared<BetweenFactor<double>>(X(0), X(1), 0, noise_model); std::make_shared<BetweenFactor<double>>(X(0), X(1), 0, noise_model);
auto one_motion = auto one_motion =
boost::make_shared<BetweenFactor<double>>(X(0), X(1), 1, noise_model); std::make_shared<BetweenFactor<double>>(X(0), X(1), 1, noise_model);
std::vector<NonlinearFactor::shared_ptr> factors = {zero_motion, one_motion}; std::vector<NonlinearFactor::shared_ptr> factors = {zero_motion, one_motion};
nfg.emplace_shared<PriorFactor<double>>(X(0), 0.0, noise_model); nfg.emplace_shared<PriorFactor<double>>(X(0), 0.0, noise_model);
nfg.emplace_shared<MixtureFactor>( nfg.emplace_shared<MixtureFactor>(

View File

@ -200,7 +200,7 @@ GaussianFactorGraph::shared_ptr specificModesFactorGraph(
// Add "motion models". // Add "motion models".
auto motion_noise_model = noiseModel::Isotropic::Sigma(1, between_sigma); auto motion_noise_model = noiseModel::Isotropic::Sigma(1, between_sigma);
for (size_t k = 0; k < K - 1; k++) { for (size_t k = 0; k < K - 1; k++) {
auto motion_model = boost::make_shared<MotionModel>( auto motion_model = std::make_shared<MotionModel>(
X(k), X(k + 1), discrete_seq.at(k), motion_noise_model); X(k), X(k + 1), discrete_seq.at(k), motion_noise_model);
graph.push_back(motion_model); graph.push_back(motion_model);
} }
@ -256,7 +256,7 @@ AlgebraicDecisionTree<Key> getProbPrimeTree(
vector<VectorValues::shared_ptr> vector_values; vector<VectorValues::shared_ptr> vector_values;
for (const DiscreteValues& assignment : assignments) { for (const DiscreteValues& assignment : assignments) {
VectorValues values = bayesNet->optimize(assignment); VectorValues values = bayesNet->optimize(assignment);
vector_values.push_back(boost::make_shared<VectorValues>(values)); vector_values.push_back(std::make_shared<VectorValues>(values));
} }
DecisionTree<Key, VectorValues::shared_ptr> delta_tree(discrete_keys, DecisionTree<Key, VectorValues::shared_ptr> delta_tree(discrete_keys,
vector_values); vector_values);
@ -413,9 +413,9 @@ static HybridNonlinearFactorGraph createHybridNonlinearFactorGraph() {
// Add mixture factor: // Add mixture factor:
DiscreteKey m(M(0), 2); DiscreteKey m(M(0), 2);
const auto zero_motion = const auto zero_motion =
boost::make_shared<BetweenFactor<double>>(X(0), X(1), 0, noise_model); std::make_shared<BetweenFactor<double>>(X(0), X(1), 0, noise_model);
const auto one_motion = const auto one_motion =
boost::make_shared<BetweenFactor<double>>(X(0), X(1), 1, noise_model); std::make_shared<BetweenFactor<double>>(X(0), X(1), 1, noise_model);
nfg.emplace_shared<MixtureFactor>( nfg.emplace_shared<MixtureFactor>(
KeyVector{X(0), X(1)}, DiscreteKeys{m}, KeyVector{X(0), X(1)}, DiscreteKeys{m},
std::vector<NonlinearFactor::shared_ptr>{zero_motion, one_motion}); std::vector<NonlinearFactor::shared_ptr>{zero_motion, one_motion});

View File

@ -73,9 +73,9 @@ TEST(HybridGaussianFactorGraph, Creation) {
GaussianMixture gm({X(0)}, {X(1)}, DiscreteKeys(DiscreteKey{M(0), 2}), GaussianMixture gm({X(0)}, {X(1)}, DiscreteKeys(DiscreteKey{M(0), 2}),
GaussianMixture::Conditionals( GaussianMixture::Conditionals(
M(0), M(0),
boost::make_shared<GaussianConditional>( std::make_shared<GaussianConditional>(
X(0), Z_3x1, I_3x3, X(1), I_3x3), X(0), Z_3x1, I_3x3, X(1), I_3x3),
boost::make_shared<GaussianConditional>( std::make_shared<GaussianConditional>(
X(0), Vector3::Ones(), I_3x3, X(1), I_3x3))); X(0), Vector3::Ones(), I_3x3, X(1), I_3x3)));
hfg.add(gm); hfg.add(gm);
@ -126,8 +126,8 @@ TEST(HybridGaussianFactorGraph, eliminateFullSequentialEqualChance) {
// Add a gaussian mixture factor ϕ(x1, c1) // Add a gaussian mixture factor ϕ(x1, c1)
DiscreteKey m1(M(1), 2); DiscreteKey m1(M(1), 2);
DecisionTree<Key, GaussianFactor::shared_ptr> dt( DecisionTree<Key, GaussianFactor::shared_ptr> dt(
M(1), boost::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1), M(1), std::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones())); std::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones()));
hfg.add(GaussianMixtureFactor({X(1)}, {m1}, dt)); hfg.add(GaussianMixtureFactor({X(1)}, {m1}, dt));
auto result = hfg.eliminateSequential(); auto result = hfg.eliminateSequential();
@ -152,8 +152,8 @@ TEST(HybridGaussianFactorGraph, eliminateFullSequentialSimple) {
hfg.add(JacobianFactor(X(0), I_3x3, X(1), -I_3x3, Z_3x1)); hfg.add(JacobianFactor(X(0), I_3x3, X(1), -I_3x3, Z_3x1));
std::vector<GaussianFactor::shared_ptr> factors = { std::vector<GaussianFactor::shared_ptr> factors = {
boost::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1), std::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones())}; std::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones())};
hfg.add(GaussianMixtureFactor({X(1)}, {m1}, factors)); hfg.add(GaussianMixtureFactor({X(1)}, {m1}, factors));
// Discrete probability table for c1 // Discrete probability table for c1
@ -178,8 +178,8 @@ TEST(HybridGaussianFactorGraph, eliminateFullMultifrontalSimple) {
hfg.add(GaussianMixtureFactor( hfg.add(GaussianMixtureFactor(
{X(1)}, {{M(1), 2}}, {X(1)}, {{M(1), 2}},
{boost::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1), {std::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones())})); std::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones())}));
hfg.add(DecisionTreeFactor(m1, {2, 8})); hfg.add(DecisionTreeFactor(m1, {2, 8}));
// TODO(Varun) Adding extra discrete variable not connected to continuous // TODO(Varun) Adding extra discrete variable not connected to continuous
@ -207,8 +207,8 @@ TEST(HybridGaussianFactorGraph, eliminateFullMultifrontalCLG) {
// Decision tree with different modes on x1 // Decision tree with different modes on x1
DecisionTree<Key, GaussianFactor::shared_ptr> dt( DecisionTree<Key, GaussianFactor::shared_ptr> dt(
M(1), boost::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1), M(1), std::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones())); std::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones()));
// Hybrid factor P(x1|c1) // Hybrid factor P(x1|c1)
hfg.add(GaussianMixtureFactor({X(1)}, {m}, dt)); hfg.add(GaussianMixtureFactor({X(1)}, {m}, dt));
@ -238,12 +238,12 @@ TEST(HybridGaussianFactorGraph, eliminateFullMultifrontalTwoClique) {
{ {
hfg.add(GaussianMixtureFactor( hfg.add(GaussianMixtureFactor(
{X(0)}, {{M(0), 2}}, {X(0)}, {{M(0), 2}},
{boost::make_shared<JacobianFactor>(X(0), I_3x3, Z_3x1), {std::make_shared<JacobianFactor>(X(0), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(0), I_3x3, Vector3::Ones())})); std::make_shared<JacobianFactor>(X(0), I_3x3, Vector3::Ones())}));
DecisionTree<Key, GaussianFactor::shared_ptr> dt1( DecisionTree<Key, GaussianFactor::shared_ptr> dt1(
M(1), boost::make_shared<JacobianFactor>(X(2), I_3x3, Z_3x1), M(1), std::make_shared<JacobianFactor>(X(2), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(2), I_3x3, Vector3::Ones())); std::make_shared<JacobianFactor>(X(2), I_3x3, Vector3::Ones()));
hfg.add(GaussianMixtureFactor({X(2)}, {{M(1), 2}}, dt1)); hfg.add(GaussianMixtureFactor({X(2)}, {{M(1), 2}}, dt1));
} }
@ -255,14 +255,14 @@ TEST(HybridGaussianFactorGraph, eliminateFullMultifrontalTwoClique) {
{ {
DecisionTree<Key, GaussianFactor::shared_ptr> dt( DecisionTree<Key, GaussianFactor::shared_ptr> dt(
M(3), boost::make_shared<JacobianFactor>(X(3), I_3x3, Z_3x1), M(3), std::make_shared<JacobianFactor>(X(3), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(3), I_3x3, Vector3::Ones())); std::make_shared<JacobianFactor>(X(3), I_3x3, Vector3::Ones()));
hfg.add(GaussianMixtureFactor({X(3)}, {{M(3), 2}}, dt)); hfg.add(GaussianMixtureFactor({X(3)}, {{M(3), 2}}, dt));
DecisionTree<Key, GaussianFactor::shared_ptr> dt1( DecisionTree<Key, GaussianFactor::shared_ptr> dt1(
M(2), boost::make_shared<JacobianFactor>(X(5), I_3x3, Z_3x1), M(2), std::make_shared<JacobianFactor>(X(5), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(5), I_3x3, Vector3::Ones())); std::make_shared<JacobianFactor>(X(5), I_3x3, Vector3::Ones()));
hfg.add(GaussianMixtureFactor({X(5)}, {{M(2), 2}}, dt1)); hfg.add(GaussianMixtureFactor({X(5)}, {{M(2), 2}}, dt1));
} }
@ -510,8 +510,8 @@ TEST(HybridGaussianFactorGraph, optimize) {
hfg.add(JacobianFactor(X(0), I_3x3, X(1), -I_3x3, Z_3x1)); hfg.add(JacobianFactor(X(0), I_3x3, X(1), -I_3x3, Z_3x1));
DecisionTree<Key, GaussianFactor::shared_ptr> dt( DecisionTree<Key, GaussianFactor::shared_ptr> dt(
C(1), boost::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1), C(1), std::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1),
boost::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones())); std::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones()));
hfg.add(GaussianMixtureFactor({X(1)}, {c1}, dt)); hfg.add(GaussianMixtureFactor({X(1)}, {c1}, dt));
@ -624,11 +624,11 @@ TEST(HybridGaussianFactorGraph, assembleGraphTree) {
// Create expected decision tree with two factor graphs: // Create expected decision tree with two factor graphs:
// Get mixture factor: // Get mixture factor:
auto mixture = boost::dynamic_pointer_cast<GaussianMixtureFactor>(fg.at(0)); auto mixture = std::dynamic_pointer_cast<GaussianMixtureFactor>(fg.at(0));
CHECK(mixture); CHECK(mixture);
// Get prior factor: // Get prior factor:
const auto gf = boost::dynamic_pointer_cast<HybridConditional>(fg.at(1)); const auto gf = std::dynamic_pointer_cast<HybridConditional>(fg.at(1));
CHECK(gf); CHECK(gf);
using GF = GaussianFactor::shared_ptr; using GF = GaussianFactor::shared_ptr;
const GF prior = gf->asGaussian(); const GF prior = gf->asGaussian();
@ -709,9 +709,9 @@ TEST(HybridGaussianFactorGraph, EliminateTiny1) {
// Create Gaussian mixture on X(0). // Create Gaussian mixture on X(0).
using tiny::mode; using tiny::mode;
// regression, but mean checked to be 5.0 in both cases: // regression, but mean checked to be 5.0 in both cases:
const auto conditional0 = boost::make_shared<GaussianConditional>( const auto conditional0 = std::make_shared<GaussianConditional>(
X(0), Vector1(14.1421), I_1x1 * 2.82843), X(0), Vector1(14.1421), I_1x1 * 2.82843),
conditional1 = boost::make_shared<GaussianConditional>( conditional1 = std::make_shared<GaussianConditional>(
X(0), Vector1(10.1379), I_1x1 * 2.02759); X(0), Vector1(10.1379), I_1x1 * 2.02759);
expectedBayesNet.emplace_back( expectedBayesNet.emplace_back(
new GaussianMixture({X(0)}, {}, {mode}, {conditional0, conditional1})); new GaussianMixture({X(0)}, {}, {mode}, {conditional0, conditional1}));
@ -743,9 +743,9 @@ TEST(HybridGaussianFactorGraph, EliminateTiny2) {
// Create Gaussian mixture on X(0). // Create Gaussian mixture on X(0).
using tiny::mode; using tiny::mode;
// regression, but mean checked to be 5.0 in both cases: // regression, but mean checked to be 5.0 in both cases:
const auto conditional0 = boost::make_shared<GaussianConditional>( const auto conditional0 = std::make_shared<GaussianConditional>(
X(0), Vector1(17.3205), I_1x1 * 3.4641), X(0), Vector1(17.3205), I_1x1 * 3.4641),
conditional1 = boost::make_shared<GaussianConditional>( conditional1 = std::make_shared<GaussianConditional>(
X(0), Vector1(10.274), I_1x1 * 2.0548); X(0), Vector1(10.274), I_1x1 * 2.0548);
expectedBayesNet.emplace_back( expectedBayesNet.emplace_back(
new GaussianMixture({X(0)}, {}, {mode}, {conditional0, conditional1})); new GaussianMixture({X(0)}, {}, {mode}, {conditional0, conditional1}));

View File

@ -201,7 +201,7 @@ TEST(HybridGaussianElimination, IncrementalInference) {
DiscreteKeys discrete_keys = {{M(0), 2}, {M(1), 2}}; DiscreteKeys discrete_keys = {{M(0), 2}, {M(1), 2}};
vector<double> probs = {0.095292197, 0.31417524, 0.28275772, 0.30777485}; vector<double> probs = {0.095292197, 0.31417524, 0.28275772, 0.30777485};
auto expectedConditional = auto expectedConditional =
boost::make_shared<DecisionTreeFactor>(discrete_keys, probs); std::make_shared<DecisionTreeFactor>(discrete_keys, probs);
EXPECT(assert_equal(*expectedConditional, *actualConditional, 1e-6)); EXPECT(assert_equal(*expectedConditional, *actualConditional, 1e-6));
} }
@ -422,12 +422,12 @@ TEST(HybridGaussianISAM, NonTrivial) {
Pose2 odometry(1.0, 0.0, 0.0); Pose2 odometry(1.0, 0.0, 0.0);
KeyVector contKeys = {W(0), W(1)}; KeyVector contKeys = {W(0), W(1)};
auto noise_model = noiseModel::Isotropic::Sigma(3, 1.0); auto noise_model = noiseModel::Isotropic::Sigma(3, 1.0);
auto still = boost::make_shared<PlanarMotionModel>(W(0), W(1), Pose2(0, 0, 0), auto still = std::make_shared<PlanarMotionModel>(W(0), W(1), Pose2(0, 0, 0),
noise_model), noise_model),
moving = boost::make_shared<PlanarMotionModel>(W(0), W(1), odometry, moving = std::make_shared<PlanarMotionModel>(W(0), W(1), odometry,
noise_model); noise_model);
std::vector<PlanarMotionModel::shared_ptr> components = {moving, still}; std::vector<PlanarMotionModel::shared_ptr> components = {moving, still};
auto mixtureFactor = boost::make_shared<MixtureFactor>( auto mixtureFactor = std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components);
fg.push_back(mixtureFactor); fg.push_back(mixtureFactor);
@ -462,12 +462,12 @@ TEST(HybridGaussianISAM, NonTrivial) {
/*************** Run Round 3 ***************/ /*************** Run Round 3 ***************/
// Add odometry factor with discrete modes. // Add odometry factor with discrete modes.
contKeys = {W(1), W(2)}; contKeys = {W(1), W(2)};
still = boost::make_shared<PlanarMotionModel>(W(1), W(2), Pose2(0, 0, 0), still = std::make_shared<PlanarMotionModel>(W(1), W(2), Pose2(0, 0, 0),
noise_model); noise_model);
moving = moving =
boost::make_shared<PlanarMotionModel>(W(1), W(2), odometry, noise_model); std::make_shared<PlanarMotionModel>(W(1), W(2), odometry, noise_model);
components = {moving, still}; components = {moving, still};
mixtureFactor = boost::make_shared<MixtureFactor>( mixtureFactor = std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(2), 2)}, components); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(2), 2)}, components);
fg.push_back(mixtureFactor); fg.push_back(mixtureFactor);
@ -505,12 +505,12 @@ TEST(HybridGaussianISAM, NonTrivial) {
/*************** Run Round 4 ***************/ /*************** Run Round 4 ***************/
// Add odometry factor with discrete modes. // Add odometry factor with discrete modes.
contKeys = {W(2), W(3)}; contKeys = {W(2), W(3)};
still = boost::make_shared<PlanarMotionModel>(W(2), W(3), Pose2(0, 0, 0), still = std::make_shared<PlanarMotionModel>(W(2), W(3), Pose2(0, 0, 0),
noise_model); noise_model);
moving = moving =
boost::make_shared<PlanarMotionModel>(W(2), W(3), odometry, noise_model); std::make_shared<PlanarMotionModel>(W(2), W(3), odometry, noise_model);
components = {moving, still}; components = {moving, still};
mixtureFactor = boost::make_shared<MixtureFactor>( mixtureFactor = std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(3), 2)}, components); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(3), 2)}, components);
fg.push_back(mixtureFactor); fg.push_back(mixtureFactor);

View File

@ -80,12 +80,12 @@ TEST(HybridNonlinearFactorGraph, Equals) {
// Test empty factor graphs // Test empty factor graphs
EXPECT(assert_equal(graph1, graph2)); EXPECT(assert_equal(graph1, graph2));
auto f0 = boost::make_shared<PriorFactor<Pose2>>( auto f0 = std::make_shared<PriorFactor<Pose2>>(
1, Pose2(), noiseModel::Isotropic::Sigma(3, 0.001)); 1, Pose2(), noiseModel::Isotropic::Sigma(3, 0.001));
graph1.push_back(f0); graph1.push_back(f0);
graph2.push_back(f0); graph2.push_back(f0);
auto f1 = boost::make_shared<BetweenFactor<Pose2>>( auto f1 = std::make_shared<BetweenFactor<Pose2>>(
1, 2, Pose2(), noiseModel::Isotropic::Sigma(3, 0.1)); 1, 2, Pose2(), noiseModel::Isotropic::Sigma(3, 0.1));
graph1.push_back(f1); graph1.push_back(f1);
graph2.push_back(f1); graph2.push_back(f1);
@ -99,13 +99,13 @@ TEST(HybridNonlinearFactorGraph, Equals) {
*/ */
TEST(HybridNonlinearFactorGraph, Resize) { TEST(HybridNonlinearFactorGraph, Resize) {
HybridNonlinearFactorGraph fg; HybridNonlinearFactorGraph fg;
auto nonlinearFactor = boost::make_shared<BetweenFactor<double>>(); auto nonlinearFactor = std::make_shared<BetweenFactor<double>>();
fg.push_back(nonlinearFactor); fg.push_back(nonlinearFactor);
auto discreteFactor = boost::make_shared<DecisionTreeFactor>(); auto discreteFactor = std::make_shared<DecisionTreeFactor>();
fg.push_back(discreteFactor); fg.push_back(discreteFactor);
auto dcFactor = boost::make_shared<MixtureFactor>(); auto dcFactor = std::make_shared<MixtureFactor>();
fg.push_back(dcFactor); fg.push_back(dcFactor);
EXPECT_LONGS_EQUAL(fg.size(), 3); EXPECT_LONGS_EQUAL(fg.size(), 3);
@ -120,19 +120,19 @@ TEST(HybridNonlinearFactorGraph, Resize) {
*/ */
TEST(HybridGaussianFactorGraph, Resize) { TEST(HybridGaussianFactorGraph, Resize) {
HybridNonlinearFactorGraph nhfg; HybridNonlinearFactorGraph nhfg;
auto nonlinearFactor = boost::make_shared<BetweenFactor<double>>( auto nonlinearFactor = std::make_shared<BetweenFactor<double>>(
X(0), X(1), 0.0, Isotropic::Sigma(1, 0.1)); X(0), X(1), 0.0, Isotropic::Sigma(1, 0.1));
nhfg.push_back(nonlinearFactor); nhfg.push_back(nonlinearFactor);
auto discreteFactor = boost::make_shared<DecisionTreeFactor>(); auto discreteFactor = std::make_shared<DecisionTreeFactor>();
nhfg.push_back(discreteFactor); nhfg.push_back(discreteFactor);
KeyVector contKeys = {X(0), X(1)}; KeyVector contKeys = {X(0), X(1)};
auto noise_model = noiseModel::Isotropic::Sigma(1, 1.0); auto noise_model = noiseModel::Isotropic::Sigma(1, 1.0);
auto still = boost::make_shared<MotionModel>(X(0), X(1), 0.0, noise_model), auto still = std::make_shared<MotionModel>(X(0), X(1), 0.0, noise_model),
moving = boost::make_shared<MotionModel>(X(0), X(1), 1.0, noise_model); moving = std::make_shared<MotionModel>(X(0), X(1), 1.0, noise_model);
std::vector<MotionModel::shared_ptr> components = {still, moving}; std::vector<MotionModel::shared_ptr> components = {still, moving};
auto dcFactor = boost::make_shared<MixtureFactor>( auto dcFactor = std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components);
nhfg.push_back(dcFactor); nhfg.push_back(dcFactor);
@ -154,24 +154,24 @@ TEST(HybridGaussianFactorGraph, Resize) {
* keys provided do not match the keys in the factors. * keys provided do not match the keys in the factors.
*/ */
TEST(HybridGaussianFactorGraph, MixtureFactor) { TEST(HybridGaussianFactorGraph, MixtureFactor) {
auto nonlinearFactor = boost::make_shared<BetweenFactor<double>>( auto nonlinearFactor = std::make_shared<BetweenFactor<double>>(
X(0), X(1), 0.0, Isotropic::Sigma(1, 0.1)); X(0), X(1), 0.0, Isotropic::Sigma(1, 0.1));
auto discreteFactor = boost::make_shared<DecisionTreeFactor>(); auto discreteFactor = std::make_shared<DecisionTreeFactor>();
auto noise_model = noiseModel::Isotropic::Sigma(1, 1.0); auto noise_model = noiseModel::Isotropic::Sigma(1, 1.0);
auto still = boost::make_shared<MotionModel>(X(0), X(1), 0.0, noise_model), auto still = std::make_shared<MotionModel>(X(0), X(1), 0.0, noise_model),
moving = boost::make_shared<MotionModel>(X(0), X(1), 1.0, noise_model); moving = std::make_shared<MotionModel>(X(0), X(1), 1.0, noise_model);
std::vector<MotionModel::shared_ptr> components = {still, moving}; std::vector<MotionModel::shared_ptr> components = {still, moving};
// Check for exception when number of continuous keys are under-specified. // Check for exception when number of continuous keys are under-specified.
KeyVector contKeys = {X(0)}; KeyVector contKeys = {X(0)};
THROWS_EXCEPTION(boost::make_shared<MixtureFactor>( THROWS_EXCEPTION(std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components)); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components));
// Check for exception when number of continuous keys are too many. // Check for exception when number of continuous keys are too many.
contKeys = {X(0), X(1), X(2)}; contKeys = {X(0), X(1), X(2)};
THROWS_EXCEPTION(boost::make_shared<MixtureFactor>( THROWS_EXCEPTION(std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components)); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components));
} }
@ -181,21 +181,21 @@ TEST(HybridGaussianFactorGraph, MixtureFactor) {
TEST(HybridFactorGraph, PushBack) { TEST(HybridFactorGraph, PushBack) {
HybridNonlinearFactorGraph fg; HybridNonlinearFactorGraph fg;
auto nonlinearFactor = boost::make_shared<BetweenFactor<double>>(); auto nonlinearFactor = std::make_shared<BetweenFactor<double>>();
fg.push_back(nonlinearFactor); fg.push_back(nonlinearFactor);
EXPECT_LONGS_EQUAL(fg.size(), 1); EXPECT_LONGS_EQUAL(fg.size(), 1);
fg = HybridNonlinearFactorGraph(); fg = HybridNonlinearFactorGraph();
auto discreteFactor = boost::make_shared<DecisionTreeFactor>(); auto discreteFactor = std::make_shared<DecisionTreeFactor>();
fg.push_back(discreteFactor); fg.push_back(discreteFactor);
EXPECT_LONGS_EQUAL(fg.size(), 1); EXPECT_LONGS_EQUAL(fg.size(), 1);
fg = HybridNonlinearFactorGraph(); fg = HybridNonlinearFactorGraph();
auto dcFactor = boost::make_shared<MixtureFactor>(); auto dcFactor = std::make_shared<MixtureFactor>();
fg.push_back(dcFactor); fg.push_back(dcFactor);
EXPECT_LONGS_EQUAL(fg.size(), 1); EXPECT_LONGS_EQUAL(fg.size(), 1);
@ -203,7 +203,7 @@ TEST(HybridFactorGraph, PushBack) {
// Now do the same with HybridGaussianFactorGraph // Now do the same with HybridGaussianFactorGraph
HybridGaussianFactorGraph ghfg; HybridGaussianFactorGraph ghfg;
auto gaussianFactor = boost::make_shared<JacobianFactor>(); auto gaussianFactor = std::make_shared<JacobianFactor>();
ghfg.push_back(gaussianFactor); ghfg.push_back(gaussianFactor);
EXPECT_LONGS_EQUAL(ghfg.size(), 1); EXPECT_LONGS_EQUAL(ghfg.size(), 1);
@ -329,7 +329,7 @@ GaussianFactorGraph::shared_ptr batchGFG(double between,
NonlinearFactorGraph graph; NonlinearFactorGraph graph;
graph.addPrior<double>(X(0), 0, Isotropic::Sigma(1, 0.1)); graph.addPrior<double>(X(0), 0, Isotropic::Sigma(1, 0.1));
auto between_x0_x1 = boost::make_shared<MotionModel>( auto between_x0_x1 = std::make_shared<MotionModel>(
X(0), X(1), between, Isotropic::Sigma(1, 1.0)); X(0), X(1), between, Isotropic::Sigma(1, 1.0));
graph.push_back(between_x0_x1); graph.push_back(between_x0_x1);
@ -351,7 +351,7 @@ TEST(HybridGaussianElimination, EliminateHybrid_2_Variable) {
ordering += X(1); ordering += X(1);
HybridConditional::shared_ptr hybridConditionalMixture; HybridConditional::shared_ptr hybridConditionalMixture;
boost::shared_ptr<Factor> factorOnModes; std::shared_ptr<Factor> factorOnModes;
std::tie(hybridConditionalMixture, factorOnModes) = std::tie(hybridConditionalMixture, factorOnModes) =
EliminateHybrid(factors, ordering); EliminateHybrid(factors, ordering);
@ -684,9 +684,9 @@ TEST(HybridFactorGraph, DefaultDecisionTree) {
Pose2 odometry(2.0, 0.0, 0.0); Pose2 odometry(2.0, 0.0, 0.0);
KeyVector contKeys = {X(0), X(1)}; KeyVector contKeys = {X(0), X(1)};
auto noise_model = noiseModel::Isotropic::Sigma(3, 1.0); auto noise_model = noiseModel::Isotropic::Sigma(3, 1.0);
auto still = boost::make_shared<PlanarMotionModel>(X(0), X(1), Pose2(0, 0, 0), auto still = std::make_shared<PlanarMotionModel>(X(0), X(1), Pose2(0, 0, 0),
noise_model), noise_model),
moving = boost::make_shared<PlanarMotionModel>(X(0), X(1), odometry, moving = std::make_shared<PlanarMotionModel>(X(0), X(1), odometry,
noise_model); noise_model);
std::vector<PlanarMotionModel::shared_ptr> motion_models = {still, moving}; std::vector<PlanarMotionModel::shared_ptr> motion_models = {still, moving};
fg.emplace_shared<MixtureFactor>( fg.emplace_shared<MixtureFactor>(

View File

@ -218,7 +218,7 @@ TEST(HybridNonlinearISAM, IncrementalInference) {
DiscreteKeys discrete_keys = {{M(0), 2}, {M(1), 2}}; DiscreteKeys discrete_keys = {{M(0), 2}, {M(1), 2}};
vector<double> probs = {0.095292197, 0.31417524, 0.28275772, 0.30777485}; vector<double> probs = {0.095292197, 0.31417524, 0.28275772, 0.30777485};
auto expectedConditional = auto expectedConditional =
boost::make_shared<DecisionTreeFactor>(discrete_keys, probs); std::make_shared<DecisionTreeFactor>(discrete_keys, probs);
EXPECT(assert_equal(*expectedConditional, *actualConditional, 1e-6)); EXPECT(assert_equal(*expectedConditional, *actualConditional, 1e-6));
} }
@ -441,12 +441,12 @@ TEST(HybridNonlinearISAM, NonTrivial) {
Pose2 odometry(1.0, 0.0, 0.0); Pose2 odometry(1.0, 0.0, 0.0);
KeyVector contKeys = {W(0), W(1)}; KeyVector contKeys = {W(0), W(1)};
auto noise_model = noiseModel::Isotropic::Sigma(3, 1.0); auto noise_model = noiseModel::Isotropic::Sigma(3, 1.0);
auto still = boost::make_shared<PlanarMotionModel>(W(0), W(1), Pose2(0, 0, 0), auto still = std::make_shared<PlanarMotionModel>(W(0), W(1), Pose2(0, 0, 0),
noise_model), noise_model),
moving = boost::make_shared<PlanarMotionModel>(W(0), W(1), odometry, moving = std::make_shared<PlanarMotionModel>(W(0), W(1), odometry,
noise_model); noise_model);
std::vector<PlanarMotionModel::shared_ptr> components = {moving, still}; std::vector<PlanarMotionModel::shared_ptr> components = {moving, still};
auto mixtureFactor = boost::make_shared<MixtureFactor>( auto mixtureFactor = std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(1), 2)}, components);
fg.push_back(mixtureFactor); fg.push_back(mixtureFactor);
@ -481,12 +481,12 @@ TEST(HybridNonlinearISAM, NonTrivial) {
/*************** Run Round 3 ***************/ /*************** Run Round 3 ***************/
// Add odometry factor with discrete modes. // Add odometry factor with discrete modes.
contKeys = {W(1), W(2)}; contKeys = {W(1), W(2)};
still = boost::make_shared<PlanarMotionModel>(W(1), W(2), Pose2(0, 0, 0), still = std::make_shared<PlanarMotionModel>(W(1), W(2), Pose2(0, 0, 0),
noise_model); noise_model);
moving = moving =
boost::make_shared<PlanarMotionModel>(W(1), W(2), odometry, noise_model); std::make_shared<PlanarMotionModel>(W(1), W(2), odometry, noise_model);
components = {moving, still}; components = {moving, still};
mixtureFactor = boost::make_shared<MixtureFactor>( mixtureFactor = std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(2), 2)}, components); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(2), 2)}, components);
fg.push_back(mixtureFactor); fg.push_back(mixtureFactor);
@ -524,12 +524,12 @@ TEST(HybridNonlinearISAM, NonTrivial) {
/*************** Run Round 4 ***************/ /*************** Run Round 4 ***************/
// Add odometry factor with discrete modes. // Add odometry factor with discrete modes.
contKeys = {W(2), W(3)}; contKeys = {W(2), W(3)};
still = boost::make_shared<PlanarMotionModel>(W(2), W(3), Pose2(0, 0, 0), still = std::make_shared<PlanarMotionModel>(W(2), W(3), Pose2(0, 0, 0),
noise_model); noise_model);
moving = moving =
boost::make_shared<PlanarMotionModel>(W(2), W(3), odometry, noise_model); std::make_shared<PlanarMotionModel>(W(2), W(3), odometry, noise_model);
components = {moving, still}; components = {moving, still};
mixtureFactor = boost::make_shared<MixtureFactor>( mixtureFactor = std::make_shared<MixtureFactor>(
contKeys, DiscreteKeys{gtsam::DiscreteKey(M(3), 2)}, components); contKeys, DiscreteKeys{gtsam::DiscreteKey(M(3), 2)}, components);
fg.push_back(mixtureFactor); fg.push_back(mixtureFactor);

View File

@ -52,9 +52,9 @@ TEST(MixtureFactor, Printing) {
auto model = noiseModel::Diagonal::Sigmas(sigmas, false); auto model = noiseModel::Diagonal::Sigmas(sigmas, false);
auto f0 = auto f0 =
boost::make_shared<BetweenFactor<double>>(X(1), X(2), between0, model); std::make_shared<BetweenFactor<double>>(X(1), X(2), between0, model);
auto f1 = auto f1 =
boost::make_shared<BetweenFactor<double>>(X(1), X(2), between1, model); std::make_shared<BetweenFactor<double>>(X(1), X(2), between1, model);
std::vector<NonlinearFactor::shared_ptr> factors{f0, f1}; std::vector<NonlinearFactor::shared_ptr> factors{f0, f1};
MixtureFactor mixtureFactor({X(1), X(2)}, {m1}, factors); MixtureFactor mixtureFactor({X(1), X(2)}, {m1}, factors);
@ -80,9 +80,9 @@ static MixtureFactor getMixtureFactor() {
auto model = noiseModel::Diagonal::Sigmas(sigmas, false); auto model = noiseModel::Diagonal::Sigmas(sigmas, false);
auto f0 = auto f0 =
boost::make_shared<BetweenFactor<double>>(X(1), X(2), between0, model); std::make_shared<BetweenFactor<double>>(X(1), X(2), between0, model);
auto f1 = auto f1 =
boost::make_shared<BetweenFactor<double>>(X(1), X(2), between1, model); std::make_shared<BetweenFactor<double>>(X(1), X(2), between1, model);
std::vector<NonlinearFactor::shared_ptr> factors{f0, f1}; std::vector<NonlinearFactor::shared_ptr> factors{f0, f1};
return MixtureFactor({X(1), X(2)}, {m1}, factors); return MixtureFactor({X(1), X(2)}, {m1}, factors);

View File

@ -80,8 +80,8 @@ TEST(HybridSerialization, GaussianMixtureFactor) {
auto A = Matrix::Zero(2, 1); auto A = Matrix::Zero(2, 1);
auto b0 = Matrix::Zero(2, 1); auto b0 = Matrix::Zero(2, 1);
auto b1 = Matrix::Ones(2, 1); auto b1 = Matrix::Ones(2, 1);
auto f0 = boost::make_shared<JacobianFactor>(X(0), A, b0); auto f0 = std::make_shared<JacobianFactor>(X(0), A, b0);
auto f1 = boost::make_shared<JacobianFactor>(X(0), A, b1); auto f1 = std::make_shared<JacobianFactor>(X(0), A, b1);
std::vector<GaussianFactor::shared_ptr> factors{f0, f1}; std::vector<GaussianFactor::shared_ptr> factors{f0, f1};
const GaussianMixtureFactor factor(continuousKeys, discreteKeys, factors); const GaussianMixtureFactor factor(continuousKeys, discreteKeys, factors);
@ -96,7 +96,7 @@ TEST(HybridSerialization, GaussianMixtureFactor) {
TEST(HybridSerialization, HybridConditional) { TEST(HybridSerialization, HybridConditional) {
const DiscreteKey mode(M(0), 2); const DiscreteKey mode(M(0), 2);
Matrix1 I = Matrix1::Identity(); Matrix1 I = Matrix1::Identity();
const auto conditional = boost::make_shared<GaussianConditional>( const auto conditional = std::make_shared<GaussianConditional>(
GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 0.5)); GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 0.5));
const HybridConditional hc(conditional); const HybridConditional hc(conditional);
@ -110,9 +110,9 @@ TEST(HybridSerialization, HybridConditional) {
TEST(HybridSerialization, GaussianMixture) { TEST(HybridSerialization, GaussianMixture) {
const DiscreteKey mode(M(0), 2); const DiscreteKey mode(M(0), 2);
Matrix1 I = Matrix1::Identity(); Matrix1 I = Matrix1::Identity();
const auto conditional0 = boost::make_shared<GaussianConditional>( const auto conditional0 = std::make_shared<GaussianConditional>(
GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 0.5)); GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 0.5));
const auto conditional1 = boost::make_shared<GaussianConditional>( const auto conditional1 = std::make_shared<GaussianConditional>(
GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 3)); GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 3));
const GaussianMixture gm({Z(0)}, {X(0)}, {mode}, const GaussianMixture gm({Z(0)}, {X(0)}, {mode},
{conditional0, conditional1}); {conditional0, conditional1});

View File

@ -20,7 +20,7 @@
#include <gtsam/inference/FactorGraph.h> #include <gtsam/inference/FactorGraph.h>
#include <boost/shared_ptr.hpp> #include <memory>
#include <string> #include <string>
namespace gtsam { namespace gtsam {
@ -37,7 +37,7 @@ class BayesNet : public FactorGraph<CONDITIONAL> {
typedef FactorGraph<CONDITIONAL> Base; typedef FactorGraph<CONDITIONAL> Base;
public: public:
typedef typename boost::shared_ptr<CONDITIONAL> typedef typename std::shared_ptr<CONDITIONAL>
sharedConditional; ///< A shared pointer to a conditional sharedConditional; ///< A shared pointer to a conditional
protected: protected:

View File

@ -155,7 +155,7 @@ namespace gtsam {
struct _pushCliqueFunctor { struct _pushCliqueFunctor {
_pushCliqueFunctor(FactorGraph<FACTOR>* graph_) : graph(graph_) {} _pushCliqueFunctor(FactorGraph<FACTOR>* graph_) : graph(graph_) {}
FactorGraph<FACTOR>* graph; FactorGraph<FACTOR>* graph;
int operator()(const boost::shared_ptr<CLIQUE>& clique, int dummy) { int operator()(const std::shared_ptr<CLIQUE>& clique, int dummy) {
graph->push_back(clique->conditional_); graph->push_back(clique->conditional_);
return 0; return 0;
} }
@ -181,11 +181,11 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
namespace { namespace {
template<typename NODE> template<typename NODE>
boost::shared_ptr<NODE> std::shared_ptr<NODE>
BayesTreeCloneForestVisitorPre(const boost::shared_ptr<NODE>& node, const boost::shared_ptr<NODE>& parentPointer) BayesTreeCloneForestVisitorPre(const std::shared_ptr<NODE>& node, const std::shared_ptr<NODE>& parentPointer)
{ {
// Clone the current node and add it to its cloned parent // Clone the current node and add it to its cloned parent
boost::shared_ptr<NODE> clone = boost::make_shared<NODE>(*node); std::shared_ptr<NODE> clone = std::make_shared<NODE>(*node);
clone->children.clear(); clone->children.clear();
clone->parent_ = parentPointer; clone->parent_ = parentPointer;
parentPointer->children.push_back(clone); parentPointer->children.push_back(clone);
@ -197,7 +197,7 @@ namespace gtsam {
template<class CLIQUE> template<class CLIQUE>
BayesTree<CLIQUE>& BayesTree<CLIQUE>::operator=(const This& other) { BayesTree<CLIQUE>& BayesTree<CLIQUE>::operator=(const This& other) {
this->clear(); this->clear();
boost::shared_ptr<Clique> rootContainer = boost::make_shared<Clique>(); std::shared_ptr<Clique> rootContainer = std::make_shared<Clique>();
treeTraversal::DepthFirstForest(other, rootContainer, BayesTreeCloneForestVisitorPre<Clique>); treeTraversal::DepthFirstForest(other, rootContainer, BayesTreeCloneForestVisitorPre<Clique>);
for(const sharedClique& root: rootContainer->children) { for(const sharedClique& root: rootContainer->children) {
root->parent_ = typename Clique::weak_ptr(); // Reset the parent since it's set to the dummy clique root->parent_ = typename Clique::weak_ptr(); // Reset the parent since it's set to the dummy clique
@ -292,7 +292,7 @@ namespace gtsam {
BayesTree<CLIQUE>::joint(Key j1, Key j2, const Eliminate& function) const BayesTree<CLIQUE>::joint(Key j1, Key j2, const Eliminate& function) const
{ {
gttic(BayesTree_joint); gttic(BayesTree_joint);
return boost::make_shared<FactorGraphType>(*jointBayesNet(j1, j2, function)); return std::make_shared<FactorGraphType>(*jointBayesNet(j1, j2, function));
} }
/* ************************************************************************* */ /* ************************************************************************* */
@ -352,7 +352,7 @@ namespace gtsam {
// Factor the shortcuts to be conditioned on the full root // Factor the shortcuts to be conditioned on the full root
// Get the set of variables to eliminate, which is C1\B. // Get the set of variables to eliminate, which is C1\B.
gttic(Full_root_factoring); gttic(Full_root_factoring);
boost::shared_ptr<typename EliminationTraitsType::BayesTreeType> p_C1_B; { std::shared_ptr<typename EliminationTraitsType::BayesTreeType> p_C1_B; {
KeyVector C1_minus_B; { KeyVector C1_minus_B; {
KeySet C1_minus_B_set(C1->conditional()->beginParents(), C1->conditional()->endParents()); KeySet C1_minus_B_set(C1->conditional()->beginParents(), C1->conditional()->endParents());
for(const Key j: *B->conditional()) { for(const Key j: *B->conditional()) {
@ -364,7 +364,7 @@ namespace gtsam {
boost::tie(p_C1_B, temp_remaining) = boost::tie(p_C1_B, temp_remaining) =
FactorGraphType(p_C1_Bred).eliminatePartialMultifrontal(Ordering(C1_minus_B), function); FactorGraphType(p_C1_Bred).eliminatePartialMultifrontal(Ordering(C1_minus_B), function);
} }
boost::shared_ptr<typename EliminationTraitsType::BayesTreeType> p_C2_B; { std::shared_ptr<typename EliminationTraitsType::BayesTreeType> p_C2_B; {
KeyVector C2_minus_B; { KeyVector C2_minus_B; {
KeySet C2_minus_B_set(C2->conditional()->beginParents(), C2->conditional()->endParents()); KeySet C2_minus_B_set(C2->conditional()->beginParents(), C2->conditional()->endParents());
for(const Key j: *B->conditional()) { for(const Key j: *B->conditional()) {

Some files were not shown because too many files have changed in this diff Show More