From 9a9f982ff10e2130475204985c6f98637ce826b3 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 10 Feb 2025 08:17:38 -0300 Subject: More changes --- fits.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'fits.cpp') diff --git a/fits.cpp b/fits.cpp index d86af73..370b63d 100644 --- a/fits.cpp +++ b/fits.cpp @@ -22,14 +22,8 @@ inline Real basisFunctions(unsigned N, unsigned i, Real x) { } */ -Real legendreP(unsigned n, Real x) { - if (n == 0) return 1; - else if (n == 1) return x; - else return ((2 * (n - 1) + 1) * x * legendreP(n - 1, x) - (n - 1) * legendreP(n - 2, x)) / n; -} - inline Real basisFunctions(unsigned N, unsigned i, Real x) { - return legendreP(i, x); + return std::legendre(i, 0.5 * (x + 1.0)); } /* @@ -91,7 +85,7 @@ Vector gradientDescent(const std::list>& data, const Vect while ( xₜ₊₁ = xₜ - α * ∇H, Hₜ₊₁ = cost(data, xₜ₊₁), - Hₜ₊₁ > Hₜ - 0.5 * α * m + Hₜ₊₁ > Hₜ - 0.0 * α * m ) { α /= 2; } -- cgit v1.2.3-70-g09d2