Just as an experiment I'm taking the quadpack.lisp file from the Maxima distribution, to see if I can install it and have it working under FriCAS. However, as a total Lisp newbie, I'm continuously stumped by trivial errors. For example, quadpack.lisp uses the f2cl-lib package. I can install this with quicklisp, but I don't know (yet) how to make that package available from within FriCAS. For that matter, I don't know how to make the quicklisp package ql available: even the line
(load "~/quicklisp/setup.lisp") which should work, doesn't appear to help - lines beginning with "(ql: " are immediately flagged as errors and the ")read" compile is aborted. I'll keep on fiddling... (while Rome burns). -Alasdair On Sat, Oct 24, 2015 at 10:03 AM, Kurt Pagani <nil...@gmail.com> wrote: > Hello Alasdair > > What I have completely forgotten to mention in the last post: > > In the fricas/contrib folder there is a file load-fricas.lisp which > allows you to use FriCAS as a cl library itself. This way you can mix in > any kind of library as long there is no interference to the "boot" > package (I'm aware of only very few ones). > > BTW: I found that > (load "../lisp/primitives.lisp") > is missing in the file, so if you encounter problems it might be this > what caused an error. (see below). I used it occasionally in the > cl-jupyter frontend. > > -- > Kurt > > #| > To use FriCAS as a Lisp library build FriCAS as usual and > keep the build tree. Change path below to point to build > tree. After that doing: > > (load "load-fricas.lisp") > > will load and initialize FriCAS. > > Examples: > Using FriCAS command interpreter: > > (in-package "BOOT") > (|parseAndInterpret| "x^2") > > 2 > (2) x > Type: Polynomial > Integer > ((Polynomial (Integer)) WRAPPED 1 x (2 0 . 1)) > > Directly calling math functions: > > (defvar *mult-i-sup* > (|getFunctionFromDomain| > '* > '(|SparseUnivariatePolynomial| (|Integer|)) > '((|SparseUnivariatePolynomial| (|Integer|)) > (|SparseUnivariatePolynomial| (|Integer|))))) > *MULT-I-SUP* > > (SPADCALL '((2 . 1) (0 . 1)) '((5 . 1) (0 . 1)) *mult-i-sup*) > ((7 . 1) (5 . 1) (2 . 1) (0 . 1)) > > > Notes: > - all intersting functionality is in package called "BOOT". > - at mathematical level FriCAS is case-sensitive, so at Lisp level one > has to use bars. > - the simplest interface is |parseAndInterpret| which takes a string > as input and produces a Lisp form repesenting printed output. As > side effect |parseAndInterpret| prints the result. > - at deeper lever FriCAS functions are overloaded, so to call correct > function one has to first use |getFunctionFromDomain| to get > function which matches to given argument types. Above I want to > multiply two sparse univarate polynomials with integer coefficients. > Since lookup may be expensive the caller is adviced to cache result > of the lookup. > - FriCAS functions use special calling convention, so one has to use > SPADCALL macro to call them. Actually, |getFunctionFromDomain| > returns a pair consistion of a function and an extra argument. > SPADCALL takes care of decomposing the pair and appending the > extra argument to the argument list. > > Currently FriCAS sets a few system (global) variables, for example > *read-default-float-format* is set to 'double-float -- in principle > FriCAS settings may interfere with other programs. > > |# > (let ((*default-pathname-defaults* > #P"~/Development/ax-build/src/interp/")) > (load "../lisp/fricas-package.lisp") > (load "../lisp/fricas-config.lisp") > (load "../lisp/fricas-lisp") > (load "../lisp/primitives.lisp") ;;;+kfp > (load "makeint.lisp")) > (in-package "BOOT") > (fricas-init) > > (in-package "BOOT") > (|parseAndInterpret| "x^2") > kfp@helix:~/Development/fricas/contrib$ > > > Am 23.10.2015 um 09:24 schrieb Waldek Hebisch: > > 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? > > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "FriCAS - computer algebra system" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/fricas-devel/q18Av7P3jnM/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > fricas-devel+unsubscr...@googlegroups.com. > To post to this group, send email to fricas-devel@googlegroups.com. > Visit this group at http://groups.google.com/group/fricas-devel. > For more options, visit https://groups.google.com/d/optout. > -- [image: http://www.facebook.com/alasdair.mcandrew] <http://www.facebook.com/alasdair.mcandrew> [image: https://plus.google.com/+AlasdairMcAndrew/posts] <https://plus.google.com/+AlasdairMcAndrew/posts> [image: https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108] <https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108> [image: https://twitter.com/amca01] <https://twitter.com/amca01> [image: http://numbersandshapes.net] <http://numbersandshapes.net> -- 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 fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.