From 4eae0ede1899c5d4b70619c40ac292919848a0c7 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 12 Dec 2007 17:48:30 +0000 Subject: [PATCH] Removed the changeAllButOneDifferent function and replaced it with simpler code --- transformations/ArrayUsageCheck.hs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/transformations/ArrayUsageCheck.hs b/transformations/ArrayUsageCheck.hs index df0ea01..ecb1a81 100644 --- a/transformations/ArrayUsageCheck.hs +++ b/transformations/ArrayUsageCheck.hs @@ -156,7 +156,7 @@ solveConstraints p ineq a_k = e ! k m = (abs a_k) + 1 sign_a_k = signum a_k - x_k_eq = changeAllButOneDifferent (k,(- sign_a_k) * m) (\a_i -> sign_a_k * (a_i `mymod` m)) e + x_k_eq = amap (\a_i -> sign_a_k * (a_i `mymod` m)) e // [(k,(- sign_a_k) * m)] -- I think this is probably equivalent to mod, but let's follow the maths: mymod x y = x - (y * (floordivplushalf x y)) @@ -165,11 +165,6 @@ solveConstraints p ineq floordivplushalf :: Integer -> Integer -> Integer floordivplushalf x y = floor ((fromInteger x / fromInteger y) + (0.5 :: Double)) - changeAllButOneDifferent :: (IArray a e, IArray a e', Ix i) => (i,e') -> (e -> e') -> a i e -> a i e' - changeAllButOneDifferent (specialI,specialE) f = arrayMapWithIndex f' - where - f' i e = if i == specialI then specialE else f e - -- Removes all equations where the coefficients are all zero removeRedundant :: EqualityProblem -> EqualityProblem removeRedundant = mapMaybe (boolToMaybe (not . isRedundant))