Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Does SymEngine have an internal malloc function

30 views
Skip to first unread message

Anutosh Bhat

unread,
Jul 15, 2023, 11:44:04 AM7/15/23
to symengine
Hello all, 

I am implementing Symbolic Algorithms for LPython as a part of my GSoC project . Y'all can find the abstract of the project here  Program Project | Google Summer of Code

So I am working on a program which goes as follows 

@ccall(header="symengine/cwrapper.h")
def basic_new_stack(x: CPtr) -> None:
    pass

@ccall(header="symengine/cwrapper.h")
def basic_const_pi(x: CPtr) -> None:
    pass

@ccall(header="symengine/cwrapper.h")
def basic_str(x: CPtr) -> str:
    pass

@ccall
def _lfortran_malloc(size: i32) -> CPtr:
    pass

def main0():
    x: CPtr = _lfortran_malloc(i32(sizeof(i64)))
    basic_new_stack(x)
    basic_const_pi(x)
    s: str = basic_str(x)
    print(s)

main0()

Here I am using LFortran's malloc function but I am curious to know if there is an internal function available within the SymEngine library that handles the memory allocation internally. I went through SymEngine's documentation but didn't wasn't able to find anything. Any idea of what could be used would be great

Regards,
Anutosh Bhat

Ondřej Čertík

unread,
Jul 16, 2023, 4:11:06 PM7/16/23
to syme...@googlegroups.com
Hi Anutosh,

On Sat, Jul 15, 2023, at 12:34 AM, Anutosh Bhat wrote:
> Hello all,
>
> I am implementing Symbolic Algorithms for LPython as a part of my GSoC
> project . Y'all can find the abstract of the project here Program
> Project | Google Summer of Code
> <https://summerofcode.withgoogle.com/programs/2023/projects/KwNcukf5>
Yes, it's called basic_new_heap, here is how to use it:

https://github.com/symengine/symengine/blob/e99496e03e6425b6ccb05c80aa531453670fbad2/symengine/tests/cwrapper/test_cwrapper.c#L201

Ondrej
Reply all
Reply to author
Forward
0 new messages