More compact and informative trace/record printing
parent
2bc0d580e7
commit
4516c67389
|
@ -119,7 +119,6 @@ public:
|
||||||
else if (kind == Leaf)
|
else if (kind == Leaf)
|
||||||
std::cout << indent << "Leaf, key = " << content.key << std::endl;
|
std::cout << indent << "Leaf, key = " << content.key << std::endl;
|
||||||
else if (kind == Function) {
|
else if (kind == Function) {
|
||||||
std::cout << indent << "Function" << std::endl;
|
|
||||||
content.ptr->print(indent + " ");
|
content.ptr->print(indent + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,8 +211,16 @@ struct Jacobian {
|
||||||
typedef Eigen::Matrix<double, traits<T>::dimension, traits<A>::dimension> type;
|
typedef Eigen::Matrix<double, traits<T>::dimension, traits<A>::dimension> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Eigen format for printing Jacobians
|
// Helper function for printing Jacobians with compact Eigen format, and trace
|
||||||
|
template <class T, class A>
|
||||||
|
static void PrintJacobianAndTrace(const std::string& indent,
|
||||||
|
const typename Jacobian<T, A>::type& dTdA,
|
||||||
|
const ExecutionTrace<A> trace) {
|
||||||
static const Eigen::IOFormat kMatlabFormat(0, 1, " ", "; ", "", "", "[", "]");
|
static const Eigen::IOFormat kMatlabFormat(0, 1, " ", "; ", "", "", "[", "]");
|
||||||
|
std::cout << indent << "d(" << typeid(T).name() << ")/d(" << typeid(A).name()
|
||||||
|
<< ") = " << dTdA.format(kMatlabFormat) << std::endl;
|
||||||
|
trace.print(indent);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/// Unary Function Expression
|
/// Unary Function Expression
|
||||||
|
@ -268,8 +276,7 @@ public:
|
||||||
/// Print to std::cout
|
/// Print to std::cout
|
||||||
void print(const std::string& indent) const {
|
void print(const std::string& indent) const {
|
||||||
std::cout << indent << "UnaryExpression::Record {" << std::endl;
|
std::cout << indent << "UnaryExpression::Record {" << std::endl;
|
||||||
std::cout << indent << dTdA1.format(kMatlabFormat) << std::endl;
|
PrintJacobianAndTrace<T,A1>(indent, dTdA1, trace1);
|
||||||
trace1.print(indent);
|
|
||||||
std::cout << indent << "}" << std::endl;
|
std::cout << indent << "}" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,10 +395,8 @@ public:
|
||||||
/// Print to std::cout
|
/// Print to std::cout
|
||||||
void print(const std::string& indent) const {
|
void print(const std::string& indent) const {
|
||||||
std::cout << indent << "BinaryExpression::Record {" << std::endl;
|
std::cout << indent << "BinaryExpression::Record {" << std::endl;
|
||||||
std::cout << indent << dTdA1.format(kMatlabFormat) << std::endl;
|
PrintJacobianAndTrace<T,A1>(indent, dTdA1, trace1);
|
||||||
trace1.print(indent);
|
PrintJacobianAndTrace<T,A2>(indent, dTdA2, trace2);
|
||||||
std::cout << indent << dTdA2.format(kMatlabFormat) << std::endl;
|
|
||||||
trace2.print(indent);
|
|
||||||
std::cout << indent << "}" << std::endl;
|
std::cout << indent << "}" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,12 +507,9 @@ public:
|
||||||
/// Print to std::cout
|
/// Print to std::cout
|
||||||
void print(const std::string& indent) const {
|
void print(const std::string& indent) const {
|
||||||
std::cout << indent << "TernaryExpression::Record {" << std::endl;
|
std::cout << indent << "TernaryExpression::Record {" << std::endl;
|
||||||
std::cout << indent << dTdA1.format(kMatlabFormat) << std::endl;
|
PrintJacobianAndTrace<T,A1>(indent, dTdA1, trace1);
|
||||||
trace1.print(indent);
|
PrintJacobianAndTrace<T,A2>(indent, dTdA2, trace2);
|
||||||
std::cout << indent << dTdA2.format(kMatlabFormat) << std::endl;
|
PrintJacobianAndTrace<T,A3>(indent, dTdA3, trace3);
|
||||||
trace2.print(indent);
|
|
||||||
std::cout << indent << dTdA3.format(kMatlabFormat) << std::endl;
|
|
||||||
trace3.print(indent);
|
|
||||||
std::cout << indent << "}" << std::endl;
|
std::cout << indent << "}" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue