Support varying numbers of residuals in autodiff.
This commit modifies the only function in autodiff that takes a
templated number of outputs (i.e. residuals) and makes that
template parameter a normal parameter. With that change, it
is a trivial matter to support a dynamic number of residuals.
The API for dynamic residuals is to pass a fake number of
residuals as the second template argument to
AutoDiffCostFunction, and to pass the real number of
parameters as a second constructor argument.
diff --git a/internal/ceres/local_parameterization_test.cc b/internal/ceres/local_parameterization_test.cc
index 1533884..26a57c1 100644
--- a/internal/ceres/local_parameterization_test.cc
+++ b/internal/ceres/local_parameterization_test.cc
@@ -176,8 +176,8 @@
double* jacobian_array[2] = { NULL, jacobian_ref };
// Autodiff jacobian at delta_x = 0.
- internal::AutoDiff<QuaternionPlus, double, 4, 4, 3>::Differentiate(
- QuaternionPlus(), parameters, x_plus_delta, jacobian_array);
+ internal::AutoDiff<QuaternionPlus, double, 4, 3>::Differentiate(
+ QuaternionPlus(), parameters, 4, x_plus_delta, jacobian_array);
double jacobian[12];
param.ComputeJacobian(x, jacobian);