]> git.unchartedbackwaters.co.uk Git - francis/lta.git/commitdiff
Avoid introducing a sum when negating a product.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Sun, 14 Apr 2013 10:47:06 +0000 (11:47 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Sun, 14 Apr 2013 10:47:06 +0000 (11:47 +0100)
LTA/Symbolic.hs

index d05f5f6c36399785fc16fc2821de176ed7a03a5e..b52cfc7bc8038a72b33307c5f22a74b6226dec86 100644 (file)
@@ -187,6 +187,7 @@ instance Num Expr where
   (*) a b = simplify . Product $ empty `addPair` (a, 1) `addPair` (b, 1)
   abs = UnaryFunction Abs
   fromInteger = Literal . fromInteger
+  negate (Product pairSeq) = Product $ transformOverall pairSeq (* (-1))
   negate a = simplify . Sum $ empty `addPair` (a, -1)
   signum = UnaryFunction Signum