| 1 | package dstream |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestLinapply1(t *testing.T) { |
| 6 | |
| 7 | x := [][]interface{}{ |
| 8 | { |
| 9 | []float64{0, 0, 0}, |
| 10 | []float64{1, 1, 1}, |
| 11 | []float64{2, 2, 3}, |
| 12 | }, |
| 13 | { |
| 14 | []string{"a", "b", "c"}, |
| 15 | []string{"d", "e", "f"}, |
| 16 | []string{"g", "h", "i"}, |
| 17 | }, |
| 18 | { |
| 19 | []float64{1, 2, 3}, |
| 20 | []float64{4, 5, 6}, |
| 21 | []float64{7, 8, 9}, |
| 22 | }, |
| 23 | } |
| 24 | na := []string{"x1", "x2", "x3"} |
| 25 | da := NewFromArrays(x, na) |
| 26 | |
| 27 | x = append(x, |
| 28 | [][]interface{}{ |
| 29 | { |
| 30 | []float64{2, 4, 6}, |
| 31 | []float64{9, 11, 13}, |
| 32 | []float64{16, 18, 21}, |
| 33 | }, |
| 34 | { |
| 35 | []float64{1, 2, 3}, |
| 36 | []float64{3, 4, 5}, |
| 37 | []float64{5, 6, 6}, |
| 38 | }, |
| 39 | }...) |
| 40 | |
| 41 | na = []string{"x1", "x2", "x3", "z0", "z1"} |
| 42 | ex := NewFromArrays(x, na) |
| 43 | |
| 44 | coeffs := [][]float64{ |
| 45 | {1, 0, 2}, |
| 46 | {-1, 1, 1}, |
| 47 | } |
| 48 | db := Linapply(da, coeffs, "z") |
| 49 | |
| 50 | if !EqualReport(db, ex, true) { |
| 51 | t.Fail() |
| 52 | } |
| 53 | } |