← Back to NumPy Course | Chapter 6: Math Operations | Lesson 6 of 7

np.dot() से Dot Product

np.dot() vectors या matrices को linear-algebra तरीके से multiply करता है।

In this page:

  1. np.dot()
Syntax
python
np.dot(a, b)
a @ b

np.dot()

दो 1-D arrays के लिए यह inner product return करता है; 2-D arrays के लिए यह matrix multiplication है। Inner dimensions match होनी चाहिए: (m, n) dot (n, p) (m, p) देता है। @ operator matrices के लिए modern equivalent है।

Note: दो vectors का dot matching elements की products add करता है।

उदाहरण: np.dot()

python
import numpy as np

v = np.array([1, 2, 3])
w = np.array([4, 5, 6])
print(np.dot(v, w))
A = np.array([[1, 2], [3, 4]])
B = np.array([[5, 6], [7, 8]])
print(np.dot(A, B))

# Output:
# 32
# [[19 22]
#  [43 50]]
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. #}
आम गलतियां
  1. dot को element-wise * से confuse करना
  2. mismatched inner dimensions वाली matrices multiply करना
  3. यह मान लेना कि order matter नहीं करता
चैप्टर सारांश
  • dot vectors के लिए inner product देता है
  • 2-D के लिए यह matrix multiplication है
  • Inner dimensions agree होनी चाहिए
  • Order matter करता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.