|
From: Alex L. <ale...@gm...> - 2006-02-24 00:47:29
|
Another thought:
def repmat(a,m,n):
from scipy import hstack, vstack
a =3D eval('hstack(('+n*'a,'+'))')
return eval('vstack(('+m*'a,'+'))')
may hstack() and vstack() be better for 1d arrays?
>>> from scipy import *
numerix Numeric 24.2
>>> a =3D array([1,2])
>>> repmat(a,2,3)
array([[1, 2, 1, 2, 1, 2],
[1, 2, 1, 2, 1, 2]])
>>> equal(repmat(1,1,1),1)
array([ [1]],'b')
of course, scipy.linalg.kron(ones((m,n,p,...)),a) is more robust and
works for higher dimensions. probably it's the best.
|