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
|
# invcheck function to check if the inverse of the matrix is correct
|
||||||
def invcheck(a, b, rowcol, intmax):
|
def invcheck(a, b, rowcol, intmax):
|
||||||
det = a.det()
|
# return bool based on if input equals inverse of matrix
|
||||||
if det != 0 :
|
print("What is the inverse of this matrix?")
|
||||||
# return bool based on if input equals inverse of matrix
|
return (sp.Matrix(inmat(rowcol)) == a.inv())
|
||||||
print("What is the inverse of this matrix?")
|
|
||||||
return (sp.Matrix(inmat(rowcol)) == a.inv())
|
|
||||||
|
|
||||||
# eigcheck function to check if the eigenvalues are correct
|
# eigcheck function to check if the eigenvalues are correct
|
||||||
def eigcheck(a, b, rowcol, intmax):
|
def eigcheck(a, b, rowcol, intmax):
|
||||||
@ -92,6 +90,9 @@ def practice(t) :
|
|||||||
if t == "diag" :
|
if t == "diag" :
|
||||||
while not a.is_diagonalizable :
|
while not a.is_diagonalizable :
|
||||||
a = genmatrix(rowcol, intmax, dif)
|
a = genmatrix(rowcol, intmax, dif)
|
||||||
|
if t == "inv" :
|
||||||
|
while a.det() == 0 :
|
||||||
|
a = genmatrix(rowcol, intmax, dif)
|
||||||
sp.pprint(a)
|
sp.pprint(a)
|
||||||
# if return of function is True
|
# if return of function is True
|
||||||
if f(a, b, rowcol, intmax) :
|
if f(a, b, rowcol, intmax) :
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user