Skip to main content

signed_gcd

Function signed_gcd 

Source
pub fn signed_gcd<R>(a: El<R>, b: El<R>, ring: R) -> El<R>
Expand description

Finds the greatest common divisor of a and b.

The gcd is only unique up to multiplication by units, so in this case up to sign. However, this function guarantees the following behavior w.r.t different signs:

  a < 0 => gcd(a, b) < 0
  a > 0 => gcd(a, b) > 0
  sign of b is irrelevant
  gcd(0, 0) = 0