On Sun, Mar 19, 2023 at 7:09 PM brombo <[email protected]> wrote:
>
> First I think there is a problem with ccode doing what it is supposed to do.  
> Consider the following code -
> (x,y,th) = symbols(r"x' y' \theta")
>
> then
> x' = ccode(x)
> y' = ccode(y)
> \theta = ccode(th)
>
> I don't think x', y', and \theta are legal program variables in c.

I think this functionality exists in some of the other printers. It
does exist in lambdify, so it shouldn't be too hard to port to the C
printer.
>
> Also I have looking at codegen examples and wish to know if the following 
> conclusion is correct. If I have a python function (example) -
>
> def W(x):
>     s = 1
>     for i in range(10):
>         s += x**i
>    return s
>
> there is no simple way (if any) to convert it to -

Starting with Python code is harder, but you can represent this sort
of thing using the codegen ast nodes in sympy.codegen module.

Aaron Meurer

>
> double W(double x)
> {
>   double s = 1;
>   int i;
>   for (i=0;i<10;++i)
>   {
>     s = s+pow(x,i);
>   }
>   return s;
> }
> On Saturday, March 18, 2023 at 11:14:20 AM UTC-4 [email protected] wrote:
>>
>> You can make custom printers for any SymPy function to return what you 
>> desire. Subclass the C printer and overwrite/create methods for your 
>> functions. The current c code printer does not target any specialized C 
>> libraries (but that would be a nice addition!).
>>
>> Jason
>> moorepants.info
>> +01 530-601-9791
>>
>>
>> On Sat, Mar 18, 2023 at 3:18 PM brombo <[email protected]> wrote:
>>>
>>> I have looked further and while ccode(expr) can export functions like sin, 
>>> cox, exp it cannot export special functions such as bessel, elliptic, etc.. 
>>> Is there a way to export special functions into c-code?
>>>
>>> On Saturday, March 18, 2023 at 9:52:48 AM UTC-4 brombo wrote:
>>>>
>>>> Does the C code generator generate special function calls with the same 
>>>> syntax that is used in the gsl (GNU Scientific Library).  For example is 
>>>> the sympy call besselj(nu,z) translated to J(nu,z) etc.?
>>>
>>> --
>>> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/sympy/73a99292-df6c-420a-804a-b2a52dfae437n%40googlegroups.com.
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/8dd42cf4-470d-4d78-9b99-71a617b0ff25n%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6LyM87gs2WGr4dmJZC9-Y-DDedyroCOahjiJuHgniMh6A%40mail.gmail.com.

Reply via email to