Ask Your Question

Revision history [back]

Indeed, when you write:

sage: M=matrix([[2+I,0],[0,1]])

The number I belongs to the symbolic ring, hence the matrix M is defined over the symbolic ring:

sage: M.parent()
Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring

You can chant this by redefining I to belong to the gaussian integers:

sage: R = ZZ[I] ; R
Gaussian Integers in Number Field in I with defining polynomial x^2 + 1
sage: I = R.basis()[1]
sage: M=matrix([[2+I,0],[0,1]]) 
sage: M.parent()
Full MatrixSpace of 2 by 2 dense matrices over Gaussian Integers in Number Field in I with defining polynomial x^2 + 1

Then, you can ask for the Smith form:

sage: M.smith_form()
(
[    1     0]  [    0     1]  [ 1 -1]
[    0 I + 2], [   -1 I + 2], [ 1  0]
)