Row echelon form (Haskell)

From LiteratePrograms
Jump to: navigation, search
Other implementations: Haskell | Python

[edit] Recursion

<<elementryRowOpperation.hs>>=
elementryRowOpperation :: (Fractional a) => [a] -> [a] -> [a]
elementryRowOpperation us vs = vsub vs (vscale (v/u) us)
    where u = head us;
          v = head vs
<<row_echelon_form_recursive.hs>>=
ref :: (Fractional a) => [[a]] -> [[a]]
ref (ms:[]) = [ms]
ref (ms:mss) = ms : zipWith (:) (map head nss) (ref (map tail nss))
    where nss = map (elementryRowOpperation ms) mss
Download code
hijacker
hijacker
hijacker
hijacker