summaryrefslogtreecommitdiff
path: root/numpy/core/defmatrix.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-04-27 07:24:30 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-04-27 07:24:30 +0000
commitde1b419c150add9b3f91ccfeccfb49e933ba0b95 (patch)
tree876cf44c69f120e763d57971106c459a8d90831c /numpy/core/defmatrix.py
parent6d4a9d0b1cc56a45286e118a67dad5dd0a21e343 (diff)
downloadnumpy-de1b419c150add9b3f91ccfeccfb49e933ba0b95.tar.gz
Bump up version number. Fix methods on matrices to preserve order. Add more scalar math (it now compiles). Add a missing API.
Diffstat (limited to 'numpy/core/defmatrix.py')
-rw-r--r--numpy/core/defmatrix.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py
index 662f6f62c..617fc811f 100644
--- a/numpy/core/defmatrix.py
+++ b/numpy/core/defmatrix.py
@@ -201,6 +201,7 @@ class matrix(N.ndarray):
def __str__(self):
return str(self.__array__())
+ # To preserve orientation of result...
def sum(self, axis=None, dtype=None):
"""Sum the matrix over the given axis. If the axis is None, sum
over all dimensions. This preserves the orientation of the
@@ -212,6 +213,83 @@ class matrix(N.ndarray):
else:
return s
+ def mean(self, axis=None):
+ s = N.ndarray.mean(self, axis)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def std(self, axis=None, dtype=None):
+ s = N.ndarray.std(self, axis, dtype)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def var(self, axis=None, dtype=None):
+ s = N.ndarray.var(self, axis, dtype)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def prod(self, axis=None, dtype=None):
+ s = N.ndarray.prod(self, axis, dtype)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def any(self, axis=None):
+ s = N.ndarray.any(self, axis)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def all(self, axis=None):
+ s = N.ndarray.all(self, axis)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def max(self, axis=None):
+ s = N.ndarray.max(self, axis)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def argmax(self, axis=None):
+ s = N.ndarray.argmax(self, axis)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def min(self, axis=None):
+ s = N.ndarray.min(self, axis)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def argmin(self, axis=None):
+ s = N.ndarray.argmin(self, axis)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
+ def ptp(self, axis=None):
+ s = N.ndarray.ptp(self, axis)
+ if axis==1:
+ return s.transpose()
+ else:
+ return s
+
# Needed becase tolist method expects a[i]
# to have dimension a.ndim-1
def tolist(self):