|
Bouncy Castle Cryptography Library 1.79 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix | +--org.bouncycastle.pqc.legacy.math.linearalgebra.GF2Matrix
This class describes some operations with matrices over finite field GF(2) and is used in ecc and MQ-PKC (also has some specific methods and implementation)
Fields inherited from class org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix |
MATRIX_TYPE_RANDOM_LT, MATRIX_TYPE_RANDOM_REGULAR, MATRIX_TYPE_RANDOM_UT, MATRIX_TYPE_UNIT, MATRIX_TYPE_ZERO, numColumns, numRows |
Constructor Summary | |
GF2Matrix(byte[] enc)
Create the matrix from encoded form. |
|
GF2Matrix(GF2Matrix a)
Copy constructor. |
|
GF2Matrix(int n,
char typeOfMatrix)
Create an nxn matrix of the given type. |
|
GF2Matrix(int n,
char typeOfMatrix,
java.security.SecureRandom sr)
Create an nxn matrix of the given type. |
|
GF2Matrix(int numColumns,
int[][] matrix)
Create the matrix with the contents of the given array. |
Method Summary | |
Matrix |
computeInverse()
Compute the inverse of this matrix. |
Matrix |
computeTranspose()
Compute the transpose of this matrix. |
static GF2Matrix[] |
createRandomRegularMatrixAndItsInverse(int n,
java.security.SecureRandom sr)
Create a nxn random regular matrix and its inverse. |
boolean |
equals(java.lang.Object other)
Compare this matrix with another object. |
GF2Matrix |
extendLeftCompactForm()
Compute the full form matrix (this | Id) from this matrix in left compact form, where Id is the k x k identity matrix and k is the number of rows of this matrix. |
GF2Matrix |
extendRightCompactForm()
Compute the full form matrix (Id | this) from this matrix in right compact form, where Id is the k x k identity matrix and k is the number of rows of this matrix. |
byte[] |
getEncoded()
Returns encoded matrix, i.e., this matrix in byte array form |
double |
getHammingWeight()
Returns the percentage of the number of "ones" in this matrix. |
int[][] |
getIntArray()
|
GF2Matrix |
getLeftSubMatrix()
Get the quadratic submatrix of this matrix consisting of the leftmost numRows columns. |
int |
getLength()
|
GF2Matrix |
getRightSubMatrix()
Get the submatrix of this matrix consisting of the rightmost numColumns-numRows columns. |
int[] |
getRow(int index)
Return the row of this matrix with the given index. |
int |
hashCode()
|
boolean |
isZero()
Check if this is the zero matrix (i.e., all entries are zero). |
Matrix |
leftMultiply(Permutation p)
Compute the product of a permutation matrix (which is generated from an n-permutation) and this matrix. |
Vector |
leftMultiply(Vector vec)
compute product a row vector and this matrix |
Vector |
leftMultiplyLeftCompactForm(Vector vec)
Compute the product of the matrix (this | Id) and a column vector, where Id is a (numRows x numRows) unit matrix. |
Matrix |
rightMultiply(Matrix mat)
Compute the product of this matrix and a matrix A over GF(2). |
Matrix |
rightMultiply(Permutation p)
Compute the product of this matrix and a permutation matrix which is generated from an n-permutation. |
Vector |
rightMultiply(Vector vec)
Compute the product of this matrix and the given column vector. |
Vector |
rightMultiplyRightCompactForm(Vector vec)
Compute the product of the matrix (Id | this) and a column vector, where Id is a (numRows x numRows) unit matrix. |
java.lang.String |
toString()
|
Methods inherited from class org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix |
getNumColumns, getNumRows |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public GF2Matrix(byte[] enc)
enc
- the encoded matrixpublic GF2Matrix(int numColumns, int[][] matrix)
numColumns
- the number of columnsmatrix
- the element arraypublic GF2Matrix(int n, char typeOfMatrix)
n
- the number of rows (and columns)typeOfMatrix
- the martix type (see Matrix
for predefined
constants)public GF2Matrix(int n, char typeOfMatrix, java.security.SecureRandom sr)
n
- the matrix sizetypeOfMatrix
- the matrix typesr
- the source of randomnesspublic GF2Matrix(GF2Matrix a)
a
- another GF2Matrix
Method Detail |
public static GF2Matrix[] createRandomRegularMatrixAndItsInverse(int n, java.security.SecureRandom sr)
n
- number of rows (and columns)sr
- source of randomnesspublic int[][] getIntArray()
public int getLength()
public int[] getRow(int index)
index
- the indexpublic byte[] getEncoded()
getEncoded
in class Matrix
public double getHammingWeight()
public boolean isZero()
isZero
in class Matrix
public GF2Matrix getLeftSubMatrix()
public GF2Matrix extendLeftCompactForm()
public GF2Matrix getRightSubMatrix()
public GF2Matrix extendRightCompactForm()
public Matrix computeTranspose()
public Matrix computeInverse()
computeInverse
in class Matrix
java.lang.ArithmeticException
- if this matrix is not invertible.public Matrix leftMultiply(Permutation p)
p
- the permutationGF2Matrix
P*thispublic Vector leftMultiply(Vector vec)
leftMultiply
in class Matrix
vec
- a vector over GF(2)public Vector leftMultiplyLeftCompactForm(Vector vec)
vec
- the vector over GF(2)public Matrix rightMultiply(Matrix mat)
rightMultiply
in class Matrix
mat
- a matrix A over GF(2)public Matrix rightMultiply(Permutation p)
rightMultiply
in class Matrix
p
- the permutationGF2Matrix
this*Ppublic Vector rightMultiply(Vector vec)
rightMultiply
in class Matrix
vec
- the vector over GF(2)public Vector rightMultiplyRightCompactForm(Vector vec)
vec
- the vector over GF(2)public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- another objectpublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class Matrix
|
Bouncy Castle Cryptography Library 1.79 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |