diff --git a/checks/ArrayUsageCheck.hs b/checks/ArrayUsageCheck.hs index 8cb9b27..f063f99 100644 --- a/checks/ArrayUsageCheck.hs +++ b/checks/ArrayUsageCheck.hs @@ -352,7 +352,7 @@ makeEquations otherInfo accesses bound vi = (var,index) add :: (Int,Integer) -> Array Int Integer -> Array Int Integer - add (ind,val) a = (makeSize (newMin, newMax) 0 a) // [(ind, (arrayLookupWithDefault 0 a ind) + val)] + add (ind,val) a = (makeArraySize (newMin, newMax) 0 a) // [(ind, (arrayLookupWithDefault 0 a ind) + val)] where newMin = minimum [fst $ bounds a, ind] newMax = maximum [snd $ bounds a, ind] @@ -705,14 +705,10 @@ mapToArray m = accumArray (+) 0 (0, highest') . Map.assocs $ m where highest' = maximum $ 0 : Map.keys m -makeSize :: ({- Show i, Show e, -} IArray a e, Ix i, Enum i) => (i,i) -> e -> a i e -> a i e -makeSize size def arr = array size [(i,arrayLookupWithDefault def arr i) | i <- [fst size .. snd size]] - - -- | Given a pair of equation sets, makes all the equations in the lists be the length -- of the longest equation. All missing elements are of course given value zero. squareEquations :: ([Array CoeffIndex Integer],[Array CoeffIndex Integer]) -> ([Array CoeffIndex Integer],[Array CoeffIndex Integer]) -squareEquations (eqs,ineqs) = uncurry transformPair (mkPair $ map $ makeSize (0,highest) 0) (eqs,ineqs) +squareEquations (eqs,ineqs) = uncurry transformPair (mkPair $ map $ makeArraySize (0,highest) 0) (eqs,ineqs) where highest = maximum $ 0 : (concatMap indices $ eqs ++ ineqs) diff --git a/common/Utils.hs b/common/Utils.hs index 565c669..9934079 100644 --- a/common/Utils.hs +++ b/common/Utils.hs @@ -284,3 +284,6 @@ applyPair f = transformPair f f applyPairM :: Monad m => (a -> m b) -> (a,a) -> m (b,b) applyPairM f = seqPair . transformPair f f + +makeArraySize :: (IArray a e, Ix i, Enum i) => (i,i) -> e -> a i e -> a i e +makeArraySize size def arr = array size [(i,arrayLookupWithDefault def arr i) | i <- [fst size .. snd size]]