Programming Language: Python

Namespace/Package Name: numpy

Class/Type: ndarray

Method/Function: dot

Examples at hotexamples.com: 37

Python numpy library provides a powerful data structure called ndarray which is a multi-dimensional array. The dot function in numpy ndarray is used to perform matrix multiplication (dot product) between two arrays.

Here are some example code snippets using numpy ndarray dot function:

**Example 1** - Multiplying 1D arrays

Output: 32

**Example 2** - Multiplying 2D arrays

Output:

**Example 3** - Multiplying 3D arrays

Output:

Here are some example code snippets using numpy ndarray dot function:

import numpy as np a = np.array([1,2,3]) b = np.array([4,5,6]) c = np.dot(a, b) print(c)

Output: 32

import numpy as np a = np.array([[1, 2], [3, 4]]) b = np.array([[5, 6], [7, 8]]) c = np.dot(a, b) print(c)

Output:

[[19, 22], [43, 50]]

import numpy as np a = np.array([[[1,2], [3,4]], [[5,6], [7,8]]]) b = np.array([[[9,10], [11,12]], [[13,14], [15,16]]]) c = np.dot(a, b) print(c)

Output:

[[[ 23, 26], [ 53, 60]], [[119, 130], [163, 178]]]The examples above are using the numpy package library.

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Related in langs

Frequently Used Methods

Related