p3(lrls/helper.go): add addTheta,addFi funcs

This commit is contained in:
leo 2023-03-05 17:50:13 +01:00
parent a44f8def21
commit ae69b3e306
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

@ -56,3 +56,50 @@ func covMatrices(size, params int) ([]*mat.Dense, error) {
return cms, nil 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
}