From d5d70d7751f7c9689798a885be956c4d8cbbbc31 Mon Sep 17 00:00:00 2001 From: Viorela Ila Date: Sun, 13 Dec 2009 03:02:14 +0000 Subject: [PATCH] gradientDescent_ and conjugateGradientDescent_ works in matlab --- cpp/GaussianFactorGraph.cpp | 14 ++++++++++++++ cpp/GaussianFactorGraph.h | 9 ++++++++- cpp/gtsam.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cpp/GaussianFactorGraph.cpp b/cpp/GaussianFactorGraph.cpp index a245b20db..300f60272 100644 --- a/cpp/GaussianFactorGraph.cpp +++ b/cpp/GaussianFactorGraph.cpp @@ -292,3 +292,17 @@ VectorConfig GaussianFactorGraph::conjugateGradientDescent( } /* ************************************************************************* */ +/* ************************************************************************* */ +boost::shared_ptr +GaussianFactorGraph::gradientDescent_(const VectorConfig& x0) const { + return boost::shared_ptr(new VectorConfig(gradientDescent(x0))); +} + +/* ************************************************************************* */ +boost::shared_ptr +GaussianFactorGraph::conjugateGradientDescent_(const VectorConfig& x0) const { + return boost::shared_ptr(new VectorConfig(conjugateGradientDescent(x0))); +} + +/* ************************************************************************* */ + diff --git a/cpp/GaussianFactorGraph.h b/cpp/GaussianFactorGraph.h index 1567f251c..1d6486aa9 100644 --- a/cpp/GaussianFactorGraph.h +++ b/cpp/GaussianFactorGraph.h @@ -187,13 +187,20 @@ namespace gtsam { * @return solution */ VectorConfig gradientDescent(const VectorConfig& x0) const; - + /** + * shared pointer versions for MATLAB + */ + boost::shared_ptrgradientDescent_(const VectorConfig& x0) const; /** * Find solution using conjugate gradient descent * @param x0: VectorConfig specifying initial estimate * @return solution */ VectorConfig conjugateGradientDescent(const VectorConfig& x0) const; + /** + * shared pointer versions for MATLAB + */ + boost::shared_ptr conjugateGradientDescent_(const VectorConfig& x0) const; }; } diff --git a/cpp/gtsam.h b/cpp/gtsam.h index a7a82a059..53e31e517 100644 --- a/cpp/gtsam.h +++ b/cpp/gtsam.h @@ -106,6 +106,8 @@ class GaussianFactorGraph { VectorConfig* optimize_(const Ordering& ordering); pair matrix(const Ordering& ordering) const; Matrix sparse(const Ordering& ordering) const; + VectorConfig* gradientDescent_(const VectorConfig& x0) const; + VectorConfig* conjugateGradientDescent_(const VectorConfig& x0) const; }; class Point2 {