[Numpy-discussion] repmat equivalent?
fullung at gmail.com
Thu Feb 23 13:22:01 CST 2006
On 2/23/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> Albert Strasheim wrote:
> >Hello all
> >I recently started using NumPy and one function that I am really
> >missing from MATLAB/Octave is repmat. This function is very useful for
> >implementing algorithms as matrix multiplications instead of for
> There is a function in scipy.linalg called kron that could be brought
> over which can do a repmat.
> kron(ones((2,3)), arr)
> >>> sl.kron(ones((2,3)),arr)
> array([[1, 2, 1, 2, 1, 2],
> [3, 4, 3, 4, 3, 4],
> [1, 2, 1, 2, 1, 2],
> [3, 4, 3, 4, 3, 4]])
> gives you the equivalent of
> repmat(arr, 2,3)
Thanks! Merging this into numpy would be much appreciated. Stefan van
der Walt did some benchmarks and this approach seems faster than
anything we managed for 2D arrays.
However, I'm a bit concerned about the ones(n,m) that is needed by
this implementation. It seems to me that this would double the memory
requirements of this repmat function, which is fine when working with
small matrices, but could be a problem with larger ones.
More information about the Numpy-discussion