Bill Allombert on Fri, 04 Jul 2025 10:06:29 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: flags in a bitmap
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Fri, 4 Jul 2025 10:06:26 +0200
- Delivery-date: Fri, 04 Jul 2025 10:06:30 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=math.u-bordeaux.fr; s=2022; t=1751616388; bh=JhuiBJ+dC38I/g4v+SGePOG/Na/Mg5vsUq7ub/vWAsY=; h=Date:From:To:Subject:References:In-Reply-To:From; b=C/epR2HwVC77eA09+6FYjiPt5UiTqi2H4htf9VBRkOLwjJTCVc4C4/RFdwpr7dYsH 0bcoRoscGLqzpe34eEfHJbXG/i75XgBqyVRtb/yz04Dofg1iMIkYSkIDXm0afE4HCU 7k4+m8PToA/hm2ysmKUtAFnWiUhMnSrx4OESwBo9AVQSBSPKD2crv/GhVJJl90lR6V 7zHjCv66BuNq1uTLYQVU0d5Nj8qgDjgjU/a2T8Xt69+WdgUrUWmEYKqhMZau8nl3BI Rs6tMdCIFuoDEt/4qVkW98WHrGQbJ1P+8GH+Yse/uthFIjycgFu0nmahI32nFFJpjr AbGuLHd76SieCqfR7IOYZgQrCK4QwaWR1355V9w+HhHUlAOj+VyclwdSXDea63wJJa 07LsR4CVfO6cXShRYC+vhcvn2FU8Fd4YWhx56mtVu3xwiO/fyk6xuGq/66GPOx4nKK YOpomQlR4GMU23mWeJjhItMskR6Q1q8VEt+frPGVLfXIAAk1bOIychOAnQgdCJqkKA 6fVYo9i49wGxmJIOAIaK2/4/vNmtT27KwZ2wHp+UEyE+yIq/Ke8Ehjf4fvdAEyXr7I H9NK9lvYR+23YqfaFEVlhHKcw13u9Qled1nbc8yg1RIU+be5Pu5w2N3HdYNtypNf5M r9hPq8Ya5Wbav35D9U8DD21w=
- In-reply-to: <66438921-ed04-4927-97e0-b1ecee7a6aa3@isolution.nl>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <0d611e03-20d3-4bf9-852e-f4be6858439e@isolution.nl> <aGZ8wfx91Ru1EToq@seventeen> <66438921-ed04-4927-97e0-b1ecee7a6aa3@isolution.nl>
On Thu, Jul 03, 2025 at 06:06:14PM +0200, Ruud H.G. van Tol wrote:
>
> Bill, many thanks for the pointers, I'll explore.
>
>
> As an alternative, maybe add a Vecbits() or Vecflags() or such.
> No idea if the first bit should have offset 0 or 1.
> Only with bittest(), maybe 0?
>
> my(B=Vecbits([0], 987654321));
> Vecbits_put(~B, 7654, v=1); \\set the bit at offset 7654, by default to 1
> Vecbits_put(~B, 7654, [1,0,0,1,1]); \\set bits 7654..7658 to [1,0,0,1,1]
> my(b=Vecbits_get(B,7654)); \\get bit-7654
> my(b=bittest(B,7653)); \\...
What I can do is to allow to set/clean a bit in place inside an integer.
However this would only work if the integer is large enough.
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.
Cheers,
Bill.