Skip to content

Commit

Permalink
Allow multiplication of constant AffineExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
gruhn committed Apr 28, 2024
1 parent 1e3c0c5 commit 1313196
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Theory/LinearArithmatic/Constraint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ data AffineExpr = AffineExpr
instance Num AffineExpr where
AffineExpr constA coeffsA + AffineExpr constB coeffsB =
AffineExpr (constA+constB) (M.unionWith (+) coeffsA coeffsB)
(*) = error "AffineExpr not closed under multiplication"

AffineExpr constA coeffsA * AffineExpr constB coeffsB
| M.null coeffsA = AffineExpr (constA*constB) (M.map (constA*) coeffsB)
| M.null coeffsB = AffineExpr (constA*constB) (M.map (constB*) coeffsA)
| otherwise = error "Can't multiply two non-constant AffineExpr because the result is not affine."

abs = error "TODO"
signum = error "TODO"
fromInteger n = AffineExpr (fromInteger n) M.empty
Expand Down

0 comments on commit 1313196

Please sign in to comment.