Beispiel #1
0
func TestSpline(n int) {

	var coefs *spline.CoefsType
	coefs = nil

	x := make([]float64, n)
	y := make([]float64, n)

	cind := -1

	x[0] = 0.0
	x[1] = 1.0
	x[2] = 1.5
	x[3] = 2.25

	y[0] = 2.0
	y[1] = 4.4366
	y[2] = 6.7134
	y[3] = 13.9130

	coefs = spline.Points(x, y, coefs)

	cind, _ = spline.Evaluate(0.66, x, cind, coefs)
	cind, _ = spline.Evaluate(1.75, x, cind, coefs)

}
Beispiel #2
0
func ResampSpline(x, y, result []float64) []float64 {

	// is there a way to keep this as global, re-usable data?
	var coefs *spline.CoefsType = nil

	coefs = spline.Points(x, y, coefs)

	outCount := len(result)

	fmt.Printf("ResampSpline outCount %d\n", outCount)

	// current index
	curind := -1

	for i := 0; i < outCount; i++ {
		curind, result[i] = spline.Evaluate(float64(i), x, curind, coefs)
	}

	return result
}