Alasdair McAndrew wrote:
> 
> I was looking at some lisp numeric libraries: gsll at 
> https://common-lisp.net/project/gsll/ (which is a wrapper for the Gnu 
> Scientific Library GSL), as well as mjrcalc at 
> http://www.mitchr.me/SS/mjrcalc/.  I imagined that as these were Lisp 
> libraries, there would be some way of integrating them into FriCAS - or at 
> least making them available so that they can be used from within a FriCAS 
> session.  However, my attempts (such as they were) came to nothing: and I 
> wasn't sure whether to )compile, )read, or do something else.
> 
> Is there some documented standard method of integrating external libraries 
> with FriCAS?

Concerning documentation, I wrote some time ago about interfacing
to one of Lapack function.

Lisp functions are a bit easier than other languages, but not
much.  To use a library from FriCAS, one need to first decide
in interface.  That is how FriCAS types correspond to library
types.  Normally this involves writing FriCAS domain/package
with apropritate declarations.  One example may be plotting
subsystem:  at Spad level there are viewport domains which
export somewhat high-level interface and implement operations
calling low-level functions.  The low-level parts are done
by several Lisp functions which are called using '$Lisp'
qualification.  The interface uses several constans defined
as Spad macros -- the constants on Spad side must agree
with constants used at other side (that is in C code).

At lower level one needs to ensure that the code is available.
Standard FriCAS code is either already loaded or FriCAS knows
how to load it on demand.  With arbitrary Lisp code one
can use ')read' (which compiles files and then loads it).
I am affraid we do not have a special command to load
Lisp without compiling, be one can do this via ')lisp'
command like:

)lisp (load "prog.fasl")

Note that FriCAS may run only using AXIOMsys executable,
which contains Lisp compiler but may miss large part
of Lisp environment.  For example, you had problem
because Lisp compiler inside FriCAS did not know
where to find Lisp libraries bundled with sbcl.

Currently for non-Lisp libraries one have to create
apropriate wrappers at Lisp level -- basically specify
type of C routine so that Lisp knowns how to pass
arguments.  In sbcl non-Lisp dynamic libraries are
easy to use: to load them one needs to use
'|quiet_load_alien|' routine giving it path to the
library.  After loadnig wrappers become usable.
When it comes to Lisp libraries each Lisp is
slightly different.  In sbcl one can load Lisp
code (which either looses execution time if
file is interpreted or looses time compiling it),
load a fasl (which contains already compiled code
but still needs nontrivial time to load) or create
a new image.  Images start fast, but they take
some effect to create, in particular one needs
to make sure that they are properly initialised.
Also. each image contains a copy of AXIOMsys
executable so multiple images could take
a lot of space.  Concerning fasl-s, there
are some provisions to create aggregate fasl-s
but usually each file gives a sparate fasl,
so in case of multifile library one have to
load several files.

There is extra difficulty with using Lisp libraries:
modern Lisp code frequently uses so called keyword
arguments.  In FriCAS using keyword arguments is
awkward, so one may be forced to create wrappers
at Lisp level which present interface free of
keyword arguments.

To summarize, if you have Lisp library in a single
file that uses FriCAS compatible data representation,
than use may be as easy as

)read "file.lisp"

DO_SOMETHING(42)$Lisp

But interesting things may require extra interface code.

BTW: Are there some specific routines that you need or
do want just to have the libraries handy?

-- 
                              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 http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to