Go to the documentation of this file.
31 class ExpressionFactorBinaryTest;
42 static_assert(
sizeof(
T) ==
sizeof(
size_t));
43 size_t & uiValue =
reinterpret_cast<size_t &
>(
value);
44 size_t misAlignment = uiValue % requiredAlignment;
46 uiValue += requiredAlignment - misAlignment;
65 class ExpressionNode {
83 virtual void print(
const std::string& indent =
"")
const = 0;
89 if (node.traceSize_ > 0)
os <<
", trace size = " << node.traceSize_;
95 virtual std::set<Key>
keys()
const {
101 virtual void dims(std::map<Key, int>& map)
const {
114 char* traceStorage)
const = 0;
139 void print(
const std::string& indent =
"")
const override {
140 std::cout << indent <<
"Constant" << std::endl;
150 char* traceStorage)
const override {
180 void print(
const std::string& indent =
"")
const override {
185 std::set<Key>
keys()
const override {
192 void dims(std::map<Key, int>& map)
const override {
203 char* traceStorage)
const override {
212 template<
class T,
class A>
218 template <
class T,
class A>
222 static const Eigen::IOFormat kMatlabFormat(0, 1,
" ",
"; ",
"",
"",
"[",
"]");
224 <<
") = " << dTdA.format(kMatlabFormat) << std::endl;
230 template<
class T,
class A1>
252 void print(
const std::string& indent =
"")
const override {
253 std::cout << indent <<
"UnaryExpression" << std::endl;
263 std::set<Key>
keys()
const override {
268 void dims(std::map<Key, int>& map)
const override {
284 void print(
const std::string& indent)
const {
285 std::cout << indent <<
"UnaryExpression::Record {" << std::endl;
286 PrintJacobianAndTrace<T,A1>(indent,
dTdA1,
trace1);
287 std::cout << indent <<
"}" << std::endl;
304 template<
typename MatrixType>
312 char* ptr)
const override {
335 template<
class T,
class A1,
class A2>
352 friend class ::ExpressionFactorBinaryTest;
361 void print(
const std::string& indent =
"")
const override {
362 std::cout << indent <<
"BinaryExpression" << std::endl;
375 std::set<Key>
keys()
const override {
378 keys.insert(myKeys.begin(), myKeys.end());
383 void dims(std::map<Key, int>& map)
const override {
408 void print(
const std::string& indent)
const {
409 std::cout << indent <<
"BinaryExpression::Record {" << std::endl;
410 PrintJacobianAndTrace<T,A1>(indent,
dTdA1,
trace1);
411 PrintJacobianAndTrace<T,A2>(indent,
dTdA2,
trace2);
412 std::cout << indent <<
"}" << std::endl;
422 template<
typename MatrixType>
431 char* ptr)
const override {
441 template<
class T,
class A1,
class A2,
class A3>
468 void print(
const std::string& indent =
"")
const override {
469 std::cout << indent <<
"TernaryExpression" << std::endl;
483 std::set<Key>
keys()
const override {
486 keys.insert(myKeys.begin(), myKeys.end());
488 keys.insert(myKeys.begin(), myKeys.end());
493 void dims(std::map<Key, int>& map)
const override {
525 void print(
const std::string& indent)
const {
526 std::cout << indent <<
"TernaryExpression::Record {" << std::endl;
527 PrintJacobianAndTrace<T,A1>(indent,
dTdA1,
trace1);
528 PrintJacobianAndTrace<T,A2>(indent,
dTdA2,
trace2);
529 PrintJacobianAndTrace<T,A3>(indent,
dTdA3,
trace3);
530 std::cout << indent <<
"}" << std::endl;
541 template<
typename MatrixType>
551 char* ptr)
const override {
580 void print(
const std::string& indent =
"")
const override {
581 std::cout << indent <<
"ScalarMultiplyNode" << std::endl;
591 std::set<Key>
keys()
const override {
596 void dims(std::map<Key, int>& map)
const override {
609 void print(
const std::string& indent)
const {
610 std::cout << indent <<
"ScalarMultiplyNode::Record {" << std::endl;
614 std::cout << indent <<
"}" << std::endl;
623 template <
typename MatrixType>
631 char* ptr)
const override {
668 void print(
const std::string& indent =
"")
const override {
669 std::cout << indent <<
"BinarySumNode" << std::endl;
680 std::set<Key>
keys()
const override {
683 keys.insert(myKeys.begin(), myKeys.end());
688 void dims(std::map<Key, int>& map)
const override {
699 void print(
const std::string& indent)
const {
700 std::cout << indent <<
"BinarySumNode::Record {" << std::endl;
703 std::cout << indent <<
"}" << std::endl;
709 trace1.startReverseAD1(jacobians);
710 trace2.startReverseAD1(jacobians);
714 template <
typename MatrixType>
717 trace1.reverseAD1(dFdT, jacobians);
718 trace2.reverseAD1(dFdT, jacobians);
724 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 Sun Dec 22 2024 04:11:32