summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/base/src/Internal/Util.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/packages/base/src/Internal/Util.hs b/packages/base/src/Internal/Util.hs
index 17d3e50..ec21fe4 100644
--- a/packages/base/src/Internal/Util.hs
+++ b/packages/base/src/Internal/Util.hs
@@ -2,6 +2,7 @@
2{-# LANGUAGE FlexibleInstances #-} 2{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE MultiParamTypeClasses #-} 3{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE FunctionalDependencies #-} 4{-# LANGUAGE FunctionalDependencies #-}
5{-# LANGUAGE ScopedTypeVariables #-}
5{-# LANGUAGE ViewPatterns #-} 6{-# LANGUAGE ViewPatterns #-}
6 7
7 8
@@ -613,6 +614,9 @@ gaussElim_1 x y = dropColumns (rows x) (flipud $ fromRows s2)
613 s1 = fromRows $ pivotDown (rows x) 0 rs -- interesting 614 s1 = fromRows $ pivotDown (rows x) 0 rs -- interesting
614 s2 = pivotUp (rows x-1) (toRows $ flipud s1) 615 s2 = pivotUp (rows x-1) (toRows $ flipud s1)
615 616
617pivotDown
618 :: forall t . (Fractional t, Num (Vector t), Ord t, Indexable (Vector t) t, Numeric t)
619 => Int -> Int -> [Vector t] -> [Vector t]
616pivotDown t n xs 620pivotDown t n xs
617 | t == n = [] 621 | t == n = []
618 | otherwise = y : pivotDown t (n+1) ys 622 | otherwise = y : pivotDown t (n+1) ys
@@ -622,6 +626,7 @@ pivotDown t n xs
622 pivot k = (const k &&& id) 626 pivot k = (const k &&& id)
623 . sortBy (flip compare `on` (abs. (!k))) 627 . sortBy (flip compare `on` (abs. (!k)))
624 628
629 redu :: (Int, [Vector t]) -> [Vector t]
625 redu (k,x:zs) 630 redu (k,x:zs)
626 | p == 0 = error "gauss: singular!" -- FIXME 631 | p == 0 = error "gauss: singular!" -- FIXME
627 | otherwise = u : map f zs 632 | otherwise = u : map f zs
@@ -632,12 +637,16 @@ pivotDown t n xs
632 redu (_,[]) = [] 637 redu (_,[]) = []
633 638
634 639
640pivotUp
641 :: forall t . (Fractional t, Num (Vector t), Ord t, Indexable (Vector t) t, Numeric t)
642 => Int -> [Vector t] -> [Vector t]
635pivotUp n xs 643pivotUp n xs
636 | n == -1 = [] 644 | n == -1 = []
637 | otherwise = y : pivotUp (n-1) ys 645 | otherwise = y : pivotUp (n-1) ys
638 where 646 where
639 y:ys = redu' (n,xs) 647 y:ys = redu' (n,xs)
640 648
649 redu' :: (Int, [Vector t]) -> [Vector t]
641 redu' (k,x:zs) = u : map f zs 650 redu' (k,x:zs) = u : map f zs
642 where 651 where
643 u = x 652 u = x