Matrix Multiplication (@) ऑपरेटर
@ operator matrices को proper linear-algebra तरीके से multiply करता है।
In this page:
Syntax
result = a @ b
result = np.matmul(a, b)
Matrix Multiplication (@)
Python 3.5 में introduce हुआ, @ np.matmul में map होता है। 2-D arrays के लिए यह standard row-by-column product है। matrices के stacks के लिए यह leading dimensions पर broadcast करता है।
Note:
कई products chain करते वक्त A @ B, np.dot(A, B) से clearer है।
उदाहरण: Matrix multiplication (@)
import numpy as np
A = np.array([[1, 2], [3, 4]])
B = np.array([[0, 1], [1, 0]])
print(A @ B)
print(B @ A)
print(A * B)
# Output:
# [[2 1]
# [4 3]]
# [[3 4]
# [1 2]]
# [[0 2]
# [3 0]]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- @ की बजाय * इस्तेमाल करना
- Inner dimensions को mismatched रखना
- यह मान लेना कि A @ B, B @ A के बराबर है
चैप्टर सारांश
- @ matrix multiplication है
- * element-wise है
- (m, n) @ (n, p) (m, p) देता है
- Commutative नहीं है
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: