Re: flags in a bitmap

"Ruud H.G. van Tol" <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
On 2025-07-04 10:06, Bill Allombert wrote:
 > I can do a git branch if you want to test:
 >
 > ? install(bitset,vWL)
 > ? x=2^(2^20);
 > ? forprime(p=2,2^20,bitset(~x,p))
 >   ***   last result computed in 8 ms.
 > ? my(S=0);for(i=0,2^20-1,S+=bittest(x,i));S
 > %16 = 82025
 >   ***   last result computed in 159 ms.

To set a base, first a pure-pari test:

? { my( bitset(~v,p)=v[1]=bitor(v[1],2^p), L=2^20, x=[2^L], s=0 );
     forprime(p=2,L-1, bitset(~x,p));
     for(i=0,L-1, s+=bittest(x[1],i));
     print(s);
}

82025
cpu time = 1,857 ms, real time = 1,861 ms.

-- Ruud
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.