Am Samstag, 12. Mai 2012 19:17:03 UTC+2 schrieb Stefan Krastanov:
>
> If we do this it would be possible to write stuff like `eye(2)*[x, y]` 
> and it will work. 


This could be implemented in Matrix.__mul__ and __rmul__. However, I'm not 
really sure it's a good idea.

In numpy we have this behavior:

>>> from numpy import *
>>> a = matrix([[1,2],[3,4]])
>>> a*[1,-1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py", 
line 330, in __mul__
    return N.dot(self, asmatrix(other))
ValueError: objects are not aligned
>>> [1,-1]*a
matrix([[-2, -2]])
>>> a = array([[1,2],[3,4]])
>>> [1,-1]*a
array([[ 1, -2],
       [ 3, -4]])
>>> a*[1,-1]
array([[ 1, -2],
       [ 3, -4]])

So it treats [1, -1] as a row vector.

Vinzent

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sympy/-/gOhhUU6TIK8J.
To post to this group, send email to [email protected].
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