[-1, 1, 0, 2, -5], [1, -1, 4, 2, 4], [-2, 2, -5, -1, -3]]) b2 = Vector([1, 5, 13, -1]) ls2 = LinearSystem(A2, b2) ls2.gauss_jordan_elimination() ls2.fancy_print() print() A3 = Matrix([[2, 2], [2, 1], [1, 2]]) b3 = Vector([3, 2.5, 7]) ls3 = LinearSystem(A3, b3) if not ls3.gauss_jordan_elimination(): print("No solution") ls3.fancy_print() print() A = Matrix([[1, 2], [3, 4]]) invA = inv(A) print(invA) print(invA.dot(A)) print(A.dot(invA)) print(rank(A1))
from playLA.Matrix import Matrix from playLA.Vector import Vector from playLA.LinearSystem import LinearSystem, inv if __name__ == "__main__": # A = Matrix([[1, 2 ,4], [3, 7, 2], [2, 3, 3]]) # b = Vector([7, -11, 1]) # A = Matrix([[1, -1, 2, 0, 3], # [-1, 1, 0, 2, -5], # [1, -1, 4, 2, 4], # [-2, 2, -5, -1, -3]]) # b = Vector([1, 5, 13, -1]) # ls = LinearSystem(A, b) # ls.gauss_jordan_elimination() # ls.fancy_print() A = Matrix([[1, 2], [3, 4]]) print(inv(A))
b = Vector([7, -11, 1]) ls = LinearSystem(A, b) ls.gauss_jordan_elimination() ls.fancy_print() A7 = Matrix([[1, -1, 2, 0, 3], [-1, 1, 0, 2, -5], [1, -1, 4, 2, 4], [-2, 2, -5, -1, -3]]) b7 = Vector([1, 5, 13, -1]) ls7 = LinearSystem(A7, b7) ls7.gauss_jordan_elimination() ls7.fancy_print() print() A8 = Matrix([[2, 2], [2, 1], [1, 2]]) b8 = Vector([3, 2.5, 7]) ls8 = LinearSystem(A8, b8) if not ls8.gauss_jordan_elimination(): print("No Solution!") ls8.fancy_print() print() A9 = Matrix([[1, 2], [3, 4]]) invA = inv(A9) print(invA) print(A9.dot(invA)) print(invA.dot(A9)) print(rank(A8)) print(rank(A7)) print(rank(A))
ls2 = LinearSystem(A2, b2) ls2.gauss_jordan_elimination() ls2.fancy_print() print() A3 = Matrix([[1, -1, 2, 0, 3], [-1, 1, 0, 2, -5], [1, -1, 4, 2, 4], [-2, 2, -5, -1, -3]]) b3 = Vector([1, 5, 13, -1]) ls3 = LinearSystem(A3, b3) if not ls3.gauss_jordan_elimination(): print("No solution") print("ls3") ls3.fancy_print() print() A4 = Matrix([[2, 2], [2, 1], [1, 2]]) b4 = Vector([3, 2.5, 7]) ls4 = LinearSystem(A4, b4) if not ls4.gauss_jordan_elimination(): print("No solution") ls4.fancy_print() print() A5 = Matrix([[1, 2], [3, 4]]) invA5 = inv(A5) print(invA5) print(A5.dot(invA5)) print(invA5.dot(A5)) print(rank(A3))