[Haskell-cafe] Re: Unifcation and matching in Abelian groups
John D. Ramsdell
ramsdell0 at gmail.com
Sun Aug 23 21:14:10 EDT 2009
The patch avoids a redundant zeroing of c[i].
$ diff -u {a,b}/Main.lhs
--- a/Main.lhs 2009-08-23 21:07:08.000000000 -0400
+++ b/Main.lhs 2009-08-23 21:09:54.000000000 -0400
@@ -255,12 +255,11 @@
> -- where n is the length of c.
> -- x[n] = sum[j] (c[j] div c[i] * x[j])
> -- The new equation to be solved is:
-> -- c[i]*x[n] + sum[j] c'[j]*x[j] = d[k] for all k
-> -- where c'[j] = c[j] mod c[i] for j /= i and c'[i] = 0.
-> let c' = map (\x -> mod x ci) (zero i c)
-> c'' = divide ci (zero i c)
-> subst' = eliminate n (i, (invert c'' ++ [1], [])) subst in
-> intLinEqLoop n (c' ++ [ci], d) subst'
+> -- c[i]*x[n] + sum[j] (c[j] mod c[i])*x[j] = d[k] for all k
+> intLinEqLoop n (map (\x -> mod x ci) c ++ [ci], d) subst'
+> where
+> subst' = eliminate n (i, (invert c' ++ [1], [])) subst
+> c' = divide ci (zero i c)
>
> -- Find the smallest coefficient in absolute value
> smallest :: [Int] -> (Int, Int)
$
More information about the Haskell-Cafe
mailing list