-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask2.hs
37 lines (29 loc) · 792 Bytes
/
task2.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{-
how to input the martix:
solver [[a]]
-}
import Data.Matrix
import Control.Monad
--get maxtrix
--getH :: [[a]] -> Matrix a
getH a = fromLists a
--getMax as list,
--getMax :: [[Float]] -> [Float]
getMax a = map (multimatrix matrixh ) ( getX $ length a)
where
matrixh = getH a
-- first function to get input and output
--solver :: [[Float]] -> [Int]
solver a n = (getX n )!! (snd $ maximum $ zip (getMax a) [0 .. ] )
--multimatrix :: Matrix ->[b] -> Matrix
multimatrix matrixh xo = getmat(xt * matrixh * xy)
where
xt= fromList 1 (length xo) xo
xy= transpose $ fromList 1 (length xo) xo
--convert the matrix to int
getmat=getElem 1 1
--get the list of the [0,1]
--getX :: Int -> [[Int]]
getX n = replicateM n [0,1]
main = do
putStrLn "Please, input your N*N martix"