hermann on Sun, 16 Nov 2025 18:47:02 +0100


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

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


On 2025-11-16 10:08, Karim Belabas wrote:
[...]

For readability, I would write

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

or

[...]

Cheers,

    K.B.

P.S. The hackish recursive F4 = Mod(F4, 2) also works ... and is marginally
faster than multiplying by Mod(1, 2).

While I find the "hackish recursive" technically nice, I bought your readability proposal and updated the gist. Now the 2×2 matrices are easy to spot!
https://gist.github.com/Hermann-SW/18f6fd4a991afbf6623c24e6dd089701

Regards,

Hermann.

P.S:
$ gp -q < F4.gp
0 =
[Mod(0, 2) Mod(0, 2)]

[Mod(0, 2) Mod(0, 2)]

1 =
[Mod(1, 2) Mod(0, 2)]

[Mod(0, 2) Mod(1, 2)]

a =
[Mod(0, 2) Mod(1, 2)]

[Mod(1, 2) Mod(1, 2)]

b =
[Mod(1, 2) Mod(1, 2)]

[Mod(1, 2) Mod(0, 2)]

{0,1,a,b} is closed under matrix +
{0,1,a,b} is closed under matrix *
(A1) (A2) (A3) (A4) (M1) (M2) (M3) (M4) (D)
𝔽₄ = ({0,1,a,b}, matrix +, matrix *) is a field
$