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