3.2 KiB
3.2 KiB
In [ ]:
In [16]:
# Q: If you compute the inverse of one of these matrixes and multiply it to the right of the position
# where it was originally multiplied it should "delete" that element as if the element was never added.
# I'm uncertain of the possibility and frequency of such inverse matrices over finite fields.
# If this scenario is possible to construct, I think we should "define" this operation as deletion.
# See: https://en.wikipedia.org/wiki/Determinant#Properties_of_the_determinant
def det2(mat, m=256):
((a, b),
(c, c)) = mat
return (a*c - b*c) % m
def det3(mat, m=256):
((a, b, c),
(d, e, f),
(g, h, i)) = mat
return (a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h) % m
def det(mat, m=256):
# I dislike having to round here, but it returns a float
# I wish it returned a native "B" type
return int(round(np.linalg.det(mat),0)) % m
a = ((-2,2,-3),(-1,1,3),(2,0,-1))
assert_equal(det(a), 18)
assert_equal(det(a), det3(a))
# ?
# assert that they didn't change since the last time I ran it
assert_equal(det(f1), 128)
assert_equal(det(f2), 160)
assert_equal(det(f3), 128)