1.pdf
import numpy as np
# Creates an array of 4 x 4 with the main diagonal of 1
arr1 = np.eye(4)
print(arr1)
#[[1. 0. 0. 0.]
# [0. 1. 0. 0.]
# [0. 0. 1. 0.]
# [0. 0. 0. 1.]]
# or you can change the diagonal position
arr2 = np.eye(4, k=1) # or try with another number like k= -2
print(arr2)
#[[0. 1. 0. 0.]
# [0. 0. 1. 0.]
# [0. 0. 0. 1.]
# [0. 0. 0. 0.]]
# but you can't change the diagonal in identity
arr3 = np.identity(4)
print(arr3)
#[[1. 0. 0. 0.]
# [0. 1. 0. 0.]
# [0. 0. 1. 0.]
# [0. 0. 0. 1.]]
2.pdf
3.pdf
4.pdf
a = np.array([[1, 2], [3, 4]])
print(a)
# [[1 2]
# [3 4]]
a_t = a.transpose()
a.T
print(a_t)
# [[1 3]
# [2 4]]
print(a_t.transpose())
# [[1 2]
# [3 4]]
5.pdf
a = np.array([[1, 2], [3, 4]])
a_inv = np.linalg.inv(a)
6.pdf
7.pdf
8.pdf
9.pdf
10.pdf