Package org.bouncycastle.pqc.math.linearalgebra

## Class GF2mMatrix

- java.lang.Object
- - org.bouncycastle.pqc.math.linearalgebra.Matrix
  - - org.bouncycastle.pqc.math.linearalgebra.GF2mMatrix

-     public class GF2mMatrix
      extends Matrix

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

- - ### Field Summary

    Fields
    Modifier and Type | Field | 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))

    - ### Fields inherited from class org.bouncycastle.pqc.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

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `` | `GF2mMatrix​(GF2mField field, byte[] enc)` | Constructor.
    `protected` | `GF2mMatrix​(GF2mField field, int[][] matrix)` | Constructor.
    `` | `GF2mMatrix​(GF2mMatrix other)` | Copy constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Matrix` | `computeInverse()` | Compute the inverse of this matrix.
    `boolean` | `equals​(java.lang.Object other)` | Checks if given object is equal to this matrix.
    `byte[]` | `getEncoded()` |
    `int` | `hashCode()` |
    `boolean` | `isZero()` | Check if this is the zero matrix (i.e., all entries are zero).
    `Vector` | `leftMultiply​(Vector vector)` | Compute the product of a vector and this matrix.
    `Matrix` | `rightMultiply​(Matrix a)` | Compute the product of this matrix and another matrix.
    `Matrix` | `rightMultiply​(Permutation perm)` | Compute the product of this matrix and a permutation.
    `Vector` | `rightMultiply​(Vector vector)` | Compute the product of this matrix and a vector.
    `java.lang.String` | `toString()` |

    - ### Methods inherited from class org.bouncycastle.pqc.math.linearalgebra.Matrix

      `getNumColumns, getNumRows`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### field

          protected GF2mField field

      finite field GF(2^m)

    - #### matrix

          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

    - #### GF2mMatrix

          public GF2mMatrix​(GF2mField field,
                            byte[] enc)

      Constructor.
      Parameters:
        `field` - a finite field GF(2^m)
        `enc` - byte[] matrix in byte array form

    - #### GF2mMatrix

          public GF2mMatrix​(GF2mMatrix other)

      Copy constructor.
      Parameters:
        `other` - another `GF2mMatrix`

    - #### GF2mMatrix

          protected GF2mMatrix​(GF2mField field,
                               int[][] matrix)

      Constructor.
      Parameters:
        `field` - a finite field GF(2^m)
        `matrix` - the matrix as int array. Only the reference is copied.

  - ### Method Detail

    - #### getEncoded

          public byte[] getEncoded()

      Specified by:
        `getEncoded` in class `Matrix`
      Returns:
        a byte array encoding of this matrix

    - #### isZero

          public boolean isZero()

      Check if this is the zero matrix (i.e., all entries are zero).
      Specified by:
        `isZero` in class `Matrix`
      Returns:
        `true` if this is the zero matrix

    - #### computeInverse

          public Matrix computeInverse()

      Compute the inverse of this matrix.
      Specified by:
        `computeInverse` in class `Matrix`
      Returns:
        the inverse of this matrix (newly created).

    - #### rightMultiply

          public Matrix rightMultiply​(Matrix a)

      Description copied from class: `Matrix`
      Compute the product of this matrix and another matrix.
      Specified by:
        `rightMultiply` in class `Matrix`
      Parameters:
        `a` - the other matrix
      Returns:
        `this * a` (newly created)

    - #### rightMultiply

          public Matrix rightMultiply​(Permutation perm)

      Description copied from class: `Matrix`
      Compute the product of this matrix and a permutation.
      Specified by:
        `rightMultiply` in class `Matrix`
      Parameters:
        `perm` - the permutation
      Returns:
        `this * p` (newly created)

    - #### leftMultiply

          public Vector leftMultiply​(Vector vector)

      Description copied from class: `Matrix`
      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.
      Specified by:
        `leftMultiply` in class `Matrix`
      Parameters:
        `vector` - a vector
      Returns:
        `vector * this` (newly created)

    - #### rightMultiply

          public Vector rightMultiply​(Vector vector)

      Description copied from class: `Matrix`
      Compute the product of this matrix and a vector.
      Specified by:
        `rightMultiply` in class `Matrix`
      Parameters:
        `vector` - a vector
      Returns:
        `this * vector` (newly created)

    - #### equals

          public boolean equals​(java.lang.Object other)

      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).
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `other` - object
      Returns:
        true or false

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Specified by:
        `toString` in class `Matrix`
      Returns:
        a human readable form of the matrix.