Testing old trace

release/4.3a0
dellaert 2014-10-11 08:41:39 +02:00
parent 820e9553ee
commit 52fc6f2db4
2 changed files with 31 additions and 2 deletions

View File

@ -91,6 +91,12 @@ public:
type = Function;
content.ptr = record;
}
/// Return record pointer, highly unsafe, used only for testing
boost::optional<CallRecord<T>*> record() {
return
(type == Function) ? boost::optional<CallRecord<T>*>(content.ptr) :
boost::none;
}
// *** This is the main entry point for reverseAD, called from Expression::augmented ***
// Called only once, either inserts identity into Jacobians (Leaf) or starts AD (Function)
void startReverseAD(JacobianMap& jacobians) const {
@ -485,7 +491,7 @@ private:
function_(f), expressionA1_(e1.root()), expressionA2_(e2.root()) {
}
friend class Expression<T>;
friend class Expression<T> ;
friend struct ::TestBinaryExpression;
public:

View File

@ -122,9 +122,32 @@ struct TestBinaryExpression {
/* ************************************************************************* */
// Binary(Leaf,Leaf)
TEST(ExpressionFactor, binary) {
TestBinaryExpression tester;
// Create some values
Values values;
values.insert(1, Cal3_S2());
values.insert(2, Point2(0, 0));
// Do old trace
ExecutionTrace<Point2> trace;
tester.binary_.traceExecution(values, trace);
// Extract record :-(
boost::optional<CallRecord<Point2>*> r = trace.record();
CHECK(r);
typedef BinaryExpression<Point2, Cal3_S2, Point2> Binary;
Binary::Record* p = dynamic_cast<Binary::Record*>(*r);
CHECK(p);
// Check matrices
Matrix25 expected25;
expected25 << 0, 0, 0, 1, 0, 0, 0, 0, 0, 1;
EXPECT( assert_equal(expected25, (Matrix)p->dTdA1, 1e-9));
Matrix2 expected22;
expected22 << 1, 0, 0, 1;
EXPECT( assert_equal(expected22, (Matrix)p->dTdA2, 1e-9));
// Check raw memory trace
}
/* ************************************************************************* */