From 1b909d2eea35f985ce3d127a18d2175ff5791b21 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Fri, 13 Oct 2023 15:36:55 -0400 Subject: [PATCH] Revert "overload the Chebyshev2::Point method to reduce duplication" This reverts commit b2efd64d2bfd8ab378dc8dd16faff971d82391b4. --- gtsam/basis/Chebyshev2.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/gtsam/basis/Chebyshev2.h b/gtsam/basis/Chebyshev2.h index 55bb39488..4c3542d56 100644 --- a/gtsam/basis/Chebyshev2.h +++ b/gtsam/basis/Chebyshev2.h @@ -51,30 +51,27 @@ class GTSAM_EXPORT Chebyshev2 : public Basis { using Parameters = Eigen::Matrix; using DiffMatrix = Eigen::Matrix; - /** - * @brief Specific Chebyshev point, within [a,b] interval. - * Default interval is [-1, 1] - * - * @param N The degree of the polynomial - * @param j The index of the Chebyshev point - * @param a Lower bound of interval (default: -1) - * @param b Upper bound of interval (default: 1) - * @return double - */ - static double Point(size_t N, int j, double a = -1, double b = 1) { + /// Specific Chebyshev point + static double Point(size_t N, int j) { assert(j >= 0 && size_t(j) < N); const double dtheta = M_PI / (N > 1 ? (N - 1) : 1); // We add -PI so that we get values ordered from -1 to +1 - // sin(-M_PI_2 + dtheta*j); also works + // sin(- M_PI_2 + dtheta*j); also works + return cos(-M_PI + dtheta * j); + } + + /// Specific Chebyshev point, within [a,b] interval + static double Point(size_t N, int j, double a, double b) { + assert(j >= 0 && size_t(j) < N); + const double dtheta = M_PI / (N - 1); + // We add -PI so that we get values ordered from -1 to +1 return a + (b - a) * (1. + cos(-M_PI + dtheta * j)) / 2; } /// All Chebyshev points static Vector Points(size_t N) { Vector points(N); - for (size_t j = 0; j < N; j++) { - points(j) = Point(N, j); - } + for (size_t j = 0; j < N; j++) points(j) = Point(N, j); return points; }