public class GF16
extends java.lang.Object
Constructor and Description |
---|
GF16() |
Modifier and Type | Method and Description |
---|---|
static void |
decode(byte[] input,
byte[] output,
int outputLen)
Decodes an encoded byte array.
|
static void |
decode(byte[] input,
int inOff,
byte[] output,
int outOff,
int outputLen) |
static void |
encode(byte[] input,
byte[] output,
int inputLen)
Encodes an array of 4-bit values into a byte array.
|
static void |
encode(byte[] input,
byte[] output,
int outOff,
int inputLen) |
static byte |
innerProduct(byte[] a,
int aOff,
byte[] b,
int bOff,
int rank) |
static byte |
inv(byte a)
Computes the multiplicative inverse in GF(16) for a GF(16) element.
|
static byte |
mul(byte a,
byte b)
GF(16) multiplication mod x^4 + x + 1.
|
static int |
mul(int a,
int b)
GF(16) multiplication mod x^4 + x + 1.
|
public static byte mul(byte a, byte b)
This method multiplies two elements in GF(16) (represented as integers 0–15) using carryless multiplication followed by reduction modulo x^4 + x + 1. Please ensure a <= 0x0F and b <= 0x0F
a
- an element in GF(16) (only the lower 4 bits are used)b
- an element in GF(16) (only the lower 4 bits are used)public static int mul(int a, int b)
This method multiplies two elements in GF(16) (represented as integers 0–15) using carryless multiplication followed by reduction modulo x^4 + x + 1. Please ensure a <= 0x0F and b <= 0x0F
a
- an element in GF(16) (only the lower 4 bits are used)b
- an element in GF(16) (only the lower 4 bits are used)public static byte inv(byte a)
public static void decode(byte[] input, byte[] output, int outputLen)
input
- the input byte array (each byte holds two 4-bit values)output
- the output array that will hold the decoded nibbles (one per byte)outputLen
- the total number of nibbles to decodepublic static void decode(byte[] input, int inOff, byte[] output, int outOff, int outputLen)
public static void encode(byte[] input, byte[] output, int inputLen)
input
- the input array of 4-bit values (stored as bytes, only lower 4 bits used)output
- the output byte array that will hold the encoded bytesinputLen
- the number of nibbles in the input arraypublic static void encode(byte[] input, byte[] output, int outOff, int inputLen)
public static byte innerProduct(byte[] a, int aOff, byte[] b, int bOff, int rank)