def scalar_mul(self): rows = int(input("\nHow many rows are in your matrix? ")) cols = int(input("How many columns are in your matrix? ")) scalar = int(input("What scalar are you multiplying your matrix by? ")) a = matrixinput.App(rows, cols).matrix scalar_a = matrixcalc.MatOperators().scalar_mul(a, scalar) print("\nThe scalar product of Matrix A is:") matrixcalc.print_matrix(scalar_a) input("\nPress ENTER to return to the menu\n") Interface().menu()
def mul(self): row1 = int(input("\nHow many rows are in Matrix A? ")) col1 = int(input("How many columns are in Matrix A? ")) row2 = int(input("\nHow many rows are in Matrix B? ")) col2 = int(input("How many columns are in Matrix B? ")) a = matrixinput.App(row1, col1).matrix b = matrixinput.App(row2, col2).matrix ab = matrixcalc.MatOperators().mul_matrices(a, b) print("\nThe product of Matrix A and Matrix B is:") matrixcalc.print_matrix(ab) input("\nPress ENTER to return to the menu\n") Interface().menu()
def navigate(selection): if selection == "1": return Interface().add_or_sub(matrixcalc.MatOperators().add_matrices) elif selection == "2": return Interface().add_or_sub(matrixcalc.sub_matrices) elif selection == "3": return Interface().mul() elif selection == "4": return Interface().scalar_mul() elif selection == "5": return Interface().transpose() elif selection == "6": return Interface().det() elif selection == "7": return Interface().inverse() elif selection == "8": exit() selection = input("Input not recognized. Please re-enter your selection: ") navigate(selection)