1 | initial version |
First, the "standard" way to do this is to change the base ring of the matrix as follows;
sage: B = A.change_ring(ZZ) ; B
[1 2 3]
[4 5 6]
sage: B.parent()
Full MatrixSpace of 2 by 3 dense matrices over Integer Ring
If P
is a parent and E
is some element, P(E)
tries to convert E
as an element of P
. Hence, when you do B = ZZ(A)
, Sage tries to transform the matrix into an integer, which leads to an error. If you want to use such a conversion, the parent P
you are looking for is the space of integer matrices of size 2*3 :
sage: P = MatrixSpace(ZZ,2,3)
sage: P
Full MatrixSpace of 2 by 3 dense matrices over Integer Ring
sage: P(A)
[1 2 3]
[4 5 6]
Or directly:
sage: MatrixSpace(ZZ,2,3)(A)
[1 2 3]
[4 5 6]
Note that it leads to the same result as with the change_ring
method:
sage: P(A) == B
True
sage: P == B.parent()
True