Return the polynomial GCD of a and b.
(a, b, gf)
| 215 | return div, val |
| 216 | |
| 217 | def poly_gcd(a, b, gf): |
| 218 | """Return the polynomial GCD of a and b.""" |
| 219 | if len(a) < len(b): |
| 220 | a, b = b, a |
| 221 | # Use Euclid's algorithm to find the GCD of a and b. |
| 222 | # see https://en.wikipedia.org/wiki/Polynomial_greatest_common_divisor#Euclid's_algorithm. |
| 223 | while len(b) > 0: |
| 224 | b = poly_monic(b, gf) |
| 225 | (_, b), a = poly_divmod(a, b, gf), b |
| 226 | return a |
| 227 | |
| 228 | def poly_sqr(poly, gf): |
| 229 | """Return the square of polynomial poly.""" |
no test coverage detected