That's how I understood it because he was messing around. Thank you for the fix and hope this helps.
Say you have an M matrix of 2x3 elements. Obviously, this has two dimensions.
I do not see the difference between Matlab and Python, asking me to manipulate the input matrix in the sizes that the matrix already has. So the two teams
repmat(M,m,n) % matlab np.tile(M,(m,n))
really equivalent for a rank 2 matrix (two dimensions).
Questions contradict intuition when you request repetition / splitting into several dimensions than the input matrix. Returning to the second-rank matrix M and the 2x3 shape, just look at what happens to the size / shape of the output matrix. Let's say that the sequence of manipulations is now 1,1,2.
In matlab
> size(repmat(M,1,1,2)) ans = 2 3 2
he copied the first two dimensions (rows and columns) of the input matrix and repeated it once to a new third dimension (it is copied twice, that is). True for naming repmat for rematrix.
In python
>>> np.tile(M,(1,1,2)).shape (1, 2, 6)
he applied a different procedure because, I believe, the sequence (1,1,2) is read differently than in Matlab. The number of copies in the direction of columns, rows, and dimension outside the plane is read from right to left. The resulting object has a different form from Matlab. It can no repmat be argued that repmat and tile are equivalent instructions.
To make tile behave like repmat , in Python you need to make sure that the input matrix has the same size as the elements in the sequence. This is done, for example, by a small precondition and the creation of a related object N
N = M[:,:,np.newaxis]
Then on the input side there is N.shape = (2,3,1) , not M.shape = (2,3) , but on the output side
>>> np.tile(N,(1,1,2)).shape (2, 3, 2)
which was the answer of size(repmat(M,1,1,2)) . I assume that this is due to the fact that we were guided by Python to add the third dimension to the right of (2,3), and not to the left, so Python develops the sequence (1,1,2), as provided in the Matlab method his reading.
The element in [:,:,0] in the Python answer for N will contain the same values as the element (:,:,1) ,, (:,:,1) Matlab answer for M.
Finally, I cannot find the equivalent for repmat when you use the Kronecker product from
>>> np.kron(np.ones((1,1,2)),M).shape (1, 2, 6)
if I did not stipulate condition M in N , as indicated above. Therefore, I would say that the most common way to move on is to use np.newaxis methods.
The game gets harder if we look at a rank 3 matrix L (three dimensions) and the simple case of adding new dimensions to the output matrix. These two seemingly equivalent instructions will not produce the same results.
repmat(L,p,q,r) % matlab np.tile(L,(p,q,r))
because the rows, columns, unplanned directions are (p, q, r) in Matlab and (q, r, p) in Python, which were not visible in the ranks of the 2nd level. There you need to be careful, and getting the same results with two languages will require more preliminary training.
I know that this reasoning may well be general, but I could only figure it out. Hopefully this will invite other fellows to test it at a tough level.