I would like to write an expression using Matrix symbols, and then evaluate 
it by substituting concrete Matrix values.   However, the resulting Matrix 
expression will not simplify.

# set up general expression
n = Symbol('n')
r1 = MatrixSymbol('r1',n,1)
r2 = MatrixSymbol('r2',n,1)
d = r2 - r1

# concrete vectors to substitute
c1 = Matrix([1.1, 2.3, 4.4])
c2 = Matrix([0.1, 2.1, 4.3])

# evaluate
d = d.subs(n,3)
r1 = r1.subs(n,3)
r2= r2.subs(n,3)

d2 = d.subs({r1:c1, r2:c2})
print d2.doit()

The result is a matrix add:

Matrix([
[-1.1],
[-2.3],
[-4.4]]) + Matrix([
[0.1],
[2.1],
[4.3]])


I suspect the 'canonicalize' rules in matadd.py need to be enhanced to fix 
this?


(If the final result is put in a Matrix it gives the expected result: 
"print Matrix(d2)".  This is not a general solution - it only works if the 
expression is known to be a Matrix.)





-- 
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 sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to