PARI/GP vecsort/versearch and Mod()
[email protected] Sat, 15 Nov 2025 15:48:05 +0100
| Newsgroups | gmane.comp.mathematics.pari.user |
|---|---|
| Message-ID | <[email protected]> |
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. So I used workaround:
https://gist.github.com/Hermann-SW/18f6fd4a991afbf6623c24e6dd089701
contains(V,M)={[m|m<-V,m==M]!=[]};
for
foreach(F4,a,
foreach(F4,b,
assert(contains(F4,a+b),"add not closed")));
With only 4 elements that is OK, but for more binary vecsearch would be
nice to have.
I defined vecsort cmpf, but because nested braces are not allowed, this
looks not nice:
...
slF4 = vecsort(lift(F4));
}
inF4(M)={vecsearch(slF4,lift(M))};
{
...
for
assert(inF4(a+b),"add not closed")
Trying to get rid of 2nd and 3rd brace I tried
inF4(M)->vecsearch(slF4,lift(M));
but that does not work. Is there a cmpf definition that works inside
braces?
Regards,
Hermann.