# Computing Smith Normal Form of $\left(\begin{smallmatrix} 1 & c_{12} & c_{13} \\ 0 & 1 & c_{23} \\ 0 & 0 & 1 \\ \end{smallmatrix}\right)$

I think this is a simple question, I am looking for a program which computes the Smith normal form or rational canonical form of a matrix. Not something fancy, I want just to compute the Smith normal form of the following matrix $$\begin{pmatrix} 1 & c_{12} & c_{13} \\ 0 & 1 & c_{23} \\ 0 & 0 & 1 \\ \end{pmatrix},$$ where the entries are from an arbitrary field. Can you help me please?

• Smith normal form is for matrices over a PID, not over a field. – Bernard Jul 17 '16 at 11:21
• Yes, I mean that I want the smith normal form of the matrix $xI-A$ over $\mathbb{F}[x]$ – user321268 Jul 17 '16 at 11:27
• Never tried it, but I suppose it should work over fields known to PARI. – Bernard Jul 17 '16 at 11:43
• I didn't try yet but I really need to calculate it unfortunately. Thank you for your interest though! – user321268 Jul 17 '16 at 11:47
• In this context, it's easy to compute by hand: they're the similarity invariants of $A$. One finds $\;1,1, (x-1)^3$. – Bernard Jul 17 '16 at 15:34

PARI GP has such a function. From its documentation:

matsnf(X,{flag = 0})

If X is a (singular or non-singular) matrix outputs the vector of elementary divisors of X, i.e. the diagonal of the Smith normal form of X, normalized so that d_n | d_{n-1} | ... | d_1.

The binary digits of flag mean:

1 (complete output): if set, outputs [U,V,D], where U and V are two unimodular matrices such that UXV is the diagonal matrix D. Otherwise output only the diagonal of D. If X is not a square matrix, then D will be a square diagonal matrix padded with zeros on the left or the top.

2 (generic input): if set, allows polynomial entries, in which case the input matrix must be square. Otherwise, assume that X has integer coefficients with arbitrary shape.

4 (cleanup): if set, cleans up the output. This means that elementary divisors equal to 1 will be deleted, i.e. outputs a shortened vector D' instead of D. If complete output was required, returns [U',V',D'] so that U'XV' = D' holds. If this flag is set, X is allowed to be of the form `vector of elementary divisors' or [U,V,D] as would normally be output with the cleanup flag unset.

The library syntax is GEN matsnf0(GEN X, long flag).