Re: PARI/GP vecsort/versearch and Mod()
[email protected] Sat, 15 Nov 2025 17:23:55 +0100
| Newsgroups | gmane.comp.mathematics.pari.user |
|---|---|
| Message-ID | <[email protected]> |
On 2025-11-15 17:01, Bill Allombert wrote: > On Sat, Nov 15, 2025 at 03:48:05PM +0100, [email protected] > wrote: >> I wanted to check four 2x2 matrixes with entries in ℤ/2ℤ to be closed >> under >> matrix addition and multiplication. >> >> Because of missing order relation for Mod() using vecsort/vecsearch >> directly >> was no option. > > You have three options: > - Use Set and setsearch > - use Map and mapisdefined > - use vecsort/vecsearch but apply lift to the vectors/ elements to > remove the Mod. > > Cheers, > Bill. > Thanks, your 3rd option is what I described. How to make this work and get rid of 1st } and 2nd { ? So all in one outer pair of braces? $ gp -q < F4.new.gp {0,1,a,b} is closed under matrix + $ $ cat F4.new.gp 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))}; { foreach(F4,a, foreach(F4,b, assert(inF4(a+b),"add not closed"))); print("{0,1,a,b} is closed under matrix +"); } $ Regards, Hermann.