On Wed, Jun 18, 2008 at 03:29, Ondrej Certik <[EMAIL PROTECTED]> wrote:
>>> It does, but it can be easily fixed, see above. I.e. fixing your >>> algorithm. :) The other option, as you said, is fixing sympy. We would >>> have to introduce a Sub class. >>> But I think it would just make things more complex. No? >> >> For all of sympy, yes. However, I think we could keep these >> transformations local to the cse module. You would have to implement >> just enough of Sub to replace Add(x, Mul(-constant, y)) and go back >> again. > > That's basically what my patch does. Yes, but down inside the guts of the CSE algorithm. My preference is to keep the core algorithm generic. It is currently entirely agnostic to the actual contents of the tree. > In terms of maintainability, I > think it's easier to maintain the two added lines, rather than a full > Sub class. If that were the only optimization, I would agree. However, this expression was the first I tested the algorithm on, and I found two places for optimization. I think we'll find more. Preprocess, CSE, then postprocess is more extensible, IMO, than adding special cases inside the CSE. I think that the product-of-powers case can only really be done by preprocessing, so we might as well do all of the optimizations by preprocessing. Unit testing is easier by separating the concerns of optimizing the representation and doing CSE. It opens the possibility for the user to select the optimizations they need. These are also things that can be added later, so having the core CSE implementation could go in right away (pending unit tests and multiple expressions). -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
