diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-02-10 08:17:38 -0300 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-02-10 08:17:38 -0300 |
commit | 9a9f982ff10e2130475204985c6f98637ce826b3 (patch) | |
tree | e04c766bfe2d9fbd1ea90ceda0a6526de5faabcb /fits.cpp | |
parent | 02d4139a09cf817d3acc93591a51402bb82054b0 (diff) | |
download | ictp-saifr_colloquium-9a9f982ff10e2130475204985c6f98637ce826b3.tar.gz ictp-saifr_colloquium-9a9f982ff10e2130475204985c6f98637ce826b3.tar.bz2 ictp-saifr_colloquium-9a9f982ff10e2130475204985c6f98637ce826b3.zip |
More changes
Diffstat (limited to 'fits.cpp')
-rw-r--r-- | fits.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -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<std::tuple<Real, Real>>& data, const Vect while ( xₜ₊₁ = xₜ - α * ∇H, Hₜ₊₁ = cost(data, xₜ₊₁), - Hₜ₊₁ > Hₜ - 0.5 * α * m + Hₜ₊₁ > Hₜ - 0.0 * α * m ) { α /= 2; } |