hermann on Sat, 15 Nov 2025 19:12:06 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: PARI/GP vecsort/versearch and Mod()


On 2025-11-15 17:49, Bill Allombert wrote:
...
instead of (inF4(M)=vecsearch(slF4,lift(M))) you can do

global(inF4(M)=vecsearch(slF4,lift(M)));
local(inF4(M)=vecsearch(slF4,lift(M)));
my(inF4(M)=vecsearch(slF4,lift(M)));
with different scoping rules.

But I would rather do the opposite:

assert(b,s="")=if(!(b),error(Str(s)));

F4 = { [[Mod(0,2),Mod(0,2);  \\ 0
        Mod(0,2),Mod(0,2)],
       [Mod(1,2),Mod(0,2);   \\ 1
        Mod(0,2),Mod(1,2)],
       [Mod(0,2),Mod(1,2);   \\ a
        Mod(1,2),Mod(1,2)],
       [Mod(1,2),Mod(1,2);   \\ b
        Mod(1,2),Mod(0,2)]]; }

slF4 = vecsort(lift(F4));
inF4(M)=vecsearch(slF4,lift(M));

{
...
Cheers,
Bill

Thanks for all the options.

Your last proposal with brackets around the matrix vector looks best for me.
I updated the gist:
https://gist.github.com/Hermann-SW/18f6fd4a991afbf6623c24e6dd089701

Regards,

Hermann.

P.S:
We had to construct a field on 4 elements with addition and multiplication tables and prove that it really is a field in linear algebra 1 lecture recently. My homework group did that on paper, but later I found that nice representation of 0,1,a,b as 2×2 matrices over ℤ/2ℤ with matrix addition and multiplication. The gist just proves all properties needed for a field. I started studying mathematics 5 weeks ago at Heidelberg University (passive phase of early retirement at age of 60). My plan is to take the many lectures needed on algebra and analysis side as preparation for the number theory courses I plan to attend in 2027/2028:
https://stamm-wilbrandt.de/en/#future