Bill Allombert on Mon, 27 Sep 2004 21:41:45 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: storing primes found by factor. |
On Mon, Sep 27, 2004 at 04:31:50PM +0200, Bill Allombert wrote: > Hello PARI-dev, > > Here a patch that add a new default, factor_add_primes > (turned on by default) that make factorint to automatically call > addprimes on primes factor found larger than 2^24. > > In particular if you stop a factorisation you can get the factors > already found using addprimes(), and they will be automatically > reused if you restart it. Following a suggestion of Gerhard Niklasch, I changed the patch so that functions like moebius() that use the ifac machinery will record primes found. Cheers, Bill. Index: src/basemath/ifactor1.c =================================================================== RCS file: /home/cvs/pari/src/basemath/ifactor1.c,v retrieving revision 1.67 diff -u -r1.67 ifactor1.c --- src/basemath/ifactor1.c 26 Sep 2004 16:02:18 -0000 1.67 +++ src/basemath/ifactor1.c 27 Sep 2004 17:40:34 -0000 @@ -27,6 +27,8 @@ extern ulong ucarrecomplet(ulong A); extern GEN mpqs(GEN N);/* returns a factor, a vector of factors, or NULL */ +int factor_add_primes = 1; + /*C++ on ia64 do not like (long)NULL*/ #define LNULL ((long)(GEN)NULL) /*********************************************************************/ @@ -3410,6 +3412,14 @@ nf, (nf>1 ? "s" : "")); else fprintferr("IFAC: main loop: this was the last factor\n"); + } + /* When factor_add_primes is set, ifac automatically add primes >2^24 + * to the addprimes DB. BA2004Jun22*/ + if (factor_add_primes && !(itos((GEN)((*partial)[2])) & 8)) + { + GEN p=(GEN)here[0]; + if (lgefint(p)>3 || expi(p)>24) + addprimes(p); } return here; } Index: src/gp/gp.c =================================================================== RCS file: /home/cvs/pari/src/gp/gp.c,v retrieving revision 1.230 diff -u -r1.230 gp.c --- src/gp/gp.c 26 Sep 2004 16:02:18 -0000 1.230 +++ src/gp/gp.c 27 Sep 2004 13:12:48 -0000 @@ -892,6 +892,10 @@ } static GEN +sd_factor_add_primes(char *v, int flag) +{ return sd_toggle(v,flag,"factor_add_primes", &factor_add_primes); } + +static GEN sd_new_galois_format(char *v, int flag) { return sd_toggle(v,flag,"new_galois_format", &new_galois_format); } @@ -1031,6 +1035,7 @@ {"debugfiles",(void*)sd_debugfiles}, {"debugmem",(void*)sd_debugmem}, {"echo",(void*)sd_echo}, + {"factor_add_primes",(void*)sd_factor_add_primes}, {"format",(void*)sd_format}, {"help",(void*)sd_help}, {"histsize",(void*)sd_histsize}, Index: src/headers/paricom.h =================================================================== RCS file: /home/cvs/pari/src/headers/paricom.h,v retrieving revision 1.62 diff -u -r1.62 paricom.h --- src/headers/paricom.h 23 Sep 2004 14:49:14 -0000 1.62 +++ src/headers/paricom.h 27 Sep 2004 13:12:48 -0000 @@ -151,6 +151,7 @@ extern void* global_err_data; extern int new_galois_format; +extern int factor_add_primes; enum manage_var_t { manage_var_create, /* 0 */