Using sym() results in overhead
Bug #868255 reported by
Gerd Wachsmuth
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
UFL |
Invalid
|
Low
|
Unassigned |
Bug Description
If I use the function sym() to assemble a form containing the symmetric part of a matrix, the (1,1)-element of the matrix gets represented as "2*A[1,1]/2" or "(A[1,1]
For instance, compiling
element = TensorElement("CG", triangle, 1)
A = Coefficient(
B = Coefficient(
a = sqrt(inner(
with ffc (optimization turned on with -O), the header file contains something like "(F0 + F0)/2.000000000
To post a comment you must log in.
Won't fix for 1.0.
Could possibly be fixed locally by specifying each matrix entry separately.
In general, optimizations like this are not done in UFL for good reasons,
UFL is really careful about not modifying the input expressions.
In the future, this particular case ((n*x)/n) _may_ be a candidate for
automatic simplification, along with other similar cases.
Have you actually profiled code with and without this though?
I would half expect (or hope) that the optimizing C++ compiler picked this up.