Le 03/11/13 14:19, Jason Moore a écrit :
Ronan,

Thanks for looking at the derivation code. We haven't ever really had
any review of it outside of our mechanical engineer group, so this very
helpful.

I'll review your PR and look into the second two items.

Why do you think the dictionary representation will be so much faster?

Using a dict would make Vector.__eq__ a lot less expensive, and make canonicalisation (as currently done in Vector.__init__) O(len(args)) instead of O(len(args)**2).

However, it seems that the main performance issue is that instantiating Matrix objects is expensive. Using a dict isn't strictly required to solve this, but the structure I suggest would allow e.g. dot products of vectors to be decomposed as combinations of multiplications of components and dot products of base vectors, which can be optimised or cached separately. There would be no need for intermediate Matrix objects.



On Sat, Nov 2, 2013 at 10:11 PM, Ronan Lamy <[email protected]
<mailto:[email protected]>> wrote:

    Le 01/11/13 11:54, Jason Moore a écrit :

        I've been tinkering with code generation for ODE's that
        sympy.physics.mechanics spits out and have some results:

        http://www.moorepants.info/__blog/pydy-code-gen.html
        <http://www.moorepants.info/blog/pydy-code-gen.html>

        Several people have posted topics on this recently. We need to
        build in
        a code generator for solving ODE's into SymPy that would play
        well with
        the codegen and autowrap modules. I think I can use this code I
        wrote as
        a base to start working on that but would need some help
        generalizing it
        beyond our systems. Feedback is welcome.


    I've only looked at the derivation part, it's an interesting
    real-world(ish) benchmark for expression manipulation. However, it
    incurs a lot of avoidable overhead:
    * Extracting some loop constants out of their loops cuts down the
    run-time by 40%, cf. https://github.com/sympy/__sympy/pull/2570
    <https://github.com/sympy/sympy/pull/2570>
    * The creation of temporary objects by the Vector class takes up
    most of the run-time.
    * The internal representation of Vector objects seems inefficient. I
    think it should be switched to a dict-based representation as a
    linear combination of base vectors (e.g. using {I.x: l0, B.y: -l1}
    for l0 * I.x - l1 * B.y).


    --
    You received this message because you are subscribed to the Google
    Groups "sympy" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to sympy+unsubscribe@__googlegroups.com
    <mailto:sympy%[email protected]>.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    Visit this group at http://groups.google.com/__group/sympy
    <http://groups.google.com/group/sympy>.
    For more options, visit https://groups.google.com/__groups/opt_out
    <https://groups.google.com/groups/opt_out>.


--
You received this message because you are subscribed to the Google
Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to