From 27fade7b8c30b36300aabe7f4b94b22b571fe040 Mon Sep 17 00:00:00 2001 From: Sameer Agarwal Date: Sun, 15 Aug 2021 16:44:15 -0700 Subject: [PATCH] Fix a bug in system_test.cc Fix an error in the cost functor for Powell's function. Reported by William Gandler. Change-Id: I4ffbbca3b3731aa13c3608067baaebd06c1a044a --- internal/ceres/system_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/ceres/system_test.cc b/internal/ceres/system_test.cc index 429973f95..11b050433 100644 --- a/internal/ceres/system_test.cc +++ b/internal/ceres/system_test.cc @@ -97,7 +97,7 @@ class PowellsFunction { template bool operator()(const T* const x1, const T* const x2, T* residual) const { // f1 = x1 + 10 * x2; - *residual = *x1 + 10.0 * *x2; + *residual = x1[0] + 10.0 * x2[0]; return true; } }; @@ -107,7 +107,7 @@ class PowellsFunction { template bool operator()(const T* const x3, const T* const x4, T* residual) const { // f2 = sqrt(5) (x3 - x4) - *residual = sqrt(5.0) * (*x3 - *x4); + *residual = sqrt(5.0) * (x3[0] - x4[0]); return true; } }; @@ -115,9 +115,9 @@ class PowellsFunction { class F3 { public: template - bool operator()(const T* const x2, const T* const x4, T* residual) const { + bool operator()(const T* const x2, const T* const x3, T* residual) const { // f3 = (x2 - 2 x3)^2 - residual[0] = (x2[0] - 2.0 * x4[0]) * (x2[0] - 2.0 * x4[0]); + residual[0] = (x2[0] - 2.0 * x3[0]) * (x2[0] - 2.0 * x3[0]); return true; } };