def _gf_pow_pnm1d2(f, n, g, b, p, K):
 f = gf_rem(f, g, p, K)
 h = f
 r = f
 for i in range(1, n):
  h = gf_frobenius_map(h, g, b, p, K)
  r = gf_mul(r, h, p, K)
  r = gf_rem(r, g, p, K)
 res = gf_pow_mod(r, ((p - 1) // 2), g, p, K)
 return res

def _gf_pow_pnm1d2 ( f , n , g , b , p , K ) : f = gf_rem ( f , g , p , K ) h = f r = f for i in range ( 1 , n ) : h = gf_frobenius_map ( h , g , b , p , K ) r = gf_mul ( r , h , p , K ) r = gf_rem ( r , g , p , K ) res = gf_pow_mod ( r , ( ( p - 1 ) // 2 ) , g , p , K ) return res
utility function for gf_edf_zassenhaus compute f**( // 2) in gf(p)[x]/(g) f**( // 2) = (f*f**p* .