-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Closed
Labels
Description
Reproducing code example
# coding:utf-8
import numpy as np
def rand_matrix(m, n):
temp = np.random.randint(m, n, [3, 3])
return np.mat(temp)
def inversion(m, n):
temp = rand_matrix(m, n)
print("random matrix is:\n ", temp)
try:
output = temp.I
print("random matrix's inversion is:\n", output)
print(np.dot(temp, output))
return output
except np.linalg.linalg.LinAlgError as err:
print("the matrix is singular matrix which inversion doesn't exist")
inversion(1, 20)
result:
I run the code several times. The result of running the code was similar to the screenshot. The code produces a random 3*3 matrix named temp, then calculates the inverse of the random matrix. Finally, I called numpy.dot() for examination. But the result exceeding my expectations, the result wasn't identity matrix
Numpy/Python version information:
Python --version 3.6.3
numpy --version 1.13.3