Documentation ¶
Index ¶
- Variables
- type Matrix
- func (m *Matrix) Add(matrix *Matrix) (*Matrix, error)
- func (m *Matrix) Copy() *Matrix
- func (m *Matrix) DeleteColumn(nLowerIndex, nUpperIndex uint64) (*Matrix, error)
- func (m *Matrix) DeleteRow(nLowerIndex, nUpperIndex uint64) (*Matrix, error)
- func (m *Matrix) Determinant() (*big.Int, error)
- func (m *Matrix) Equal(m2 *Matrix) bool
- func (m *Matrix) Get(i, j uint64) *big.Int
- func (m *Matrix) GetColumn(nIndex uint64) ([]*big.Int, error)
- func (m *Matrix) GetMatrix() [][]*big.Int
- func (m *Matrix) GetMatrixRank(fieldOrder *big.Int) (uint64, error)
- func (m *Matrix) GetNumberColumn() uint64
- func (m *Matrix) GetNumberRow() uint64
- func (m *Matrix) GetRow(nIndex uint64) ([]*big.Int, error)
- func (m *Matrix) Inverse() (*Matrix, error)
- func (m *Matrix) IsSquare() bool
- func (m *Matrix) Pseudoinverse() (*Matrix, error)
- func (m *Matrix) Transpose() *Matrix
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNonPrimeFieldOrder is returned if the field order is nonprime ErrNonPrimeFieldOrder = errors.New("non prime field order") // ErrNilMatrix is returned if it's a nil matrix ErrNilMatrix = errors.New("nil matrix") // ErrZeroRows is returned if the number of row of the matrix is zero ErrZeroRows = errors.New("zero rows") // ErrZeroColumns is returned if the number of column of the matrix is zero ErrZeroColumns = errors.New("zero columns") // ErrInconsistentColumns is returned if the column rank is inconsistent in this matrix ErrInconsistentColumns = errors.New("inconsistent columns") // ErrZeroOrNegativeRank is returned if the rank is zero or negative ErrZeroOrNegativeRank = errors.New("zero or negative rank") // ErrOutOfRange is returned if the index is out of the column or row range ErrOutOfRange = errors.New("out of range") // ErrInconsistentNumber is returned if the two matrixes are the inconsistent number ErrInconsistentNumber = errors.New("inconsistent number") // ErrNotSquareMatrix is returned if it's not a square matrix ErrNotSquareMatrix = errors.New("not a square matrix") // ErrNotInvertableMatrix is returned if it's not an invertable matrix ErrNotInvertableMatrix = errors.New("not invertable matrix") // ErrMaximalSizeOfMatrice is returned if the number of column or row exceeds the given bound ErrMaximalSizeOfMatrice = errors.New("the number of column or row exceeds the given bound") )
Functions ¶
This section is empty.
Types ¶
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
Matrix is the struct for matrix operation
func NewMatrix ¶
NewMatrix checks the input matrix slices. It returns error if the number of rows or columns is zero or the number of column is inconsistent.
func (*Matrix) DeleteColumn ¶
DeleteColumn deletes the columns from nLowerIndex to nUpperIndex Ex: a_11 a_12 a_13 a_14 a_21 a_22 a_23 a_24 a_31 a_32 a_33 a_34 a_41 a_42 a_43 a_44 Then DeleteRow(1, 2) will gives a_11 a_14 a_21 a_24 a_31 a_34 a_41 a_44
func (*Matrix) DeleteRow ¶
DeleteRow deletes the rows from nLowerIndex to nUpperIndex Ex: a_11 a_12 a_13 a_14 a_21 a_22 a_23 a_24 a_31 a_32 a_33 a_34 a_41 a_42 a_43 a_44 Then DeleteRow(1, 2) will gives a_11 a_12 a_13 a_14 a_41 a_42 a_43 a_44
func (*Matrix) Determinant ¶
Determinant returns the determinant of the matrix
func (*Matrix) GetColumn ¶
GetColumn gets column at the index Assume matrixA = [ 1, 2, 3 ]
[ 2, 4, 5 ] [ 5, 10, 3]
Then the output of GetColumn(matrixA, nIndex) is the indicated column. Ex: GetColumn(matrixA, 2)= [3, 5, 3], GetColumn(matrixA, 1)=[2, 4, 10]
func (*Matrix) GetMatrixRank ¶
GetMatrixRank returns the number of linearly independent column over finite field with order fieldOrder. As give the index of rows of a matrix, this function will find nonzero value such that this value has the smallest index of rows.
func (*Matrix) GetNumberColumn ¶
func (*Matrix) GetNumberRow ¶
func (*Matrix) GetRow ¶
GetRow gets row at the index Assume matrixA = [ 1, 2, 3 ]
[ 2, 4, 5 ] [ 5, 10, 3]
Then the output of GetColumn(matrixA, nIndex ) is the indicated row. Ex: GetRow(matrixA, 2)= [5, 10, 3], GetRow(matrixA, 1)=[2, 4, 5]
func (*Matrix) Pseudoinverse ¶
Pseudoinverse is the general inverse of non-square matrix. This is a special case of Pseudoinverse. In particular, if the matrix is non-singular and square, then Pseudoinverse is the standard inverse matrix. More details can be found in https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_inverse If m^t*m is invertible. In this case, an explicitly formula is : (m^t*m)^(-1)*m^t. TODO: This function only works under the following conditions: - the columns of m are linearly independent - row rank >= column rank