On Sat, 8 Dec 2018 09:31:46 +0100
"Mikael P. Sundqvist" <mic...@gmail.com> 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to