Jump to content

Gaussian elimination: Difference between revisions

m
(From scratch)
Line 1,416:
===From scratch===
<lang Haskell>
 
isMatrix xs = null xs || all ((== (length.head $ xs)).length) xs
 
Line 1,446 ⟶ 1,445:
go (x:xs) (y:ys) zs = go xs ys $ (val x y zs):zs
 
triangle::(Num a, Ord a) => [[a]] -> [[a]] -> ([[a]],[[a]])
triangle xs bs = triang ([],[]) (xs,bs)
where
Line 1,454 ⟶ 1,453:
where ((us@(u:tus)):uss,cs:css) = bubble zs
 
bubble:: (Num a, Ord a) => ([[a]],[[a]]) -> ([[a]],[[a]])
bubble (xs,bs) = (go xs, go bs)
where
idmax = snd.maximumminimum.flip zip [0..].map (negate.abs.head) $ xs
go ys = let (us,vs) = splitAt idmax ys in vs ++ us
678

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.