Made a small change to sort multiplied expressions into order during flattening in the usage checking
This makes sure that y*x and x*y are both flattened into x*y, but doesn't yet solve the problem of (x*y)*z vs (y*z)*x
This commit is contained in:
parent
f7e05c2714
commit
dd57fdccbd
|
@ -496,9 +496,11 @@ flatten e@(A.Dyadic m op lhs rhs)
|
|||
mult :: FlattenedExp -> FlattenedExp -> Either String FlattenedExp
|
||||
mult (Const x) e = scale x e
|
||||
mult e (Const x) = scale x e
|
||||
mult lhs rhs = do lhs' <- backToEq lhs
|
||||
rhs' <- backToEq rhs
|
||||
return $ (Scale 1 (A.Dyadic emptyMeta A.Mul lhs' rhs', 0))
|
||||
mult lhs rhs
|
||||
= do lhs' <- backToEq lhs
|
||||
rhs' <- backToEq rhs
|
||||
let (onLeft, onRight) = if lhs' <= rhs' then (lhs', rhs') else (rhs', lhs')
|
||||
return $ (Scale 1 (A.Dyadic emptyMeta A.Mul onLeft onRight, 0))
|
||||
|
||||
backScale :: Integer -> A.Expression -> A.Expression
|
||||
backScale 1 = id
|
||||
|
|
Loading…
Reference in New Issue
Block a user