import AbstractGenericGF from './AbstractGenericGF' ; author Sean Owen
  export default abstract class AbstractGenericGFPoly { protected field : AbstractGenericGF ; protected coefficients : Int32Array ; public getCoefficients ( ) { return this . coefficients ; } return public getDegree ( ) { return this . coefficients . length - 1 ; } return public isZero ( ) { return this . coefficients [ 0 ] === 0 ; } return public getCoefficient ( degree ) { return this . coefficients [ this . coefficients . length - 1 - degree ] ; } return public evaluateAt ( a ) { if ( a === 0 ) { return this . getCoefficient ( 0 ) ; } const coefficients = this . coefficients ; let result ; if ( a === 1 ) { result = 0 ; for ( let i = 0 , length = coefficients . length ; i !== length ; i ++ ) { const coefficient = coefficients [ i ] ; result = AbstractGenericGF . addOrSubtract ( result , coefficient ) ; } return result ; } result = coefficients [ 0 ] ; const size = coefficients . length ; const field = this . field ; for ( let i = 1 ; i < size ; i ++ ) { result = AbstractGenericGF . addOrSubtract ( field . multiply ( a , result ) , coefficients [ i ] ) ; } return result ; } public abstract addOrSubtract ( other ) ; public abstract multiply ( other ) ; public abstract multiplyScalar ( scalar ) ; public abstract multiplyByMonomial ( degree , coefficient ) ; public abstract divide ( other ) ; public toString ( ) { let result = '' ; for ( let degree = this . getDegree ( ) ; degree >= 0 ; degree -- ) { let coefficient = this . getCoefficient ( degree ) ; if ( coefficient !== 0 ) { if ( coefficient < 0 ) { result += ' - ' ; coefficient = - coefficient ; } else { if ( result . length > 0 ) { result += ' + ' ; } } if ( degree === 0 || coefficient !== 1 ) { const alphaPower = this . field . log ( coefficient ) ; if ( alphaPower === 0 ) { result += '1' ; } else if ( alphaPower === 1 ) { result += 'a' ; } else { result += 'a^' ; result += alphaPower ; } } if ( degree !== 0 ) { if ( degree === 1 ) { result += 'x' ; } else { result += 'x^' ; result += degree ; } } } } return result ; } }