From 5f6472b5ff83fe28708bcaabc33b5bac1f7536b5 Mon Sep 17 00:00:00 2001 From: KuzarinM Date: Thu, 26 Sep 2024 22:12:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=20=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0.=20=D0=9D?= =?UTF-8?q?=D1=83=D0=B6=D0=BD=D0=BE=20=D0=B2=D1=81=D1=91=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=B8=D1=82=D1=8C=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B5=20=D0=BE=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kuzarin_maxim_lab_6/.gitignore | 484 ++++++++++++++++++ .../DeterminantCalculation.sln | 25 + .../DeterminantCalculation.csproj | 10 + .../DeterminantCalculation/Program.cs | 184 +++++++ .../Images/determinant test.png | Bin 0 -> 14656 bytes kuzarin_maxim_lab_6/README.md | 15 + 6 files changed, 718 insertions(+) create mode 100644 kuzarin_maxim_lab_6/.gitignore create mode 100644 kuzarin_maxim_lab_6/DeterminantCalculation.sln create mode 100644 kuzarin_maxim_lab_6/DeterminantCalculation/DeterminantCalculation.csproj create mode 100644 kuzarin_maxim_lab_6/DeterminantCalculation/Program.cs create mode 100644 kuzarin_maxim_lab_6/Images/determinant test.png create mode 100644 kuzarin_maxim_lab_6/README.md diff --git a/kuzarin_maxim_lab_6/.gitignore b/kuzarin_maxim_lab_6/.gitignore new file mode 100644 index 0000000..104b544 --- /dev/null +++ b/kuzarin_maxim_lab_6/.gitignore @@ -0,0 +1,484 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/kuzarin_maxim_lab_6/DeterminantCalculation.sln b/kuzarin_maxim_lab_6/DeterminantCalculation.sln new file mode 100644 index 0000000..6c92229 --- /dev/null +++ b/kuzarin_maxim_lab_6/DeterminantCalculation.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34916.146 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeterminantCalculation", "DeterminantCalculation\DeterminantCalculation.csproj", "{31083870-167F-45D9-8205-4E908E4DEAEC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {31083870-167F-45D9-8205-4E908E4DEAEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31083870-167F-45D9-8205-4E908E4DEAEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31083870-167F-45D9-8205-4E908E4DEAEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31083870-167F-45D9-8205-4E908E4DEAEC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {15AF4683-8FFA-462B-AEB1-EBC1DC51E24A} + EndGlobalSection +EndGlobal diff --git a/kuzarin_maxim_lab_6/DeterminantCalculation/DeterminantCalculation.csproj b/kuzarin_maxim_lab_6/DeterminantCalculation/DeterminantCalculation.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/kuzarin_maxim_lab_6/DeterminantCalculation/DeterminantCalculation.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/kuzarin_maxim_lab_6/DeterminantCalculation/Program.cs b/kuzarin_maxim_lab_6/DeterminantCalculation/Program.cs new file mode 100644 index 0000000..b04446d --- /dev/null +++ b/kuzarin_maxim_lab_6/DeterminantCalculation/Program.cs @@ -0,0 +1,184 @@ +using System.Diagnostics; + +internal class Program +{ + private static string[] _resTableColumnsNames = new string[] { "m*m", "1 t", "2 t", "3 t", "4 t", "5 t", "6 t"}; + private static void Main(string[] args) + { + Console.WriteLine(string.Join("\t", _resTableColumnsNames)); + for (int i = 8; i < 13; i++) + { + var e = CreateMatrix(i, i); + + List times = new() { i }; + + for (int j = 1; j <= 6; j++) + { + var sw = new Stopwatch(); + sw.Start(); + + CalculateDeterminant(e, j); + + sw.Stop(); + times.Add(sw.ElapsedMilliseconds); + } + + Console.WriteLine(string.Join("\t", times)); + } + } + + private static int[,] CreateMatrix(int x, int y) + { + var rnd = new Random(); + + var res = new int[y, x]; + + for (int i = 0; i < y; i++) + { + for (int j = 0; j < x; j++) + { + res[i, j] = rnd.Next(0, 100); + } + } + return res; + } + + private static void PritMatrix(int[,] mx) + { + for (int i = 0; i < mx.GetLength(0); i++) + { + for (int j = 0; j < mx.GetLength(1); j++) + { + Console.Write($"{mx[i, j].ToString("000")}\t"); + } + Console.WriteLine(); + } + } + + public static long CalculateDeterminant(int[,] matrix, int maxThreads) + => CalculateDeterminantParalel( + matrix, + Enumerable.Range(0, matrix.GetLength(0)).ToArray(), + Enumerable.Range(0, matrix.GetLength(1)).ToArray(), + maxThreads + ); + + private static long CalculateDeterminant(int[,] matrix, int[] rows, int[] columns) + { + if (rows.Length <= 3) + return GetSimpleDeterminant(matrix, rows.ToList(), columns.ToList()); + + (int fixIndex, bool isFixRow) = GetTheBestRowColumn(matrix, rows, columns); + + long res = 0; + int row = isFixRow ? rows[fixIndex] : -1; + int column = isFixRow ? -1 : columns[fixIndex]; + + for (int index = 0; index < rows.Length; index++) + { + if (isFixRow) + column = columns[index]; + else + row = rows[index]; + + res += ((index + fixIndex) % 2 != 0 ? -1 : 1) * matrix[column, row] * + CalculateDeterminant(matrix, rows.Where(x => x != row).ToArray(), columns.Where(x => x != column).ToArray()); + } + + return res; + } + + private static long CalculateDeterminantParalel(int[,] matrix, int[] rows, int[] columns, int maxThread) + { + if (rows.Length <= 3) + return GetSimpleDeterminant(matrix, rows.ToList(), columns.ToList()); + + (int fixIndex, bool isFixRow) = GetTheBestRowColumn(matrix, rows, columns); + + long res = 0; + int row = isFixRow ? rows[fixIndex] : -1; + int column = isFixRow ? -1 : columns[fixIndex]; + + var semaphore = new SemaphoreSlim(maxThread, maxThread); + + for (int index = 0; index < rows.Length; index++) + { + if (isFixRow) + column = columns[index]; + else + row = rows[index]; + + var c_column = column; + var c_row = row; + var c_index = fixIndex + index; + semaphore.Wait(); + Task.Run(() => + { + try + { + res += (c_index % 2 != 0 ? -1 : 1) * matrix[c_column, c_row] * + CalculateDeterminant( + matrix, + rows.Where(x => x != c_row).ToArray(), + columns.Where(x => x != c_column).ToArray() + ); + } + finally { semaphore.Release(); } + }); + } + + semaphore.Wait(maxThread); + return res; + } + + private static (int fixIndex, bool isFixRow) GetTheBestRowColumn(int[,] matrix, int[] rows, int[] columns) + { + Dictionary zerosCount = rows.Select(x => x + 1).Union(columns.Select(x => -x - 1)).ToDictionary(x => x, x => 0); + + foreach (var r in rows) + { + foreach (var c in columns) + { + if (matrix[r, c] == 0) + { + zerosCount[r + 1] += 1; + zerosCount[-c - 1] += 1; + } + } + } + + var best = zerosCount.ToList().OrderByDescending(x => x.Value).FirstOrDefault().Key; + + if (best > 0) + { + return (Array.IndexOf(rows, best - 1), true); + } + else + { + return (Array.IndexOf(columns, -best + 1), false); + } + } + + private static long GetSimpleDeterminant(int[,] matrix, List rows, List columns) + { + if (rows.Count == 1) + { + return matrix[columns[0], rows[0]]; + } + else if (rows.Count == 2) + { + return matrix[columns[0], rows[0]] * matrix[columns[1], rows[1]] - matrix[columns[0], rows[1]] * matrix[columns[1], rows[0]]; + } + else if (columns.Count == 3) + { + return matrix[columns[0], rows[0]] * matrix[columns[1], rows[1]] * matrix[columns[2], rows[2]] + + matrix[columns[0], rows[1]] * matrix[columns[1], rows[2]] * matrix[columns[2], rows[0]] + + matrix[columns[0], rows[2]] * matrix[columns[1], rows[0]] * matrix[columns[2], rows[1]] - + + matrix[columns[0], rows[2]] * matrix[columns[1], rows[1]] * matrix[columns[2], rows[0]] - + matrix[columns[1], rows[0]] * matrix[columns[0], rows[1]] * matrix[columns[2], rows[2]] - + matrix[columns[0], rows[0]] * matrix[columns[1], rows[2]] * matrix[columns[2], rows[1]]; + } + throw new Exception(); + } +} \ No newline at end of file diff --git a/kuzarin_maxim_lab_6/Images/determinant test.png b/kuzarin_maxim_lab_6/Images/determinant test.png new file mode 100644 index 0000000000000000000000000000000000000000..cddef53c6cc0ff5ad42abef24ee8d9ebc77f16cc GIT binary patch literal 14656 zcmdVBbySq$_b-ZtN{57`hys$*FvN&-OE*Y&cb7kak*2Kyxy~< z81b5S46jJWNJs>JBtF(Q3G^jF?_V!TI}_hjo;PN*DR2P|zdh;9>osy?d7E~zo*;n~ zYWEzIN_{!pVkQB@4Kwb~q_xb1A%+B1Qsw9-j$rK*4fe3@i;KkBquY_AKK}AO&gU3;99m#A?< z@T{Y*d+bP&uWmlaQ}uBv73%GiyYJ8(R=Ou}dHww9A2n-2^TZt)AsXG6Yaptqdfs=Hf`JqPD2TSD^-#0Pa#pXqs*7`1%}1v;y}8QhfX z6o&P)z}7@Lm*GWj)Mw|mNmkJhgw9h{Su}P|$G}xj${yibSVvp$0?&&q<-86Oa8X~UD7!GK2 z3LvNMZk)w~xg2+|cpWn@>^0BAPLYmI5yY@=I_9;*=adYTWF=x#X0e&`-Z?7e<5i>| zxc5xQCuv+?WU9qPv%In;Vqe}F^ay)UUNBzC`66D1;h|^ueiX@*ZbEz=ur&gKILUTV zr5!OXX&5b5?sPTv%x}nzAkqRQ;Gzy!%gyGYawspVv{;`x!;WTVz0lS%`uCA-{xkXfQL1+WHw?+a~C9-jz3kT zFS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d00001 diff --git a/kuzarin_maxim_lab_6/README.md b/kuzarin_maxim_lab_6/README.md new file mode 100644 index 0000000..3378bbf --- /dev/null +++ b/kuzarin_maxim_lab_6/README.md @@ -0,0 +1,15 @@ +# Лабораторная работа 6 +Данная работа посвящена параллельному вычислению определителя матриц +## Описание +Вычисление определителей для матрицы порядка более чем 3, сводится к разложению матрицы по строке (столбцу). Из этого следует, что для нахождения определителя 10-го порядка нужно (в худшем случае) 10 определителей 9-го порядка, что в свою очередь в худшем случае означает, что потребуется 8*9 = 72 определителя 8-го порядка и так далее. Это достаточно трудоёмкая процедура, которую желательно распределить +## Запуск +Приложение представлет собой консольную программу на C#, которую можно скомпилировать и затем запустит exe файл. В результате в окне консоли появится таблица сравнения времени находления определителя квадратных матриц (размер указан в первой колонке) с использованием разного числа потоков(от 1 до 6). Чем больше размер, тем дольше будет идти расчёт. +## Результаты +Результаты одного из запусков программы представлены ниже. +
+![Resout](Images/determinant test.png) +
+Как можно заметить, на небольших размерах распаралеливание приводит только к увеличению времени выполнения (за счёт времени создания Task и синхронизации). Но с ростом размера матрицы использование нескольким потоков начинает приносить значительный выигрыш по производительности. Но в рамках текущей реализации ускориться сильнее определённого предела не получится, что видно из расчёта матрицы 12/*12 + +## Видеодемонстрация +Был записан видеоролик, демонстрирующий процесс запуска и работы системы. Он расположен по [адресу](https://drive.google.com/file/d/1bwJMBa_zKTvZ5PT_xgmrz9SCtEf_ied2/view?usp=sharing)