Question: For Symbol, we can declare it as a real-valued variable: x =
Symbol('x', real=True). Is there a way in sympy that we can declare a
MatrixSymbol of dimension M * N whose elements are real-valued variables ?
Why: In the problem I am working on, I need to compute the differentiation
of Abs of a matrix element (which is real-valued for my problem). However,
the sympy output for matrix element is not as nice as the output of the
differentiation of Abs of a real-value symbol. See the sample program:
>>> from sympy import *
>>> N = Symbol('N', integer=True)
>>> M = MatrixSymbol('M', N, N)
>>> diff(Abs(M[0,0]), M[0,0])
(re(M[0, 0])*Subs(Derivative(re(_xi_2), _xi_2), (_xi_2,), (M[0, 0],)) +
im(M[0, 0])*Subs(Derivative(im(_xi_2), _xi_2), (_xi_2,), (M[0,
0],)))/Abs(M[0, 0])
>>> X = Symbol('X', real=True)
>>> diff(Abs(X), X)
sign(X)
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/c8ad1f75-f199-4136-b257-40e6b7cc0ed9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.