[pstricks] Re: Floating point calculations in LaTeX

Denis Girou Denis.Girou at idris.fr
Thu Feb 27 19:34:55 CET 2003


>>>>> "Chris.Sangwin" == Chris Sangwin <sangwinc at for.mat.bham.ac.uk> writes:

    Chris.Sangwin> I've been a loyal PSTricks user for a number of years, and find myself
    Chris.Sangwin> typesetting more and more complex figures.  As most of these are highly
    Chris.Sangwin> mathematical, many of these now involve macros which require floating
    Chris.Sangwin> point calculations.

    Chris.Sangwin> ...

    Chris.Sangwin> I've been using the fp package
    Chris.Sangwin> to perform these calculations within LaTeX, but this clashes with multido,

  Uwe Kern <u.kern at web.de> already answer on this point. In the past, I gave
myself a similar patch than the one he sent, that Manuel Luque put on one of
his pages (the text is in french)
http://members.aol.com/Mluque5130/index.htm#TeX et les Calculs
and the patch was for instance on:
http://members.aol.com/Mluque5130/courbes.tex

    Chris.Sangwin> and the syntax is a little hard to understand.

  The README file (CTAN:macros/latex/contrib/other/fp/readme.fp) must be read
with care. There are several ways to use the package, but the \FPeval macro
allow by itself to do nearly everything needed and is both very powerful and
very easy to use. It avoid to use the many basic macros and allow to do a
serie of computations in one call only.

  In my experience, `fp' is a very convenient and powerful package.
The main weakness I found is that it is slow (because TeX offer only basic
mechanisms), which is of course only sensible if you must make a lot of
thousands of computations, use recursion, etc.

  The "TeX et les Calculs" ("TeX and Computations") section in Manuel's page
give good hints and a lot of examples of the usage of `fp' with PSTricks.


    Chris.Sangwin> What other approaches have people taken to this problem?  

    Chris.Sangwin> Can this be done using postscript?  If so, how does one access these
    Chris.Sangwin> functions from within LaTeX - I know no PS at all.  Are there methods to
    Chris.Sangwin> access them from within PSTricks?

  As Franco Bagnoli <franco.bagnoli at unifi.it> told you, this is another way
of choice. For instance, you can look at the examples from Philippe Esperet,
which I think are rather easy to understand, in the Mathematics example page
( http://tug.org/applications/PSTricks/Mathematics ) and also a lot of other
examples (often complex) in the various works of Manuel Luque
( http://members.aol.com/Mluque5130 ).

  As already said, the main drawback of this method is that you cannot use
back the result of the computations in TeX (at the exception of the usage of
the VTeX compiler), as they will be computed and known only during PostScript
code interpretation, but very often this is not needed... Also, the
computations will be made for each print and visualization, which in complex
cases can be slow.


    Franco Bagnoli> Clearly it would much better to have floating points calculations,
    Franco Bagnoli> strings and vector addressability, etc. 

  There were macros published for strings addressability and also vectors
addressability (for this last case, as far as I know, the `arrayjob' package
from Zhuhan Jiang CTAN:macros/generic/arrayjob is from far the most powerful
available).

D.G.


More information about the PSTricks mailing list