Michael Stoll on Sun, 19 Apr 1998 22:32:53 +0200


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

New patch for gtrunc


I got somewhat entagled in the memory management. Sorry about that.
New patch follows.

Michael

*** gen3.c.orig Sun Apr 19 15:33:15 1998
--- gen3.c      Sun Apr 19 22:27:45 1998
***************
*** 1699,1703 ****
  gtrunc(GEN x)
  {
!   long tx=typ(x),av,tetpil,i;
    GEN y;

--- 1699,1703 ----
  gtrunc(GEN x)
  {
!   long tx=typ(x),av,tetpil,i,v;
    GEN y;

***************
*** 1715,1720 ****
      case t_PADIC:
        if (!signe(x[4])) return gzero;
!       av=avma; y=gpuigs((GEN)x[2],valp(x)); tetpil=avma;
!       return gerepile(av,tetpil, mulii(y,(GEN)x[4]));

      case t_RFRAC: case t_RFRACN:
--- 1715,1732 ----
      case t_PADIC:
        if (!signe(x[4])) return gzero;
!       av=avma; v=valp(x);
!       if (v>=0) /* p^v is an integer */
!       {
!         y=gpuigs((GEN)x[2],v); tetpil=avma;
!         return gerepile(av,tetpil,mulii(y,(GEN)x[4]));
!       }
!       else /* result is fraction x[4]/p^(-v);
!               should already be in lowest terms */
!       {
!         y=cgetg(3,t_FRAC);
!         y[1]=lcopy((GEN)x[4]);
!         y[2]=lpuigs((GEN)x[2],-v);
!         return y;
!       }

      case t_RFRAC: case t_RFRACN: