def _gf_gcdex(f, g, p):
 ring = f.ring
 (s, t, h) = gf_gcdex(f.to_dense(), g.to_dense(), p, ring.domain)
 return (ring.from_dense(s), ring.from_dense(t), ring.from_dense(h))

def _gf_gcdex ( f , g , p ) : ring = f . ring ( s , t , h ) = gf_gcdex ( f . to_dense ( ) , g . to_dense ( ) , p , ring . domain ) return ( ring . from_dense ( s ) , ring . from_dense ( t ) , ring . from_dense ( h ) )
extended euclidean algorithm for two univariate polynomials over mathbb z_p .