Rank of Matrix
import numpy as np
x = np.matrix("4,5,16,7;2,-3,2,3;,3,4,5,6;4,7,8,9")
print(x)
[[ 4 5 16 7]
[ 2 -3 2 3]
[ 3 4 5 6]
[ 4 7 8 9]]
#numpy.linalg.matrix_rank() - return a rank of a matrix
# Syntax: numpy.linalg.matrix_rank(matrix)
rank_matrix = np.linalg.matrix_rank(x)
print(rank_matrix)
4
Determinant of Matrix
import numpy as np
x = np.matrix("4,5,16,7;2,-3,2,3;,3,4,5,6;4,7,8,9")
print(x)
[[ 4 5 16 7]
[ 2 -3 2 3]
[ 3 4 5 6]
[ 4 7 8 9]]
det_matrix = np.linalg.det(x)
print(det_matrix)
128.00000000000009
Inverse of a Matrix
inverse formula = A-1 = (1/determinant of A) * adj A
numpy.linalg.inv() - return the multiplicative inverse of a matrix Syntax: numpy.linalg.inv(matrix)
A = np.matrix("3,1,2;3,2,5;6,7,8")
print(A)
[[3 1 2]
[3 2 5]
[6 7 8]]
Inv_matrix = np.linalg.inv(A)
print(Inv_matrix)
[[ 0.57575758 -0.18181818 -0.03030303]
[-0.18181818 -0.36363636 0.27272727]
[-0.27272727 0.45454545 -0.09090909]]
0 Comments:
Post a Comment