From caf742d5e12ff04bd0b4ccc7eb42e5073cd0b8d6 Mon Sep 17 00:00:00 2001 From: dellaert Date: Sun, 5 Oct 2014 17:20:55 +0200 Subject: [PATCH] Better names --- gtsam_unstable/nonlinear/Expression-inl.h | 32 +++++++++++------------ gtsam_unstable/nonlinear/Expression.h | 4 +-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gtsam_unstable/nonlinear/Expression-inl.h b/gtsam_unstable/nonlinear/Expression-inl.h index 85e4be001..669f1369d 100644 --- a/gtsam_unstable/nonlinear/Expression-inl.h +++ b/gtsam_unstable/nonlinear/Expression-inl.h @@ -147,7 +147,7 @@ struct JacobianTrace { T value() const { return t; } - virtual void update(const Matrix& H, JacobianMap& jacobians) const = 0; + virtual void reverseAD(const Matrix& H, JacobianMap& jacobians) const = 0; // /// Insert terms into jacobians_, adding if already exists // static void add(const JacobianMap& terms) { @@ -193,7 +193,7 @@ public: virtual Augmented forward(const Values& values) const = 0; /// Construct an execution trace for reverse AD - virtual boost::shared_ptr > reverse( + virtual boost::shared_ptr > traceExecution( const Values& values) const = 0; }; @@ -237,13 +237,13 @@ public: /// Trace structure for reverse AD struct Trace: public JacobianTrace { /// Return value and derivatives - virtual void update(const Matrix& H, JacobianMap& jacobians) const { + virtual void reverseAD(const Matrix& H, JacobianMap& jacobians) const { // Base case: don't touch jacobians } }; /// Construct an execution trace for reverse AD - virtual boost::shared_ptr > reverse( + virtual boost::shared_ptr > traceExecution( const Values& values) const { boost::shared_ptr trace = boost::make_shared(); trace->t = constant_; @@ -294,14 +294,14 @@ public: struct Trace: public JacobianTrace { Key key; /// Return value and derivatives - virtual void update(const Matrix& H, JacobianMap& jacobians) const { + virtual void reverseAD(const Matrix& H, JacobianMap& jacobians) const { // Base case: just insert a new H in the JacobianMap with correct key jacobians.add(key, H); } }; /// Construct an execution trace for reverse AD - virtual boost::shared_ptr > reverse( + virtual boost::shared_ptr > traceExecution( const Values& values) const { boost::shared_ptr trace = boost::make_shared(); trace->t = value(values); @@ -363,19 +363,19 @@ public: boost::shared_ptr > trace1; Matrix H1; /// Return value and derivatives - virtual void update(const Matrix& H, JacobianMap& jacobians) const { + virtual void reverseAD(const Matrix& H, JacobianMap& jacobians) const { // This is a top-down calculation // The end-result needs Jacobians to all leaf nodes. // Since this is not a leaf node, we compute what is needed for leaf nodes here - trace1->update(H * H1, jacobians); + trace1->reverseAD(H * H1, jacobians); } }; /// Construct an execution trace for reverse AD - virtual boost::shared_ptr > reverse( + virtual boost::shared_ptr > traceExecution( const Values& values) const { boost::shared_ptr trace = boost::make_shared(); - trace->trace1 = this->expressionA_->reverse(values); + trace->trace1 = this->expressionA_->traceExecution(values); trace->t = function_(trace->trace1->value(), trace->H1); return trace; } @@ -446,22 +446,22 @@ public: boost::shared_ptr > trace2; Matrix H1, H2; /// Return value and derivatives - virtual void update(const Matrix& H, JacobianMap& jacobians) const { + virtual void reverseAD(const Matrix& H, JacobianMap& jacobians) const { // This is a top-down calculation // The end-result needs Jacobians to all leaf nodes. // Since this is not a leaf node, we compute what is needed for leaf nodes here // The binary node represents a fork in the tree, and hence we will get two Augmented maps - trace1->update(H * H1, jacobians); - trace2->update(H * H2, jacobians); + trace1->reverseAD(H * H1, jacobians); + trace2->reverseAD(H * H2, jacobians); } }; /// Construct an execution trace for reverse AD - virtual boost::shared_ptr > reverse( + virtual boost::shared_ptr > traceExecution( const Values& values) const { boost::shared_ptr trace = boost::make_shared(); - trace->trace1 = this->expressionA1_->reverse(values); - trace->trace2 = this->expressionA2_->reverse(values); + trace->trace1 = this->expressionA1_->traceExecution(values); + trace->trace2 = this->expressionA2_->traceExecution(values); trace->t = function_(trace->trace1->value(), trace->trace2->value(), trace->H1, trace->H2); return trace; diff --git a/gtsam_unstable/nonlinear/Expression.h b/gtsam_unstable/nonlinear/Expression.h index 709070d9b..f3653abdf 100644 --- a/gtsam_unstable/nonlinear/Expression.h +++ b/gtsam_unstable/nonlinear/Expression.h @@ -105,10 +105,10 @@ public: Augmented augmented(const Values& values) const { #define REVERSE_AD #ifdef REVERSE_AD - boost::shared_ptr > trace = root_->reverse(values); + boost::shared_ptr > trace = root_->traceExecution(values); Augmented augmented(trace->value()); size_t n = T::Dim(); - trace->update(Eigen::MatrixXd::Identity(n, n), augmented.jacobians()); + trace->reverseAD(Eigen::MatrixXd::Identity(n, n), augmented.jacobians()); return augmented; #else return root_->forward(values);