1 | initial version |
sage: M = matrix(2,2,var('a b c d'))
sage: M; M.parent(); M(a=5)
[a b]
[c d]
Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring
[5 b]
[c d]
We can use substitution M(a=5)
(looking similar to a function call).
What happens if we try to use M as variable of a function?
sage: M = matrix(2,2,var('a b c d'))
sage: print M.parent(); print
sage: f(M) = M.transpose()
The error message indicates that the type of M has changed.
Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring
Traceback (click to the left of this block for traceback)
...
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'transpose'
M is no longer a matrix over SR but a symbolic expression.
sage: M.parent()
Symbolic Ring
When defining a symbolic function with a variable M, this M becomes (implicitly) a member of SR overwriting the previous definition of M. After redefining M as matrix:
sage: A = M[0,0] + M[1,1]
sage: A; A(a=5,b=3,c=0,d=-2)
a + d
3