xCircle

DSL Practical-3

Dec 24th, 2022
815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | Source Code | 0 0
  1. # DSL Practical 3
  2. # @author: xCircle (Pranav)
  3.  
  4. import numpy as np
  5.  
  6. m1 = np.array([[1,2,3], [4,5,6], [7,8,9]])
  7. m2 = np.array( [[7,8,9], [1,2,3], [4,5,6]])
  8.  
  9. print("Addition of m1 m2")
  10. print(np.add(m1,m2))    # Add two matrices
  11.  
  12. print("Subtraction of m1 m2")
  13. print(np.subtract(m1,m2))    # Subtract two matrices
  14.  
  15. print("Multiplication of m1 m2")
  16. print(np.multiply(m1,m2))    # Multiply two matrices
  17.  
  18. print("Division of m1 m2")
  19. print(np.divide(m1,m2))    # Divide two matrices
  20.  
  21. print("Transpose of m1")
  22. print(m1.T)    # Transpose of a matrix
  23.  
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment