-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure out how to allow the x**2+y**2 syntax with symbolic expressions #4
Comments
Btw, why do you need to generate Fortran code if you are using symengine in Fortran? Isn't lambdify enough? |
Does lambdify create a C++ function behind the scenes? Right now, I don't see how it can be pulled in to Fortran, since the Fortran interface should be available at compile time. I'm assuming it is possible to have same kind of dynamic Fortran object with a handle to a Fortran 2018 also opened a path to access allocatable and pointer entities from C, using the "ISO_Fortran_Binding.h" header file. I imagine this can also be used in some situations to provide a "native" feel to any kind of Fortran interface. For the reason to do it in the first place, @certik wrote:
|
https://github.com/symengine/symengine/blob/065b7a9dbebaadee1547f1b9c472b7b76d935eea/symengine/cwrapper.h#L711-L713 creates a C++ function and stores it in the
|
@isuruf I think @ivan-pi's original use case was to write a script that generates Fortran code that gets compiled. It's just that instead of using Python one would use Fortran. The use case you have in mind is to simply generate things on the fly using LLVM, and I think that would be useful too. The only disadvantage is that one then must link with SymEngine and LLVM in a production code, which might or might not be desirable. |
This issue has been addressed in #9 |
This now works after the merging of #9 |
@ivan-pi posted an example here:
https://fortran-lang.discourse.group/t/code-generation-using-sympy/321/5
I assume one must overload the
+
and**
operators, and then make it work with thesym_t
type (I would just call itsym
, as in Matlab). One issue is about ensuring it does not leak memory, i.e. in:c = a + b + c
, it must automatically deallocate the intermediate expressions. The same inx**2+y**2
, the operator**
first createsx**2
, but then when you dox**2+y**2
, it must deallocate thex**2
. In C++ and in Python, when the expression goes out of scope, its destructor gets called which deallocates the memory.The text was updated successfully, but these errors were encountered: