Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 16x 16x 1x 496x 496x 496x 496x 496x 1x 1x 510x 510x 1x 1x 1x 1x 1x 1x 21966x 21965x 21965x 1x 1x 1x 1x 1x 12288x 12288x 12288x 12288x | /**
* The Galois field exponent table.
*/
const EXP_TABLE = new Uint8Array(256)
/**
* The Galois field logarithmic table.
*/
const LOG_TABLE = new Uint8Array(256)
// fill exponent table
for (let i = 0; i < 8; i += 1) {
EXP_TABLE[i] = 1 << i
}
for (let i = 8; i < 256; i += 1) {
EXP_TABLE[i] = EXP_TABLE[i - 4] ^
EXP_TABLE[i - 5] ^
EXP_TABLE[i - 6] ^
EXP_TABLE[i - 8]
}
// fill logarithmic table
for (let i = 0; i < 255; i += 1) {
LOG_TABLE[EXP_TABLE[i]] = i
}
/**
* @param {number} n - input
* @returns {number} logarithm of {@link n} using Galois field logarithmic table
*/
export function glog (n) {
if (n < 1) { throw Error(`glog(${n})`) }
return LOG_TABLE[n]
}
/**
* @param {number} n - input
* @returns {number} exponential of {@link n} using Galois field exponent table
*/export function gexp (n) {
while (n < 0) { n += 255 }
while (n >= 256) { n -= 255 }
return EXP_TABLE[n]
}
|