Moved the makeSize function from ArrayUsageCheck into Utils
This commit is contained in:
parent
ba04340989
commit
4299951511
|
@ -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)
|
||||
|
|
|
@ -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]]
|
||||
|
|
Loading…
Reference in New Issue
Block a user