Gaussian elimination: Difference between revisions

Content added Content deleted
Line 1,525: Line 1,525:
We use Rational numbers for having more precision. a % b is the rational a / b.
We use Rational numbers for having more precision. a % b is the rational a / b.
<lang Haskell>mult:: Num a => [[a]] -> [[a]] -> [[a]]
<lang Haskell>mult:: Num a => [[a]] -> [[a]] -> [[a]]
mult uss vss = map (foldl (zipWith (+)) ts . zipWith (\vs u -> map (u*) vs) vss) uss
mult uss vss = map ((\xs -> if null xs then [] else foldl1 (zipWith (+)) xs). zipWith (\vs u -> map (u*) vs) vss) uss
where ts = map (const 0).concat $ take 1 vss


bubble::([a] -> c) -> (c -> c -> Bool) -> [[a]] -> [[b]] -> ([[a]],[[b]])
bubble::([a] -> c) -> (c -> c -> Bool) -> [[a]] -> [[b]] -> ([[a]],[[b]])