[Numpy-discussion] general version of repmat?
Bill Baxter
wbaxter at gmail.com
Thu Sep 21 22:34:49 EDT 2006
Is there some way to get the equivalent of repmat() for ndim == 1 and ndim >2.
For ndim == 1, repmat always returns a 2-d array, instead of remaining 1-d.
For ndim >2, repmat just doesn't work.
Maybe we could add a 'reparray', with the signature:
reparray(A, repeats, axis=None)
where repeats is a scalar or a sequence.
If 'repeats' is a scalar then the matrix is duplicated along 'axis'
that many times.
If 'repeats' is a sequence of length N, then A is duplicated
repeats[i] times along axis[i]. If axis is None then it is assumed to
be (0,1,2...N).
Er that's not quite complete, because it doesn't specify what happens
when you reparray an array to a higher dimension, like a 1-d to a 3-d.
Like reparray([1,2], (2,2,2)). I guess the axis parameter could have
some 'newaxis' entries to accomodate that.
--bb
More information about the NumPy-Discussion
mailing list