diff options
Diffstat (limited to 'numpy/core/defmatrix.py')
-rw-r--r-- | numpy/core/defmatrix.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py index f6ecbcaad..33efe2b99 100644 --- a/numpy/core/defmatrix.py +++ b/numpy/core/defmatrix.py @@ -154,12 +154,12 @@ class matrix(N.ndarray): def __mul__(self, other): - if not isscalar(other) : - try : - other = asmatrix(other) - except : - return NotImplemented - return N.dot(self, other) + if isinstance(other,(N.ndarray, list, tuple)) : + # This promotes 1-D vectors to row vectors + return N.dot(self, asmatrix(other)) + if N.isscalar(other) or not hasattr(other, '__rmul__') : + return N.dot(self, other) + return NotImplemented def __rmul__(self, other): return N.dot(other, self) |