private SL2 Random() { var r = new SL2(); r[0][0] = GF127.Random(); r[0][1] = GF127.Random(); r[1][0] = GF127.Random(); // d = a^-1 * (1 + b*c) r[1][1] = GF127.Inv(r[0][0]) * (r[0][1] * r[1][0] + new GF127(1, 0)); return(r); }
public void TestInv() { foreach (var row in InvTestCases) { var c = GF127.Inv(row[0]); Assert.AreEqual(row[1], c); } for (int i = 0; i < 4; i++) { var a = GF127.Random(); if (a.Equals(GF127.Zero)) { continue; } var b = GF127.Inv(a); var c = a * b; Assert.AreEqual(new GF127(1, 0), c); } }