public int power ( int x , int n ) { assert ( x >= 0 && x < getFieldSize ( ) ) ; if ( n == 0 ) { return 1 ; } if ( x == 0 ) { return 0 ; } x = logTable [ x ] * n ; if ( x < primitivePeriod ) { return powTable [ x ] ; } x = x % primitivePeriod ; return powTable [ x ] ; }
Compute power n of a field