Bill Page wrote:
>
> > Dima Pasechnik wrote:
> > ...
> >> running Maxima in ECL,
> >> which is embedded in Python; for the latter the code is in
> >> src/sage/libs/ecl.pyx
> >>
> >> In the latter one sees an example of calling CL functions from Sage:
> >>
> >> sage: from sage.libs.ecl import *
> >> sage: ecl_eval("(defun fibo (n)(cond((= n 0) 0)((= n 1) 1)(T (+
> >> (fibo (- n 1)) (fibo (- n 2))))))")
> >> <ECL: FIBO>
> >> sage: ecl_eval("(mapcar 'fibo '(1 2 3 4 5 6 7))")
> >> <ECL: (1 1 2 3 5 8 13)>
> >>
> >> That is, one would just need to adapt src/sage/interfaces/maxima_lib.py to
> >> loading/running FriCAS instead.
> >> For this one needs to know some parts of FriCAS, that is, how to load it in
> >> a running CL instance, etc etc...
>
>
> On 13 August 2016 at 07:08, Waldek Hebisch <[email protected]> wrote:
> >
> > With the following patch applied to FriCAS trunk:
> > ...
> > I can use the following to produce fricas as shared library:
> > ...
>
> That is excellent.
>
> > Once FriCAS shared library is created in ECL you can do:
> >
> > (load "src/interp/fricas_lib.fas")
> > (in-package "BOOT")
> > (fricas-init)
> >
> > and then use FriCAS functions. Presumably in Sage it will look
> > like:
> >
> > ecl_eval("(load \"src/interp/fricas_lib.fas\")")
> > ecl_eval("(in-package \"BOOT\")")
> > ecl_eval("(fricas-init)")
> >
>
> What is the best way to interact with FriCAS once the shared library
> is loaded and FriCAS in initialized? For example, what would be
> required to call FriCAS with a command string from Python and return
> the result as a string?
Well, what is best depends on your criteria. From performance point
of view best is accessing the same data and that is what interface
between ECL and C can do. I do not know what Sage interface to
ECL is doing, but I suspect that it essentially provides Python
wrapper of ECL data. Of course, FriCAS and Sage are using different
data structures and you need some translation layer. If
you insist on using strings, than extracting string from
result given by ecl_eval should be easy. But one point about
library interface is that there is no need to go via strings.
For example FriCAS can directly fill C array with data or
Python can directly read data from FriCAS data structures.
> I think that the gains from running FriCAS as a library will out
> weight the difference in performance between ECL and SBCL for most
> Sage users.
At functionality level socket interface and in-process calls can
have almost the same functionality. Main difference is performance.
If you are using strings for data exchange, then you decrease
performance advantage. I supect that for most users performance
difference between in-process calls and socket interface
will not matter. Of course, I mean here socket interface
with proper translation layer, not current regex + pexpect
hack.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.