{"id":309329,"date":"2020-09-02T09:00:42","date_gmt":"2020-09-02T09:00:42","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=309329"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=309329","title":{"rendered":"\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430 \u0425\u0430\u0441\u043a\u0435\u043b\u043b\u0435"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/517422\/\">\u0420\u0435\u0448\u0438\u043b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u043a\u043e\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u0439. \u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0447\u0438\u0439, \u0445\u043e\u0442\u044f \u0438 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u043e\u0437\u043d\u043e\u0441\u0442\u044c. \u041f\u0440\u043e\u0441\u0442\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0425\u0430\u0441\u043a\u0435\u043b\u043b\u0435. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438: \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u0438 \u043c\u0435\u0442\u043e\u0434 \u0413\u0430\u0443\u0441\u0441\u0430.<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h4>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <b>n*n<\/b> \u2014 \u044d\u0442\u043e \u0441\u0443\u043c\u043c\u0430 <b>n!<\/b> \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445, \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u0440\u043e\u0432\u043d\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0438 \u0440\u043e\u0432\u043d\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0417\u043d\u0430\u043a \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f:   <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6f1\/acc\/bb2\/6f1accbb257d16efc1d2f8c9ba3d5596.svg\" alt=\"${a}_{1,i1}*{a}_{2,i2}*...{a}_{n,in}$\" data-tex=\"display\"><\/math><\/p>\n<p>  \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0451\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438:<br \/>  \\begin{pmatrix}1 &amp; 2 &amp;\u2026 &amp; n \\\\ {i}_{1} &amp; {i}_{2} &amp;\u2026 &amp; {i}_{n} \\end{pmatrix}<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u0440\u044f\u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0433\u043e \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0432 \u0441\u0443\u043c\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u043d\u0430 \u0438\u0445 \u0430\u043b\u0433\u0435\u0431\u0440\u0430\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0430\u043b\u0433\u0435\u0431\u0440\u0430\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/378\/26e\/fc4\/37826efc48480cf95dbc5b235363818c.svg\" alt=\"${a}_{i,j}$\" data-tex=\"display\"><\/math><\/p>\n<p> \u0435\u0441\u0442\u044c <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/dbb\/6de\/afd\/dbb6deafd0bf9e6b1b40b0a4c3112837.svg\" alt=\"${(-1)}^{i+j}*{M}_{i,j}$\" data-tex=\"display\"><\/math><\/p>\n<p> \u043f\u0440\u0438 \u044d\u0442\u043e\u043c <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f2a\/17f\/f75\/f2a17ff75e853145bbd7bf033d1a2015.svg\" alt=\"${M}_{i,j}$\" data-tex=\"display\"><\/math><\/p>\n<p> \u2014 \u0435\u0441\u0442\u044c \u043c\u0438\u043d\u043e\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (i,j), \u0442.\u0435. \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435\u043c i-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 j-\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430.<\/p>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c. \u041d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0436\u0435\u043b\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u2014 O(n!). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u044f\u043c\u043e\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u043a\u043b\u0430\u0434\u043a\u0430\u0445 (\u0438 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430).<\/p>\n<p>  \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u0413\u0430\u0443\u0441\u0441\u0430. \u0415\u0433\u043e \u0441\u0443\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445:<\/p>\n<p>  1. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \\begin{pmatrix}{a}_{1,1} &amp; {a}_{1,2} &amp;\u2026 &amp; {a}_{1,n} \\\\ 0 &amp; {a}_{2,2} &amp;\u2026 &amp; {a}_{2,n} \\\\ 0 &amp; 0 &amp;\u2026 &amp; &#8230;\\\\ 0 &amp; 0 &amp;\u2026 &amp; {a}_{n,n} \\\\\\end{pmatrix} \u0440\u0430\u0432\u0435\u043d \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u0435\u0435 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430.<\/p>\n<p>  2. \u0415\u0441\u043b\u0438 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f.<\/p>\n<p>  3. \u0415\u0441\u043b\u0438 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 (\u0438\u043b\u0438 \u0434\u0432\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u0430), \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0437\u043d\u0430\u043a \u043d\u0430 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0439.<\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c, \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u043d\u0443\u043b\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u0445, \u043a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0432\u043e\u0439. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u043b\u044f \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u0435\u0440\u0432\u0443\u044e, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u043d\u0430 <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b51\/1d4\/9d1\/b511d49d1969d381ccb64dd0ea664b40.svg\" alt=\"$-{a}_{2,1}\/{a}_{1,1}$\" data-tex=\"display\"><\/math><\/p>\n<p> \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u043b\u044f \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u043d\u0443\u0436\u043d\u043e \u043a \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u043d\u0430 <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d5b\/a31\/279\/d5ba312799a4d1638c77899448b92dba.svg\" alt=\"$-{a}_{3,1}\/{a}_{1,1}$\" data-tex=\"display\"><\/math><\/p>\n<p> \u0438 \u0442.\u0434. \u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435, \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442\u0441\u044f \u043a \u0432\u0438\u0434\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/688\/c98\/697\/688c98697d53d4bc4f1262909fc5c983.svg\" alt=\"${a}_{n,1}$\" data-tex=\"display\"><\/math><\/p>\n<p> \u043f\u0440\u0438 n&gt;1 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3cb\/64f\/21f\/3cb64f21fc8c86e5514037ffdf19321d.svg\" alt=\"${a}_{1,1}$\" data-tex=\"display\"><\/math><\/p>\n<p> \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 (\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043e\u043d \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0430 k-\u043c \u043c\u0435\u0441\u0442\u0435) \u0438 \u043e\u0431\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u043f\u0435\u0440\u0432\u0443\u044e \u0438 k-\u044e \u0441\u0442\u0440\u043e\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u043d\u0430\u043a, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u043d\u0435\u0442 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u043b\u0438 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435, \u0437\u0430\u0442\u0435\u043c \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0438 \u0442.\u043f. \u0412\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u043d\u0443\u043b\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0435 \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044f, \u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c. \u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0413\u0430\u0443\u0441\u0441\u0430 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438, \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0442\u0430\u043a\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0440\u0430\u0432\u0435\u043d \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h4>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e. <\/h4>\n<p>  \u041c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439. \u041c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 \u0441\u0442\u0440\u043e\u043a. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0434\u0432\u0430 \u0442\u0438\u043f\u0430:  <\/p>\n<pre><code class=\"haskell\">type Row    = [Double] type Matrix = [Row] <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f<\/h4>\n<p>  \u041d\u0438\u0447\u0442\u043e\u0436\u0435 \u0441\u0443\u043c\u043d\u044f\u0448\u0435\u0441\u044f, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0435\u0440\u0432\u043e\u0439 (\u0442.\u0435. \u043d\u0443\u043b\u0435\u0432\u043e\u0439) \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u0438\u043d\u043e\u0440\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 k-\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430.   <\/p>\n<pre><code class=\"haskell\">-- \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 k-\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437\u043e \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u043e\u043a \u043c\u0430\u0442\u0440\u0438\u0446\u044b deln :: Matrix -&gt; Int -&gt; Matrix deln matrix k = map (\\ r -&gt; (take (k) r)++(drop (k+1) r)) matrix <\/code><\/pre>\n<p>  \u0410 \u0432\u043e\u0442 \u0438 \u043c\u0438\u043d\u043e\u0440:  <\/p>\n<pre><code class=\"haskell\">-- \u041c\u0438\u043d\u043e\u0440 k-\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 minor :: Matrix -&gt; Int -&gt; Double minor matrix k = det $ deln (drop 1 matrix) k <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u043c\u0438\u043d\u043e\u0440 \u2014 \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c. \u041c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e det, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0435\u0449\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 det, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u0447\u0435\u0440\u0435\u0434\u0443\u044e\u0449\u0443\u044e\u0441\u044f \u0441\u0443\u043c\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043c\u0438\u043d\u043e\u0440\u0430. \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u043a\u0430 \u0441\u0443\u043c\u043c\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"haskell\">sgn :: Int -&gt; Double sgn n = if n `rem` 2 == 0 then 1.0 else (-1.0) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c:  <\/p>\n<pre><code class=\"haskell\">-- \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b det :: Matrix -&gt; Double det [[a,b],[c,d]] = a*d-b*c det matrix = sum $ map (\\c -&gt; ((matrix !! 0)!!c)*(sgn c)*(minor matrix c))  [0..n]              where n = length matrix - 1 <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0441\u043e\u0431\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e main:  <\/p>\n<pre><code class=\"haskell\">main = print $ det [[1,2,3],[4,5,6],[7,8,(-9)]]<\/code><\/pre>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0440\u0430\u0432\u043d\u043e 54, \u0432 \u0447\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h4>\u041c\u0435\u0442\u043e\u0434 \u0413\u0430\u0443\u0441\u0441\u0430<\/h4>\n<p>  \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445). \u041f\u0435\u0440\u0432\u0430\u044f \u0438\u0437 \u043d\u0438\u0445 \u2014 \u0432\u0437\u0430\u0438\u043c\u043d\u044b\u0439 \u043e\u0431\u043c\u0435\u043d \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u043e\u043a \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435:  <\/p>\n<pre><code class=\"haskell\">-- \u041e\u0431\u043c\u0435\u043d \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u043e\u043a \u043c\u0430\u0442\u0440\u0438\u0446\u044b swap :: Matrix -&gt; Int -&gt; Int -&gt; Matrix swap matrix n1 n2 = map row [0..n]                     where n=length matrix - 1                           row k | k==n1 = matrix !! n2                                 | k==n2 = matrix !! n1                                 | otherwise = matrix !! k <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c\u0443 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0443, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0437\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c n1, \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430 n2 (\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442). \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043c\u0435\u0441\u0442\u0435.<br \/>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 r1 \u0441\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439 r2, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e \u043d\u0430 \u0447\u0438\u0441\u043b\u043e f:  <\/p>\n<pre><code class=\"haskell\">-- \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 r1+f*r2 comb :: Row -&gt; Row -&gt; Double -&gt; Row comb r1 r2 f = zipWith (\\ x y -&gt; x+f*y) r1 r2 <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e: \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0434 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b (\u0442.\u0435. \u043d\u0430\u0434 \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 [Double]). \u0410 \u0432\u043e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u044d\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0434 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 (\u0438, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443):  <\/p>\n<pre><code class=\"haskell\">-- \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0441\u0442\u0440\u043e\u043a\u0435 r1 \u0441\u0442\u0440\u043e\u043a\u0443 r2, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u043d\u0430 f trans :: Matrix -&gt; Int -&gt; Int -&gt; Double -&gt; Matrix trans matrix n1 n2 f = map row [0..n]                        where n=length matrix - 1                              row k | k==n1 = comb (matrix !! n1) (matrix !! n2) f                                    | otherwise = matrix !! k <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f getNz \u0438\u0449\u0435\u0442 \u043d\u043e\u043c\u0435\u0440 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u041e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e.  <\/p>\n<pre><code class=\"haskell\">-- \u041d\u043e\u043c\u0435\u0440 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 getNz :: Row -&gt; Int getNz xs = if length tmp == 0 then (-1) else snd $ head tmp            where tmp=dropWhile (\\ (x,k) -&gt; (abs x) &lt;= 1.0e-10) $ zip xs [0..] <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043f\u0438\u0441\u043a\u0430 \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 -1.<br \/>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f search \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043b\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0434\u043b\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f (\u0443 \u043d\u0435\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442). \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a.  <\/p>\n<pre><code class=\"haskell\">-- \u041f\u043e\u0438\u0441\u043a \u0432\u0435\u0434\u0443\u0449\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0442\u0440\u043e\u043a \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 search :: Matrix -&gt; Int -&gt; Matrix search matrix k | (abs ((matrix !! k) !! k)) &gt; 1.0e-10 = matrix                 | nz &lt; 0 = matrix  -- \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u0430                     | otherwise = swap matrix k p                             where n   = length matrix                                  lst = map (\\ r -&gt; r !! k) $ drop k matrix                                  nz  = getNz lst                                  p   = k + nz <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0435\u0434\u0443\u0449\u0438\u0439 (\u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439) \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e (\u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u0430), \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u0435\u0435 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439. \u0424\u0443\u043d\u043a\u0446\u0438\u044f mkzero \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u0443\u043b\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b:  <\/p>\n<pre><code class=\"haskell\">-- \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0443\u043b\u0435\u0439 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 mkzero :: Matrix -&gt; Int -&gt; Int -&gt; Matrix mkzero matrix k p | p&gt;n-1 = matrix                   | otherwise = mkzero (trans matrix p k (-f)) k (p+1)                     where n = length matrix                           f = ((matrix !! p) !! k)\/((matrix !! k) !! k) <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f triangle \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u044b:  <\/p>\n<pre><code class=\"haskell\">-- \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043c\u0430\u0442\u0440\u0438\u0446\u044b triangle :: Matrix -&gt; Int -&gt; Matrix triangle matrix k | k&gt;=n = matrix                   | (abs v) &lt;= 1.0e-10 = [[0.0]] -- \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u0430                   | otherwise = triangle (mkzero tmp k k1) k1                      where n   = length matrix                           tmp = search matrix k                           v   = (tmp !! k) !! k -- \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442                           k1  = k+1 <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0432\u0435\u0434\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0443\u043b\u0435\u0432\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 1-\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u0434\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043a \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435:  <\/p>\n<pre><code class=\"haskell\">-- \u041f\u0430\u0440\u0430\u0434\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f gauss :: Matrix -&gt; Matrix gauss matrix = triangle matrix 0  <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"haskell\">-- \u041f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 proddiag :: Matrix -&gt; Double proddiag matrix = product $ map (\\ (r,k) -&gt; r !!k) $ zip matrix [0,1..] <\/code><\/pre>\n<p>  \u041d\u0443, \u0438 \u00ab\u0431\u0430\u043d\u0442\u0438\u043a\u00bb \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f:  <\/p>\n<pre><code class=\"haskell\">-- \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f det :: Matrix -&gt; Double det matrix = proddiag $ triangle matrix 0 <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f:  <\/p>\n<pre><code class=\"haskell\">main = print $ det  [[1,2,3],[4,5,6],[7,8,-9]]  [1 of 1] Compiling Main             ( main.hs, main.o )  Linking a.out ...                                                                                  54.0      <\/code><\/pre>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0442\u0435\u043c, \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b \u0434\u043e \u043a\u043e\u043d\u0446\u0430!<br \/>  \u041a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/yadi.sk\/d\/Y-Vn5ouy83T13A\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/517422\/\"> https:\/\/habr.com\/ru\/post\/517422\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/517422\/\">\u0420\u0435\u0448\u0438\u043b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u043a\u043e\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u0439. \u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0447\u0438\u0439, \u0445\u043e\u0442\u044f \u0438 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u043e\u0437\u043d\u043e\u0441\u0442\u044c. \u041f\u0440\u043e\u0441\u0442\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0425\u0430\u0441\u043a\u0435\u043b\u043b\u0435. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438: \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u0438 \u043c\u0435\u0442\u043e\u0434 \u0413\u0430\u0443\u0441\u0441\u0430.<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h4>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <b>n*n<\/b> \u2014 \u044d\u0442\u043e \u0441\u0443\u043c\u043c\u0430 <b>n!<\/b> \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445, \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u0440\u043e\u0432\u043d\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0438 \u0440\u043e\u0432\u043d\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0417\u043d\u0430\u043a \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f:   <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6f1\/acc\/bb2\/6f1accbb257d16efc1d2f8c9ba3d5596.svg\" alt=\"${a}_{1,i1}*{a}_{2,i2}*...{a}_{n,in}$\" data-tex=\"display\"><\/math><\/p>\n<p>  \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0451\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438:<br \/>  \\begin{pmatrix}1 &amp; 2 &amp;\u2026 &amp; n \\\\ {i}_{1} &amp; {i}_{2} &amp;\u2026 &amp; {i}_{n} \\end{pmatrix}  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-309329","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/309329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=309329"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/309329\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=309329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=309329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=309329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}