On Sat, Dec 8, 2018 at 4:15 PM Alan Braslau
On Sat, 8 Dec 2018 09:31:46 +0100 "Mikael P. Sundqvist"
wrote: 3) It would be nice to be able to plot some special functions. I'm thinking of the usual suspects, Airy, Bessel, Hypergeometric, Laguerre, Legendre, ... Could it be that one could have support via some lua library?
I use ffi and libcerf (thank you Luigi!) For example (lots of other functions are available):
\startluacode
ffi = require("ffi") ffi.cdef[[ double j0(double x); double j1(double x); double jn(double x); ]]
cerf = ffi.load(ffi.os == "OSX" and "/opt/local/lib/libcerf.dylib" or "cerf")
\stopluacode
\startMPdefinitions {doublefun}
vardef jzero primary x = scantokens(lua("mp.quoted( ffi.C.j0(" & decimal x & "))")) enddef ; vardef jone primary x = scantokens(lua("mp.quoted( ffi.C.j1(" & decimal x & "))")) enddef ; vardef jn primary x = scantokens(lua("mp.quoted( ffi.C.jn(" & decimal x & "))")) enddef ;
\stopMPdefinitions
Thanks, Alan! That looks very promising. I could not make it work, though, and I guess that is because I use linux and do not know what to change for what. I installed libcerf but I assume something else is missing. In any case, this is one of the things it would be nice to have, at least as a module. I have no idea on how to realize that, though. /Mikael