From ae69b3e3067d7a1f3a39f454a2e6682fc55ef722 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 5 Mar 2023 17:50:13 +0100 Subject: [PATCH] p3(lrls/helper.go): add addTheta,addFi funcs --- p3/lrls/helper.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/p3/lrls/helper.go b/p3/lrls/helper.go index 3b67025..2620e6f 100644 --- a/p3/lrls/helper.go +++ b/p3/lrls/helper.go @@ -56,3 +56,50 @@ func covMatrices(size, params int) ([]*mat.Dense, error) { return cms, nil } + +// nolint: unused +func newTheta(size, params int) ([][]float64, error) { + switch { + case size < 1: + return nil, errors.New("ErrThetaSize") + + case params < 4 || params > 5: + log.Printf("error: params needs to be from the set {4 ,5}, got: %d", params) + return nil, errors.New("ErrBadParams") + } + + th := make([][]float64, size) + + // initialise. + for i := range th { + th[i] = make([]float64, params) + } + + // specifically set the second vector to all 0.1s. + for i := range th[1] { + th[1][i] = 0.1 + } + + return th, nil +} + +// nolint: unused +func newFi(size, params int) ([][]float64, error) { + switch { + case size < 1: + return nil, errors.New("ErrFiSize") + + case params < 4 || params > 5: + log.Printf("error: params needs to be from the set {4 ,5}, got: %d", params) + return nil, errors.New("ErrBadParams") + } + + fi := make([][]float64, size) + + // prealloc. + for i := range fi { + fi[i] = make([]float64, params) + } + + return fi, nil +}