Karim Belabas on Wed, 19 Nov 1997 02:15:48 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

patch2


* Due to a last-change-modification-that-couldn't-possibly-break-anything,
factorization of univariate polynomials over Z had a tendency to forget
about multiple factors:

(00:56) gp > factor(x^2)
%1 = 
[x 1]

* Here's a patch:
===========================  patch 2 (2.0.alpha) ==========================

*** src/basemath/polarit2.c.orig	Fri Nov 14 04:53:30 1997
--- src/basemath/polarit2.c	Tue Nov 18 19:16:54 1997
***************
*** 436,442 ****
      p1=cgetg(2,t_COL); y[2]=(long)p1; p1[1]=un; return y;
    }
  
!   fa=cgetg(lx,t_VEC); d=content(x);
    if (!gcmp1(leading_term(x))) d = negi(d);
    if (!gcmp1(d)) x=gdiv(x,d);
    vv=varn(x); xp=deriv(x,vv); t=ggcd(x,xp);
--- 436,444 ----
      p1=cgetg(2,t_COL); y[2]=(long)p1; p1[1]=un; return y;
    }
  
!   p1 = cgetg(1,t_VEC); fa=cgetg(lx,t_VEC);
!   for (i=1; i<lx; i++) fa[i] = (long)p1;
!   d=content(x);
    if (!gcmp1(leading_term(x))) d = negi(d);
    if (!gcmp1(d)) x=gdiv(x,d);
    vv=varn(x); xp=deriv(x,vv); t=ggcd(x,xp);
***************
*** 443,454 ****
    v=gdiv(x,t); w=gdiv(xp,t); j=0; f=1; nbfac=0;
    while (f)
    {
!     w=gsub(w,deriv(v,vv)); f=signe(w);
      if (f) { res=ggcd(v,w); v=gdiv(v,res); w=gdiv(w,res); }
      else res=v;
      if (lgef(res) > 3)
      {
!       j++; fa[j] = (long)squff(res,klim,hint);
        nbfac += lg(fa[j])-1;
      }
    }
--- 445,456 ----
    v=gdiv(x,t); w=gdiv(xp,t); j=0; f=1; nbfac=0;
    while (f)
    {
!     j++; w=gsub(w,deriv(v,vv)); f=signe(w);
      if (f) { res=ggcd(v,w); v=gdiv(v,res); w=gdiv(w,res); }
      else res=v;
      if (lgef(res) > 3)
      {
!       fa[j] = (long)squff(res,klim,hint);
        nbfac += lg(fa[j])-1;
      }
    }


--
Karim Belabas                          e-mail:
Max-Planck-Institut fuer Mathematik       karim@mpim-bonn.mpg.de
Gottfried-Claren-Str. 26               tel:
53225 Bonn (Germany)                      (00 49 228) 402-245