diff --git a/examples/Data/pose3example-offdiagonal-rewritten.txt b/examples/Data/pose3example-offdiagonal-rewritten.txt index b99d266aa..a855eff4d 100644 --- a/examples/Data/pose3example-offdiagonal-rewritten.txt +++ b/examples/Data/pose3example-offdiagonal-rewritten.txt @@ -1,3 +1 @@ -VERTEX_SE3:QUAT 0 0 0 0 0 0 0 1 -VERTEX_SE3:QUAT 1 1.00137 0.01539 0.004948 0.190253 0.283162 -0.392318 0.85423 EDGE_SE3:QUAT 0 1 1.00137 0.01539 0.004948 0.190253 0.283162 -0.392318 0.85423 10000 1 1 1 1 1 10000 2 2 2 2 10000 3 3 3 10000 4 4 10000 5 10000 diff --git a/examples/Data/pose3example-rewritten.txt b/examples/Data/pose3example-rewritten.txt index 6d342fcb0..d445fa96c 100644 --- a/examples/Data/pose3example-rewritten.txt +++ b/examples/Data/pose3example-rewritten.txt @@ -1,8 +1,3 @@ -VERTEX_SE3:QUAT 0 0 0 0 0 0 0 1 -VERTEX_SE3:QUAT 1 1.00137 0.01539 0.004948 0.190253 0.283162 -0.392318 0.85423 -VERTEX_SE3:QUAT 2 1.9935 0.023275 0.003793 0.351729 0.597838 -0.584174 -0.421446 -VERTEX_SE3:QUAT 3 2.00429 1.02431 0.018047 0.331798 -0.200659 0.919323 0.067024 -VERTEX_SE3:QUAT 4 0.999908 1.05507 0.020212 -0.035697 -0.46249 0.445933 0.765488 EDGE_SE3:QUAT 0 1 1.00137 0.01539 0.004948 0.190253 0.283162 -0.392318 0.85423 10000 0 0 0 0 0 10000 0 0 0 0 10000 0 0 0 10000 0 0 10000 0 10000 EDGE_SE3:QUAT 1 2 0.523923 0.776654 0.326659 -0.311512 -0.656877 0.678505 -0.105373 10000 0 0 0 0 0 10000 0 0 0 0 10000 0 0 0 10000 0 0 10000 0 10000 EDGE_SE3:QUAT 2 3 0.910927 0.055169 -0.411761 0.595795 -0.561677 0.079353 0.568551 10000 0 0 0 0 0 10000 0 0 0 0 10000 0 0 0 10000 0 0 10000 0 10000 diff --git a/gtsam/nonlinear/tests/testValues.cpp b/gtsam/nonlinear/tests/testValues.cpp index a8b7b612f..5d82891dc 100644 --- a/gtsam/nonlinear/tests/testValues.cpp +++ b/gtsam/nonlinear/tests/testValues.cpp @@ -54,9 +54,9 @@ int TestValueData::DestructorCount = 0; class TestValue { TestValueData data_; public: - virtual void print(const std::string& str = "") const {} + void print(const std::string& str = "") const {} bool equals(const TestValue& other, double tol = 1e-9) const { return true; } - virtual size_t dim() const { return 0; } + size_t dim() const { return 0; } TestValue retract(const Vector&) const { return TestValue(); } Vector localCoordinates(const TestValue&) const { return Vector(); } }; @@ -353,12 +353,12 @@ TEST(Values, filter) { BOOST_FOREACH(const Values::Filtered<>::KeyValuePair& key_value, filtered) { if(i == 0) { LONGS_EQUAL(2, (long)key_value.key); - EXPECT(typeid(Pose2) == typeid(key_value.value)); - EXPECT(assert_equal(pose2, dynamic_cast(key_value.value))); + EXPECT(typeid(GenericValue) == typeid(key_value.value)); + EXPECT(assert_equal(pose2, dynamic_cast&>(key_value.value).value())); } else if(i == 1) { LONGS_EQUAL(3, (long)key_value.key); - EXPECT(typeid(Pose3) == typeid(key_value.value)); - EXPECT(assert_equal(pose3, dynamic_cast(key_value.value))); + EXPECT(typeid(GenericValue) == typeid(key_value.value)); + EXPECT(assert_equal(pose3, dynamic_cast&>(key_value.value).value())); } else { EXPECT(false); } @@ -416,10 +416,10 @@ TEST(Values, Symbol_filter) { BOOST_FOREACH(const Values::Filtered::KeyValuePair& key_value, values.filter(Symbol::ChrTest('y'))) { if(i == 0) { LONGS_EQUAL(Symbol('y', 1), (long)key_value.key); - EXPECT(assert_equal(pose1, dynamic_cast(key_value.value))); + EXPECT(assert_equal(pose1, dynamic_cast&>(key_value.value).value())); } else if(i == 1) { LONGS_EQUAL(Symbol('y', 3), (long)key_value.key); - EXPECT(assert_equal(pose3, dynamic_cast(key_value.value))); + EXPECT(assert_equal(pose3, dynamic_cast&>(key_value.value).value())); } else { EXPECT(false); } @@ -441,11 +441,15 @@ TEST(Values, Destructors) { values.insert(0, value1); values.insert(1, value2); } - LONGS_EQUAL(4, (long)TestValueData::ConstructorCount); - LONGS_EQUAL(2, (long)TestValueData::DestructorCount); + // additional 2 con/destructor counts for the temporary + // GenericValue in insert() + // but I'm sure some advanced programmer can figure out + // a way to avoid the temporary, or optimize it out + LONGS_EQUAL(4+2, (long)TestValueData::ConstructorCount); + LONGS_EQUAL(2+2, (long)TestValueData::DestructorCount); } - LONGS_EQUAL(4, (long)TestValueData::ConstructorCount); - LONGS_EQUAL(4, (long)TestValueData::DestructorCount); + LONGS_EQUAL(4+2, (long)TestValueData::ConstructorCount); + LONGS_EQUAL(4+2, (long)TestValueData::DestructorCount); } /* ************************************************************************* */ diff --git a/gtsam_unstable/nonlinear/tests/testAdaptAutoDiff.cpp b/gtsam_unstable/nonlinear/tests/testAdaptAutoDiff.cpp index dc07c4b46..0c9046d6c 100644 --- a/gtsam_unstable/nonlinear/tests/testAdaptAutoDiff.cpp +++ b/gtsam_unstable/nonlinear/tests/testAdaptAutoDiff.cpp @@ -202,7 +202,7 @@ TEST(Expression, Snavely) { #ifdef GTSAM_USE_QUATERNIONS EXPECT_LONGS_EQUAL(480,expression.traceSize()); // Todo, should be zero #else - EXPECT_LONGS_EQUAL(528,expression.traceSize()); // Todo, should be zero + EXPECT_LONGS_EQUAL(432,expression.traceSize()); // Todo, should be zero #endif set expected = list_of(1)(2); EXPECT(expected == expression.keys()); diff --git a/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp b/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp index c063f182f..a320ebc5a 100644 --- a/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp +++ b/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp @@ -144,19 +144,19 @@ TEST(ExpressionFactor, Binary) { // traceRaw will fill raw with [Trace | Binary::Record] EXPECT_LONGS_EQUAL(8, sizeof(double)); - EXPECT_LONGS_EQUAL(24, sizeof(Point2)); - EXPECT_LONGS_EQUAL(48, sizeof(Cal3_S2)); + EXPECT_LONGS_EQUAL(16, sizeof(Point2)); + EXPECT_LONGS_EQUAL(40, sizeof(Cal3_S2)); EXPECT_LONGS_EQUAL(16, sizeof(ExecutionTrace)); EXPECT_LONGS_EQUAL(16, sizeof(ExecutionTrace)); EXPECT_LONGS_EQUAL(2*5*8, sizeof(Jacobian::type)); EXPECT_LONGS_EQUAL(2*2*8, sizeof(Jacobian::type)); - size_t expectedRecordSize = 24 + 24 + 48 + 2 * 16 + 80 + 32; - EXPECT_LONGS_EQUAL(expectedRecordSize, sizeof(Binary::Record)); + size_t expectedRecordSize = 16 + 16 + 40 + 2 * 16 + 80 + 32; + EXPECT_LONGS_EQUAL(expectedRecordSize + 8, sizeof(Binary::Record)); // Check size size_t size = binary.traceSize(); CHECK(size); - EXPECT_LONGS_EQUAL(expectedRecordSize, size); + EXPECT_LONGS_EQUAL(expectedRecordSize + 8, size); // Use Variable Length Array, allocated on stack by gcc // Note unclear for Clang: http://clang.llvm.org/compatibility.html#vla char raw[size]; @@ -208,8 +208,8 @@ TEST(ExpressionFactor, Shallow) { EXPECT_LONGS_EQUAL(464, sizeof(Binary::Record)); LONGS_EQUAL(112+464, expectedTraceSize); #else - EXPECT_LONGS_EQUAL(496, sizeof(Binary::Record)); - LONGS_EQUAL(112+496, expectedTraceSize); + EXPECT_LONGS_EQUAL(400, sizeof(Binary::Record)); + LONGS_EQUAL(112+400, expectedTraceSize); #endif size_t size = expression.traceSize(); CHECK(size);