private int [ ] [ ] div ( int [ ] a , int [ ] f ) { int df = computeDegree ( f ) ; int da = computeDegree ( a ) + 1 ; if ( df == - 1 ) { throw new ArithmeticException ( "Division by zero." ) ; } int [ ] [ ] result = new int [ 2 ] [ ] ; result [ 0 ] = new int [ 1 ] ; result [ 1 ] = new int [ da ] ; int hc = headCoefficient ( f ) ; hc = field . inverse ( hc ) ; result [ 0 ] [ 0 ] = 0 ; System . arraycopy ( a , 0 , result [ 1 ] , 0 , result [ 1 ] . length ) ; while ( df <= computeDegree ( result [ 1 ] ) ) { int [ ] q ; int [ ] coeff = new int [ 1 ] ; coeff [ 0 ] = field . mult ( headCoefficient ( result [ 1 ] ) , hc ) ; q = multWithElement ( f , coeff [ 0 ] ) ; int n = computeDegree ( result [ 1 ] ) - df ; q = multWithMonomial ( q , n ) ; coeff = multWithMonomial ( coeff , n ) ; result [ 0 ] = add ( coeff , result [ 0 ] ) ; result [ 1 ] = add ( q , result [ 1 ] ) ; } return result ; }
Compute the result of the division of two polynomials over the field < tt > GF ( 2^m ) < /tt > .