utils

package
v0.0.0-...-0c2b93f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Average

func Average(v []float64) float64

Takes average of a vector v Input - v : m x 1 Output - avg: scalar

func DataExport

func DataExport(data [][]float64, fileName string)

func MatToStr

func MatToStr(M [][]float64) [][]string

Convert a matrix to a string Input - M : m x n float matrix Output - strOut : m x n string matrix

func MatToVec

func MatToVec(M [][]float64) []float64

Convert a matrix to a vector The matrix must have 1 column Input - M : m x 1 float matrix Output - vOut : m x 1 float vector

func MatVecMult

func MatVecMult(M [][]float64, v []float64) []float64

Multiply a matrix to a vector Input - M : m x n float matrix - v : n x 1 float vector Output - vOut: m x l float vector

func ModMatFloat

func ModMatFloat(M [][]float64, q uint64) [][]uint64

Mod q of float matrix Each component of MOut belongs to [0, q). Input - M : m x n float matrix Output - MOut: m x n uint64 matrix

func ModVec

func ModVec(v []int64, q uint64) []uint64

func ModVecFloat

func ModVecFloat(v []float64, q uint64) []uint64

Mod q of float vector Each component of vOut belongs to [0, q). Input - v : m x 1 float vector Output - vOut: m x 1 uint64 vector

func RoundVec

func RoundVec(v []float64) []int64

Rounding of a vector Input - v : n x 1 float vector Output - v : n x 1 float vector

func RoundVec(v []float64) []float64 {
	row := len(v)
	vOut := make([]float64, row)
	for r := 0; r < row; r++ {
		vOut[r] = math.Round(v[r])
	}
	return vOut
}

func ScalMatMult

func ScalMatMult(s float64, M [][]float64) [][]float64

Multiply a scalar to a matrix Input - s : scalar float - M : m x n float matrix Output - MOut: m x n float matrix

func ScalVecMult

func ScalVecMult(s float64, v []float64) []float64

Multiply a scalar to a vector Input - s : scalar float - v : m x 1 float vector Output - vOut: m x 1 float vector

func ScalVecMultInt

func ScalVecMultInt(s int64, v []int64) []int64

func SignFloat

func SignFloat(s float64, T uint64) float64

Maps a float to interval (-T/2, T/2). Input - s : float Output - sOut: float

func Vec2Norm

func Vec2Norm(v []float64) float64

2-norm of a vector Input - v : n x 1 float vector Output - s: scalar float

func VecAdd

func VecAdd(v1 []float64, v2 []float64) []float64

Add a vector to a vector Input - v1 : m x 1 float vector - v2 : m x 1 float vector Output - vOut: m x 1 float vector

func VecDuplicate

func VecDuplicate(v []float64, n int, h int) []float64

Duplicate + zero padding length h vector n times Length of a must be less than or equal to h Input - v : float vector Output - v: nh x 1 float vector

func VecSub

func VecSub(v1 []float64, v2 []float64) []float64

Subtract a vector to a vector Input - v1 : m x 1 float vector - v2 : m x 1 float vector Output - vOut: m x 1 float vector

func VecSumUint

func VecSumUint(v []uint64, T uint64, bredparams [2]uint64) uint64

Inner sum of vector elements (mod q) Input - v : m x 1 uint64 vector Output - sum: scalar uint64

func VecToStr

func VecToStr(v []float64) [][]string

Convert a vector to a string Input - v : n x 1 float vector Output - strOut : n x 1 string matrix

Types

This section is empty.

Directories

Path Synopsis
core

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL