summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-05-21 09:51:41 +0200
committerAlberto Ruiz <aruiz@um.es>2014-05-21 09:51:41 +0200
commit92de588b82945bb251a056c34a8ef0c00cb00e5a (patch)
tree76604fff37602baadc225a2f1c1adfb29844747d
parent9412ef25f2a9d6f6ca233ef123a01c3f4145ffa4 (diff)
license change and formatting
-rw-r--r--packages/base/src/Numeric/Chain.hs33
1 files changed, 17 insertions, 16 deletions
diff --git a/packages/base/src/Numeric/Chain.hs b/packages/base/src/Numeric/Chain.hs
index c6160e9..4c497f0 100644
--- a/packages/base/src/Numeric/Chain.hs
+++ b/packages/base/src/Numeric/Chain.hs
@@ -2,7 +2,7 @@
2-- | 2-- |
3-- Module : Numeric.Chain 3-- Module : Numeric.Chain
4-- Copyright : (c) Vivian McPhail 2010 4-- Copyright : (c) Vivian McPhail 2010
5-- License : GPL-style 5-- License : BSD3
6-- 6--
7-- Maintainer : Vivian McPhail <haskell.vivian.mcphail <at> gmail.com> 7-- Maintainer : Vivian McPhail <haskell.vivian.mcphail <at> gmail.com>
8-- Stability : provisional 8-- Stability : provisional
@@ -98,21 +98,22 @@ minimum_cost :: (Sizes,Cost,Indexes) -> (Int,Int) -> (Sizes,Cost,Indexes)
98minimum_cost sci fu = foldl (smaller_cost fu) sci (fulcrum_order fu) 98minimum_cost sci fu = foldl (smaller_cost fu) sci (fulcrum_order fu)
99 99
100smaller_cost :: (Int,Int) -> (Sizes,Cost,Indexes) -> ((Int,Int),(Int,Int)) -> (Sizes,Cost,Indexes) 100smaller_cost :: (Int,Int) -> (Sizes,Cost,Indexes) -> ((Int,Int),(Int,Int)) -> (Sizes,Cost,Indexes)
101smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) = let op_cost = fromJust ((cost A.! lr) A.! lc) 101smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) =
102 + fromJust ((cost A.! rr) A.! rc) 102 let op_cost = fromJust ((cost A.! lr) A.! lc)
103 + fst (mz A.! (lr-lc+1)) 103 + fromJust ((cost A.! rr) A.! rc)
104 * snd (mz A.! lc) 104 + fst (mz A.! (lr-lc+1))
105 * snd (mz A.! rr) 105 * snd (mz A.! lc)
106 cost' = (cost A.! r) A.! c 106 * snd (mz A.! rr)
107 in case cost' of 107 cost' = (cost A.! r) A.! c
108 Nothing -> let cost'' = update cost (r,c) (Just op_cost) 108 in case cost' of
109 ixes'' = update ixes (r,c) (Just ix) 109 Nothing -> let cost'' = update cost (r,c) (Just op_cost)
110 in (mz,cost'',ixes'') 110 ixes'' = update ixes (r,c) (Just ix)
111 Just ct -> if op_cost < ct then 111 in (mz,cost'',ixes'')
112 let cost'' = update cost (r,c) (Just op_cost) 112 Just ct -> if op_cost < ct then
113 ixes'' = update ixes (r,c) (Just ix) 113 let cost'' = update cost (r,c) (Just op_cost)
114 in (mz,cost'',ixes'') 114 ixes'' = update ixes (r,c) (Just ix)
115 else (mz,cost,ixes) 115 in (mz,cost'',ixes'')
116 else (mz,cost,ixes)
116 117
117 118
118fulcrum_order (r,c) = let fs' = zip (repeat r) [1..(c-1)] 119fulcrum_order (r,c) = let fs' = zip (repeat r) [1..(c-1)]