Documentation ¶
Overview ¶
Package gomatrix Is a go package for scientific operations with matrices in F2.
Index ¶
- func PartialXor(x, y *big.Int, startCol, stopCol int) *big.Int
- type F2
- func (f *F2) AddMatrix(m *F2) *F2
- func (f *F2) At(i, j int) (int, error)
- func (f *F2) CheckGaussian(startRow, startCol, n int) bool
- func (f *F2) GaussianElimination()
- func (f *F2) GetCol(i int) *big.Int
- func (f *F2) GetSubMatrix(startRow, startCol, stopRow, stopCol int) *F2
- func (f *F2) IsEqual(m *F2) bool
- func (f *F2) MulMatrix(m *F2) *F2
- func (f *F2) PartialGaussianElimination(startRow, startCol, stopRow, stopCol int)
- func (f *F2) PartialGaussianWithLinearChecking(startRow int, startCol int, stopRow int, stopCol int, ...) (*F2, *F2, error)
- func (f *F2) PartialT(startRow, startCol, n int) error
- func (f *F2) PermuteCols() *F2
- func (f *F2) PrettyPrint()
- func (f *F2) PrintCSV()
- func (f *F2) PrintLaTex()
- func (f *F2) PrintSlim()
- func (f *F2) Set(data []*big.Int) *F2
- func (f *F2) SetSubMatrix(m *F2, startRow, startCol int) (*F2, error)
- func (f *F2) SetToIdentity() *F2
- func (f *F2) SwapCols(i, j int) error
- func (f *F2) SwapRows(i, j int) error
- func (f *F2) T() *F2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PartialXor ¶
PartialXor xor's the bits from startCol to stopCol
@param *big.Int x The base number to xor @param *big.Int y The number with the bits to xor @param int startCol The start index of the bit mask @param int stopCol The stop index of the bit mask
@return *big.Int
Types ¶
type F2 ¶
F2 represents a matrix with entries that contains 0 or 1
Each row consists of one big Int with arbitrary size. Each column is one bit at 2**(column_index) of the big Int in each row.
func NewF2 ¶
NewF2 creates a new matrix in F_2
@param int n The count of rows @param int m The count of columns
@return *F2
func (*F2) AddMatrix ¶
AddMatrix adds two matrices
This function adds a matrix to the matrix object. The result will be saved in the object, whose AddMatrix method was called.
@param *F2 m The matrix to add
@return *F2|nil
func (*F2) At ¶
At returns the value at index i, j
@param int i The row index @param int j The column index
@return int, error|nil
func (*F2) CheckGaussian ¶
CheckGaussian checks if the given range in the matrix is the identity matrix
@param int startRow The row where the check starts @param int startCol The column where the check starts @param int n The size of the submatrix to check
@return bool
func (*F2) GaussianElimination ¶
func (f *F2) GaussianElimination()
GaussianElimination converts the matrix to an echelon form
This function applies the gaussian elimination to the matrix in order to create an echelon form.
func (*F2) GetCol ¶
GetCol returns the column at index i
This function returns the column as big.Int after the index is verified. If an invalid index is used, the function returns nil.
@param int i The index for the column
@return *big.Int
func (*F2) GetSubMatrix ¶
GetSubMatrix gets the submatrix with boundaries included
@param int startRow The first row to include @param int startCol The first column to include @param int stopRow The last row to include @param int stopCol The last column to include
func (*F2) IsEqual ¶
IsEqual checks the equality of the matrix objects
This function compares the values of the matrix that is given with the matrix whose function is called.
@param *F2 m The matrix to compare with
@return bool
func (*F2) MulMatrix ¶
MulMatrix multiplies matrix f with matrix m
This functions multiplies matrix fxm. M could be a Nx1 matrix for a vector. If the matrices cannot be multiplied, nil is returned and f is not modified. If the multiplication was successful, the result is stored in f and returned.
@param *F2 m The matrix that is used for the multiplication
@return *F2
func (*F2) PartialGaussianElimination ¶
PartialGaussianElimination performs a gaussian elimination on a part of the matrix
func (*F2) PartialGaussianWithLinearChecking ¶
func (f *F2) PartialGaussianWithLinearChecking( startRow int, startCol int, stopRow int, stopCol int, linearCheck func(*F2, *F2, *F2, int, int, int, int, int) (*F2, *F2, error), ) (*F2, *F2, error)
PartialGaussianWithLinearChecking performs a partial gaussian elimination
This function performs a gaussian elimination on the matrix and calls the check callback after each iteration in order to verify that linear dependencies in the code could be resolved easily. The function returns the permutation matrix in addition to the error. For the linearCheck callback take a look at the resolver package.
func (*F2) PartialT ¶
PartialT partially transpose the matrix
This function partially transposes a matrix. The submatrix that is transposed need to be a square matrix.
@param int startRow The row to start @param int startCol The column to start @param int n The size of the submatrix
@return error
func (*F2) PermuteCols ¶
PermuteCols permutes the columns of the matrix randomly
This function swaps columns randomly. The swap operation will be repeated on every column. After swapping the columns, the permutation matrix will be returned.
@return *F2
func (*F2) PrintSlim ¶
func (f *F2) PrintSlim()
PrintSlim prints the matrix without whitespaces to stdout
func (*F2) Set ¶
Set sets data from the data array
@param []*big.Int data The data to insert into the matrix
@return *F2|nil
func (*F2) SetSubMatrix ¶
SetSubMatrix sets the submatrix into the current matrix
@param *F2 m The submatrix to use @param int startRow The first row to replace @param int startCol The first column to replace
@return *F2, error
func (*F2) SetToIdentity ¶
SetToIdentity sets the matrix to the identity matrix
This function sets the identity matrix into f. If f is a non square matrix, the remaining rows/columns will be set to 0.
func (*F2) SwapCols ¶
SwapCols swaps the columns at index i with the row at index j
@param int i The index of the first columns to swap @param int j The index of the second columns to swap
@return error