Finished constant Trace and *everything* just works!!! Amazing :-)

release/4.3a0
dellaert 2014-10-05 13:41:20 +02:00
parent 7c19542245
commit 8db2cd17fc
1 changed files with 15 additions and 3 deletions

View File

@ -205,10 +205,22 @@ public:
return Augmented<T>(constant_);
}
/// Trace structure for reverse AD
typedef typename ExpressionNode<T>::Trace BaseTrace;
struct Trace: public BaseTrace {
T t;
/// Return value and derivatives
virtual Augmented<T> augmented(const Matrix& H) const {
// Base case: just return value and empty map
return Augmented<T>(t);
}
};
/// Construct an execution trace for reverse AD
virtual boost::shared_ptr<typename ExpressionNode<T>::Trace> reverse(
const Values& values) const {
return boost::shared_ptr<typename ExpressionNode<T>::Trace>();
virtual boost::shared_ptr<BaseTrace> reverse(const Values& values) const {
boost::shared_ptr<Trace> trace = boost::make_shared<Trace>();
trace->t = constant_;
return trace;
}
};