Evaluate ResidualBlocks without LossFunction if needed.
1. Add the ability to evaluate the problem without loss function.
2. Remove static Evaluator::Evaluate
3. Refactor the common code from problem_test.cc and
evaluator_test.cc into evaluator_test_utils.cc
Change-Id: I1aa841580afe91d288fbb65288b0ffdd1e43e827
diff --git a/internal/ceres/residual_block.cc b/internal/ceres/residual_block.cc
index 7f78960..b91b0ed 100644
--- a/internal/ceres/residual_block.cc
+++ b/internal/ceres/residual_block.cc
@@ -62,7 +62,8 @@
parameter_blocks_.get());
}
-bool ResidualBlock::Evaluate(double* cost,
+bool ResidualBlock::Evaluate(const bool apply_loss_function,
+ double* cost,
double* residuals,
double** jacobians,
double* scratch) const {
@@ -154,7 +155,7 @@
}
}
- if (loss_function_ == NULL) {
+ if (loss_function_ == NULL || !apply_loss_function) {
*cost = 0.5 * squared_norm;
return true;
}