If you want to interact with PARI/GP it is much better (= faster and
more reliable) to use the cypari interface. Namely
sage: s = pari('square(x)=x^2')
sage: s(20)
400
If you want to convert the output of s(20) (a "Gen") then use
sage: s(20).sage()
400
sage: type(s20)
<class 'cypari2.gen.Gen'>
sage: type(s(20).sage())
<class 'sage.rings.integer.Integer'>
Vincent
Le 13/01/2020 à 08:31, Pedja Terzic a écrit :
Thank you, it works!
On Sun, Jan 12, 2020 at 7:54 PM Dima Pasechnik <dimp...@gmail.com> wrote:
e.g. something like
sage: gp.eval("square(x)=x^2")
'(x)->x^2'
sage: gp.function_call("square",[20]).sage()
400
So one can have
def foo(x):
return gp.function_call("square",[x]).sage()
to create a Sage function that will square a number using GP
On Sun, Jan 12, 2020 at 2:26 PM Dima Pasechnik <dimp...@gmail.com> wrote:
this way Python does not know anything about GP functions.
You need to pass the input/output from/to Python.
On Sun, 12 Jan 2020, 14:06 Pedja, <tersi...@gmail.com> wrote:
Why the following code doesn't work inside Sage Cell?
gp("""
square(x)=x^2;
""")
@interact
def _(x=2):
print(square(x))
--
You received this message because you are subscribed to the Google
Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/25a5f980-f93d-4721-94d4-e5f1677b285d%40googlegroups.com
.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/CAAWYfq0rwwUEQFxmexC9vn8PaLczFSBFGSekYQFQMKi5bTPFFw%40mail.gmail.com
.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/1c312d8b-2a30-2295-8c2a-39276d8920c1%40gmail.com.