Hi, This is my first attempt to use the sympy-patches list. The attached patch is a proposal for the code generator for sympy, and includes working tests. The current possibilities are intentionally very limited, but the code should be extensible with future patches to handle the more complex cases of interest.
The friendly interface is the codegen function, and works like this: xyz = symbols("xyz") codegen([("fn",(x+y)*z)], "C", "codegen") This writes two files: codegen.h: /****************************************************************************** * Code generated with sympy 0.6.5-git * * * * See http://www.sympy.org/ for more information. * * * * This file is part of 'project' * ******************************************************************************/ #ifndef PROJECT__CODEGEN__H #define PROJECT__CODEGEN__H double test(double x, double y, double z); #endif codegen.c: /****************************************************************************** * Code generated with sympy 0.6.5-git * * * * See http://www.sympy.org/ for more information. * * * * This file is part of 'project' * ******************************************************************************/ #include "codegen.h" #include <math.h> double test(double x, double y, double z) { return z*(x + y); } The codegen function is based a more complex api with more possibilities. More info can be found as comments and the doc strings. Any comments are appreciated. (coding style, typo's, code design, milestones, ...) cheers, Toon -- ir. Toon Verstraelen Center for Molecular Modeling Ghent University Proeftuinstraat 86 B9000 Gent Belgium Tel: +32 9 264 65 56 E-mail: toon.verstrae...@ugent.be http://molmod.UGent.be/ http://molmod.UGent.be/code/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---
0001-Initial-codegen-implementation.patch.gz
Description: GNU Zip compressed data
begin:vcard fn:Toon Verstraelen n:Verstraelen;Toon org:Ghent University;Center for Molecular Modeling adr:;;Proeftuinstraat 86;Ghent;;9000;Belgium email;internet:toon.verstrae...@ugent.be title:ir. tel;work:+32 (0) 9 264 65 56 tel;home:+32 (0) 9 351 56 05 x-mozilla-html:FALSE url:http://molmod.ugent.be version:2.1 end:vcard