| 1 |
package matrix |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/wcharczuk/go-chart/v2/testutil" |
| 7 |
) |
| 8 |
|
| 9 |
func TestPoly(t *testing.T) { |
| 10 |
|
| 11 |
var xGiven = []float64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} |
| 12 |
var yGiven = []float64{1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321} |
| 13 |
var degree = 2 |
| 14 |
|
| 15 |
c, err := Poly(xGiven, yGiven, degree) |
| 16 |
testutil.AssertNil(t, err) |
| 17 |
testutil.AssertLen(t, c, 3) |
| 18 |
|
| 19 |
testutil.AssertInDelta(t, c[0], 0.999999999, DefaultEpsilon) |
| 20 |
testutil.AssertInDelta(t, c[1], 2, DefaultEpsilon) |
| 21 |
testutil.AssertInDelta(t, c[2], 3, DefaultEpsilon) |
| 22 |
} |