20 #include <gtsam/config.h> 25 #include <boost/type_traits/aligned_storage.hpp> 33 template<
int T>
struct CallRecord;
41 template<
bool UseBlock,
typename Derived>
46 jacobians(key).block<Derived::RowsAtCompileTime, Derived::ColsAtCompileTime>(
52 template<
typename Derived>
56 jacobians(key) += dTdA;
61 template<
typename Derived>
67 dTdA, jacobians, key);
123 void print(
const std::string& indent =
"")
const {
124 if (kind == Constant)
125 std::cout << indent <<
"Constant" << std::endl;
126 else if (kind == Leaf)
127 std::cout << indent <<
"Leaf, key = " <<
content.key << std::endl;
128 else if (kind == Function) {
129 content.ptr->print(indent +
" ");
134 template<
class Record>
136 if (kind != Function)
140 return p ? boost::optional<Record*>(
p) : boost::none;
151 static const JacobianTT
I = JacobianTT::Identity();
153 }
else if (kind == Function)
156 content.ptr->startReverseAD2(jacobians);
163 template<
typename DerivedMatrix>
168 else if (kind == Function)
169 content.ptr->reverseAD2(dTdA, jacobians);
173 if (kind == Function) {
174 content.ptr->~CallRecord<Dim>();
void print(const std::string &indent="") const
Print.
void reverseAD1(const Eigen::MatrixBase< DerivedMatrix > &dTdA, JacobianMap &jacobians) const
Either add to Jacobians (Leaf) or propagate (Function)
ExecutionTrace< T > type
Define type so we can apply it as a meta-function.
ExecutionTrace()
Pointer always starts out as a Constant.
JacobianMap for returning derivatives from expressions.
void handleLeafCase(const Eigen::MatrixBase< Derived > &dTdA, JacobianMap &jacobians, Key key)
Handle Leaf Case: reverse AD ends here, by writing a matrix into Jacobians.
boost::aligned_storage< 1, TraceAlignment >::type ExecutionTraceStorage
boost::optional< Record * > record()
Return record pointer, quite unsafe, used only for testing.
static void addToJacobian(const Eigen::MatrixBase< Derived > &dTdA, JacobianMap &jacobians, Key key)
Base class and basic functions for Manifold types.
void setFunction(CallRecord< Dim > *record)
Take ownership of pointer to a Function Record.
void startReverseAD1(JacobianMap &jacobians) const
Eigen::Matrix< double, Dim, Dim > JacobianTT
static const unsigned TraceAlignment
The matrix class, also used for vectors and row-vectors.
void setLeaf(Key key)
Change pointer to a Leaf Record.
Base class for all dense matrices, vectors, and expressions.
static void addToJacobian(const Eigen::MatrixBase< Derived > &dTdA, JacobianMap &jacobians, Key key)
std::uint64_t Key
Integer nonlinear key type.