check matrix invertible before invoking invcheck, trim unnecessary
This commit is contained in:
parent
6eb450ddbe
commit
9ddeaaf907
@ -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) :
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user