summaryrefslogtreecommitdiff
path: root/examples/pinv1.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pinv1.hs')
-rw-r--r--examples/pinv1.hs18
1 files changed, 0 insertions, 18 deletions
diff --git a/examples/pinv1.hs b/examples/pinv1.hs
deleted file mode 100644
index 301eac8..0000000
--- a/examples/pinv1.hs
+++ /dev/null
@@ -1,18 +0,0 @@
1-- initial check for the polynomial model example
2import Numeric.LinearAlgebra
3
4
5prepSyst :: Int -> Matrix Double -> (Matrix Double, Vector Double)
6prepSyst n d = (a,b) where
7 [x,b] = toColumns d
8 a = fromColumns $ 1+0*x : map (x^) [1 .. n]
9
10main = do
11 dat <- readMatrix `fmap` readFile "data.txt"
12 let (a,b) = prepSyst 3 dat
13 putStr "Coefficient matrix:\n"
14 dispR 3 a
15 putStr "Desired values:\n"
16 print b
17 putStr "\nLeast Squares Solution:\n"
18 print $ pinv a <> b -- equivalent to: linearSolveLSR a (fromColumns [b])