From e68c51b31382af32c79326e62edb2247b0679336 Mon Sep 17 00:00:00 2001 From: rita Date: Wed, 10 Jan 2024 06:03:14 +0400 Subject: [PATCH] mashkova_margarita_lab_6 ready --- mashkova_margarita_lab_6/README.md | 25 +++++ mashkova_margarita_lab_6/console.png | Bin 0 -> 20724 bytes mashkova_margarita_lab_6/src/Main.java | 130 +++++++++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 mashkova_margarita_lab_6/README.md create mode 100644 mashkova_margarita_lab_6/console.png create mode 100644 mashkova_margarita_lab_6/src/Main.java diff --git a/mashkova_margarita_lab_6/README.md b/mashkova_margarita_lab_6/README.md new file mode 100644 index 0000000..43d9e9b --- /dev/null +++ b/mashkova_margarita_lab_6/README.md @@ -0,0 +1,25 @@ +# Лабораторная работа №6 +## ПИбд-42 Машкова Маргарита +## Задание +Реализовать нахождение детерминанта квадратной матрицы. Требуется сделать два алгоритма: обычный и параллельный (задание со * - реализовать это в рамках одного алгоритма). +В параллельном алгоритме предусмотреть ручное задание количества потоков (число потоков = 1 как раз и реализует задание +со *), каждый из которых будет выполнять нахождение отдельной группы множителей. + +## Запуск программы +Запустить файл `Main` + +## Описание работы программы +В методе `main` вызывается метод `run`, для которого в качестве параметра передается размер квадратной матрицы `n`. +Генирируется матрица `a` заданного размера `n`. Вызываются соответсвующие методы вычисления детерминанта квадратной матрицы +и измеряется время. Результаты выполнения выводятся в консоль. + +## Тесты +![Вывод в консоли](console.png) + +### Выводы +По оценки времени выполнения можно сделать вывод, что параллельный алгоритм позволяет ускорять процесс на больших размерах +матриц. Для маленьких матриц лучше использовать обычный алгоритм. Для размера матрицы 100х100 и 300х300 быстрее выполнился обычный +алгоритм. При последующем увеличении размера матрицы параллельный алгоритм позволяет ускорить вычислительный процесс. + +Ссылка на видео: +https://youtu.be/3-m6j7oUlX4 \ No newline at end of file diff --git a/mashkova_margarita_lab_6/console.png b/mashkova_margarita_lab_6/console.png new file mode 100644 index 0000000000000000000000000000000000000000..c72e44ee2445762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PY53cu}&NM@0MWIu|@rT36}Vr zS5e}LM+9qUdZk=-Jx-U~f<<@dj5A2g{7D~7b62gcNmBFkknkK|Not>@-gJTj!s{%OF3(sWV z-)aYn;{PEiRd3kdY1pO$SE^>%u~*H|s2JfwccjvS`wy!aOO1 z@n=0XUhk|(kbV3 zlA{ySmXC<0@jYKQa0>O0p+nG~Uv9liBohxs<0LlFfI|%7EXO^ttI97el Math.abs(matrix[maxRow][i])) { + maxRow = j; + } + } + + if (maxRow != i) { + double[] temp = matrix[i]; + matrix[i] = matrix[maxRow]; + matrix[maxRow] = temp; + + det = det.multiply(BigDecimal.valueOf(-1)); + } + + for (int j = i + 1; j < n; j++) { + double factor = matrix[j][i] / matrix[i][i]; + for (int k = i; k < n; k++) { + matrix[j][k] -= factor * matrix[i][k]; + } + } + } + + for (int i = 0; i < n; i++) { + det = det.multiply(BigDecimal.valueOf(matrix[i][i])); + } + + return det; + + } + + // Вычисление детерминанта при помощи параллельного алгоритма + private static BigDecimal findDeterminantGaussParallel(double[][] matrix, int threadsCount) { + int n = matrix.length; + final BigDecimal[] det = {BigDecimal.ONE}; + + ExecutorService executor = Executors.newFixedThreadPool(threadsCount); + + for (int i = 0; i < n; i++) { + final int rowIdx = i; + + int maxRow = rowIdx; + for (int j = rowIdx + 1; j < n; j++) { + if (Math.abs(matrix[j][rowIdx]) > Math.abs(matrix[maxRow][rowIdx])) { + maxRow = j; + } + } + + if (maxRow != rowIdx) { + double[] temp = matrix[rowIdx]; + matrix[rowIdx] = matrix[maxRow]; + matrix[maxRow] = temp; + det[0] = det[0].multiply(BigDecimal.valueOf(-1)); + } + executor.execute(() -> { + for (int j = rowIdx + 1; j < n; j++) { + double factor = matrix[j][rowIdx] / matrix[rowIdx][rowIdx]; + for (int k = rowIdx; k < n; k++) { + matrix[j][k] -= factor * matrix[rowIdx][k]; + } + } + }); + det[0] = det[0].multiply(BigDecimal.valueOf(matrix[rowIdx][rowIdx])); + } + + executor.shutdown(); + + try { + executor.awaitTermination(1, TimeUnit.DAYS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + return det[0]; + + } + + public static void main(String[] args) { + System.out.println("Сравнение результатов\n"); + run(100); + run(300); + run(500); + run(800); + } + + public static void run(int n) { + System.out.println(String.format("Размер матрицы = %d * %d", n, n)); + double[][] a = generateMatrix(n); + double[][] aClone = Arrays.copyOf(a, n); + + long time = System.currentTimeMillis(); + BigDecimal determinantGauss = findDeterminantGauss(a); + System.out.println("Время при обычном выполнении: " + (System.currentTimeMillis() - time)); + + time = System.currentTimeMillis(); + BigDecimal determinantGaussAsync = findDeterminantGaussParallel(aClone, Runtime.getRuntime().availableProcessors()); + System.out.println("Время при параллельном выполнении: " + (System.currentTimeMillis() - time)); + System.out.println(); + + } +} \ No newline at end of file