summaryrefslogtreecommitdiff
path: root/numpy/core/defmatrix.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2007-03-26 19:23:04 +0000
committerCharles Harris <charlesr.harris@gmail.com>2007-03-26 19:23:04 +0000
commit14a5747967255b2fef4cf89ded1b3271ca3710ec (patch)
treeffdea925ffe33158cdf88a5914b2a99e68b59e4b /numpy/core/defmatrix.py
parent3b8ce0276bcae0c99790cab2c3fed417288d21cb (diff)
downloadnumpy-14a5747967255b2fef4cf89ded1b3271ca3710ec.tar.gz
Fix errors involving matrix*sparse
Diffstat (limited to 'numpy/core/defmatrix.py')
-rw-r--r--numpy/core/defmatrix.py12
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)