import GenericGFPoly from './GenericGFPoly' ; import AbstractGenericGF from './AbstractGenericGF' ; import Integer from '../../util/Integer' ; import IllegalArgumentException from '../../IllegalArgumentException' ; import ArithmeticException from '../../ArithmeticException' ; author Sean Owen
 *  author David Olivier
  export default class GenericGF extends AbstractGenericGF { public static AZTEC_DATA_12 = new GenericGF ( 0x1069 , 4096 , 1 ) ; public static AZTEC_DATA_10 = new GenericGF ( 0x409 , 1024 , 1 ) ; public static AZTEC_DATA_6 = new GenericGF ( 0x43 , 64 , 1 ) ; public static AZTEC_PARAM = new GenericGF ( 0x13 , 16 , 1 ) ; public static QR_CODE_FIELD_256 = new GenericGF ( 0x011d , 256 , 0 ) ; public static DATA_MATRIX_FIELD_256 = new GenericGF ( 0x012d , 256 , 1 ) ; public static AZTEC_DATA_8 = GenericGF . DATA_MATRIX_FIELD_256 ; public static MAXICODE_FIELD_64 = GenericGF . AZTEC_DATA_6 ; private zero : GenericGFPoly ; private one : GenericGFPoly ; param primitive param size param b public constructor ( private primitive , private size , private generatorBase ) { super ( ) ; const expTable = new Int32Array ( size ) ; let x = 1 ; for ( let i = 0 ; i < size ; i ++ ) { expTable [ i ] = x ; x *= 2 ; if ( x >= size ) { x ^= primitive ; x &= size - 1 ; } } this . expTable = expTable ; const logTable = new Int32Array ( size ) ; for ( let i = 0 ; i < size - 1 ; i ++ ) { logTable [ expTable [ i ] ] = i ; } this . logTable = logTable ; this . zero = new GenericGFPoly ( this , Int32Array . from ( [ 0 ] ) ) ; this . one = new GenericGFPoly ( this , Int32Array . from ( [ 1 ] ) ) ; } public getZero ( ) { return this . zero ; } public getOne ( ) { return this . one ; } return public buildMonomial ( degree , coefficient ) { if ( degree < 0 ) { throw new IllegalArgumentException ( ) ; } if ( coefficient === 0 ) { return this . zero ; } const coefficients = new Int32Array ( degree + 1 ) ; coefficients [ 0 ] = coefficient ; return new GenericGFPoly ( this , coefficients ) ; } return public inverse ( a ) { if ( a === 0 ) { throw new ArithmeticException ( ) ; } return this . expTable [ this . size - this . logTable [ a ] - 1 ] ; } return public multiply ( a , b ) { if ( a === 0 || b === 0 ) { return 0 ; } return this . expTable [ ( this . logTable [ a ] + this . logTable [ b ] ) % ( this . size - 1 ) ] ; } public getSize ( ) { return this . size ; } public getGeneratorBase ( ) { return this . generatorBase ; } public toString ( ) { return ( 'GF(0x' + Integer . toHexString ( this . primitive ) + ',' + this . size + ')' ) ; } public equals ( o ) { return o === this ; } }