![]() |
VOOZH | about |
Vectorization is a technique used to perform operations on entire arrays at once instead of iterating through elements using Python loops. It improves performance by using optimised implementations provided by libraries such as NumPy.
Example: Vectorization in NumPy
[ 2 4 6 8 10]
Explanation:
The dot product, also known as the inner product, is a mathematical operation that multiplies corresponding elements of two vectors of equal length and sums the resulting products to produce a single scalar value.
Example:
32
Explanation:
Syntax:
numpy.dot(a, b)
The outer product of two vectors produces a matrix containing the product of every element in the first vector with every element in the second vector.
Example:
[[3 4] [6 8]]
Explanation:
Syntax:
numpy.outer(a, b)
Element-wise multiplication multiplies each element of an array with the element at the same position in another array of the same shape. The operation returns a new array containing the products of the corresponding elements.
Example:
[ 4 10 18]
Explanation:
Syntax:
numpy.multiply(a, b)
Array addition is a mathematical operation in which corresponding elements of two equally shaped arrays are added together to create a new array. It is commonly used in numerical computing and data analysis for efficient vectorized calculations.
Example:
[5 7 9]
Explanation:
Syntax:
a + b
Matrix multiplication is a linear algebra operation in which rows of the first matrix are multiplied with columns of the second matrix to generate a new matrix. It is widely used in machine learning, computer graphics, and scientific computing.
Example:
[[19 22] [43 50]]
Explanation:
Syntax:
numpy.matmul(a, b)