## Creation of Matrix:

### Operations on Matrix :

1. Creation of 2D matrix:- we can create a 2D matrix using numpy.
import numpy as np
a = np.matrix('1 2 ; 3 4')
print(a)
OutPut: [[1 2]
[3 4]]
b = np.matrix('1 2 ; 3 4')
print(b)
OutPut:  [[1 2]
[3 4]]

2. Creation of 3D matrix:-  we can create a 3D matrix using numpy.
import numpy as np
a = np.matrix('1 2 3 ; 11 12 13 ; 21 22 23')
print(a)
Output: [[ 1  2  3]
[11 12 13]
[21 22 23]]
b = np.matrix('1 2 3 ; 5 6 1 ; 3 3 4')
print(b)
Output: [[1 2 3]
[5 6 1]
[3 3 4]]

3. Addition():- This function is used to perform element wise addition operation on a given Matrix.

c = a+b
print(c)
Output:  [[ 2  4  6]
[16 18 14]
[24 25 27]]

Also, Read the Basics of Python Programming

4. Subtraction():- This function is used to  perform element wise matrix subtraction.

d = a-b
print(d)
Output:   [[ 0  0  0]
[ 6  6 12]
[18 19 19]]

5. Multiplication():- This function is used to perform element-wise matrix multiplication.

e = a*b
print(e)
Output:  [[ 20  23  17]
[110 133  97]
[200 243 177]]

6. Division():- This function is used to perform element-wise matrix division.

f = a/b
print(f)
Output: [[ 1.          1.          1.        ]
[ 2.2         2.         13.        ]
[ 7.          7.33333333  5.75      ]]

7. Transpose of a Matrix:- This function is used to transpose a certain matrix.

g = np.transpose(a)
print(g)
Output:  [[ 1 11 21]
[ 2 12 22]
[ 3 13 23]]

8. Inverse of a Matrix:- This function is used to perfrom inverse operation on a matrix.

h = a.I
print(h)
Output: [[ 2.81474977e+14 -5.62949953e+14  2.81474977e+14]
[-5.62949953e+14  1.12589991e+15 -5.62949953e+14]
[ 2.81474977e+14 -5.62949953e+14  2.81474977e+14]]

Also, Read Introduction to Python Programming

9. Creation of zeros Matrix:- Create a matrix filled of zeroes with the use of  np.zeros

i = np.zeros([3,3])
print(i)
Output:  [[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]

10. Creation of ones Matrix:- Create a matrix filled of ones with the use of  np.ones

j = np.ones([3,3])
print(j)
Output:  [[1. 1. 1.]
[1. 1. 1.]
[1. 1. 1.]]

11. Determinant of a Matrix:- This function is used to return Determinant of a Matrix.

k = np.matrix([[1,3],[5,8]])
print(k)
Output:   [[1 3]
[5 8]]
l = np.linalg.det(k)
print(l)
Output:    -6.999999999999999

Also, Read Introduction to Python Programming

12. Vector Product of a Matrix:- This function is used to perform Vector Product of a Matrix

q = np.array([[1,5],[3,9]])
print(q)
Output:    [[1 5]
[3 9]]

r = np.array([[5,8],[9,4]])

print(r)
Output:  [[5 8]
[9 4]]
s = np.vdot(q,r)
print(s)
Output:    108

13. Dot():-This function is used to perform matrix multiplication, rather than element-wise matrix multiplication.
m = np.matrix([[1,5],[3,9]])
print(m)
Output:  [[1  5]
[3  9]]

n = np.matrix([[5,8],[9,4]])

print(n)
Output: [[5  8]
[9  4]]
z = np.dot(m,n)
print(z)
Output: [[50 28]
[96 60]