Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Smith Normal Form

After executing the following for computing snf of a matrix I got two different results. In the second case I expected to get integer transformation matrices.

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))
sage:print(C==B)
sage:show(B.smith_form())
sage:show(C.smith_form())

<class 'sage.matrix.matrix_rational_dense.Matrix_rational_dense'> 
<class 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>
True

([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])



([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])

Smith Normal Form

After executing the following for computing snf of a matrix I got two different results. In the second case I expected to get integer transformation matrices.

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))
sage:print(C==B)
sage:show(B.smith_form())
sage:show(C.smith_form())

<class 'sage.matrix.matrix_rational_dense.Matrix_rational_dense'> 
<class 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>
True

([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])



([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])

(sagecell)

Smith Normal Form

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

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

The code below can be run in sagecell.

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

sage: C = matrix(QQ, [ [1143, [[1143, 2361, -1995, 2694],\
2694],
                      [-342, -704, 595, -806],\
-806],
                      [-454, -936, 791, -1070],\
-1070],
                      [-521, -1077, 910, -1228]  ] )
sage:print(type(C),"\n",type(B))
sage:print(C==B)
sage:show(B.smith_form())
sage:show(C.smith_form())

-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])

(sagecell)