Bill Allombert on Thu, 21 Oct 1999 18:01:19 +0200 (MET DST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: removeprimes() |
> Hi, > > I noticed this interesting behavior. > > ? addprimes(2*primes(64));length(addprimes) > 64 > ? removeprimes(addprimes);length(addprimes) > 32 > So removeprimes() cuts the size of the list of > declared primes in half. I don't this this is how > removeprimes() is described to behave. > > Thanks > > Igor The problem is that primetab is an universal object! ? addprimes(2*primes(64));length(addprimes) %1 = 64 ? x=addprimes;removeprimes(x);length(addprimes) %2 = 0 Bill. Here a patch: (I will update the CVS version this evening (Bordeaux time)). =================================================================== RCS file: /home/megrez/cvsroot/pari/src/basemath/arith2.c,v retrieving revision 1.2 diff -u -r1.2 arith2.c --- src/basemath/arith2.c 1999/10/15 11:30:40 1.2 +++ src/basemath/arith2.c 1999/10/21 15:58:52 @@ -271,10 +271,20 @@ long i,tx, av = avma; if (!prime) return primetab; + if (prime == primetab)/*remove all primes. B.A.*/ + { + for (i=1; i < lg(primetab); i++) + { + gunclone((GEN)primetab[i]); + primetab[i]=0; + } + cleanprimetab(); + return primetab; + } tx = typ(prime); if (is_vec_t(tx)) { - for (i=1; i < lg(prime); i++) removeprimes((GEN) prime[i]); + for (i=1; i < lg(prime); i++) removeprimes((GEN) prime[i]);/*bug if prime==primetab*/ return primetab; } if (tx != t_INT) err(typeer,"removeprimes");