Initial implementation of Symbolic type#1591
Initial implementation of Symbolic type#1591Thirumalai-Shaktivel wants to merge 1 commit intolcompilers:mainfrom
Conversation
| print(x) | ||
|
|
||
| main0() | ||
| main() |
There was a problem hiding this comment.
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.
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