From 92de588b82945bb251a056c34a8ef0c00cb00e5a Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Wed, 21 May 2014 09:51:41 +0200 Subject: license change and formatting --- packages/base/src/Numeric/Chain.hs | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'packages/base/src/Numeric/Chain.hs') 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 @@ -- | -- Module : Numeric.Chain -- Copyright : (c) Vivian McPhail 2010 --- License : GPL-style +-- License : BSD3 -- -- Maintainer : Vivian McPhail gmail.com> -- Stability : provisional @@ -98,21 +98,22 @@ minimum_cost :: (Sizes,Cost,Indexes) -> (Int,Int) -> (Sizes,Cost,Indexes) minimum_cost sci fu = foldl (smaller_cost fu) sci (fulcrum_order fu) smaller_cost :: (Int,Int) -> (Sizes,Cost,Indexes) -> ((Int,Int),(Int,Int)) -> (Sizes,Cost,Indexes) -smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) = let op_cost = fromJust ((cost A.! lr) A.! lc) - + fromJust ((cost A.! rr) A.! rc) - + fst (mz A.! (lr-lc+1)) - * snd (mz A.! lc) - * snd (mz A.! rr) - cost' = (cost A.! r) A.! c - in case cost' of - Nothing -> let cost'' = update cost (r,c) (Just op_cost) - ixes'' = update ixes (r,c) (Just ix) - in (mz,cost'',ixes'') - Just ct -> if op_cost < ct then - let cost'' = update cost (r,c) (Just op_cost) - ixes'' = update ixes (r,c) (Just ix) - in (mz,cost'',ixes'') - else (mz,cost,ixes) +smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) = + let op_cost = fromJust ((cost A.! lr) A.! lc) + + fromJust ((cost A.! rr) A.! rc) + + fst (mz A.! (lr-lc+1)) + * snd (mz A.! lc) + * snd (mz A.! rr) + cost' = (cost A.! r) A.! c + in case cost' of + Nothing -> let cost'' = update cost (r,c) (Just op_cost) + ixes'' = update ixes (r,c) (Just ix) + in (mz,cost'',ixes'') + Just ct -> if op_cost < ct then + let cost'' = update cost (r,c) (Just op_cost) + ixes'' = update ixes (r,c) (Just ix) + in (mz,cost'',ixes'') + else (mz,cost,ixes) fulcrum_order (r,c) = let fs' = zip (repeat r) [1..(c-1)] -- cgit v1.2.3