I think this is valid optimization, it avoids extra allocation and
computation when the gcd is 1.
- Qian
diff --git a/src/algebra/fraction.spad b/src/algebra/fraction.spad
index d9f4754a..b98a3d37 100644
--- a/src/algebra/fraction.spad
+++ b/src/algebra/fraction.spad
@@ -365,6 +365,7 @@ Fraction(S : IntegralDomain) : QuotientFieldCategory
S with
cancelGcd x ==
((x.den) = 1) => x.den
d := gcd(x.num, x.den)
+ one? d => d
xn := x.num exquo d
xn case "failed" =>
error "gcd not gcd in QF cancelGcd (numerator)"
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/0300ab34-1534-746b-3078-71a735e401b1%40gmail.com.