On Tue, May 19, 2026 at 12:33:27PM +0800, Qian Yun wrote:
> (1) -> prime?(0::SUP INT)
> 
>    (1)  true
> 
> (2) -> prime?(((x-1)^2)::SUP INT)
> 
>    (2)  true
> 
> 
> prime$SUP INT is implemented in UFD.
> The implementation clearly overlooked a few things.

Thanks, pleas commit.
 
> On a related subject, is it intentional that "factor" of
> POLY INT does not factor the coefficient?
> 
> (3) -> factor((6*(x-1)^2)::POLY INT)
> 
>                  2
>    (3)  6 (x - 1)
> 

Yes.  Factoring integers may be extremaly expensive, while
factoring polynomials is relatively cheap and we do this
frequently.  Also, most polynomial algorithms assume that
factoring is done over a field and then adjusted to have
coefficients in the ring.

If 'factor' would factor constant factor, then we would need
a separate function 'factor_but_do_not_factor_constant_factor'
and use it in many/most places instead of 'factor'.  It would be
more consistent to do so, but it requires work and gain
seem to be small.

> diff --git a/src/algebra/catdef.spad b/src/algebra/catdef.spad
> index 262ba2ba..109671c8 100644
> --- a/src/algebra/catdef.spad
> +++ b/src/algebra/catdef.spad
> @@ -1532,7 +1532,10 @@
>    squareFreePart x ==
>        unit(s := squareFree x) * _*/[f.factor for f in factorList s]
> 
> -  prime? x == numberOfFactors factor x = 1
> +  prime? x ==
> +      zero? x => false
> +      f := factorList factor x
> +      # f = 1 and first(f).exponent = 1
> 
>  --Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
>  --All rights reserved.

-- 
                              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 visit 
https://groups.google.com/d/msgid/fricas-devel/agxQTfqTXh0whuqW%40fricas.org.

Reply via email to