From: Franco <fra...@ng...> - 2022-10-17 15:08:32
|
Dear Professor Merritt Many thanks for your excellent work and for the commitment in keeping Gnuplot up to date. This page https://www.sixsigmain.it/Blog_AEX.html contains videos of a Gnuplot application (*) perfectly operational both on 5.4.x and on all 5.5.x (released this year). I am sure that with this new feature, the code will be even more simplified. Franco (*) Given your personal background, the videos will be easy to understand. Da: Ethan A Merritt [mailto:me...@uw...] Inviato: sabato 15 ottobre 2022 19:06 A: Tatsuro MATSUOKA <tma...@ya...> Cc: beta <gnu...@li...> Oggetto: Re: Is there any explanation for function block? Function blocks are implemented in a new branch that I have not yet committed. The "local" property for variables was part of that branch but is useful already by itself, so I added it first. The idea of function blocks is similar to datablocks, except that the text in the block is executed as a function rather than used as data. See earlier discussion attached to Bug #2547 https://sourceforge.net/p/gnuplot/bugs/2547/ and Feature Request 521 https://sourceforge.net/p/gnuplot/feature-requests/521/ Here is a draft section of the documentation for the new branch. It still has a few rough edges, but I expect to merge it in the next week or so. The `function` command signals the definition of a here-document containing a named block of gnuplot code that can be called as a function. As with data blocks, the name of a function block must begin with a '$'. Up to nine named parameters may be specified as part of the definition. These names may be used inside the function block as local variables. See `local` and `scope`. Once the function block is defined, you can invoke it by name anywhere that a normal function could be used. Example: function $sinc(arg) << EOF if (arg == 0) { return 1.0 } return sin(arg) / arg EOF gnuplot> plot $sinc(x) with lines title "sinc(x) as a function block" It is not necessary to specify a list of named arguments to a function block at the time it is declared. Arguments to the function passed from the command line can be accessed inside the function block as ARGV[1] etc, as would be the case for a `call` command. See `ARGV`. This allows defining a function block that can operate on a variable number of arguments. The primary motivation for function block support is to allow definition of complicated functions directly in gnuplot. Execution is of course slower than if the same function were coded directly in C or Fortran, but this is acceptable for many purposes. If execution speed matters then the function can be implemented later as a plugin instead (see `plugins`). A non-trivial example of using function blocks to implement and plot a 15-term Lancosz approximation for the complex lngamma function is provided in the demo collection as ^ <a href="http://www.gnuplot.info/demo_5.5/function_block.html"> function_block.dem ^ </a> The function block implementation is slower by a factor of roughly 25 compared to the built-in lnGamma function using the same algorithm coded directly in C. Nevertheless it is still fast enough for 3D interactive rotation. On Fri, Oct 14, 2022 at 11:40 PM Tatsuro MATSUOKA via gnuplot-beta <gnu...@li... <mailto:gnu...@li...> > wrote: I found the option --enable-function-blocks is implemented to the development branch. Is there any explanation for the function block? Tatsuro _______________________________________________ gnuplot-beta mailing list gnu...@li... <mailto:gnu...@li...> Membership management via: https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/gnuplot-beta__;!!K-Hz7m0Vt54!i-6R1LQEUOPOg9GRf_E7o8MGHFaWf_cXfyDWcdAF0zC6EGVNvS-Yx-0U-vtqT0DdmY1ubirVqocHtClLZsrDvB2_cxG8J_Z9dvdW$ <https://urldefense.com/v3/__https:/lists.sourceforge.net/lists/listinfo/gnuplot-beta__;!!K-Hz7m0Vt54!i-6R1LQEUOPOg9GRf_E7o8MGHFaWf_cXfyDWcdAF0zC6EGVNvS-Yx-0U-vtqT0DdmY1ubirVqocHtClLZsrDvB2_cxG8J_Z9dvdW$> -- Ethan A Merritt Biomolecular Structure Center, K-428 Health Sciences Bldg MS 357742, University of Washington, Seattle 98195-7742 |