Rewrote the substIn function in solveConstraints to be clearer and simpler

This commit is contained in:
Neil Brown 2007-12-12 15:07:01 +00:00
parent 1aa914e077
commit a5e277505f

View File

@ -105,9 +105,11 @@ solveConstraints p ineq
substIn :: CoeffIndex -> Array CoeffIndex Integer -> EqualityProblem -> EqualityProblem
substIn ind arr = map substIn'
substIn k x_k_val = map substIn'
where
substIn' eq = changeAllButOneDifferent (ind,0) id $ arrayZipWith (+) eq (amap (* (eq ! ind)) arr)
substIn' eq = (arrayZipWith (+) eq scaled_x_k_val) // [(k,0)]
where
scaled_x_k_val = amap (* (eq ! k)) x_k_val
solveUnits :: EqualityProblem -> StateT InequalityProblem Maybe EqualityProblem
solveUnits p = case findFirstUnit p of