Speed up corrector.cc
Remove the Eigen temporary by revealing the columnwise nature
of the computation. This also allows us to get rid of the
special case for nrow = 1.
On problem-356-226730-pre.txt with -robustify evaluation times
change from:
Before:
Residual Evaluations 1.015
Jacobian Evaluations 18.313
After:
Residual Evaluations 1.005
Jacobian Evaluations 8.382
To give a sense of the overhead reduction, compare these numbers
when loss functions are disabled.
Residual Evaluations 0.955
Jacobian Evaluations 7.772
So, this is a 17.5x speedup!
The one dimensional specialization was motivated by denoising.cc.
The evaluation times there are essentially unchanged.
Before:
Residual Evaluations 2.774
Jacobian Evaluations 20.178
After:
Residual Evaluations 2.588
Jacobian Evaluations 19.781
Change-Id: Ic0efbaed75fe4489635039f17189ae24b97802c8
diff --git a/internal/ceres/corrector.h b/internal/ceres/corrector.h
index 9914641..2137221 100644
--- a/internal/ceres/corrector.h
+++ b/internal/ceres/corrector.h
@@ -66,7 +66,7 @@
explicit Corrector(double sq_norm, const double rho[3]);
// residuals *= sqrt(rho[1]) / (1 - alpha)
- void CorrectResiduals(int nrow, double* residuals);
+ void CorrectResiduals(int num_rows, double* residuals);
// jacobian = sqrt(rho[1]) * jacobian -
// sqrt(rho[1]) * alpha / sq_norm * residuals residuals' * jacobian.
@@ -74,8 +74,10 @@
// The method assumes that the jacobian has row-major storage. It is
// the caller's responsibility to ensure that the pointer to
// jacobian is not null.
- void CorrectJacobian(int nrow, int ncol,
- double* residuals, double* jacobian);
+ void CorrectJacobian(int num_rows,
+ int num_cols,
+ double* residuals,
+ double* jacobian);
private:
double sqrt_rho1_;