- edited description
Remove/postpone confusing canonicalization of inner
Issue #107
new
From the time when inner
was symmetric, operands used to get sorted at the node definition time to allow
- common subexpression elimination (CSE),
- canonicalize hash.
Now inner
is Hermitian symmetric and UFL is in general (compute_form_data
is called) complex so hash(inner(a, b)) == hash(inner(b, a))
is not true and 2. is not relevant any more.
The objection is that now canonicalization yields unpredictable graphs:
from ufl import *
a = as_vector((Constant(interval), Constant(interval)))
b = as_vector((Constant(interval), Constant(interval)))
print(inner(a, b))
print(inner(b, a))
gives
([w_0, w_1]) : ([w_2, w_3])
conj((([w_0, w_1]) : ([w_2, w_3])))
Stephan and Lawrence suggest that sorting is done later (to keep supporting CSE) with something like:
def inner(self, o, a, b):
if (a, b) != tuple(sorted_expr((a, b))):
return Conj(Inner(b, a))
return Inner(a, b)
Comments (1)
-
reporter - Log in to comment