Top Description Fields Constructors Methods
org.bouncycastle.pqc.legacy.math.linearalgebra

public Class GF2mMatrix

extends Matrix
Class Inheritance

This class describes some operations with matrices over finite field GF(2m) with small m (1< m <32).
See Also
Matrix

Field Summary

Modifier and TypeField and Description
protected GF2mField
field

finite field GF(2^m)

protected int[][]
matrix

For the matrix representation the array of type int[][] is used, thus every element of the array keeps one element of the matrix (element from finite field GF(2^m))

Inherited from org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix:
MATRIX_TYPE_RANDOM_LTMATRIX_TYPE_RANDOM_REGULARMATRIX_TYPE_RANDOM_UTMATRIX_TYPE_UNITMATRIX_TYPE_ZEROnumColumnsnumRows

Constructor Summary

AccessConstructor and Description
public
GF2mMatrix(GF2mField
a finite field GF(2^m)
field
,
byte[]
byte[] matrix in byte array form
enc
)

Constructor.

public
GF2mMatrix(GF2mMatrix
another GF2mMatrix
other
)

Copy constructor.

protected
GF2mMatrix(GF2mField
a finite field GF(2^m)
field
,
int[][]
the matrix as int array. Only the reference is copied.
matrix
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private void
addToRow(int[]
the addend
fromRow
,
int[]
the row to add to
toRow
)

Add one row to another.

public Matrix

Returns:

the inverse of this matrix (newly created).
computeInverse
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.computeInverse.

Compute the inverse of this matrix.
public boolean

Returns:

true or false
equals
(Object
object
other
)

Overrides java.lang.Object.equals.

Checks if given object is equal to this matrix.
public byte[]

Returns:

a byte array encoding of this matrix
getEncoded
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.getEncoded.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean

Returns:

true if this is the zero matrix
isZero
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.isZero.

Check if this is the zero matrix (i.e., all entries are zero).
public Vector
leftMultiply(Vector
a vector
vector
)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.leftMultiply.

Compute the product of a vector and this matrix.
private int[]
multRowWithElement(int[] row, int element)

private void
multRowWithElementThis(int[] row, int element)

public Matrix
rightMultiply(Matrix
the other matrix
a
)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Compute the product of this matrix and another matrix.
public Matrix
rightMultiply(Permutation
the permutation
perm
)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Compute the product of this matrix and a permutation.
public Vector
rightMultiply(Vector
a vector
vector
)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Compute the product of this matrix and a vector.
private static void
swapColumns(int[][] matrix, int first, int second)

public String
toString()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.toString.

Returns a string representation of the object.
Inherited from org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix:
getNumColumnsgetNumRows

Field Detail

fieldback to summary
protected GF2mField field

finite field GF(2^m)

matrixback to summary
protected int[][] matrix

For the matrix representation the array of type int[][] is used, thus every element of the array keeps one element of the matrix (element from finite field GF(2^m))

Constructor Detail

GF2mMatrixback to summary
public GF2mMatrix(GF2mField field, byte[] enc)

Constructor.

Parameters
field:GF2mField

a finite field GF(2^m)

enc:byte[]

byte[] matrix in byte array form

GF2mMatrixback to summary
public GF2mMatrix(GF2mMatrix other)

Copy constructor.

Parameters
other:GF2mMatrix

another GF2mMatrix

GF2mMatrixback to summary
protected GF2mMatrix(GF2mField field, int[][] matrix)

Constructor.

Parameters
field:GF2mField

a finite field GF(2^m)

matrix:int[][]

the matrix as int array. Only the reference is copied.

Method Detail

addToRowback to summary
private void addToRow(int[] fromRow, int[] toRow)

Add one row to another.

Parameters
fromRow:int[]

the addend

toRow:int[]

the row to add to

computeInverseback to summary
public Matrix computeInverse()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.computeInverse.

Compute the inverse of this matrix.

Returns:Matrix

the inverse of this matrix (newly created).

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Checks if given object is equal to this matrix. The method returns false whenever the given object is not a matrix over GF(2^m).

Parameters
other:Object

object

Returns:boolean

true or false

getEncodedback to summary
public byte[] getEncoded()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.getEncoded.

Returns:byte[]

a byte array encoding of this matrix

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

isZeroback to summary
public boolean isZero()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.isZero.

Check if this is the zero matrix (i.e., all entries are zero).

Returns:boolean

true if this is the zero matrix

leftMultiplyback to summary
public Vector leftMultiply(Vector vector)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.leftMultiply.

Doc from org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.leftMultiply.

Compute the product of a vector and this matrix. If the length of the vector is greater than the number of rows of this matrix, the matrix is multiplied by each m-bit part of the vector.

Parameters
vector:Vector

a vector

Returns:Vector

vector * this (newly created)

multRowWithElementback to summary
private int[] multRowWithElement(int[] row, int element)
multRowWithElementThisback to summary
private void multRowWithElementThis(int[] row, int element)
rightMultiplyback to summary
public Matrix rightMultiply(Matrix a)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Doc from org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Compute the product of this matrix and another matrix.

Parameters
a:Matrix

the other matrix

Returns:Matrix

this * a (newly created)

rightMultiplyback to summary
public Matrix rightMultiply(Permutation perm)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Doc from org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Compute the product of this matrix and a permutation.

Parameters
perm:Permutation

the permutation

Returns:Matrix

this * p (newly created)

rightMultiplyback to summary
public Vector rightMultiply(Vector vector)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Doc from org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.rightMultiply.

Compute the product of this matrix and a vector.

Parameters
vector:Vector

a vector

Returns:Vector

this * vector (newly created)

swapColumnsback to summary
private static void swapColumns(int[][] matrix, int first, int second)
toStringback to summary
public String toString()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

Doc from org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix.toString.

a human readable form of the matrix.