On Mon, Sep 26, 2022 at 06:40:40PM +0800, Qian Yun wrote:
> I think this is valid optimization, it avoids extra allocation and
> computation when the gcd is 1.

Looks OK.

> - 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)"
-- 
                              Waldek Hebisch

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/20220929185922.GA26006%40fricas.math.uni.wroc.pl.

Reply via email to