0hc.net Menu
Home Overview
About Menu
Impressum

Determinant

a la Laplace: import Array det :: Num a => Array (Int,Int) a -> a det a | b == 1 = a!(1,1) | otherwise = foldr1 (+) (map f1 x) where b = fst $ snd $ bounds a c = b-1 x = [1..b] f1 y = a!(1,y) * (-1)^(1+y) * det (f2 y) f2 y = array ((1,1),(c,c)) [((i,j),a!(i+1,(f3 y j))) | i <- [1..c], j <- [1..c]] f3 y k | k >= y = k+1 | otherwise = k
0hc.net    © 2001-2014 Harald Wolfsgruber