def do_add_matrices(): """Add two matrices""" matrix1 = build_matrix( enter_size.format(first), enter_matrix.format(first) ) matrix2 = build_matrix( enter_size.format(second), enter_matrix.format(second) ) print_add_matrices(matrix1, matrix2)
def do_multiply_matrices(): """Multiply two matrices""" matrix1 = build_matrix( enter_size.format(first), enter_matrix.format(first) ) matrix2 = build_matrix( enter_size.format(second), enter_matrix.format(second) ) print_multiply_matrices(matrix1, matrix2)
def do_calc_determinant(): """Calculate determinant""" matrix = build_matrix(enter_size.format(""), enter_matrix.format("")) if is_square_matrix(matrix): det = calc_determinant(matrix) print(result_is) print(det)
def do_scale_matrix(): """Multiply matrix by a constant number""" matrix = build_matrix( enter_size.format(""), enter_matrix.format("") ) k = get_num_row(1, lambda x: float(x), prompt=enter_k)[0] print_scale_matrix(matrix, k)
def do_transpose_matrix(): """Select kind of transposition and perform it""" print(transpose_text) t_code = input(your_choice).strip() if t_code not in "1234": print(error) return matrix = build_matrix(enter_size.format(""), enter_matrix.format("")) print_transpose(matrix, t_code)
def do_inverse_matrix(): """Calculate inverse matrix""" matrix = build_matrix(enter_size.format(""), enter_matrix.format("")) if is_square_matrix(matrix): det = calc_determinant(matrix) if det == 0: print(no_inverse) return print_inverse_matrix(matrix, det)