Expression evaluator
@ggael
Submitted by Gael GuennebaudAssigned to Nobody
Link to original bugzilla bug (#99)
Version: 3.0
Description
This include matrix products because they may hold the result of the product. But we have a similar issue with solve expressions and the like. Matrix and Array objects are also nested by reference.
The problem is when someone want to return an expression object containing some temporaries, like, for instance the expression of a chained product:
XXX foo(const MatA& A, const MatB& B) {
return A * (B * A);
}
See for instance this thread: http://forum.kde.org/viewtopic.php?f=74&t=91119
Perhaps there exist a solution allowing to always nest products by values while avoiding memory and performance overheads.
Some ideas in the case of dynamic sized object:
- we could add a "temporary" runtime flag enabling shallow copies
- in ProductBase, we could try to explicitly do a shallow copy in the copy ctor using swap
For statically allocated objects, however, I'm stuck. I don't see any alternative than relying on the smartness of the compiler.
Also note that temporaries might be created at different stage, some tricky examples that have to be seriously tested before pushing any changes:
(A+B) * C + D + E + F;
For general products, the expression (A+B) is evaluated during the evaluation of the product, so this temporary is not an issue. However, for simple coefficient base products (small ones) this might be an issue.
Depends on
Blocking
#100 #112 #138 #256 #257 #371 #408 #416 #512 (closed) #520 #536 #558 (closed) #604 #610 #835 #329 (closed) #505 (closed) #1001 (closed)