Ask Your Question

Revision history [back]

Use M.change_ring(SR) to change the entries of M to lie in the symbolic ring. Note that M.change_ring(SR) will still be a matrix. On the other hand, SR(M) is not a matrix. For most uses, I think that M.change_ring(SR) is the right choice.

sage: M = matrix([[0, -1], [1, 0]])
sage: type(SR(M))
<class 'sage.symbolic.expression.Expression'>
sage: type(M.change_ring(SR))
<class 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'>
sage: M.change_ring(SR) == M
sage: M.change_ring(SR) + M
[ 0 -2]
[ 2  0]