I think I already figured out the problem. The indices are in the form of a tuple like (0,N-1), and CSE tries to substitute all N-1 by some non-integer, which the Idx object does not like. Actually, CSE should not touch the indices, so I hacked it for this purpose and it works now.
I think I should probably also add a function in CSE to canonicalize indices of Indexed objects, and then submit the update as a pull request. Le vendredi 13 mars 2015 18:13:53 UTC-4, Jason Moore a écrit : > > If you make some small examples of how CSE fails with Indexed types and > submit them as issues, we can work to improve it for your needs. And you > are more than welcome to help. > > > Jason > moorepants.info > +01 530-601-9791 > > On Fri, Mar 13, 2015 at 2:05 PM, <j.gont...@gmail.com <javascript:>> > wrote: > >> Jason, >> >> thank you very much for pointing out the CSE algorithm. I discovered >> SymPy quite recently and was not aware of this feature. It seems to have >> difficulties with indexed objects unfortunately, apparently it is not >> properly setting the index ranges to be integer. I may be able to fix that >> by specializing relevant parts of CSE for Indexed objects, though... >> >> I had noticed the code printers, yes, and they will be put to good use :) >> One of my colleagues has already been using them here. >> >> Jérôme >> >> Le vendredi 13 mars 2015 13:52:14 UTC-4, Jason Moore a écrit : >>> >>> Jérôme, >>> >>> I don't anything about the tensor stuff, others will have to comment. >>> >>> As far as creating production numerical code is concerned, there are a >>> lot of tools available. We have a CSE algorithm that works really well and >>> we have code printers for a variety of languages in addition to code >>> generators and autowrappers for Python use. All of this is currently in >>> SymPy. >>> >>> For example, the PyDy project uses these facilities to build production >>> speed code for complex multibody dynamic systems in classical mechanics >>> using all of these tools. >>> >>> >>> Jason >>> moorepants.info >>> +01 530-601-9791 >>> >>> On Fri, Mar 13, 2015 at 10:29 AM, <j.gont...@gmail.com> wrote: >>> >>>> Hi everyone, >>>> >>>> First, thanks to all developers here for having made SymPy such a great >>>> tool. I am using it to help me derive some complicated expressions for >>>> electronic structure methods in quantum chemistry (I am a post-doc in >>>> GeorgiaTech, USA). >>>> >>>> Basically, I have a sum of tensor contractions (rank 2 and rank 4) with >>>> a significant number of terms. I started implementing new functions that >>>> operate on indexed objects to do some simple index manipulation and >>>> tensors >>>> substitution. I would simply like to know if anyone is working on this >>>> module right now to avoid any double effort ? >>>> >>>> My next endeavour is to implement a factorization and common >>>> subexpression elimination routine for these indexed objects, so as to >>>> reduce the total operation count to implement the resulting expression in >>>> a >>>> production-level quantum chemistry software (specifically, PSI4). Are any >>>> of you aware of similar work being done or already implemented in SymPy ? >>>> This needs to be more than the factor() function, because it needs to >>>> be able to identify factorization that yields the lowest operation count. >>>> I >>>> also noted that factor() did not partial factorization when some indexed >>>> quantity was present in some terms of a sum, but not all. >>>> My factorization implementation may use the collect() function though, >>>> if no one foresees any problem with that. >>>> >>>> Thanks! >>>> >>>> Jérôme >>>> >>>> -- >>>> 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+un...@googlegroups.com. >>>> To post to this group, send email to sy...@googlegroups.com. >>>> Visit this group at http://groups.google.com/group/sympy. >>>> To view this discussion on the web visit https://groups.google.com/d/ >>>> msgid/sympy/0fb89705-66ca-452a-acaf-28a7fcb0d7aa%40googlegroups.com >>>> <https://groups.google.com/d/msgid/sympy/0fb89705-66ca-452a-acaf-28a7fcb0d7aa%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> 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+un...@googlegroups.com <javascript:>. >> To post to this group, send email to sy...@googlegroups.com <javascript:> >> . >> Visit this group at http://groups.google.com/group/sympy. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/68aaabe2-87a3-4e66-b013-0a02baded21d%40googlegroups.com >> >> <https://groups.google.com/d/msgid/sympy/68aaabe2-87a3-4e66-b013-0a02baded21d%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/4908db48-4b80-4bea-98cd-c99467ab44a4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.