Skip to content

Instantly share code, notes, and snippets.

View qnikst's full-sized avatar
🐧
penguin?

Alexander Vershilov qnikst

🐧
penguin?
View GitHub Profile
@qnikst
qnikst / Spaghetti.hs
Created April 18, 2012 23:30
Awful attempt to code gauss' method
gauss :: [[Double]] -> [Double]
gauss m = let (m',is) = gauss0 m
in order is $ gauss2 $ gauss1 m
gauss0 :: [[Double]] -> ([[Double]],[Int])
gauss0 m = let ( mt,is) = foldr choose (trns m,straight) straight
in (trns mt,is)
where choose k (mt,is) = let row = m !! (k-1)
q = (+) 1 $ fromJust $ elemIndex (maximum $ init $ drop (k-1) row) row
in (swap' k q mt, swap' k q is)