Fix two bugs.
1. ProblemEvaluateResidualTest was leaking the loss_function in cases
where it was not being used.
2. Fix a grammo in rotation.h
Change-Id: If94ae1624033c8f6d1934dc2f40fa0dfe4e025c3
diff --git a/include/ceres/rotation.h b/include/ceres/rotation.h
index 71d64e2..8ba58ab 100644
--- a/include/ceres/rotation.h
+++ b/include/ceres/rotation.h
@@ -211,7 +211,7 @@
// xy = x cross y;
//
-// Inplace cross product is not support. The resulting vector x_cross_y must not
+// Inplace cross product is not supported. The resulting vector x_cross_y must not
// share the memory with the input vectors x and y, otherwise the result will be
// undefined.
template<typename T> inline
diff --git a/internal/ceres/problem_test.cc b/internal/ceres/problem_test.cc
index 03e8da7..3613dd6 100644
--- a/internal/ceres/problem_test.cc
+++ b/internal/ceres/problem_test.cc
@@ -1554,11 +1554,6 @@
static double kLossFunctionScale;
protected:
- void SetUp() {
- loss_function_ = new ScaledLoss(nullptr, 2.0, TAKE_OWNERSHIP);
- }
-
- LossFunction* loss_function_;
ProblemImpl problem_;
double x_[2] = {1, 2};
double y_[3] = {1, 2, 3};
@@ -1712,8 +1707,11 @@
}
TEST_F(ProblemEvaluateResidualBlockTest, OneResidualBlockWithLossFunction) {
- ResidualBlockId residual_block_id = problem_.AddResidualBlock(
- IdentityFunctor::Create(), loss_function_, x_, y_);
+ ResidualBlockId residual_block_id =
+ problem_.AddResidualBlock(IdentityFunctor::Create(),
+ new ScaledLoss(nullptr, 2.0, TAKE_OWNERSHIP),
+ x_,
+ y_);
Vector expected_f(5);
expected_f << 1, 2, 1, 2, 3;
expected_f *= std::sqrt(kLossFunctionScale);
@@ -1756,8 +1754,11 @@
TEST_F(ProblemEvaluateResidualBlockTest,
OneResidualBlockWithLossFunctionDisabled) {
- ResidualBlockId residual_block_id = problem_.AddResidualBlock(
- IdentityFunctor::Create(), loss_function_, x_, y_);
+ ResidualBlockId residual_block_id =
+ problem_.AddResidualBlock(IdentityFunctor::Create(),
+ new ScaledLoss(nullptr, 2.0, TAKE_OWNERSHIP),
+ x_,
+ y_);
Vector expected_f(5);
expected_f << 1, 2, 1, 2, 3;
Matrix expected_dfdx = Matrix::Zero(5, 2);