Hi, yesterday I asked for help in the channel to ask how I could achieve 
something like Matlab's repmat(): Julia also has a repmat() function, but 
only for two-dimensional arrays, whereas Matlab's implementation works for 
as many dimensions as you want. I found about repeat() but didn't 
understand the docstring (English is not my mother tongue, so that may be 
an important factor).

When I read the docstring, I was under the impression that repeat() would 
also only work for two dimensional arrays, which is actually not the case. 
Thanks to tkelman's help, I could replicate Matlab's repmat() behavior with 
repeat. 

Here is repeat()'s docstring:

Base.repeat(A, inner = Int[], outer = Int[])

   Construct an array by repeating the entries of "A". The i-th
   element of "inner" specifies the number of times that the
   individual entries of the i-th dimension of "A" should be
   repeated. The i-th element of "outer" specifies the number of
   times that a slice along the i-th dimension of "A" should be
   repeated.


Here is an example of what I wanted to achieve:

Let's create an array first:

A= diagm([1,2,3,4,5])

Now I want to have this same array repeated along a third dimension. In 
Matlab, I'd do this:

repmat(A,1,1,3)

to have a new array with A repeated three times along the third axis. In 
Julia, this same command doesn't work. So the user has to use repeat():

repeat(A,inner=[1,1,1],outer=[1,1,3])

repeat() is much more useful that Matlab's repmat(), but the docstring is 
unclear, at least for me. Unfortunately, I don't have, right now, any 
proposals to correct it. Could maybe an example be added to the docstring? 
Maybe it could be clearer this way.

Reply via email to