Hello,
here is a tiny patch to generalize Matrix.subs() with a working test.

diff -r 55980b35927e sympy/matrices/matrices.py
--- a/sympy/matrices/matrices.py        Sat Jun 14 21:09:27 2008 +0200
+++ b/sympy/matrices/matrices.py        Sun Jun 15 18:44:16 2008 +0200
@@ -251,9 +251,9 @@
         out[:,:] = Matrix(self.lines, self.cols, lambda i,j:
self[i,j].combine())
         return out

-    def subs(self,a,b):
+    def subs(self, *args):
         out = self[:,:]
-        out[:,:] = Matrix(self.lines, self.cols, lambda i,j:
self[i,j].subs(a,b))
+        out[:,:] = Matrix(self.lines, self.cols, lambda i,j:
self[i,j].subs(*args))
         return out

     def __sub__(self,a):
diff -r 55980b35927e sympy/matrices/tests/test_matrices.py
--- a/sympy/matrices/tests/test_matrices.py     Sat Jun 14 21:09:27
2008 +0200
+++ b/sympy/matrices/tests/test_matrices.py     Sun Jun 15 18:44:16
2008 +0200
@@ -712,6 +712,10 @@
 def test_subs():
     x = Symbol('x')
     assert Matrix([[1,x],[x,4]]).subs(x, 5) == Matrix([[1,5],[5,4]])
+    y = Symbol('y')
+    assert Matrix([[x,2],[x+y,4]]).subs([[x,-1],[y,-2]]) ==
Matrix([[-1,2],[-3,4]])
+    assert Matrix([[x,2],[x+y,4]]).subs([(x,-1),(y,-2)]) ==
Matrix([[-1,2],[-3,4]])
+    assert Matrix([[x,2],[x+y,4]]).subs({x:-1,y:-2}) ==
Matrix([[-1,2],[-3,4]])


 def test_conjugate():

Now we can use also _subs_dict, and _subs_list with matrices.

Thank you for sympy

Riccardo Gori
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to