On 9/26/22 18:40, Qian Yun wrote:
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

Also, does it make sense to use "quo" instead of "exquo" here? ^^^

          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/f07be645-6f05-b851-f06a-00a33878f468%40gmail.com.

Reply via email to