Задание 2

This commit is contained in:
nihonium 2023-09-20 15:57:53 +03:00
parent 811fea30b8
commit 32088041ed
Signed by: nihonium
GPG key ID: 0251623741027CFC
12 changed files with 151 additions and 0 deletions

View file

@ -0,0 +1,35 @@
module Main where
import Numeric.LinearAlgebra as LA
import Data.Complex
import Graphics.EasyPlot
gen x y | x == y = -2
| abs (x - y) == 1 = 1
| otherwise = 0
a n = build (n,n) gen :: Matrix Double
-- Нормы
norm1 = maximum . map (sum . map abs) . toLists
norm2 = norm1 . tr
norm3 m = sqrt $ maximum $ map magnitude $ toList $ eigenvalues $ m LA.<> (tr m)
mu norm m = norm m * (norm $ inv m)
collectDots norm 1 = [(0, mu norm (a 1))]
collectDots norm n = (fromIntegral n, mu norm (a n)) : collectDots norm (n - 1)
main :: IO ()
main = do
let res1 = collectDots norm1 6
plot X11 $ Data2D [Title "norm1", Style Lines] [] res1
print res1
let res2 = collectDots norm2 6
plot X11 $ Data2D [Title "norm2", Style Lines] [] res2
print res2
let res3 = collectDots norm3 6
plot X11 $ Data2D [Title "norm3", Style Lines] [] res3
print res3