MCPcopy Create free account
hub / github.com/ElementsProject/elements / poly_gcd

Function poly_gcd

src/minisketch/tests/pyminisketch.py:217–226  ·  view source on GitHub ↗

Return the polynomial GCD of a and b.

(a, b, gf)

Source from the content-addressed store, hash-verified

215 return div, val
216
217def 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
228def poly_sqr(poly, gf):
229 """Return the square of polynomial poly."""

Callers 1

rec_splitFunction · 0.85

Calls 2

poly_monicFunction · 0.85
poly_divmodFunction · 0.85

Tested by

no test coverage detected