<?xml version="1.0" encoding="utf-8" standalone="no"?><?xml-stylesheet href="/mathmlc2p.xsl" type="text/xsl"?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>rings</title>
</head>
<body>
<tt>
// Requires : <a href="mvn:cc.redberry/rings.scaladsl_2.12/2.5.7">cc.redberry#rings.scaladsl_2.12;2.5.7</a><br/>
<br/>
import cc.redberry.rings<br/>
<br/>
import rings.poly.PolynomialMethods._<br/>
import rings.scaladsl._<br/>
import syntax._<br/>
<br/>
// polynomial ring Z/17[x]<br/>
implicit val ring = UnivariateRingZp64(17, &quot;x&quot;)<br/>
// parse ring element<br/>
val x = ring(&quot;x&quot;)<br/>
<br/>
// construct some polynomials<br/>
val poly1 = 1 + x + x.pow(2) + x.pow(3)<br/>
val poly2 = 1 + 2 * x + 9 * x.pow(2)<br/>
<br/>
// compute (gcd, s, t) such that s * poly1 + t * poly2 = gcd<br/>
val Array(gcd, s, t) = PolynomialExtendedGCD(poly1, poly2)<br/>
assert (s * poly1 + t * poly2 == gcd)<br/>
<br/>
println((gcd, s, t))<br/>
</tt>
</body>
</html>
