Yes, this is a bug introduced during my cleanup of Factored domain.

The fix is simple (I've commit it; see below).

The original thought is to avoid extra allocation of "0" and "1",
by reusing the argument:

    zero? u => u
    zero? v => v

but I wrote "zero? u or zero? v => u".

Now to think about it, if we really want to avoid extra allocation,
a better approach is to use local variable:

    __one := [1, empty()]
    1 == __one

====================================
--- src/algebra/fr.spad (revision 2550)
+++ src/algebra/fr.spad (working copy)
@@ -266,7 +266,7 @@
           _*/[convert(f.factor)@DoubleFloat ^ f.exponent for f in
factorList x]

     u : % * v : % ==
-        zero? u or zero? v => u
+        zero? u or zero? v => 0
         one? u => v
         one? v => u
         lu := factorList u; lv := factorList v
@@ -425,7 +425,7 @@
         (expand((u exquo u1)::%) + expand((v exquo u1)::%)) * u1

       gcd(u, v) ==
-          one? u or one? v => u
+          one? u or one? v => 1
           zero? u => v
           zero? v => u
           lu := factorList u; lv := factorList v


On 1/30/19 5:26 AM, Ralf Hemmecke wrote:
> Can someone confirm the following problem?
> 
> Ralf
> 
> (1) -> f:=factor(x^2-1)
> 
>    (1)  (x - 1)(x + 1)
>                                           Type:
> Factored(Polynomial(Integer))
> (2) -> g:=f*(x-1)
> 
>                2
>    (2)  (x - 1) (x + 1)
>                                           Type:
> Factored(Polynomial(Integer))
> (3) -> h := g+1
> 
>    >> Error detected within library code:
>    "failed" of mode Union(Factored(Polynomial(Integer)),"failed") cannot
> be coerced to mode Factored(Polynomial(Integer))
> 

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/a7e7ba4a-4fc3-1e22-c776-737d959a0729%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to