-
Notifications
You must be signed in to change notification settings - Fork 164
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
Initial implementation of Symbolic type #1591
Initial implementation of Symbolic type #1591
Conversation
print(x) | ||
|
||
main0() | ||
main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, this doesn't work in CPython. I think we have to handle this in ltypes and make sure this works with CPython
x: i32 | ||
x = (2+3)*5 | ||
def main(): | ||
x: symbolic = Symbolic('x') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from lpython import Symbolic
from sympy import Symbol
...
x: symbolic = Symbolic('x') | |
x: Symbolic = Symbol('x') |
Here is a simple symbolic code: from lpython import S
from sympy import Symbol
def f():
x: S = Symbol("x")
y: S = Symbol("y")
z: S = x + y
print(z)
f() At the ASR level this would be represented using Then I would write an ASR pass that transforms the above into explicit calls to SymEngine's C interface, so something like (approximately): basic x = symbol("x')
basic y = symbol("y")
basic z = add(x, y)
printf(str(z))
free(z)
free(x)
free(y) where Let's use the LLVM backend, which will generate an object file, that depends on these C functions. Then when we link, we have to link against the SymEngine library (either static or dynamic) and ensure the C++ runtime library (that SymEngine depends on) is also properly linked. It shouldn't be difficult, and we should only do it if I made a dedicated issue with the design here: #1607. |
Closing as the |
cc @anutosh491