summaryrefslogtreecommitdiff
path: root/numpy/matlib.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-10-07 02:12:09 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-10-07 02:12:09 +0000
commit1ff0cd9948e79eecd2c8ec9ac9aa88c81c6b9dfc (patch)
tree5f7b0c9161a42b9b9738cf59b5bab5b7bfe31f06 /numpy/matlib.py
parent831feb757019ebbeb911e867e30700581629140f (diff)
downloadnumpy-1ff0cd9948e79eecd2c8ec9ac9aa88c81c6b9dfc.tar.gz
Add tile to numpy and move repmat to matlib.py
Diffstat (limited to 'numpy/matlib.py')
-rw-r--r--numpy/matlib.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/numpy/matlib.py b/numpy/matlib.py
index 6728cdb2f..6035f394f 100644
--- a/numpy/matlib.py
+++ b/numpy/matlib.py
@@ -6,7 +6,7 @@ from numpy import *
__version__ = N.__version__
__all__ = N.__all__[:] # copy numpy namespace
-__all__ += ['rand', 'randn']
+__all__ += ['rand', 'randn', 'repmat']
def empty(shape, dtype=None, order='C'):
"""return an empty matrix of the given shape
@@ -48,4 +48,18 @@ def randn(*args):
args = args[0]
return asmatrix(N.random.randn(*args))
-
+def repmat(a, m, n):
+ """Repeat a 0-d to 2-d array mxn times
+ """
+ a = asanyarray(a)
+ ndim = a.ndim
+ if ndim == 0:
+ origrows, origcols = (1,1)
+ elif ndim == 1:
+ origrows, origcols = (1, a.shape[0])
+ else:
+ origrows, origcols = a.shape
+ rows = origrows * m
+ cols = origcols * n
+ c = a.reshape(1,a.size).repeat(m, 0).reshape(rows, origcols).repeat(n,0)
+ return c.reshape(rows, cols)