21 #include <gtsam/config.h> 31 #include <type_traits> 36 template<
int T>
struct CallRecord;
45 static const unsigned TraceAlignment = 32;
50 template<
bool UseBlock,
typename Derived>
55 jacobians(key).block<Derived::RowsAtCompileTime, Derived::ColsAtCompileTime>(
61 template<
typename Derived>
65 jacobians(key) += dTdA;
70 template<
typename Derived>
76 dTdA, jacobians, key);
128 content.ptr = record;
132 void print(
const std::string& indent =
"")
const {
133 if (kind == Constant) {
134 std::cout << indent <<
"Constant" << std::endl;
135 }
else if (kind ==
Leaf) {
136 std::cout << indent <<
"Leaf, key = " << content.key << std::endl;
137 }
else if (kind == Function) {
138 content.ptr->print(indent +
" ");
143 template<
class Record>
145 if (kind != Function) {
149 return p ? std::optional<Record*>(
p) : std::nullopt;
160 static const JacobianTT
I = JacobianTT::Identity();
162 }
else if (kind == Function) {
165 content.ptr->startReverseAD2(jacobians);
173 template<
typename DerivedMatrix>
178 else if (kind == Function)
179 content.ptr->reverseAD2(dTdA, jacobians);
183 if (kind == Function) {
184 content.ptr->~CallRecord<Dim>();
const gtsam::Symbol key('X', 0)
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.
void reverseAD1(const Eigen::MatrixBase< DerivedMatrix > &dTdA, JacobianMap &jacobians) const
Either add to Jacobians (Leaf) or propagate (Function)
void startReverseAD1(JacobianMap &jacobians) const
static void addToJacobian(const Eigen::MatrixBase< Derived > &dTdA, JacobianMap &jacobians, Key key)
Base class and basic functions for Manifold types.
static sharedNode Leaf(Key key, const SymbolicFactorGraph &factors)
std::aligned_storage< 1, TraceAlignment >::type ExecutionTraceStorage
void print(const std::string &indent="") const
Print.
void setFunction(CallRecord< Dim > *record)
Take ownership of pointer to a Function Record.
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.
std::optional< Record * > record()
Return record pointer, quite unsafe, used only for testing.