check matrix invertible before invoking invcheck, trim unnecessary
This commit is contained in:
		
							parent
							
								
									6eb450ddbe
								
							
						
					
					
						commit
						9ddeaaf907
					
				| @ -38,8 +38,6 @@ 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() |  | ||||||
|     if det != 0 : |  | ||||||
|     # return bool based on if input equals inverse of matrix |     # return bool based on if input equals inverse of matrix | ||||||
|     print("What is the inverse of this matrix?") |     print("What is the inverse of this matrix?") | ||||||
|     return (sp.Matrix(inmat(rowcol)) == a.inv()) |     return (sp.Matrix(inmat(rowcol)) == a.inv()) | ||||||
| @ -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