Computing Smith normal form in $\mathbb{Z}/2\mathbb{Z}$ in Python

185 Views Asked by At

I am not sure if my question belongs here or more on stackoverflow as it concerns programming aspects of linear algebra. But I would like to compute the Smith normal form of a matrix $M$ with coefficient in $\mathbb{Z}/2\mathbb{Z}$ in Python.

I have come across the package Sympy that permit to do so via sympy.matrices.normalforms. This function allow specifying the domain of the matrix (see example here : https://docs.sympy.org/latest/modules/matrices/normalforms.html). Yet, as I am new to this package (and to formal calculus), I don't see how to specify that I am working in $\mathbb{Z}/2\mathbb{Z}$ ?

If this is not possible, do you know any other package that would permit to do so ?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use FiniteField to create finite fields. Then use the following code example:

from sympy import Matrix, FiniteField
from sympy.matrices.normalforms import smith_normal_form
    
m = Matrix([[0, 1, 1], [1, 1, 1], [1, 1, 0]])
F3 = FiniteField(3)
    
print(smith_normal_form(m, domain=F3))