summaryrefslogtreecommitdiff
path: root/fits.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fits.cpp')
-rw-r--r--fits.cpp10
1 files changed, 2 insertions, 8 deletions
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<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;
}