Wow this looks really nice, I'm glad to see others extending these
code generation features.

Some comments regarding the request for review, using the commit
194edc73e6743c666315821a0c2ead0eb93588a3 .  Overall I am +1 for
pushing but I would like to see a few small changes, probably move
some of the comments into issues into themselves.

fcode.py
-----------

* I don't like the repeating of many of functions that ccode has as
well.  It seems that we could have a low level code generator that is
general enough to abstract many things, such as printing the implicit
functions and constant values.  For example print pow, some special
functions and constants. This is probably a whole new issue though not
something to stop the code from being pushed.


* The implicit_functions dict should only rename functions if
necessary.  As it is this makes the code bloated.


* Can you do piecewise functions the same way as ccode does where you
have the _print_Piecewise function.  Probably could go into
LowLevelCodePrinter as well.


* the line wrapping produces bad code (unreadable).  There needs to be
work to take care of cases where operators will be split.  For
example:

In [12]: e = [x**i for i in range(11)]

In [13]: print fcode(Add(*e))
-------> print(fcode(Add(*e)))
      1 + x + x**2 + x**3 + x**4 + x**5 + x**6 + x**7 + x**8 + x**9 + x*
     @    *10


* fcode function should move to something like the following signature
(expr, *args, **kws) and look up the keywords, it gets too many
optional keywords as is.


* Something that might be nice, instead of an exception being thrown
just have a list of functions that are in the expression but not
implemented in the core language. That way a code generator can look
at what needs to be implemented and prompt the user appropriately
instead of just halting.


* One test failed for me:

__________________________ sympy.printing.fcode.fcode __________________________
File "/Users/aterrel/workspace/sympy/sympy/printing/fcode.py", line
252, in sympy.printing.fcode.fcode
Failed example:
    fcode((2*tau)**Rational(7,2))
Expected:
    '      8*2**(1.0/2.0)*tau**(7.0/2.0)'
Got:
    '      8*sqrt(2)*tau**(7.0/2.0)'


The tests and docs look good.  We should probably take some time and
make ccode this good as well.


-- Andy




On Thu, Jul 2, 2009 at 5:27 AM, Toon
Verstraelen<[email protected]> wrote:
> Hi All,
>
> I have a rather workable implementation of fcode (the fortran counterpart of
> ccode). You can grab it here: http://github.com/tovrstra/sympy/tree/issue1487
>
> I think it is more or less OK to merge the patches? I tried to take into 
> account
> all the comments from issue 1487. Only non-top-level piecewise functions are 
> not
> supported yet. Appart from that, it generates nice Fortran code that one can
> copy-paste and compile. fcode is also designed to play well with codegen in 
> the
> future. For the interested: more details can be found in
> doc/src/modules/printing.txt
>
> cheers,
>
> Toon
>
>
> --
> Dr. ir. Toon Verstraelen
> Center for Molecular Modeling
> Ghent University
> Proeftuinstraat 86
> B9000 Gent
> Belgium
> Tel: +32 9 264 65 56
> E-mail: [email protected]
> http://molmod.UGent.be/
> http://molmod.UGent.be/code/
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to