pymbolic icon indicating copy to clipboard operation
pymbolic copied to clipboard

Stop auto-flattening

Open inducer opened this issue 3 years ago • 3 comments

FP arithmetic isn't associative, after all.

inducer avatar Oct 29 '21 01:10 inducer

I think the auto-flattening is just fine. See

>> import pymbolic.primitives as p
>>> a = p.Variable("a")
>>> b = p.Variable("b")
>>> c = p.Variable("c")

>>> (a * b) * c
Product((Variable('a'), Variable('b'), Variable('c')))  # flattening was legal and hence was done

>>> a * (b * c)
Product((Variable('a'), Product((Variable('b'), Variable('c')))))  # flattening wouldn't be legal and was avoided.

kaushikcfd avatar Oct 29 '21 01:10 kaushikcfd

12569d59cb548c15094d11b2a1cc1bd36ebe4895 removed the flattening in IdentityMapper.

inducer avatar Nov 20 '22 01:11 inducer

As for flatten-upon-creation, we should document that the intended eval order is from left to right, so that the flattening behavior on operator overload is fine, as @kaushikcfd states.

inducer avatar Nov 20 '22 01:11 inducer