Ask Your Question
1

Smith Normal Form

asked 2022-10-23 02:15:27 +0100

draz gravatar image

updated 2022-10-31 18:58:37 +0100

slelievre gravatar image

After executing the following for computing the snf (or Smith normal form) of a matrix I got two different results.

In the second case I expected to get integer transformation matrices.

The code below can be run in sagecell.

sage: B = matrix([[1143, 2361, -1995, 2694],
                  [-342, -704, 595, -806],
                  [-454, -936, 791, -1070],
                  [-521, -1077, 910, -1228]])

sage: C = matrix(QQ, [[1143, 2361, -1995, 2694],
                      [-342, -704, 595, -806],
                      [-454, -936, 791, -1070],
                      [-521, -1077, 910, -1228]])

sage: print(type(C), "\n", type(B))
<class 'sage.matrix.matrix_rational_dense.Matrix_rational_dense'> 
<class 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>

sage: print(C == B)
True

sage: show(B.smith_form())
([1 0 0 0]   [ 0  1  0  0] 
 [0 1 0 0]   [-5 -1 -3 -8]
 [0 0 0 0]   [19  3 10 31]
 [0 0 0 0],  [ 7  0  5 11], 

[      0       0       1       0]
[   4505     -53 1549031     112]
[   5715     -60 1963950     142]
[    284       2   96814       7])

sage: show(C.smith_form())
([1 0 0 0]  [ 1/1143       0       0       0]
 [0 1 0 0]  [ 19/155 127/310       0       0]
 [0 0 0 0]  [   8/45  -11/15       1       0]
 [0 0 0 0], [    5/9     1/3       0       1],

[       1 -787/381     7/62   -71/31]
[       0        1    49/62    -1/31]
[       0        0        1        0]
[       0        0        0        1])
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-23 04:51:48 +0100

In the second case you are explicitly defining a matrix over the rationals, so you get rational matrices as output. There is an option C.smith_form(integral=True) which will force Sage to work over the integers. That happens to give different integer matrices than B.smith_form() in this case.

edit flag offensive delete link more

Comments

OK. I tried this, I got different transformation matrices (for cases (1),(2)) . But the cases (1) and (3) provides exactly the same Transformation matrices.

B.smith_form() #1
C.smith_form(integral=True) #2
matrix(ZZ,C).smith_form() #3

I had in my mind that snf is defined over a PID, so I supposed even if the matrix is defined over Q, finally I get the transformation matrices over Z. Thanks.

draz gravatar imagedraz ( 2022-10-23 14:10:15 +0100 )edit

There is nothing unexpected here. While the SNF is defined uniquely, there may exist different transformation matrices (resulting in the same SNF).

Max Alekseyev gravatar imageMax Alekseyev ( 2022-10-23 20:12:58 +0100 )edit
1

Also, the code used for integer matrices is different from that used for general matrices (even when integral=Trueis specified). So it is not an issue that the transformation matrices are different. Integer matrices: https://github.com/sagemath/sage/blob.... General matrices, including over QQ: https://github.com/sagemath/sage/blob...

John Palmieri gravatar imageJohn Palmieri ( 2022-10-23 22:07:34 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-10-23 02:15:27 +0100

Seen: 703 times

Last updated: Oct 31 '22