From 3e1d95d470d9101227250748ec59c1fa0cb01269 Mon Sep 17 00:00:00 2001 From: Lukasz M Date: Thu, 24 Mar 2022 18:43:36 +0100 Subject: [PATCH] added invcheck feature --- linalg-practice.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linalg-practice.py b/linalg-practice.py index 49f0a94..032e0b1 100644 --- a/linalg-practice.py +++ b/linalg-practice.py @@ -28,6 +28,14 @@ def detcheck(a, b, rowcol, intmax): # return bool based on if input equals determinant return (det == sp.nsimplify(input("What is the determinant of this matrix?: "))) +# 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()) + # practice function def practice(t) : count = 0 @@ -40,6 +48,8 @@ def practice(t) : f = multcheck elif t == "det" : f = detcheck + elif t == "inv" : + f = invcheck else : exit()