[NTG-context] finding content of xml elements
Having a string pointing to an element in the XML-tree, for example IDENT::3 as the third element of the tree IDENT. How can access this element in a Lua function as function examine(element)…end called with value element = IDENT::3? Or formulated otherwise: how can I reach from that string into the XML-tree? dr. Hans van der Meer ___ 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 ___
Re: [NTG-context] graphics
On Thu, 13 Dec 2018 09:02:05 +1300 Henri Menke wrote: > On 13/12/18 8:56 AM, Alan Braslau wrote: > > On Wed, 12 Dec 2018 20:42:56 +0100 > > "Mikael P. Sundqvist" wrote: > >> > >> 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 > > > > You likely also need to install libffi - I do not know what package > > this is on your flavor of linux - Luigi is the ffi specialist! > > FFI is integrated in LuaTeX >= 1.03 > > In you example you load libcerf but you are not using it. What you > are actually using are the Bessel function from the C Standard > library. GCC includes them as a GNU extension. > https://www.gnu.org/software/libc/manual/html_node/Special-Functions.html#index-j0 > Your example also works if you remove libcerf (at least for me on > Linux). I had stripped-down my example, for in fact I use the voigt and error functions from libcerf, and yes the Bessel functions from the standard C math library. One should note, by the way, that the C math library is more or less complete depending on the system, and not everyone uses gcc nor gnu... Alan ___ 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 ___
Re: [NTG-context] graphics
On Wed, 12 Dec 2018 14:51:47 +0100 Mathias Schickel wrote: > You can see the desired behaviour in the attached pdf output of the > LaTeX file. No, one cannot, unless one has Adobe... Alan ___ 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 ___
Re: [NTG-context] graphics
On 13/12/18 9:12 AM, Alan Braslau wrote: > On Thu, 13 Dec 2018 09:02:05 +1300 > Henri Menke wrote: > >> On 13/12/18 8:56 AM, Alan Braslau wrote: >>> On Wed, 12 Dec 2018 20:42:56 +0100 >>> "Mikael P. Sundqvist" wrote: 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 >>> >>> You likely also need to install libffi - I do not know what package >>> this is on your flavor of linux - Luigi is the ffi specialist! >> >> FFI is integrated in LuaTeX >= 1.03 >> >> In you example you load libcerf but you are not using it. What you >> are actually using are the Bessel function from the C Standard >> library. GCC includes them as a GNU extension. >> https://www.gnu.org/software/libc/manual/html_node/Special-Functions.html#index-j0 >> Your example also works if you remove libcerf (at least for me on >> Linux). > > I had stripped-down my example, for in fact I use the voigt and error > functions from libcerf, and yes the Bessel functions from the standard > C math library. One should note, by the way, that the C math library is > more or less complete depending on the system, and not everyone uses > gcc nor gnu... Sorry, my mistake, the Bessel functions are not a GCC extension but POSIX standard functions. http://pubs.opengroup.org/onlinepubs/9699919799/functions/j0.html Since TeX Live is always built on a POSIX platform (MSYS2 on Windows), you can expect j0 etc. to be available in LuaTeX. > > Alan > ___ 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 ___
Re: [NTG-context] graphics
On Thu, 13 Dec 2018 10:03:40 +1300 Henri Menke wrote: > Sorry, my mistake, the Bessel functions are not a GCC extension but > POSIX standard functions. > http://pubs.opengroup.org/onlinepubs/9699919799/functions/j0.html > Since TeX Live is always built on a POSIX platform (MSYS2 on Windows), > you can expect j0 etc. to be available in LuaTeX. That is true for the Bessel functions, but not for some other "-lmath" functions (such as the erf), so they may depend on the system. Alan ___ 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 ___
Re: [NTG-context] graphics
On Wed, 12 Dec 2018 20:42:56 +0100 "Mikael P. Sundqvist" wrote: > > 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 You likely also need to install libffi - I do not know what package this is on your flavor of linux - Luigi is the ffi specialist! Alan ___ 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 ___
Re: [NTG-context] graphics
On Wed, Dec 12, 2018 at 9:02 PM Henri Menke wrote: > > On 13/12/18 8:56 AM, Alan Braslau wrote: > > On Wed, 12 Dec 2018 20:42:56 +0100 > > "Mikael P. Sundqvist" wrote: > >> > >> 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 > > > > You likely also need to install libffi - I do not know what package > > this is on your flavor of linux - Luigi is the ffi specialist! > > FFI is integrated in LuaTeX >= 1.03 > > In you example you load libcerf but you are not using it. What you are > actually using are the Bessel function from the C Standard library. GCC > includes them as a GNU extension. > https://www.gnu.org/software/libc/manual/html_node/Special-Functions.html#index-j0 > Your example also works if you remove libcerf (at least for me on Linux). > Thanks Henri! Indeed it worked now. The following example (just in case someone else did not get what to change) compiles here, and shows the expected graph. This is very good news! \startluacode ffi = require("ffi") ffi.cdef[[ double j0(double x); double j1(double x); double jn(double x); ]] \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 jnprimary x = scantokens(lua("mp.quoted( ffi.C.jn(" & decimal x & "))")) enddef ; \stopMPdefinitions \starttext \startMPpage[instance=doublefun] draw function(1,"x","jone(x)",epsed(0),epsed(10),1/10) scaled 1cm; \stopMPpage \stoptext /Mikael ___ 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 ___
Re: [NTG-context] graphics
On Sat, Dec 8, 2018 at 4:15 PM Alan Braslau wrote: > > 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 jnprimary 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 ___ 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 ___
Re: [NTG-context] graphics
On 13/12/18 8:56 AM, Alan Braslau wrote: > On Wed, 12 Dec 2018 20:42:56 +0100 > "Mikael P. Sundqvist" wrote: >> >> 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 > > You likely also need to install libffi - I do not know what package > this is on your flavor of linux - Luigi is the ffi specialist! FFI is integrated in LuaTeX >= 1.03 In you example you load libcerf but you are not using it. What you are actually using are the Bessel function from the C Standard library. GCC includes them as a GNU extension. https://www.gnu.org/software/libc/manual/html_node/Special-Functions.html#index-j0 Your example also works if you remove libcerf (at least for me on Linux). > > Alan > ___ > 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 > ___ > ___ 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 ___
[NTG-context] \xmlfunction
How can one transmit argument values to \xmlfunction in order to be used by the Lua function called? dr. Hans van der Meer ___ 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 ___
Re: [NTG-context] graphics
On 13/12/18 10:39 AM, Alan Braslau wrote: > On Thu, 13 Dec 2018 10:03:40 +1300 > Henri Menke wrote: > >> Sorry, my mistake, the Bessel functions are not a GCC extension but >> POSIX standard functions. >> http://pubs.opengroup.org/onlinepubs/9699919799/functions/j0.html >> Since TeX Live is always built on a POSIX platform (MSYS2 on Windows), >> you can expect j0 etc. to be available in LuaTeX. > > That is true for the Bessel functions, but not for some other "-lmath" > functions (such as the erf), so they may depend on the system. erf definitely does not depend on the system. That is part of the C Standard library. https://en.cppreference.com/w/c/numeric/math/erf But in general you are right. The zoo of special functions in the Standard library and POSIX is rather limited. Personally I prefer using the GNU Scientific library if I need special functions. https://www.gnu.org/software/gsl/doc/html/index.html Earlier this year I wrote a TUGboat article about using GSL with FFI in LuaTeX. https://tug.org/TUGboat/tb39-1/tb121menke-ffi.pdf I also plan on submitting an abstract about that topic for TUG2019 in Palo Alto. > > Alan > ___ 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 ___
[NTG-context] searching in nodes
In a Lua function called from within an \startxmlsetups..\stopxmlsetups code block I would like to search through the current node and all below. Using string.match("to-be-searched”,”pattern”). The Lua function being called through \def\findmypattern#1#2{\ctxlua{tex.print(hvdm.findmypattern("#1","#2",))} But I do not seem to get the node contents in the first argument #1. Using \xmlverbatim{#1} fails with Lua error "hexadecimal digit expected near '"\xm’”. \xmlflushpure{#1} fails with Lua error "invalid escape sequence near …” Any help? dr. Hans van der Meer ___ 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 ___