Go to the documentation of this file.
30 class ExpressionFactorBinaryTest;
41 static_assert(
sizeof(
T) ==
sizeof(
size_t));
42 size_t & uiValue =
reinterpret_cast<size_t &
>(
value);
43 size_t misAlignment = uiValue % requiredAlignment;
45 uiValue += requiredAlignment - misAlignment;
64 class ExpressionNode {
82 virtual void print(
const std::string& indent =
"")
const = 0;
88 if (node.traceSize_ > 0)
os <<
", trace size = " << node.traceSize_;
94 virtual std::set<Key>
keys()
const {
100 virtual void dims(std::map<Key, int>& map)
const {
113 char* traceStorage)
const = 0;
138 void print(
const std::string& indent =
"")
const override {
139 std::cout << indent <<
"Constant" << std::endl;
149 char* traceStorage)
const override {
179 void print(
const std::string& indent =
"")
const override {
184 std::set<Key>
keys()
const override {
191 void dims(std::map<Key, int>& map)
const override {
202 char* traceStorage)
const override {
211 template<
class T,
class A>
217 template <
class T,
class A>
221 static const Eigen::IOFormat kMatlabFormat(0, 1,
" ",
"; ",
"",
"",
"[",
"]");
223 <<
") = " << dTdA.format(kMatlabFormat) << std::endl;
229 template<
class T,
class A1>
251 void print(
const std::string& indent =
"")
const override {
252 std::cout << indent <<
"UnaryExpression" << std::endl;
262 std::set<Key>
keys()
const override {
267 void dims(std::map<Key, int>& map)
const override {
283 void print(
const std::string& indent)
const {
284 std::cout << indent <<
"UnaryExpression::Record {" << std::endl;
285 PrintJacobianAndTrace<T,A1>(indent,
dTdA1,
trace1);
286 std::cout << indent <<
"}" << std::endl;
303 template<
typename MatrixType>
311 char* ptr)
const override {
334 template<
class T,
class A1,
class A2>
351 friend class ::ExpressionFactorBinaryTest;
360 void print(
const std::string& indent =
"")
const override {
361 std::cout << indent <<
"BinaryExpression" << std::endl;
374 std::set<Key>
keys()
const override {
377 keys.insert(myKeys.begin(), myKeys.end());
382 void dims(std::map<Key, int>& map)
const override {
407 void print(
const std::string& indent)
const {
408 std::cout << indent <<
"BinaryExpression::Record {" << std::endl;
409 PrintJacobianAndTrace<T,A1>(indent,
dTdA1,
trace1);
410 PrintJacobianAndTrace<T,A2>(indent,
dTdA2,
trace2);
411 std::cout << indent <<
"}" << std::endl;
421 template<
typename MatrixType>
430 char* ptr)
const override {
440 template<
class T,
class A1,
class A2,
class A3>
467 void print(
const std::string& indent =
"")
const override {
468 std::cout << indent <<
"TernaryExpression" << std::endl;
482 std::set<Key>
keys()
const override {
485 keys.insert(myKeys.begin(), myKeys.end());
487 keys.insert(myKeys.begin(), myKeys.end());
492 void dims(std::map<Key, int>& map)
const override {
524 void print(
const std::string& indent)
const {
525 std::cout << indent <<
"TernaryExpression::Record {" << std::endl;
526 PrintJacobianAndTrace<T,A1>(indent,
dTdA1,
trace1);
527 PrintJacobianAndTrace<T,A2>(indent,
dTdA2,
trace2);
528 PrintJacobianAndTrace<T,A3>(indent,
dTdA3,
trace3);
529 std::cout << indent <<
"}" << std::endl;
540 template<
typename MatrixType>
550 char* ptr)
const override {
579 void print(
const std::string& indent =
"")
const override {
580 std::cout << indent <<
"ScalarMultiplyNode" << std::endl;
590 std::set<Key>
keys()
const override {
595 void dims(std::map<Key, int>& map)
const override {
608 void print(
const std::string& indent)
const {
609 std::cout << indent <<
"ScalarMultiplyNode::Record {" << std::endl;
613 std::cout << indent <<
"}" << std::endl;
622 template <
typename MatrixType>
630 char* ptr)
const override {
667 void print(
const std::string& indent =
"")
const override {
668 std::cout << indent <<
"BinarySumNode" << std::endl;
679 std::set<Key>
keys()
const override {
682 keys.insert(myKeys.begin(), myKeys.end());
687 void dims(std::map<Key, int>& map)
const override {
698 void print(
const std::string& indent)
const {
699 std::cout << indent <<
"BinarySumNode::Record {" << std::endl;
702 std::cout << indent <<
"}" << std::endl;
708 trace1.startReverseAD1(jacobians);
709 trace2.startReverseAD1(jacobians);
713 template <
typename MatrixType>
716 trace1.reverseAD1(dFdT, jacobians);
717 trace2.reverseAD1(dFdT, jacobians);
723 char* ptr)
const override {
ExecutionTrace< A1 > trace1
ExecutionTrace< T > trace1
UnaryExpression(Function f, const Expression< A1 > &e1)
Constructor with a unary function f, and input argument e1.
std::set< Key > keys() const override
Return keys that play in this expression.
void setLeaf(Key key)
Change pointer to a Leaf Record.
void startReverseAD4(JacobianMap &jacobians) const
If the BinarySumExpression is the root, we just start as many pipelines as there are terms.
Jacobian< T, A1 >::type dTdA1
void reverseAD4(const MatrixType &dFdT, JacobianMap &jacobians) const
Given df/dT, multiply in dT/dA and continue reverse AD process.
virtual void dims(std::map< Key, int > &map) const
Return dimensions for each argument, as a map.
virtual ~ExpressionNode()
Destructor.
Eigen::Matrix< double, traits< T >::dimension, traits< A >::dimension > type
Array< double, 1, 3 > e(1./3., 0.5, 2.)
ExecutionTrace< A1 > trace1
std::shared_ptr< ExpressionNode< T > > expression_
virtual T traceExecution(const Values &values, ExecutionTrace< T > &trace, char *traceStorage) const =0
Construct an execution trace for reverse AD.
void print(const std::string &indent="") const override
Print.
static const unsigned TraceAlignment
GTSAM_EXPORT friend std::ostream & operator<<(std::ostream &os, const ExpressionNode &node)
Streaming.
Jacobian< T, A2 >::type dTdA2
void dims(std::map< Key, int > &map) const override
Return dimensions for each argument.
std::set< Key > keys() const override
Return keys that play in this expression.
void dims(std::map< Key, int > &map) const override
Return dimensions for each argument.
Unary Function Expression.
std::shared_ptr< ExpressionNode< T > > expression1_
void print(const std::string &indent="") const override
Print.
void print(const std::string &indent="") const override
Print.
T upAligned(T value, unsigned requiredAlignment=TraceAlignment)
std::set< Key > keys() const override
Return keys that play in this expression.
std::shared_ptr< ExpressionNode< A2 > > expression2_
T value(const Values &values) const override
Return value.
void reverseAD1(const Eigen::MatrixBase< DerivedMatrix > &dTdA, JacobianMap &jacobians) const
Either add to Jacobians (Leaf) or propagate (Function)
void dims(std::map< Key, int > &map) const override
Return dimensions for each argument.
std::set< Key > keys() const override
Return keys that play in this expression.
T traceExecution(const Values &values, ExecutionTrace< T > &trace, char *ptr) const override
Construct an execution trace for reverse AD.
void startReverseAD4(JacobianMap &jacobians) const
Start the reverse AD process.
~BinarySumNode() override
Destructor.
ExecutionTrace< A1 > trace1
ofstream os("timeSchurFactors.csv")
Key key_
The key into values.
BinaryExpression(Function f, const Expression< A1 > &e1, const Expression< A2 > &e2)
Constructor with a binary function f, and two input arguments.
~UnaryExpression() override
Destructor.
T value(const Values &values) const override
Return value.
ExecutionTrace< A2 > trace2
Execution trace for expressions.
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
T traceExecution(const Values &values, ExecutionTrace< T > &trace, char *ptr) const override
Construct an execution trace for reverse AD, see UnaryExpression for explanation.
~TernaryExpression() override
Destructor.
std::set< Key > keys() const override
Return keys that play in this expression.
void print(const std::string &indent="") const override
Print.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Jacobian< T, A1 >::type dTdA1
std::shared_ptr< ExpressionNode< A2 > > expression2_
void dims(std::map< Key, int > &map) const override
Return dimensions for each argument.
Record(const Values &values, const ExpressionNode< A1 > &expression1, const ExpressionNode< A2 > &expression2, const ExpressionNode< A3 > &expression3, char *ptr)
Construct record by calling 3 argument expressions.
LeafExpression(Key key)
Constructor with a single key.
void startReverseAD4(JacobianMap &jacobians) const
Start the reverse AD process, see comments in UnaryExpression.
void reverseAD4(const MatrixType &dFdT, JacobianMap &jacobians) const
If we are not the root, we simply pass on the adjoint matrix dFdT to all terms.
Record(const Values &values, const ExpressionNode< A1 > &expression1, char *ptr)
Construct record by calling argument expression.
static void PrintJacobianAndTrace(const std::string &indent, const typename Jacobian< T, A >::type &dTdA, const ExecutionTrace< A > trace)
Expression for scalar multiplication.
TernaryExpression(Function f, const Expression< A1 > &e1, const Expression< A2 > &e2, const Expression< A3 > &e3)
Constructor with a ternary function f, and two input arguments.
~ConstantExpression() override
Destructor.
T value(const Values &values) const override
Return value.
Jacobian< T, A3 >::type dTdA3
Jacobian< T, A2 >::type dTdA2
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW
void print(const std::string &indent="") const
Print.
std::shared_ptr< ExpressionNode< A1 > > expression1_
void print(const std::string &indent) const
Print to std::cout.
void startReverseAD4(JacobianMap &jacobians) const
Start the reverse AD process.
const gtsam::Symbol key('X', 0)
ExecutionTrace< A2 > trace2
void print(const std::string &indent="") const override
Print.
virtual void print(const std::string &indent="") const =0
Print.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
void reverseAD4(const MatrixType &dFdT, JacobianMap &jacobians) const
Given df/dT, multiply in dT/dA and continue reverse AD process.
void reverseAD4(const MatrixType &dFdT, JacobianMap &jacobians) const
Given df/dT, multiply in dT/dA and continue reverse AD process.
T traceExecution(const Values &values, ExecutionTrace< T > &trace, char *traceStorage) const override
Construct an execution trace for reverse AD.
T value(const Values &values) const override
Return value.
virtual T value(const Values &values) const =0
Return value.
BinarySumNode(const Expression< T > &e1, const Expression< T > &e2)
Constructor with a binary function f, and two input arguments.
void startReverseAD4(JacobianMap &jacobians) const
Start the reverse AD process, see comments in Base.
ExecutionTrace< A3 > trace3
ExecutionTrace< T > trace
std::string demangle(const char *name)
Pretty print Value type name.
size_t traceSize() const
Return size needed for memory buffer in traceExecution.
T value(const Values &values) const override
Return value.
virtual std::set< Key > keys() const
Return keys that play in this expression as a set.
void print(const std::string &indent) const
Print to std::cout.
void setFunction(CallRecord< Dim > *record)
Take ownership of pointer to a Function Record.
Expression< T >::template UnaryFunction< A1 >::type Function
std::shared_ptr< ExpressionNode< T > > expression2_
Leaf Expression, if no chart is given, assume default chart and value_type is just the plain value.
T traceExecution(const Values &values, ExecutionTrace< T > &trace, char *ptr) const override
Construct an execution trace for reverse AD.
std::shared_ptr< ExpressionNode< A1 > > expression1_
~LeafExpression() override
Destructor.
~ScalarMultiplyNode() override
Destructor.
void print(const std::string &indent="") const override
Print.
ConstantExpression(const T &value)
Constructor with a value, yielding a constant.
The matrix class, also used for vectors and row-vectors.
T & upAlign(T &value, unsigned requiredAlignment=TraceAlignment)
Eigen::Matrix< double, Dim, Dim > JacobianTT
Expression< T >::template BinaryFunction< A1, A2 >::type Function
ExpressionNode< T > NodeT
meta-function to generate fixed-size JacobianTA type
Jacobian< T, A1 >::type dTdA1
T traceExecution(const Values &values, ExecutionTrace< T > &trace, char *traceStorage) const override
Construct an execution trace for reverse AD.
T value(const Values &values) const override
Return value.
void print(const std::string &indent) const
Print to std::cout.
std::uint64_t Key
Integer nonlinear key type.
void dims(std::map< Key, int > &map) const override
Return dimensions for each argument.
Expression< T >::template TernaryFunction< A1, A2, A3 >::type Function
ScalarMultiplyNode(double s, const Expression< T > &e)
Constructor with a unary function f, and input argument e1.
Record(const Values &values, const ExpressionNode< A1 > &expression1, const ExpressionNode< A2 > &expression2, char *ptr)
Construct record by calling argument expressions.
T traceExecution(const Values &values, ExecutionTrace< T > &trace, char *ptr) const override
Construct an execution trace for reverse AD, see UnaryExpression for explanation.
std::set< Key > keys() const override
Return keys that play in this expression.
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW
void reverseAD4(const MatrixType &dFdT, JacobianMap &jacobians) const
Given df/dT, multiply in dT/dA and continue reverse AD process.
ExecutionTrace< T > trace2
~BinaryExpression() override
Destructor.
T constant_
The constant value.
void print(const std::string &indent) const
Print to std::cout.
T value(const Values &values) const override
Return value.
GTSAM_CONCEPT_ASSERT(IsVectorSpace< T >)
ExpressionNode(size_t traceSize=0)
Constructor, traceSize is size of the execution trace of expression rooted here.
T traceExecution(const Values &values, ExecutionTrace< T > &trace, char *ptr) const override
Construct an execution trace for reverse AD.
void print(const std::string &indent) const
Print to std::cout.
A non-templated config holding any types of Manifold-group elements.
void dims(std::map< Key, int > &map) const override
Return dimensions for each argument.
std::shared_ptr< ExpressionNode< A1 > > expression1_
void print(const std::string &indent="") const override
Print.
std::shared_ptr< ExpressionNode< A3 > > expression3_
Internals for Expression.h, not for general consumption.
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:17