diff --git a/include/ceres/internal/numeric_diff.h b/include/ceres/internal/numeric_diff.h index 504834856..3b264b45a 100644 --- a/include/ceres/internal/numeric_diff.h +++ b/include/ceres/internal/numeric_diff.h @@ -103,14 +103,17 @@ struct NumericDiff { typedef Matrix ResidualVector; typedef Matrix ParameterVector; + + // The convoluted reasoning for choosing the Row/Column major + // ordering of the matrix is an artifact of the restrictions in + // Eigen that prevent it from creating RowMajor matrices with a + // single column. In these cases, we ask for a ColMajor matrix. typedef Matrix 1) ? ColMajor : RowMajor> + (kParameterBlockSize == 1) ? ColMajor : RowMajor> JacobianMatrix; - Map parameter_jacobian(jacobian, NUM_RESIDUALS, kParameterBlockSize); diff --git a/internal/ceres/numeric_diff_cost_function_test.cc b/internal/ceres/numeric_diff_cost_function_test.cc index 422c712ab..b3d8817ef 100644 --- a/internal/ceres/numeric_diff_cost_function_test.cc +++ b/internal/ceres/numeric_diff_cost_function_test.cc @@ -182,6 +182,30 @@ TEST(NumericDiffCostFunction, EigenRowMajorColMajorTest) { cost_function.reset( new NumericDiffCostFunction, CENTRAL, 2, 2>( new SizeTestingCostFunction<2,2>, ceres::TAKE_OWNERSHIP)); + + cost_function.reset( + new NumericDiffCostFunction( + new EasyFunctor, TAKE_OWNERSHIP, 1)); + + cost_function.reset( + new NumericDiffCostFunction( + new EasyFunctor, TAKE_OWNERSHIP, 2)); + + cost_function.reset( + new NumericDiffCostFunction( + new EasyFunctor, TAKE_OWNERSHIP, 1)); + + cost_function.reset( + new NumericDiffCostFunction( + new EasyFunctor, TAKE_OWNERSHIP, 2)); + + cost_function.reset( + new NumericDiffCostFunction( + new EasyFunctor, TAKE_OWNERSHIP, 1)); + + cost_function.reset( + new NumericDiffCostFunction( + new EasyFunctor, TAKE_OWNERSHIP, 2)); } TEST(NumericDiffCostFunction, EasyCaseFunctorCentralDifferencesAndDynamicNumResiduals) {