Documentation
¶
Overview ¶
utils for plaintext operations and poc for block matrices
Index ¶
- func AddConst(m *mat.Dense, c float64) *mat.Dense
- func ApplyFunc(Bm *BMatrix, f func(x float64) float64)
- func ApplyFuncDense(f func(v float64) float64, a *mat.Dense) *mat.Dense
- func ComplexToReal(v []complex128) []float64
- func DenseToMatrix(m *mat.Dense) [][]float64
- func Distance(a, b []float64) float64
- func ExpandBlocks(Bm *BMatrix) *mat.Dense
- func Eye(n int) *mat.Dense
- func MatToArray(m *mat.Dense) [][]float64
- func MatrixForDebug(r, c int) *mat.Dense
- func Max(a, b int) int
- func Min(a, b int) int
- func MulByConst(m *mat.Dense, c float64) *mat.Dense
- func MulByi(v []float64) []complex128
- func NewDense(X [][]float64) *mat.Dense
- func NumCols(m *mat.Dense) int
- func NumRows(m *mat.Dense) int
- func Pad(v []float64, n int) []float64
- func PadDense(m *mat.Dense, rowPad, colPad int) *mat.Dense
- func PrintBlocks(bm *BMatrix)
- func PrintDense(m *mat.Dense)
- func RandMatrix(r, c int) *mat.Dense
- func RealToComplex(v []float64) []complex128
- func ReplicateComplexArray(v []complex128, n int) []complex128
- func ReplicateRealArray(v []float64, n int) []float64
- func ReplicateValue(v float64, n int) []float64
- func RotateComplexArray(v []complex128, k int) []complex128
- func RotateRealArray(v []float64, k int) []float64
- func RowFlatten(m *mat.Dense) []float64
- func TransposeDense(m *mat.Dense) (mt *mat.Dense)
- func Vectorize(X [][]float64, transpose bool) []float64
- type BMatrix
- func AddBlocks(A, B *BMatrix) (*BMatrix, error)
- func MultiPlyBlocks(A, B *BMatrix) (*BMatrix, error)
- func MultiplyBlocksByConst(A *BMatrix, c float64) *BMatrix
- func PartitionMatrix(m *mat.Dense, rowP, colP int) (*BMatrix, error)
- func PartitionMatrixSquare(m *mat.Dense, rowP, colP, d int) (*BMatrix, error)
- func TransposeBlocks(Bm *BMatrix) *BMatrix
- type Padding
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComplexToReal ¶
func ComplexToReal(v []complex128) []float64
func DenseToMatrix ¶
func ExpandBlocks ¶
Reconstruct a matrix from block representation
func MatToArray ¶
func MatrixForDebug ¶
returns a matrix useful for debug. E.g if r,c = 3,3 -> returns | 1 2 3 | | 4 5 6 | | 7 8 9 |
func MulByi ¶
func MulByi(v []float64) []complex128
func PrintBlocks ¶
func PrintBlocks(bm *BMatrix)
func PrintDense ¶
func RandMatrix ¶
func RealToComplex ¶
func RealToComplex(v []float64) []complex128
func ReplicateComplexArray ¶
func ReplicateComplexArray(v []complex128, n int) []complex128
replicates v with n copies
func ReplicateRealArray ¶
replicates v with n copies
func RotateComplexArray ¶
func RotateComplexArray(v []complex128, k int) []complex128
rotates v of k positions to the left or to the right if k < 0
func RotateRealArray ¶
rotates v of k positions to the left or to the right if k < 0
func RowFlatten ¶
func Vectorize ¶
Input: matrix X Output: column array of vectorized X Example:
X = |a b|
|c d|
if tranpose false:
output = [a ,b, c, d] column vector
else:
output = [a ,c, b, d] column vector
for reference: https://en.wikipedia.org/wiki/Vectorization_(mathematics)
Types ¶
type BMatrix ¶
type BMatrix struct { Blocks [][]*mat.Dense RowP, ColP int //num of partitions InnerRows, InnerCols int //size of sub-matrixes RealRows, RealCols int //size of original matrix with no padding }
block matrix
func MultiPlyBlocks ¶
func MultiplyBlocksByConst ¶
func PartitionMatrix ¶
Partitions m into a rowPxcolP Block Matrix where each sub-matrix is row(m)/rowP x col(m)/colP
func PartitionMatrixSquare ¶
Partitions m into a rowPxcolP Block Matrix where each sub-matrix is a square dxd matrix (eventually with padding)
func TransposeBlocks ¶
Tranpose the blocks partition of the matrix, but leaves untouched the inner matrix of each block In other words, it changes the arrangment the blocks
type Padding ¶
type Padding struct { //see func below P1 [][]float64 P2 [][]float64 // contains filtered or unexported fields }
func GenPaddingMatrixes ¶
Returns P1 and P2 matrixes such that: P2 * X * P1 = padded X, where * is the matrix product E.g is X = |a b| |c d| if pad = 1, X becomes |0 0 0 0| |0 a b 0| |0 c d 0| |0 0 0 0|