From 325d6f9bbb66559718cc9b4ca54d08f6eea60c5f Mon Sep 17 00:00:00 2001 From: DmitriyAntonov Date: Tue, 5 Dec 2023 10:35:19 +0400 Subject: [PATCH] good start3 --- antonov_dmitry_lab_6/parallel_determ.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/antonov_dmitry_lab_6/parallel_determ.py b/antonov_dmitry_lab_6/parallel_determ.py index 2204f96..7e973c6 100644 --- a/antonov_dmitry_lab_6/parallel_determ.py +++ b/antonov_dmitry_lab_6/parallel_determ.py @@ -10,11 +10,11 @@ def submatrix(matrix, row, col): def determinant(matrix): size = len(matrix) - # Base case: determinant of a 1x1 matrix is the only element in it + # Простой случай: детерминант матрицы 1x1 if size == 1: return matrix[0][0] - # Base case: determinant of a 2x2 matrix + # Простой случай: детерминант матрицы 2x2 if size == 2: return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0] @@ -36,8 +36,8 @@ def sequential_determinant_calculation(matrix_size, lower_limit, upper_limit): result = determinant(random_matrix) end_time = time.time() - print(f"Sequential determinant: {result}") - print(f"Sequential time: {end_time - start_time} seconds") + print(f"Последовательный детерминант: {result}") + print(f"Последовательное время: {end_time - start_time} секунд") def parallel_determinant_calculation(matrix_size, lower_limit, upper_limit, num_processes): @@ -52,19 +52,19 @@ def parallel_determinant_calculation(matrix_size, lower_limit, upper_limit, num_ result = sum(((-1) ** col) * random_matrix[0][col] * det for col, det in enumerate(determinants)) end_time = time.time() - print(f"Parallel determinant: {result}") - print(f"Parallel time: {end_time - start_time} seconds") + print(f"Параллельный детерминант: {result}") + print(f"Параллельное время: {end_time - start_time} секунд") if __name__ == "__main__": - matrix_size = 10 # You can change this to the desired size of the matrix - lower_limit = 10 # You can change this to the lower limit of the random numbers - upper_limit = 1000 # You can change this to the upper limit of the random numbers - num_processes = 8 # You can change this to the desired number of parallel processes + matrix_size = 10 # размер матрицы + lower_limit = 10 # числа в матрице от + upper_limit = 1000 # и до + num_processes = 8 # число потоков - # Sequential calculation + # последовательное вычисление sequential_determinant_calculation(matrix_size, lower_limit, upper_limit) - # Parallel calculation + # параллельное вычисление parallel_determinant_calculation(matrix_size, lower_limit, upper_limit, num_processes)