-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgaussianelim.hs
76 lines (49 loc) · 1.03 KB
/
gaussianelim.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
-- three types of operations
-- swap
-- multiply by scalar
-- add one row to another
let x1 = [3,4,5]
let x2 = [2,1,4]
head x1 / head x2 :: Rational
:t x1
:{
let asdf :: [Int]
asdf = [1..3]
:}
:t asdf
-- reduce row, not getting it to work with the right type signature
:{
let rr :: Int a => [a] -> [a] -> [Rational]
rr x1 x2 = zipWith (-) x1 mb
where mb = map (*(head x1 / head x2)) x2
:}
:{
let rr x1 x2 = zipWith (+) mb x2
where mb = map (*gk) x1
gk = -(head x2 / head x1)
:}
let y = rr a b
let z = rr a c
rr (tail y) (tail z)
:{
let ut xs = lg : map (rr lg) gj
where lg = head xs
gj = tail xs
:}
-- need an extra tail somewhere!
--so go ut x -> ut map tail (tail ut)
-- works
-- how to account for the zero padding
--
ut [a,b,c]
let mt = map tail
ut $ mt $ tail $ ut [a,b,c]
let dunno x = ut $ mt $ tail $ ut x
dunno [a,b,c]
a : (map (0:) (dunno [a,b,c]))
fjk x n =
-- need to somehow recursively do all of this
a
let a = [2,1,-1,8]
let b = [-3,-1,2,-11]
let c = [-2,1,2,-3]