added eigcheck feature

This commit is contained in:
Lukasz M 2022-03-24 18:44:29 +01:00
parent 3e1d95d470
commit a037168e3f

View File

@ -36,6 +36,16 @@ def invcheck(a, b, rowcol, intmax):
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):
eigs = a.eigenvals()
for i in range(len(eigs)) :
val = sp.nsimplify(input("Input eigenvalue: "))
if not (val in eigs and eigs[val] == sp.nsimplify(input("Input its algebraic multiplicity: "))) :
# return false if the eigenvalue not in dictionary and wrong alg multiplicity
return False
return True
# practice function
def practice(t) :
count = 0
@ -50,6 +60,8 @@ def practice(t) :
f = detcheck
elif t == "inv" :
f = invcheck
elif t == "eig" :
f = eigcheck
else :
exit()