DEV Community

Punitha
Punitha

Posted on

Matrix Multiplication & Universal Functions

What is Matrix Multiplication?

  • Matrix multiplication is an operation used to multiply two compatible arrays or matrices.

NumPy provides two common ways:

a @ b
Enter fullscreen mode Exit fullscreen mode

and

np.matmul(a, b)
Enter fullscreen mode Exit fullscreen mode

Step 1:

Output:

Universal Functions

  • Cumulative Sum – cumsum()

What is cumsum()?

  • cumsum() calculates the running total of the elements.

Step 1:

Output:

  • Cumulative Product – cumprod()

What is cumprod()?

  • cumprod() calculates the running multiplication of the elements.

Step 1:

Output:

Minimum and Maximum

  • NumPy provides functions to find the smallest and largest values.

min() & argmin()

  • min() returns the smallest value.
  • argmin() returns the index of the minimum value.

Step 1:

Output:

max() & argmax()

  • max() returns the largest value.
  • argmax() returns the index of the maximum value.

Step 1:

Output:

Top comments (0)