13
"github.com/RB-PRO/ssa/pkg/pchip"
14
"github.com/xuri/excelize/v2"
17
func TestPchip(t *testing.T) {
20
lag := int(math.Floor(float64(win) / 10.0))
21
lgl := make([]float64, lag)
22
for m := 0; m < len(lgl); m++ {
23
lgl[m] = float64(m + 1)
25
PhaAcfNrm := loadXlsx("pchip_test.xlsx")
28
_, _, coefs := pchip.Pchip(PhaAcfNrm,
31
len(PhaAcfNrm), len(lgl))
37
func safeToXlsx(coefs pchip.PchipCoefs) {
38
file_graph, _ := excelize.OpenFile("pchip_test.xlsx", excelize.Options{})
39
defer file_graph.Close()
40
lenFor := len(coefs.A)
41
for ind := 0; ind < lenFor; ind++ {
42
file_graph.SetCellValue("golang", "B"+strconv.Itoa(ind+1), coefs.A[ind])
43
file_graph.SetCellValue("golang", "C"+strconv.Itoa(ind+1), coefs.B[ind])
44
file_graph.SetCellValue("golang", "D"+strconv.Itoa(ind+1), coefs.C[ind])
45
file_graph.SetCellValue("golang", "E"+strconv.Itoa(ind+1), coefs.D[ind])
51
func loadXlsx(filename string) []float64 {
52
output := make([]float64, 0)
54
file_graph, _ := excelize.OpenFile(filename, excelize.Options{})
55
defer file_graph.Close()
57
rows, err := file_graph.GetRows("input")
62
for _, row := range rows {
64
n, err := strconv.ParseFloat(row[0], 64)
66
output = append(output, n)