diff --git a/linalg-practice.py b/linalg-practice.py index 9f7c032..1f59dc8 100644 --- a/linalg-practice.py +++ b/linalg-practice.py @@ -38,11 +38,9 @@ def detcheck(a, b, rowcol, intmax): # invcheck function to check if the inverse of the matrix is correct def invcheck(a, b, rowcol, intmax): - det = a.det() - if det != 0 : - # return bool based on if input equals inverse of matrix - print("What is the inverse of this matrix?") - return (sp.Matrix(inmat(rowcol)) == a.inv()) + # return bool based on if input equals inverse of matrix + print("What is the inverse of this matrix?") + return (sp.Matrix(inmat(rowcol)) == a.inv()) # eigcheck function to check if the eigenvalues are correct def eigcheck(a, b, rowcol, intmax): @@ -92,6 +90,9 @@ def practice(t) : if t == "diag" : while not a.is_diagonalizable : a = genmatrix(rowcol, intmax, dif) + if t == "inv" : + while a.det() == 0 : + a = genmatrix(rowcol, intmax, dif) sp.pprint(a) # if return of function is True if f(a, b, rowcol, intmax) :