numpy.matlib.repmat()
— ceci est une autre fonction pour effectuer des opérations matricielles dans numpy. Renvoie un tableau Repeat 0-D, 1-D ou 2-D, ou une matrice M x N.
Syntaxe : numpy.matlib.repmat (a , m, n)
Paramètres :
a : [array_like] Le tableau ou la matrice d`entrée à répéter.
m, n : [int] Le nombre de fois que a est répété le long des premier et deuxième axes.Retour : [ndarray] tableau répétitif.
Code n° 1 :
Sortie : I tableau d`entrée [[ 1 0 2] [3 4 5]] Matrice répétée en sortie : [[1 0 2 1 0 2 1 0 2] [3 4 5 3 4 5 3 4 5] [1 0 2 1 0 2 1 0 2] [3 4 5 3 4 5 3 4 5]] Code # 2 :
|
Sortie :
Tableau d`entrée [0 1 2] Matrice répétée en sortie : [[0 1 2 0 1 2] [0 1 2 0 1 2]]