diff options
Diffstat (limited to 'packages/base/src/Internal/Util.hs')
-rw-r--r-- | packages/base/src/Internal/Util.hs | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/packages/base/src/Internal/Util.hs b/packages/base/src/Internal/Util.hs index bf6c8b6..98eb4ef 100644 --- a/packages/base/src/Internal/Util.hs +++ b/packages/base/src/Internal/Util.hs | |||
@@ -54,7 +54,9 @@ module Internal.Util( | |||
54 | -- ** 2D | 54 | -- ** 2D |
55 | corr2, conv2, separable, | 55 | corr2, conv2, separable, |
56 | block2x2,block3x3,view1,unView1,foldMatrix, | 56 | block2x2,block3x3,view1,unView1,foldMatrix, |
57 | gaussElim_1, gaussElim_2, gaussElim, luST, luSolve', luSolve'', luPacked', luPacked'' | 57 | gaussElim_1, gaussElim_2, gaussElim, |
58 | luST, luSolve', luSolve'', luPacked', luPacked'', | ||
59 | invershur | ||
58 | ) where | 60 | ) where |
59 | 61 | ||
60 | import Internal.Vector | 62 | import Internal.Vector |
@@ -829,6 +831,45 @@ luSolve' (lup,p) b = backSust lup (forwSust lup pb) | |||
829 | where | 831 | where |
830 | pb = b ?? (Pos (fixPerm' p), All) | 832 | pb = b ?? (Pos (fixPerm' p), All) |
831 | 833 | ||
834 | |||
835 | -------------------------------------------------------------------------------- | ||
836 | |||
837 | data MatrixView t b | ||
838 | = Elem t | ||
839 | | Block b b b b | ||
840 | deriving Show | ||
841 | |||
842 | |||
843 | viewBlock' r c m | ||
844 | | (rt,ct) == (1,1) = Elem (atM' m 0 0) | ||
845 | | otherwise = Block m11 m12 m21 m22 | ||
846 | where | ||
847 | (rt,ct) = size m | ||
848 | m11 = sliceMatrix (0,0) (r,c) m | ||
849 | m12 = sliceMatrix (0,c) (r,ct-c) m | ||
850 | m21 = sliceMatrix (r,0) (rt-r,c) m | ||
851 | m22 = sliceMatrix (r,c) (rt-r,ct-c) m | ||
852 | |||
853 | viewBlock m = viewBlock' n n m | ||
854 | where | ||
855 | n = rows m `div` 2 | ||
856 | |||
857 | invershur (viewBlock -> Block a b c d) = fromBlocks [[a',b'],[c',d']] | ||
858 | where | ||
859 | r1 = invershur a | ||
860 | r2 = c <> r1 | ||
861 | r3 = r1 <> b | ||
862 | r4 = c <> r3 | ||
863 | r5 = r4-d | ||
864 | r6 = invershur r5 | ||
865 | b' = r3 <> r6 | ||
866 | c' = r6 <> r2 | ||
867 | r7 = r3 <> c' | ||
868 | a' = r1-r7 | ||
869 | d' = -r6 | ||
870 | |||
871 | invershur x = recip x | ||
872 | |||
832 | -------------------------------------------------------------------------------- | 873 | -------------------------------------------------------------------------------- |
833 | 874 | ||
834 | instance Testable (Matrix I) where | 875 | instance Testable (Matrix I) where |