diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2007-03-26 19:23:04 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2007-03-26 19:23:04 +0000 |
commit | 14a5747967255b2fef4cf89ded1b3271ca3710ec (patch) | |
tree | ffdea925ffe33158cdf88a5914b2a99e68b59e4b /numpy/core/defmatrix.py | |
parent | 3b8ce0276bcae0c99790cab2c3fed417288d21cb (diff) | |
download | numpy-14a5747967255b2fef4cf89ded1b3271ca3710ec.tar.gz |
Fix errors involving matrix*sparse
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) |