Fixed creation of empty HessianFactor and added unit test

release/4.3a0
Richard Roberts 2012-01-20 16:53:35 +00:00
parent 9157d891d3
commit 5dd5f612ce
2 changed files with 9 additions and 1 deletions

View File

@ -65,6 +65,11 @@ HessianFactor::HessianFactor(const HessianFactor& gf) :
/* ************************************************************************* */
HessianFactor::HessianFactor() : info_(matrix_) {
// The empty HessianFactor has only a constant error term of zero
FastVector<size_t> dims;
dims.push_back(1);
info_.resize(dims.begin(), dims.end(), false);
info_(0,0)(0,0) = 0.0;
assertInvariants();
}

View File

@ -38,7 +38,10 @@ const double tol = 1e-5;
/* ************************************************************************* */
TEST(HessianFactor, emptyConstructor) {
HessianFactor f;
// f.print();
DOUBLES_EQUAL(0.0, f.constantTerm(), 1e-9); // Constant term should be zero
EXPECT(assert_equal(Vector(), f.linearTerm())); // Linear term should be empty
EXPECT(assert_equal(zeros(1,1), f.info())); // Full matrix should be 1-by-1 zero matrix
DOUBLES_EQUAL(0.0, f.error(VectorValues()), 1e-9); // Should have zero error
}
/* ************************************************************************* */