[NTG-context] graphics

Alan Braslau braslau.list at comcast.net
Sat Dec 8 16:15:20 CET 2018


On Sat, 8 Dec 2018 09:31:46 +0100
"Mikael P. Sundqvist" <mickep at 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


More information about the ntg-context mailing list