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 16:04, Ruud H.G. van Tol wrote:
> 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.
Now similar on the freshly patched gp:
? { my( L=2^20, x=2^L, s=0 );
forprime(p=2,L-1, bitset(~x,p));
for(i=0,L-1, s+=bittest(x,i));
print(s);
}
82025
time = 135 ms.
-- Ruud