Official documentation:
Personal Understanding: Return Value
Ndarray, which returns a multi-digit group after reps repeats...
Parameters
A can be almost all types, array, list, tuple, dict, matrix, Int, long, STR, bool, etc.
Reps, there are many types, such as array, tuple, list, dict, Int, long, And bool. But in any case, it must be a one-dimensional array (not necessarily an array, which is a class one-dimensional array) ", such as [1, 2, 3], (1, 2, 3), or 3.
Implementation Process
1: Set Ndim = a dimension, ndimsa [] = length of each coordinate component of
D = reps length (because reps must be a "class one-dimensional array ")
Ans = tile (a, d), ndimsans [] = the length of each coordinate component of ANS
2: ANS. Ndim = max (A. Ndim, d)
If a. Ndim> = D:
For example, ndims = (,), reps =)
So ndims [] remains unchanged. Add a. Ndim-D '1' before the reps array, then reps =)
Otherwise, A. Ndim <D:
For example, ndims = (2, 3), reps = (1, 2, 3, 4)
At this time, the ndims dimension is not enough, you should add the dimension to D, similarly add the d-A.ndims before ndims '1', that is, ndims)
3: Calculate ndimsans []
Because ndims and reps have the same length through 2, ndimsans = (ndism [0] * reps [0], ndims [1] * reps [1], ndims [2] * reps [2],...) multiply the index value
For example, ndims = (,), reps =)
So ndimsans = (2*1, 3*1, 4*2) =)
4: Calculate ans
The dimension size of ANS is determined through 2, and the length of each dimension component of ANS is determined through 3.
Note that the repetition of dimensions starts from the right side (which can be understood as from the low dimension). For details, see the following example.
Example:
>>> A = array ([[1, 2], [3, 4])
>>>
Array ([[1, 2],
[3, 4])
>>> Reps = (1, 2, 3)
>>> Ans = tile (A, reps)
>>> Ans
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])
>>> Ans. Shape
(1, 4, 6)
From a low dimension, repeat the column three times to obtain a' = [1, 2, 2, 2],
[3, 4, 3, 4]
Repeat the previous steps twice to obtain a ''= [[1, 2, 2, 2],
[3, 4, 3, 4],
[1, 2, 1, 2],
[3, 4, 3, 4]
Repeat the last layer once (unchanged), ANS = [[1, 2, 1, 2],
[3, 4, 3, 4],
[1, 2, 1, 2],
[3, 4, 3, 4]
Therefore, there is a 3-dimensional array (, 6) at most.