linux build environment updated

This commit is contained in:
nuknal
2024-07-12 11:34:02 +08:00
parent 31887a6bfe
commit 2bc6f53acc
8 changed files with 33 additions and 24 deletions

View File

@@ -46,13 +46,13 @@ func (p PolynomialInterpolator) Predict(x float64) float64 {
return y
}
func InterpPolynomial(x []float64, y []float64, xq float64) float64 {
func InterpPolynomial(x []float64, y []float64, xq float64, degree int) float64 {
if len(x) != len(y) {
return 0.0
}
start, end := FindClosestSubset(x, xq, 4)
interp := &PolynomialInterpolator{Degree: 3}
start, end := FindClosestSubset(x, xq, degree+1)
interp := &PolynomialInterpolator{Degree: degree}
interp.Fit(x[start:end+1], y[start:end+1])
return interp.Predict(xq)
}