def gf_frobenius_map(f, g, b, p, K):
 m = gf_degree(g)
 if (gf_degree(f) >= m):
  f = gf_rem(f, g, p, K)
 if (not f):
  return []
 n = gf_degree(f)
 sf = [f[(-1)]]
 for i in range(1, (n + 1)):
  v = gf_mul_ground(b[i], f[(n - i)], p, K)
  sf = gf_add(sf, v, p, K)
 return sf

def gf_frobenius_map ( f , g , b , p , K ) : m = gf_degree ( g ) if ( gf_degree ( f ) >= m ) : f = gf_rem ( f , g , p , K ) if ( not f ) : return [ ] n = gf_degree ( f ) sf = [ f [ ( - 1 ) ] ] for i in range ( 1 , ( n + 1 ) ) : v = gf_mul_ground ( b [ i ] , f [ ( n - i ) ] , p , K ) sf = gf_add ( sf , v , p , K ) return sf
compute gf_pow_mod using the frobenius map parameters f .