private int[] mod(int[] a,int[] f){
  int df=computeDegree(f);
  if (df == -1) {
    throw new ArithmeticException("Division by zero");
  }
  int[] result=new int[a.length];
  int hc=headCoefficient(f);
  hc=field.inverse(hc);
  System.arraycopy(a,0,result,0,result.length);
  while (df <= computeDegree(result)) {
    int[] q;
    int coeff=field.mult(headCoefficient(result),hc);
    q=multWithMonomial(f,computeDegree(result) - df);
    q=multWithElement(q,coeff);
    result=add(q,result);
  }
  return result;
}

private int [ ] mod ( int [ ] a , int [ ] f ) { int df = computeDegree ( f ) ; if ( df == - 1 ) { throw new ArithmeticException ( "Division by zero" ) ; } int [ ] result = new int [ a . length ] ; int hc = headCoefficient ( f ) ; hc = field . inverse ( hc ) ; System . arraycopy ( a , 0 , result , 0 , result . length ) ; while ( df <= computeDegree ( result ) ) { int [ ] q ; int coeff = field . mult ( headCoefficient ( result ) , hc ) ; q = multWithMonomial ( f , computeDegree ( result ) - df ) ; q = multWithElement ( q , coeff ) ; result = add ( q , result ) ; } return result ; }
reduce a polynomial modulo another polynomial .
