Exercice 9
Programme qui renvoie la multiplication de deux matrices numpy.
Solution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import numpy as np A = np.array([[1 , 1], [2 , -1]]) B = np.array([[2 , -1], [3 , 3]]) C = A@B # on peut aussi utiliser C = np.dot(A , B) # on peut aussi utiliser C = np.matmul(A , B) print(C) """ affiche: [[ 5 2] [ 1 -5]] """ |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercice 9: multiplication de deux matrices numpy”