mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
Validate ParameterBlocks before solve.
Ensure that all parameter blocks have finite values before the minimizer is called. Change-Id: I15fd9c487247989626f799496bb8f5ea8728d6f0
This commit is contained in:
@@ -54,5 +54,22 @@ TEST(ArrayUtils, IsArrayValid) {
|
||||
EXPECT_FALSE(IsArrayValid(3, x));
|
||||
}
|
||||
|
||||
TEST(ArrayUtils, FindInvalidIndex) {
|
||||
double x[3];
|
||||
x[0] = 0.0;
|
||||
x[1] = 1.0;
|
||||
x[2] = 2.0;
|
||||
EXPECT_EQ(FindInvalidValue(3, x), 3);
|
||||
x[1] = std::numeric_limits<double>::infinity();
|
||||
EXPECT_EQ(FindInvalidValue(3, x), 1);
|
||||
x[1] = std::numeric_limits<double>::quiet_NaN();
|
||||
EXPECT_EQ(FindInvalidValue(3, x), 1);
|
||||
x[1] = std::numeric_limits<double>::signaling_NaN();
|
||||
EXPECT_EQ(FindInvalidValue(3, x), 1);
|
||||
EXPECT_EQ(FindInvalidValue(1, NULL), 1);
|
||||
InvalidateArray(3, x);
|
||||
EXPECT_EQ(FindInvalidValue(3, x), 0);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ceres
|
||||
|
||||
Reference in New Issue
Block a user