From 9978f54ca53386674587dd631a4d3de681a6a561 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sat, 13 Feb 2016 21:07:26 +0100 Subject: tex --- tex/.texmf/bibtex/bst/alphadin.bst | 2212 ++++ .../tex/context/third/pgfplots/t-pgfplots.tex | 80 + .../tex/context/third/pgfplots/t-pgfplotstable.tex | 41 + .../libs/pgflibrarypgfplots.surfshading.code.tex | 631 + .../generic/pgfplots/libs/pgfplotslibrary.code.tex | 94 + .../libs/tikzlibrarypgfplots.colormaps.code.tex | 99 + .../libs/tikzlibrarypgfplots.dateplot.code.tex | 234 + ...kzlibrarypgfplots.decorations.softclip.code.tex | 36 + .../libs/tikzlibrarypgfplots.external.code.tex | 102 + .../libs/tikzlibrarypgfplots.fillbetween.code.tex | 187 + .../libs/tikzlibrarypgfplots.groupplots.code.tex | 494 + .../libs/tikzlibrarypgfplots.patchplots.code.tex | 2722 +++++ .../libs/tikzlibrarypgfplots.polar.code.tex | 676 ++ .../libs/tikzlibrarypgfplots.smithchart.code.tex | 1678 +++ .../libs/tikzlibrarypgfplots.statistics.code.tex | 1221 ++ .../libs/tikzlibrarypgfplots.ternary.code.tex | 928 ++ .../libs/tikzlibrarypgfplots.units.code.tex | 224 + .../pgfplots/liststructure/pgfplotsarray.code.tex | 669 ++ .../pgfplots/liststructure/pgfplotsdeque.code.tex | 125 + .../liststructure/pgfplotsliststructure.code.tex | 435 + .../pgfplotsliststructureext.code.tex | 615 + .../pgfplots/liststructure/pgfplotsmatrix.code.tex | 544 + tex/.texmf/tex/generic/pgfplots/lua/pgfplots.lua | 45 + .../tex/generic/pgfplots/lua/pgfplots/binary.lua | 41 + .../tex/generic/pgfplots/lua/pgfplots/colormap.lua | 98 + .../pgfplots/lua/pgfplots/meshplothandler.lua | 294 + .../pgfplots/lua/pgfplots/pgfplotstexio.lua | 464 + .../generic/pgfplots/lua/pgfplots/pgfplotsutil.lua | 139 + .../generic/pgfplots/lua/pgfplots/plothandler.lua | 962 ++ .../generic/pgfplots/lua/pgfplots/statistics.lua | 400 + .../tex/generic/pgfplots/lua/pgfplots/streamer.lua | 193 + .../lua/pgfplotsoldpgfsupp/luamath/functions.lua | 649 ++ .../lua/pgfplotsoldpgfsupp/luamath/parser.lua | 495 + .../pgfplots/numtable/pgfplotstable.code.tex | 2998 +++++ .../numtable/pgfplotstable.coltype.code.tex | 93 + .../pgfplots/numtable/pgfplotstableshared.code.tex | 2003 ++++ .../pgfplotsoldpgfsupp_loader.code.tex | 146 + .../pgfplotsoldpgfsupp_misc.code.tex | 885 ++ .../pgfplotsoldpgfsupp_pgfcoreexternal.code.tex | 562 + .../pgfplotsoldpgfsupp_pgfcoreimage.code.tex | 585 + .../pgfplotsoldpgfsupp_pgfcorelayers.code.tex | 217 + .../pgfplotsoldpgfsupp_pgfcorescopes.code.tex | 607 + .../pgfplotsoldpgfsupp_pgfkeys.code.tex | 1067 ++ .../pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex | 1041 ++ .../pgfplotsoldpgfsupp_pgflibraryfpu.code.tex | 2211 ++++ ...lotsoldpgfsupp_pgflibraryintersections.code.tex | 1018 ++ .../pgfplotsoldpgfsupp_pgflibraryluamath.code.tex | 540 + ...plotsoldpgfsupp_pgflibraryplothandlers.code.tex | 1141 ++ .../pgfplotsoldpgfsupp_pgfmanual.code.tex | 90 + .../pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex | 450 + ...lotsoldpgfsupp_pgfmanual.prettyprinter.code.tex | 1120 ++ .../pgfplotsoldpgfsupp_pgfmathfloat.code.tex | 2665 +++++ .../pgfplotsoldpgfsupp_pgfutil-common-lists.tex | 184 + .../pgfplotsoldpgfsupp_tikzexternal.sty | 164 + .../pgfplotsoldpgfsupp_tikzexternalshared.code.tex | 1708 +++ ...pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex | 93 + .../pgfplotsoldpgfsupp_trig_format.code.tex | 380 + .../tikzlibrarydateplot.code.tex | 24 + .../pgfcontrib/pgflibraryfillbetween.code.tex | 1157 ++ .../tikzlibrarydecorations.softclip.code.tex | 517 + .../pgfcontrib/tikzlibraryfillbetween.code.tex | 577 + tex/.texmf/tex/generic/pgfplots/pgfplots.code.tex | 11520 +++++++++++++++++++ .../generic/pgfplots/pgfplots.errorbars.code.tex | 599 + .../tex/generic/pgfplots/pgfplots.markers.code.tex | 368 + .../tex/generic/pgfplots/pgfplots.paths.code.tex | 71 + .../tex/generic/pgfplots/pgfplots.revision.tex | 15 + .../tex/generic/pgfplots/pgfplots.scaling.code.tex | 3396 ++++++ .../pgfplots/pgfplotscoordprocessing.code.tex | 9152 +++++++++++++++ .../tex/generic/pgfplots/pgfplotscore.code.tex | 379 + .../pgfplots/pgfplotsmeshplothandler.code.tex | 2966 +++++ .../generic/pgfplots/pgfplotsplothandlers.code.tex | 2922 +++++ .../generic/pgfplots/pgfplotsstackedplots.code.tex | 584 + .../tex/generic/pgfplots/pgfplotsticks.code.tex | 2305 ++++ ...librarypgfplots.surfshading.pgfsys-dvipdfmx.def | 179 + ...pgflibrarypgfplots.surfshading.pgfsys-dvips.def | 114 + ...gflibrarypgfplots.surfshading.pgfsys-pdftex.def | 161 + ...pgflibrarypgfplots.surfshading.pgfsys-xetex.def | 30 + .../pgfplots/sys/pgfplotssysgeneric.code.tex | 84 + .../generic/pgfplots/test/pgfplots.assert.code.tex | 50 + .../tex/generic/pgfplots/test/pgfplots.assert.sty | 2 + .../generic/pgfplots/util/pgfplotsbinary.code.tex | 603 + .../pgfplots/util/pgfplotsbinary.data.code.tex | 291 + .../generic/pgfplots/util/pgfplotscolor.code.tex | 630 + .../pgfplots/util/pgfplotscolormap.code.tex | 801 ++ .../generic/pgfplots/util/pgfplotsutil.code.tex | 2115 ++++ .../pgfplots/util/pgfplotsutil.verb.code.tex | 97 + tex/.texmf/tex/generic/ydoc/ydocincl.tex | 106 + tex/.texmf/tex/generic/ydoc/ydocstrip.tex | 83 + tex/.texmf/tex/latex/misc/3dplot.sty | 665 ++ tex/.texmf/tex/latex/misc/algorithmicx/README | 4 + tex/.texmf/tex/latex/misc/algorithmicx/algc.sty | 49 + .../tex/latex/misc/algorithmicx/algcompatible.sty | 89 + .../tex/latex/misc/algorithmicx/algmatlab.sty | 68 + .../tex/latex/misc/algorithmicx/algorithm.sty | 100 + .../tex/latex/misc/algorithmicx/algorithmicx.sty | 786 ++ .../tex/latex/misc/algorithmicx/algorithmicx.tex | 1768 +++ .../tex/latex/misc/algorithmicx/algpascal.sty | 44 + .../tex/latex/misc/algorithmicx/algpseudocode.sty | 92 + tex/.texmf/tex/latex/misc/ellipsis.sty | 88 + tex/.texmf/tex/latex/misc/eulervm.sty | 267 + tex/.texmf/tex/latex/misc/fontaxes.sty | 383 + tex/.texmf/tex/latex/misc/framed.sty | 548 + tex/.texmf/tex/latex/misc/invoice/invoice.def | 501 + tex/.texmf/tex/latex/misc/invoice/invoice.sty | 1042 ++ tex/.texmf/tex/latex/misc/invoice/realcalc.tex | 581 + tex/.texmf/tex/latex/misc/marginnote.sty | 412 + tex/.texmf/tex/latex/misc/multirow/bigdelim.sty | 68 + tex/.texmf/tex/latex/misc/multirow/bigstrut.sty | 41 + tex/.texmf/tex/latex/misc/multirow/multirow.sty | 159 + tex/.texmf/tex/latex/misc/mweights.sty | 87 + tex/.texmf/tex/latex/misc/preview/prauctex.cfg | 48 + tex/.texmf/tex/latex/misc/preview/prauctex.def | 61 + tex/.texmf/tex/latex/misc/preview/prcounters.def | 38 + tex/.texmf/tex/latex/misc/preview/preview.drv | 34 + tex/.texmf/tex/latex/misc/preview/preview.sty | 391 + tex/.texmf/tex/latex/misc/preview/prfootnotes.def | 28 + tex/.texmf/tex/latex/misc/preview/prlyx.def | 32 + tex/.texmf/tex/latex/misc/preview/prshowbox.def | 32 + tex/.texmf/tex/latex/misc/preview/prshowlabels.def | 67 + tex/.texmf/tex/latex/misc/preview/prtightpage.def | 146 + tex/.texmf/tex/latex/misc/preview/prtracingall.def | 30 + .../tex/latex/misc/standalone/standalone.cls | 954 ++ .../tex/latex/misc/standalone/standalone.sty | 1125 ++ tex/.texmf/tex/latex/misc/subfigure.sty | 419 + tex/.texmf/tex/latex/misc/tfbrief/mparhack.sty | 287 + tex/.texmf/tex/latex/misc/tfbrief/textcase.sty | 61 + .../tex/latex/misc/tfbrief/tfbrief-invoice.cls | 362 + tex/.texmf/tex/latex/misc/tfbrief/tfbrief.cls | 382 + tex/.texmf/tex/latex/misc/tfbrief/vmargin.sty | 576 + .../latex/misc/tikz-dependency/tikz-dependency.sty | 303 + tex/.texmf/tex/latex/misc/tikz-qtree/README | 49 + tex/.texmf/tex/latex/misc/tikz-qtree/pgfsubpic.sty | 4 + tex/.texmf/tex/latex/misc/tikz-qtree/pgfsubpic.tex | 209 + tex/.texmf/tex/latex/misc/tikz-qtree/pgftree.sty | 6 + tex/.texmf/tex/latex/misc/tikz-qtree/pgftree.tex | 215 + .../latex/misc/tikz-qtree/tikz-qtree-compat.sty | 72 + .../tex/latex/misc/tikz-qtree/tikz-qtree.sty | 4 + .../tex/latex/misc/tikz-qtree/tikz-qtree.tex | 204 + tex/.texmf/tex/latex/misc/totpages.sty | 241 + tex/.texmf/tex/latex/misc/type1cm.sty | 272 + tex/.texmf/tex/latex/misc/wrapfig.sty | 598 + tex/.texmf/tex/latex/pgfplots/bugtracker.sty | 429 + .../libs/tikzlibrarypgfplots.clickable.code.tex | 1393 +++ .../libs/tikzlibrarypgfplotsclickable.code.tex | 24 + tex/.texmf/tex/latex/pgfplots/pgfplots.sty | 121 + tex/.texmf/tex/latex/pgfplots/pgfplotstable.sty | 39 + .../tex/latex/pgfplots/pgfregressiontest.sty | 159 + tex/.texmf/tex/latex/ydoc/ydoc-code.sty | 219 + tex/.texmf/tex/latex/ydoc/ydoc-desc.sty | 620 + tex/.texmf/tex/latex/ydoc/ydoc-doc.sty | 250 + tex/.texmf/tex/latex/ydoc/ydoc-expl.sty | 99 + tex/.texmf/tex/latex/ydoc/ydoc.cfg | 40 + tex/.texmf/tex/latex/ydoc/ydoc.cls | 21 + tex/.texmf/tex/latex/ydoc/ydoc.sty | 27 + tex/.texmf/tex/plain/pgfplots/pgfplots.tex | 50 + tex/.texmf/tex/plain/pgfplots/pgfplotstable.tex | 38 + 156 files changed, 100314 insertions(+) create mode 100644 tex/.texmf/bibtex/bst/alphadin.bst create mode 100644 tex/.texmf/tex/context/third/pgfplots/t-pgfplots.tex create mode 100644 tex/.texmf/tex/context/third/pgfplots/t-pgfplotstable.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.decorations.softclip.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.statistics.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.units.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsdeque.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsmatrix.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots/binary.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots/colormap.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots/meshplothandler.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots/pgfplotsutil.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots/plothandler.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots/statistics.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplots/streamer.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/functions.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/parser.lua create mode 100644 tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstable.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstable.coltype.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreimage.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcorelayers.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcorescopes.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryluamath.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfutil-common-lists.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_trig_format.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/oldpgfplotscompatib/tikzlibrarydateplot.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfcontrib/pgflibraryfillbetween.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfcontrib/tikzlibrarydecorations.softclip.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplots.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplots.errorbars.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplots.markers.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplots.paths.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplots.revision.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplots.scaling.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplotscore.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplotsplothandlers.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplotsstackedplots.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/pgfplotsticks.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvipdfmx.def create mode 100644 tex/.texmf/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvips.def create mode 100644 tex/.texmf/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def create mode 100644 tex/.texmf/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-xetex.def create mode 100644 tex/.texmf/tex/generic/pgfplots/sys/pgfplotssysgeneric.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/test/pgfplots.assert.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/test/pgfplots.assert.sty create mode 100644 tex/.texmf/tex/generic/pgfplots/util/pgfplotsbinary.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/util/pgfplotsbinary.data.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/util/pgfplotscolor.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/util/pgfplotscolormap.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/util/pgfplotsutil.code.tex create mode 100644 tex/.texmf/tex/generic/pgfplots/util/pgfplotsutil.verb.code.tex create mode 100644 tex/.texmf/tex/generic/ydoc/ydocincl.tex create mode 100644 tex/.texmf/tex/generic/ydoc/ydocstrip.tex create mode 100644 tex/.texmf/tex/latex/misc/3dplot.sty create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/README create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/algc.sty create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/algcompatible.sty create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/algmatlab.sty create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/algorithm.sty create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/algorithmicx.sty create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/algorithmicx.tex create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/algpascal.sty create mode 100644 tex/.texmf/tex/latex/misc/algorithmicx/algpseudocode.sty create mode 100644 tex/.texmf/tex/latex/misc/ellipsis.sty create mode 100644 tex/.texmf/tex/latex/misc/eulervm.sty create mode 100644 tex/.texmf/tex/latex/misc/fontaxes.sty create mode 100644 tex/.texmf/tex/latex/misc/framed.sty create mode 100644 tex/.texmf/tex/latex/misc/invoice/invoice.def create mode 100644 tex/.texmf/tex/latex/misc/invoice/invoice.sty create mode 100644 tex/.texmf/tex/latex/misc/invoice/realcalc.tex create mode 100644 tex/.texmf/tex/latex/misc/marginnote.sty create mode 100644 tex/.texmf/tex/latex/misc/multirow/bigdelim.sty create mode 100644 tex/.texmf/tex/latex/misc/multirow/bigstrut.sty create mode 100644 tex/.texmf/tex/latex/misc/multirow/multirow.sty create mode 100644 tex/.texmf/tex/latex/misc/mweights.sty create mode 100644 tex/.texmf/tex/latex/misc/preview/prauctex.cfg create mode 100644 tex/.texmf/tex/latex/misc/preview/prauctex.def create mode 100644 tex/.texmf/tex/latex/misc/preview/prcounters.def create mode 100644 tex/.texmf/tex/latex/misc/preview/preview.drv create mode 100644 tex/.texmf/tex/latex/misc/preview/preview.sty create mode 100644 tex/.texmf/tex/latex/misc/preview/prfootnotes.def create mode 100644 tex/.texmf/tex/latex/misc/preview/prlyx.def create mode 100644 tex/.texmf/tex/latex/misc/preview/prshowbox.def create mode 100644 tex/.texmf/tex/latex/misc/preview/prshowlabels.def create mode 100644 tex/.texmf/tex/latex/misc/preview/prtightpage.def create mode 100644 tex/.texmf/tex/latex/misc/preview/prtracingall.def create mode 100644 tex/.texmf/tex/latex/misc/standalone/standalone.cls create mode 100644 tex/.texmf/tex/latex/misc/standalone/standalone.sty create mode 100644 tex/.texmf/tex/latex/misc/subfigure.sty create mode 100644 tex/.texmf/tex/latex/misc/tfbrief/mparhack.sty create mode 100644 tex/.texmf/tex/latex/misc/tfbrief/textcase.sty create mode 100644 tex/.texmf/tex/latex/misc/tfbrief/tfbrief-invoice.cls create mode 100644 tex/.texmf/tex/latex/misc/tfbrief/tfbrief.cls create mode 100644 tex/.texmf/tex/latex/misc/tfbrief/vmargin.sty create mode 100644 tex/.texmf/tex/latex/misc/tikz-dependency/tikz-dependency.sty create mode 100644 tex/.texmf/tex/latex/misc/tikz-qtree/README create mode 100644 tex/.texmf/tex/latex/misc/tikz-qtree/pgfsubpic.sty create mode 100644 tex/.texmf/tex/latex/misc/tikz-qtree/pgfsubpic.tex create mode 100644 tex/.texmf/tex/latex/misc/tikz-qtree/pgftree.sty create mode 100644 tex/.texmf/tex/latex/misc/tikz-qtree/pgftree.tex create mode 100644 tex/.texmf/tex/latex/misc/tikz-qtree/tikz-qtree-compat.sty create mode 100644 tex/.texmf/tex/latex/misc/tikz-qtree/tikz-qtree.sty create mode 100644 tex/.texmf/tex/latex/misc/tikz-qtree/tikz-qtree.tex create mode 100644 tex/.texmf/tex/latex/misc/totpages.sty create mode 100644 tex/.texmf/tex/latex/misc/type1cm.sty create mode 100644 tex/.texmf/tex/latex/misc/wrapfig.sty create mode 100644 tex/.texmf/tex/latex/pgfplots/bugtracker.sty create mode 100644 tex/.texmf/tex/latex/pgfplots/libs/tikzlibrarypgfplots.clickable.code.tex create mode 100644 tex/.texmf/tex/latex/pgfplots/libs/tikzlibrarypgfplotsclickable.code.tex create mode 100644 tex/.texmf/tex/latex/pgfplots/pgfplots.sty create mode 100644 tex/.texmf/tex/latex/pgfplots/pgfplotstable.sty create mode 100644 tex/.texmf/tex/latex/pgfplots/pgfregressiontest.sty create mode 100644 tex/.texmf/tex/latex/ydoc/ydoc-code.sty create mode 100644 tex/.texmf/tex/latex/ydoc/ydoc-desc.sty create mode 100644 tex/.texmf/tex/latex/ydoc/ydoc-doc.sty create mode 100644 tex/.texmf/tex/latex/ydoc/ydoc-expl.sty create mode 100644 tex/.texmf/tex/latex/ydoc/ydoc.cfg create mode 100644 tex/.texmf/tex/latex/ydoc/ydoc.cls create mode 100644 tex/.texmf/tex/latex/ydoc/ydoc.sty create mode 100644 tex/.texmf/tex/plain/pgfplots/pgfplots.tex create mode 100644 tex/.texmf/tex/plain/pgfplots/pgfplotstable.tex (limited to 'tex') diff --git a/tex/.texmf/bibtex/bst/alphadin.bst b/tex/.texmf/bibtex/bst/alphadin.bst new file mode 100644 index 0000000..0698026 --- /dev/null +++ b/tex/.texmf/bibtex/bst/alphadin.bst @@ -0,0 +1,2212 @@ +%% ALPHADIN.BST Ausgabe [8.2] 2006-01-02 +%% +%% ersetzt ABBRVDIN.BST Ausgabe [8.1b4] 15/12/2004 +%% wichtigste Aenderung gegenueber Version [8.1b4]: +%% die Standardergaenzung "Online-Ressource" bei Internetquellen +%% ist ersatzlos gestrichen worden (wegen ueberfluessiger Redundanz). +%% +% +%% K.F.Lorenzen (Copyright 1994-2006) email: lorenzen.marxen@t-online.de +%% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +%% ALPHADIN.BST wurde entwickelt aus Oren Patashnik's BibTeX standard +%% bibliography style `alpha'. Eine vorgegebene Literaturdatenbank laesst sich +%% somit beliebig nach Us- oder deutscher DIN 1505-Zitierkonvention +%% verarbeiten. +%% Analog zu den 4 US standard styles werden 4 DIN-gerechte bst-style Dateien +%% veroeffentlicht (alphadin.bst, plaindin.bst, unsrtdin.bst, abbrvdin.bst). +%% Die gueltige Version ist am schnellsten aus dem WWW ueber folgende URL zu +%% beziehen: +%% http://www.haw-hamburg.de/pers/Lorenzen/bibtex/ +%% Stand: 2006-01-02 +%% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +%% WAS IST ALPHADIN.BST ? +%% Dieser style produziert "deutsche" Literaturzitate in Literaturverzeichnis- +%% sen gemaess der deutschen Norm DIN 1505, Teil 2 vom Jan. 1984. +%% Die Literaturzitate werden alphabetisch nach Verfassern sortiert. +%% Die Zitiermarken im Text und die Ordnungsmarken im Literaturverzeichnis +%% bestehen aus abgekuerzten Verfasserbuchstaben plus Erscheinungsjahr in +%% eckigen Klammern. Die vorliegenden DIN-styles gehen ueber einige bibliogra- +%% phischen Beschraenkungen der Originalstyles hinaus. +% +%% Es werden nun auch Elektronische Online / Offline Ressourcen wie Internet- +%% quellen, CD-ROM usw. verarbeitet. Dazu kommen besondere Publikationsformen +%% wie Patente, Normen, Karten, Fernsehaufzeichnungen, Gesetzesstellen, Spiele. +% +%% Zur Gewaehrleistung der Allgemeingueltigkeit von bib-files gelten in den +%% DIN-styles die in der Tex-Literatur veroeffentlichten originalen +%% Definitionen und Regeln fuer die Publikationstypen (entry-types) und die +%% bibliographischen Felder (fields). +%% Treten kleinere "Schoenheitsfehler" im fertig gesetzten output auf, +%% lassen sich diese so gut wie immer durch eine veraenderte +%% Erfassung im bib-inputfile beseitigen. Oren Patashnik empfiehlt, die +%% Definition der Felder weit auszulegen. Last but not least koennen +%% Sie im output-file < *.bbl > noch letzte Hand zur Korrektur ansetzen. +% +%% WARN- UND FEHLERMELDUNGEN +%% Ursache von Warnmeldungen sind meistens ausgelassene Felder oder +%% Erfassungs-"Fehler". Letztere haengen teilweise mit den gegenueber US- +%% Gepflogenheiten andersartigen bibliographischen Regeln nach DIN 1505 +%% zusammen. Sie sind also in Wahrheit keine "Fehler" und duerfen fast immer +%% ignoriert werden. Dennoch pruefen Sie diese Warnungen, um herauszufinden, +%% ob Publikationstyp (=entry-type) und "fields" eventuell unzulaessig +%% kombiniert worden sind. +%% Echte Fehler ("errors") treten nur noch in Verbindung mit falscher +%% Erfassung auf (nach meinen Tests!). Pruefen Sie die Syntax, den entry-type +%% und die fields. +%% Zu guter letzt: Qualitaetsmasstab ist einzig der DIN-konforme output! +%% +%% DANKSAGUNG +%% Hartmut Lueddecke, HAW Hamburg, hat viele Verbesserungsvorschlaege +%% in die frueheren Versionen eingebracht. Ihm danke ich herzlich. +%% Patrick W. Daly, dem Entwickler des Natbib-Stils, verdanke ich viele +%% Anregungen und den steten Ansporn, die DIN-Stile zu verbessern. +%% Viele an dieser Stelle ungenannt bleibende Anwender haben mich in +%% den vergangenen Jahren auf Fehler oder Verbesserungsmoeglichkeiten +%% aufmerksam gemacht und so diesen Stil mitentwickelt. Ihnen gilt mein +%% besonderer Dank. Ihr Feedback ist immer willkommen und eine Ermunterung. +%% +%% Klaus F. Lorenzen +%% +%% +%% +%% HINWEIS: Neben den vier bibliographischen DIN 1505 Standard-Stilen +%% nach den Original-styles von Oren Patashnik +%% gibt es noch vier DIN 1505 Adaptionen der NATBIB-style +%% Emulationen von Patrick W.Daly. Die Fuelle der darin +%% implementierten Zitierweisen geht weit ueber die urspruenglichen +%% Standardstyles hinaus. +%% Naeheres unter URL http://www.haw-hamburg.de/pers/Lorenzen/bibtex/ +%% +%%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +%% version 0.99c for BibTeX versions 0.99c or later, LaTeX2e version +%% Copyright (C) 1985, all rights reserved. +%% Copying of this file is authorized only if either +%% (1) you make absolutely no changes to your copy, including name, or +%% (2) if you do make changes, you name it something other than +%% alphadin.bst +%% This restriction helps ensure that all standard styles are identical. +%% +%% +%% +%%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +%% NEUE FELDER +%% Zur Erfassung der neuen digitalen Online-Medien z.B. Internetquellen, E-journals, E-books, +%% E-mail u.a. gibt es die zusaetzlichen Felder: doi, url, urn, lastchecked +%% Internetquellen werden vorzugsweise mit dem BOOKLET-Typ erfasst. +%% Normen, Patente, Schutzrechte sind mit dem MISC-Typ zu erfassen. + +ENTRY + { address %% Verlagsort (immer!) + author %% persoenlicher Urheber eines Werkes oder am Zustandekommen + %% beteiligte Personen(=Mitarbeiter, Uebersetzer, Redakteur u.a.) + booktitle %% a) Gesamttitel eines mehrbaendigen Werkes +% %% b) Titel des Sammelwerks, das einzelne selbstaendige +% %% Beitraege mit eigenem Titel enthaelt ->incollection + chapter %% Kapitel in einem Buch (Monographie) + doi %%% Digital Object Identifier ->article + edition %% a) Auflagevermerk +% %% b) bei selbst. elektron. Quellen == Version ->booklet + editor %% Persoenl.Herausgeber oder Koerperschaftlicher Herausgeber + howpublished %% beliebiger Verlegervermerk: veroeffentlicht "von wem, wo" + institution %% Institution, die e.verlagsfreie Veroeffentlichung betreibt + isbn %% Standardnr fuer Buecher + issn %% - " - : Zeitschriften u. Serien + journal %% Titel einer Zeitschrift + key %% Zusaetzlich vergebener Sortierschluessel, mitunter notwend. + lastchecked %% neues Feld fuer das Datum des Online-Abrufs +% %% einer Internetquelle (n. GRAY ) + month %% naehere Bestimmung des Erscheinungsjahres -> macro 's + note %% freies Eingabefeld fuer zusaetzliche Informationen z. Quelle + number %% Versch. Bedeutungen in Abhaengigkeit vom Eingabetyp: +% %% a) Bandnummer einer gezaehlten Reihe (series) +% %% b) Heftnummer einer Zeitschrift ->article +% %% c) Nummer eines Forschungsberichts ->techreport + organization %% a) Name der Organisation/des Organisators e. Tagung,Konferenz +% %% b) Name einer Firma/Gesellschaft, die ein ->manual herausgab + pages %% Umfangsangaben, meist Seitenzahlen + publisher %% Verlag + school %% Hochschule/Universitaet, die eine Dipl.-Arb./Dissertation veroeff. + series %% Titel e.Reihe, in der ein best. Buchtitel erschienen ist + title %% Titel einer (namentlich gekennzeichneten) Veroeffentlichung + type %% Zusatzfeld z.Kennzeichnung e.besonderen Publikationstyps + url %% neues Feld URL ( Uniform Resource Locator ): +% %% Serveradresse einer Internetquelle + urn %% neues Feld URN ( Uniform Resource Name ): +% %% Persistent Identifier einer Internetquelle + volume %% a) Zaehlung bei einem mehrbaendigen Werk ->book/->proceedings +% %% b) Jahrgang einer Zeitschrift ->article + year %% Erscheinungsjahr + } + {} + { label extra.label sort.label short.list } + +%%%---------------------------------------------------------------------------- +% Einige Standardvorgaben, die vom Benutzer veraendert werden koennen. +%%%---------------------------------------------------------------------------- + +% Abkuerzung ("... und andere") bei Mehrverfasserquellen: + +FUNCTION { ua.etal } { " u.\,a." } %% evtl. auch in eckigen Klammern " [u.\,a.]" + +%% oder lateinisch: FUNCTION { ua.etal } { " et~al." } + +FUNCTION { und } { " u. " } + +%% oder ausgeschrieben: FUNCTION { und } { " und " } +% +% Einige elektronische Medien erhalten nach DIN 1505 eine "Ergaenzende Angabe" +% zusaetzlich zum materiellen Typ, z.B. CD ROM oder DVD u.a.: + +FUNCTION { eress } { "Elektronische Ressource" } + +%%%----------------------------------------------------------------------------------- + +INTEGERS { output.state before.all mid.sentence after.sentence after.block } + +INTEGERS { colon.after period.dash } + +INTEGERS { after.firstblock } + +INTEGERS { zahl lang } + +INTEGERS { nameptr namesleft numnames } + +INTEGERS { ptr collation collrest } + +INTEGERS { len } + +INTEGERS { et.al.char.used } + +INTEGERS { longest.label.width last.extra.num } +%------------------------- +STRINGS { longest.label last.sort.label next.extra } + +STRINGS { h s t u v w } + +STRINGS { fkt } +%------------------------- + +FUNCTION {init.state.consts} +{ #0 'before.all := + #1 'mid.sentence := + #2 'after.sentence := + #3 'after.block := + #4 'colon.after := + #5 'period.dash := + #6 'after.firstblock := +} + +FUNCTION {output.nonnull} +{ 's := + output.state after.block = + { add.period$ write$ + newline$ + "\newblock " write$ + } + { output.state before.all = + { write$ } + { output.state colon.after = + { ": " * write$ + newline$ + "\newblock " write$ + } + { output.state period.dash = + { ". -- " * write$ + newline$ + "\newblock " write$ + } + { output.state mid.sentence = + { ", " * write$ } + { output.state after.sentence = + { " " * write$ } + { output.state after.firstblock = + { add.period$ write$ + newline$ + "\newblock " write$ + } + { write$ + newline$ + "\newblock " write$ + } + if$ + } + if$ + } + if$ + } + if$ + } + if$ + } + if$ + after.block 'output.state := + } + if$ + s + } + +FUNCTION {output} +{ duplicate$ empty$ + 'pop$ + 'output.nonnull + if$ +} + +FUNCTION {output.check} +{ 't := + duplicate$ empty$ + { pop$ "empty " t * " in " * cite$ * warning$ } + 'output.nonnull + if$ +} + +FUNCTION {new.block} +{ output.state before.all = + 'skip$ + { after.block 'output.state := } + if$ +} + +FUNCTION {not} +{ { #0 } + { #1 } + if$ +} + +FUNCTION {and} +{ 'skip$ + { pop$ #0 } + if$ +} + +FUNCTION {or} +{ { pop$ #1 } + 'skip$ + if$ +} + + +FUNCTION {output.bibitem} +{ newline$ + "\bibitem[" write$ + label write$% + "]{" write$ + cite$ write$ + "}" write$ + newline$ + "" + before.all 'output.state := +} + +FUNCTION {fin.entry} +{ write$ + newline$ +} + +FUNCTION {set.period.dash} %% Wenn ein ". - " die Satzteile trennen soll.! +{ output.state before.all = + 'skip$ + { period.dash 'output.state := } + if$ +} + +FUNCTION {set.period.dash.check} +{ empty$ + 'skip$ + 'set.period.dash + if$ +} + +FUNCTION {set.colon.after} %%$$$ Wenn ein ": " d. Satzteile trennen soll! +{ output.state before.all = + 'skip$ + { colon.after 'output.state := } + if$ +} + +%% Wenn ein " " die Satzteile trennen soll.! +FUNCTION {new.sentence} +{ output.state before.all = + 'skip$ + { after.sentence 'output.state := } + if$ +} + +%% Wenn ein ", " die Satzteile trennen soll.! +FUNCTION { part.of.sentence } +{ output.state before.all = + 'skip$ + { mid.sentence 'output.state := } + if$ +} + +FUNCTION {new.sentence.checka} +{ empty$ + 'skip$ + 'new.sentence + if$ +} + +FUNCTION {field.or.null} +{ duplicate$ empty$ + { pop$ "" } + 'skip$ + if$ +} + +FUNCTION {emphasize} +{ duplicate$ empty$ + { pop$ "" } + { "\emph{" swap$ * "}" * } + if$ +} + +FUNCTION { capitalize } + { duplicate$ empty$ + { pop$ "" } + { "\textsc{" swap$ * "}" * } + if$ +} + + +%% Adelspraedikate beim Sortieren nach den(m) Vornamen auffuehren +%% Abweichend v. DIN !!! +FUNCTION {format.names} +{ 's := + "" 'u := + #1 'nameptr := + s num.names$ 'numnames := + numnames 'namesleft := + { namesleft #0 > } + { + s nameptr "{ll}" format.name$ 't := + t capitalize 't := + s nameptr "{ jj}" format.name$ 'w := + s nameptr "{, ff}{ vv}{ jj}" format.name$ 'u := + u text.length$ 'lang := + #1 'zahl := + "" 'v := + { zahl lang < } + { u zahl #1 substring$ "~" = + { v "" = + { u #1 zahl #1 - substring$ 'v := } + 'skip$ + if$ + v u zahl #2 substring$ * "." * w * 'v := + } + 'skip$ + if$ + zahl #1 + 'zahl := } + while$ + v "" = + { u 'v := } + 'skip$ + if$ + t v * fkt * 't := + nameptr #1 > + { namesleft #1 > + { " ; " * t * } + { numnames #2 > + { " " * } + 'skip$ + if$ + t "\textsc{others}" = t "\textsc{others} (Hrsg.)" = or + { ua.etal * } + { " ; " * t * } + if$ + } + if$ %% Ende der namesleft-Pruefung + } + 't + if$ %% Ende der nameptr-Pruefung + + nameptr #1 + 'nameptr := + namesleft #1 - 'namesleft := + } + while$ %% Ende von { namesleft #0 > } ganz oben + "" 'fkt := %% fkt wird zurueckgesetzt +} + +FUNCTION {format.authors} +{ author empty$ + { "" } + { author format.names } + if$ +} + +FUNCTION {format.editors} +{ editor empty$ + { author empty$ + { "empty author and editor in " cite$ * warning$ "" } + 'skip$ + if$ + } + { author empty$ + { " (Hrsg.)" 'fkt := + editor format.names + } + { " (Hrsg.)" 'fkt := + " ; " * editor format.names * + } + if$ + } + if$ + } + +%% 2005-11-11 +FUNCTION { format.authors.organization } +{ type$ "misc" = + { organization empty$ + { author empty$ + { "" } + { author format.names " (Erfinder)" * } + if$ + } + { author empty$ + { organization } + { author format.names " (Erfinder); " * + organization * " (Anmelder)" * + } + if$ + } + if$ + } + { type$ "manual" = + { organization empty$ + { author empty$ + { "" } + { author format.names } + if$ + } + { author empty$ + { organization capitalize " (Hrsg.)" * } + { author format.names " ; " * + organization capitalize * " (Hrsg.)" * + } + if$ + } + if$ + } + 'skip$ + if$ + } + if$ +} + + +FUNCTION { format.editors.organization } +{ organization empty$ + 'skip$ + { type$ "misc" = + { organization } + { * " ; " * organization " (Veranst.)" *} + if$ + } + if$ +} + +FUNCTION { format.tr.institution } +{ institution empty$ + 'skip$ + { institution capitalize } + if$ +} + +FUNCTION {format.ed.incoll} +{ editor empty$ + { "" } + { " (Hrsg.)" 'fkt := + editor format.names + format.editors.organization + } + if$ +} + +FUNCTION {article.in.journal} +{ duplicate$ empty$ + { pop$ "" } + { author missing$ title missing$ and + { emphasize } + { emphasize "{In: }" swap$ * } + if$ + } + if$ +} + +FUNCTION {format.title} +{ title empty$ + { "" } + { title } %% Text so wie er dasteht im Feld title + if$ +} + +FUNCTION {format.number} +{ number empty$ + { "" } + { number " " * } %% Text so wie er im Feld number steht plus " " + if$ +} + + +FUNCTION {format.digital.type} +{ type empty$ + { "" } + { type #-1 #4 substring$ "mail" = + type #1 #4 substring$ "Mail" = + OR + { "" } + { type } %% Typ einer digitalen Ressource in Form einer + %% "Ergaenzenden Angabe", so wie er dasteht; + %% Alternativ kann dieser Text auch in NOTE erfasst werden. + if$ + } + if$ +} + +FUNCTION {n.dashify} +{ 't := + "" + { t empty$ not } + { t #1 #1 substring$ "-" = + { t #1 #2 substring$ "--" = not + { "--" * + t #2 global.max$ substring$ 't := + } + { { t #1 #1 substring$ "-" = } + { "-" * + t #2 global.max$ substring$ 't := + } + while$ + } + if$ + } + { t #1 #1 substring$ * + t #2 global.max$ substring$ 't := + } + if$ + } + while$ +} + +%% Auflagenvermerke gibt man komplett, einschliesslich Abkuerzungen in +%% das Feld edition ein: ---> EDITION= { 3., erw. und verb. Aufl. } +%% oder fremdsprachlich: EDITION= { 2nd edition } + +FUNCTION {format.edition} +{ edition empty$ + { "" } + { edition } + if$ +} + +FUNCTION {format.date} +{ year duplicate$ empty$ + { "empty year in " cite$ * warning$ + pop$ "" } + 'skip$ + if$ + month empty$ + 'skip$ + { type$ "book" = + type$ "inbook" = + OR + 'skip$ + { month " " * swap$ * } + if$ + } + if$ +} + + +FUNCTION {format.edition.or.date} +{ edition empty$ year empty$ and + { "" } + { edition empty$ + { type empty$ NOT + { type #-1 #4 substring$ "mail" = + type #1 #4 substring$ "Mail" = + OR + { " gesendet: " "-- " type * swap$ * + format.date * + } + { "\,Version:\," + format.date * + } + if$ + } + { "\,Version:\," + format.date * + } + if$ + } + { year empty$ + { "\,Version:\," edition * } + { "\,Version:\," edition * ", " * + format.date * + } + if$ + } + if$ + } + if$ +} + +FUNCTION {format.doi} +{ doi empty$ + { "" } + { new.block "\url{http://dx.doi.org/" doi * "}" * + %% { new.block "\url{http://dx.medra.org/" doi * "}" * + } + if$ +} + +FUNCTION {format.url} +{ urn missing$ + { doi missing$ + { url empty$ + { "" } + { type empty$ NOT + { type #-1 #4 substring$ "mail" = + type #1 #4 substring$ "Mail" = + OR + { type$ "incollection" = + { "" } + { "\,Absenderadresse: \url{" url * "}" * } + if$ + } + { "\url{" url * "}" * }%% evtl. "URL" oder "<...>" + if$ + } + { "\url{" url * "}" * } %% evtl. "URL" oder "<...>" + if$ + } + if$ + } + { format.doi } + if$ + } + { "\url{http://nbn-resolving.de/urn/resolver.pl?urn=" urn * "}" * + } + if$ +} + +FUNCTION {format.maillist.url} + { url empty$ + { "" } + { type empty$ + { "" } + { type #-1 #4 substring$ "mail" = + type #1 #4 substring$ "Mail" = + OR + { "\url{" url * "}" * } + { "" } + if$ + } + if$ + } + if$ + } + + +FUNCTION {format.version.url} +{ url empty$ doi empty$ urn empty$ and and + { type$ "techreport" = + { format.edition } + { "" } + if$ + } + { format.edition.or.date output format.url } + if$ +} + +FUNCTION {format.edition.or.version} +{ url empty$ doi empty$ urn empty$ and and + { format.edition } + { format.edition.or.date } + if$ +} + +FUNCTION {format.online.lastcheck} +{ lastchecked empty$ + { url empty$ doi empty$ urn empty$ and and + { skip$ } + { "" output } + if$ + } + { url empty$ doi empty$ urn empty$ and and + { "there's a lastchecked date but no url, urn or doi in " + cite$ * warning$ + } + { part.of.sentence + lastchecked "Abruf: " swap$ * output + } + if$ + } + if$ +} + + +FUNCTION {format.maillist.lastcheck} + { type empty$ NOT + { type #-1 #4 substring$ "mail" = + type #1 #4 substring$ "Mail" = + OR + { format.online.lastcheck } + 'skip$ + if$ + } + 'skip$ + if$ + } + +FUNCTION {format.address.publisher.year} +{ publisher empty$ + { address empty$ + { year empty$ + { "" } + { year } + if$ + } + { "there's an address but no publisher in " cite$ * warning$ + address ", " * format.date * + } + if$ + } + { address empty$ + { year empty$ + { "neither address nor publication date in " cite$ * warning$ + publisher + } + { publisher ", " * format.date * } + if$ + } + { year empty$ + { address " : " * publisher * } + { address " : " * publisher * ", " * format.date * } + if$ + } + if$ + } + if$ +} + +FUNCTION {format.address.publisher.year.alt} +{ publisher empty$ + { address empty$ + { year empty$ + { "" } + { url empty$ + { year } + { "" } + if$ + } + if$ + } + { "there's an address but no publisher in " cite$ * warning$ + address ", " * format.date * + } + if$ + } + { url empty$%%%% wenn es URL gibt wird nur die service-provider Adresse +%%% ausgegeben, die im publisher-Feld steht + { address empty$ + { year empty$ + { "neither address nor publication date in " cite$ * warning$ + publisher + } + { publisher ", " * format.date * } + if$ + } + { year empty$ + { address " : " * publisher * } + { address " : " * publisher * ", " * format.date * } + if$ + } + if$ + } + { publisher } + if$ + } + if$ +} + +FUNCTION {format.howpublished} +{ url missing$ urn missing$ doi missing$ AND AND + { howpublished empty$ + { address empty$ + { type empty$ + { "" } + { type #-1 #4 substring$ "mail" = + { "(gesendet: " new.sentence + format.date * ")" * + } + { "" } + if$ + } + if$ + format.date * + } + { address ", " * format.date * } + if$ + } + { address empty$ + { howpublished ", " * format.date * } + { address " : " * howpublished * ", " * format.date * } + if$ + } + if$ + } + { howpublished empty$ + { "" } + { howpublished } + if$ + } + if$ +} + +FUNCTION {format.lastchecked.or.type}%% nur in misc-Funktion +{ lastchecked empty$ + { url empty$ doi empty$ urn empty$ and and + { type empty$ + { skip$ } + { type set.period.dash.check + type output + } + if$ + } + { type empty$ + { skip$ } + { type #-1 #4 substring$ "mail" = + type #1 #4 substring$ "Mail" = + OR + { skip$ } + { type set.period.dash.check + type output } + if$ + } + if$ + } + if$ + } + { url empty$ doi empty$ urn empty$ and and + { "there's a lastchecked date but no url, urn or doi in " + cite$ * warning$ + } + { type empty$ + { "there's a URL and a lastchecked date but no type in " + cite$ * warning$ + } + { type set.period.dash.check + type output + part.of.sentence + lastchecked "Abruf: " swap$ * output + } + if$ + } + if$ + } + if$ +} + + +FUNCTION {format.btitle} +{ title emphasize +} + +FUNCTION {tie.or.space.connect} +{ duplicate$ text.length$ #3 < + { "~" } + { " " } + if$ + swap$ * * +} + +FUNCTION {format.btitle.vol} +{ number empty$ + { series empty$ + { volume empty$ + { title emphasize } + { title emphasize ". Bd." * volume tie.or.space.connect } + if$ + } + { volume empty$ + { title emphasize }%% ein Buch, das zusaetzl. SERIES=Reihentitel besitzt + %% jetzt kommt d. Fall des mehrbaendigen Werkes mit Gesamttitel=SERIES + %% Zaehlung=VOLUME und Bandtitel=TITLE; + { series emphasize ". Bd." * volume tie.or.space.connect + ": " * "{\emph{" * title * "}}" * } + if$ + } + if$%% series-test + } + { title emphasize }%% wenn number ex., dann immer title-Feld + if$%% Ende number-test +} + +FUNCTION {format.series.number.din} +{ volume empty$ + { number empty$ + { series empty$ + { "" } + { "(" series * ")" * } %% d. Seriennr koennte auch gleich hier + %% im SERIES-Feld miterfasst werden + if$ + } + { series empty$ + { "(" number * ")" * + "there's a number but no series in " cite$ * warning$ + } + { "(" series * number tie.or.space.connect ")" * } + if$ + } + if$ + } + { series empty$ + { "" } + { type$ "proceedings" = %% Sonderfall, es darf VOLUME und NUMBER ex. ! + type$ "inproceedings" = OR + { number empty$ + { "(" series * ")" * } + { "(" series * number tie.or.space.connect ")" * } + if$ + } + { "" }%% Ausstieg mit Nullstring, s. Kommentar + if$ + }%% bei gezaehlten Reihen MUSS die Reihennr. im Feld NUMBER stehen! + if$ %% wenn also d. Feld VOLUME nicht leer ist, dann liegt ausser bei + %% Typ PROCEEDINGS falsche + } %% Erfassung vor und es erfolgt d. Ausstieg mit d. Nullstring! + if$ +} + +FUNCTION {format.tr.series.or.number} +{ number empty$ + { series empty$ + { "" } + { "(" series * ")" * } + if$ + } + { series empty$ + { "(" number * ")" * } + { "(" series * number tie.or.space.connect ")" * } + if$ + } + if$ + } + +FUNCTION {format.misc.series} +{ series empty$ + { "" } + { "(" series * ")" * } + if$ +} + +FUNCTION { format.doi.urn } +{ urn empty$ + { doi empty$ + { "" } + { "DOI" doi n.dashify tie.or.space.connect } + if$ + } + { "URN" urn n.dashify tie.or.space.connect } + if$ +} + +FUNCTION { format.isbn.issn } +{ isbn empty$ + { issn empty$ + { "" } + { "ISSN" issn n.dashify tie.or.space.connect } + if$ + } + { "ISBN" isbn n.dashify tie.or.space.connect } + if$ +} + +FUNCTION {format.pages} +{ pages empty$ + { "" } + { url empty$ + { "S." pages n.dashify tie.or.space.connect } + { pages } + if$ + } + if$ +} + +FUNCTION {format.pages.book} +{ pages empty$ + { "" } + { note empty$ isbn empty$ AND + { "" pages n.dashify tie.or.space.connect " S" * + add.period$ } + { "" pages n.dashify tie.or.space.connect " S" * } + if$ + } + if$ +} + +FUNCTION {format.pages.bkcollation} +{ pages empty$ + { "" } + { "" pages n.dashify tie.or.space.connect } + if$ +} + +FUNCTION {format.bkpages.collat.check} +{ 's := + #1 'ptr := + s text.length$ 'collation := + collation #1 = + { format.pages.book } + { + collation 'collrest := + { collrest #0 > } + { s ptr #2 substring$ 't := + t "S." = + { format.pages.bkcollation + #0 'collrest := } + { ptr #1 + 'ptr := + collrest #1 - 'collrest := + #1 collrest = + { format.pages.book } + { skip$ } + if$ + } + if$ + } + while$ + } + if$ +} + +FUNCTION {format.vol.year.num.pages} +{ volume field.or.null + year empty$ + { "there's no year in " cite$ * warning$ } + { " (" year * ")" * * } + if$ + month empty$ + 'skip$ + { ", " month * * } + if$ + number empty$ + 'skip$ + { ", Nr. " number * * } + if$ + pages empty$ + 'skip$ + { duplicate$ empty$ + { pop$ "" } + { title missing$ + { ", " pages format.bkpages.collat.check * *} + { ", " format.pages * *} + if$ + } + if$ + } + if$ +} + +FUNCTION {format.chapter.inbook} +{ duplicate$ empty$ + { pop$ "empty chapter in " cite$ * warning$ } + { type empty$ + { "\emph{Kapitel\/} " swap$ tie.or.space.connect } + { type " " * swap$ * }%% wenn keine bes. Abschnittsform gen. werden soll, + %% koennte e. kl. Zwischenraum gewaehlt werden, z.B. " \, " + if$ + } + if$ + } + +FUNCTION {format.chapter.pages} +{ chapter empty$ + 'format.pages + { type empty$ + { "Kapitel " } + { url empty$ + { type } + { "Kapitel " } + if$ + } + if$ + chapter tie.or.space.connect + pages empty$ + 'skip$ + { ", " * format.pages * } + if$ + } + if$ +} + +FUNCTION {format.in.ed.booktitle.din} +{ booktitle empty$ + { "" } + { editor empty$ + { volume empty$ + { "{In: }" booktitle emphasize * } + { "{In: }" booktitle emphasize * + " Bd." volume tie.or.space.connect * + } + if$ + } + { volume empty$ + { "{In: }" format.ed.incoll * ": " * booktitle emphasize * } + { "{In: }" format.ed.incoll * ": " * booktitle emphasize * + " Bd." volume tie.or.space.connect * + } + if$ + } + if$ + } + if$ +} + +FUNCTION {format.thesis.tr.type} +{ type empty$ + 'skip$ + { pop$ + type + } + if$ +} + +FUNCTION {format.article.crossref} +{ key empty$ + { journal empty$ + { "need key or journal for " cite$ * " to crossref " * crossref * + warning$ + "" + } + { "{In: }{\emph " journal * "}" * } + if$ + } + { "{In: }" key * } + if$ + "\cite{" * crossref * "}" * ", " * format.pages * +} + +FUNCTION {format.crossref.editor} + { editor #1 "{ll}" format.name$ " (Hrsg.)" * + editor num.names$ duplicate$ + #2 > + { pop$ ua.etal * }%% --->u. a. + { #2 < + 'skip$ + { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" = + { ua.etal } + { " ; " * editor #2 "{vv~}{ll}" format.name$ * " (Hrsg.)" * } + if$ + } + if$ + } + if$ +} + +FUNCTION {format.inbk.vol.title} +{ volume empty$ + { " In: " } + { title empty$ + { " In: Bd." volume tie.or.space.connect + " von " * + } + { "In: Bd." volume tie.or.space.connect ": " * title emphasize * + " (" * year * ") in " * + } + if$ + } + if$ + } + + +FUNCTION {format.book.crossref} +{ type$ "inbook" = + { format.inbk.vol.title } + { volume empty$ + { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ + " " + } + { ". -- Bd." volume tie.or.space.connect + " von " * + } + if$ + } + if$ + editor empty$ + editor field.or.null author field.or.null = + or + { key empty$ + { series empty$ + { "need editor, key, or series for " cite$ * " to crossref " * + crossref * warning$ + "" * + } + { "" * } + if$ + } + { key * } + if$ + } + { "" * } + if$ + "\cite{" * crossref * "}" * +} + +FUNCTION {format.incoll.inproc.crossref} +{ editor empty$ + editor field.or.null author field.or.null = + or + { key empty$ + { booktitle empty$ + { "need editor, key, or booktitle for " cite$ * " to crossref " * + crossref * warning$ + "" + } + { "{In: }{\emph " booktitle * "}" * }%% + if$ + } + { "{In: }" } + if$ + } + { "{In: }" } + if$ + "\cite{" * crossref * "}" * %% ", " * format.pages * 5.12.2005 +} + +FUNCTION {article} +{ output.bibitem + format.authors "author" output.check + set.colon.after + format.title "title" output.check + crossref missing$ + { journal article.in.journal output.nonnull + new.sentence + format.vol.year.num.pages output + format.url output + } + { format.article.crossref output.nonnull } + if$ + format.online.lastcheck + doi set.period.dash.check + urn set.period.dash.check + format.doi.urn output + issn set.period.dash.check + format.isbn.issn output + note set.period.dash.check + note output + fin.entry +} + +FUNCTION {book} +{ output.bibitem + author empty$ + { format.editors "author and editor" output.check } + { format.authors format.editors output.nonnull } + if$ + set.colon.after + crossref missing$ + { format.btitle.vol "title" output.check } + { format.btitle "title" output.check } + if$ + format.edition output + format.address.publisher.year "publisher" output.check + new.sentence + crossref missing$ + { format.series.number.din output } + { format.book.crossref output.nonnull } + if$ + pages empty$ + { skip$ } + { pages set.period.dash.check + pages format.bkpages.collat.check output + } + if$ + format.doi output + format.url output + new.block + isbn set.period.dash.check + format.isbn.issn output + note set.period.dash.check + note output + fin.entry +} + +FUNCTION {booklet} +{ output.bibitem + author empty$ + { format.editors "author and editor" output.check } + { format.authors format.editors output.nonnull } + if$ + set.colon.after + format.btitle "title" output.check + format.edition.or.version output + format.url output + format.online.lastcheck + format.howpublished output + series new.sentence.checka + format.series.number.din output + pages empty$ + { skip$ } + { pages set.period.dash.check + pages format.bkpages.collat.check output + } + if$ + type set.period.dash.check + format.digital.type output + doi set.period.dash.check + urn set.period.dash.check + format.doi.urn output + note set.period.dash.check + note output + format.isbn.issn output + fin.entry +} + + +FUNCTION {inbook} +{ output.bibitem + chapter format.chapter.inbook output.nonnull + crossref missing$ + { author empty$ + { format.editors "\,{In:\,}" swap$ * "author and editor" output.check } + { format.authors "\,{In:\,}" swap$ * output.nonnull } + if$ + author empty$ editor empty$ AND + { before.all 'output.state := } + { set.colon.after } + if$ + format.btitle.vol "title" output.check + format.edition output + format.address.publisher.year "publisher" output.check + new.sentence + format.series.number.din output + isbn set.period.dash.check + format.isbn.issn output + } + { format.book.crossref output.nonnull } + if$ + part.of.sentence + format.pages output + note set.period.dash.check + note output + fin.entry +} + +FUNCTION {incollection} +{ output.bibitem + format.authors "author" output.check + set.colon.after + format.title "title" output.check + format.version.url output + type empty$ NOT + { type #-1 #4 substring$ "mail" = + type #1 #4 substring$ "Mail" = + OR + 'skip$ + { format.online.lastcheck } + if$ + } + { format.online.lastcheck } + if$ + crossref missing$ + { format.in.ed.booktitle.din "booktitle" output.check + format.edition output + format.address.publisher.year "publisher" output.check + format.maillist.url output + format.maillist.lastcheck + new.sentence + format.series.number.din output + doi set.period.dash.check + urn set.period.dash.check + format.doi.urn output + isbn set.period.dash.check + issn set.period.dash.check + format.isbn.issn output + } + { format.incoll.inproc.crossref output.nonnull } + if$ + part.of.sentence + format.chapter.pages "pages" output.check + note set.period.dash.check + note output + fin.entry +} + + +FUNCTION {inproceedings} +{ output.bibitem + format.authors "author" output.check + set.colon.after + format.title "title" output.check + crossref missing$ + { format.in.ed.booktitle.din "booktitle" output.check + address empty$ + { organization new.sentence.checka + organization output + part.of.sentence + format.address.publisher.year output + } + { format.address.publisher.year "publisher" output.check } + if$ + new.sentence + series empty$ + 'skip$ + { format.series.number.din output } + if$ + isbn set.period.dash.check + issn set.period.dash.check + format.isbn.issn output + } + { format.incoll.inproc.crossref output.nonnull } + if$ + part.of.sentence + format.pages "pages" output.check + note set.period.dash.check + note output + fin.entry +} + +FUNCTION {conference} { inproceedings }%% nach Patashnik, wg US-Kompatibilitaet + +FUNCTION {manual} +{ output.bibitem + author empty$ + { organization empty$ + { title empty$ + 'skip$ + {format.btitle "title" output.check } + if$ + } + 'skip$ + if$ + } + 'skip$ + if$ + format.authors.organization output.nonnull + set.colon.after + format.btitle "title" output.check + format.edition "edition" output.check + author empty$ organization empty$ AND + { address "address" output.check + part.of.sentence + } + { organization empty$ + { address "address" output.check + part.of.sentence + } + { address ": " * organization * output + part.of.sentence + } + if$ + } + if$ + format.date output + number empty$ + 'skip$ + { "(" number * ") " * output } + if$ + pages empty$ + { skip$ } + { pages set.period.dash.check + pages format.bkpages.collat.check output + } + if$ + format.doi output + format.url output + format.online.lastcheck + note set.period.dash.check + note output + fin.entry +} + +%% Standard ist "Diplomarbeit", anderes mit TYPE="anderer Typ" erfassen! +%% z.B. TYPE={Hausarbeit}, TYPE={Diss.}, TYPE={Habil.}, TYPE={Magisterarb.} +FUNCTION {mastersthesis} +{ output.bibitem + format.authors "author" output.check + set.colon.after + format.btitle "title" output.check + address output + part.of.sentence + school "school" output.check + part.of.sentence + "Diplomarbeit" format.thesis.tr.type output.nonnull + part.of.sentence + format.date "year" output.check + format.url output + format.online.lastcheck +%% format.digital.resource.type + doi set.period.dash.check + urn set.period.dash.check + format.doi.urn output +%% pages set.period.dash.check +%% format.pages.book output + pages empty$ + { skip$ } + { pages set.period.dash.check + pages format.bkpages.collat.check output + } + if$ + note set.period.dash.check + note output + fin.entry +} + +FUNCTION {phdthesis} %% {mastersthesis}% ist identisch bis auf Standardwert, s.o. +{ output.bibitem + format.authors "author" output.check + set.colon.after + format.btitle "title" output.check + address output + part.of.sentence + school "school" output.check + part.of.sentence + "Diss." format.thesis.tr.type output.nonnull % koennte auch `Dissertation' sein + part.of.sentence + format.date "year" output.check + format.url output + format.online.lastcheck +%% format.digital.resource.type + doi set.period.dash.check + urn set.period.dash.check + format.doi.urn output + pages empty$ + { skip$ } + { pages set.period.dash.check + pages format.bkpages.collat.check output + } + if$ +%% pages set.period.dash.check +%% format.pages.book output + note set.period.dash.check + note output + fin.entry +} + + +%% Normen, Vornormen, Schutzrechte (Patente) werden hiermit erfasst; +%% (z.Zt. auch noch Internetressourcen) +%% das type-Feld uebernimmt eine wichtige Steuerfunktion: +FUNCTION {misc} +{ output.bibitem + type missing$ not + { type duplicate$ #1 #4 substring$ "Norm" = + type #1 #4 substring$ "Vorn" = OR + { " " * + format.number * output + new.sentence + format.date output + title empty$ + { skip$ } + { add.period$ new.sentence } + if$ + format.btitle "title" output.check + note set.period.dash.check + note output + } + { duplicate$ #1 #6 substring$ "Schutz" = + { " " * format.number * output + new.sentence + "(" * format.date ")" * output + add.period$ new.sentence + format.authors.organization add.period$ output + note output + } + %% wenn irgendein anderer Typ eingetragen ist + { pop$ pop$ "" + title empty$ + { note empty$ + { url empty$ + { "there's no relevant field in " cite$ warning$ + pop$ "" + } + { format.url output }%%% + if$ + } + { note " " * output.nonnull } + if$ + } + { author empty$ + { editor empty$ + { organization empty$ + { skip$ } + { format.editors.organization output.nonnull + set.colon.after + } + if$ + } + { format.editors format.editors.organization + output.nonnull set.colon.after + } + if$ + } + { format.authors format.editors output.nonnull + set.colon.after + } + if$ + format.btitle output.nonnull + url empty$ + { format.edition output + format.howpublished output} + { format.howpublished output + format.edition.or.date output + format.url output + } + if$ + format.online.lastcheck +%% format.lastchecked.or.type + new.sentence + format.misc.series output +%% note set.period.dash.check + note output + } + if$ + } + if$ + } + if$ + } + %% wenn es keinen type gibt + { title empty$ + { note empty$ + { url empty$ + { "there's no relevant field in " cite$ warning$ + pop$ "" + } + { format.url output }%%% das waere e. reine URL + if$ + } + { note " " * output.nonnull + %% format.url format.date output + } + if$ + } + { author empty$ + { editor empty$ + { organization empty$ + { skip$ } + { format.editors.organization output.nonnull + set.colon.after + } + if$ + } + { format.editors format.editors.organization + output.nonnull set.colon.after + } + if$ + } + { format.authors format.editors output.nonnull + set.colon.after + } + if$ + format.btitle output.nonnull + url empty$ + { format.edition output + format.howpublished output} + { format.howpublished output + format.url output + format.edition.or.date output + format.online.lastcheck +%% format.lastchecked.or.type + } + if$ + new.sentence + format.misc.series output + note set.period.dash.check + note output + } + if$ + } + if$ + fin.entry +} + +FUNCTION {proceedings} +{ output.bibitem + editor empty$ + { organization empty$ + { "empty organization and editor in " cite$ * warning$ } + { organization " (Veranst.)" * output } + if$ + } + { format.editors format.editors.organization output.nonnull } + if$ + set.colon.after + format.btitle "title" output.check + volume empty$ + { skip$ } + { "{\textnormal{Bd.}}" volume tie.or.space.connect emphasize "volume" output.check } + if$ + format.address.publisher.year "publisher" output.check + new.sentence + format.series.number.din output.nonnull + pages empty$ + { skip$ } + { pages set.period.dash.check + pages format.bkpages.collat.check output + } + if$ + isbn set.period.dash.check + issn set.period.dash.check + format.isbn.issn output + note set.period.dash.check + note output + fin.entry +} + +FUNCTION {techreport} +{ output.bibitem + author empty$ + { format.editors "author and editor" output.check + format.tr.institution output.nonnull } + { format.authors format.editors output.nonnull } + if$ + set.colon.after + format.title "title" output.check + institution empty$ + 'skip$ + { author empty$ editor empty$ AND + 'skip$ + { institution new.sentence.checka + "/ " institution * output.nonnull + } + if$ + } + if$ + format.version.url output + format.online.lastcheck + format.address.publisher.year output + number new.sentence.checka + format.tr.series.or.number "number" output.check + "Forschungsbericht" format.thesis.tr.type set.period.dash.check + "Forschungsbericht" format.thesis.tr.type output +%% format.digital.resource.type + pages empty$ + { skip$ } + { pages set.period.dash.check + pages format.bkpages.collat.check output + } + if$ + isbn set.period.dash.check + issn set.period.dash.check + format.isbn.issn output + note set.period.dash.check + note "note" output.check + fin.entry +} + +FUNCTION {unpublished} {misc}%% AUTHOR, TITLE, NOTE muessen sein! +%% andere Felder sind optional + +FUNCTION {default.type} { misc } + + +MACRO {jan} {"Januar"} + +MACRO {feb} {"Februar"} + +MACRO {mar} {"M{\^^b a}rz"} + +MACRO {apr} {"April"} + +MACRO {mai} {"Mai"} + +MACRO {may} {"Mai"} + +MACRO {jun} {"Juni"} + +MACRO {jul} {"Juli"} + +MACRO {aug} {"August"} + +MACRO {sep} {"September"} + +MACRO {okt} {"Oktober"} + +MACRO {oct} {"Oktober"} + +MACRO {nov} {"November"} + +MACRO {dez} {"Dezember"} + +MACRO {dec} {"Dezember"} + +%%$$$ stillgelegte Beispiele fuer den Gebrauch von Kuerzeln (hier Zs-Titel). + +%%MACRO {acmcs} {"ACM Computing Surveys"} + +%%MACRO {acta} {"Acta Informatica"} + +READ + +FUNCTION {sortify} +{ purify$ + "l" change.case$ +} + +FUNCTION {chop.word} +{ 's := + 'len := + s #1 len substring$ = + { s len #1 + global.max$ substring$ } + 's + if$ +} + +FUNCTION {initialize.et.al.char.used} +{ #0 'et.al.char.used := +} + +EXECUTE {initialize.et.al.char.used} + +FUNCTION {format.lab.names} +{ 's := + s num.names$ 'numnames := + numnames #1 > + { numnames #4 > + { #3 'namesleft := } + { numnames 'namesleft := } + if$ + #1 'nameptr := + "" + { namesleft #0 > } + { nameptr numnames = + { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" = +%% { "\," * %% kein besonderes Zeichen fuer "others" i. label + { "{\etalchar{+}}" * %% ein plus-Zeichen (+) fuer "others"! + #1 'et.al.char.used := + } + { s nameptr "{l{}}" format.name$ * } + if$ + } + { s nameptr "{l{}}" format.name$ * } + if$ + nameptr #1 + 'nameptr := + namesleft #1 - 'namesleft := + } + while$ + numnames #4 > +%% { "\," * %% s. Bemerkung oben + { "{\etalchar{+}}" * + #1 'et.al.char.used := + } + 'skip$ + if$ + } + { s #1 "{l{}}" format.name$ + duplicate$ text.length$ #2 < + { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ } %% vgl. Anmerkung! + 'skip$ + if$ + } + if$ +} + +FUNCTION {author.key.label} +{ author empty$ + { key empty$ + { cite$ #1 #3 substring$ } + { key #3 text.prefix$ } + if$ + } + { author format.lab.names } + if$ +} + +FUNCTION {author.editor.key.label} +{ author empty$ + { editor empty$ + { key empty$ + { cite$ #1 #3 substring$ } + { key #3 text.prefix$ } + if$ + } + { editor format.lab.names } + if$ + } + { author format.lab.names } + if$ +} + +FUNCTION {author.key.organization.label} +{ author empty$ + { key empty$ + { organization empty$ + { cite$ #1 #3 substring$ } + { "The " #4 organization chop.word #3 text.prefix$ } + if$ + } + { key #3 text.prefix$ } + if$ + } + { author format.lab.names } + if$ +} + +FUNCTION {editor.key.organization.label} +{ editor empty$ + { key empty$ + { organization empty$ + { cite$ #1 #3 substring$ } + { "The " #4 organization chop.word organization } + if$ + } + { key #5 text.prefix$ }%% man kann Laenge des key einstellen + if$ + } + { key empty$%% wenn key vh., dann macht er das label! Lo,18/5/99 + { editor format.lab.names } + { key #5 text.prefix$ } + if$ + } + if$ +} + +FUNCTION {calc.label} +{ type$ "book" = + type$ "booklet" = + type$ "inbook" = + or or + 'author.editor.key.label + { type$ "proceedings" = + 'editor.key.organization.label + { type$ "manual" = + 'author.key.organization.label + 'author.key.label + if$ + } + if$ + } + if$ + duplicate$ + year field.or.null purify$ #-1 #2 substring$ + * + 'label := + year field.or.null purify$ #-1 #4 substring$ + * + sortify 'sort.label := +} + +FUNCTION {sort.format.names} +{ 's := + #1 'nameptr := + "" + s num.names$ 'numnames := + numnames 'namesleft := + { namesleft #0 > } + { nameptr #1 > + { " " * } + 'skip$ + if$ + s nameptr "{ll{ }}{ ff{ }}{ vv{ }}{ jj{ }}" format.name$ 't := + nameptr numnames = t "others" = and + { ua.etal * } + { t sortify * } + if$ + nameptr #1 + 'nameptr := + namesleft #1 - 'namesleft := + } + while$ +} + +FUNCTION {sort.format.title} +{ 't := + "A " #2 + "An " #3 + "Der " #4 + "Die " #4 + "Das " #4 + "Ein " #4 + "Eine " #5 + "The " #4 t chop.word + chop.word + chop.word + chop.word + chop.word + chop.word + chop.word + chop.word + sortify + #1 global.max$ substring$ +} + +FUNCTION {author.sort} +{ author empty$ + { key empty$ + { "to sort, need author or key in " cite$ * warning$ + "" + } + { key sortify } + if$ + } + { author sort.format.names } + if$ +} + +FUNCTION {author.editor.sort} +{ author empty$ + { editor empty$ + { key empty$ + { "to sort, need author, editor, or key in " cite$ * warning$ + "" + } + { key sortify } + if$ + } + { editor sort.format.names } + if$ + } + { author sort.format.names } + if$ +} + +FUNCTION {author.organization.sort} +{ author empty$ + { organization empty$ + { key empty$ + { "to sort, need author, organization, or key in " cite$ * warning$ + "" + } + { key sortify } + if$ + } + { "The " #4 organization chop.word sortify } + if$ + } + { author sort.format.names } + if$ +} + +FUNCTION {editor.organization.sort} +{ editor empty$ + { organization empty$ + { key empty$ + { "to sort, need editor, organization, or key in " cite$ * warning$ + "" + } + { key sortify } + if$ + } + { "The " #4 organization chop.word sortify } + if$ + } + { editor sort.format.names } + if$ +} + +FUNCTION {presort} +{ calc.label + sort.label + " " + * + type$ "book" = + type$ "booklet" = + type$ "inbook" = + or or + 'author.editor.sort + { type$ "proceedings" = + 'editor.organization.sort + { type$ "manual" = + 'author.organization.sort + 'author.sort + if$ + } + if$ + } + if$ + * + " " + * + year field.or.null sortify + * + " " + * + title field.or.null + sort.format.title + * + #1 entry.max$ substring$ + 'sort.key$ := +} + +ITERATE {presort} + +SORT + +FUNCTION {initialize.longest.label} +{ "" 'longest.label := + #0 int.to.chr$ 'last.sort.label := + "" 'next.extra := + #0 'longest.label.width := + #0 'last.extra.num := +} + +FUNCTION {forward.pass} +{ last.sort.label sort.label = + { last.extra.num #1 + 'last.extra.num := + last.extra.num int.to.chr$ 'extra.label := + } + { "a" chr.to.int$ 'last.extra.num := + "" 'extra.label := + sort.label 'last.sort.label := + } + if$ +} + +FUNCTION {reverse.pass} +{ next.extra "b" = + { "a" 'extra.label := } + 'skip$ + if$ + label extra.label * 'label := + label width$ longest.label.width > + { label 'longest.label := + label width$ 'longest.label.width := + } + 'skip$ + if$ + extra.label 'next.extra := +} + +EXECUTE {initialize.longest.label} + +ITERATE {forward.pass} + +REVERSE {reverse.pass} + +FUNCTION {begin.bib} +{ et.al.char.used + { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ } + 'skip$ + if$ + preamble$ empty$ + 'skip$ + { preamble$ write$ newline$ } + if$ + "\begin{thebibliography}{" longest.label * "}" * write$ newline$ + newline$ + "% this bibliography is generated by alphadin.bst [8.2] from 2005-12-21" + write$ newline$ + newline$ + "\providecommand{\url}[1]{\texttt{#1}}" + write$ newline$ + "\expandafter\ifx\csname urlstyle\endcsname\relax" + write$ newline$ + " \providecommand{\doi}[1]{doi: #1}\else" + write$ newline$ + " \providecommand{\doi}{doi: \begingroup \urlstyle{rm}\Url}\fi" + write$ newline$ +} + +EXECUTE {begin.bib} + +EXECUTE {init.state.consts} + +ITERATE {call.type$} + +FUNCTION {end.bib} +{ newline$ + "\end{thebibliography}" write$ newline$ +} + +EXECUTE {end.bib} \ No newline at end of file diff --git a/tex/.texmf/tex/context/third/pgfplots/t-pgfplots.tex b/tex/.texmf/tex/context/third/pgfplots/t-pgfplots.tex new file mode 100644 index 0000000..426d072 --- /dev/null +++ b/tex/.texmf/tex/context/third/pgfplots/t-pgfplots.tex @@ -0,0 +1,80 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\writestatus{loading}{ConTeXt User Module / Pgfplots} + +\unprotect + +\input pgfplots.revision.tex +\startmodule [pgfplots] + +\usemodule[tikz] +\usetikzlibrary[plotmarks] + +\edef\tikzatcode{\the\catcode`\@} +\edef\tikzbarcode{\the\catcode`\|} +\edef\tikzexclaimcode{\the\catcode`\!} +\catcode`\@=11 +\catcode`\|=12 +\catcode`\!=12 + + + +\input pgfplots.code.tex + +\def\pgfplotsincludegraphics[#1]#2{\externalfigure[#2][#1]} +\pgfkeys{/pgfplots/plot graphics/includegraphics cmd=\pgfplotsincludegraphics} + + +\let\pgfplots@ORIG@tikz@installcommands@before@context=\tikz@installcommands + +\def\tikz@installcommands{% + \pgfplots@ORIG@tikz@installcommands@before@context + % + \let\startaxis=\pgfplots@environment@axis + \let\stopaxis=\endpgfplots@environment@axis + % + \let\startsemilogxaxis=\pgfplots@environment@semilogxaxis + \let\stopsemilogxaxis=\endpgfplots@environment@semilogxaxis + % + \let\startsemilogyaxis=\pgfplots@environment@semilogyaxis + \let\stopsemilogyaxis=\endpgfplots@environment@semilogyaxis + % + \let\startloglogaxis=\pgfplots@environment@loglogaxis + \let\stoploglogaxis=\endpgfplots@environment@loglogaxis + % + \def\startpgfplotsinterruptdatabb{\pgfplotsinterruptdatabb}% + \def\stoppgfplotsinterruptdatabb{\endpgfplotsinterruptdatabb}% +}% + +\catcode`\@=\tikzatcode +\catcode`\|=\tikzbarcode +\catcode`\!=\tikzexclaimcode + +\stopmodule + +\protect +\endinput diff --git a/tex/.texmf/tex/context/third/pgfplots/t-pgfplotstable.tex b/tex/.texmf/tex/context/third/pgfplots/t-pgfplotstable.tex new file mode 100644 index 0000000..7351363 --- /dev/null +++ b/tex/.texmf/tex/context/third/pgfplots/t-pgfplotstable.tex @@ -0,0 +1,41 @@ +%-------------------------------------------- +% +% Package pgfplotstable +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\writestatus{loading}{ConTeXt User Module / Pgfplotstable} + +\unprotect + +\startmodule [pgfplotstable] + +\usemodule[pgfplots] + +% FIXME : +%\def\pgfplots@texdist@protect{\protect}% + +\input pgfplotstable.code.tex + + +\stopmodule + +\protect +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex new file mode 100644 index 0000000..e73f87a --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex @@ -0,0 +1,631 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007-2012 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +%-------------------------------------------------- +% \pgfqkeys{/pgfplots/surf shading}{ +% cols=3, +% % test colormap 1, +% } +% \pgfplotslibrarysurfstreamstart +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{0pt}{10pt}}{0} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{100pt}{10pt}}{100} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{180pt}{10pt}}{30} +% % +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{0pt}{100pt}}{300} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{110pt}{90pt}}{1000} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{190pt}{110pt}}{600} +% % +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{0pt}{200pt}}{0} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{110pt}{200pt}}{100} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{190pt}{200pt}}{60} +% \pgfplotslibrarysurfstreamend +% \fbox{% +% \pgfplotslibrarysurfdraw +% }% +%-------------------------------------------------- + + +\newif\ifpgfplotslibrarysurf@updatebb +\newif\ifpgfplotslibrarysurf@usecolormap +\pgfplotslibrarysurf@updatebbtrue + +\pgfkeys{% + /pgfplots/surf shading/anchor/.initial=\pgfpointorigin,% + /pgfplots/surf shading/shading type/.initial=5,% triangles in form of lattice + % + % If this is true, the embedding picture's bounding box will be updated using + % the shading's bounding box. + % This bounding box may be (highly!) inaccurate for coons shadings and tensor product shadings. + % The 'patch' plot handler disables it and takes control over it explicitly (using interpolation + % points rather than bezier control points). + /pgfplots/surf shading/update BB/.is if=pgfplotslibrarysurf@updatebb, + % + % can only have values '' (empty) for binary encoding or + % ASCIIHexEncode for base 16 encoding. Use this if some driver + % cannot produce binary encoding. This is undocumented; for use in + % emergency only. + /pgfplots/surf shading/pdf stream filter/.initial=,% + % + /pgfplots/surf shading/precision/.is choice, + /pgfplots/surf shading/precision/pdf/.code={% + % Lossless coordinate output. + \def\pgfplotslibrarysurf@bitspercoordinate{32}% + \def\pgfplotslibrarysurf@bytespercoordinate{4}% + \def\pgfplotslibrarysurf@filter@encode{}% raw binary. + \def\pgfplotslibrarysurf@filter@decode{}% + },% + /pgfplots/surf shading/precision/ps/.code={% + % quantized coordinate output (introduces quantization error). + \def\pgfplotslibrarysurf@bitspercoordinate{24}% + \def\pgfplotslibrarysurf@bytespercoordinate{3}% + % doesn't improve behavior of pdf2ps: + %\def\pgfplotslibrarysurf@filter@encode{ASCIIHexEncode}% + %\def\pgfplotslibrarysurf@filter@decode{ASCIIHexDecode}% + \def\pgfplotslibrarysurf@filter@encode{}% raw binary. + \def\pgfplotslibrarysurf@filter@decode{}% + },% + /pgfplots/surf shading/precision/postscript/.style={% + /pgfplots/surf shading/precision/ps},% + /pgfplots/surf shading/precision/ps,% + % columns: + /pgfplots/surf shading/cols/.initial=,% + /pgfplots/surf shading/colorspace/.initial=rgb,% rgb or cmyk or gray + % + % the colormap. If this key is empty, we assume that individual + % color components are provided for EVERY vertex for which cdata + % is expected. + /pgfplots/surf shading/colormap/.initial={% + << + /FunctionType 2 + /Domain [0 1] + /C0 [0 0 1] /C1 [1 0 0] /N 1 + >> + },% + /pgfplots/surf shading/test colormap 1/.style={% + /pgfplots/surf shading/colormap={ + << + /FunctionType 3 + /Domain [0 1] + /Functions [ + << + /FunctionType 2 + /Domain [0 1] + /C0 [0 0 1] /C1 [1 1 0] /N 1 + >> + << + /FunctionType 2 + /Domain [0 1] + /C0 [1 1 0] /C1 [1 0.5 0] /N 1 + >> + << + /FunctionType 2 + /Domain [0 1] + /C0 [1 0.5 0] /C1 [1 0 0] /N 1 + >> + ] + /Bounds [ 0.3 0.6 ] + /Encode [0 1 0 1 0 1] + %/Range [0 1 0 1 0 1] INCOMPATIBLE WITH ACROBAT 6.0 + >> + }% + },% + /pgfplots/surf shading/debug text/.initial=\the\c@pgfplotslibrarysurf@no, + /pgfplots/surf shading/every debug coord/.style={ + circle, + draw, + fill=yellow, + }, + /pgfplots/surf shading/debug/.is choice, + /pgfplots/surf shading/debug/false/.code={% + \let\pgfplotslibrarysurfprocesscoordinate=\pgfplotslibrarysurfprocesscoordinate@orig + \let\pgfplotslibrarysurfusepath=\pgfplotslibrarysurfusepath@orig + }, + /pgfplots/surf shading/debug/true/.code={% + \let\pgfplotslibrarysurfprocesscoordinate=\pgfplotslibrarysurfprocesscoordinate@debug + \def\pgfplotslibrarysurfusepath{\pgfusepath{stroke,fill}} + }, + /pgfplots/surf shading/debug/.default=true, +}% + +\def\pgfplotslibrarysurf@corner@sw{\pgfplots@error{This is unavailable until \string\pgfplotslibrarysurfstreamend}} +\let\pgfplotslibrarysurf@corner@ne\pgfplotslibrarysurf@corner@sw + +% parametric colors (colormap) are always in [0,1000]. I +% 2 bytes suffice for that range. +\def\pgfplotslibrarysurf@bytespercomponent{2}% +\def\pgfplotslibrarysurf@bitspercomponent{16}% + +\def\pgfplotslibrarysurf@decode{% + -16383.999992 16384 % see the docs of \pgfplotsbinaryencodedimenmaplinearly + -16383.999992 16384 % + \pgfplotslibrarysurf@decode@colors +}% +\def\pgfplotslibrarysurf@decode@colors@colormap{% + 0 \pgfplotscolormappdfmax % map [0,2^BitsPerComponent-1] linearly to [0 1] for parametric color data +}% +\def\pgfplotslibrarysurf@decode@colors@explicit@one@component{% + % this is just one component for explicit color data. + % it will be replicated for every color component. + 0 1 % the target value for color component values. +}% + +\def\pgfplotslibrarysurf@count{0}% +\newcount\c@pgfplotslibrarysurf@no + +% driver specific: +\def\pgfplotslibrarysurf@initstream{% + \edef\pgfplots@loc@TMPa{\pgfkeysvalueof{/pgfplots/surf shading/pdf stream filter}}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \let\pgfplotslibrarysurf@filter@encode=\pgfplots@loc@TMPa + \let\pgfplotslibrarysurf@filter@decode=\pgfplotslibrarysurf@filter@encode + \fi +} + +\def\pgfplotslibrarysurf@advancestreamlen#1{}% + +\def\pgfplotslibrarysurfstreamstart{% + \pgfplotslibrarysurfstreamstart@init@colors + \pgfkeysgetvalue{/pgfplots/surf shading/shading type}\pgfplotslibrarysurf@type + \pgfplotsapplistXglobalnewempty\pgfplotslibrarysurf@binarystream@accum + \pgfplotslibrarysurf@initstream + \ifx\pgfplotslibrarysurf@filter@encode\pgfutil@empty + \def\pgfplotslibrarysurf@filter@encode{binary encoding}% + \fi + \pgfkeysalso{/pgfplots/bin/\pgfplotslibrarysurf@filter@encode}% + % + \pgfplotsbinarysetbytes1% + \pgfplotsbinaryencodeunsigned{0}% use this method - it respects any special encodings. + \let\pgfplots@loc@TMPa=\pgfplotsbinaryresult + \ifcase\pgfplotslibrarysurf@type\relax + % 0 + \pgfplotslibrarysurf@initstream@wrongtype + \or% 1 + \pgfplotslibrarysurf@initstream@wrongtype + \or% 2 + \pgfplotslibrarysurf@initstream@wrongtype + \or% 3 + \or% 4 + % ok, triangle meshes. + \let\pgfplotslibrarysurf@edgeflag=\pgfplots@loc@TMPa + \or% 5 triangles in lattice form. disable edge flag: + \let\pgfplotslibrarysurf@edgeflag=\pgfutil@empty + \or% 6 coons patches: + \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty + \global\c@pgfplotslibrarysurf@no=0 + \def\pgfplotslibrarysurf@cubicpatch@numverts{12}% + \let\pgfplotslibrarysurfstreamcoord=\pgfplotslibrarysurfstreamcoord@cubicpatch + \let\pgfplotslibrarysurf@edgeflag=\pgfplots@loc@TMPa + \or% 7 full tensor product cubic bezier patches: + \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty + \global\c@pgfplotslibrarysurf@no=0 + \def\pgfplotslibrarysurf@cubicpatch@numverts{16}% + \let\pgfplotslibrarysurfstreamcoord=\pgfplotslibrarysurfstreamcoord@cubicpatch + \let\pgfplotslibrarysurf@edgeflag=\pgfplots@loc@TMPa + \else + \pgfplotslibrarysurf@initstream@wrongtype + \fi + % + % + % we want to establish a bounding box for THIS shading only! Otherwise the pdf XFORM might have a larger bounding box than we want. Is that ok here? Or does it hurt somewhere? + \pgf@getpathsizes{\pgfplots@loc@TMPa}% + \global\let\pgfplotslibrarysurf@pathsizes@before=\pgfplots@loc@TMPa +}% + + +\def\pgfplotslibrarysurfstreamstart@init@colors{% + % + \pgfkeysgetvalue{/pgfplots/surf shading/colormap}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfplotslibrarysurf@usecolormapfalse + \else + \pgfplotslibrarysurf@usecolormaptrue + \fi + % + \ifpgfplotslibrarysurf@usecolormap + \let\pgfplotslibrarysurf@decode@colors=\pgfplotslibrarysurf@decode@colors@colormap + \else + \pgfplotscolorspacegetcomponents{\pgfkeysvalueof{/pgfplots/surf shading/colorspace}}% + \c@pgf@counta=0 % + \c@pgf@countb=\pgfplotsretval\relax + % + \def\pgfplotslibrarysurf@decode@colors{}% + \pgfplotslibrarysurf@decode@colors@loop + \fi + % + \pgfplotslibrarysurf@translate@colorspace + \let\pgfplotslibrarysurf@colorspace=\pgfplotsretval +}% + +\def\pgfplotslibrarysurf@decode@colors@loop{% + \ifnum\c@pgf@counta<\c@pgf@countb + % + \edef\pgfplotslibrarysurf@decode@colors{% + \pgfplotslibrarysurf@decode@colors + \pgfplotslibrarysurf@decode@colors@explicit@one@component + }% + \advance\c@pgf@counta by1 % + % + \expandafter\pgfplotslibrarysurf@decode@colors@loop + \fi +}% + +\def\pgfplotslibrarysurf@initstream@wrongtype{% + \pgfplots@error{CRITICAL: shader=interp: got unsupported pdf shading type '\pgfplotslibrarysurf@type'. This may corrupt your pdf!}% +}% +\def\pgfplotslibrarysurfstreamend{% + \pgfplotsapplistXgloballet\pgfplotslibrarysurf@binarystream=\pgfplotslibrarysurf@binarystream@accum + \pgfplotsapplistXglobalnewempty\pgfplotslibrarysurf@binarystream@accum + % + \pgfplotslibrarysurfstreamend@set@BB +} + +\def\pgfplotslibrarysurfstreamend@set@BB{% + \xdef\pgfplotslibrarysurf@corner@sw{% + \global\pgf@x=\the\pgf@pathminx\space + \global\pgf@y=\the\pgf@pathminy\space + }% + \xdef\pgfplotslibrarysurf@corner@ne{% + \global\pgf@x=\the\pgf@pathmaxx\space + \global\pgf@y=\the\pgf@pathmaxy\space + }% + \pgf@setpathsizes\pgfplotslibrarysurf@pathsizes@before +}% + +% ATTENTION: see also \pgfplotslibrarysurfstreamcoord@cubicpatch +% #1: a pgf point. +% #2: a color coordinate in the range [0,1000] +\def\pgfplotslibrarysurfstreamcoord#1#2{% + \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercoordinate% + \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercoordinate}% + \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercoordinate}% + %\pgf@process{#1}% this here causes `{retaining \pgf@x}' messages and pollutes the save stack! Avoid it. See \tracingrestores=2 + \pgfplotslibrarysurfprocesscoordinate{#1}% + % The idea is to map + % the low-level point coordinates LINEARLY into [0,2^{8*}]. + % + % This is what the pdf standard expects for surface shadings. + % + % To do that, we simply map + % [-16384,16384] linearly into [0,2^{32}] + % and write the resulting integer in big endian binary format to + % the pdf low level stream. + % + % The decode procedure tells the pdf viewer how to invert that + % stuff. + % + \pgf@xa=\pgf@x + \pgf@sys@bp@correct\pgf@xa% + \pgfplotsbinaryencodedimenmaplinearly\pgf@xa +%\message{POINT \the\c@pgfplots@scanlineindex: ENCODING(x=\the\pgf@x)=\pgfplotsbinaryresult.}\advance\c@pgfplots@scanlineindex by1 + \t@pgfplots@toka=\expandafter{\pgfplotsbinaryresult}% + \pgf@ya=\pgf@y + \pgf@sys@bp@correct\pgf@ya% + \pgfplotsbinaryencodedimenmaplinearly\pgf@ya +%\message{ENCODING(y=\the\pgf@y)=\pgfplotsbinaryresult.}% + \t@pgfplots@tokb=\expandafter{\pgfplotsbinaryresult}% + % + \pgfplotslibrarysurf@encode@cdata{#2}% +%\message{\pgfplotsbinaryresult.}% + \t@pgfplots@tokc=\expandafter{\pgfplotsbinaryresult}% + \ifx\pgfplotslibrarysurf@edgeflag\pgfutil@empty + \else + % for shading type 4, the edge flag is given for EVERY + % coordinate (unlike all other shading types). + \pgfplotslibrarysurf@advancestreamlen{1}% + \fi + \edef\pgfplots@loc@TMPa{\pgfplotslibrarysurf@edgeflag\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\pgfplotsapplistXglobalpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum +} + +% defines \pgfplotsbinaryresult to contain the result of a CDATA +% entry and advances the stream counters. +\def\pgfplotslibrarysurf@encode@cdata#1{% + \ifpgfplotslibrarysurf@usecolormap + \pgfplotslibrarysurf@map@to@FFF@colormap{#1}% + \else + % oh. No cdata. Ok, then encode stuff individually! + % We expect data of the form + % {} + \edef\pgfplots@loc@TMPa{#1}% + \def\pgfplotsretval{}% + \expandafter\pgfplotslibrarysurf@encode@cdata@loop\pgfplots@loc@TMPa,,% + \let\pgfplotsbinaryresult=\pgfplotsretval + \fi +} + +\def\pgfplotslibrarysurf@encode@cdata@loop#1,{% + \def\pgfplots@loc@TMPa{#1}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + % + % + \pgfplotslibrarysurf@map@to@FFF@component{#1}% + \edef\pgfplotsretval{\pgfplotsretval\pgfplotsbinaryresult}% + % + % + % continue loop: + \expandafter\pgfplotslibrarysurf@encode@cdata@loop + \fi +}% + +% Defines \pgfplotsbinaryresult +\def\pgfplotslibrarysurf@map@to@FFF@colormap#1{% + \begingroup + % read fixed point input (in the range [0,1000]). + \pgf@xa=#1pt % + % convert to integer (= *65536): + \c@pgf@counta=\pgf@xa + % provide map [0,1000] -> [0,2^16-1] + \divide\c@pgf@counta by1000 + % now, we have \c@pgf@counta in [0,2^16]. Simply strip it into + % the required range, that's ok. + \ifnum\c@pgf@counta<0 + \c@pgf@counta=0 + \else + \ifnum\c@pgf@counta>65535 + \c@pgf@counta=65535 + \fi + \fi + % Now, we have CDATA in the range [0,65535] + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% +%\message{ENCODING(C=\pgfplots@glob@TMPa\space for \the\pgf@xa)=}% + \endgroup + \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercomponent% + \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa + \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercomponent}% +} + +% Defines \pgfplotsbinaryresult +\def\pgfplotslibrarysurf@map@to@FFF@component#1{% + \begingroup + % read fixed point input (in the range [0,1]). + \pgf@xa=#1pt % + % convert to integer (= *65536): + \c@pgf@counta=\pgf@xa + % provide map [0,1] -> [0,2^16-1] + % well, there is nothing to do! it was in [0,1], we multiplied by 65536 implicitly... that's it. + % + % now, we have \c@pgf@counta in [0,2^16]. Simply strip it into + % the required range, that's ok. + \ifnum\c@pgf@counta<0 + \c@pgf@counta=0 + \else + \ifnum\c@pgf@counta>65535 + \c@pgf@counta=65535 + \fi + \fi + % Now, we have CDATA in the range [0,65535] + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% +%\message{ENCODING(C=\pgfplots@glob@TMPa\space for \the\pgf@xa)=}% + \endgroup + \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercomponent% + \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa + \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercomponent}% +} + +\def\pgfplotslibrarysurf@translate@colorspace{% + \pgfkeysgetvalue{/pgfplots/surf shading/colorspace}\pgfplots@loc@TMPd + \edef\pgfplots@loc@TMPd{\pgfplots@loc@TMPd}% + \def\pgfplots@loc@TMPa{rgb}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd + \def\pgfplotsretval{RGB}% + \else + \def\pgfplots@loc@TMPa{cmyk}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd + \def\pgfplotsretval{CMYK}% + \else + \def\pgfplots@loc@TMPa{cmy}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd + \def\pgfplotsretval{CMY}% + \else + \def\pgfplots@loc@TMPa{gray}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd + \def\pgfplotsretval{Gray}% + \else + \pgfplots@error{Sorry, the 'surfshading' lib failed to recognise the choice '/pgfplots/surf shading/colorspace=\pgfplots@loc@TMPd'... maybe you misspelled it?}% + \def\pgfplotsretval{RGB}% + \fi + \fi + \fi + \fi +}% + +\def\pgfplotslibrarysurfusepath{\pgfusepath{fill}} +\let\pgfplotslibrarysurfusepath@orig=\pgfplotslibrarysurfusepath + +% We DO want to protocol the size of the shading. In fact, we NEED a +% bounding box which contains the whole shading, otherwise it will be +% clipped. More precisely, it will be packed into a pdf XForm object +% and that appears to need a correct bounding box. +% +% But we do NOT want to update the picture's bounding box, only that +% of the pdf XForm. The picture's bounding box will be updated as soon +% as we *use* the shading anyway (in +% \pgfplotslibrarysurfdrawinpicture). This here takes care of that detail: +\def\pgfplotslibrarysurf@protocolsizes@#1#2{% + \ifpgf@relevantforpicturesize + \pgfplots@loc@tmptrue + \else + \pgfplots@loc@tmpfalse + \fi + \pgf@relevantforpicturesizefalse + \pgf@protocolsizes{#1}{#2}% + \ifpgfplots@loc@tmp + \pgf@relevantforpicturesizetrue + \fi +}% + +\def\pgfplotslibrarysurfprocesscoordinate#1{% + #1\relax% + \pgfplotslibrarysurf@protocolsizes@{\pgf@x}{\pgf@y}% +}% +\let\pgfplotslibrarysurfprocesscoordinate@orig=\pgfplotslibrarysurfprocesscoordinate% + +\def\pgfplotslibrarysurfprocesscoordinate@debug#1{% + \pgfinterruptpath + \scope + \pgftransformshift{#1}% + \node[/pgfplots/surf shading/every debug coord] at (0pt,0pt) {\pgfkeysvalueof{/pgfplots/surf shading/debug text}};% + \endscope + \endpgfinterruptpath + #1\relax% + \pgfplotslibrarysurf@protocolsizes@{\pgf@x}{\pgf@y}% +}% + +% ATTENTION: see also \pgfplotslibrarysurfstreamcoord +% special routine for coons type patches and cubic tensor product type +% patches. It has FIRST all vertices, +% THEN the cdata. Furthermore, it only has 4 CDATA points, but a total +% of 12 vertices. +% +% #1: a pgf point. +% #2: a color coordinate in the range [0,1000] +\def\pgfplotslibrarysurfstreamcoord@cubicpatch#1#2{% + \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercoordinate% + \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercoordinate}% + \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercoordinate}% + %\pgf@process{#1}% this here causes `{retaining \pgf@x}' messages and pollutes the save stack! Avoid it. See \tracingrestores=2 + \pgfplotslibrarysurfprocesscoordinate{#1}% + % The idea is to map + % the low-level point coordinates LINEARLY into [0,2^{8*}]. + % + % This is what the pdf standard expects for surface shadings. + % + % To do that, we simply map + % [-16384,16384] linearly into [0,2^{32}] + % and write the resulting integer in big endian binary format to + % the pdf low level stream. + % + % The decode procedure tells the pdf viewer how to invert that + % stuff. + % + \pgf@xa=\pgf@x + \pgf@sys@bp@correct\pgf@xa% + \pgfplotsbinaryencodedimenmaplinearly\pgf@xa +%\message{POINT \the\c@pgfplots@scanlineindex: ENCODING(x=\the\pgf@x)=\pgfplotsbinaryresult.}\advance\c@pgfplots@scanlineindex by1 + \t@pgfplots@toka=\expandafter{\pgfplotsbinaryresult}% + \pgf@ya=\pgf@y + \pgf@sys@bp@correct\pgf@ya% + \pgfplotsbinaryencodedimenmaplinearly\pgf@ya +%\message{ENCODING(y=\the\pgf@y)=\pgfplotsbinaryresult.}% + \t@pgfplots@tokb=\expandafter{\pgfplotsbinaryresult}% + \def\pgfplotslibrarysurf@cubicpatch@hascdata{0}% + \ifnum\c@pgfplotslibrarysurf@no=0 + \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}% + % prepend edge flag. it is a new patch. + \t@pgfplots@toka=\expandafter{\expandafter\pgfplotslibrarysurf@edgeflag\the\t@pgfplots@toka}% + \pgfplotslibrarysurf@advancestreamlen{1}% + \else + \ifnum\c@pgfplotslibrarysurf@no=3 + \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}% + \else + \ifnum\c@pgfplotslibrarysurf@no=6 + \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}% + \else + \ifnum\c@pgfplotslibrarysurf@no=9 + \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}% + \fi + \fi + \fi + \fi + \if1\pgfplotslibrarysurf@cubicpatch@hascdata + % + \pgfplotslibrarysurf@encode@cdata{#2}% + %\message{\pgfplotsbinaryresult.}% + \t@pgfplots@tokc=\expandafter{\pgfplotslibrarysurf@cubicpatch@cdata}% + \xdef\pgfplotslibrarysurf@cubicpatch@cdata{% + \the\t@pgfplots@tokc + \pgfplotsbinaryresult + }% + \fi + \global\advance\c@pgfplotslibrarysurf@no by1 + % + \ifnum\pgfplotslibrarysurf@cubicpatch@numverts=\c@pgfplotslibrarysurf@no %finalize patch. + \t@pgfplots@tokc=\expandafter{\pgfplotslibrarysurf@cubicpatch@cdata}% + \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty + \global\c@pgfplotslibrarysurf@no=0 + \else + \t@pgfplots@tokc={}% + \fi + % edge flag is already in \t@pgfplots@toka (if this is the first + % vertex) + \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\pgfplotsapplistXglobalpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum +} + +\def\pgfplotslibrarysurfactivateshadefill{% + \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa% + \expandafter\pgfutil@addpdfresource@patterns\expandafter{\pgfplots@loc@TMPa}%% +} + +%-------------------------------------------------- +% \def\pgfplotslibrarysurfdraw{% +% % \pgftext[at=\pgfqpoint{0pt}{0pt}]% +% {\pgfplotssys@do@surfshading}% +% }% +%-------------------------------------------------- + +\def\pgfplotslibrarysurfdrawinpicture{% + \begingroup + % this statement will modify both the picture's BB and the path's BB + % unless we take control. + % + % Note that the path's BB will eventually be updated into the + % picture's BB as well (meaning that 'overlay' is of no use inside + % of this group). + % + % Implement the 'surf shading/update BB' functionality here: + \let\pgfplots@@protocolsizes=\pgf@protocolsizes + \ifpgfplotslibrarysurf@updatebb + \else + % NO update to any BB. this implies 'overlay' + % *and* disables updates to the path's BB. + \def\pgf@protocolsizes##1##2{\relax}% + \fi + \pgftext[at=\pgfplotslibrarysurf@corner@sw,left,bottom] {% + \begingroup + % inside of this box, we *always* need bounding boxes. + % restore functionality. + \let\pgf@protocolsizes=\pgfplots@@protocolsizes + \pgfplotslibrarysurfdraw + \endgroup +% this does NOT work because I can't undo the box' shift: +%\pgfplotssys@do@surfshading + }% + \endgroup +} + +\pgfplotsiffileexists{pgflibrarypgfplots.surfshading.\pgfsysdriver}{% + \input pgflibrarypgfplots.surfshading.\pgfsysdriver\relax + \def\pgflibrarysurfshadingifactive#1#2{#1}% +}{% + \def\pgfplotslibrarysurfdraw{% + \pgfplots@error{Sorry, surfshading (shader=interp) is NOT available for the selected driver `\pgfsysdriver'.}% + }% + \def\pgflibrarysurfshadingifactive#1#2{#2}% +} +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex new file mode 100644 index 0000000..7ab01a3 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex @@ -0,0 +1,94 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. +% Comment: This file has been modified to utilize libraries in the pgfplots package. +% Edited by Nick Papior Andersen + + + +% Loading further libraries + +% Include a library file. +% +% #1 = List of names of library file. +% +% Description: +% +% This command includes a list of pgfplots library files. For each file X in the +% list, the file tikzlibrarypgfplots.X.code.tex is included, provided this has +% not been done earlier. +% +% For the convenience of Context users, both round and square brackets +% are possible for the argument. +% +% Example: +% +% \usepgfplotslibrary{units} +% \usepgfplotslibrary[units,dateplot] + +\def\usepgfplotslibrary{\pgfutil@ifnextchar[{\use@pgfplotslibrary}{\use@@pgfplotslibrary}}%} +\def\use@pgfplotslibrary[#1]{\use@@pgfplotslibrary{#1}} +\def\use@@pgfplotslibrary#1{% + \edef\pgf@list{#1}% + \pgfutil@for\pgf@temp:=\pgf@list\do{% + \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}% + \ifx\pgf@temp\pgfutil@empty + \else + \pgfplotsiflibraryloaded{\pgf@temp}{}{% + \expandafter\global\expandafter\let\csname pgfp@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} + \catcode`\@=11 + \catcode`\|=12 + \pgfplots@iffileexists{tikzlibrarypgfplots.\pgf@temp.code.tex}{% + \input tikzlibrarypgfplots.\pgf@temp.code.tex}{% + \input pgflibrarypgfplots.\pgf@temp.code.tex}% + \catcode`\@=\csname tikz@library@#1@atcode\endcsname + \catcode`\|=\csname tikz@library@#1@barcode\endcsname + \expandafter\ifx\csname pgfp@library@#1@loadoptions\endcsname\relax + \else + \expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfp@library@\pgf@temp @loadoptions\endcsname + \expandafter\pgfplotsset\expandafter{\pgfplots@glob@TMPa}% + \fi + }% + \fi + }% +} + +\pgfkeys{ + % #1: library name + % #2: compatiblity presets which are controlled by the + % compatibility system but which belong to the library. + % + % FIXME : now as I wrote it, it might have been better to reverse + % the dependency... !? + /pgfplots/compat/library hook/.code 2 args={% + \pgfplotsiflibraryloaded{#1}{% + \pgfkeysalso{#2}% + }{% + \expandafter\ifx\csname pgfp@library@#1@loadoptions\endcsname\relax + \expandafter\def\csname pgfp@library@#1@loadoptions\endcsname{#2}% + \else + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfp@library@#1@loadoptions\endcsname}% + \t@pgfplots@tokb={#2}% + \expandafter\edef\csname pgfp@library@#1@loadoptions\endcsname{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% + \fi + }% + }, +} + +\def\pgfplotsiflibraryloaded#1#2#3{% + \expandafter\ifx\csname pgfp@library@#1@loaded\endcsname\relax% + #3\relax + \else + #2\relax + \fi% +}% + +% Default loaded libraries: +% Currently none diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex new file mode 100644 index 0000000..d6060e1 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex @@ -0,0 +1,99 @@ +%-------------------------------------------- +% +% Package pgfplots, library for additional colormaps, especially those +% related to matlab (tm). +% +% Copyright 2011 by Christian Feuersänger and Patrick Häcker. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% + +\pgfplotsset{ + /pgfplots/colormap/autumn/.style={ + /pgfplots/colormap={autumn}{rgb255=(255,0,0) rgb255=(255,255,0)} + }, + /pgfplots/colormap/bled/.style={ + /pgfplots/colormap={bled}{rgb255=(0,0,0) rgb255=(43,43,0) rgb255=(0,85,0) rgb255=(0,128,128) rgb255=(0,0,170) rgb255=(213,0,213) rgb255=(255,0,0)} + }, + /pgfplots/colormap/bright/.style={ + /pgfplots/colormap={bright}{rgb255=(0,0,0) rgb255=(78,3,100) rgb255=(2,74,255) rgb255=(255,21,181) rgb255=(255,113,26) rgb255=(147,213,114) rgb255=(230,255,0) rgb255=(255,255,255)} + }, + /pgfplots/colormap/cold/.style={ + /pgfplots/colormap={cold}{rgb255=(0,0,0) rgb255=(0,0,255) rgb255=(0,255,255) rgb255=(255,255,255)} + }, + /pgfplots/colormap/copper/.style={ + /pgfplots/colormap={copper}{[1cm]rgb255(0cm)=(0,0,0) rgb255(4cm)=(255,159,101) rgb255(5cm)=(255,199,127)} + }, + /pgfplots/colormap/copper2/.style={ + /pgfplots/colormap={copper2}{rgb255=(0,0,0) rgb255=(68,62,63) rgb255=(170,112,95) rgb255=(207,194,138) rgb255=(255,255,255)} + }, + /pgfplots/colormap/earth/.style={ + /pgfplots/colormap={earth}{rgb255=(0,0,0) rgb255=(0,28,15) rgb255=(42,39,6) rgb255=(28,73,33) rgb255=(67,85,24) rgb255=(68,112,46) rgb255=(81,129,83) rgb255=(124,137,87) rgb255=(153,147,122) rgb255=(145,173,164) rgb255=(144,202,180) rgb255=(171,220,177) rgb255=(218,229,168) rgb255=(255,235,199) rgb255=(255,255,255)} + }, + /pgfplots/colormap/gray/.style={ + /pgfplots/colormap={gray}{rgb255=(0,0,0) rgb255=(255,255,255)} + }, + /pgfplots/colormap/hsv/.style={ + /pgfplots/colormap={hsv}{rgb255=(255,0,0) rgb255=(255,255,0) rgb255=(0,255,0) rgb255=(0,255,255) rgb255=(0,0,255) rgb255=(255,0,255) rgb255=(255,0,0)} + }, + /pgfplots/colormap/hsv2/.style={ + /pgfplots/colormap={hsv2}{rgb255=(0,0,0) rgb255=(128,0,128) rgb255=(0,0,230) rgb255=(0,255,255) rgb255=(0,255,0) rgb255=(255,255,0) rgb255=(255,0,0)} + }, + /pgfplots/colormap/pastel/.style={ + /pgfplots/colormap={pastel}{rgb255=(0,0,0) rgb255=(120,0,5) rgb255=(0,91,172) rgb255=(215,35,217) rgb255=(120,172,78) rgb255=(255,176,24) rgb255=(230,255,0) rgb255=(255,255,255)} + }, + /pgfplots/colormap/pink/.style={ + /pgfplots/colormap={pink}{rgb255=(0,0,0) rgb255=(12,16,46) rgb255=(62,22,43) rgb255=(53,53,65) rgb255=(79,72,58) rgb255=(122,80,67) rgb255=(147,91,102) rgb255=(147,115,140) rgb255=(144,145,154) rgb255=(173,163,146) rgb255=(216,171,149) rgb255=(250,179,179) rgb255=(255,198,227) rgb255=(246,229,255) rgb255=(255,255,255)} + }, + /pgfplots/colormap/sepia/.style={ + /pgfplots/colormap={sepia}{rgb255(0cm)=(0,0,0) rgb255(1cm)=(26,13,0) rgb255(18cm)=(255,230,204) rgb255(20cm)=(255,255,255)} + }, + /pgfplots/colormap/bone/.style={ + /pgfplots/colormap={bone}{[1cm]rgb255(0cm)=(0,0,0) rgb255(3cm)=(84,84,116) rgb255(6cm)=(167,199,199) rgb255(8cm)=(255,255,255)} +}, + %-------------------------------------------------- + % % mesh width is too fine for these: + % /pgfplots/colormap/dusk/.style={ + % /pgfplots/colormap={dusk}{ + % [1cm]rgb255(0cm)=(0,0,0) + % rgb255(114cm)=(0,0,128) rgb255(701cm)=(0,128,128) + % rgb255(1000cm)=(128,128,128) rgb255(1299cm)=(255,128,128) + % rgb255(1886cm)=(255,255,128) rgb255(2000cm)=(255,255,255)} + % }, + % /pgfplots/colormap/hicontrast/.style={ + % /pgfplots/colormap={hicontrast}{ + % [1cm]rgb255(0cm)=(0,0,0) rgb255(114cm)=(0,0,255) rgb255(299cm)=(255,0,0) rgb255(413cm)=(255,0,255) + % rgb255(587cm)=(0,255,0) rgb255(701cm)=(0,255,255) rgb255(886cm)=(255,255,0) + % rgb255(1000cm)=(255,255,255)} + % }, + %-------------------------------------------------- + /pgfplots/colormap/spring/.style={ + /pgfplots/colormap={spring}{rgb255=(255,0,255) rgb255=(255,255,0)} + }, + /pgfplots/colormap/summer/.style={ + /pgfplots/colormap={summer}{rgb255=(0,128,102) rgb255=(255,255,102)} + }, + /pgfplots/colormap/temp/.style={ + /pgfplots/colormap={temp}{rgb255=(36,0,217) rgb255=(25,29,247) rgb255=(41,87,255) rgb255=(61,135,255) rgb255=(87,176,255) rgb255=(117,211,255) rgb255=(153,235,255) rgb255=(189,249,255) rgb255=(235,255,255) rgb255=(255,255,235) rgb255=(255,242,189) rgb255=(255,214,153) rgb255=(255,172,117) rgb255=(255,120,87) rgb255=(255,61,61) rgb255=(247,40,54) rgb255=(217,22,48) rgb255=(166,0,33)} + }, + /pgfplots/colormap/thermal/.style={ + /pgfplots/colormap={thermal}{rgb255=(0,0,0) rgb255=(77,0,179) rgb255=(255,51,0) rgb255=(255,255,0) rgb255=(255,255,255)} + }, + /pgfplots/colormap/winter/.style={ + /pgfplots/colormap={winter}{rgb255=(0,0,255) rgb255=(0,255,128)} + }, +} + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex new file mode 100644 index 0000000..55d8da8 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex @@ -0,0 +1,234 @@ +%-------------------------------------------- +% +% Package pgfplots, library for high-level coordinates. +% +% Copyright 2007/2008/2009 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\pgfutil@usemodule{pgfcalendar} + +% Idea: allow +%-------------------------------------------------- +% \begin{tikzpicture} +% \begin{axis}[ +% date coordinates in=x, +% xticklabel={\day.\month.}, +% ] +% \addplot coordinates { +% (2008-01-5, 5) +% (2008-01-12, 10) +% (2008-01-16, 20) +% }; +% \end{axis} +% \end{tikzpicture} +%-------------------------------------------------- + +\def\pgfplotslibdateplot@number@to@julian@and@time#1.#2\julianto#3\hourto#4\minuteto#5{% + #3=#1 + \pgf@xa=0.#2pt + \multiply\pgf@xa by24 + \afterassignment\pgfplots@gobble@until@relax + \c@pgf@countb=\the\pgf@xa\relax + \edef#4{\the\c@pgf@countb}% + \advance\pgf@xa by-#4pt + \multiply\pgf@xa by60 + \afterassignment\pgfplots@gobble@until@relax + \c@pgf@countb=\the\pgf@xa\relax + % round minutes (we may loose precision here) + \advance\pgf@xa by-\the\c@pgf@countb pt + \ifdim\pgf@xa>0.5pt + \advance\c@pgf@countb by1 + \ifnum\c@pgf@countb=60 + \c@pgf@countb=#4 % + \advance\c@pgf@countb by1 + \edef#4{\the\c@pgf@countb}% + \c@pgf@countb=0 + \fi + \fi + \edef#5{\the\c@pgf@countb}% +} + +% #1 the date +% #2 the hours +% #3 the minutes +% #4 is either empty or is the seconds. +% #5 a macro which will be filled with the date part. +% #6 the macro which will contain a number in the range [0,1] +% representing hours and minutes. +% +% If you don't have seconds, you have to provide the second ':' sign +% as dummy! In that case #4 will be empty. +\def\pgfplotslibdateplot@map@time#1 #2:#3:#4\dateto#5\timeto#6{% + \pgf@xa=#2pt + \divide\pgf@xa by24 + \pgf@xb=#3pt + \divide\pgf@xb by1440 + \advance\pgf@xa by\pgf@xb + \ifdim\pgf@xa<0pt + \pgf@xa=0pt + \else + \ifdim\pgf@xa>1pt + \pgf@xa=1pt + \fi + \fi + \def#5{#1}% + \edef#6{\pgf@sys@tonumber\pgf@xa}% +}% +\def\pgfplotslibdateplot@discard@zero@dot 0.#1\to#2{\def#2{#1}}% + +%-------------------------------------------------- +%This here extends it to SECONDS, but the precision is too low +% \def\pgfplotslibdateplot@map@time#1 #2:#3:#4\dateto#5\timeto#6{% +% \pgf@xa=#2pt +% \divide\pgf@xa by24 +% % +% \pgf@xb=#3pt +% \divide\pgf@xb by1440 +% \advance\pgf@xa by\pgf@xb +% % +% \def\pgfplots@loc@TMPc{#4}% +% \ifx\pgfplots@loc@TMPc\pgfutil@empty +% \else +% \edef\pgfplots@loc@TMPc{\pgfplotslibdateplot@discard@trailing@colon #4}% +% \pgf@xb=\pgfplots@loc@TMPc pt +% \divide\pgf@xb by1440 +% \divide\pgf@xb by60 +% \advance\pgf@xa by\pgf@xb +% \fi +% % +% \ifdim\pgf@xa<0pt +% \pgf@xa=0pt +% \else +% \ifdim\pgf@xa>1pt +% \pgf@xa=1pt +% \fi +% \fi +% \def#5{#1}% +% \edef#6{\pgf@sys@tonumber\pgf@xa}% +% }% +% \def\pgfplotslibdateplot@discard@trailing@colon#1:{#1}% +%-------------------------------------------------- + +\pgfplotsset{ + /pgfplots/date ZERO/.code={% + \begingroup + \pgfcalendardatetojulian{#1}\c@pgf@counta + \edef\pgfmathresult{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@calender@ZEROSHIFT=\pgfmathresult + }, + date ZERO=2006-01-01, + /pgfplots/date coordinates in/.code={% + \pgfkeysdef{/pgfplots/#1 coord trafo}{% + \begingroup + \edef\pgfplotstempjuliandate{##1}% + % check if we also have a TIME like '2006-01-01 11:21' + \expandafter\pgfutil@in@\expandafter:\expandafter{\pgfplotstempjuliandate}% + \ifpgfutil@in@ + % we have a TIME! + \expandafter\pgfplotslibdateplot@map@time\pgfplotstempjuliandate:\dateto\pgfplotstempjuliandate\timeto\pgfplotstemptime + \else + \let\pgfplotstemptime=\pgfutil@empty + \fi + \expandafter\pgfcalendardatetojulian\expandafter{\pgfplotstempjuliandate}\c@pgf@counta + \advance\c@pgf@counta by-\pgfplots@calender@ZEROSHIFT\relax + \ifx\pgfplotstemptime\pgfutil@empty + % no time: + \edef\pgfmathresult{\the\c@pgf@counta}% + \else + % add time fraction (which should be in the range + % [0,1]). + \ifdim\pgfplotstemptime pt<1pt + % discard prefix '0.': + \expandafter\pgfplotslibdateplot@discard@zero@dot\pgfplotstemptime\to\pgfplotstemptime + \edef\pgfmathresult{\the\c@pgf@counta.\pgfplotstemptime}% + \else + % assume \pgfplotstemptime=1pt : + \advance\c@pgf@counta by1 + \edef\pgfmathresult{\the\c@pgf@counta}% + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup + }% + \pgfkeysdef{/pgfplots/#1 coord inv trafo}{% + \edef\pgfplotstempjuliandatenumeric{##1}% + \begingroup + \expandafter\pgfplotslibdateplot@number@to@julian@and@time\pgfplotstempjuliandatenumeric\julianto{\c@pgf@counta}\hourto\Hour\minuteto\Minute% + \advance\c@pgf@counta by\pgfplots@calender@ZEROSHIFT\relax + \expandafter\pgfcalendarjuliantodate\expandafter{\the\c@pgf@counta}\year\month\day + \xdef\pgfplotslibdateplot@TMP{% + \noexpand\def\noexpand\year{\year}% + \noexpand\def\noexpand\month{\month}% + \noexpand\def\noexpand\day{\day}% + \noexpand\def\noexpand\Hour{\Hour}% + \noexpand\def\noexpand\Minute{\Minute}% + }% + \endgroup + \pgfplotslibdateplot@TMP + \let\hour=\Hour + \let\minute=\Minute + \ifnum\hour<10 + \edef\hour{0\hour}% + \fi + \ifnum\minute<10 + \edef\minute{0\minute}% + \fi + \def\Second{0}% + \def\second{00}% + \edef\lowlevel{##1}% + \pgfkeysifdefined{/pgfplots/date default inv/#1}{% + \edef\pgfmathresult{\pgfkeysvalueof{/pgfplots/date default inv/#1}}% + }{% + \edef\pgfmathresult{\year-\month-\day\space\hour:\minute:\second}% + }% + }% + \pgfkeysifdefined{/pgfplots/#1ticklabel/.@cmd}{% + \pgfkeysalso{% + /pgfplots/#1ticklabel={\tick},% + /pgfplots/scaled #1 ticks=false,% + /pgfplots/plot coordinates/math parser=false,% + }% + }{% + % OK. The style can be used for other coordinates as well + % (like hist/data) + }% + % + \pgfkeysifdefined{/pgfplots/#1 is expr}{% + \pgfkeyssetvalue{/pgfplots/#1 is expr}{0}% + }{}% + % + % Allow a callback (optional) + \pgfkeysifdefined{/pgfplots/#1/@execute on coord trafo changed/.@cmd}{% + \pgfkeysalso {/pgfplots/#1/@execute on coord trafo changed}% + }{}% + }, + /pgfplots/date coordinates in/.value required, + % + % #1: the argument for 'data coordinates in={#1} + % #2: the default for the inverse transformation. If there is + % none, a default will be chosen automatically (with full + % information) + /pgfplots/date coordinates default inverse/.style 2 args={% + /pgfplots/date default inv/#1/.initial=#2, + }, + /pgfplots/date coordinates default inverse={x}{\year-\month-\day}, + /pgfplots/date coordinates default inverse={y}{\year-\month-\day}, + /pgfplots/date coordinates default inverse={z}{\year-\month-\day}, +} + diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.decorations.softclip.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.decorations.softclip.code.tex new file mode 100644 index 0000000..06b3c62 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.decorations.softclip.code.tex @@ -0,0 +1,36 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2013 by Christian Feuersaenger +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- +% +% This library adds support for a "soft clip" decoration. It applies +% clipping to an input path, but rather than simply instructing the +% display driver to clip the path, it computes a new clip path from +% the input. +% +% This library is (currently) on top of tikz. + +\usetikzlibrary{decorations.softclip} + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex new file mode 100644 index 0000000..41fc81b --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex @@ -0,0 +1,102 @@ +%-------------------------------------------- +% +% Package pgfplots, library for image externalization +% +% Copyright 2007/2008/2009 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +% This file is a wrapper which loads the external library. +% +% If we have a recent pgf version, use its external lib. If not: load +% the copy shipped with pgfplots. +% +% NOTE: +% the external library has been written by Christian Feuersänger as +% part of his work on pgfplots -- since it is general purpose, it is +% part of tikz. A copy comes with pgfplots. +% +% + +% \pgfplots@glob@TMPa = 1 iff we can rely on the external lib shipped +% with tikz: +\pgfplotsiffileexists{tikzlibraryexternal.code.tex}{% + \pgfplots@ifneedspgfcompabitibilitycode@has@pgf@one@zero@zero{% + \def\pgfplots@glob@TMPa{0}% + }{% + \def\pgfplots@glob@TMPa{1}% + }% +}{% + \def\pgfplots@glob@TMPa{0}% +}% + +\def\pgfplots@backw@compat@external@load{% + \immediate\write16{Package pgfplots external lib: loading complementary code for your PGF version...} + % Backwards compatibility: + \let\pgfplots@backw@compat@AtBeginDocument=\AtBeginDocument + \def\AtBeginDocument##1{}% + \input pgfplotsoldpgfsupp_pgfcoreexternal.code.tex + \input pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex + \let\AtBeginDocument=\pgfplots@backw@compat@AtBeginDocument +}% + + +\if1\pgfplots@glob@TMPa + \usetikzlibrary{external}% + \pgfutil@ifundefined{tikzexternal@driver@pgfsys-pdftex.def}{% + \pgfplots@backw@compat@external@load + }{}% +\else + \pgfplots@backw@compat@external@load +\fi + +% This here is a section for patches. +% +% A patch contains software pieces which add individual functionality. +% +% The content is copyright Christian Feuersaenger. I added it to both +% PGF and TikZ such that it can be distributed easily +\expandafter\ifx\csname pgfsys@prepare@papersize\endcsname\relax + \immediate\write16{Package pgfplots external lib: patching system driver code for your PGF version...} + % Patch drivers.... this is needed since recent revisions. + \def\pgfsys@prepare@papersize#1#2{\pgfsys@papersize{#1}{#2}} + \begingroup + \expandafter\def\csname pgfplots@backw@ext@pgfsys-dvips.def\endcsname{% + \gdef\pgfsys@prepare@papersize##1##2{% + \expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument\special{papersize=##1,##2}}% + } + }% + \expandafter\def\csname pgfplots@backw@ext@pgfsys-dvipdfmx.def\endcsname{% + \gdef\pgfsys@prepare@papersize##1##2{% + \expandafter\gdef\expandafter\pgfsys@atbegindocument% + \expandafter{\pgfsys@atbegindocument + \special{papersize=##1,##2}% + } + } + }% + \expandafter\def\csname pgfplots@backw@ext@pgfsys-dvipdfm.def\endcsname{% + \gdef\pgfsys@prepare@papersize##1##2{% + \expandafter\gdef\expandafter\pgfsys@atbegindocument% + \expandafter{\pgfsys@atbegindocument + \special{papersize=##1,##2}% + } + } + }% + \csname pgfplots@backw@ext@\pgfsysdriver\endcsname + \endgroup +\fi + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex new file mode 100644 index 0000000..3c3243a --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex @@ -0,0 +1,187 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2013 by Christian Feuersaenger +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + + +% This library adds support for high-level instructions for "fill area +% between two arbitrary plots of functions". +% +% It activates the syntax +% +% \addplot fill between[of=A and B]; +% +% where A and B are two plots named by 'name path='. +% +% In fact, this here is not much more than a low-level invocation of +% \pgfpathfillbetween +% and a couple of styles. It could become a TikZ library because it +% actually works on any two named paths, but it has its restrictions +% regarding the supported input paths: both need to be plots of +% functions (non-intersecting, should have at most one function value +% for each canvas X coord) + +\pgfutil@IfUndefined{pgfplotsset}{% + \pgferror{Please load pgfplots before pgfplots.fillbetween.}% + \endinput +}{}% + +\usetikzlibrary{fillbetween} +\usepgfplotslibrary{decorations.softclip} + +\pgfkeys{ + /pgfplots/every fill between plot/.style={/pgfplots/area legend,/tikz/fill}, + /tikz/soft clip assign/domain/.code args={#1:#2}{% + \pgfplotsifisvisualizationphase{% + \edef\pgfplots@loc@TMPa{% + (axis cs:#1,\pgfkeysvalueof{/pgfplots/ymin}) + rectangle (axis cs:#2,\pgfkeysvalueof{/pgfplots/ymax})}% + \pgfkeysalso{/tikz/soft clip assign/path/.expand once=\pgfplots@loc@TMPa}% + }{}% + },% + /tikz/soft clip assign/y domain y/.style={/tikz/soft clip assign/domain y={#1}}, + /tikz/soft clip assign/domain y/.code args={#1:#2}{% + \pgfplotsifisvisualizationphase{% + \edef\pgfplots@loc@TMPa{% + (axis cs:\pgfkeysvalueof{/pgfplots/xmin},#1) + rectangle (axis cs:\pgfkeysvalueof{/pgfplots/xmax},#2)}% + \pgfkeysalso{/tikz/soft clip assign/path/.expand once=\pgfplots@loc@TMPa}% + }{}% + },% + % + /pgfplots/execute at begin axis@@/.add={}{% + \gdef\pgfplotsfillbetween@list@of@layers@with@clippath{}% + \gdef\b@pgfplotsfillbetween@list@has@set@layers{0}% + }, +} + +% #1: the value of /tikz/fill between/on layer +\def\pgfplotsfillbetween@ensure@clipping@on@layer{% + \ifpgfplots@clip + \pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots@loc@TMPa + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + % + % check if 'pre main,' is inside of the already prepared layers: + \def\pgfplots@loc@TMPb{\expandafter\pgfutil@in@\expandafter{\pgfplots@loc@TMPa,}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplotsfillbetween@list@of@layers@with@clippath}% + % + \ifpgfutil@in@ + % ah - already prepared. Good, nothing left to do. + \else + \pgfplots@log3{fill between: found 'clip=true'. Preparing pgfplotsextra instruction with clip path for layer '\pgfplots@loc@TMPa'...}% + \xdef\pgfplotsfillbetween@list@of@layers@with@clippath{\pgfplots@loc@TMPa,\pgfplotsfillbetween@list@of@layers@with@clippath}% + % + \edef\pgfplots@loc@TMPb{% + \noexpand\pgfplotsextra{% + \noexpand\pgfplotsonlayer{\pgfplots@loc@TMPa}% + \noexpand\pgfplotspathaxisoutline + \noexpand\pgfusepath{clip}% + \noexpand\endpgfplotsonlayer + }% + }% + \pgfplots@loc@TMPb + % + \fi + \fi +}% + +% The options are from +% \addplot[#1] fill between[#2] #3; +% +% This method is invoked from the global \addplot dispatching. +\def\pgfplotslibraryfillbetween@addplot#1#2#3{% + % + \pgfplots@start@plot@with@behavioroptions{/pgfplots/every fill between plot,#1}% + % + \pgfkeysvalueof{/pgfplots/execute at end survey}% + \pgfplots@remember@survey@option@list + % + % + \pgfplotslibraryfillbetweenpreparecurrentlayer + % + \pgfplots@addplot@enqueue@coords{% + % precmd + }{% + % empty - this here is a TikZ instruction, not a "real" \addplot command + }{% + % the path instruction: + \tikzfillbetween[#2]{% + /pgfplots/.search also=/tikz,% + /pgfplots/.cd,% + /tikz/fill between/every last segment/.append style={/tikz/fill between/path after segment={#3}},% + #1% + }% + }{% + % post command. + }% +} + +% ONLY TO BE USED AS LATER OPTION! +\pgfkeysdef{/pgfplots/fill between/@ensure layers}{% + \ifpgfplots@layered@graphics + \else + \pgfplots@log3{fill between: activating layered graphics}% + \pgfplotsset{set layers}% + \pgfplots@set@options@of@layered@graphics + \fi +}% + +% SIDE-EFFECT: modifies \b@pgfplotsfillbetween@list@has@set@layers and +% \pgfplotsfillbetween@list@of@layers@with@clippath +\def\pgfplotslibraryfillbetweenpreparecurrentlayer{% + \pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \if0\b@pgfplotsfillbetween@list@has@set@layers + % + \pgfplotssetlateoptions{fill between/@ensure layers}% + \gdef\b@pgfplotsfillbetween@list@has@set@layers{1}% + \fi + \pgfplotsfillbetween@ensure@clipping@on@layer% + \fi +} + +\def\pgfplots@tikzfillbetween{\pgfutil@ifnextchar[{\pgfplots@tikzfillbetween@opt}{\pgfplots@tikzfillbetween@opt[]}} +\def\pgfplots@tikzfillbetween@opt[#1]#2{% + \pgfplots@addplot@enqueue@coords{% + % precmd + }{% + % empty - this here is a TikZ instruction, not a "real" \addplot command + }{% + % the path instruction: + \tikzfillbetween[#1]{#2}% + }{% + % post command. + }% +}% + +\expandafter\def\expandafter\pgfplots@replace@path@commands\expandafter{\pgfplots@replace@path@commands + \let\pgfplots@orig@tikzfillbetween=\tikzfillbetween + \let\tikzfillbetween=\pgfplots@tikzfillbetween +}% +\expandafter\def\expandafter\pgfplots@restore@path@commands\expandafter{\pgfplots@restore@path@commands + \let\tikzfillbetween=\pgfplots@orig@tikzfillbetween +} + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex new file mode 100644 index 0000000..74f7cd5 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex @@ -0,0 +1,494 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2009 by Nick Papior Andersen. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\newif\ifpgfplots@group@sharedlabels + +\def\pgfplots@group@xticklabels{} +\def\pgfplots@group@yticklabels{} +\def\pgfplots@group@xlabels{} +\def\pgfplots@group@ylabels{} +\def\pgfplots@group@totalplots{1} +\def\pgfplots@group@columns{1} +\def\pgfplots@group@rows{1} +\def\pgfplots@group@name{group} +\def\pgfplots@group@style{} +\gdef\pgfplots@group@rmopts{} +\newcount\pgfplots@group@current@plot +\newcount\pgfplots@group@current@row +\newcount\pgfplots@group@current@column + +\usetikzlibrary{calc} + +\pgfkeys{ + /pgfplots/group/.is family, + /pgfplots/group style/.store in=\pgfplots@group@style, + /pgfplots/group/horizontal sep/.initial=1cm, + /pgfplots/group/vertical sep/.initial=1cm, + /pgfplots/group/group size/.style args={#1 by #2}{/pgfplots/group/columns=#1,/pgfplots/group/rows=#2}, + /pgfplots/group/group size/.default={1 by 1}, + /pgfplots/group/columns/.store in=\pgfplots@group@columns, + /pgfplots/group/rows/.store in=\pgfplots@group@rows, + /pgfplots/group/every plot/.style=, + /pgfplots/group/shared labels/.is if=pgfplots@group@sharedlabels, + /pgfplots/group/shared labels=false, + /pgfplots/group/xticklabels at/.is choice, + /pgfplots/group/xticklabels at/all/.code=\def\pgfplots@group@xticklabels{all}, + /pgfplots/group/xticklabels at/edge top/.code=\def\pgfplots@group@xticklabels{top}, + /pgfplots/group/xticklabels at/edge bottom/.code=\def\pgfplots@group@xticklabels{lower}, + /pgfplots/group/xticklabels at/edge left/.code=\def\pgfplots@group@xticklabels{left}, % TODO + /pgfplots/group/xticklabels at/edge right/.code=\def\pgfplots@group@xticklabels{right}, % TODO + /pgfplots/group/xticklabels at=all, + /pgfplots/group/yticklabels at/.is choice, + /pgfplots/group/yticklabels at/all/.code=\def\pgfplots@group@yticklabels{all}, + /pgfplots/group/yticklabels at/edge left/.code=\def\pgfplots@group@yticklabels{left}, + /pgfplots/group/yticklabels at/edge right/.code=\def\pgfplots@group@yticklabels{right}, + /pgfplots/group/yticklabels at/edge top/.code=\def\pgfplots@group@yticklabels{top}, % TODO + /pgfplots/group/yticklabels at/edge bottom/.code=\def\pgfplots@group@yticklabels{bottom}, % TODO + /pgfplots/group/yticklabels at=all, + /pgfplots/group/xlabels at/.is choice, + /pgfplots/group/xlabels at/all/.code=\def\pgfplots@group@xlabels{all}, + /pgfplots/group/xlabels at/edge top/.code=\def\pgfplots@group@xlabels{top}, + /pgfplots/group/xlabels at/edge bottom/.code=\def\pgfplots@group@xlabels{lower}, + /pgfplots/group/xlabels at/edge right/.code=\def\pgfplots@group@xlabels{right}, % TODO + /pgfplots/group/xlabels at/edge left/.code=\def\pgfplots@group@xlabels{left},% TODO + /pgfplots/group/xlabels at=all, + /pgfplots/group/ylabels at/.is choice, + /pgfplots/group/ylabels at/all/.code=\def\pgfplots@group@ylabels{all}, + /pgfplots/group/ylabels at/edge left/.code=\def\pgfplots@group@ylabels{left}, + /pgfplots/group/ylabels at/edge right/.code=\def\pgfplots@group@ylabels{right}, + /pgfplots/group/ylabels at/edge top/.code=\def\pgfplots@group@ylabels{top}, % TODO + /pgfplots/group/ylabels at/edge bottom/.code=\def\pgfplots@group@ylabels{bottom}, % TODO + /pgfplots/group/ylabels at=all, + /pgfplots/group/x descriptions at/.is choice, + /pgfplots/group/x descriptions at/all/.style={ + /pgfplots/group/xlabels at=all, + /pgfplots/group/xticklabels at=all + }, + /pgfplots/group/x descriptions at/edge bottom/.style={ + /pgfplots/group/xlabels at=edge bottom, + /pgfplots/group/xticklabels at=edge bottom + }, + /pgfplots/group/x descriptions at/edge top/.style={ + /pgfplots/group/xlabels at=edge top, + /pgfplots/group/xticklabels at=edge top + }, + /pgfplots/group/y descriptions at/.is choice, + /pgfplots/group/y descriptions at/all/.style={ + /pgfplots/group/ylabels at=all, + /pgfplots/group/yticklabels at=all + }, + /pgfplots/group/y descriptions at/edge left/.style={ + /pgfplots/group/ylabels at=edge left, + /pgfplots/group/yticklabels at=edge left + }, + /pgfplots/group/y descriptions at/edge right/.style={ + /pgfplots/group/ylabels at=edge right, + /pgfplots/group/yticklabels at=edge right + }, + /pgfplots/group/group name/.store in=\pgfplots@group@name, + /pgfplots/group/empty plot/.style={/pgfplots/hide axis=true}, + /pgfplots/trim axis group left/.code={% + \pgfutil@ifundefined{pgfsettrimleft}{% + \pgfplots@error{Sorry, the 'trim axis group left' requires a more recent PGF version.}% + }{% + \pgfkeysalso{/tikz/trim left={(group c1r1.south west)}}% + }% + },% + /tikz/trim axis group left/.style={/pgfplots/trim axis group left}, + /pgfplots/trim axis group right/.code={% + \pgfutil@ifundefined{pgfsettrimleft}{% + \pgfplots@error{Sorry, the 'trim axis group right' requires a more recent PGF version.}% + }{% + \pgfkeysalso{/pgfplots/trim axis right}% + }% + },% + /tikz/trim axis group right/.style={/pgfplots/trim axis group right}, +} +\pgfkeys{ + /pgfplots/warning/groupplots/too many plots/.code 2 args={% + \pgfplotsthrow@warning{You are adding more plots than you specified, current plots=#1\space vs. total allowed + plots=#2.}% + }, +} + +\def\nextgroupplot{% + \pgfutil@ifnextchar[{\pgfplots@group@nextplot}{\pgfplots@group@nextplot[]}%} +} + +% +% The actual addition of the new plots +% +\def\pgfplots@group@nextplot[#1]{% + % Check if it legal to produce another plot + \ifnum\pgfplots@group@current@plot=\pgfplots@group@totalplots\relax + \pgfplotswarning{groupplots/too many plots}{\the\pgfplots@group@current@plot}{\pgfplots@group@totalplots}\pgfeov + \else + % + % If there has been other plots before then end the plot + % + \ifnum0<\pgfplots@group@current@plot\relax + % DEBUG: \message{DEBUG: Ending plot} + \endpgfplots@environment@opt + \fi + % Prepare for next plot, increment plot, row and column + \pgfplots@group@increment@numbers + % DEBUG: \message{DEBUG: Cur. Plot: \the\pgfplots@group@current@plot. Current Row: \the\pgfplots@group@current@row. Current Column: \the\pgfplots@group@current@column.} + % Creation of the new axis environment + \pgfplots@group@environment@create{#1} + \fi +} +% +% This creates an environment according to which plots that have been typeset. +% The code utilizes previous plots anchor points to position themselves, unless it's the +% first plot. +% Using the figure below to describe the code implementation: +% ____ ____ ____ +%| | | | | | +%| 1 | | 2 | | 3 | +%|___| |___| |___| +% ____ ____ ____ +%| | | | | | +%| 4 | | 5 | | 6 | +%|___| |___| |___| +% ____ ____ ____ +%| | | | | | +%| 7 | | 8 | | 9 | +%|___| |___| |___| +% +% The plots anchors are as follows: +% 1: plot is typeset normally +% 2: the "1" plot anchor "east" is anchored to "west" +% 3: the "2" plot anchor "east" is anchored to "west" +% 4: the "1" plot anchor "south" is anchored to "north" +% 5: the "2" plot anchor "south" is anchored to "north" +% 6: the "3" plot anchor "south" is anchored to "north" +% 7: the "4" plot anchor "south" is anchored to "north" +% 8: the "5" plot anchor "south" is anchored to "north" +% 9: the "6" plot anchor "south" is anchored to "north" +% +\def\pgfplots@group@environment@create#1{% + \ifnum1=\pgfplots@group@current@row\relax + \ifnum1=\pgfplots@group@current@column\relax + \pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% + /pgfplots/group/every plot,% + /pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% + #1] + \else + \pgfplotsgroupplotsmath@decrease\pgfplots@group@current@column + \xdef\pgfplots@glob@TMPb{\pgfplots@group@name\space c\pgfmathresult r\the\pgfplots@group@current@row} + \pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% + /pgfplots/group/every plot,% + /pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% + at={($(\pgfplots@glob@TMPb.east)+(\pgfkeysvalueof{/pgfplots/group/horizontal sep},0)$)},anchor=west,% + #1] + \fi + \else + \pgfplotsgroupplotsmath@decrease\pgfplots@group@current@row + \xdef\pgfplots@glob@TMPb{\pgfplots@group@name\space c\the\pgfplots@group@current@column r\pgfmathresult} + \pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% + /pgfplots/group/every plot,% + /pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% + at={($(\pgfplots@glob@TMPb.south)-(0,\pgfkeysvalueof{/pgfplots/group/vertical sep})$)},anchor=north,% + #1]% + \fi% +} + +% +% Determine the labels of both x and y. +% +\def\pgfplots@group@determine@labels{% + \def\pgfplots@loc@TMPa{all} + \def\pgfplots@loc@TMPb{lower} + \ifx\pgfplots@loc@TMPa\pgfplots@group@xlabels% + % xlabels at=all + % Do nothing as all should have xlabels + \fi + \gdef\pgfplots@glob@TMPa{} + \ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels% + % xlabels at=lower + \ifnum1<\pgfplots@group@rows\relax + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \ifnum\pgfplots@row=\pgfplots@group@rows\relax% + \else + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xlabel={}}}% + \fi + }% + }% + \fi% + \else + \def\pgfplots@loc@TMPb{top}% + \ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels% + % xlabels at=top + \ifnum1<\pgfplots@group@rows\relax + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \ifnum\pgfplots@row=1 % + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xticklabel pos=upper}}% + \else + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xlabel={}}}% + \fi + }% + }% + \fi% + \fi + \fi + % + % Defining styles for the y's + % + \ifx\pgfplots@loc@TMPa\pgfplots@group@ylabels% + % ylabels at=all + % Do nothing as all should have ylabels + \else + \def\pgfplots@loc@TMPb{left}% + \ifx\pgfplots@loc@TMPb\pgfplots@group@ylabels% + % ylabels at=left + \ifnum1<\pgfplots@group@columns\relax + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \foreach \pgfplots@column in {2,...,\pgfplots@group@columns} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/ylabel={}}}% + }% + }% + \fi% + \else + \def\pgfplots@loc@TMPb{right}% + \ifx\pgfplots@loc@TMPb\pgfplots@group@ylabels% + % ylabels at=right + \ifnum1<\pgfplots@group@columns\relax + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \ifnum\pgfplots@column=\pgfplots@group@columns\relax + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/yticklabel pos=upper}}% + \else + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/ylabel={}}}% + \fi + }% + }% + \fi + \fi% + \fi + \fi + \expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa} +} + +% +% Determine the ticklabels of both x and y. +% +\def\pgfplots@group@determine@ticklabels{% + \def\pgfplots@loc@TMPa{all} + \def\pgfplots@loc@TMPb{top} + \def\pgfplots@loc@TMPc{lower} + \ifx\pgfplots@loc@TMPa\pgfplots@group@xticklabels% + % Do nothing as all should have xticklabels + \fi + \gdef\pgfplots@glob@TMPa{} + \ifx\pgfplots@loc@TMPb\pgfplots@group@xticklabels% + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r1/.append style={xticklabel pos=upper}}% + \ifnum1<\pgfplots@group@rows\relax + \foreach \pgfplots@row in {2,...,\pgfplots@group@rows} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xticklabels={}}}% + }% + \fi% + }% + \fi + \ifx\pgfplots@loc@TMPc\pgfplots@group@xticklabels% + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@group@rows/.append style={xticklabel pos=lower}}% + \ifnum1<\pgfplots@group@rows\relax + \pgfplotsgroupplotsmath@decrease\pgfplots@group@rows + \foreach \pgfplots@row in {1,...,\pgfmathresult} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xticklabels={}}}% + }% + \fi% + }% + \fi% + % + % Defining styles for the ytick's + % + \def\pgfplots@loc@TMPb{left} + \def\pgfplots@loc@TMPc{right} + \ifx\pgfplots@loc@TMPa\pgfplots@group@yticklabels% + % Do nothing as all should have yticklabels + \fi + \ifx\pgfplots@loc@TMPb\pgfplots@group@yticklabels% + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c1r\pgfplots@row/.append style={yticklabel pos=left}}% + \ifnum1<\pgfplots@group@columns\relax + \foreach \pgfplots@column in {2,...,\pgfplots@group@columns} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/yticklabels={}}}% + }% + \fi% + }% + \fi + \ifx\pgfplots@loc@TMPc\pgfplots@group@yticklabels% + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@group@columns r\pgfplots@row/.append style={yticklabel pos=right}}% + \ifnum1<\pgfplots@group@columns\relax + \pgfplotsgroupplotsmath@decrease\pgfplots@group@columns + \foreach \pgfplots@column in {1,...,\pgfmathresult} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/yticklabels={}}}% + }% + \fi% + }% + \fi% + \expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa} +} + +% +% The counters which are used to determine the current plot: +% \pgfplots@group@current@plot +% \pgfplots@group@current@column +% \pgfplots@group@current@row +% gets incremented according to the scheme below: +% ____ ____ ____ +%| | | | | | +%| 1 | | 2 | | 3 | +%|___| |___| |___| +% ____ ____ ____ +%| | | | | | +%| 4 | | 5 | | 6 | +%|___| |___| |___| +% ____ ____ ____ +%| | | | | | +%| 7 | | 8 | | 9 | +%|___| |___| |___| +% where the number matches the plot number. +% +\def\pgfplots@group@increment@numbers{% + \advance\pgfplots@group@current@plot by1 + \ifnum\pgfplots@group@current@column=\pgfplots@group@columns\relax + \ifnum1=\pgfplots@group@current@plot\relax + \else + \advance\pgfplots@group@current@row by1 + \fi + \pgfplots@group@current@column=1 + \else + \advance\pgfplots@group@current@column by1 + \fi +} + +\def\pgfplots@group@get@plot@name#1,#2\in#3{% + \edef#3{c#1r#2}% +} + + +% +% Setting up all possible styles in current plot +% I.e. Setting: +% /pgfplots/group/plot c1r1/.style= +% /pgfplots/group/plot c2r1/.style= +% ... +% /pgfplots/group/plot cr/.style= +% +\def\pgfplots@group@individual@setup{% + \gdef\pgfplots@glob@TMPa{} + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.style=}% + }% + }% + \expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa}% +} + + + +% +% Implementation of the environment {groupplots} +\def\pgfplots@environment@groupplot{% + \pgfutil@ifnextchar[{\pgfplots@@environment@groupplot}{\pgfplots@@environment@groupplot[\pgfutil@empty]}% +} + +\def\endpgfplots@environment@groupplot{\endpgfplots@environment@opt\endgroup} + +\def\pgfplots@@environment@groupplot[#1]{% + \begingroup% + % Only find the keys column and row + % the following things appear to be complete... ? + \pgfkeysinstallkeyfilterhandler{/pgf/key filter handlers/append filtered to}{\pgfplots@group@rmopts}% + \let\pgfplots@group@rmopts=\pgfutil@empty + \pgfkeysinstallkeyfilter{/pgf/key filters/equals}{/pgfplots/group style} + \pgfkeysinstallkeyfilter{/pgf/key filters/is descendant of}{/pgfplots/group} + \pgfqkeysfiltered{/pgfplots}{#1} + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfkeys{/pgfplots/group/.cd,\pgfplots@group@style} + }\pgfplots@loc@TMPa + % + \let\pgfplots@set@options@sanitizemode@old=\pgfplots@set@options@sanitizemode + \let\pgfplots@set@options@sanitize@old=\pgfplots@set@options@sanitize + \let\pgfplots@set@options@sanitize=\relax + \let\pgfplots@set@options@sanitizemode=\relax + \expandafter\pgfplots@set@options\expandafter{\pgfplots@group@rmopts} + \let\pgfplots@set@options@sanitize=\pgfplots@set@options@sanitize@old + \let\pgfplots@set@options@sanitizemode=\pgfplots@set@options@sanitizemode@old + % + \pgfplots@group@individual@setup + \pgfplots@group@determine@ticklabels + \pgfplots@group@determine@labels + \pgfplots@group@current@plot=0% + \pgfplots@group@current@row=1% + \pgfplots@group@current@column=0% + \begingroup + \c@pgf@counta=\pgfplots@group@rows\relax + \multiply \c@pgf@counta by\pgfplots@group@columns\relax + \edef\pgfmathresult{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \edef\pgfplots@group@totalplots{\pgfmathresult}% + %DEBUG: \message{TEST: \pgfplots@group@totalplots, rows=\pgfplots@group@rows, columns=\pgfplots@group@columns}% +} + +% Assigns \pgfmathresult as #1-1 (in integer arithmetics) +% +% #1 an integer (a register or something which expands to an integer). +\def\pgfplotsgroupplotsmath@decrease#1{% + \begingroup + \c@pgf@counta=#1\relax + \advance\c@pgf@counta by-1 + \edef\pgfmathresult{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\tikzaddtikzonlycommandshortcutlet\groupplot\pgfplots@environment@groupplot +\tikzaddtikzonlycommandshortcutlet\endgroupplot\endpgfplots@environment@groupplot + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex new file mode 100644 index 0000000..9e885f3 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex @@ -0,0 +1,2722 @@ +%-------------------------------------------- +% +% Package pgfplots, library for higher order patch plots. +% It contains advanced patch plots like quadratic triangles, +% biquadratic quadrilaterals, coons patches and others. +% The basic implementation for patches supports already line, triangle +% and rectangle (=2 triangles) patches. +% +% Copyright 2007/2008/2009 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + + % NOTES: + % In general, a Bezier spline C:[0,1] -> \R of order n fulfills + % C'(0) = n ( P_1 - P_0 ), + % C'(1) = n ( P_n - P_{n-1} ). + % For n=3 and given P_0 and P_3, I can directly compute P_1 and P_2 once I know + % the derivatives at t=0 and t=1. + % + % + % +%-------------------------------------------------- +% 4-point Lagrange interpolation on {0,1/3,2/3,1}: +% C(x) = +% a * (1/3 - x)/(1/3) * (2/3-x)/(2/3) * (1-x) + +% b * (0 - x)/(0 - 1/3) * (2/3-x)/(2/3-1/3) * (1-x)/(1-1/3) + +% c * (0 - x)/(0 - 2/3) * (1/3-x)/(1/3-2/3) * (1-x)/(1-2/3) + +% d * (0 - x)/(0 - 1) * (1/3-x)/(1/3-1) * (2/3-x) /(2/3-1) +% +% +% Derivative: +% +% (-9*c + 2*d + 72*c*x - 18*d*x - 81*c*x^2 + 27*d*x^2 + +% a*(-11 + 36*x - 27*x^2) + 9*b*(2 - 10*x + 9*x^2))/2 +% +% bezier control points are +% P1 = (-5*a)/6 + 3*b - (3*c)/2 + d/3 +% = -0.833333 a + 3. b - 1.5 c + 0.333333 d +% +% P2 = 0.333333 (0.5 (2. a - 9. b + 18. c - 11. d) + 3. d) +% = 0.333333 a - 1.5 b + 3. c - 0.833333 d +%-------------------------------------------------- + + + +% A quadratic spline in the ordering +% +% +% +% where is the function value at the left end of the spline +% segmment, the function value at the right end, and +% the function value in the middle of the spline segment. +\pgfplotsdeclarepatchclass{quadratic spline}{% + get dimension=\def\pgfplotsretval{1}, + supports global path=\def\pgfplotsretval{1}, + new=\def\pgfplotspatchclass@qspline@no{A}, + set next vertex={% + % EXPECTED ORDERING: first 2 corners, then 1 mid nodes + % (interpolatory). + % defines \pgfplotspatchclass@qspline@A ... \pgfplotspatchclass@qspline@C (3 points) + \expandafter\edef\csname pgfplotspatchclass@qspline@\pgfplotspatchclass@qspline@no\endcsname{#1}% + \if C\pgfplotspatchclass@qspline@no + \def\pgfplotspatchclass@qspline@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@qspline@no\csname pgfpptchindexnext@\pgfplotspatchclass@qspline@no\endcsname + \fi + }, + if current point can be first last={% + \pgfplots@loc@tmptrue + \if A\pgfplotspatchclass@qspline@no + % Ah - the current point is the 'C' point, i.e. the + % control point (we have advanced the '@no' counter) + \pgfplots@loc@tmpfalse + \fi + \ifpgfplots@loc@tmp + #1\relax% + \else + #2\relax + \fi + }, + sample in unit cube={% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{0.5}% + \def\pgfplotspatchclassy{0}% + #1% + \pgfplotspatchready + },% + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@C\endvertex #1% + }, + fill path={% + \begingroup + % Draw the patch boundary using a bezier curves. + % + % Since I have lagrange points to describe the patch (i.e. + % points the patch passes through), I have to convert the + % lagrange representation to bezier. + % + % Furthermore, I convert to *cubic* bezier since pdf only + % supports cubic curves. + % + % See the docs for 'biquadratic::fill path' for more details, + % in does the same. + \def\pgfplots@edge{% + \ifx\pgfplotspatchclass@qspline@A\PA + \pgfplotsplothandlermesh@pathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}% + \fi + \pgfpathcurveto {% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{% + \expandafter\pgfplotspointpatchvertex\PC\endvertex + }% + }% + \let\PA=\pgfplotspatchclass@qspline@A + \let\PB=\pgfplotspatchclass@qspline@C + \let\PC=\pgfplotspatchclass@qspline@B + \pgfplots@edge + \pgfplotsplothandlermesh@setlastpoint{\expandafter\pgfplotspointpatchvertex\PC\endvertex}% + \endgroup + }, + triangulate class=\def\pgfplotsretval{line}, + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{line}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@B}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + recursive refine@={% + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@C\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qspline@AC + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@AC}% + #1% + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@C\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qspline@CB + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@CB}% + #1% + % + },% + get pdf shading type=0, + get num vertices=\def\pgfplotsretval{3}, +}% + +\pgfplotsdeclarepatchclass{cubic spline}{% + get dimension=\def\pgfplotsretval{1}, + supports global path=\def\pgfplotsretval{1}, + new=\def\pgfplotspatchclass@cspline@no{A}, + set next vertex={% + % EXPECTED ORDERING: first 2 corners, then 1 mid nodes + % (interpolatory). + % defines \pgfplotspatchclass@cspline@A ... \pgfplotspatchclass@cspline@D (4 points) + \expandafter\edef\csname pgfplotspatchclass@cspline@\pgfplotspatchclass@cspline@no\endcsname{#1}% + \if D\pgfplotspatchclass@cspline@no + \def\pgfplotspatchclass@cspline@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@cspline@no\csname pgfpptchindexnext@\pgfplotspatchclass@cspline@no\endcsname + \fi + }, + if current point can be first last={% + \pgfplots@loc@tmpfalse + \if B\pgfplotspatchclass@cspline@no + % Ah - the current point is the 'A' point (we have + % advanced the '@no' counter) + \pgfplots@loc@tmptrue + \fi + \if C\pgfplotspatchclass@cspline@no + % Ah - the current point is the 'B' point (we have + % advanced the '@no' counter) + \pgfplots@loc@tmptrue + \fi + \ifpgfplots@loc@tmp + #1\relax% + \else + #2\relax + \fi + }, + sample in unit cube={% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{0.3333333}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{0.6666666}% + \def\pgfplotspatchclassy{0}% + #1% + \pgfplotspatchready + },% + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@D\endvertex #1% + }, + fill path={% + % Draw the patch boundary using a bezier curve. + \pgfplotsplothandlermesh@pathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@cspline@A\endvertex}% + \pgfplotspathcubicfrominterpolation + {\pgfplotspatchclass@cspline@A}% + {\pgfplotspatchclass@cspline@C}% + {\pgfplotspatchclass@cspline@D}% + {\pgfplotspatchclass@cspline@B}% + \pgfplotsplothandlermesh@setlastpoint{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@cspline@B\endvertex}% + }, + triangulate class=\def\pgfplotsretval{line}, + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{line}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@B}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + recursive refine@={% + % The 4-point lagrangian interpolation formular is shown on + % the top of this page. What I do here is simply to evaluate + % C(i*1/9) for i =0,...,9: + % 0 + % 0.493827 A +0.740741 C -0.296296 D +0.0617284 B + % 0.17284 A +1.03704 C -0.259259 D +0.0493827 B + % 1/3 + % -0.0617284 A +0.740741 C +0.37037 D -0.0493827 B + % -0.0493827 A +0.37037 C +0.740741 D -0.0617284 B + % 2/3 + % 0.0493827 A -0.259259 C +1.03704 D +0.17284 B + % 0.0617284 A -0.296296 C +0.740741 D +0.493827 B + % 1 + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.0617284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.740741}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{-0.296296}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.17284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.0493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{1.03704}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{-0.259259}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}% + #1% + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{-0.0617284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{-0.0493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.740741}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.37037}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{-0.0493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{-0.0617284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.37037}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.740741}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}% + #1% + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.0493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.17284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{-0.259259}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{+1.03704}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.0617284}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.493827}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{-0.296296}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.740741}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}% + #1% + }, + get pdf shading type=0, + get num vertices=\def\pgfplotsretval{4}, +}% + +\def\pgfplotspathcubicfrominterpolation#1#2#3#4{% + % switch basis from lagrange to bezier (see formular on top of + % this file) + \pgfpathcurveto {% + \begingroup + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY#1\times{-0.833333}% + \expandafter\pgfplotspatchvertexaddXY#2\times{3}% + \expandafter\pgfplotspatchvertexaddXY#3\times{-1.5}% + \expandafter\pgfplotspatchvertexaddXY#4\times{0.3333333}% + \pgfplotspatchvertexfinish\pgfplots@loc@TMPa + \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex + \endgroup + }{% + \begingroup + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY#1\times{0.333333}% + \expandafter\pgfplotspatchvertexaddXY#2\times{-1.5}% + \expandafter\pgfplotspatchvertexaddXY#3\times{3}% + \expandafter\pgfplotspatchvertexaddXY#4\times{-0.833333}% + \pgfplotspatchvertexfinish\pgfplots@loc@TMPa + \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex + \endgroup + }{% + \expandafter\pgfplotspointpatchvertex#4\endvertex + }% +}% + +% make a linearized sequence around the edge of the quad.triangle. +% note the ordering: first 3 corners, then 3 mid nodes: +\def\pgfplots@qtri@next@A{D}% +\def\pgfplots@qtri@next@B{E}% +\def\pgfplots@qtri@next@C{F}% +\def\pgfplots@qtri@next@D{B}% +\def\pgfplots@qtri@next@E{C}% +\def\pgfplots@qtri@next@F{A}% + +\def\pgfplots@qtri@rnext@A{F}% +\def\pgfplots@qtri@rnext@B{D}% +\def\pgfplots@qtri@rnext@C{E}% +\def\pgfplots@qtri@rnext@D{A}% +\def\pgfplots@qtri@rnext@E{B}% +\def\pgfplots@qtri@rnext@F{C}% + +\def\pgfplotspatchclass@qtri@recursiverefine@newnames{% + \let\pgfplotspatchclass@qtri@A@=\pgfplotspatchclass@qtri@A% + \let\pgfplotspatchclass@qtri@B@=\pgfplotspatchclass@qtri@B% + \let\pgfplotspatchclass@qtri@C@=\pgfplotspatchclass@qtri@C% + \let\pgfplotspatchclass@qtri@D@=\pgfplotspatchclass@qtri@D% + \let\pgfplotspatchclass@qtri@E@=\pgfplotspatchclass@qtri@E% + \let\pgfplotspatchclass@qtri@F@=\pgfplotspatchclass@qtri@F% +}% + + +% A 3-point interpolatory patch which draws quadratic polynomial +% splines (functions f(x), x 1d). +\pgfplotsdeclarepatchclass{triangle quadr}{% + uses view depth=\def\pgfplotsretval{1},% used by the shader: we reorder corners. + new=\def\pgfplotspatchclass@qtri@no{A}\let\pgfplotspatchclass@qtrie@AB\relax, + set next vertex={% + % EXPECTED ORDERING: first 3 corners, then 3 mid nodes. + % defines \pgfplotspatchclass@qtri@A ... \pgfplotspatchclass@qtri@F (6 points) + \expandafter\edef\csname pgfplotspatchclass@qtri@\pgfplotspatchclass@qtri@no\endcsname{#1}% + \if F\pgfplotspatchclass@qtri@no + \def\pgfplotspatchclass@qtri@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@qtri@no\csname pgfpptchindexnext@\pgfplotspatchclass@qtri@no\endcsname + \fi + }, + sample in unit cube={% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{1}% + #1% + % + \def\pgfplotspatchclassx{0.5}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{0.5}% + \def\pgfplotspatchclassy{0.5}% + #1% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0.5}% + #1% + \pgfplotspatchready + % + % + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{1}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{1}% + #1% + % + \def\pgfplotspatchclassx{0.5}% + \def\pgfplotspatchclassy{0.5}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0.5}% + #1% + \def\pgfplotspatchclassx{0.5}% + \def\pgfplotspatchclassy{1}% + #1% + \pgfplotspatchready + },% + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@E\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@F\endvertex #1% + }, + foreach cdata vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@C\endvertex #1% + }, + fill path={% + \begingroup + % Draw the patch boundary using three bezier curves. + % + % Since I have lagrange points to describe the patch (i.e. + % points the patch passes through), I have to convert the + % lagrange representation to bezier. + % + % Furthermore, I convert to *cubic* bezier since pdf only + % supports cubic curves. + % + % See the docs for 'biquadratic::fill path' for more details, + % in does the same. + \def\pgfplots@edge{% + \ifx\pgfplotspatchclass@qtri@A\PA + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}% + \fi + \pgfpathcurveto {% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{% + \expandafter\pgfplotspointpatchvertex\PC\endvertex + }% + }% + \let\PA=\pgfplotspatchclass@qtri@A + \let\PB=\pgfplotspatchclass@qtri@D + \let\PC=\pgfplotspatchclass@qtri@B + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@qtri@B + \let\PB=\pgfplotspatchclass@qtri@E + \let\PC=\pgfplotspatchclass@qtri@C + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@qtri@C + \let\PB=\pgfplotspatchclass@qtri@F + \let\PC=\pgfplotspatchclass@qtri@A + \pgfplots@edge + \endgroup + \pgfpathclose + }, + %-------------------------------------------------- + % stroke path={% + % \ifx\pgfplotspatchclass@qtrie@AB\relax + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}% + % \pgfpathclose + % \else + % \if1\pgfplotspatchclass@qtrie@AB + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}% + % \fi + % \if1\pgfplotspatchclass@qtrie@BC + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}% + % \fi + % \if1\pgfplotspatchclass@qtrie@CA + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}% + % \fi + % \fi + % }, + %-------------------------------------------------- + stream to shader={% + % create a degenerate coons patch: + \begingroup +%\message{EDGE INIT^^J}% + % this defines \Pcur and \Pnextseq : + \pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth + % + \pgfutil@namelet{Pstart}{pgfplotspatchclass@qtri@\Pcur}% + % + % see the docus for "fill path" about these 1.33333 and -0.33333 factors + \def\pgfplots@coonsedge{% +%\message{EDGE \Pcur^^J}% + \expandafter\let\expandafter\PA\csname pgfplotspatchclass@qtri@\Pcur\endcsname + \edef\Pcur{\csname pgfplots@qtri@\Pnextseq next@\Pcur\endcsname}% +%\message{---> \Pcur^^J}% + \expandafter\let\expandafter\PB\csname pgfplotspatchclass@qtri@\Pcur\endcsname + \edef\Pcur{\csname pgfplots@qtri@\Pnextseq next@\Pcur\endcsname}% +%\message{---> \Pcur^^J}% + \expandafter\let\expandafter\PC\csname pgfplotspatchclass@qtri@\Pcur\endcsname + \ifx\PA\Pstart + \expandafter\pgfplotspatchvertex\PA\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + % degenerate: the "edge" \PA -- \PA collabses into one + % point. + % Per construction, the "edge" is the FOREGROUND. +%\message{STREAMING COLLAPSED EDGE AT START POINT^^J}% + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{}% + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{}% + \ifx\PC\Pstart + \else + \expandafter\pgfplotspatchvertex\PC\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + }% + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + % + \endgroup + },% + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{triangle}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}11% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20% + % Ok. Now create 4 triangles. The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}% + % + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}00% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}% + % + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}11% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + set edge visible={% + \ifcase#1 + \edef\pgfplotspatchclass@qtrie@AB{#2}% + \or + \edef\pgfplotspatchclass@qtrie@BC{#2}% + \or + \edef\pgfplotspatchclass@qtrie@CA{#2}% + \fi + }, + serialize except vertices={% + \ifx\pgfplotspatchclass@qtrie@AB\relax + \let\pgfplotsretval\pgfutil@empty% + \else + \edef\pgfplotsretval{% + \noexpand\def\noexpand\pgfplotspatchclass@qtrie@AB{\pgfplotspatchclass@qtrie@AB}% + \noexpand\def\noexpand\pgfplotspatchclass@qtrie@BC{\pgfplotspatchclass@qtrie@BC}% + \noexpand\def\noexpand\pgfplotspatchclass@qtrie@CA{\pgfplotspatchclass@qtrie@CA}% + }% + \fi + },% + deserialize except vertices=% + \let\pgfplotspatchclass@qtrie@AB\relax + #1, + recursive refine@={% + \pgfplotspatchclass@qtri@recursiverefine@newnames + % + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + %-------------------------------------------------- + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20% + %-------------------------------------------------- + % The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + % + % I used the reference triangle and shape functions as listed in + % http://www.colorado.edu/engineering/CAS/courses.d/IFEM.d/ + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@AD + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DF + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@AF + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@A@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@AF}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@AD}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DF}% + % + #1\pgfplotspatchclass@qtri@recursiverefine@newnames + % + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DF + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.25}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DE + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EF + % + % + %-------------------------------------------------- + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}00% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}10% + %-------------------------------------------------- + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DF}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DE}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EF}% + % % + % %-------------------------------------------------- + % % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01% + % % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11% + % %-------------------------------------------------- + #1\pgfplotspatchclass@qtri@recursiverefine@newnames + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.25}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DE + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@BE + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@B@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DB}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@BE}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DE}% + % + #1\pgfplotspatchclass@qtri@recursiverefine@newnames + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EC + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EF + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@CF + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@C@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EC}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@CF}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EF}% + % + #1% + % + },% + get pdf shading type=6, + get num vertices=\def\pgfplotsretval{6}, + get num cdata vertices=\def\pgfplotsretval{3}, +}% + + +% see +% \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth +% and its documentation. +% +% POSTCONDITION: +% \Pcur and \Pnextseq are defined. +\def\pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth{% + \def\Pcur{A}% + \def\Pnextseq{}% + % + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex + \ifx\pgfplotspatchvertexdepth\pgfutil@empty + \else + % ah. We have view depth. Use it! + % The idea here is as follows. + % According to pdf standard, the COONS Shading is + % generated in the unit cube and then mapped to the + % shading. If u,v in [0,1] are the coordinates in the unit + % cube, pixel values for v=1 overwrite values for v=0. + % If pixel values have the same v, u=1 overwrites u=0. + % In other words, the loop is + % for v= 0 to Nv + % for u = 0 to Nu + % shade pixel for (u,v) + % + % BB-------CC <--v=1 + % | | + % | | + % | | + % AA-------DD <--v=0 + % | | + % u=0 u=1 + % + % + % IDEA: re-order the sequence of vertices such that z + % buffering is obtained. + % + % APPROACH: + % the edge BB--CC collapses into just one point, namely + % the FOREGROUND point (i.e. it is drawn on top of + % everything else). + % + % The AA point is the second nearest foreground point. + % The sequence is chosen such that AA,BB is the first + % edge. + % + % What is to do (besides determining the vertices for AA + % and BB)? Well, make sure, that we can arrange them in + % the desired order. This involves a periodic "next vertex" + % algorithm which might either go forward + % or backward. + % + % sort according to depth. + % To do so, prepare macros \PA,\PB,\PC for use in + % \pgfplotsutilsortthree. FORMAT: + % \PA={pt } + \edef\PA{\pgfplotspatchvertexdepth pt A}% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@B\endvertex + \edef\PB{\pgfplotspatchvertexdepth pt B}% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@C\endvertex + \edef\PC{\pgfplotspatchvertexdepth pt C}% + \pgfplotsutilsortthree\PA\PB\PC + \def\toCHAR##1pt ##2{##2}% get original index + % + \edef\Pcur{\expandafter\toCHAR\PB}%% + \edef\Pnext{\csname pgfplots@qtri@next@\Pcur\endcsname}% + \edef\Pnext{\csname pgfplots@qtri@next@\Pnext\endcsname}% + \if\Pnext\PA + % ok, next(next(AA)) = BB. + % that means we have to advance forward. + \def\Pnextseq{}% + \else + % well, since we have a triangle, there only remains + % the backwards direction. + \def\Pnextseq{r}% + \fi +%\message{FOREGROUND VERTEX = \PA.^^J}% +%\message{SECOND NEAREST VERTEX = \PB.^^J}% + \fi +} +\def\pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth@no@op{% + \def\Pcur{A}% + \def\Pnextseq{}% +} + +% bilinear is the same as 'rectangle', but it uses a different shader. +\pgfplotsdeclarepatchclass{bilinear}{% + allow matrix=\def\pgfplotsretval{1}, + new=\def\pgfplotspatchclass@rect@no{0}, + set next vertex={% + \ifcase\pgfplotspatchclass@rect@no\relax + \edef\pgfplotspatchclass@rect@A{#1}% + \def\pgfplotspatchclass@rect@no{1}% + \or + \edef\pgfplotspatchclass@rect@B{#1}% + \def\pgfplotspatchclass@rect@no{2}% + \or + \edef\pgfplotspatchclass@rect@C{#1}% + \def\pgfplotspatchclass@rect@no{3}% + \or + \edef\pgfplotspatchclass@rect@D{#1}% + \def\pgfplotspatchclass@rect@no{0}% + \pgfplotspatchready% + \fi + }, + sample in unit cube={% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{1}% + #1% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{1}% + #1% + \pgfplotspatchready + },% + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex #1% + }, + stream to shader={% + % create a coons patch: + \begingroup + \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth + {pgfplotspatchclass@rect@}{\Pcur}{\Pnextseq}% + % + \pgfutil@namelet{Pstart}{pgfplotspatchclass@rect@\Pcur}% + \def\pgfplots@coonsedge{% +%\message{EDGE \Pcur^^J}% + \expandafter\let\expandafter\PA\csname pgfplotspatchclass@rect@\Pcur\endcsname + \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}% +%\message{---> \Pcur^^J}% + \expandafter\let\expandafter\PB\csname pgfplotspatchclass@rect@\Pcur\endcsname + \ifx\PA\Pstart + \expandafter\pgfplotspatchvertex\PA\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + % + % CONTROL POINT A+1/3(B-A) + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{0.6666666}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + {\pgfqpointscale{0.3333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + }{}% + % CONTROL POINT A+2/3(B-A) + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{0.3333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + {\pgfqpointscale{0.6666666}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + }{}% + \ifx\PB\Pstart + \else + \expandafter\pgfplotspatchvertex\PB\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + }% + % + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + \pgfplots@coonsedge + % + \endgroup + },% + fill path={% + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@A\endvertex}% + \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@B\endvertex}% + \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@C\endvertex}% + \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@D\endvertex}% + \pgfpathclose + }, + triangulate={% + \pgfplotscoordmath{meta}{parsenumber}{0.25}% + \let\pgfplots@loc@scale=\pgfmathresult + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\endvertex\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\endvertex\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\endvertex\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\endvertex\times{0.25}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@M + % + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{triangle}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20% + % Ok. Now create 4 triangles. The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + recursive refine@={% + \pgfplotspatchclass@rect@refine@{#1}% + },% + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get pdf shading type=6, + get num vertices=\def\pgfplotsretval{4}, +}% + +\pgfplotsdeclarepatchclass{rectangle}{% + recursive refine@={% + \pgfplotspatchclass@rect@refine@{#1}% + },% +} +\def\pgfplotspatchclass@rect@refine@#1{% + \pgfplotspatchclass@rect@recursiverefine@newnames + % + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + %-------------------------------------------------- + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20% + %-------------------------------------------------- + % The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.25}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.25}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@M + % + \expandafter\pgfplotspatchclass@rect@refine@@\expandafter{\pgfplotspatchclass@rect@M}{#1}% +} +\def\pgfplotspatchclass@rect@refine@@#1#2{% + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@AB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@DA + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@AB}% + \pgfplotsplothandlermesh@setnextvertex{#1}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@DA}% + #2\pgfplotspatchclass@rect@recursiverefine@newnames + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@AB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@BC + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@AB}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@BC}% + \pgfplotsplothandlermesh@setnextvertex{#1}% + #2\pgfplotspatchclass@rect@recursiverefine@newnames + % + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@CD + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@BC + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@BC}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@CD}% + \pgfplotsplothandlermesh@setnextvertex{#1}% + #2\pgfplotspatchclass@rect@recursiverefine@newnames + % + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@CD + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@DA + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@CD}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@DA}% + \pgfplotsplothandlermesh@setnextvertex{#1}% + #2\pgfplotspatchclass@rect@recursiverefine@newnames + % +}% + +\def\pgfplotspatchclass@rect@recursiverefine@newnames{% + \let\pgfplotspatchclass@rect@A@=\pgfplotspatchclass@rect@A% + \let\pgfplotspatchclass@rect@B@=\pgfplotspatchclass@rect@B% + \let\pgfplotspatchclass@rect@C@=\pgfplotspatchclass@rect@C% + \let\pgfplotspatchclass@rect@D@=\pgfplotspatchclass@rect@D% +}% + + +% An arbitrary poligy specified in the sequence +% D <-- C +% | ^ +% v | +% A --> B +% +\pgfkeyssetvalue{/pgfplots/vertex count}{0}% +\pgfplotsdeclarepatchclass{polygon}{% + new=\def\pgfplotspatchclass@poly@no{0}, + set next vertex={% + \pgfplotspatchclass@poly@checkcount + \expandafter\edef\csname pgfplotspatchclass@poly@\pgfplotspatchclass@poly@no\endcsname{#1}% + \pgfplotsutil@advancestringcounter\pgfplotspatchclass@poly@no + \ifnum\pgfplotspatchclass@poly@no=\pgfkeysvalueof{/pgfplots/vertex count} % + \def\pgfplotspatchclass@poly@no{0}% + \pgfplotspatchready% + \fi + }, + first vertex=\expandafter\expandafter\expandafter\pgfplotspatchvertex\csname pgfplotspatchclass@poly@0\endcsname\endvertex, + foreach vertex={% + \pgfplotspatchclass@poly@foreach@loop{0}{#1}% + }, + init pdf shading={% + \pgfplots@error{Sorry, patch type=polygon does not support shadings}% + }, + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get pdf shading type=4, + get num vertices=\def\pgfplotsretval{\pgfkeysvalueof{/pgfplots/vertex count}}, +}% +\def\pgfplotspatchclass@poly@checkcount{% + \ifnum\pgfkeysvalueof{/pgfplots/vertex count}>0 + \else + \pgfplots@error{Sorry, 'patch type=polygon' *requires* that 'vertex count=' is set (note: it is allowed if multiple vertices have the same coordinates).}% + \fi +}% +\long\def\pgfplotspatchclass@poly@foreach@loop#1#2{% + \ifnum#1<\pgfkeysvalueof{/pgfplots/vertex count} % + \expandafter\expandafter\expandafter\pgfplotspatchvertex\csname pgfplotspatchclass@poly@#1\endcsname\endvertex #2% + \begingroup + \c@pgf@counta=#1 % + \advance\c@pgf@counta by1 % + \t@pgfplots@toka={#2}% + \xdef\pgfplots@glob@TMPc{\noexpand\pgfplotspatchclass@poly@foreach@loop{\the\c@pgf@counta}{\the\t@pgfplots@toka}}% + \endgroup + \else + \gdef\pgfplots@glob@TMPc{}% + \fi + \pgfplots@glob@TMPc +}% + +\def\pgfplots@biquad@next@A{E} +\def\pgfplots@biquad@next@B{F} +\def\pgfplots@biquad@next@C{G} +\def\pgfplots@biquad@next@D{H} +\def\pgfplots@biquad@next@E{B} +\def\pgfplots@biquad@next@F{C} +\def\pgfplots@biquad@next@G{D} +\def\pgfplots@biquad@next@H{A} + + +\def\pgfplots@biquad@rnext@A{H} +\def\pgfplots@biquad@rnext@B{E} +\def\pgfplots@biquad@rnext@C{F} +\def\pgfplots@biquad@rnext@D{G} +\def\pgfplots@biquad@rnext@E{A} +\def\pgfplots@biquad@rnext@F{B} +\def\pgfplots@biquad@rnext@G{C} +\def\pgfplots@biquad@rnext@H{D} + +\def\pgfplotspatchclass@biquad@recursiverefine@newnames{% + \let\pgfplotspatchclass@biquad@A@=\pgfplotspatchclass@biquad@A% + \let\pgfplotspatchclass@biquad@B@=\pgfplotspatchclass@biquad@B% + \let\pgfplotspatchclass@biquad@C@=\pgfplotspatchclass@biquad@C% + \let\pgfplotspatchclass@biquad@D@=\pgfplotspatchclass@biquad@D% + \let\pgfplotspatchclass@biquad@E@=\pgfplotspatchclass@biquad@E% + \let\pgfplotspatchclass@biquad@F@=\pgfplotspatchclass@biquad@F% + \let\pgfplotspatchclass@biquad@G@=\pgfplotspatchclass@biquad@G% + \let\pgfplotspatchclass@biquad@H@=\pgfplotspatchclass@biquad@H% + \let\pgfplotspatchclass@biquad@I@=\pgfplotspatchclass@biquad@I% +}% + + +% mathematica shape functions parameterized in +% (xi,eta) in [-1,1]x[-1,1]: +%f[xi_, eta_] = +% a*1/4*(1 - xi) (1 - eta) xi*eta + +% b 1/4 (-1 - xi) (1 - eta) xi*eta + +% c* 1/4 (-1 - xi) (-1 - eta) xi*eta + +% d *1/4 (1 - xi) (-1 - eta) xi*eta + +% e * 1/2 (xi^2 - 1) (1 - eta) eta + +% f*1/2 (-1 - xi) (eta^2 - 1) xi + +% g* -1/2 (1 - xi^2) (-1 - eta) eta + +% h* -1/2 (1 - xi) (1 - eta^2) xi + +% i*(1 - xi^2) (1 - eta^2) +% here, a,b,...,i are the 9 nodes. +\pgfplotsdeclarepatchclass{biquadratic}{% + new=\def\pgfplotspatchclass@biquad@no{A}\let\pgfplotspatchclass@biquade@AB\relax, + set next vertex={% + % defines \pgfplotspatchclass@biquad@A ... \pgfplotspatchclass@biquad@I (9 points) + \expandafter\edef\csname pgfplotspatchclass@biquad@\pgfplotspatchclass@biquad@no\endcsname{#1}% + \if I\pgfplotspatchclass@biquad@no + \def\pgfplotspatchclass@biquad@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@biquad@no\csname pgfpptchindexnext@\pgfplotspatchclass@biquad@no\endcsname + \fi + }, + sample in unit cube={% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{1}% + #1% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{1}% + #1% + \def\pgfplotspatchclassx{0.5}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0.5}% + #1% + \def\pgfplotspatchclassx{0.5}% + \def\pgfplotspatchclassy{1}% + #1% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0.5}% + #1% + \def\pgfplotspatchclassx{0.5}% + \def\pgfplotspatchclassy{0.5}% + #1% + \pgfplotspatchready + },% + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@E\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@F\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@H\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@I\endvertex #1% + }, + foreach cdata vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@D\endvertex #1% + }, + fill path={% + \begingroup + % Visualize the patch boundary using four bezier curves. + % + % This involves a change from Lagrange to bezier + % representation of the boundary curves. + % + % Furthermore, pdf supports only **cubic** bezier curves. What + % I am doing here is + % a) change of basis from 3-point lagrange ---> 3 point quadratic bezier + % b) expression 3 point quadratic bezier ----> 4 point cubic bezier + % + % INPUT: + % 3 langrange points (i.e. the patch passes through them) + % \PA,\PB,\PC (start,middle,end) + % + % OUTPUT: + % \PA,bezier control 1, bezier control 2, \PC. + % + \def\pgfplots@edge{% + \ifx\pgfplotspatchclass@biquad@A\PA + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}% + \fi + \pgfpathcurveto {% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{% + \expandafter\pgfplotspointpatchvertex\PC\endvertex + }% + }% + \let\PA=\pgfplotspatchclass@biquad@A + \let\PB=\pgfplotspatchclass@biquad@E + \let\PC=\pgfplotspatchclass@biquad@B + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@biquad@B + \let\PB=\pgfplotspatchclass@biquad@F + \let\PC=\pgfplotspatchclass@biquad@C + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@biquad@C + \let\PB=\pgfplotspatchclass@biquad@G + \let\PC=\pgfplotspatchclass@biquad@D + \pgfplots@edge + % + \let\PA=\pgfplotspatchclass@biquad@D + \let\PB=\pgfplotspatchclass@biquad@H + \let\PC=\pgfplotspatchclass@biquad@A + \pgfplots@edge + \endgroup + \pgfpathclose + }, + %-------------------------------------------------- + % stroke path={% + % \ifx\pgfplotspatchclass@biquade@AB\relax + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}% + % \pgfpathclose + % \else + % \if1\pgfplotspatchclass@biquade@AB + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}% + % \fi + % \if1\pgfplotspatchclass@biquade@BC + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}% + % \fi + % \if1\pgfplotspatchclass@biquade@CA + % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}% + % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}% + % \fi + % \fi + % }, + %-------------------------------------------------- + stream to shader={% + \begingroup + % + % An early version of this shader used Coons patch shadings + % (which provides coordinates only for the 9 boundary + % vertices, not for the inner vertices). That is a little bit + % simpler than what you see in the following lines of code: a + % transformation to a tensor bezier shading. + % + % What we need is to map the 3x3 data from lagrangrian + % (interpolation) representation to 4x4 cubic bezier - and + % handle the four INNER nodes correctly. + % + % The algorithm to convert from 1d curves with 3 point langrange to 4 point + % bezier is well-known and relatively simple. Fortunately, the + % extension to 3x3 -> 4x4 can be boiled down to a successive + % application of the 1d algorithm - applied to horizontal and + % vertical lines in the data matrizes. + % + % NOTE: the algorithm in the following lines results in + % EXACTLY THE SAME four cubic boundary curves as the approach + % in 'fill path'. The only difference is that it also does the + % right thing for the inner node. + % + % STEP 1: ensure that the patch's coordinates are streamed in + % a sequence which is compatible with the DEPTH of the + % corners. + % + % we use + % \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth + % which works for bilinear, biquadratic, and bicubic + \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth + {pgfplotspatchclass@biquad@}{\Pcur}{\Pnextseq}% + % + % STEP 2: + % now, translate the result into our matrix form. + % This means to (a) identify the FIRST point which needs to be + % streamed (it is stored in \Pcur as 'A', 'B', 'C', or 'D') + % and (b) keep in mind that we have to take care of the + % sequence in which points are streamed ("forward" means to + % rotate the matrix elements and "backward" means to transpose + % the "forward" result). + % + % This can be seen as conversion from the "linearized" + % numbering to matrix indexing - while respecting the "start + % point". + % + % INPUT: + % + % D G C + % H I F + % A E B + % + \if A\Pcur + % Ah - the point "A" needs to be streamed as first. + % + % Well, this is simple: take the matrix as-is! + % simply copy 1:1 + % + % i.e. convert + % D G C + % H I F + % A E B + % + % to + % + % AC BC CC + % AB BB CB + % AA BA CA + \let\P@AA=\pgfplotspatchclass@biquad@A + \let\P@BA=\pgfplotspatchclass@biquad@E + \let\P@CA=\pgfplotspatchclass@biquad@B + \let\P@AB=\pgfplotspatchclass@biquad@H + \let\P@BB=\pgfplotspatchclass@biquad@I + \let\P@CB=\pgfplotspatchclass@biquad@F + \let\P@AC=\pgfplotspatchclass@biquad@D + \let\P@BC=\pgfplotspatchclass@biquad@G + \let\P@CC=\pgfplotspatchclass@biquad@C + \fi + \if B\Pcur + % the "B" point needs to be streamed as first. + % + % i.e. reorder + % D G C + % H I F + % A E B + % + % to + % A H D AC BC CC + % E I G =: AB BB CB + % B F C AA BA CA + % + \let\P@AA=\pgfplotspatchclass@biquad@B + \let\P@BA=\pgfplotspatchclass@biquad@F + \let\P@CA=\pgfplotspatchclass@biquad@C + \let\P@AB=\pgfplotspatchclass@biquad@E + \let\P@BB=\pgfplotspatchclass@biquad@I + \let\P@CB=\pgfplotspatchclass@biquad@G + \let\P@AC=\pgfplotspatchclass@biquad@A + \let\P@BC=\pgfplotspatchclass@biquad@H + \let\P@CC=\pgfplotspatchclass@biquad@D + \fi + \if C\Pcur + % the "C" point needs to be streamed as first. + % + % i.e. reorder + % D G C + % H I F + % A E B + % + % to + % B E A AC BC CC + % F I H =: AB BB CB + % C G D AA BA CA + % + \let\P@AA=\pgfplotspatchclass@biquad@C + \let\P@BA=\pgfplotspatchclass@biquad@G + \let\P@CA=\pgfplotspatchclass@biquad@D + \let\P@AB=\pgfplotspatchclass@biquad@F + \let\P@BB=\pgfplotspatchclass@biquad@I + \let\P@CB=\pgfplotspatchclass@biquad@H + \let\P@AC=\pgfplotspatchclass@biquad@B + \let\P@BC=\pgfplotspatchclass@biquad@E + \let\P@CC=\pgfplotspatchclass@biquad@A + \fi + \if D\Pcur + % the "D" point needs to be streamed as first. + % + % i.e. reorder + % D G C + % H I F + % A E B + % + % to + % C F B AC BC CC + % G I E =: AB BB CB + % D H A AA BA CA + % + \let\P@AA=\pgfplotspatchclass@biquad@D + \let\P@BA=\pgfplotspatchclass@biquad@H + \let\P@CA=\pgfplotspatchclass@biquad@A + \let\P@AB=\pgfplotspatchclass@biquad@G + \let\P@BB=\pgfplotspatchclass@biquad@I + \let\P@CB=\pgfplotspatchclass@biquad@E + \let\P@AC=\pgfplotspatchclass@biquad@C + \let\P@BC=\pgfplotspatchclass@biquad@F + \let\P@CC=\pgfplotspatchclass@biquad@B + \fi + \ifx\Pnextseq\pgfutil@empty + \else + % reverse the ordering. This means to transpose the + % matrix: + \pgfplotspatchclass@biquad@transpose + \fi + % + % + % Step: convert to tensor bezier representation. + % + % Converting a 2d tensor product lagrangian interpoland to a + % 2d tensor product bezier interpoland can be achieved by + % means of 1d algorithms along LINES in the matrix. + % + % The underlying proof for this is related to the tensor + % product form: the U and V coordinates are orthogonal to each + % other, so we can redistribute all intermediate results. (I + % do not have the real proof, so this hand-waving argument has + % to be enough). I verified its results experimentally. + % + % Note that the underlying 1d operation is the same as for + % 'patch type=quadratic spline' . We only need to apply it to all + % lines in U direction and afterwards to all lines in V + % direction. + % + \def\pgfplotspatchvertexaddXY@expanded##1\times{% + \edef\pgfplots@loc@TMPa{##1}% + \expandafter\pgfplotspatchvertexaddXY\pgfplots@loc@TMPa\times + }% + % + % this macro operates on \pgfplots@line{[ABC]} and defines + % \pgfplots@line{[ABCD]} (i.e. one dimension more!) + \def\pgfplots@apply@to@line{% + \pgfplotspatchvertexaccumstart + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{B}\times{1.333333}% + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{C}\times{-0.333333}% + \pgfplotspatchvertexfinish\pgfplots@controlpoint@A + % + \pgfplotspatchvertexaccumstart + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{A}\times{-0.333333}% + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{B}\times{1.333333}% + \pgfplotspatchvertexfinish\pgfplots@controlpoint@B + % + % ... we output 4 points (cubic!). + % A= left endpoint (untouched) + % B= first control + % C= second control + % D= right endpoint (untouched, is formerly called 'C') + \edef\pgfplots@loc@TMPa{\pgfplots@line{C}}% + \expandafter\expandafter\expandafter\let\pgfplots@line{B}=\pgfplots@controlpoint@A + \expandafter\expandafter\expandafter\let\pgfplots@line{C}=\pgfplots@controlpoint@B + \expandafter\expandafter\expandafter\let\pgfplots@line{D}=\pgfplots@loc@TMPa + }% + % + \def\pgfplots@line##1{\csname P@##1A\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@##1B\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@##1C\endcsname}% + \pgfplots@apply@to@line + % + % Now, we have a 3x4 matrix. + % + % + \def\pgfplots@line##1{\csname P@A##1\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@B##1\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@C##1\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@D##1\endcsname}% + \pgfplots@apply@to@line + % + % OK. The tensor product representation is READY. + % + % in particular, we have a 4x4 matrix right now: + % + \pgfplotsplothandlermesh@shade@cubic@tensor + \endgroup + },% + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{triangle}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20% + % Ok. Now create 4 triangles. The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + %-------------------------------------------------- + % set edge visible={% + % \ifcase#1 + % \edef\pgfplotspatchclass@biquade@AB{#2}% + % \or + % \edef\pgfplotspatchclass@biquade@BC{#2}% + % \or + % \edef\pgfplotspatchclass@biquade@CA{#2}% + % \fi + % }, + %-------------------------------------------------- + serialize except vertices={% + \ifx\pgfplotspatchclass@biquade@AB\relax + \let\pgfplotsretval\pgfutil@empty% + \else + \edef\pgfplotsretval{% + \noexpand\def\noexpand\pgfplotspatchclass@biquade@AB{\pgfplotspatchclass@biquade@AB}% + \noexpand\def\noexpand\pgfplotspatchclass@biquade@BC{\pgfplotspatchclass@biquade@BC}% + \noexpand\def\noexpand\pgfplotspatchclass@biquade@CA{\pgfplotspatchclass@biquade@CA}% + }% + \fi + },% + deserialize except vertices=% + \let\pgfplotspatchclass@biquade@AB\relax + #1, + recursive refine@={% + \pgfplotspatchclass@biquad@recursiverefine@newnames + % + \pgfplotspatchclass{\pgfplotspatchclassname}{new}% + %-------------------------------------------------- + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11% + % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20% + %-------------------------------------------------- + % The ordering is not arbitrary + % (unless z buffer=sort is in effect). Let's assume that the + % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then + % this sequence here should have approximately the same depth + % ordering: + % + % I used the reference triangle and shape functions as listed in + % http://www.colorado.edu/engineering/CAS/courses.d/IFEM.d/, + % see above for the definition of f[xi,eta] + % + % N[{f[-1/2, -1], f[0, -1/2], f[-1/2, 0], f[-1, -1/2], f[-1/2, -1/2]}] + % {0.375` a - 0.125` b + 0.75` e, + % 0.375` e - 0.125` g + 0.75` i, + % -0.125` f + 0.375` h + 0.75` i, + % 0.375` a - 0.125` d + 0.75` h, + % 0.140625` a - 0.046875` b + 0.015625` c - 0.046875` d + + % 0.28125` e - 0.09375` f - 0.09375` g + 0.28125` h + + % 0.5625` i} + %-------------------------------------------------- + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AE + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AH + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.140625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.015625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AEIH + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AE}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AH}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AEIH}% + % + #1\pgfplotspatchclass@biquad@recursiverefine@newnames + % + % N[{f[1/2, -1], f[1, -1/2], f[1/2, 0], f[1/2, -1/2]}] + % {-0.125` a + 0.375` b + 0.75` e, + % 0.375` b - 0.125` c + 0.75` f, + % 0.375` f - 0.125` h + 0.75` i, + % -0.046875 a + 0.140625 b - 0.046875 c + 0.015625 d + 0.28125 e + 0.28125 f - 0.09375 g - 0.09375 h + 0.5625 i} + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@BF + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FI + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.140625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.015625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EBFI + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EB}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@BF}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EBFI}% + % + #1\pgfplotspatchclass@biquad@recursiverefine@newnames + % + % + % N[ {f[1, 1/2], f[1/2, 1], f[0, 1/2], f[1/2, 1/2]}] + % {-0.125` b + 0.375` c + 0.75` f, + % 0.375` c - 0.125` d + 0.75` g, + % -0.125` e + 0.375` g + 0.75` i, + % 0.015625` a - 0.046875` b + 0.140625` c - 0.046875` d - 0.09375` e + 0.28125` f + 0.28125` g - 0.09375` h + 0.5625` i} + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FC + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@CG + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FI + % + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.015625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.140625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@IFCG + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FC}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@CG}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@IFCG}% + % + #1\pgfplotspatchclass@biquad@recursiverefine@newnames + % + % + % N[{f[-1/2, 1], f[-1, 1/2], f[-1/2, 1/2]}] + % {-0.125 c + 0.375 d + 0.75 g, + % -0.125 a + 0.375 d + 0.75 h, + % -0.046875 a + 0.015625 b - 0.046875 c + 0.140625 d - 0.09375 e - 0.09375 f + 0.28125 g + 0.28125 h + 0.5625 i} + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GD + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@DH + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.015625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.046875}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.140625}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.09375}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.28125}% + \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}% + \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HIGD + % + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D@}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GI}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GD}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@DH}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HIGD}% + % + #1% + % + },% + get pdf shading type*={% + \if1\b@pgfplotsplothandlermesh@enable@fixed@biquadratic + \def\pgfplotsretval{7}% + \else + \def\pgfplotsretval{6}% + \fi + },% + get num vertices=\def\pgfplotsretval{9}, + get num cdata vertices=\def\pgfplotsretval{4}, +}% + +% set this to 0 to revert to an older implementation (which was buggy, +% though) +\def\b@pgfplotsplothandlermesh@enable@fixed@biquadratic{1}% + + +% see docs in 'biquadratic::stream to shader' for details. +% PRECONDITION: to be used inside of 'stream to shader'. +\def\pgfplotspatchclass@biquad@coonsedge{% +%\message{EDGE \Pcur^^J}% + \expandafter\let\expandafter\PA\csname pgfplotspatchclass@biquad@\Pcur\endcsname + \edef\Pcur{\csname pgfplots@biquad@\Pnextseq next@\Pcur\endcsname}% + \expandafter\let\expandafter\PB\csname pgfplotspatchclass@biquad@\Pcur\endcsname +%\message{---> \Pcur^^J}% + \edef\Pcur{\csname pgfplots@biquad@\Pnextseq next@\Pcur\endcsname}% + \expandafter\let\expandafter\PC\csname pgfplotspatchclass@biquad@\Pcur\endcsname +%\message{---> \Pcur^^J}% + \ifx\PA\Pstart + \expandafter\pgfplotspatchvertex\PA\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + }{}% + \pgfplotslibrarysurfstreamcoord{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + }{}% + \ifx\PC\Pstart + \else + \expandafter\pgfplotspatchvertex\PC\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \fi +}% +\def\pgfplotspatchclass@biquad@innercontrolpoints{% + \begingroup + % + % This here computes the FOUR INNER CONTROL POINTS of a tensor + % cubic bezier patch (Shading Type 7). + % + % + % the following point coordinates have been acquired from + % biquadratic::recursive refine. See above for documentation. + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@A\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@B\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@E\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@AE + % + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@F\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@H\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@HI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@A\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@B\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@E\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@EB + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@F\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@H\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@I\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@FI + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@C\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@D\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@G\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@CG + % + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@C\times{-0.125}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@D\times{0.375}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@G\times{0.75}% + \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@GD + % + % + \let\PA=\pgfplotspatchclass@biquad@AE + \let\PB=\pgfplotspatchclass@biquad@HI + \let\PC=\pgfplotspatchclass@biquad@GD + \pgfplotspatchclass@biquad@innercontrolpoints@PREPARE\pgfplotspatchclass@biquad@@A\pgfplotspatchclass@biquad@@D + % + \let\PA=\pgfplotspatchclass@biquad@EB + \let\PB=\pgfplotspatchclass@biquad@FI + \let\PC=\pgfplotspatchclass@biquad@CG + \pgfplotspatchclass@biquad@innercontrolpoints@PREPARE\pgfplotspatchclass@biquad@@B\pgfplotspatchclass@biquad@@C + % + % + \let\Pcur=\Pstartidx + \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}% + % + \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}% + \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}% + % + \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}% + \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}% + % + \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}% + \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}% + \endgroup +}% +\def\pgfplotspatchclass@biquad@innercontrolpoints@PREPARE#1#2{% + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}% + \edef#1{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + % + \pgfpointadd + {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}% + {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}% + \edef#2{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + % +\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PA\endvertex}{1pt}\pgfusepath{fill}% +\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PB\endvertex}{1pt}\pgfusepath{fill}% +\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PC\endvertex}{1pt}\pgfusepath{fill}% +\pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}% +\pgfpathcurveto{#1}{#2}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}% +\pgfusepath{stroke}% +} + +% Direct interface to coons patches (pdf shading type 6). +% See manual and/or pdf reference +\pgfplotsdeclarepatchclass{coons}{% + new=\def\pgfplotspatchclass@coons@no{A}, + set next vertex={% + % defines \pgfplotspatchclass@coons@A ... \pgfplotspatchclass@coons@L (12 points) + \expandafter\edef\csname pgfplotspatchclass@coons@\pgfplotspatchclass@coons@no\endcsname{#1}% + \if L\pgfplotspatchclass@coons@no + \def\pgfplotspatchclass@coons@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@coons@no\csname pgfpptchindexnext@\pgfplotspatchclass@coons@no\endcsname + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@E\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@F\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@H\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@I\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@J\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@K\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@L\endvertex #1% + }, + foreach cdata vertex={% + % 0, 3, 6, 9 + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@J\endvertex #1% + }, + fill path={% + \pgfpathmoveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@A\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@B\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@C\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@D\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@E\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@F\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@G\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@H\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@I\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@J\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@K\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@L\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@A\endvertex}% + \pgfpathclose + }, + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get pdf shading type=6, + get num vertices=\def\pgfplotsretval{12}, + get num cdata vertices=\def\pgfplotsretval{4}, +}% + +% Direct interface to tensor product bezier patches (pdf shading type 7). +% See manual and/or pdf reference +\pgfplotsdeclarepatchclass{tensor bezier}{% + new=\def\pgfplotspatchclass@tensor@no{A}, + set next vertex={% + % defines \pgfplotspatchclass@tensor@A ... \pgfplotspatchclass@tensor@P (16 points) + \expandafter\edef\csname pgfplotspatchclass@tensor@\pgfplotspatchclass@tensor@no\endcsname{#1}% + \if P\pgfplotspatchclass@tensor@no + \def\pgfplotspatchclass@tensor@no{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@tensor@no\csname pgfpptchindexnext@\pgfplotspatchclass@tensor@no\endcsname + \fi + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@B\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@C\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@E\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@F\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@H\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@I\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@J\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@K\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@L\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@M\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@N\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@O\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@P\endvertex #1% + }, + foreach cdata vertex={% + % 0, 3, 6, 9 + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@D\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@G\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@J\endvertex #1% + }, + fill path={% + \pgfpathmoveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@A\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@B\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@C\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@D\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@E\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@F\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@G\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@H\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@I\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@J\endvertex}% + \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@K\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@L\endvertex}% + {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@A\endvertex}% + \pgfpathclose + }, + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get pdf shading type=7, + get num vertices=\def\pgfplotsretval{16}, + get num cdata vertices=\def\pgfplotsretval{4}, +}% + +% A bicubic patch with 16 points. +% +% It expects points in the order (i.e. in matrix ordering, row-wise): +% +% AD BD CD DD +% AC BC CC DC +% AB BB CB DB +% AA BA CA DA +% +\pgfplotsdeclarepatchclass{bicubic}{% + new=\def\pgfplotspatchclass@bicubic@row{A}\def\pgfplotspatchclass@bicubic@col{A}, + set next vertex={% + % defines \pgfplotspatchclass@bicubic@AA ... \pgfplotspatchclass@bicubic@DD (16 points) + \expandafter\edef\csname pgfplotspatchclass@bicubic@\pgfplotspatchclass@bicubic@row\pgfplotspatchclass@bicubic@col\endcsname{#1}% + \if D\pgfplotspatchclass@bicubic@row + \def\pgfplotspatchclass@bicubic@row{A}% + \if D\pgfplotspatchclass@bicubic@col + \def\pgfplotspatchclass@bicubic@col{A}% + \pgfplotspatchready + \else + \expandafter\let\expandafter\pgfplotspatchclass@bicubic@col\csname pgfpptchindexnext@\pgfplotspatchclass@bicubic@col\endcsname + \fi + \else + \expandafter\let\expandafter\pgfplotspatchclass@bicubic@row\csname pgfpptchindexnext@\pgfplotspatchclass@bicubic@row\endcsname + \fi + }, + sample in unit cube={% + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{0.333333333}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{0.666666666}% + \def\pgfplotspatchclassy{0}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0}% + #1% + % + % + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0.333333333}% + #1% + \def\pgfplotspatchclassx{0.333333333}% + \def\pgfplotspatchclassy{0.333333333}% + #1% + \def\pgfplotspatchclassx{0.666666666}% + \def\pgfplotspatchclassy{0.333333333}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0.333333333}% + #1% + % + % + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{0.666666666}% + #1% + \def\pgfplotspatchclassx{0.333333333}% + \def\pgfplotspatchclassy{0.666666666}% + #1% + \def\pgfplotspatchclassx{0.666666666}% + \def\pgfplotspatchclassy{0.666666666}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{0.666666666}% + #1% + % + % + \def\pgfplotspatchclassx{0}% + \def\pgfplotspatchclassy{1}% + #1% + \def\pgfplotspatchclassx{0.333333333}% + \def\pgfplotspatchclassy{1}% + #1% + \def\pgfplotspatchclassx{0.666666666}% + \def\pgfplotspatchclassy{1}% + #1% + \def\pgfplotspatchclassx{1}% + \def\pgfplotspatchclassy{1}% + #1% + % + % + % + \pgfplotspatchready + },% + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AA\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AA\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@BA\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@CA\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DA\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AB\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@BB\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@CB\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DB\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AC\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@BC\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@CC\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DC\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AD\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@BD\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@CD\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DD\endvertex #1% + }, + foreach cdata vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AA\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DA\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DD\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AD\endvertex #1% + }, + fill path={% + % Visualize the patch boundary using four bezier curves. + % + % This involves a change from Lagrange to bezier + % representation of the boundary curves. + % + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@bicubic@AA\endvertex}% + \pgfplotspathcubicfrominterpolation + {\pgfplotspatchclass@bicubic@AA} + {\pgfplotspatchclass@bicubic@BA} + {\pgfplotspatchclass@bicubic@CA} + {\pgfplotspatchclass@bicubic@DA}% + \pgfplotspathcubicfrominterpolation + {\pgfplotspatchclass@bicubic@DA} + {\pgfplotspatchclass@bicubic@DB} + {\pgfplotspatchclass@bicubic@DC} + {\pgfplotspatchclass@bicubic@DD}% + \pgfplotspathcubicfrominterpolation + {\pgfplotspatchclass@bicubic@DD} + {\pgfplotspatchclass@bicubic@CD} + {\pgfplotspatchclass@bicubic@BD} + {\pgfplotspatchclass@bicubic@AD}% + \pgfplotspathcubicfrominterpolation + {\pgfplotspatchclass@bicubic@AD} + {\pgfplotspatchclass@bicubic@AC} + {\pgfplotspatchclass@bicubic@AB} + {\pgfplotspatchclass@bicubic@AA}% + \pgfpathclose + }, + stream to shader={% + \begingroup + % + % AD BD CD DD + % AC BC CC DC + % AB BB CB DB + % AA BA CA DA + % + % STEP 1: ensure that the patch's coordinates are streamed in + % a sequence which is compatible with the DEPTH of the + % corners. + % + % we use + % \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth + % which works for bilinear, biquadratic, and bicubic + % + % define helper macros which are input for + % \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth: + \let\pgfplotspatchclass@rect@A=\pgfplotspatchclass@bicubic@AA + \let\pgfplotspatchclass@rect@B=\pgfplotspatchclass@bicubic@DA + \let\pgfplotspatchclass@rect@C=\pgfplotspatchclass@bicubic@DD + \let\pgfplotspatchclass@rect@D=\pgfplotspatchclass@bicubic@AD + \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth + {pgfplotspatchclass@rect@}{\Pcur}{\Pnextseq}% + % + %\message{using \Pcur\space(set = \Pnextseq)^^J}% + % now, translate the result into our matrix form. + % This means to (a) identify the FIRST point which needs to be + % streamed (it is stored in \Pcur as 'A', 'B', 'C', or 'D') + % and (b) keep in mind that we have to take care of the + % sequence in which points are streamed ("forward" means to + % rotate the matrix elements and "backward" means to transpose + % the "forward" result). + % + \if A\Pcur + % Ah - the point "AA" needs to be streamed as first. + % + % Well, this is simple: take the matrix as-is! + % simply copy 1:1 + \let\P@AA=\pgfplotspatchclass@bicubic@AA + \let\P@BA=\pgfplotspatchclass@bicubic@BA + \let\P@CA=\pgfplotspatchclass@bicubic@CA + \let\P@DA=\pgfplotspatchclass@bicubic@DA + \let\P@AB=\pgfplotspatchclass@bicubic@AB + \let\P@BB=\pgfplotspatchclass@bicubic@BB + \let\P@CB=\pgfplotspatchclass@bicubic@CB + \let\P@DB=\pgfplotspatchclass@bicubic@DB + \let\P@AC=\pgfplotspatchclass@bicubic@AC + \let\P@BC=\pgfplotspatchclass@bicubic@BC + \let\P@CC=\pgfplotspatchclass@bicubic@CC + \let\P@DC=\pgfplotspatchclass@bicubic@DC + \let\P@AD=\pgfplotspatchclass@bicubic@AD + \let\P@BD=\pgfplotspatchclass@bicubic@BD + \let\P@CD=\pgfplotspatchclass@bicubic@CD + \let\P@DD=\pgfplotspatchclass@bicubic@DD + \fi + \if B\Pcur + % the "DA" point needs to be streamed as first. + % + % Reorder + % AD BD CD DD + % AC BC CC DC + % AB BB CB DB + % AA BA CA DA + % to + % AA AB AC AD + % BA BB BC BD + % CA CB CC CD + % DA DB DC DD + % + \let\P@AA=\pgfplotspatchclass@bicubic@DA + \let\P@BA=\pgfplotspatchclass@bicubic@DB + \let\P@CA=\pgfplotspatchclass@bicubic@DC + \let\P@DA=\pgfplotspatchclass@bicubic@DD + \let\P@AB=\pgfplotspatchclass@bicubic@CA + \let\P@BB=\pgfplotspatchclass@bicubic@CB + \let\P@CB=\pgfplotspatchclass@bicubic@CC + \let\P@DB=\pgfplotspatchclass@bicubic@CD + \let\P@AC=\pgfplotspatchclass@bicubic@BA + \let\P@BC=\pgfplotspatchclass@bicubic@BB + \let\P@CC=\pgfplotspatchclass@bicubic@BC + \let\P@DC=\pgfplotspatchclass@bicubic@BD + \let\P@AD=\pgfplotspatchclass@bicubic@AA + \let\P@BD=\pgfplotspatchclass@bicubic@AB + \let\P@CD=\pgfplotspatchclass@bicubic@AC + \let\P@DD=\pgfplotspatchclass@bicubic@AD + \fi + \if C\Pcur + % the "DD" point needs to be streamed as first. + % + % Reorder + % AD BD CD DD + % AC BC CC DC + % AB BB CB DB + % AA BA CA DA + % to + % DA CA BA AA + % DB CB BB AB + % DC CC BC AC + % DD CD BD AD + % + \let\P@AA=\pgfplotspatchclass@bicubic@DD + \let\P@BA=\pgfplotspatchclass@bicubic@CD + \let\P@CA=\pgfplotspatchclass@bicubic@BD + \let\P@DA=\pgfplotspatchclass@bicubic@AD + \let\P@AB=\pgfplotspatchclass@bicubic@DC + \let\P@BB=\pgfplotspatchclass@bicubic@CC + \let\P@CB=\pgfplotspatchclass@bicubic@BC + \let\P@DB=\pgfplotspatchclass@bicubic@AC + \let\P@AC=\pgfplotspatchclass@bicubic@DB + \let\P@BC=\pgfplotspatchclass@bicubic@CB + \let\P@CC=\pgfplotspatchclass@bicubic@BB + \let\P@DC=\pgfplotspatchclass@bicubic@AB + \let\P@AD=\pgfplotspatchclass@bicubic@DA + \let\P@BD=\pgfplotspatchclass@bicubic@CA + \let\P@CD=\pgfplotspatchclass@bicubic@BA + \let\P@DD=\pgfplotspatchclass@bicubic@AA + \fi + \if D\Pcur + % the "AD" point needs to be streamed as first. + % + % Reorder + % AD BD CD DD + % AC BC CC DC + % AB BB CB DB + % AA BA CA DA + % to + % DD DC DB DA + % CD CC CB CA + % BD BC BB BA + % AD AC AB AA + % + \let\P@AA=\pgfplotspatchclass@bicubic@AD + \let\P@BA=\pgfplotspatchclass@bicubic@AC + \let\P@CA=\pgfplotspatchclass@bicubic@AB + \let\P@DA=\pgfplotspatchclass@bicubic@AA + \let\P@AB=\pgfplotspatchclass@bicubic@BD + \let\P@BB=\pgfplotspatchclass@bicubic@BC + \let\P@CB=\pgfplotspatchclass@bicubic@BB + \let\P@DB=\pgfplotspatchclass@bicubic@BA + \let\P@AC=\pgfplotspatchclass@bicubic@CD + \let\P@BC=\pgfplotspatchclass@bicubic@CC + \let\P@CC=\pgfplotspatchclass@bicubic@CB + \let\P@DC=\pgfplotspatchclass@bicubic@CA + \let\P@AD=\pgfplotspatchclass@bicubic@DD + \let\P@BD=\pgfplotspatchclass@bicubic@DC + \let\P@CD=\pgfplotspatchclass@bicubic@DB + \let\P@DD=\pgfplotspatchclass@bicubic@DA + \fi + \ifx\Pnextseq\pgfutil@empty + \else + % reverse the ordering. This means to transpose the + % matrix: + \pgfplotspatchclass@bicubic@transpose + \fi + % + % Step: convert to tensor bezier representation. + % + % Converting a 2d tensor product lagrangian interpoland to a + % 2d tensor product bezier interpoland can be achieved by + % means of 1d algorithms along LINES in the matrix. + % + % The underlying proof for this is related to the tensor + % product form: the U and V coordinates are orthogonal to each + % other, so we can redistribute all intermediate results. (I + % do not have the real proof, so this hand-waving argument has + % to be enough). I verified its results experimentally. + % + % Note that the underlying 1d operation is the same as for + % 'patch type=cubic spline' . We only need to apply it to all + % lines in U direction and afterwards to all lines in V + % direction. + % + \def\pgfplotspatchvertexaddXY@expanded##1\times{% + \edef\pgfplots@loc@TMPa{##1}% + \expandafter\pgfplotspatchvertexaddXY\pgfplots@loc@TMPa\times + }% + % + % this macro operates on \pgfplots@line{[ABCD]}, see below: + \def\pgfplots@apply@to@line{% + \pgfplotspatchvertexaccumstart + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{A}\times{-0.833333}% + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{B}\times{3}% + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{C}\times{-1.5}% + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{D}\times{0.3333333}% + \pgfplotspatchvertexfinish\pgfplots@controlpoint@A + % + \pgfplotspatchvertexaccumstart + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{A}\times{0.333333}% + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{B}\times{-1.5}% + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{C}\times{3}% + \pgfplotspatchvertexaddXY@expanded\pgfplots@line{D}\times{-0.833333}% + \pgfplotspatchvertexfinish\pgfplots@controlpoint@B + % + \expandafter\expandafter\expandafter\let\pgfplots@line{B}=\pgfplots@controlpoint@A + \expandafter\expandafter\expandafter\let\pgfplots@line{C}=\pgfplots@controlpoint@B + }% + % + \def\pgfplots@line##1{\csname P@##1A\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@##1B\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@##1C\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@##1D\endcsname}% + \pgfplots@apply@to@line + % + % + \def\pgfplots@line##1{\csname P@A##1\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@B##1\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@C##1\endcsname}% + \pgfplots@apply@to@line + % + \def\pgfplots@line##1{\csname P@D##1\endcsname}% + \pgfplots@apply@to@line + % + % OK. The tensor product representation is READY. + % + \pgfplotsplothandlermesh@shade@cubic@tensor + \endgroup + }, + triangulate={% + \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass + \def\pgfplotsplothandlermesh@patchclass{triangle}% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}% + % Ok. Now create a lot of triangles. + % + % FIXME: The ordering is not arbitrary (unless z buffer=sort is in effect). + % + % ##1: the row index of the cell to be triangulated (either A,B,or C) + % ##2: the col index of the cell to be triangulated (either A,B,or C) + % ##3: the 1. 'set edge visible' value for the first triangle + % ##4: the 2. 'set edge visible' value for the first triangle + % ##5: the 3. 'set edge visible' value for the first triangle + % ##6: the 1. 'set edge visible' value for the second triangle + % ##7: the 2. 'set edge visible' value for the second triangle + % ##8: the 3. 'set edge visible' value for the second triangle + \def\pgfplots@bicubic@triangulate@cell##1##2##3##4##5##6##7##8{% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}0##3% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}1##4% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}2##5% + \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@##1##2\endcsname}% + \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@\csname pgfpptchindexnext@##1\endcsname##2\endcsname}% + \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@\csname pgfpptchindexnext@##1\endcsname \csname pgfpptchindexnext@##2\endcsname\endcsname}% + % + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}0##6% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}1##7% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}2##8% + \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@##1\csname pgfpptchindexnext@##2\endcsname\endcsname}% + \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@##1##2\endcsname}% + \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@\csname pgfpptchindexnext@##1\endcsname \csname pgfpptchindexnext@##2\endcsname\endcsname}% + % + }% + % + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20% + \pgfplots@bicubic@triangulate@cell AA100 100% + \pgfplots@bicubic@triangulate@cell BA100 000% + \pgfplots@bicubic@triangulate@cell CA110 000% + % + \pgfplots@bicubic@triangulate@cell AB000 100% + \pgfplots@bicubic@triangulate@cell BB000 000% + \pgfplots@bicubic@triangulate@cell CB010 000% + % + \pgfplots@bicubic@triangulate@cell AC000 101% + \pgfplots@bicubic@triangulate@cell BC000 001% + \pgfplots@bicubic@triangulate@cell CC010 001% + \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@ + },% + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get pdf shading type=7, + get num vertices=\def\pgfplotsretval{16}, + get num cdata vertices=\def\pgfplotsretval{4}, +}% + +% Transpose a bicubic matrix (4x4). +% +% Reorder +% AD BD CD DD +% AC BC CC DC +% AB BB CB DB +% AA BA CA DA +% to +% DA DB DC DD +% CA CB CC CD +% BA BB BC BD +% AA AB AC AD +\def\pgfplotspatchclass@bicubic@transpose{% + \pgfplotsutil@swap\P@AB\P@BA + \pgfplotsutil@swap\P@CA\P@AC + \pgfplotsutil@swap\P@DA\P@AD + \pgfplotsutil@swap\P@CB\P@BC + \pgfplotsutil@swap\P@BD\P@DB + \pgfplotsutil@swap\P@DC\P@CD +} + +% Transpose a bicubic matrix (4x4). +% +% Reorder +% AC BC CC +% AB BB CB +% AA BA CA +% to +% CA CB CC +% BA BB BC +% AA AB AC +\def\pgfplotspatchclass@biquad@transpose{% + \pgfplotsutil@swap\P@AB\P@BA + \pgfplotsutil@swap\P@CA\P@AC + \pgfplotsutil@swap\P@CB\P@BC +} + +% Expects that a 4x4 matrix in tensor bezier representation where +% A = left end point +% B = first control point +% C = second control point +% D = right end point +% +% and the coordinates are stored in \csname P@[ABCD][ABCD]\endcsname +% +% Streaming starts with \P@AA and is applied rowwise. +\def\pgfplotsplothandlermesh@shade@cubic@tensor{% + % Stream it to the shader. Note that the shader has a + % DIFFERENT ordering; it expects points in the cyclic ordering + % + % AA BA CA DA DB DC DD CD BD AD AC AB BB CB CC BC + % + % note furthermore that only the corners have "point meta" in + % this shading :-( + % + \expandafter\pgfplotspatchvertex\P@AA\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@BA\endvertex}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@CA\endvertex}{\pgfplotspointmetatransformed}% + \expandafter\pgfplotspatchvertex\P@DA\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + % + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@DB\endvertex}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@DC\endvertex}{\pgfplotspointmetatransformed}% + \expandafter\pgfplotspatchvertex\P@DD\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + % + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@CD\endvertex}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@BD\endvertex}{\pgfplotspointmetatransformed}% + \expandafter\pgfplotspatchvertex\P@AD\endvertex + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}% + % + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@AC\endvertex}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@AB\endvertex}{\pgfplotspointmetatransformed}% + % + % + \pgfplotspatchclass{\pgfplotspatchclassname}{get pdf shading type}% + \if 7\pgfplotsretval + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@BB\endvertex}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@CB\endvertex}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@CC\endvertex}{\pgfplotspointmetatransformed}% + \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@BC\endvertex}{\pgfplotspointmetatransformed}% + \else + % assume 'get pdf shading type=6' - it does not contain the + % inner vertices. + \fi +} +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex new file mode 100644 index 0000000..6697ab0 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex @@ -0,0 +1,676 @@ +%-------------------------------------------- +% +% Package pgfplots, library for polar coordinates. +% +% Copyright 2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% A polar axis lives in (ANGLE,LENGTH). +% That is +% x == ANGLE +% y == LENGTH +% +% + +\pgfplotsdefineaxistype[polar]{polar}{% + \pgfplots@polaraxis@activate +}% + +\newif\ifpgfplots@polaraxis@rellimits + +\pgfplotsset{ + /pgfplots/every polar axis/.style={ + grid=major, + xtick pos=right, + ytick pos=right, + every axis title shift=1.2\baselineskip, + legend style={anchor=center}, + /pgfplots/polar labels, + }, + /pgfplots/polar labels/.code={ + % this is equivalent to 'use units=false'. But that key is only available if the units lib is loaded. + \pgfplots@units@usefalse + \pgfkeysalso{% + % is this a good choice? No, it is not. + % In fact, I believe that neither xlabel nor ylabel is a good idea for a polar plot. + % BUT: if we simply leave the defaults, they will be placed outside of the circle - and + % this will confuse the units library which (for some reason) always generates labels. + every axis x label/.style={ + at={(rel axis cs:0,0.5)}, + anchor=north, + }, + every axis y label/.style={ + at={(0.2,0.85)}, + anchor=center, + }, + }% + }, + /pgfplots/xticklabel in circle/.style={ + xtick align=inside, + xticklabel style={ + rotate=90, + sloped like x axis={% + execute for upside down={\tikzset{anchor=north east}}, + %allow upside down, + reset nontranslations=false}, + anchor=south west, + %font=\tiny, + } + }, +} + +\def\pgfplots@polaraxis@activate{% + % FIXME : activating it results in strange output: + \pgfplots@LUA@backend@supportedfalse + % + \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy + \let\pgfplotsqpointxy=\pgfplotsqpointxy@polaraxis + \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy +% \def\pgfplotsqpointxyz##1##2##3{\pgfplotsqpointxy{##1}{##2}}% FIXME + \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@polaraxis + \def\pgfplotspointouternormalvectorofaxis@ifdependson@v##1##2##3{##2}% + \def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf##1{}% + \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@polaraxis + \let\pgfplots@handle@invalid@range@defaultlimits=\pgfplots@handle@invalid@range@defaultlimits@polar% + \let\pgfplots@check@invalid@range=\pgfplots@check@invalid@range@polar + \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@polaraxis + \let\pgfplots@drawgridlines@onorientedsurf@fromto=\pgfplots@drawgridlines@onorientedsurf@fromto@polar + \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@polar% + \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@polar + \let\pgfplotsaxisifcontainspoint=\pgfplotsaxisifcontainspoint@polar + \let\pgfplots@prepare@axis@API=\pgfplots@prepare@axis@API@polar + \def\axisdefaultheight{\axisdefaultwidth}% + \let\pgfplots@initsizes=\pgfplots@initsizes@polar + \let\pgfplots@BB@for@plotbox@get@unit@scales@for@limits=\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@polar + \let\pgfplots@limits@ready=\pgfplots@limits@ready@polar + \let\pgfplots@assign@default@tick@foraxis@normalizetickdist=\pgfplots@assign@default@tick@foraxis@normalizetickdist@polar + \let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@@polar + \let\pgfplots@enlarge@limit@for=\pgfplots@enlarge@limit@for@polar + \def\pgfplots@xtick@disable@last@tick{0}% + \let\pgfplots@xtick@check@tickshow=\pgfplots@xtick@check@tickshow@polar% + \let\pgfplots@set@options@sanitize=\relax + \let\pgfplots@set@options@sanitizemode=\relax + \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@polar + % + % this here is set *before* 'every polar axis' is invoked. + \pgfplotsset{ + enlarge x limits=false, + }% + \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{% + \pgfplots@notify@options@are@set + \pgfplotsset{separate axis lines}% + }% + \def\pgfplots@xticklabel@pos{}% + \def\pgfplots@yticklabel@pos{}% + \def\pgfplots@zticklabel@pos{}% + \def\pgfplots@init@ticklabelaxisspecfor##1##2{}% + \def\pgfplots@init@ticklabelaxisspec@twodim@for##1##2{}% + \def\pgfplots@xticklabelaxisspec{v10}% + \def\pgfplots@yticklabelaxisspec{0v0}% + \def\pgfplots@zticklabelaxisspec{00v}% + % + % cartesian cs + \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end}% + % +}% + +\let\pgfplots@prepare@axis@API@orig=\pgfplots@prepare@axis@API +\def\pgfplots@prepare@axis@API@polar{% + \pgfplots@prepare@axis@API@orig + \let\pgfplotsaxisupdatelimitsforcoordinatetwodim=\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar + \let\pgfplotsaxisupdatelimitsforcoordinatethreedim=\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar +}% + +\def\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar#1#2#3{% + % + % + % Update limits: + % I do not respect x limits (since they are periodic). + % Consequently, I do not respect the clip limits options here (I + % suppose it is useless) + % + % for y (radius) limits, I always use the ABSOLUTE value: + \pgfmathfloatabs@{#2}% + \let\pgfplots@loc@limit=\pgfmathresult + % + \ifpgfplots@autocompute@ymax + \ifpgfplots@yislinear + \pgfplotsmathfloatmax{\pgfplots@ymax}{\pgfplots@loc@limit}% + \global\let\pgfplots@ymax=\pgfmathresult + \else + \pgfplotsmathmax{\pgfplots@ymax}{\pgfplots@loc@limit}% + \global\let\pgfplots@ymax=\pgfmathresult + \fi + \fi + % + % Compute data range: + \pgfplotsmathfloatmin{\pgfplots@data@xmin}{#1}% + \global\let\pgfplots@data@xmin=\pgfmathresult + \pgfplotsmathfloatmax{\pgfplots@data@xmax}{#1}% + \global\let\pgfplots@data@xmax=\pgfmathresult + \pgfplotsmathfloatmin{\pgfplots@data@ymin}{#2}% + \global\let\pgfplots@data@ymin=\pgfmathresult + \pgfplotsmathfloatmax{\pgfplots@data@ymax}{#2}% + \global\let\pgfplots@data@ymax=\pgfmathresult +%\pgfplots@message{Updated limits: (\pgfplots@xmin,\pgfplots@ymin) rectangle (\pgfplots@xmax,\pgfplots@ymax).}% +% +%\tracingmacros=0\tracingcommands=0 +}% +\def\pgfplotsaxisifcontainspoint@polar#1#2{% + \begingroup + \pgfmath@basic@mod@{\pgfplots@current@point@x}{360}% + \pgf@xa=\pgfmathresult pt % + % + \pgf@ya=\pgfplots@current@point@y pt % + \ifdim\pgf@ya<0pt + % absolute value: + \pgf@ya=-\pgf@ya + \fi +%\message{ifcontainspoint(\the\pgf@xa,\pgfplots@current@point@y) limits = [\pgfplots@xmin@mod:\pgfplots@xmax@mod] x [\the\pgfplots@ymin@reg,\the\pgfplots@ymax@reg]^^J}% + % + % I assume that \pgfplots@[xyz]min@reg and min@reg are registers + % containing the limits. + \pgfplots@loop@CONTINUEfalse + \ifdim\pgf@ya<\pgfplots@ymin@reg + \else + \ifdim\pgf@ya>\pgfplots@ymax@reg + \else + \if1\b@pgfplots@polar@limit@around@zero + % check condition + % x <= max || x >= min + % <=> ! (x > max && x < min) + \pgfplots@loop@CONTINUEtrue + \ifdim\pgf@xa>\pgfplots@xmax@mod pt % + \ifdim\pgf@xa<\pgfplots@xmin@mod pt % + \pgfplots@loop@CONTINUEfalse + \fi + \fi + \else + \ifdim\pgf@xa<\pgfplots@xmin@mod pt % + \else + \ifdim\pgf@xa>\pgfplots@xmax@mod pt % + \else + \pgfplots@loop@CONTINUEtrue + \fi + \fi + \fi + \fi + \fi + \ifpgfplots@loop@CONTINUE + \def\pgfplots@loc@TMPa{#1}% + \else + \def\pgfplots@loc@TMPa{#2}% + \fi + \expandafter\endgroup\pgfplots@loc@TMPa% +} + +\def\pgfplots@check@invalid@range@polar{% + % + % A polar axis allows \addplot3, but it ignores the third + % coordinate. + \pgfplots@threedimfalse + % + \pgfplots@limits@are@computedtrue + \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin + \pgfplotscoordmath{x}{zero}% + \let\pgfplots@xmin=\pgfmathresult + \fi + \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax + \pgfplotscoordmath{x}{parsenumber}{360}% + \let\pgfplots@xmax=\pgfmathresult + \fi + \ifx\pgfplots@ymin\pgfplots@invalidrange@ymin + \pgfplotscoordmath{y}{zero}% + \let\pgfplots@ymin=\pgfmathresult + \fi + \ifx\pgfplots@ymax\pgfplots@invalidrange@ymax + \pgfplots@limits@are@computedfalse + \fi + \ifpgfplots@limits@are@computed + \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmin + \global\let\pgfplots@data@xmin=\pgfplots@xmin + \fi + \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmax + \global\let\pgfplots@data@xmax=\pgfplots@xmax + \fi + \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymin + \global\let\pgfplots@data@ymin=\pgfplots@ymin + \fi + \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymax + \global\let\pgfplots@data@ymax=\pgfplots@ymax + \fi + \ifpgfplots@clip@limits + \else + % there is a rare change that min > max. + % Handle that ... + \pgfplotscoordmath{x}{min}{\pgfplots@xmin}{\pgfplots@xmax}% + \global\let\pgfplots@xmin=\pgfmathresult + \pgfplotscoordmath{x}{max}{\pgfplots@xmin}{\pgfplots@xmax}% + \global\let\pgfplots@xmax=\pgfmathresult + % + \pgfplotscoordmath{y}{min}{\pgfplots@ymin}{\pgfplots@ymax}% + \global\let\pgfplots@ymin=\pgfmathresult + \pgfplotscoordmath{y}{max}{\pgfplots@ymin}{\pgfplots@ymax}% + \global\let\pgfplots@ymax=\pgfmathresult + % + \ifpgfplots@threedim + \pgfplotscoordmath{z}{min}{\pgfplots@zmin}{\pgfplots@zmax}% + \global\let\pgfplots@zmin=\pgfmathresult + \pgfplotscoordmath{z}{max}{\pgfplots@zmin}{\pgfplots@zmax}% + \global\let\pgfplots@zmax=\pgfmathresult + \fi + \fi + \else + \pgfplots@handle@invalid@range + \fi +}% + +\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{% + \pgfpointxy@orig{#1}{#2}% +}% +\def\pgfplotscoordmathnotifydatascalesetfor@polar#1{% + \def\pgfplotscoordmathnotifydatascalesetfor##1{}% + \edef\pgfplotscoordmathnotifydatascalesetfor@{#1}% + \def\pgfplotscoordmathnotifydatascalesetfor@@{x}% + \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@ + \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}% + \else + \def\pgfplotscoordmathnotifydatascalesetfor@@{y}% + \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@ + \pgfplotscoordmath{#1}{datascaletrafo set shift}{0}% + \fi + \fi + \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@polar +}% + +% #1: the "a" value on the oriented surf +% #2: the "b" value. +% #3: the shift along the normal. +% +\def\pgfplotspointonorientedsurfaceabwithbshift@polaraxis#1#2#3{% + % implement the shift in "b" direction explicitly: + % + \pgfplotspointonorientedsurfaceab{#1}{#2}% + \edef\pgfplots@loc@TMPe{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% + \pgfpointadd + {\pgfplots@loc@TMPe}% + {% + \begingroup + % I need a '-' here because for polaraxis axes, the "b" axis + % points to the *outside* instead of the inside. + \pgf@xa=-#3\relax + \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}% + % oh. a reversed axis. + \pgf@xa=-\pgf@xa + \fi + \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfqpointscale{\pgfplots@loc@TMPa}{% + \if x\pgfplotspointonorientedsurfaceB + % the angle. + % FIXME : datascaling! + % FIXME : aspect ratios! + \pgfmath@basic@sin@{#2}% + \pgf@x=-\pgfmathresult pt + \pgfmath@basic@cos@{#2}% + \pgf@y=\pgfmathresult pt + \else + % the length. + % FIXME : datascaling! + % FIXME : aspect ratios! + % perhaps pgfpointpolarxy? + \if y\pgfplotspointonorientedsurfaceB + \pgfqpointpolar{#1}{1pt}% + \else + \pgfpointorigin + \fi + \fi + }% + }% +} + + +\def\pgfplotsqpointxy@polaraxis#1#2{% + \pgf@process{% + \pgfplotsmathpoltocartbasic{#1}{#2}\x\y + \pgfqpointxy@orig\x\y +%\message{pgfplotsqpointxy{#1}{#2} ---> (\x,\y) ---> (\the\pgf@x,\the\pgf@y)}% + }% +}% +\def\pgfplots@clippath@prepare@for@axistype@polaraxis{% + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto + {\pgfplotsqpointxy\pgfplots@xmin\pgfplots@ymax}% + \pgfpatharcaxes{\pgfplots@xmin}{\pgfplots@xmax} + {\pgfqpointxy@orig{\pgfplots@ymax}{0}}% + {\pgfqpointxy@orig{0}{\pgfplots@ymax}}% + \if1\pgfplots@xtick@disable@last@tick + % we have min angle = max angle. + \ifdim\pgfplots@ymin pt=0pt + \else + \pgfseteorule + \pgfpathmoveto + {\pgfplotsqpointxy\pgfplots@xmin\pgfplots@ymin}% + \pgfpatharcaxes{\pgfplots@xmin}{\pgfplots@xmax} + {\pgfqpointxy@orig{\pgfplots@ymin}{0}}% + {\pgfqpointxy@orig{0}{\pgfplots@ymin}}% + \fi + \else + % we have min angle != max angle. + \ifdim\pgfplots@ymin pt=0pt + % Ok, then pass through origin: + \pgfpathlineto\pgfplotspointaxisorigin + \else + % complicated special case. + \pgfpathlineto + {\pgfplotsqpointxy\pgfplots@xmax\pgfplots@ymin}% + \pgfpatharcaxes{\pgfplots@xmax}{\pgfplots@xmin} + {\pgfqpointxy@orig{\pgfplots@ymin}{0}}% + {\pgfqpointxy@orig{0}{\pgfplots@ymin}}% + \fi + \pgfpathclose + \fi + \pgfplots@clippath@use@{##1}% + }% +}% + +\def\pgfplotspointouternormalvectorofaxis@polaraxis#1#2#3\relax{% + \if v#1% + \pgfplotspointouternormalvectorofaxisgetv{#1#2#3}% + % in direction of the length. + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + % FIXME : datascaling! + % FIXME : aspect ratios! + % perhaps pgfpointpolarxy? + \pgfqpointpolar{\pgfplotsretval}{1pt}% + \else + \if v#2% + \if#10% + \def\pgfplotsretval{\pgfplots@xmin}% + \else + \def\pgfplotsretval{\pgfplots@xmax}% + \fi + % in direction of the angle. + % FIXME : datascaling! + % FIXME : aspect ratios! + \pgfmath@basic@sin@{\pgfplotsretval}% + \pgf@x=-\pgfmathresult pt + \pgfmath@basic@cos@{\pgfplotsretval}% + \pgf@y=\pgfmathresult pt + \else + \pgfqpoint{0pt}{1pt}% + \fi + \fi + %\pgf@process{\pgfpointnormalised{}}% + \pgf@process{}% + \endgroup +}% + +\def\pgfplotspoint@initialisation@axes@polar{% + % + \begingroup + \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}% + \xdef\pgfplotspointminminmin{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + % + \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}% + \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + % + % the length of the "angle" axis is 2*pi*r . + % The radius, however, is the length of (0,ymax) which is (0pt,\pgf@xx*ymax): + \pgfmath@basic@multiply@{\pgf@sys@tonumber\pgf@xx}{\pgfplots@ymax}% + \pgfmathmultiply@{\pgfmathresult}{6.28318530717959}% 2*pi * r + \if0\pgfplots@xtick@disable@last@tick + % oh: minangle != maxangle. We have a partial circle. + % compute the arc length (<360 deg) + \pgf@xa=\pgfplots@xmax pt + \advance\pgf@xa by-\pgfplots@xmin pt + \divide\pgf@xa by360 + \ifdim\pgf@xa<1pt + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xa}% + \pgfmathmultiply@{\pgfmathresult}{\pgfplots@loc@TMPa}% + \fi + \fi + \xdef\pgfplotspointxaxislength{\pgfmathresult pt}% + % + \pgfpointdiff + {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}% + {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}% + \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \xdef\pgfplotspointyaxislength{\pgfmathresult pt}% + % + \global\let\pgfplotspointzaxis=\pgfpointorigin + \gdef\pgfplotspointzaxislength{0pt}% + \endgroup + % +} +\let\pgfplotspoint@initialisation@units@orig=\pgfplotspoint@initialisation@units +\def\pgfplotspoint@initialisation@units@polar{% + \def\pgfplotspointunitx{% + \pgfplotspointouternormalvectorofaxisgetv{v10}% angle varying, radius at outer pos + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + \pgfmath@basic@sin@{\pgfplotsretval}% + \pgf@x=-\pgfmathresult pt + \pgfmath@basic@cos@{\pgfplotsretval}% + \pgf@y=\pgfmathresult pt + }% + \def\pgfplotsunitxlength{1}% + \def\pgfplotsunitxinvlength{1}% + % + \def\pgfplotspointunity{% + \pgfqpointpolar{\pgfplots@xmin}{1pt}% + }% + \def\pgfplotsunitylength{1}% + \def\pgfplotsunityinvlength{1}% +}% + +\def\pgfplots@drawgridlines@onorientedsurf@fromto@polar#1{% + \if x\pgfplotspointonorientedsurfaceA + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% + \else + \if y\pgfplotspointonorientedsurfaceA\relax + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% + \pgf@x=#1\pgf@xx + \pgf@y=#1\pgf@yy + \edef\pgfplots@loc@TMPa{\the\pgf@x\space and \the\pgf@y}% + \def\pgfplots@loc@TMPb{\pgfpatharc{\pgfplots@xmin}{\pgfplots@xmax}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% + \else + \fi + \fi +}% + +\let\pgfplots@initsizes@original=\pgfplots@initsizes + +\def\pgfplots@initsizes@polar{% + % I copy-pasted most of this code, up to just one position where + % I introduced the modified scaling for polar axes + %---------------------------------- + % INIT. + % + % + \pgfmath@basic@mod@{\pgfplots@xmin}{360}% + \let\pgfplots@xmin@mod=\pgfmathresult + \pgfmath@basic@mod@{\pgfplots@xmax}{360}% + \let\pgfplots@xmax@mod=\pgfmathresult + \ifdim\pgfplots@xmax@mod pt>\pgfplots@xmin@mod pt + \def\b@pgfplots@polar@limit@around@zero{0}% + \else + \def\b@pgfplots@polar@limit@around@zero{1}% + \fi + % + \pgfplots@initsizes@original +}% + +\def\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@polar#1#2#3{% + % #1 is the angle ... and that does not need to be squeezed into + % the box. + % + % use only y (the radius). + \if1\b@pgfplots@plotbox@yisunit + % we do not need to compute max-min as for standard axes (because the inner part + % characterized by ymin does not enter the scaling). + % + % However, we have to keep in mind that our range is TWICE as + % large because [0,ymax] is just a radius, and we have to + % scale for the diameter. + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{2}% + \let\pgfplots@loc@TMPa=\pgfmathresult + % + \let\pgfmathresult=\pgfplots@ymax + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{\pgfmathresult}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{op}{multiply}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{tofixed}{\pgfmathresult}% + \else + \def\pgfmathresult{2}% not 1: the factor 2 is for 2*radius + \fi + \let#1=\pgfmathresult + \let#2=\pgfmathresult + \def#3{1}% FIXME : z ? +}% + +\def\pgfplots@handle@invalid@range@defaultlimits@polar{% + \def\pgfplots@loc@TMPa{0}% + \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin + \def\pgfplots@loc@TMPa{1}% + \fi + \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax + \def\pgfplots@loc@TMPa{1}% + \fi + \if\pgfplots@loc@TMPa1% + \pgfplotscoordmath{x}{parsenumber}{0}% + \global\let\pgfplots@xmin=\pgfmathresult + \pgfplotscoordmath{x}{parsenumber}{360}% + \global\let\pgfplots@xmax=\pgfmathresult + \global\let\pgfplots@data@xmin=\pgfplots@xmin + \global\let\pgfplots@data@xmax=\pgfplots@xmax + \fi + % + \pgfplotscoordmath{y}{parsenumber}{0}% + \global\let\pgfplots@ymin=\pgfmathresult + \pgfplotscoordmath{y}{parsenumber}{1}% + \global\let\pgfplots@ymax=\pgfmathresult + \global\let\pgfplots@data@ymin=\pgfplots@ymin + \global\let\pgfplots@data@ymax=\pgfplots@ymax +} + +\let\pgfplots@show@ticklabel@@orig=\pgfplots@show@ticklabel@ +\def\pgfplots@show@ticklabel@@polar#1#2{% + \def\pgfmathresult{#2}% + \if#1x% + \ifdim#2pt>360pt + \pgfmath@basic@mod@{#2}{360}% + \fi + \fi + \def\pgfplots@loc@TMPa{\pgfplots@show@ticklabel@@orig{#1}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% +}% + +\let\pgfplots@xtick@check@tickshow@orig=\pgfplots@xtick@check@tickshow% +\def\pgfplots@xtick@check@tickshow@polar{% + \if1\pgfplots@xtick@disable@last@tick + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@xmax pt} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{% + \pgfplots@xtick@check@tickshow@orig + }% + \else + \pgfplots@xtick@check@tickshow@orig + \fi +} + +\let\pgfplots@enlarge@limit@for@orig=\pgfplots@enlarge@limit@for +\def\pgfplots@enlarge@limit@for@polar#1{% + \if#1x% + % ignore 'enlarge x limits' (degrees). + \else + % allow 'enlarge y limits', but only for UPPER radius + \def\bool@pgfplots@loc@enlargelimits@min{0}% + \pgfplots@enlarge@limit@for@orig{#1}% + \fi +}% + +\let\pgfplots@assign@default@tick@foraxis@normalizetickdist@orig=\pgfplots@assign@default@tick@foraxis@normalizetickdist +\def\pgfplots@assign@default@tick@foraxis@normalizetickdist@polar#1#2{% + \if#1x% + % special handling for the angles: + \begingroup + \pgfmathfloattofixed{#2}% + \let\H=\pgf@xb + \H=\pgfmathresult pt + % only allow step sizes of + % 90, 45, 30, 15, 10, 5. + % + % Prefer the LARGER step size during the snap-to-nearest. + % The following decision boundaries are heuristics and have no + % mathematical foundation. + \ifdim\H>67pt + \H=90pt + \else + \ifdim\H>30pt + \H=45pt + \else + \ifdim\H>18pt + \H=30pt + \else + \ifdim\H>10pt + \H=15pt + \else + \ifdim\H>6pt + \H=10pt + \else + \H=5pt + \fi + \fi + \fi + \fi + \fi + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\H}% + \pgfmathfloatparsenumber{\pgfplots@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \else + \pgfplots@assign@default@tick@foraxis@normalizetickdist@orig{#1}{#2}% + \fi +}% + +\let\pgfplots@limits@ready@orig=\pgfplots@limits@ready +\def\pgfplots@limits@ready@polar{% + \pgfplots@limits@ready@orig + % + % Avoid tick labels at upper *and* lower angle range if both are the + % same: + \pgfmath@basic@subtract@{\pgfplots@xmax}{\pgfplots@xmin}% + \pgfmath@basic@mod@{\pgfmathresult}{360}% + \pgfplotsmath@ifapproxequal@dim + {\pgfmathresult pt}{0pt}% + {0.002pt} + {% + \def\pgfplots@xtick@disable@last@tick{1}% + }{% + }% + % +}% +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex new file mode 100644 index 0000000..611b12b --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex @@ -0,0 +1,1678 @@ +%-------------------------------------------- +% +% Package pgfplots, library for smith charts. +% +% Copyright 2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% A smithchart maps the complex halfplane +% H subset \C, +% H := [0,infty] x [-infty,infty] +% =~ \{ z = a+ j *b | a >=0, b \in \R } +% +% to the unit circle. +% +% A number z = a+jb is mapped to r(z) = (z-1) / (z+1) which is, per +% definition, in the 2d unit circle. +% +% Grid lines (i.e. a==const or b==const) are mapped on circles. +% +% In PGFPlots, the a=Re(z) is the x axis and b = Im(z) is the y axis. +% +% - CARTESIAN INPUT +% - tick/grid coordinates are from +% - input coordinates can be either from H or (perhaps preferred) from +% the unit circle. +% this "preferred" needs to be discussed. +% - the transformed data range is the unit circle (or a sequeezed variant) +% - in order to compute limits etc., I should accept data in H. this +% should simplify the logic to determine ticks etc considerably. +% problem: this transformation appears to be quite difficult (?) +% -> r(z) = (z-1)/(z+1) +% in complex arithmetics (but the G-tutorial.pdf says something +% about these circle equations!?) +% +% www.amanogawa.com/archive/docs/G-tutorial.pdf +% +% +% Idea: +% - work on H +% - transform whereever necessary +% - implement all pgfplots wrinkles in analogy to polar axes +% - provide support for normalized input coords (combined with +% untransformed limits or something like that) + +\pgfplotsdefineaxistype{smithchart}{% + \pgfplots@smithchartaxis@activate +}% + +\newif\ifpgfplotspointisinsmithchartCS +\newif\ifpgfplots@smithchart@showorigin +\newif\ifpgfplots@smithchart@mirrored + +\pgfplotsset{ + /pgfplots/xgrid each nth passes y/.initial=,% format: CSV list, each entry of the form ' | ':' | 'if <' | ':' 'if <' ' + /pgfplots/xgrid each nth passes y start/.initial=0, + /pgfplots/ygrid each nth passes x/.initial=, + /pgfplots/ygrid each nth passes x start/.initial=0, + % + /pgfplots/xgrid stop at y/.initial=,% individual stop map of the form ' ':' ', separated by white space + /pgfplots/ygrid stop at x/.initial=, + % + % FIXME : this is undocumented: + /pgfplots/smithchart mirrored/.is if=pgfplots@smithchart@mirrored, + /pgfplots/smithchart mirrored/.default=true, + % + % this boolean may only be used inside of \addplot. It will be + % ignored otherwise. + /pgfplots/is smithchart cs/.is if=pgfplotspointisinsmithchartCS, + /pgfplots/is smithchart cs/.default=true, + /pgfplots/show origin/.is if=pgfplots@smithchart@showorigin, + /pgfplots/show origin/.default=true, + /pgfplots/show origin code/.code={% + \path[draw=black,fill=white] (0pt,0pt) circle (2.5pt); + \path[fill=black] (0pt,0pt) circle (0.5pt); + }, + /pgfplots/every smithchart axis/.style={ + grid=both, + xmin=0, + xmax=16000,% FIXME : more is not possible because some code uses the \pgfplots@xmin@reg registers... (ticks) + ymin=-16000,ymax=16000, + scaled ticks=false, % never draw the \cdot 10^4 labels + major tick style={draw=black}, + xtick align=center, + ytick align=center, + every axis title shift=1.2\baselineskip, + legend style={anchor=center}, + }, + /pgfplots/default smithchart xtick/.code=, + /pgfplots/default smithchart ytick/.code=, + /pgfplots/default smithchart xytick/.code=, + /pgfplots/smithchart ticks by size/.code 2 args={% + \ifdim#1<14cm + \pgfkeysalso{/pgfplots/few smithchart ticks}% + \else + \ifdim#1<20cm + \pgfkeysalso{/pgfplots/many smithchart ticks}% + \else + \pgfkeysalso{/pgfplots/dense smithchart ticks}% + \fi + \fi + }, + /pgfplots/few smithchart ticks*/.style={ + default smithchart xtick/.style={ + xtick={0.2,0.5,1,2,5}, + }, + default smithchart ytick/.style={ + ytick={% + 0,% + 0.2, 0.5, 1, 2, 5,% + -0.2,-0.5,-1,-2,-5}, + }, + default smithchart xytick/.style={ + xgrid each nth passes y={2}, + ygrid each nth passes x={2}, + }, + }, + /pgfplots/few smithchart ticks/.style={/pgfplots/few smithchart ticks*}, + /pgfplots/few smithchart ticks*,% use it as initial config + /pgfplots/many smithchart ticks*/.style={ + default smithchart xtick/.style={ + xtick={ + 0.1,0.2,0.3,0.4,0.5,1,1.5,2,3,4,5,10,20% + }, + minor xtick={0.6,0.7,0.8,0.9,1.1,1.2,1.3,1.4,1.6,1.7,1.8,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50}, + }, + default smithchart ytick/.style={ + ytick={% + 0,% + 0.1,0.2,...,1,1.5,2,3,4,5,10,20,% + -0.1,-0.2,...,-1,-1.5,-2,-3,-4,-5,-10,-20% + }, + minor ytick={% + 1.1,1.2,1.3,1.4,1.6,1.7,1.8,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50,% + -1.1,-1.2,-1.3,-1.4,-1.6,-1.7,-1.8,-1.9,-2.2,-2.4,-2.6,-2.8,-3.2,-3.4,-3.6,-3.8,-4.5,-6,-7,-8,-9,-50% + }, + }, + default smithchart xytick/.style={ + xgrid each nth passes y={1,2,4,5,10,20}, + ygrid each nth passes x={1,2,3,5,10:3,20:3}, + }, + }, + /pgfplots/many smithchart ticks/.style={ + many smithchart ticks*, + every axis title shift=6pt, + yticklabel in circle, + show origin=true, + }, + /pgfplots/dense smithchart ticks*/.style={ + default smithchart xtick/.style={ + %ygrid each nth passes x start=0, + xtick={ + 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.2,1.4,1.6,1.8,2,3,4,5,10,20% + }, + minor xtick={% + 0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,% + 0.22,0.24,0.26,0.28,0.32,0.34,0.36,0.38,0.42,0.44,0.46,0.48,% + 0.52,% + 0.55,0.65,0.75,0.85,0.95,% + %0.6,0.7,0.8,0.9,% + 1.1,1.3,1.5,1.7,1.9,% + 2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50}, + }, + default smithchart ytick/.style={ + ytick={% + 0,% + 0.1,0.2,...,1,1.2,1.4,1.6,1.8,2,3,4,5,10,20,% + -0.1,-0.2,...,-1,-1.2,-1.4,-1.6,-1.8,-2,-3,-4,-5,-10,-20% + }, + minor ytick={% + 0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,% + 0.22,0.24,0.26,0.28,0.32,0.34,0.36,0.38,0.42,0.44,0.46,0.48,% + 0.55,0.65,0.75,0.85,0.95,% + 1.1,1.3,1.5,1.7,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50,% + -0.01,-0.02,-0.03,-0.04,-0.05,-0.06,-0.07,-0.08,-0.09,-0.11,-0.12,-0.13,-0.14,-0.15,-0.16,-0.17,-0.18,-0.19,% + -0.22,-0.24,-0.26,-0.28,-0.32,-0.34,-0.36,-0.38,-0.42,-0.44,-0.46,-0.48,% + -0.55,-0.65,-0.75,-0.85,-0.95,% + -1.1,-1.3,-1.5,-1.7,-1.9,-2.2,-2.4,-2.6,-2.8,-3.2,-3.4,-3.6,-3.8,-4.5,-6,-7,-8,-9,-50% + }, + }, + default smithchart xytick/.style={ + xgrid each nth passes y={0.2 if < 0.2001,0.5 if < 0.50001,1 if < 1.001,2,4,5,10,20}, + ygrid each nth passes x={0.2 if < 0.2001,0.52 if < 0.52001,1 if < 1.001,2,3,5,10:3,20:3}, + }, + }, + /pgfplots/dense smithchart ticks/.style={ + yticklabel in circle, + every axis title shift=6pt, + dense smithchart ticks*, + show origin=true, + every major grid/.style={black!60}, + }, + /pgfplots/yticklabel in circle/.style={ + ytick align=inside, + yticklabel style={ + rotate=90, + sloped like y axis={% + execute for upside down={\tikzset{anchor=north east}}, + %allow upside down, + reset nontranslations=false}, + anchor=south west, + %font=\tiny, + } + }, + yticklabel around circle/.style={ + ytick align=center, + yticklabel style={ + rotate=90, + sloped like y axis={% + execute for upside down={\tikzset{anchor=south west}}, + %allow upside down, + reset nontranslations=false}, + anchor=south east, + %font=\tiny, + } + }, + yticklabel around circle*/.style={ + ytick align=center, + yticklabel style={ + rotate=90, + sloped like y axis={% + execute for upside down={\tikzset{anchor=north west}}, + %allow upside down, + reset nontranslations=false}, + anchor=north east, + %font=\tiny, + } + } +} + +\pgfkeys{ + /pgfplots/warning/smithchart/no such tick/.code 2 args={% + \pgfplotsthrow@warning{There is no #1tick with index '#2'. Skipping it.}% + }, +} + +\def\pgfplots@smithchartaxis@activate{% + \def\axisdefaultwidth{207pt}% + \def\axisdefaultheight{207pt}% + \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy + \let\pgfplotsqpointxy=\pgfplotsqpointxy@smithchartaxis + \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy + \def\pgfplotsqpointxyz##1##2##3{\pgfplotsqpointxy{##1}{##2}}% FIXME + \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@smithchartaxis + \def\pgfplotspointouternormalvectorofaxis@ifdependson@v##1##2##3{##2}% + \def\pgfplots@drawticklines@INSTALLCLIP@onorientedsurf##1{}% + \let\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf=\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf@smithchartaxis + \def\pgfplots@visphase@notify@changeofcanvaslimits##1{}% + \def\pgfplots@avoid@empty@axis@range@for##1{}% + \def\pgfplotsaxisifcontainspoint##1##2{##1}% + \let\pgfplots@set@default@size@options=\pgfplots@set@default@size@options@smithchart% + % + \def\b@pgfplots@smithchart@defaultticks@x{0}% + \def\b@pgfplots@smithchart@defaultticks@y{0}% + \let\pgfplots@assign@default@tick@foraxis=\pgfplots@assign@default@tick@foraxis@smithchart + \def\pgfplots@checkisuniformLINEARtick##1##2{% + % don't do anything here. I suppose it is useless and is a + % waste of time for many ticks. + \global\pgfplots@isuniformtickfalse + }% + \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@smithchartaxis + % + % invalid range: do not clear plots. simply assign default limits. + \let\pgfplots@handle@invalid@range@defaultlimits=\pgfplots@handle@invalid@range@defaultlimits@smithchart% + \def\pgfplots@handle@invalid@range{\pgfplots@handle@invalid@range@defaultlimits}% + % + \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@smithchartaxis + \let\pgfplots@draw@axis@is@prepared=\pgfplots@draw@axis@is@prepared@smithchartaxis + \let\pgfplots@drawgridlines@onorientedsurf@fromto=\pgfplots@drawgridlines@onorientedsurf@fromto@smithchart + \let\pgfplots@drawaxis@innerlines@onorientedsurf=\pgfplots@drawaxis@innerlines@onorientedsurf@smithchart + \let\pgfplots@drawaxis@outerlines@separate@onorientedsurf=\pgfplots@drawaxis@outerlines@separate@onorientedsurf@smithchartaxis + \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@smithchart% + \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@smithchart + \expandafter\def\expandafter\pgfplots@create@axis@descriptions@\expandafter{% + \pgfplots@create@axis@descriptions@ + \ifpgfplots@smithchart@showorigin + \pgfkeysvalueof{/pgfplots/show origin code/.@cmd}\pgfeov% + \fi + }% + \def\axisdefaultheight{\axisdefaultwidth}% + \let\pgfplots@BB@for@plotbox@get@unit@scales@for@limits=\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@smithchart + %\let\pgfplots@limits@ready=\pgfplots@limits@ready@smithchart + %\let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@@smithchart + %\def\pgfplots@xtick@disable@last@tick{0}% + \let\pgfplots@xtick@check@tickshow=\pgfplots@xtick@check@tickshow@smithchart% + \let\pgfplots@ytick@check@tickshow=\pgfplots@ytick@check@tickshow@smithchart% + \let\pgfplots@set@options@sanitize=\relax + \let\pgfplots@set@options@sanitizemode=\relax + \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@smithchart + % + \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{% + \pgfplots@notify@options@are@set + \pgfplotsset{% + separate axis lines,% + is smithchart cs=false,% + xtick pos=left, + ytick pos=left, + axis x line*=center, + disabledatascaling, + }% + \def\pgfplots@xtickposnum{2}% + % + \ifx\pgfplots@xtick\pgfutil@empty + \def\b@pgfplots@smithchart@defaultticks@x{1}% + \fi + \ifx\pgfplots@ytick\pgfutil@empty + \def\b@pgfplots@smithchart@defaultticks@y{1}% + \fi + \pgfplotscoordmath{default}{parsenumber}{0.002}% + \let\pgfplots@almost@zero@thresh=\pgfmathresult + }% + \def\pgfplots@xticklabel@pos{}% + \def\pgfplots@yticklabel@pos{}% + \def\pgfplots@zticklabel@pos{}% + \def\pgfplots@init@ticklabelaxisspecfor##1##2{}% + \def\pgfplots@init@ticklabelaxisspec@twodim@for##1##2{}% + \def\pgfplotspointonorientedsurfaceabmatchaxisline@warn##1{}% clear warning. It works for smith charts. + \def\pgfplots@xticklabelaxisspec{v20}% + \def\pgfplots@yticklabelaxisspec{0v0}% + \def\pgfplots@zticklabelaxisspec{00v}% + % + % cartesian cs + \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end}% + % + % + % Special treatment for + % \pgfplots@prepare@tick@coordlists@for: make sure we don't need + % to use the register arithmetics in \pgfplots@xmin@reg and its + % variants! I want an UNRESTRICTED max data range! + \def\pgfplots@prepare@tick@coordlists@for@assign##1=##2{\edef##1{##2}}% + \def\pgfplots@prepare@tick@coordlists@for@advance##1by##2{% + % THIS IS NEVER USED (at the time of this writing). + \edef\pgfplots@loc@TMPa{##2}% + \pgfplotscoordmath{default}{parsenumber}{##1}% + \pgfplotscoordmath{default}{op}{add}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% + \let##1=\pgfmathresult + }% + \def\pgfplots@prepare@tick@coordlists@for@tofixed##1{\edef\pgfmathresult{##1}}% + \def\pgfplots@prepare@tick@coordlists@for@handletolerance##1{}% does not apply to smithcharts. + \def\pgfplots@prepare@tick@coordlists@for@checktickmin##1{% + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tmpa}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@##1tickmin\endcsname}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfplotscoordmath{default}{if less than}{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{% + \pgfplots@tickshowfalse + }{% + }% + }% + \def\pgfplots@prepare@tick@coordlists@for@checktickmax##1{% + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tmpa}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@##1tickmin\endcsname}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfplotscoordmath{default}{if less than}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPa}{% + \pgfplots@tickshowfalse + }{% + }% + }% + \def\pgfplots@prepare@tick@coordlists@for@checkdatalimits##1{}% I won't do this here. Smithcharts are somewhat special. +}% + +\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{% + \pgfpointxy@orig{#1}{#2}% +}% +\def\pgfplotscoordmathnotifydatascalesetfor@smithchart#1{% + \def\pgfplotscoordmathnotifydatascalesetfor##1{}% + \edef\pgfplotscoordmathnotifydatascalesetfor@{#1}% + \def\pgfplotscoordmathnotifydatascalesetfor@@{x}% + \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@ + \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}% + \else + \def\pgfplotscoordmathnotifydatascalesetfor@@{y}% + \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@ + \pgfplotscoordmath{#1}{datascaletrafo set shift}{0}% + \fi + \fi + \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@smithchart +}% + +% #1: the "a" value on the oriented surf +% #2: the "b" value. +% #3: the shift along the normal. +% +\def\pgfplotspointonorientedsurfaceabwithbshift@smithchartaxis#1#2#3{% + % implement the shift in "b" direction explicitly: + \pgfpointadd + {\pgfplotspointonorientedsurfaceab{#1}{#2}}% + {% + \pgfplotspointonorientedsurfaceabtolinespec{v}{0}% + \afterassignment\pgfplots@gobble@until@relax + \pgf@xa=-#3\relax + \edef\pgfplots@shift@no@unit{\pgf@sys@tonumber\pgf@xa}% + \pgfqpointscale + {\pgfplots@shift@no@unit} + {\expandafter\pgfplotspointouternormalvectorofaxis\expandafter{\pgfplotsretval}}% + }% +} + + +% Computes the complex division +% (A + j B) / (C + j D) = (A C + B D + j (B C - A D) ) / (C^2 + D^2) +% and assigns the result to \pgfmathresult and \pgfmathresultim . Here +% 'j = sqrt{-1}' is the imaginary unit. +% +% #1 : A +% #2 : B +% #3 : C +% #4 : D +% +% The arithmetics is performed in \pgfplotscoordmath{default} (which +% uses the floating point unit in the initial configuration) +% +% Numbers are expected to be already parsed (i.e. you need to invoke +% \pgfplotscoordmath{default}{parsenumber}{#1}% +% \let\A=\pgfmathresult +% before) +\def\pgfplotscoordmathcomplexdivision#1#2#3#4{% + \begingroup + \edef\pgfplots@A{#1}% + \edef\pgfplots@B{#2}% + \edef\pgfplots@C{#3}% + \edef\pgfplots@D{#4}% + % + % + % ok, compute it: + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@A}{\pgfplots@C}}% + \let\pgfplots@AC=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@A}{\pgfplots@D}}% + \let\pgfplots@AD=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@B}{\pgfplots@D}}% + \let\pgfplots@BD=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@B}{\pgfplots@C}}% + \let\pgfplots@BC=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@C}{\pgfplots@C}}% + \let\pgfplots@CC=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@D}{\pgfplots@D}}% + \let\pgfplots@DD=\pgfmathresult + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@CC}{\pgfplots@DD}}% + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}% + \let\pgfplots@scale=\pgfmathresult + % + % + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@AC}{\pgfplots@BD}}% + \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@scale}}% + \let\pgfplots@x=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@BC}{\pgfplots@AD}}% + \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@scale}}% + \let\pgfplots@y=\pgfmathresult + % + \xdef\pgfplots@glob@TMPa{% + \noexpand\def\noexpand\pgfmathresult{\pgfplots@x}% + \noexpand\def\noexpand\pgfmathresultim{\pgfplots@y}% + }% + \endgroup + \pgfplots@glob@TMPa +}% + +\def\pgfplotsqpointxy@smithchartaxis#1#2{% + \pgf@process{% + \ifpgfplotspointisinsmithchartCS + \def\pgfplots@x{#1}% + \def\pgfplots@y{#2}% + \else + % compute rx + j* ry = (#1 + j * #2 -1) / (#1 + j*#2 + 1) + % + % I write + % #1 - 1 + j * #2 = A + j * B + % 1 + #1 + j * #2 = C + j * D + % + % -> rx + j * ry = (A + j B) / (C + j D) = (A C + B D + j (B C - A D) ) / (C^2 + D^2) + \pgfplotscoordmath{default}{parsenumber}{#1}% + \let\pgfplots@x=\pgfmathresult + % + \pgfplotscoordmath{default}{parsenumber}{#2}% + \let\pgfplots@D=\pgfmathresult + % + \pgfplotscoordmath{default}{one}% + \let\pgfplots@one=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@one}{\pgfplots@x}}% + \let\pgfplots@C=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@x}{\pgfplots@one}}% + \let\pgfplots@A=\pgfmathresult + % + \let\pgfplots@B=\pgfplots@D + % + \pgfplotscoordmathcomplexdivision\pgfplots@A\pgfplots@B\pgfplots@C\pgfplots@D + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% + \let\pgfplots@x=\pgfmathresult + \pgfplotscoordmath{default}{tofixed}{\pgfmathresultim}% + \let\pgfplots@y=\pgfmathresult + \fi + % + \pgfplotsqpointxy@smithchart@canvas\pgfplots@x\pgfplots@y +%\message{pgfplotsqpointxy{#1}{#2} ---> (\pgfplots@x,\pgfplots@y) ---> (\the\pgf@x,\the\pgf@y)}% + }% +}% + +\def\pgfplotsqpointxy@smithchart@canvas#1#2{% + \ifpgfplots@smithchart@mirrored + \pgfqpointxy@orig{-#1}{#2}% + \else + \pgfqpointxy@orig{#1}{#2}% + \fi +}% + +\def\pgfplots@clippath@prepare@for@axistype@smithchartaxis{% + \def\pgfplots@clippath@install##1{% + \pgfpathellipse + {\pgfplotsqpointxy@smithchart@canvas{0}{0}} + {\pgfplotsqpointxy@smithchart@canvas{1}{0}} + {\pgfplotsqpointxy@smithchart@canvas{0}{1}}% + \pgfplots@clippath@use@{##1}% + }% +}% + +\def\pgfplotspointouternormalvectorofaxis@smithchartaxis#1#2#3\relax{% + \if v#1% + \pgfqpoint{0pt}{1pt}% + \else + \if v#2% + \pgfplotspointouternormalvectorofaxisgetv{#1#2#3}% + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + \pgfpointdiff + {\pgfplotsqpointxy@smithchart@canvas{0}{0}}% + {\pgfplotsqpointxy{0}{\pgfplotsretval}}% + \pgfpointnormalised{}% + \else + \pgfqpoint{0pt}{1pt}% + \fi + \fi + \pgf@process{}% + \endgroup +}% + +\def\pgfplotspoint@initialisation@axes@smithchart{% + \begingroup + %\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}% + \gdef\pgfplotspointminminmin{\pgfplotsqpointxy@smithchart@canvas{0}{0}}% + % + % the "x" axis is the diameter of the circle (for fixed y=0) + \pgf@x=2\pgf@xx + \pgf@y=0pt + \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \xdef\pgfplotspointxaxislength{\pgfmathresult pt}% + % + \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}% + \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + % + % the length of the "y" axis is 2*pi*r (for fixed x=0, the outer + % circle). + % The radius is the length of (0,1) which is (0pt,\pgf@xx1): + \pgfmath@basic@multiply@{\pgf@sys@tonumber\pgf@xx}{1}% + \pgfmathmultiply@{\pgfmathresult}{6.28318530717959}% 2*pi * r + \xdef\pgfplotspointyaxislength{\pgfmathresult pt}% + % + \global\let\pgfplotspointzaxis=\pgfpointorigin + \gdef\pgfplotspointzaxislength{0pt}% + \endgroup + % + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xx}% + \pgfmathdivide@{16000}{\pgfplots@loc@TMPa}% + \let\pgfplots@smithchart@axis@max@xradius@for@ycircle=\pgfmathresult + % + \ifdim\pgf@xx=\pgf@yy + \def\pgfplots@smithchart@axis@ratioxy{1}% + \def\pgfplots@smithchart@axis@ratioyx{1}% + \let\pgfplots@smithchart@axis@max@yradius@for@ycircle=\pgfplots@smithchart@axis@max@xradius@for@ycircle + \else + \edef\pgfplots@loc@TMPb{\pgf@sys@tonumber\pgf@yy}% + \pgfmathdivide@\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \let\pgfplots@smithchart@axis@ratioxy=\pgfmathresult + \pgfmathdivide@\pgfplots@loc@TMPb\pgfplots@loc@TMPa + \let\pgfplots@smithchart@axis@ratioyx=\pgfmathresult + % + \pgfmathdivide@{16000}{\pgfplots@loc@TMPb}% + \let\pgfplots@smithchart@axis@max@yradius@for@ycircle=\pgfmathresult + \fi +} +\let\pgfplotspoint@initialisation@units@orig=\pgfplotspoint@initialisation@units +\def\pgfplotspoint@initialisation@units@smithchart{% + \pgfplotspoint@initialisation@units@orig + \def\pgfplotspointunity{% + \pgfplotspointouternormalvectorofaxisgetv{0v0}% x=0 (outer circle) and v varies (the yticks) + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + \pgfpointnormalised{\pgfplotsqpointxy{0}{\ifx\pgfplotsretval\pgfutil@empty 0\else\pgfplotsretval\fi}}% + \pgf@xa=-\pgf@y + \global\pgf@y=\pgf@x + \global\pgf@x=\pgf@xa + }% + \def\pgfplotsunitylength{1}% + \def\pgfplotsunityinvlength{1}% +}% + +\def\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf@smithchartaxis#1{% + %\pgfplots@clippath@install{\pgfusepath{clip}}% +}% + +% At this time, the minor/major tick lists are initialised. +\def\pgfplots@draw@axis@is@prepared@smithchartaxis{% + \pgfplots@gridlines@init@grid@stop@points@for xy% + \pgfplots@gridlines@init@grid@stop@points@for yx% + % + % and finalize x: + \def\pgfplots@finalize@constraints{1}% + \pgfplots@gridlines@init@grid@stop@points@for@computethem{x}{y}{\pgfplots@finalize@constraints}% +}% + + +% Initialises the '#1grid each nth passes #2' and '#1grid stop at #2' +% features. All it does is to prepare the +% method \pgfplots@get@current@grid@stop@point. +% +% The method is quite involved. Please refer to the manual for what it +% is supposed to do, and refer to the code comments below for +% implementational details. +% +% #1 either x or y +% #2 either x or y +\def\pgfplots@gridlines@init@grid@stop@points@for#1#2{% + % + \expandafter\let\csname pgfplots@#1grid@stop@points\endcsname=\relax + % + \pgfkeysgetvalue{/pgfplots/#1grid each nth passes #2}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + % we have no "xticknum -> xtickpos" lookup table yet. + \expandafter\def\csname b@pgfplots@#2ticknum@to@pos@lookup\endcsname{0}% + % + \pgfplotslistnewempty\pgfplots@loc@TMPd + % normalise the argument for 'ygrid each nth passes x': each list element + % should be of the form ':' where means that each + % th arc can pass. + \expandafter\pgfplotsutilforeachcommasep\pgfplots@loc@TMPa\as\entry{% + \expandafter\pgfplots@gridlines@init@grid@stop@points@for@normalise\entry\relax#1#2% + \expandafter\pgfplotslistpushback\entry\to\pgfplots@loc@TMPd + }% + \expandafter\let\csname pgfplots@#1grid@stop@points\endcsname=\pgfplots@loc@TMPd + % + % Ok. + % + % Now, the 'ygrid each nth passes x' feature relies *crucially* on grid line + % indices (for the 'each nth' feature). + % + % I sort the arcs according to their absolute magnitude and assign + % indices into the resulting arrays to normalize that stuff. + % + % The array is of the form + % A[i] = entry of \pgfplots@prepared@tick@positions@* + % and contains *both*, major and minor grid lines. + \pgfplotsarraynewempty\pgfplots@gridlines + \pgfplotscoordmath{default}{zero}% + \edef\elem{{-1}{\pgfmathresult}}% require 0 to be zero for symmetry even if there is no such tick pos + \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines + \pgfplots@if{pgfplots@#1majorgrids}{% + % insert all major tick positions, using their absolute value. + \expandafter + \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#1\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}% + \pgfplotscoordmath{default}{op}{abs}{{\pgfmathresult}}% + \edef\elem{{\pgfplots@ticknum}{\pgfmathresult}}% + \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines + }% + }{}% + \pgfplots@if{pgfplots@#1minorgrids}{% + % now the same for minor grid positions: + \expandafter + \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#1\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}% + \pgfplotscoordmath{default}{op}{abs}{{\pgfmathresult}}% + \edef\elem{{\pgfplots@ticknum}{\pgfmathresult}}% + \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines + }% + }{}% + % sort the array! + \pgfkeysgetvalue{/pgfplots/smithchart@sortlt/.@cmd}\pgfplots@loc@TMPa + \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplots@loc@TMPa + \pgfplotsarraysort\pgfplots@gridlines + % + % ok. Now it is sorted. + % + % I finally need a lookup + % \pgfplots@ticknum --> sort index. + % If the associated values have the same absolute value, the same + % sort index should be assigned. + % + % For example, the array might be associated to the following tick + % positions, sorted by absolute value: + % 0.0, 1.0, -1.0, 3.0, -3.0, 4.0, -4.0, 5.0, -5.0 + % What I want is that + % 0.0 gets sort index 0 + % 1.0 and -1.0 get sort index 1 + % 3.0 and -3.0 get sort index 2 + % 4.0 and -4.0 get sort index 3 + % and so on. The array contains only absolute values, so that's + % not too difficult to check. + % + % Since each of the tick positions can be (uniquely) identified by + % its associated \pgfplots@ticknum value, I map \pgfplots@ticknum + % to the sort index. + \countdef\c@sortindex=\c@pgf@counta + \c@sortindex=\pgfkeysvalueof{/pgfplots/#1grid each nth passes #2 start} % this is assigned to the '0.0' gridline (if any) + \def\pgfplots@lasttickpos{}% + \pgfplotsarrayforeachungrouped\pgfplots@gridlines\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \ifx\pgfplots@lasttickpos\pgfutil@empty + \else + \ifx\pgfplots@lasttickpos\pgfplots@tick + \else + \advance\c@sortindex by1 + \fi + \fi + \expandafter\edef\csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname{\the\c@sortindex}% +%\message{\pgfplots@ticknum\space(abs(tickpos) = \pgfplots@tick)---> sort index \csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname^^J}% + \let\pgfplots@lasttickpos=\pgfplots@tick + }% + % + % unfortunately, I can't free the \pgfplots@gridlines array + % without extensive overhead :-( + \fi + % + \expandafter\let\csname b@pgfplots@#1gridline@stopmap\endcsname\relax + \pgfkeysgetvalue{/pgfplots/#1grid stop at #2}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa,}% this inserts the final comma and handles any active ':' sign (for french babel) + \def\pgfplots@loc@TMPb{\pgfplots@gridlines@init@stop@maps #1#2}% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI% + \fi + % + % + % Now, compute all final stop positions. Also prepare the cross + % dependencies between x grids and y grids here (such that there + % is no grid line stopping in white space) + % + \if#1x% + \def\pgfplots@finalize@constraints{0}% we have to wait until y stop points are known. + \else + \def\pgfplots@finalize@constraints{1}% + \fi + \pgfplots@gridlines@init@grid@stop@points@for@computethem{#1}{#2}{\pgfplots@finalize@constraints}% +}% +% #1,#2,#3 the arguments for +% \pgfplots@gridlines@preparation@get@current@grid@stop@point +\def\pgfplots@gridlines@init@grid@stop@points@for@computethem#1#2#3{% + % + \expandafter\pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#1\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}\let\pgfplots@tick=\pgfmathresult + \pgfplots@gridlines@preparation@get@current@grid@stop@point{#1}{#2}{\pgfplots@tick}{#3}% + \if1#3% + \pgfplots@gridlines@let{#1}{\pgfplots@tick@prepared}=\pgfplotsretval + \fi + }% + \expandafter\pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#1\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}\let\pgfplots@tick=\pgfmathresult + \pgfplots@gridlines@preparation@get@current@grid@stop@point{#1}{#2}{\pgfplots@tick}{#3}% + \if1#3% + \pgfplots@gridlines@let{#1}{\pgfplots@tick@prepared}=\pgfplotsretval + \fi + }% + \expandafter\def\csname b@pgfplots@#1gridline@stopmap\endcsname{1}% +} + +\def\pgfplots@gridlines@init@stop@maps#1#2{% + \pgfutil@ifnextchar\pgfplots@EOI{% + \pgfutil@gobble + }{% + \pgfutil@ifnextchar,{% + \pgfplots@gridlines@init@stop@maps@next@@#1#2% + }{% + \pgfplots@gridlines@init@stop@maps@next#1#2% + }% + }% +}% +\def\pgfplots@gridlines@init@stop@maps@next#1#2#3:#4,{% + \pgfplotscoordmath{default}{parsenumber}{#4}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplots@gridlines@stopmap@prepare{#3}% + \pgfplots@gridlines@let{#1}{\pgfmathresult}=\pgfplots@loc@TMPa + \expandafter\def\csname b@pgfplots@#1gridline@stopmap\endcsname{1}% + % + \pgfplots@gridlines@init@stop@maps #1#2% +} +% just eat one empty comma: +\def\pgfplots@gridlines@init@stop@maps@next@@#1#2,{\pgfplots@gridlines@init@stop@maps #1#2}% +\def\pgfplots@gridlines@let#1#2=#3{% + \expandafter\let\csname pgfplots@#1gridline@stopmap@#2\endcsname=#3% + \if#1y% + % support symmetry: + % add -\pgfmathresult to the map. + % To disable this symmetry, use 'ygrid stop at x={0.2:4 -0.2:5} + % you can also use an empty value '-0.2:{}', that's also ok. + \expandafter\let\csname pgfplots@#1gridline@stopmap@-#2\endcsname=#3% + \fi +}% + +\def\pgfplots@gridlines@stopmap@prepare@digits{2}% +\def\pgfplots@gridlines@stopmap@prepare#1{% + \begingroup + \pgfmathfloatparsenumber{#1}% + \let\pgfmathfloat@round@precision=\pgfplots@gridlines@stopmap@prepare@digits% + \pgfmathfloatroundzerofill\pgfmathresult + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfplots@gridlines@stopmap@trunc@#1.#2#3#4\relax{% + \def\pgfmathresult{#1.#2#3}% +}% + +\pgfkeysdefargs{/pgfplots/smithchart@sortlt}{#1#2#3#4}{% + \expandafter\pgfplots@prepared@tick@pos@unpack#1% + \let\pgfplots@A=\pgfplots@tick + \expandafter\pgfplots@prepared@tick@pos@unpack#2% + \let\pgfplots@B=\pgfplots@tick + \pgfplotscoordmath{default}{if less than}{\pgfplots@A}{\pgfplots@B}{#3}{#4}% +}% + +% initialise a lookuptable from ticknumber -> tick position (sort +% of an array) +% +% This is only invoked if it is needed (if 'arc +% limits={[index]4,[index]2}' or something like that is used, see the +% manual). +% +% #1 either x or y +% #2 either x or y +\def\pgfplots@gridlines@init@grid@stop@points@for@init@ticknum@lookup#1#2{% + \c@pgf@counta=0 + \pgfplots@if{pgfplots@#1majorgrids}{% + \expandafter + \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#2\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \expandafter\let\csname pgfplots@#2tick@num@to@pos@\the\c@pgf@counta\endcsname=\pgfplots@tick + \advance\c@pgf@counta by1 + }% + }{}% + \pgfplots@if{pgfplots@#1minorgrids}{% + \expandafter + \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#2\endcsname\as\elem{% + \expandafter\pgfplots@prepared@tick@pos@unpack\elem + \expandafter\let\csname pgfplots@#2tick@num@to@pos@\the\c@pgf@counta\endcsname=\pgfplots@tick + \advance\c@pgf@counta by1 + }% + }{}% + \expandafter\def\csname b@pgfplots@#2ticknum@to@pos@lookup\endcsname{1}% +}% +\def\pgfplots@gridlines@init@grid@stop@points@for@normalise#1\relax#2#3{% + \def\b@pgfplots@haslt{0}% + % + \pgfutil@in@{if <}{#1}% + \ifpgfutil@in@ + % strip the white space between 'if' and '<': + \def\pgfplots@loc@TMPa##1if <##2\relax{\edef\entry{##1if<##2}}% + \expandafter\pgfplots@loc@TMPa\entry\relax + \def\b@pgfplots@haslt{1}% + \fi + % + \pgfutil@in@{if<}{#1}% + \ifpgfutil@in@ + \def\b@pgfplots@haslt{1}% + \fi + % + \pgfutil@in@:{#1}% + \ifpgfutil@in@ + \def\b@pgfplots@hascolon{1}% + \else + \def\b@pgfplots@hascolon{0}% + \fi + % + \if1\b@pgfplots@hascolon + \edef\entry{\entry\if0\b@pgfplots@haslt if<\fi}% + \else + \if1\b@pgfplots@haslt + \expandafter\pgfplots@gridlines@stop@at@unpack@@@\entry\relax + \edef\entry{\pgfplots@grid@stop@at:2if<\pgfplots@grid@stop@at@iflt}% + \else + \edef\entry{\entry:2if<}% + \fi% + \fi% + % + \pgfutil@in@{[index]}{#1}% + \ifpgfutil@in@ + \if0\csname b@pgfplots@#3ticknum@to@pos@lookup\endcsname + \pgfplots@gridlines@init@grid@stop@points@for@init@ticknum@lookup#2#3% + \fi + \expandafter\pgfplots@gridlines@stop@at@unpack\entry\relax + \pgfutil@ifundefined{pgfplots@#3tick@num@to@pos@\pgfplots@grid@stop@at}{% + \pgfplotswarning{smithchart/no such tick}{#3}{\pgfplots@grid@stop@at}\pgfeov + \let\entry=\pgfutil@empty + }{% + \edef\entry{\csname pgfplots@#3tick@num@to@pos@\pgfplots@grid@stop@at\endcsname:\pgfplots@grid@stop@at@eachnth}% + }% + \fi + % + \expandafter\pgfplots@gridlines@stop@at@unpack\entry\relax + \pgfplotscoordmath{default}{parsenumber}\pgfplots@grid@stop@at + \let\pgfplots@grid@stop@at=\pgfmathresult + \ifx\pgfplots@grid@stop@at@iflt\pgfutil@empty + \else + \pgfplotscoordmath{default}{parsenumber}\pgfplots@grid@stop@at@iflt + \let\pgfplots@grid@stop@at@iflt=\pgfmathresult + \fi + \edef\entry{\pgfplots@grid@stop@at:\pgfplots@grid@stop@at@eachnth if<\pgfplots@grid@stop@at@iflt}% +}% +\def\pgfplots@gridlines@stop@at@unpack@@@#1if<#2\relax{% + \def\pgfplots@grid@stop@at{#1}% + \def\pgfplots@grid@stop@at@iflt{#2}% +}% +\def\pgfplots@gridlines@stop@at@unpack#1:#2if<#3\relax{% + \def\pgfplots@grid@stop@at{#1}% + \def\pgfplots@grid@stop@at@eachnth{#2}% + \def\pgfplots@grid@stop@at@iflt{#3}% +}% + +% Returns the xtick position which should end the current arc. +% +% This is an INTERNAL preparation method. See +% \pgfplots@get@current@grid@stop@point for the final one. +% +% Note that arcs correspond to ygrid lines. +% +% #1 either x or y +% #2 either x or y +% #3 the value of the current grid line +% #4 a boolean which expands either to 0 or to 1. +% The \pgfplots@get@current@grid@stop@point@handle@constraints method +% will be invoked if and only if #4=1 +% +% @POSTCONDITION On output, +% - \pgfplotsretval will be filled with the +% result. If the result is empty, no restriction is imposed. +% Otherwise, it contains the #2tick value at which the current #1grid shall end. +% The result is already processed with +% \pgfplotscoordmath{default}{parsenumber}{} +% - \pgfplots@tick@prepared contains a rounded representation of #3. +% +% The method relies on the 'ygrid each nth passes x' feature, more specifically the +% stuff prepared by \pgfplots@gridlines@init@grid@stop@points@for +\def\pgfplots@gridlines@preparation@get@current@grid@stop@point#1#2#3#4{% + \def\pgfplotsretval{}% + % + \pgfplots@gridlines@stopmap@prepare{#3}% + \let\pgfplots@tick@prepared=\pgfmathresult + \pgfmathfloatabs@\pgfplots@tick@prepared + \let\pgfplots@tick@prepared@abs=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{abs}{{#3}}% + \let\pgfplots@tick@abs=\pgfmathresult + % + % first: check the '#1grid stop at #2': + \expandafter\ifx\csname b@pgfplots@#1gridline@stopmap\endcsname\relax% + % ok. there is no such thing. + \else + % ah - process it! + \pgfutil@ifundefined{pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared}{% + }{% + \edef\pgfplotsretval{\csname pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared\endcsname}% + }% + \fi + % + \ifx\pgfplotsretval\pgfutil@empty + % the individual map failed. Ok, then check for the '#1grid each nth passes #2' + \expandafter\ifx\csname pgfplots@#1grid@stop@points\endcsname\relax + \else + % \pgfplots@ticknum is defined in this context here. + \pgfutil@ifundefined{pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum}{% + \pgfplots@warning{Sorry, I can't get the current arc limit for #1grid no \#\pgfplots@ticknum\space(value \pgfplots@tick). This seems like an internal error!?}% + }{% + % get the sort index for the current tick (which is + % uniquely identified by its \pgfplots@ticknum) + \expandafter\let\expandafter\pgfplots@k\csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname + % + \expandafter\pgfplotslistforeachungrouped\csname pgfplots@#1grid@stop@points\endcsname\as\pgfplots@loc@TMPa{% + \ifx\pgfplotsretval\pgfutil@empty + % we found no final limit so far. proceed. + \expandafter\pgfplots@gridlines@stop@at@unpack\pgfplots@loc@TMPa\relax + \ifx\pgfplots@grid@stop@at@iflt\pgfutil@empty + \pgfplots@loop@CONTINUEtrue + \else + \pgfplotscoordmath{default}{if less than}{\pgfplots@tick@abs}{\pgfplots@grid@stop@at@iflt}{% + \pgfplots@loop@CONTINUEtrue + }{% + \pgfplots@loop@CONTINUEfalse + }% + \fi + % + \ifpgfplots@loop@CONTINUE + \pgfplotsmathmodint\pgfplots@k\pgfplots@grid@stop@at@eachnth + \ifnum\pgfmathresult=0 + \c@pgf@counta=\pgfplots@k + \divide\c@pgf@counta by\pgfplots@grid@stop@at@eachnth\relax + \edef\pgfplots@k{\the\c@pgf@counta}% + \else + % found the final limit. + % + % Now, check the constraints which couple + % X and Y. + \let\pgfplotsretval=\pgfplots@grid@stop@at + \if1#4% + \pgfplots@get@current@grid@stop@point@handle@constraints #1#2{#3}% + \fi + \fi + \fi + \fi + }% + }% + \fi + \fi + \ifx\pgfplotsretval\pgfutil@empty + \else + \expandafter\let\csname pgfplots@final@stop@point@for@#1tick@\pgfplots@tick@prepared\endcsname=\pgfplotsretval +%\message{#1 grid line: storing end value for '#3' END[\pgfplots@tick@prepared] = \pgfplotsretval.^^J}% + \fi +}% + +% PRECONDITION +% \pgfplotsretval contains a non-zero constraint for the ygrid at #1. +% +% POSTCONDITION +% either \pgfplotsretval is unchanged, or it is reset to +% \pgfutil@empty if constraints are violated. +% +% The constraints are ONLY effective if BOTH, incomplete x- and y grid +% lines are in effect. In that case, it should never happen that a +% single grid line ends in a dead-end somewhere in white space. +% +% I enforce two constraints which apply only to ygrid to fix this +% issue (this may be improved later). +% +% The idea is simple: +% 1. suppose the grid line 'x=1' stops at 'y=5'. +% Suppose further that the y grid line 'y=0.95' should stop at 'x=1'. +% Is that acceptable? Yes, because |y| < 5. +% Now, suppose an y grid line with |y| > 5 should stop at 'x=1'. +% Is this allowed? NO! Because it would become a dead end since +% the 'x=1' line ends at 'y=5'! +% +% So, whenever we consider ygrids and stop point candidates "x=X", +% acquire the value Q where the x (!) grid line "x=X" stops. +% If |y| > Q, the candidate "x=X" is rejected. +% +% 2. There might still be the case that x grid lines have dead-ends. +% The current solution applies the idea first to all y grid lines, +% and once the y grid lines are ready, it applies the same idea to +% x grid lines. +% +% Uncomment the routine(s) and run the test cases to see what happens. +\def\pgfplots@get@current@grid@stop@point@handle@constraints#1#2#3{% + \ifx\pgfplotsretval\pgfutil@empty + \else + \pgfplots@gridlines@stopmap@prepare{\pgfplotsretval}% + \let\pgfplots@loc@TMPa=\pgfmathresult + % +%\message{checking ending '#1=#3' at '#2=\pgfplotsretval'. '#2=\pgfplots@loc@TMPa' stops}% + \pgfutil@ifundefined{pgfplots@final@stop@point@for@#2tick@\pgfplots@loc@TMPa}{% + % no constraint. Ok. +%\message{ nowhere. No constraint.^^J}% + }{% +%\message{ at \pgfplots@loc@TMPa. Feasible: }% + % Oh, a constraint. That means + % further work. + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@final@stop@point@for@#2tick@\pgfmathresult\endcsname + \pgfplotscoordmath{default}{op}{abs}{{#3}}% + \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@loc@TMPa}{% + % ok, we can use the found + % stop value. +%\message{YES.^^J}% + }{% +%\message{NO.^^J}% + % no, the stop value is + % invalid; it would stop in + % white space! + \let\pgfplotsretval=\pgfutil@empty + }% + }% + \fi +}% + +% Returns the xtick position which should end the current arc. +% +% Note that arcs correspond to ygrid lines. +% +% #1 either x or y +% #2 either x or y +% #3 the value of the current grid line +% +% @POSTCONDITION On output, \pgfplotsretval will be filled with the +% result. If the result is empty, no restriction is imposed. +% Otherwise, it contains the #2tick value at which the current #1grid shall end. +% The result is already processed with +% \pgfplotscoordmath{default}{parsenumber}{} +% +% The method relies on the 'ygrid each nth passes x' feature, more specifically the +% stuff prepared by \pgfplots@gridlines@init@grid@stop@points@for +% +% Note that all work has already been done by +% \pgfplots@gridlines@init@grid@stop@points@for. We only need to query +% the result at this point. +% @see \pgfplots@gridlines@init@grid@stop@points@for +% @see \pgfplots@gridlines@preparation@get@current@grid@stop@point +\def\pgfplots@get@current@grid@stop@point#1#2#3{% + \def\pgfplotsretval{}% + % + % check the '#1grid stop at #2': + \expandafter\ifx\csname b@pgfplots@#1gridline@stopmap\endcsname\relax% + % ok. there is no such thing. + \else + % + \pgfplots@gridlines@stopmap@prepare{#3}% + \let\pgfplots@tick@prepared=\pgfmathresult + \pgfmathfloatabs@\pgfplots@tick@prepared + \let\pgfplots@tick@prepared@abs=\pgfmathresult + % + % ah - process it! + \pgfutil@ifundefined{pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared}{% + \let\pgfplotsretval\pgfutil@empty + }{% + \edef\pgfplotsretval{\csname pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared\endcsname}% + }% + \fi + % +}% + + +\def\pgfplots@smithchart@draw@xcircle#1{% + \pgfplotscoordmath{default}{one}% + \let\pgfplots@loc@TMPa=\pgfmathresult + % + \pgfplotscoordmath{default}{parsenumber}{#1}% + \let\pgfplots@x=\pgfmathresult + % + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@loc@TMPa}{\pgfplots@x}}% + \let\pgfplots@radius@inverse=\pgfmathresult + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}% + \let\pgfplots@radius=\pgfmathresult + \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@x}}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% + \let\pgfplots@center=\pgfmathresult + % + \pgfplotscoordmath{default}{tofixed}{\pgfplots@radius}% + \let\pgfplots@radius=\pgfmathresult + % + \pgfplotscoordmath{default}{tofixed}{\pgfplots@radius@inverse}% + \let\pgfplots@radius@inverse=\pgfmathresult + % + % This here would suffice in case 'xgrid each nth passes y={}': +% \pgfpathellipse +% {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@center}{0}} +% {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@radius}{0}} +% {\pgfplotsqpointxy@smithchart@canvas{0}{\pgfplots@radius}}% + % + % but we also check for the 'xgrid each nth passes y' feature: + \pgfplots@get@current@grid@stop@point xy{\pgfplots@x}% + \let\pgfplots@arc@ends@at@y@arc@value\pgfplotsretval% + % + \ifx\pgfplots@arc@ends@at@y@arc@value\pgfutil@empty + % Ok. There is no specific end point -- simply use the + % (1,0) point (i.e. draw the full circle). + % + \pgfmathadd@{\pgfplots@center}{\pgfplots@radius}% + \let\pgfplots@start=\pgfmathresult% + \def\pgfplots@startim{0}% + \def\pgfplots@startangle{0}% + \let\pgfplots@end=\pgfplots@start + \let\pgfplots@endim=\pgfplots@startim + \def\pgfplots@endangle{360}% + \else + % Ok. The arc should end before it reaches the (1,0) + % point. Determine the exact position and the + % corresponding arc end angle. + % + % In general, the intersection between the circle for + % fixed x=A and fixed y=B is given by + % + % p + j * q = (A + j * B -1 ) / ( A + j*B +1) + % see http://www.siart.de/lehre/tutorien.xhtml#smishort + \pgfplotscoordmath{default}{one}% + \let\pgfplots@one=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{-1}% + \let\pgfplots@mone=\pgfmathresult + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@x}{\pgfplots@mone}}% + \let\pgfplots@A@mone=\pgfmathresult + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@x}{\pgfplots@one}}% + \let\pgfplots@A@one=\pgfmathresult + % oh - we should only draw a partial arc. + % Well, then compute its end point and the + % corresponding end angle. + \pgfplotscoordmathcomplexdivision + {\pgfplots@A@mone}{\pgfplots@arc@ends@at@y@arc@value}% + {\pgfplots@A@one}{\pgfplots@arc@ends@at@y@arc@value}% + \let\pgfplots@start=\pgfmathresult + \let\pgfplots@startim=\pgfmathresultim + \pgfplotscoordmath{default}{tofixed}{\pgfplots@start}% + \let\pgfplots@start=\pgfmathresult + \pgfplotscoordmath{default}{tofixed}{\pgfplots@startim}% + \let\pgfplots@startim=\pgfmathresult + % + \pgfplots@compute@angle@of@point@in@circle\pgfplots@start\pgfplots@startim{\pgfplots@center}{\pgfplots@radius}{\pgfplots@radius@inverse}% + \let\pgfplots@startangle=\pgfmathresult + \pgfmathsubtract@{360}{\pgfplots@startangle}% + \let\pgfplots@endangle=\pgfmathresult + \let\pgfplots@end=\pgfplots@start + \edef\pgfplots@endim{-\pgfplots@startim}% + \ifdim\pgfplots@startangle pt>\pgfplots@endangle pt + \let\pgfplots@loc@TMPa=\pgfplots@startangle + \let\pgfplots@startangle=\pgfplots@endangle + \let\pgfplots@endangle=\pgfplots@loc@TMPa + \fi + \fi + % +%\message{X grid line \#\csname pgfplots@ticknum\endcsname \space at '#1': center = (\pgfplots@center,0); radius = \pgfplots@radius\space(start angle \pgfplots@startangle, end angle = \pgfplots@endangle; stops at y = \pgfplots@arc@ends@at@y@arc@value).^^J}% + % + % Now, compute the arc. + % + % first, compute the absolute x/y radii: + \pgf@xa=\pgfplots@radius\pgf@xx + \pgf@xb=\pgfplots@radius\pgf@yy + \edef\pgfplots@mirror@sign{\ifpgfplots@smithchart@mirrored -\fi}% + \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{\pgfplots@start}{\pgfplots@startim}}% + % note that the case startangle > endangle is + % automatically correct; patharc handles that. + %\edef\pgfplots@loc@TMPa{{\pgfplots@startangle}{\pgfplots@endangle}{\pgfplots@mirror@sign\the\pgf@xa\space and \the\pgf@xb}}% + %\expandafter\pgfpatharc\pgfplots@loc@TMPa + % + % prefer \pgfpatharctoprecomputed. It is faster and more accurate + \edef\pgfplots@loc@TMPa{% + {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@center}{0}}% + {\pgfplots@startangle}% + {\pgfplots@endangle}% + {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@end}{\pgfplots@endim}}% + {\pgfplots@mirror@sign\the\pgf@xa}% + {\the\pgf@xb}% + {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioxy}% + {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioyx}% + }% + \expandafter\pgfpatharctoprecomputed\pgfplots@loc@TMPa +} + +\def\pgfplots@smithchart@draw@yarc#1{% + \pgfplotscoordmath{default}{parsenumber}{#1}% + \let\pgfplots@y\pgfmathresult + \pgfplotscoordmath{default}{op}{abs}{{\pgfplots@y}}% + \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@almost@zero@thresh}{% + \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{-1}{0}}% + \pgfpathlineto{\pgfplotsqpointxy@smithchart@canvas{1}{0}}% + }{% + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplots@y}}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% + \let\pgfplots@signedradius=\pgfmathresult + % + \pgfplotscoordmath{default}{tofixed}{\pgfplots@y}% + \ifdim\pgfplots@signedradius pt<0pt + \def\pgfplots@radius@sign{-}% + \edef\pgfplots@radius@inverse{-\pgfmathresult}% + \edef\pgfplots@radius{-\pgfplots@signedradius}% + \else + \def\pgfplots@radius@sign{}% + \edef\pgfplots@radius@inverse{\pgfmathresult}% + \let\pgfplots@radius=\pgfplots@signedradius + \fi + % this here is the correct, complete circle -- together + % with a clip path, you get what you want: + %\pgfpathellipse + % {\pgfplotsqpointxy@smithchart@canvas{1}{\pgfplots@signedradius}} + % {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@signedradius}{0}} + % {\pgfplotsqpointxy@smithchart@canvas{0}{\pgfplots@signedradius}}% + % But I only want the arc (probably stopped earlier to + % improve qualtity of the chart) + % + % compute start point for the arc. + % + % To do so, we need to compute the intersection between + % the circle for fixed x=0 and the circle for y=#1. + % + % In general, the intersection between the circle for + % fixed x=A and fixed y=B is given by + % + % p + j * q = (A + j * B -1 ) / ( A + j*B +1) + % see http://www.siart.de/lehre/tutorien.xhtml#smishort + % + % inserting A = 0 and B = #1 yields the result + % p=\pgfplots@start + % q=\pgfplots@startim + % as follows: + \pgfplotscoordmath{default}{one}% + \let\pgfplots@one=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{-1}% + \let\pgfplots@mone=\pgfmathresult + \pgfplotscoordmathcomplexdivision{\pgfplots@mone}{\pgfplots@y}{\pgfplots@one}{\pgfplots@y}% + \let\pgfplots@start=\pgfmathresult + \let\pgfplots@startim=\pgfmathresultim + \pgfplotscoordmath{default}{tofixed}{\pgfplots@start}% + \let\pgfplots@start=\pgfmathresult + \pgfplotscoordmath{default}{tofixed}{\pgfplots@startim}% + \let\pgfplots@startim=\pgfmathresult + % + \pgfplots@compute@angle@of@point@in@circle\pgfplots@start\pgfplots@startim{1}{\pgfplots@signedradius}{\pgfplots@radius@inverse}% + \let\pgfplots@startangle=\pgfmathresult + % + % + % compute end angle. + \pgfplots@get@current@grid@stop@point yx{\pgfplots@y}% + \let\pgfplots@arc@ends@at@x@circle@value\pgfplotsretval% + % + \ifx\pgfplots@arc@ends@at@x@circle@value\pgfutil@empty + % Ok. There is no specific end point -- simply use the + % (1,0) point (i.e. draw the full arc). + % + % The "0 degree" angle in my circles is in the direction + % of (1,0) . + \ifdim\pgfplots@startim pt>0pt + % ok; this arc belongs to the upper hemisphere. + \def\pgfplots@endangle{270}% + \else + % ok; this arc belongs to the lower hemisphere. + \def\pgfplots@endangle{90}% + \fi + \def\pgfplots@end{1}% + \def\pgfplots@endim{0}% + \else + % Ok. The arc should end before it reaches the (1,0) + % point. Determine the exact position and the + % corresponding arc end angle. + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@arc@ends@at@x@circle@value}{\pgfplots@mone}}% + \let\pgfplots@A@mone=\pgfmathresult + \pgfplotscoordmath{default}{op}{add}{{\pgfplots@arc@ends@at@x@circle@value}{\pgfplots@one}}% + \let\pgfplots@A@one=\pgfmathresult + % oh - we should only draw a partial arc. + % Well, then compute its end point and the + % corresponding end angle. + \pgfplotscoordmathcomplexdivision{\pgfplots@A@mone}{\pgfplots@y}{\pgfplots@A@one}{\pgfplots@y}% + \let\pgfplots@end=\pgfmathresult + \let\pgfplots@endim=\pgfmathresultim + \pgfplotscoordmath{default}{tofixed}{\pgfplots@end}% + \let\pgfplots@end=\pgfmathresult + \pgfplotscoordmath{default}{tofixed}{\pgfplots@endim}% + \let\pgfplots@endim=\pgfmathresult + % + \pgfplots@compute@angle@of@point@in@circle\pgfplots@end\pgfplots@endim{1}{\pgfplots@signedradius}{\pgfplots@radius@inverse}% + \let\pgfplots@endangle=\pgfmathresult + \fi + % + % + % + % Now, compute the arc. + % + % first, compute the absolute x/y radii: + % + % Note that for small y (like y=0.01), the arc is almost a + % straight line. Consequently, the ellipsis radius will be much larger + % than 16000, violating TeX's number range. + % + % To avoid that, I clip it to the highest allowed value. + % The final radius is + % \pgfplots@radius * \pgf@xx and \pgfplots@radius * \pgf@yy. + % the clipped value thus needs to respect the magnitude of \pgf@xx and \pgf@yy. + \ifdim\pgfplots@radius pt<\pgfplots@smithchart@axis@max@xradius@for@ycircle pt + \let\pgfplots@radius@x\pgfplots@radius + \else + \let\pgfplots@radius@x=\pgfplots@smithchart@axis@max@xradius@for@ycircle + \fi + \ifdim\pgfplots@radius pt<\pgfplots@smithchart@axis@max@yradius@for@ycircle pt + \let\pgfplots@radius@y\pgfplots@radius + \else + \let\pgfplots@radius@y=\pgfplots@smithchart@axis@max@yradius@for@ycircle + \fi +%\message{Y grid line \#\csname pgfplots@ticknum\endcsname\space at '#1': center = (1,\pgfplots@signedradius); signedradius = \pgfplots@signedradius\space clipped radii = \pgfplots@radius@x*\the\pgf@xx\space and \pgfplots@radius@y*\the\pgf@yy\space ( start angle \pgfplots@startangle, end angle \pgfplots@endangle, arc limit: \ifx\pgfplots@arc@ends@at@x@circle@value\pgfutil@empty NONE\else \pgfplots@arc@ends@at@x@circle@value\fi)^^J}% + \pgf@xa=\pgfplots@radius@x\pgf@xx + \pgf@xb=\pgfplots@radius@y\pgf@yy + \edef\pgfplots@mirror@sign{\ifpgfplots@smithchart@mirrored -\fi}% + \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{\pgfplots@start}{\pgfplots@startim}}% + % note that the case startangle > endangle is + % automatically correct; patharc handles that. + %\edef\pgfplots@loc@TMPa{{\pgfplots@startangle}{\pgfplots@endangle}{\pgfplots@mirror@sign\the\pgf@xa\space and \the\pgf@xb}}% + %\expandafter\pgfpatharc\pgfplots@loc@TMPa + % + % prefer \pgfpatharctoprecomputed. It is faster and more accurate + \ifdim\pgfplots@startangle pt>\pgfplots@endangle pt + \let\pgfplots@loc@TMPa=\pgfplots@startangle +% \let\pgfplots@startangle=\pgfplots@endangle +% \let\pgfplots@endangle=\pgfplots@loc@TMPa + \fi + \edef\pgfplots@loc@TMPa{% + {\noexpand\pgfplotsqpointxy@smithchart@canvas{1}{\pgfplots@radius@sign\pgfplots@radius@y}}% + {\pgfplots@startangle}% + {\pgfplots@endangle}% + {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@end}{\pgfplots@endim}}% + {\pgfplots@mirror@sign\the\pgf@xa}% + {\the\pgf@xb}% + {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioxy}% + {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioyx}% + }% + \expandafter\pgfpatharctoprecomputed\pgfplots@loc@TMPa + }% +} + +\def\pgfplots@drawgridlines@onorientedsurf@fromto@smithchart#1{% + \if x\pgfplotspointonorientedsurfaceA + \pgfplots@smithchart@draw@xcircle{#1}% + \else + \pgfplots@smithchart@draw@yarc{#1}% + \fi +}% + +% Given a circle with center point (#3,#4), we search for the angle +% of the point (#1,#2). The point is expected to be on the circle. +% The resulting angle is returned in \pgfmathresult +% +% #1 x coordinate of the point for which an angle is searched +% #2 y coordinate of the point for which an angle is searched +% #3 x coordinate of the circle's center point +% #4 y coordinate of the circle's center point +% #5 is either empty or it is expected to contain the inverse radius, 1/r +% this information is available in my context, so I don't recompute +% it. +% +% All coordinates are expected in standard TeX precision (numbers +% without unit) +\def\pgfplots@compute@angle@of@point@in@circle#1#2#3#4#5{% + % + % 1. compute diff vector from center=(1,\pgfplots@signedradius) to start: + \pgfmathsubtract@{#1}{#3}% + \let\pgfplots@D\pgfmathresult + \pgfmathsubtract@{#2}{#4}% + \let\pgfplots@Dim\pgfmathresult + % + % 2. compute the start angle. + % It is related to the angle between the point (1,0) and + % diff, which, in turn is given by + % < (1,0), (D,Dim) > = cos(alpha) ||(D,Dim)|| + % < (1,0), (D,Dim) > = D + % + % Note that ||(D,Dim)|| = r, the radius of the involved circle + % around (#3,#4). If 1/r is already available, use it! Saves a lot + % of time. + % + \def\pgfplots@loc@TMPa{#5}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfmathveclen\pgfplots@D\pgfplots@Dim + \let\pgfplots@veclen=\pgfmathresult + \pgfmathreciprocal@\pgfplots@veclen + \let\pgfplots@inverseveclen=\pgfmathresult + \else + % oh, good -- we already have 1/||(D,Dim)||. Use it. + \def\pgfplots@inverseveclen{#5}% +%\message{using already available inverseveclen '#5' }% + \fi + \pgfmathmultiply@{\pgfplots@D}{\pgfplots@inverseveclen}% +%\message{D= (\pgfplots@D,\pgfplots@Dim).. acos(\pgfplots@D * \pgfplots@inverseveclen) = acos(\pgfmathresult)}% + \pgfmathacos@{\pgfmathresult}% the '-' comes from D<0 . +%\message{= \pgfmathresult^^J}% + \let\pgfplots@tmpangle\pgfmathresult% + % ok. tmpangle is per definition less than 180; it is the + % smaller angle between (1,0) and (D,Dim). + % + % compute the angle relative to (1,0): + \ifdim\pgfplots@Dim pt<0pt + \pgfmathiftrigonometricusesdeg{% + \pgfmathsubtract@{360}{\pgfplots@tmpangle}% + }{% + \pgfmathsubtract@{6.28318530717959}{\pgfplots@tmpangle}% + }% + \fi +}% + +\def\pgfplots@drawaxis@innerlines@onorientedsurf@smithchart#1#2#3{% + \if2\csname pgfplots@#1axislinesnum\endcsname + \draw[/pgfplots/every inner #1 axis line,% + decorate,% + #1discont,% + decoration={pre length=\csname #1disstart\endcsname, post length=\csname #1disend\endcsname}] + \pgfextra + \csname pgfplotspointonorientedsurfaceabsetupforset#3\endcsname{\csname pgfplots@logical@ZERO@#3\endcsname}{2}% + \if#1x% + \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + \pgfplots@drawgridlines@onorientedsurf@fromto{0}% + \else + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}% + \fi + \endpgfextra + ; + \fi +}% +\def\pgfplots@drawaxis@outerlines@separate@onorientedsurf@smithchartaxis#1#2{% + \if2\csname pgfplots@#1axislinesnum\endcsname + % centered axis lines handled elsewhere. + \else + \scope[/pgfplots/every outer #1 axis line, + #1discont,decoration={pre length=\csname #1disstart\endcsname, post length=\csname #1disend\endcsname}] + \if#1x + \draw decorate { + \pgfextra + % exchange roles of A <-> B axes: + \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + \pgfplots@drawgridlines@onorientedsurf@fromto{0}% + \endpgfextra + }; + \else + \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% + \draw decorate { + \pgfextra + % exchange roles of A <-> B axes: + \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2min\endcsname}% + \endpgfextra + }; + }{}% + %-------------------------------------------------- + % \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% + % \draw decorate { + % \pgfextra + % % exchange roles of A <-> B axes: + % \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + % \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2max\endcsname}% + % \endpgfextra + % }; + % }{}% + %-------------------------------------------------- + \fi + \endscope + \fi +}% + +\def\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@smithchart#1#2#3{% + % In a smith chart, the size of the image is unrelated to the + % involved data limits. + % + % The factor 2 is because we want to fit the DIAMETER into the + % prescribed dimensions, not just the radius. + \def\pgfmathresult{2}% + \let#1=\pgfmathresult + \let#2=\pgfmathresult + \def#3{1}% +}% + +\def\pgfplots@handle@invalid@range@defaultlimits@smithchart{% + \pgfplotscoordmath{x}{parsenumber}{0}% + \global\let\pgfplots@xmin=\pgfmathresult + \pgfplotscoordmath{x}{parsenumber}{16000}% + \global\let\pgfplots@xmax=\pgfmathresult + \global\let\pgfplots@data@xmin=\pgfplots@xmin + \global\let\pgfplots@data@xmax=\pgfplots@xmax + % + \pgfplotscoordmath{y}{parsenumber}{0}% + \global\let\pgfplots@ymin=\pgfmathresult + \pgfplotscoordmath{y}{parsenumber}{16000}% + \global\let\pgfplots@ymax=\pgfmathresult + \global\let\pgfplots@data@ymin=\pgfplots@ymin + \global\let\pgfplots@data@ymax=\pgfplots@ymax + \pgfplotsset{enlargelimits=false}% +} + +\let\pgfplots@set@default@size@options@standard=\pgfplots@set@default@size@options +\def\pgfplots@set@default@size@options@smithchart{% + \pgfplots@set@default@size@options@standard + \pgfplotsset{smithchart ticks by size={\pgfkeysvalueof{/pgfplots/width}}{\pgfkeysvalueof{/pgfplots/height}}}% + % + \if1\b@pgfplots@smithchart@defaultticks@x + \if1\b@pgfplots@smithchart@defaultticks@y + \pgfplotsset{default smithchart xytick}% + \fi + \fi +} +\def\pgfplots@assign@default@tick@foraxis@smithchart#1{% + % do nothing here. I don't know the algorithm yet... but for + % smithcharts, it may be sufficient to simply predefine several + % sets of ticks, depending on the final size. + % + % This is realized in + % \pgfplots@set@default@size@options@smithchart (which is invoked + % before the ticks are processed). + \pgfplots@determinedefaultvalues@needs@check@uniformtickfalse + \expandafter\let\csname pgfplots@tick@distance@#1\endcsname=\pgfutil@empty + % + \pgfplotsset{default smithchart #1tick}% + % ok, I expect the '#1tick' key to be set now. Process it. + % Note that the earlier processing of pgfplots has been bypassed + % at this point -- we need to preprocess the tick list *here*: + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname + \expandafter\pgfplots@assign@default@tick@foraxis@smithchart@\expandafter{\pgfplots@loc@TMPa}% + \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplotsretval + % + \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \expandafter\pgfplots@assign@default@tick@foraxis@smithchart@\expandafter{\pgfplots@loc@TMPa}% + \pgfkeyslet{/pgfplots/minor #1tick}\pgfplotsretval + \fi + % +}% +% #1: a \foreach list +% on output, \pgfplotsretval contains a parsed list of positions +\def\pgfplots@assign@default@tick@foraxis@smithchart@#1{% + \pgfplotsapplistXXglobalnewempty + \gdef\pgfplots@loc@TMPd{1}% + \foreach \pgfplots@loc@TMPb in {#1} {% + \ifx\pgfplots@loc@TMPb\pgfutil@empty + \else + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@loc@TMPb}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% per convention... + \edef\pgfmathresult{\if0\pgfplots@loc@TMPd,\fi\pgfmathresult}% + \gdef\pgfplots@loc@TMPd{0}% + \expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfmathresult}% + \fi + }% + \pgfplotsapplistXXgloballet\pgfplotsretval + \pgfplotsapplistXXglobalclear +}% + +\let\pgfplots@show@ticklabel@@orig=\pgfplots@show@ticklabel@ +\def\pgfplots@show@ticklabel@@smithchart#1#2{% + \def\pgfmathresult{#2}% + \if#1x% + \ifdim#2pt>360pt + \pgfmath@basic@mod@{#2}{360}% + \fi + \fi + \def\pgfplots@loc@TMPa{\pgfplots@show@ticklabel@@orig{#1}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% +}% + +\def\pgfplots@xtick@check@tickshow@smithchart{% + \pgfplots@tickshowtrue +} +\def\pgfplots@ytick@check@tickshow@smithchart{% + \pgfplots@tickshowtrue +} + +\let\pgfplots@limits@ready@orig=\pgfplots@limits@ready +\def\pgfplots@limits@ready@smithchart{% + \pgfplots@limits@ready@orig + % + % Avoid tick labels at upper *and* lower angle range if both are the + % same: + \pgfmath@basic@sin@{\pgfplots@xmin}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfmath@basic@sin@{\pgfplots@xmax}% + \pgfplotsmath@ifapproxequal@dim + {\pgfmathresult pt}{\pgfplots@loc@TMPa pt}% + {0.002pt} + {% + \def\pgfplots@xtick@disable@last@tick{1}% + }{% + }% +}% + +\def\smithchart{\smithchartaxis} +\def\endsmithchart{\endsmithchartaxis} + +\def\startsmithchart{\smithchart}% +\def\stopsmithchart{\endsmithchart}% +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.statistics.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.statistics.code.tex new file mode 100644 index 0000000..7fbf4f5 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.statistics.code.tex @@ -0,0 +1,1221 @@ +%-------------------------------------------- +% +% Package pgfplots, library for statistical plots (boxplots in the first version) +% +% Copyright 2007-2012 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\catcode`\;=12 +\catcode`\"=12 +\newif\ifpgfplotsplothandlerboxplot@variable@width + +\ifpgfplots@LUA@supported + \directlua{require("pgfplots.statistics")}% +\fi + +\newif\ifpgfplots@boxplot@ensure@plot@mark +\def\pgfplots@boxplot@ensure@plot@mark{% + \ifpgfplots@boxplot@ensure@plot@mark + \pgfplots@if@has@plot@marks{}{% + \tikzset{mark=*}% + }% + \fi +}% + +\pgfplotsset{ + boxplot/.code={% + \def\tikz@plot@handler{\pgfplotsplothandlerboxplot}% + \pgfplotsset{% + /pgfplots/every boxplot, + /pgfplots/boxplot/.cd,% + #1% + }% + \pgfplots@boxplot@ensure@plot@mark + }, + boxplot prepared/.code={% + \def\tikz@plot@handler{\pgfplotsplothandlerboxplotprepared}% + \pgfplotsset{% + /pgfplots/every boxplot, + /pgfplots/boxplot/.cd,% + #1% + }% + \pgfplots@boxplot@ensure@plot@mark + }, + boxplot/data value/.code =\pgfplots@set@source@for{boxplot/data}{#1}{0},% + boxplot/data/.code =\pgfplots@set@source@for{boxplot/data}{#1}{1},% + boxplot/data filter/.code=, + boxplot/data value=\pgfkeysvalueof{/data point/y}, + % + every boxplot/.style={% + }, + % + % 'auto' means "if possible". + % For boxplot prepared, this is equivalent to "disabled" (empty value). + % For boxplot, it means "compute it". + % Empty value means disabled. + boxplot/median/.initial=auto, + boxplot/lower quartile/.initial=auto, + boxplot/upper quartile/.initial=auto, + boxplot/lower whisker/.initial=auto, + boxplot/upper whisker/.initial=auto, + boxplot/average/.initial=, + % + % mainly used for compatibility. + boxplot/ensure mark/.is if=pgfplots@boxplot@ensure@plot@mark, + % + boxplot/estimator/.is choice, + boxplot/estimator/legacy/.code={\def\pgfplots@boxplot@estimator{legacy}}, + % + boxplot/estimator/legacy*/.code={\def\pgfplots@boxplot@estimator{legacy*}}, + boxplot/estimator/R1/.code={\def\pgfplots@boxplot@estimator{R1}}, + boxplot/estimator/SAS3/.code={\def\pgfplots@boxplot@estimator{R1}}, + boxplot/estimator/Maple1/.code={\def\pgfplots@boxplot@estimator{R1}}, + % + boxplot/estimator/R2/.code={\def\pgfplots@boxplot@estimator{R2}}, + boxplot/estimator/SAS5/.code={\def\pgfplots@boxplot@estimator{R2}}, + boxplot/estimator/Maple2/.code={\def\pgfplots@boxplot@estimator{R2}}, + % + boxplot/estimator/R3/.code={\def\pgfplots@boxplot@estimator{R3}}, + boxplot/estimator/SAS2/.code={\def\pgfplots@boxplot@estimator{R3}}, + % + boxplot/estimator/R4/.code={\def\pgfplots@boxplot@estimator{R4}}, + boxplot/estimator/SAS1/.code={\def\pgfplots@boxplot@estimator{R4}}, + boxplot/estimator/SciPy0-1/.code={\def\pgfplots@boxplot@estimator{R4}}, + boxplot/estimator/Maple3/.code={\def\pgfplots@boxplot@estimator{R4}}, + % + boxplot/estimator/R5/.code={\def\pgfplots@boxplot@estimator{R5}}, + boxplot/estimator/SciPy12-12/.code={\def\pgfplots@boxplot@estimator{R5}}, + boxplot/estimator/Maple4/.code={\def\pgfplots@boxplot@estimator{R5}}, + % + boxplot/estimator/R6/.code={\def\pgfplots@boxplot@estimator{R6}}, + boxplot/estimator/SAS4/.code={\def\pgfplots@boxplot@estimator{R6}}, + boxplot/estimator/SciPy0-0/.code={\def\pgfplots@boxplot@estimator{R6}}, + boxplot/estimator/Maple5/.code={\def\pgfplots@boxplot@estimator{R6}}, + % + boxplot/estimator/R7/.code={\def\pgfplots@boxplot@estimator{R7}}, + boxplot/estimator/Excel/.code={\def\pgfplots@boxplot@estimator{R7}}, + boxplot/estimator/SciPy1-1/.code={\def\pgfplots@boxplot@estimator{R7}}, + boxplot/estimator/Maple6/.code={\def\pgfplots@boxplot@estimator{R7}}, + % + boxplot/estimator/R8/.code={\def\pgfplots@boxplot@estimator{R8}}, + boxplot/estimator/SciPy13-13/.code={\def\pgfplots@boxplot@estimator{R8}}, + boxplot/estimator/Maple7/.code={\def\pgfplots@boxplot@estimator{R8}}, + % + boxplot/estimator/R9/.code={\def\pgfplots@boxplot@estimator{R9}}, + boxplot/estimator/SciPy38-38/.code={\def\pgfplots@boxplot@estimator{R9}}, + boxplot/estimator/Maple8/.code={\def\pgfplots@boxplot@estimator{R9}}, + % + boxplot/estimator=legacy, + % + boxplot/lower quartile off/.initial=0.25, + boxplot/upper quartile off/.initial=0.75, + boxplot/whisker range/.initial=1.5, + % + % + % the size of whisker lines in axis units. + % The default is to make it relative to 'box extend' + boxplot/whisker extend/.initial=\pgfkeysvalueof{/pgfplots/boxplot/box extend}*0.8, + % + % the size of the box in axis units. Note that this has been + % chosen to fit the initial 'draw position': + boxplot/box extend/.initial=0.8, + % draw direction=x|y + boxplot/draw direction/.initial=x, + % + % Activates "dynamic size" feature + boxplot/variable width/.is if=pgfplotsplothandlerboxplot@variable@width, + boxplot/variable width/.default=true, + % + boxplot/sample size/.initial=auto, + % + % a transformation which is applied to anything related to + % sample size. + boxplot/variable width expr/.code=\pgfmathparse{sqrt(#1)}, + % + % will be computed automatically if needed. If it is present, it + % will not contribute to the axis-wide limit unless it has been + % given axis-wide. + boxplot/sample size min/.initial=, + boxplot/sample size max/.initial=, + % + % this factor times 'box extend' is the size for + % 'sample size min'. The max value gets 'box extend'. + boxplot/variable width min target/.initial=0.2, + % + % + % defines where how the "free" position is chosen. The idea is to + % place one box at each "y" position and to number these + % 1,2,3,4,... . This should probably simplify tick (label) generation. + boxplot/draw position/.initial=1+\plotnumofactualtype, + % + % draw relative anchor=0: + % | |---| | + % | | | | + % |----|---|--| + % + % draw relative anchor=0.5: + % | |---| | + % |----| |--| + % | |---| | + % + % draw relative anchor=1: + % |----|---|--| + % | | | | + % | |---| | + boxplot/draw relative anchor/.initial=0.5, + % + boxplot/every whisker/.style={% + }, + boxplot/every box/.style={% + }, + boxplot/every median/.style={% + }, + boxplot/every average/.style={% + /tikz/mark=diamond*, + }, + boxplot/draw/lower whisker/.style={% + /pgfplots/boxplot/draw/whisker=% + {\pgfplotsboxplotvalue{lower quartile}} + {\pgfplotsboxplotvalue{lower whisker}} + }, + boxplot/draw/upper whisker/.style={% + /pgfplots/boxplot/draw/whisker=% + {\pgfplotsboxplotvalue{upper quartile}} + {\pgfplotsboxplotvalue{upper whisker}}% + }, + boxplot/draw/whisker/.code 2 args={% + \draw[/pgfplots/boxplot/every whisker/.try] + (boxplot cs:#1) -- (boxplot cs:#2) + (boxplot whisker cs:#2,0) + -- + (boxplot whisker cs:#2,1) + ; + },% + % + boxplot/draw/box/.code={% + \draw[/pgfplots/boxplot/every box/.try] + (boxplot box cs:\pgfplotsboxplotvalue{lower quartile},0) + rectangle + (boxplot box cs:\pgfplotsboxplotvalue{upper quartile},1) + ; + },% + % + boxplot/draw/average/.code={% + \draw[/pgfplots/boxplot/every average/.try] + \pgfextra + % do NOT use \draw[mark=*] plot coordinates because + % boxplots uses the same plot handler to draw its + % outliers. + \pgftransformshift{% + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{average}} + {0.5}% + }% + \pgfuseplotmark{\tikz@plot@mark}% + \endpgfextra + ; + }, + % + boxplot/draw/median/.code={% + \draw[/pgfplots/boxplot/every median/.try] + (boxplot box cs:\pgfplotsboxplotvalue{median},0) + -- + (boxplot box cs:\pgfplotsboxplotvalue{median},1) + ; + },% +} + + +\def\pgfplotsplothandlerboxplot{% + \pgfplotsresetplothandler + \def\pgf@plotstreamstart{% + \pgfplotsset{/pgfplots/boxplot prepared}% + \pgfplotsresetplothandler + \tikz@plot@handler + \pgf@plotstreamstart + }% + \def\pgfplotsplothandlername{boxplot}% + \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@boxplot + \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@boxplot + \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@boxplot + \def\pgfplotsplothandlerLUAfactory{% + function(axis, pointmetainputhandler) + return pgfplots.BoxPlotPlothandler.new( + pgfplots.BoxPlotRequest.new( + "\pgfkeysvalueof{/pgfplots/boxplot/lower quartile off}", + "\pgfkeysvalueof{/pgfplots/boxplot/upper quartile off}", + "\pgfkeysvalueof{/pgfplots/boxplot/whisker range}", + pgfplots.getPercentileEstimator("\pgfplots@boxplot@estimator")), + "\pgfkeysvalueof{/pgfplots/boxplot/draw direction}", + "\pgfkeysvalueof{/pgfplots/boxplot/draw position}", + axis, pointmetainputhandler) + end + }% +} + + +\def\pgfplotsplothandlersurveystart@boxplot{% + \pgfplots@prepare@source@parser@for{boxplot/}{data}{\pgfplotsplothandlerboxplot@parse}% + % + \pgfplotscoordmath{float}{zero}% + \let\pgfplotsplothandlerboxplot@sum=\pgfmathresult + % + \pgfplotscoordmath{float}{min limit}% + \let\pgfplotsplothandlerboxplot@last=\pgfmathresult + % + \def\b@pgfplotsplothandlerboxplot@issorted{1}% + % + \pgfplotsarraynewempty\pgfp@boxplot@@ + \def\c@pgfplotsplothandlerboxplot@num{0}% + \c@pgfplots@coordindex=0 +}% + +\def\pgfplotsplothandlersurveyend@boxplot{% + \pgfplots@curplot@threedimfalse + % + \ifpgfplots@LUA@backend@supported + \else + \if0\b@pgfplotsplothandlerboxplot@issorted + \pgfplotsplothandlersurveyend@boxplot@sort + \fi + \fi + % + % + \edef\numcoords{\pgfplots@current@point@coordindex}% + % + %% + \pgfplotsset{% + /pgfplots/boxplot prepared={% + data value=\pgfplots@current@point@data, + },% + }% + \pgfplotsresetplothandler + % + \let\pgfplotsplothandlerboxplotprepared@normalize@values@@=\pgfplotsplothandlerboxplotprepared@normalize@values + \def\pgfplotsplothandlerboxplotprepared@normalize@values{\relax}% + % + \tikz@plot@handler + % + \pgfplotsplothandlersurveystart + % + \ifpgfplots@LUA@backend@supported + \else + % this will report outliers as point stream: + \pgfplotsplothandlersurveyend@boxplot@computestats + \fi + % + \let\pgfplotsplothandlerboxplotprepared@normalize@values=\pgfplotsplothandlerboxplotprepared@normalize@values@@ + \pgfplotsplothandlerboxplotprepared@normalize@values + % + % + \pgfplotsplothandlersurveyend +}% + +\def\pgfplotsplothandlersurveyend@boxplot@sort{% + \pgfkeys{/pgfplots/float <}% + \pgfplotsarraysort{\pgfp@boxplot@@}% +}% + +\def\pgfplots@boxplot@fillarray{% + \def\pgfplots@loc@TMPa{\pgfplotsarrayset\c@pgfplots@coordindex\of{P}\to}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@current@point@data}% +} + +%%%% + +\def\pgfplotsplothandler@boxplot@init@percentile@estimator{% + \def\pgfplots@loc@TMPb{legacy}% + \ifx\pgfplots@loc@TMPb\pgfplots@boxplot@estimator + \let\pgfplotsplothandler@boxplot@percentile@estimator@=\pgfplotsplothandler@boxplot@percentile@estimator@legacy + \else + \def\pgfplots@loc@TMPb{legacy*}% + \ifx\pgfplots@loc@TMPb\pgfplots@boxplot@estimator + \let\pgfplotsplothandler@boxplot@percentile@estimator@=\pgfplotsplothandler@boxplot@percentile@estimator@legacy@bad + \else + % first, strip 'R' and store the integer number into \pgfplotsretval: + \def\pgfplots@loc@TMPb##1##2{% + \def\pgfplotsretval{##2}% + }% + \expandafter\pgfplots@loc@TMPb\pgfplots@boxplot@estimator + \ifcase\pgfplotsretval\relax + % 0: + \pgfplots@error{illegal argument 'estimator=\pgfplots@boxplot@estimator' encountered.}% + \or + % R1: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2}% + \let\h=\pgfmathresult + \pgfmathparse{ceil(\h)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}% + } + % FIXME : implement 'ceil' in the FPU! + \pgfplots@error{The argument 'estimator=\pgfplots@boxplot@estimator' is only available in conjunction with 'lua backend' and lualatex.}% + \or + % R2: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2 + 0.5}% + \let\h=\pgfmathresult + % + \pgfmathparse{ceil(\h-0.5)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + % + \pgfmathparse{floor(\h+0.5)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@high=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}% + \let\x@low=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{##2}% + \let\x@high=\pgfmathresult + \pgfmathparse{0.5*(\x@low + \x@high)}% + } + % FIXME : implement 'ceil' in the FPU! + \pgfplots@error{The argument 'estimator=\pgfplots@boxplot@estimator' is only available in conjunction with 'lua backend' and lualatex.}% + \or + % R3: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2}% + \let\h=\pgfmathresult + \pgfmathparse{round(\h)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}% + } + \or + % R4: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R5: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2 + 0.5}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R6: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*(##2+1)}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R7: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{(##2-1) * ##1 + 1}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R8: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{(##2 + 1/3) * ##1 + 1/3}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R9: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{(##2 + 1/4) * ##1 + 3/8}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \else + \pgfplots@error{illegal argument 'estimator=\pgfplots@boxplot@estimator' encountered.}% + \fi + \fi + \fi +}% + +% #1: the percentile in question (like 0.5 for the median) +% #2: the number of data points in the array \pgfp@boxplot@@ +% POSTCONDITION: \pgfmathresult contains the result. +\def\pgfplotsplothandler@boxplot@percentile@estimator#1#2{% + \begingroup + \pgfkeys{/pgf/fpu}% + \pgfplotsplothandler@boxplot@percentile@estimator@{#1}{#2}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% #1: the index +% #2: the number of data points in the array \pgfp@boxplot@@ +% +% POSTCONDITION: \pgfmathresult contains the result. +\def\pgfplotsplothandler@boxplot@percentile@estimator@getIndex#1#2{% + \c@pgf@countd=#1\relax + \advance\c@pgf@countd by-1 % we have 0-based indices + \ifnum\c@pgf@countd<0 \c@pgf@countd=0 \fi + \ifnum\c@pgf@countd<#2\relax \else \c@pgf@countd=#2\relax \advance\c@pgf@countd by-1 \fi + \pgfplotsarrayselect\c@pgf@countd\of\pgfp@boxplot@@\to\pgfmathresult +}% + +% #1: the index +% #2: the number of data points in the array \pgfp@boxplot@@ +% +% POSTCONDITION: \pgfmathresult contains the result. +\def\pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad#1#2{% + \c@pgf@countd=#1\relax + %\advance\c@pgf@countd by-1 % we have 0-based indices + \ifnum\c@pgf@countd<0 \c@pgf@countd=0 \fi + \ifnum\c@pgf@countd<#2\relax \else \c@pgf@countd=#2\relax \advance\c@pgf@countd by-1 \fi + \pgfplotsarrayselect\c@pgf@countd\of\pgfp@boxplot@@\to\pgfmathresult +}% + +\def\pgfplotsplothandler@boxplot@percentile@estimator@#1#2{% + \pgfplots@error{The estimator is uninitialized in this context. Call \string\pgfplotsplothandler@boxplot@init@percentile@estimator\space first.}% +} + +% computes x_low + (h - h_low) * (x_up - x_low) +% #1: the number of data points in the array \pgfp@boxplot@@ +\def\pgfplotsplothandler@boxplot@percentile@estimator@std@lookup#1{% + \pgfmathparse{floor(\h)}% + \let\h@low=\pgfmathresult + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + \c@pgf@countd=\offset@low\relax + \advance\c@pgf@countd by1 % + \edef\offset@high{\the\c@pgf@countd}% + % + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{#1}% + \let\x@low=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{#1}% + \let\x@high=\pgfmathresult + \pgfmathparse{\x@low + (\h - \h@low) * (\x@high - \x@low)}% +}% + +% implements 'estimator=legacy' +\def\pgfplotsplothandler@boxplot@percentile@estimator@legacy#1#2{% + \pgfmathparse{#1*#2}% + \let\h=\pgfmathresult + \pgfmathparse{floor(\h)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + % + \pgfmathparse{\h > \offset@low}% + \ifpgfmathfloatcomparison + \def\b@is@int{0}% + \else + \def\b@is@int{1}% + \fi + % + \c@pgf@countd=\offset@low\relax + \advance\c@pgf@countd by1 % + \edef\offset@high{\the\c@pgf@countd}% + % + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{#2}% + \if0\b@is@int + \let\temp=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{#2}% + \pgfmathparse{0.5*(\temp + \pgfmathresult)}% + \fi +} +\def\pgfplotsplothandler@boxplot@percentile@estimator@legacy@bad#1#2{% + \pgfmathparse{#1*(#2-1)}% + \let\h=\pgfmathresult + \pgfmathparse{floor(\h)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + % + \pgfmathparse{\h > \offset@low}% + \ifpgfmathfloatcomparison + \def\b@is@int{0}% + \else + \def\b@is@int{1}% + \fi + % + \c@pgf@countd=\offset@low\relax + \advance\c@pgf@countd by1 % + \edef\offset@high{\the\c@pgf@countd}% + % + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad{\offset@low}{#2}% + \if0\b@is@int + \let\temp=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad{\offset@high}{#2}% + \pgfmathparse{0.5*(\temp + \pgfmathresult)}% + \fi +} + + +\def\pgfplotsplothandlersurveyend@boxplot@computestats{ + % + \pgfplotsplothandler@boxplot@init@percentile@estimator + % + % hm. I once had the idea to support quartile-based whisker + % definitions... but I did not implement them. + \let\c@pgfplotsplothandlerboxplot@lowerwhisker=\pgfutil@empty + \let\c@pgfplotsplothandlerboxplot@upperwhisker=\pgfutil@empty + % + % + % These here are the VALUES that will be communicated to 'boxplot prepared' + % They need to be computed below. + \let\pgfplotsplothandlerboxplot@lowerwhisker=\pgfutil@empty + \let\pgfplotsplothandlerboxplot@lowerquartile=\pgfutil@empty + \let\pgfplotsplothandlerboxplot@median=\pgfutil@empty + \let\pgfplotsplothandlerboxplot@upperquartile=\pgfutil@empty + \let\pgfplotsplothandlerboxplot@upperwhisker=\pgfutil@empty + % + \pgfplotsplothandler@boxplot@percentile@estimator{\pgfkeysvalueof{/pgfplots/boxplot/lower quartile off}}{\numcoords}% + \let\pgfplotsplothandlerboxplot@lowerquartile=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator{\pgfkeysvalueof{/pgfplots/boxplot/upper quartile off}}{\numcoords}% + \let\pgfplotsplothandlerboxplot@upperquartile=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator{0.5}{\numcoords}% + \let\pgfplotsplothandlerboxplot@median=\pgfmathresult + % + % + \pgfplotscoordmath{float}{parsenumber}{\numcoords}% + \let\pgfplots@boxplot@numcoords=\pgfmathresult + \pgfplotscoordmath{float}{op}{divide}{{\pgfplotsplothandlerboxplot@sum}{\pgfplots@boxplot@numcoords}}% + \let\pgfplotsplothandlerboxplot@average=\pgfmathresult + % + % communicate and set results to pgfkeys - and to the plot + % specification option list: + \pgfplotsplothandlersurveyend@boxplot@set{lower whisker}{\pgfplotsplothandlerboxplot@lowerwhisker}% + \pgfplotsplothandlersurveyend@boxplot@set{lower quartile}{\pgfplotsplothandlerboxplot@lowerquartile}% + \pgfplotsplothandlersurveyend@boxplot@set{median}{\pgfplotsplothandlerboxplot@median}% + \pgfplotsplothandlersurveyend@boxplot@set{average}{\pgfplotsplothandlerboxplot@average}% + \pgfplotsplothandlersurveyend@boxplot@set{upper quartile}{\pgfplotsplothandlerboxplot@upperquartile}% + \pgfplotsplothandlersurveyend@boxplot@set{upper whisker}{\pgfplotsplothandlerboxplot@upperwhisker}% + \pgfplotsplothandlersurveyend@boxplot@set{sample size}{\pgfplots@boxplot@numcoords}% + % + % Ok, now make sure that we use the FINAL variables from the user, + % i.e. that we respect manual overrides. This is only necessary + % for quartiles from what I see here. + \pgfplotsplothandlersurveyend@boxplot@get{\pgfplotsplothandlerboxplot@lowerquartile}{lower quartile}% + \pgfplotsplothandlersurveyend@boxplot@get{\pgfplotsplothandlerboxplot@upperquartile}{upper quartile}% + % + \pgfplotscoordmath{float}{parsenumber}{\pgfplotsboxplotvalue{whisker range}}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{float}{op}{subtract}{{\pgfplotsplothandlerboxplot@upperquartile}{\pgfplotsplothandlerboxplot@lowerquartile}}% + \pgfplotscoordmath{float}{op}{multiply}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% + \let\pgfplots@boxplot@whisker@width=\pgfmathresult + \pgfplotscoordmath{float}{op}{add}{{\pgfplotsplothandlerboxplot@upperquartile}{\pgfplots@boxplot@whisker@width}}% + \let\pgfplotsplothandlerboxplot@upperwhisker@value=\pgfmathresult + \pgfplotscoordmath{float}{op}{subtract}{{\pgfplotsplothandlerboxplot@lowerquartile}{\pgfplots@boxplot@whisker@width}}% + \let\pgfplotsplothandlerboxplot@lowerwhisker@value=\pgfmathresult + % + \pgfplotsarrayforeachungrouped\pgfp@boxplot@@\as\pgfplots@current@point@data{% + \pgfplotsplothandlersurveyend@boxplot@computestats@valuebased + }% + % + \pgfplotsplothandlersurveyend@boxplot@set{lower whisker}{\pgfplotsplothandlerboxplot@lowerwhisker}% + \pgfplotsplothandlersurveyend@boxplot@set{upper whisker}{\pgfplotsplothandlerboxplot@upperwhisker}% + % +}% + +% takes a key #1 which is expected in /pgfplots/boxplot/#1, +% and overwrites its value with #2 if that is allowed. +% +% More specifically, if the current value of '#1' is 'auto', it is +% replaced by #2. In all other cases, it will not be modified. +% +% The "replaced by #2" means to set the value right away and to modify +% the plot's option list to reflect the new value. +% +% ---- NOTE: this routine is also invoked from the LUA BACKEND. +\def\pgfplotsplothandlersurveyend@boxplot@set#1#2{% + \pgfkeysgetvalue{/pgfplots/boxplot/#1}\pgfplots@loc@TMPa + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + \def\pgfplots@loc@TMPc{auto}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPc + \edef\pgfmathresult{#2}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfplotscoordmath{float}{tostring}{#2}% + \edef\pgfplots@loc@TMPb{\noexpand\pgfplotsplothandlersurveyaddoptions{/pgfplots/boxplot/#1={\pgfmathresult}}}% + \pgfplots@loc@TMPb + \pgfplotsplothandlersurveyend@boxplot@log{#1}{\pgfmathresult}% + \fi + \fi +}% + +\def\pgfplotsplothandlersurveyend@boxplot@log#1#2{% + \pgfplots@log3{boxplot: got #1=#2}% +}% + +\def\pgfplotsplothandlersurveyend@boxplot@get#1#2{% + \pgfkeysgetvalue{/pgfplots/boxplot/#2}\pgfplots@loc@TMPa + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + \def\pgfplots@loc@TMPc{auto}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPc + \else + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfmathparse{\pgfplots@loc@TMPa}% + \let#1=\pgfmathresult + \fi + \fi +} + +\def\pgfplotsplothandlersurveyend@boxplot@computestats@valuebased{% + \ifx\pgfplotsplothandlerboxplot@lowerwhisker\pgfutil@empty + \pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@data}{\pgfplotsplothandlerboxplot@lowerwhisker@value}{% + % Ah. an outlier. + \pgfplotsplothandlerboxplot@outlier + }{% + \let\pgfplotsplothandlerboxplot@lowerwhisker=\pgfplots@current@point@data + }% + \fi + % + % FIXME : optimize this! We have an array so we COULD check it in + % reverse order! + % it would be so cool if we could simply check the list in reverse + % order. but not if it really is a singly-linked list... + \pgfplotscoordmath{float}{if less than}{\pgfplotsplothandlerboxplot@upperwhisker@value}{\pgfplots@current@point@data}{% + % Ah. an outlier. + \pgfplotsplothandlerboxplot@outlier + }{% + \ifx\pgfplotsplothandlerboxplot@upperwhisker\pgfutil@empty + \let\pgfplotsplothandlerboxplot@upperwhisker=\pgfplots@current@point@data + \else + \pgfplotscoordmath{float}{max}{\pgfplotsplothandlerboxplot@upperwhisker}{\pgfplots@current@point@data}% + \let\pgfplotsplothandlerboxplot@upperwhisker=\pgfmathresult + \fi + }% +} + +\def\pgfplotsplothandlerboxplot@outlier{% + \def\pgfplots@current@point@x{0}% + \def\pgfplots@current@point@y{0}% + \def\pgfplots@current@point@z{0}% + \pgfplotsplothandlersurveypoint +}% + +%%% + +\def\pgfplotsplothandlersurveypoint@boxplot{% + \pgfplotsplothandlerboxplot@parse + \let\pgfplots@current@point@data=\pgfmathresult + % + \ifx\pgfplots@current@point@data\pgfutil@empty + \else + \pgfplotscoordmath{float}{if is bounded}{\pgfplots@current@point@data}{% + % + \ifpgfplots@LUA@backend@supported + \pgfplotsplothandlerboxplot@LUA@survey@point + \else + \pgfplotsplothandlersurveypoint@boxplot@ + \fi + }{% + }% + \fi +}% + +\def\pgfplotsplothandlerboxplot@LUA@survey@point{% + \directlua{pgfplots.texBoxPlotSurveyPoint("\pgfplots@current@point@data")}% +}% +\def\pgfplotsplothandlersurveypoint@boxplot@{% + \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlerboxplot@num + % + \if1\b@pgfplotsplothandlerboxplot@issorted + \pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@data}{\pgfplotsplothandlerboxplot@last}{% + \def\b@pgfplotsplothandlerboxplot@issorted{0}% + }{% + }% + \fi + % + % + \pgfplotscoordmath{float}{op}{add}{{\pgfplots@current@point@data}{\pgfplotsplothandlerboxplot@sum}}% + \let\pgfplotsplothandlerboxplot@sum=\pgfmathresult + % + % store parsed result. + \edef\pgfmathresult{\pgfplots@current@point@data}% + \expandafter\pgfplotsarraypushback\expandafter{\pgfmathresult}\to\pgfp@boxplot@@ + % + \let\pgfplotsplothandlerboxplot@last=\pgfplots@current@point@data + % + \advance\c@pgfplots@coordindex by1 +} +% ============================================================= + +\def\pgfplotsplothandlerboxplotprepared{% + \ifpgfplots@stackedmode + \pgfplotsthrow{unsupported operation}{Sorry, 'stacked plots' are currently unsupported for box plots. See the manual for 'boxplot/draw position' for how to achieve the effect (using \string\plotnumofactualtype)}\pgfeov + \else + \pgfplotsplothandlerboxplotprepared@ + \fi +} +\def\pgfplotsplothandlerboxplotprepared@{% + \pgfplotsresetplothandler + % + \def\pgfplotsplothandlername{boxplot prepared}% + % + \let\pgf@plotstreamstart=\pgfplotsplothandlervisstart@boxplot@prepared + \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@boxplot@prepared + \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@boxplot@prepared + \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@boxplot@prepared + % + \pgfplotsplothandlerboxplotprepared@normalize@values + % + \pgfkeysgetvalue{/pgfplots/boxplot/draw direction}\pgfplots@loc@TMPa + \if x\pgfplotsboxplotvalue{draw direction}% + \else + \if y\pgfplotsboxplotvalue{draw direction}% + \else + \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Invalid choice boxplot/draw direction=\pgfplots@loc@TMPa}\pgfeov% + \def\pgfplots@loc@TMPa{x}% + \fi + \fi + \csname pgfplotsplothandlerboxplotprepared@setxy@\pgfplots@loc@TMPa\endcsname + % + \def\pgfplotsboxplotpointab##1##2{% + \begingroup + \pgfkeys{/pgf/fpu}% + \pgfmathparse{##1}% + \let\pgfplotsplothandlerboxplot@@=\pgfmathresult + \pgfmathparse{\pgfplotsboxplotvalue{draw position} + ##2}% + \xdef\pgfplots@glob@TMPa{{\pgfplotsplothandlerboxplot@@}{\pgfmathresult}}% + \expandafter\pgfplotsboxplotpointab@\pgfplots@glob@TMPa{\pgfplotspointaxisxy}% + \pgf@process{}% + \endgroup + }% + \def\pgfplotsboxplotpointab@survey##1##2{% + \edef\pgfmathresult{##1}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathparse{\pgfmathresult}% + \fi + \let\pgfplotsplothandlerboxplot@@=\pgfmathresult + \pgfmathparse{\pgfplotsboxplotvalue{draw position} + ##2}% + \xdef\pgfplots@glob@TMPa{{\pgfplotsplothandlerboxplot@@}{\pgfmathresult}}% + \let\pgfplotsplothandlerboxplot@modified@draw@position=\pgfmathresult% + \expandafter\pgfplotsboxplotpointab@\pgfplots@glob@TMPa{\pgfplotsboxplotpointab@@define@current@xy}% + }% +}% + +\def\pgfplotsplothandlerboxplotprepared@normalize@values{% + \def\pgfplots@loc@TMPa{auto}% + \pgfplotsforeachentryinCSV{\value}{% + lower whisker,% + lower quartile,% + median,% + average,% + upper quartile,% + upper whisker,% + sample size% + }{% + \pgfkeysgetvalue{/pgfplots/boxplot/\value}\pgfplots@loc@TMPb + \edef\pgfplots@loc@TMPb{\pgfplots@loc@TMPb}% + \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa + \pgfkeyslet{/pgfplots/boxplot/\value}\pgfutil@empty + \fi + }% +}% + +\def\pgfplotsboxplotpointab@@define@current@xy#1#2{% + \edef\pgfplots@current@point@x{#1}% + \edef\pgfplots@current@point@y{#2}% +}% + +\def\pgfplotsplothandlerboxplotprepared@setxy@x{% + \def\pgfplotsboxplotpointab@##1##2##3{% + ##3{##1}{##2}% + }% +}% +\def\pgfplotsplothandlerboxplotprepared@setxy@y{% + \def\pgfplotsboxplotpointab@##1##2##3{% + ##3{##2}{##1}% + }% +}% + +\def\pgfplotsplothandlersurveypoint@boxplot@collect@limits{% + \pgfplotsaxisparsecoordinate + \pgfplotsaxispreparecoordinate + \ifpgfplotsaxisparsecoordinateok + \pgfplotsaxisupdatelimitsforcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z + \fi + % + % do NOT store the processed coordinate! the coordinate stream + % is ONLY for outliers. + % + % ... but update this stuff to avoid a "plot without coordinates" + % case + \pgfplotscoordstream@firstlast@update +} + +\def\pgfplotsplothandlersurveystart@boxplot@prepared{% + \pgfplots@prepare@source@parser@for{boxplot/}{data}{\pgfplotsplothandlerboxplot@parse}% + % + \let\pgfplotsboxplotpointab=\pgfplotsboxplotpointab@survey + % + \pgfplotsplothandlersurveystart@default +} + +\def\pgfplotsplothandlersurveypoint@boxplot@prepared{% + % seems the "parse" routine is stupid ... the /data point/ stuff + % is redefined although it should not. Strange... + \pgfkeyslet{/data point/x}\pgfplots@current@point@x + \pgfkeyslet{/data point/y}\pgfplots@current@point@y + \pgfkeyslet{/data point/z}\pgfplots@current@point@z + \pgfplotsplothandlerboxplot@parse + % + \pgfplotsboxplotpointab{\pgfmathresult}{0}% + % + \pgfplotsplothandlersurveypoint@default +} + +\def\pgfplotsplothandlersurveyend@boxplot@prepared{% + \let\pgfplots@invoke@filter@xyz@old=\pgfplots@invoke@filter@xyz + \let\pgfplots@invoke@filter@xyz=\relax + \let\pgfplots@invoke@filter@old=\pgfplots@invoke@filter + \def\pgfplots@invoke@filter##1##2{}% + \let\pgfplots@invoke@prefilter@old=\pgfplots@invoke@prefilter + \let\pgfplots@invoke@prefilter=\relax + % + \pgfmathparse{\pgfplotsboxplotvalue{draw position}}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \ifpgfplots@usefpu + \pgfmathfloattofixed\pgfmathresult + \fi + % remember it for later - it might have been retrieved from some + % table column! If you used something like + % 'draw position=\thisrow{position}, the position of the LAST data point + % will be used (because we are in end survey here). + \edef\pgfplots@loc@TMPb{\noexpand\pgfplotsplothandlersurveyaddoptions{/pgfplots/boxplot/draw position=\pgfmathresult}}% + \pgfplots@loc@TMPb + % + % ... this here will make things faster if the FPU is active. + \pgfkeyslet{/pgfplots/boxplot/draw position}\pgfplots@loc@TMPa + % + % + % + % + \pgfplotsboxplotpointabwhisker + {\pgfplotsboxplotvalue{lower whisker}} + {0}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + \pgfplotsboxplotpointabwhisker + {\pgfplotsboxplotvalue{lower whisker}} + {1}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + % + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{lower quartile}}% + {0}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{lower quartile}}% + {1}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + % + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{median}} + {0}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{median}} + {1}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + % + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{average}} + {0}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{average}} + {1}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + % + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{upper quartile}}% + {0}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + \pgfplotsboxplotpointabbox + {\pgfplotsboxplotvalue{upper quartile}}% + {1}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + % + % + \pgfplotsboxplotpointabwhisker + {\pgfplotsboxplotvalue{upper whisker}}% + {1}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + \pgfplotsboxplotpointabwhisker + {\pgfplotsboxplotvalue{upper whisker}}% + {0}% + \pgfplotsplothandlersurveypoint@boxplot@collect@limits + % + \let\pgfplots@invoke@prefilter=\pgfplots@invoke@prefilter@old + \let\pgfplots@invoke@filter=\pgfplots@invoke@filter@old + \let\pgfplots@invoke@filter@xyz=\pgfplots@invoke@filter@xyz@old + % + \pgfplotsplothandlerboxplotsurvey@variable@width% + % + \pgfplotsplothandlersurveyend@default +}% + +\def\pgfplotsplothandlerboxplotsurvey@variable@width{% + \ifnum\plotnumofactualtype=0 % + % Ah - the first boxplot in this axis. Init the global + % counter: + \pgfplotscoordmath{default}{max limit}% + \global\let\g@pgfplotsplothandlerboxplot@widthkey@min=\pgfmathresult + \pgfplotscoordmath{default}{min limit}% + \global\let\g@pgfplotsplothandlerboxplot@widthkey@max=\pgfmathresult + \fi + % + % + \ifpgfplotsplothandlerboxplot@variable@width + \pgfkeysgetvalue{/pgfplots/boxplot/sample size}\pgfmathresult + \edef\pgfmathresult{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfplotsplothandlerboxplot@variable@width@expr{\pgfmathresult}% + % + \let\pgfplots@widthkey@=\pgfmathresult + % + \pgfkeysgetvalue{/pgfplots/boxplot/sample size min}\pgfmathresult + \edef\pgfplotsplothandlerboxplot@widthkey@min{\pgfmathresult}% + % + \pgfkeysgetvalue{/pgfplots/boxplot/sample size max}\pgfmathresult + \edef\pgfplotsplothandlerboxplot@widthkey@max{\pgfmathresult}% + % + % + \ifx\pgfplotsplothandlerboxplot@widthkey@min\pgfutil@empty + \let\pgfplotsplothandlerboxplot@widthkey@min=\g@pgfplotsplothandlerboxplot@widthkey@min + \def\pgfplotsplothandlerboxplot@widthkey@min@autocompute{1}% + \else + \pgfplotsplothandlerboxplot@variable@width@expr{\pgfplotsplothandlerboxplot@widthkey@min}% + \let\pgfplotsplothandlerboxplot@widthkey@min=\pgfmathresult + \def\pgfplotsplothandlerboxplot@widthkey@min@autocompute{0}% + \fi + \ifx\pgfplotsplothandlerboxplot@widthkey@max\pgfutil@empty + \let\pgfplotsplothandlerboxplot@widthkey@max=\g@pgfplotsplothandlerboxplot@widthkey@max + \def\pgfplotsplothandlerboxplot@widthkey@max@autocompute{1}% + \else + \pgfplotsplothandlerboxplot@variable@width@expr{\pgfplotsplothandlerboxplot@widthkey@max}% + \def\pgfplotsplothandlerboxplot@widthkey@max@autocompute{0}% + \fi + % + \if1\pgfplotsplothandlerboxplot@widthkey@max@autocompute + \pgfmathparse{max(\pgfplotsplothandlerboxplot@widthkey@max,\pgfplots@widthkey@)}% + \global\let\g@pgfplotsplothandlerboxplot@widthkey@max=\pgfmathresult + \let\pgfplotsplothandlerboxplot@widthkey@max=\pgfmathresult + % + \pgfmathparse{min(\pgfplotsplothandlerboxplot@widthkey@min,\pgfplots@widthkey@)}% + \global\let\g@pgfplotsplothandlerboxplot@widthkey@min=\pgfmathresult + \let\pgfplotsplothandlerboxplot@widthkey@min=\pgfmathresult + \fi + % + % + \fi + \fi + % +%\message{sample size=\pgfplots@widthkey@. interval = \pgfplotsplothandlerboxplot@widthkey@min:\pgfplotsplothandlerboxplot@widthkey@max^^J}% +}% + +\def\pgfplotsplothandlerboxplot@variable@width@expr#1{% + \begingroup + \pgfkeys{/pgf/fpu}% + \let\pgfmathresult=#1% + \pgfplotsboxplotvalue{variable width expr/.@cmd}#1\pgfeov + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let#1=\pgfmathresult +}% + +\def\pgfplotsplothandlerboxplotvisualization@variable@width{% + \ifpgfplotsplothandlerboxplot@variable@width + \pgfkeysgetvalue{/pgfplots/boxplot/sample size}\pgfmathresult + \edef\pgfmathresult{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfplotsplothandlerboxplot@variable@width@expr{\pgfmathresult}% + \let\pgfplots@widthkey@=\pgfmathresult + % + \pgfkeysgetvalue{/pgfplots/boxplot/sample size min}\pgfmathresult + \edef\pgfplotsplothandlerboxplot@widthkey@min{\pgfmathresult}% + % + \pgfkeysgetvalue{/pgfplots/boxplot/sample size max}\pgfmathresult + \edef\pgfplotsplothandlerboxplot@widthkey@max{\pgfmathresult}% + % + % + \ifx\pgfplotsplothandlerboxplot@widthkey@min\pgfutil@empty + \let\pgfplotsplothandlerboxplot@widthkey@min=\g@pgfplotsplothandlerboxplot@widthkey@min + \else + \pgfplotsplothandlerboxplot@variable@width@expr{\pgfplotsplothandlerboxplot@widthkey@min}% + \fi + \ifx\pgfplotsplothandlerboxplot@widthkey@max\pgfutil@empty + \let\pgfplotsplothandlerboxplot@widthkey@max=\g@pgfplotsplothandlerboxplot@widthkey@max + \else + \pgfplotsplothandlerboxplot@variable@width@expr{\pgfplotsplothandlerboxplot@widthkey@max}% + \fi + % + \pgfkeysgetvalue{/pgfplots/boxplot/variable width min target}\pgfplots@widthkey@mintrg + \pgfkeysgetvalue{/pgfplots/boxplot/box extend}\pgfplots@loc@TMPa + %\message{sample size=\pgfplots@widthkey@. interval = \pgfplotsplothandlerboxplot@widthkey@min:\pgfplotsplothandlerboxplot@widthkey@max. Target = [\pgfplots@widthkey@mintrg:1]^^J}% + \begingroup + \pgfkeys{/pgf/fpu}% + \pgfmathparse{ + (\pgfplots@widthkey@mintrg + + max(0,min(1,(\pgfplots@widthkey@ - \pgfplotsplothandlerboxplot@widthkey@min) / + (\pgfplotsplothandlerboxplot@widthkey@max - \pgfplotsplothandlerboxplot@widthkey@min))) + * (1-\pgfplots@widthkey@mintrg)) * \pgfplots@loc@TMPa}% + \pgfmathfloattofixed\pgfmathresult + \pgfmath@smuggleone\pgfmathresult + \endgroup + \pgfkeyslet{/pgfplots/boxplot/box extend}\pgfmathresult + \fi + \fi +}% + +\def\pgfplotsplothandlervisstart@boxplot@prepared{% + % + \pgfplotsplothandlerboxplotvisualization@variable@width + % + \global\let\pgf@plotstreampoint=\pgfutil@gobble + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax + % + \pgfplotsplothandlervisstart@boxplot@prepared@draw +}% + +\def\pgfplotsplothandlervisstart@boxplot@prepared@draw{% + \def\b@pgfplots@boxplot@hasbox{1}% + \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{lower quartile}}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\b@pgfplots@boxplot@hasbox{0}% + \fi + \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{upper quartile}}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\b@pgfplots@boxplot@hasbox{0}% + \fi + % + \if0\b@pgfplots@boxplot@hasbox + % hm. we have no box. Very strange boxplot, I'd say. + % + % But anyway: if someone has whiskers without box, + % short-circuit the whiskers: + \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{lower whisker}}% + \edef\pgfplots@loc@TMPb{\pgfplotsboxplotvalue{upper whisker}}% + \pgfkeyslet{/pgfplots/boxplot/lower quartile}\pgfplots@loc@TMPb + \pgfkeyslet{/pgfplots/boxplot/upper quartile}\pgfplots@loc@TMPa + \fi + % + % + \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{lower whisker}}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplotsboxplotvalue{draw/lower whisker/.@cmd}\pgfeov + \fi + % + \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{upper whisker}}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplotsboxplotvalue{draw/upper whisker/.@cmd}\pgfeov + \fi + % + \if1\b@pgfplots@boxplot@hasbox + \pgfplotsboxplotvalue{draw/box/.@cmd}\pgfeov + \fi + % + \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{median}}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplotsboxplotvalue{draw/median/.@cmd}\pgfeov + \fi + % + \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{average}}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplotsboxplotvalue{draw/average/.@cmd}\pgfeov + \fi +}% + +\def\pgfplots@boxplot@cs@decompose#1{% + \edef\pgfplots@loc@TMPa{#1}% + \expandafter\pgfutil@in@\expandafter,\expandafter{\pgfplots@loc@TMPa}% + \ifpgfutil@in@ + \def\pgfplots@loc@TMPb##1,##2\pgfplots@EOI{% + \def\pgfplots@boxplotcs@a{##1}% + \def\pgfplots@boxplotcs@b{##2}% + }% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI + \else + \let\pgfplots@boxplotcs@a=\pgfplots@loc@TMPa% + \def\pgfplots@boxplotcs@b{0}% + \fi +}% + +\def\pgfplotsboxplotvalue#1{\pgfkeysvalueof{/pgfplots/boxplot/#1}}% + +\tikzaddtikzonlycommandshortcutlet\boxplotvalue\pgfplotsboxplotvalue + +% A helper which implements 'draw relative anchor'. It expands to a +% math expression which is suitable as second argument for 'boxplot cs'; +% i.e. it needs to be added to 'boxplot/draw position'. +% +% More precisely, this macro is to be used in a context where lines of +% 'box extend' length have to be drawn. +% +% The argument is shifted by 'draw relative anchor' and is scaled by +% 'box extend'. +% +% #1: the coordinate. 0 is the means "lower part of the construct +% which is to be drawn". 1 means the "upper part of that construct" +% and 0.5 is in the middle. +\def\pgfplots@boxplot@anchor@value#1{% + (#1-\pgfplotsboxplotvalue{draw relative anchor})*\pgfplotsboxplotvalue{box extend}% +} + +% same as \pgfplots@boxplot@anchor@value, but for drawing constructs +% which are at most 'whisker extend' long. +\def\pgfplots@boxplot@anchor@value@whisker#1{% + (#1-\pgfplotsboxplotvalue{draw relative anchor})*\pgfplotsboxplotvalue{whisker extend}% +} + +\def\pgfplotsboxplotpointabbox#1#2{% + \pgfplotsboxplotpointab{#1}{\pgfplots@boxplot@anchor@value{#2}}% +}% +\def\pgfplotsboxplotpointabwhisker#1#2{% + \pgfplotsboxplotpointab{#1}{\pgfplots@boxplot@anchor@value@whisker{#2}}% +}% + +\tikzdeclarecoordinatesystem{boxplot}{% + \pgfplots@boxplot@cs@decompose{#1}% + \pgfplotsboxplotpointab{\pgfplots@boxplotcs@a}{\pgfplots@boxplotcs@b}% +}% + +\tikzdeclarecoordinatesystem{boxplot box}{% + \pgfplots@boxplot@cs@decompose{#1}% + \pgfplotsboxplotpointabbox{\pgfplots@boxplotcs@a}{\pgfplots@boxplotcs@b}% +}% + +\tikzdeclarecoordinatesystem{boxplot whisker}{% + \pgfplots@boxplot@cs@decompose{#1}% + \pgfplotsboxplotpointabwhisker{\pgfplots@boxplotcs@a}{\pgfplots@boxplotcs@b}% +}% + +\catcode`\;=\pgfplots@oldcatcodesemicolon +\catcode`\"=\pgfplots@oldcatcodedoublequote +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex new file mode 100644 index 0000000..cefa4fd --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex @@ -0,0 +1,928 @@ +%-------------------------------------------- +% +% Package pgfplots, library for ternary plots (triangular axes). +% +% Copyright 2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% +% This is a library to draw ternary diagrams. +% +% A ternary diagram visualizes percentages of three components in a +% triangle. +% +% Sometimes there is also contour data drawn on top of the ternary +% diagram, i.e. data (x,y,z, T(x,y,z) ), but I can't do that yet. +% +% How to read a ternary diagram: http://csmres.jmu.edu/geollab/fichter/SedRx/readternary.html +% +% Another usage example: http://www.sv.vt.edu/classes/MSE2094_NoteBook/96ClassProj/experimental/ternary2.html +% +% Drawing ternary diagrams: http://staff.aist.go.jp/a.noda/programs/ternary/ternary-en.html +% +% computing these coordinates: http://www.gamedev.net/community/forums/topic.asp?topic_id=451357 +% + +\pgfplotsdefineaxistype{ternary}{% + \pgfplots@ternary@activate +}% + +\newif\ifpgfplots@ternary@rellimits + + +\pgfplotsset{ + /pgfplots/ternary limits relative/.is if=pgfplots@ternary@rellimits, + /pgfplots/ternary limits relative=true, + /pgfplots/ternary limits relative/.default=true, + /pgfplots/ternary relative limits/.style={/pgfplots/ternary limits relative=#1}, + /pgfplots/ternary start x/.initial=, % FIXME : implement + /pgfplots/ternary start y/.initial=, + /pgfplots/ternary start z/.initial=, + /pgfplots/every ternary axis/.style={ + /pgfplots/tick align=outside, + grid=major, + xticklabel style={anchor=west}, + % yticklabel style={anchor=south east}, + % zticklabel style={anchor=north}, + /pgfplots/every 3d description/.style={}, + /pgfplots/every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every axis y label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every axis z label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every x tick scale label/.style={at={(xticklabel cs:0.95,5pt)},anchor=near xticklabel,inner sep=0pt}, + /pgfplots/every y tick scale label/.style={at={(yticklabel cs:0.95,5pt)},anchor=near yticklabel,inner sep=0pt}, + /pgfplots/every z tick scale label/.style={at={(yticklabel cs:0.95,5pt)},anchor=near yticklabel,inner sep=0pt}, + /pgfplots/every axis title shift=15pt, + /pgfplots/every axis legend/.style={% + cells={anchor=center}, + inner xsep=3pt,inner ysep=2pt,nodes={inner sep=2pt,text depth=0.15em}, + shape=rectangle,% + fill=white,% + draw=black, + at={(1.03,1.03)}, + anchor=north west,% + }, + annot/point format 3d/.initial={(\%.2f, \%.2f, \%.2f)}, + }, +} + +\def\pgfplots@ternary@activate{% + \let\pgfplotsqpointxy=\pgfplotsqpointxy@ternary + \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy + \let\pgfplotsqpointxyz=\pgfplotsqpointxyz@ternary + \let\pgfplots@draw@axis=\pgfplots@draw@axis@ternary + \def\pgfplots@drawaxis@outerlines@separate@onorientedsurf##1##2{}% + \def\pgfplots@drawaxis@innerlines@onorientedsurf##1##2##3{}% + \let\pgfplots@draw@axis@post=\pgfplots@draw@axis@post@ternary + \let\pgfplots@initsizes=\pgfplots@initsizes@ternary + \let\pgfplots@limits@ready=\pgfplots@limits@ready@ternary + \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@ternary + \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@ternary + \let\pgfplots@initsizes@setunitvector=\pgfplots@initsizes@setunitvector@ternary + \let\pgfplots@computeunitvectorlengths=\pgfplots@computeunitvectorlengths@ternary + \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@ternary + \let\pgfplots@prepare@ZERO@coordinates=\pgfplots@prepare@ZERO@coordinates@ternary + \def\pgfplots@scaleaxes@to@BB@##1##2{}% + \let\pgfplotsgetnormalforcurrentview=\relax + \def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf##1{}% + \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@ternary + % + \pgfkeys{/pgfplots/oriented surf installed/.add={}{% + \let\pgfplotspointonorientedsurfaceab@ternary@orig=\pgfplotspointonorientedsurfaceab + \let\pgfplotspointonorientedsurfaceab=\pgfplotspointonorientedsurfaceab@ternary + }}% + \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@ternary + \pgfkeyssetvalue{/pgfplots/view/az}{}% + \pgfkeyssetvalue{/pgfplots/view/el}{}% + \let\pgfplots@set@options@sanitize=\relax + \let\pgfplots@set@options@sanitizemode=\relax + % + \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{\pgfplots@notify@options@are@set + \ifpgfplots@ternary@rellimits + \pgfplotsset{scaled ticks=false,ticklabel style={/pgf/number format/precision=0}}% + \let\pgfplots@show@ticklabel@orig=\pgfplots@show@ticklabel@ + \let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@ternary@relative + \fi + }% + % + % this here is set *before* 'every ternary axis' is invoked. + \pgfplotsset{ + /pgfplots/footnotesize/.append style= {/pgfplots/every axis title shift=15pt},% + /pgfplots/tiny/.append style= {/pgfplots/every axis title shift=15pt},% + enlargelimits=false, + xmin=0,xmax=1, + ymin=0,ymax=1, + zmin=0,zmax=1, + annot/point format/.style={/pgfplots/annot/point format 3d={##1}}, + }% + \def\pgfplots@xticklabel@pos{}% + \def\pgfplots@yticklabel@pos{}% + \def\pgfplots@zticklabel@pos{}% + %\def\pgfplots@xaxislinesnum{1}% + %\def\pgfplots@yaxislinesnum{3}% + %\def\pgfplots@zaxislinesnum{3}% + \def\pgfplotsifaxissurfaceisforeground##1##2##3{##2}% + \def\pgfplots@init@ticklabelaxisspecfor##1##2{}% + \def\pgfplots@xticklabelaxisspec{v00}% + \def\pgfplots@yticklabelaxisspec{0v0}% + \def\pgfplots@zticklabelaxisspec{00v}% + \def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@##1##2##3{% + \pgfplotspointonorientedsurfaceabtolinespec v##1% + \edef\pgfplots@loc@TMPe{\csname pgfplots@\pgfplotspointonorientedsurfaceA ticklabelaxisspec\endcsname}% + \ifx\pgfplots@loc@TMPe\pgfplotsretval +%\message{pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@{##1}---> TRUE.}% + ##2% + \else +%\message{pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@{##1}---> FALSE.}% + ##3% + \fi + }% + \def\pgfplots@ifgridlines@onorientedsurf@should@be@drawn##1##2{% + ##1% FIXME + }% + \def\pgfplotspointonorientedsurfaceabmatchaxisline##1##2{% + \pgfplotspointonorientedsurfaceabtolinespec v0% FIXME that's just a bad guess! + \edef\pgfplots@loc@TMPe{##1}% + \ifx\pgfplots@loc@TMPe\pgfplotsretval + \def##2{0}% + \else + \def##2{}% + \fi + }% + \let\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn=\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@% + % + % + % cartesian cs + \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end} +}% + +\def\pgfplots@show@ticklabel@ternary@relative#1#2{% + \csname pgfplots@ternary@map@to@unit@#1\endcsname{#2}% + \pgfmathfloatparsenumber\pgfmathresult + \pgfmathfloatshift@\pgfmathresult{2}% + \let\tick=\pgfmathresult +}% + +\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{% + \pgfpointxy@orig{#1}{#2}% +}% + +% This here is *the* key point why ternary axes can be processed with +% almost the same code as rectangular axes. +% +% Recall that rectangular axes are drawn using "oriented surfaces", +% the complete code is based on them. The "a" axis is the direction in +% which we have tick positions and the "b" axis is the direction in +% which tick lines (or grid lines) shall be drawn). +% +% Now, ternary axes do not directly fit into the "oriented surface" +% framework. But they have a lot of structure which allows to use it +% with a specialed "pointonorientedsurfaceab" routine: by noting that +% - there are only three axes, +% - the axis containing tick lines (and grid lines) *always* has one +% component set to 0 (lower limit), and the remaining two components +% sum to 1. Thus, we can simply use one value (for example the "a" +% value) and compute the remaining one, +% - \pgfplotspointonorientedsurfaceab is *always* invoked with +% b set to either the lower or the upper limit. +% The lower limit is easy, see above. The upper limit is mainly used +% for grid lines, more precisely it denotes the target point of the grid line. +% I use special handling to find this target point (by exchanging +% coordinate components, see the implementation). +% +% #1: the "a" value on the oriented surf +% #2: the "b" value. Note that *only* the lower *or* the upper limit +% on the "b" axis are supported here! +% +\def\pgfplotspointonorientedsurfaceab@ternary#1#2{% + \let\pgfplotspointonorientedsurfaceab@ternary@fixedx=\pgfplotspointonorientedsurfaceabsetupfor@fixedx + \let\pgfplotspointonorientedsurfaceab@ternary@fixedy=\pgfplotspointonorientedsurfaceabsetupfor@fixedy + \let\pgfplotspointonorientedsurfaceab@ternary@fixedz=\pgfplotspointonorientedsurfaceabsetupfor@fixedz + % +%\message{\string\pgfplotspointonorientedsurfaceab{#1}{#2} -----> }% + \ifpgfplots@ternary@next@is@unitinterval + \edef\pgfplotspointonorientedsurfaceab@ternary@A{#1}% + \edef\pgfplotspointonorientedsurfaceab@ternary@B{#2}% + \else + \csname pgfplots@ternary@map@to@unit@\pgfplotspointonorientedsurfaceA\endcsname{#1}% + \let\pgfplotspointonorientedsurfaceab@ternary@A=\pgfmathresult + % + \csname pgfplots@ternary@map@to@unit@\pgfplotspointonorientedsurfaceB\endcsname{#2}% + \let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfmathresult + \fi + \if0\pgfplotspointonorientedsurfacespecsymbol + \else + \pgfplots@error{Internal processing error: only \string\pgfplotspointonorientedsurfaceab\space for ternary axes works only for oriented surfs fixed to LOWER or UPPER axis limits.}% + \fi +%\message{A=\pgfplotspointonorientedsurfaceab@ternary@A; B=\pgfplotspointonorientedsurfaceab@ternary@B -----> }% + \ifdim\pgfplotspointonorientedsurfaceab@ternary@B pt=0pt + \pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}% + \let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfmathresult + \expandafter\def\csname pgfplotspointonorientedsurfaceabsetupfor@fixed\pgfplotspointonorientedsurfaceN\endcsname{0}% + \else + %\let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceab@ternary@A + %\pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}% + %\let\pgfplotspointonorientedsurfaceab@ternary@A=\pgfmathresult + %\let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfplots@loc@TMPa + \pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}% + \def\pgfplotspointonorientedsurfaceab@ternary@B{0}% + \expandafter\let\csname pgfplotspointonorientedsurfaceabsetupfor@fixed\pgfplotspointonorientedsurfaceN\endcsname=\pgfmathresult% + \fi + % + \global\pgfplots@ternary@next@is@unitintervaltrue +%\message{\string\pgfplotspointonorientedsurfaceab@orig{\pgfplotspointonorientedsurfaceab@ternary@A}{\pgfplotspointonorientedsurfaceab@ternary@B}[fixedsymbol=\pgfplotspointonorientedsurfacespecsymbol; a=\pgfplotspointonorientedsurfaceA,b=\pgfplotspointonorientedsurfaceB.]}% + \pgfplotspointonorientedsurfaceab@ternary@orig + {\pgfplotspointonorientedsurfaceab@ternary@A}% + {\pgfplotspointonorientedsurfaceab@ternary@B}% + % + \let\pgfplotspointonorientedsurfaceabsetupfor@fixedx=\pgfplotspointonorientedsurfaceab@ternary@fixedx + \let\pgfplotspointonorientedsurfaceabsetupfor@fixedy=\pgfplotspointonorientedsurfaceab@ternary@fixedy + \let\pgfplotspointonorientedsurfaceabsetupfor@fixedz=\pgfplotspointonorientedsurfaceab@ternary@fixedz +}% + +\def\pgfplotspointonorientedsurfaceabwithbshift@ternary#1#2#3{% + % implement the shift in "b" direction explicitly: + % + \pgfplotspointonorientedsurfaceab@ternary{#1}{#2}% + \edef\pgfplots@loc@TMPe{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% + \pgfpointadd + {\pgfplots@loc@TMPe}% + {% + \begingroup + % I need a '-' here because for ternary axes, the "b" axis + % points to the *outside* instead of the inside. + \pgf@xa=-#3\relax + \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}% + % oh. a reversed axis. + \pgf@xa=-\pgf@xa + \fi + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xa}% + \pgfmath@basic@multiply@{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}{\pgfplots@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfqpointscale{\pgfplots@loc@TMPa}{\csname pgfplotspointunit\pgfplotspointonorientedsurfaceB\endcsname}% + }% +} + + +\let\pgfplots@initsizes@ternary@orig=\pgfplots@initsizes +\def\pgfplots@initsizes@ternary{% + \ifpgfplots@threedim + \else + \pgfplots@error{Sorry, 'axis type=ternary' needs a three dimensional axes. Make sure you supplied three dimensional coordinates (using \string\addplot3, for example). This error is critical; I can't recover}% + \fi + % + \pgfplots@initsizes@get@width@withoutlabels + \pgf@x=\pgfmathresult + \edef\pgfplots@width@ternary{\pgf@sys@tonumber\pgf@x}% + % + \pgfplots@initsizes@ternary@orig + % +}% + +\let\pgfplots@limits@ready@original=\pgfplots@limits@ready + +\def\pgfplots@limits@ready@ternary{% + \pgfplots@limits@ready@original + % +%\message{ternary with limits x=[\pgfplots@xmin:\pgfplots@xmax], y=[\pgfplots@ymin:\pgfplots@ymax]; z=[\pgfplots@zmin:\pgfplots@zmax].}% + \pgfplots@ternary@init@map@to@unit x% + \pgfplots@ternary@init@map@to@unit y% + \pgfplots@ternary@init@map@to@unit z% +}% + +\def\pgfplots@ternary@init@map@to@unit#1{% + \begingroup + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@#1max\endcsname}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@#1min\endcsname}% + \let\pgfplots@map@to@unit@scale@diff=\pgfmathresult + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@loc@TMPa}{\pgfmathresult}}% + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}% + \let\pgfplots@map@to@unit@scale=\pgfmathresult + % + \expandafter\xdef\csname pgfplots@ternary@map@to@unit@#1\endcsname##1{% + \noexpand\pgfplotscoordmath{default}{parsenumber}{##1}% + \noexpand\pgfplotscoordmath{default}{op}{subtract}{{\noexpand\pgfmathresult}{\pgfplots@map@to@unit@scale@diff}}% + \noexpand\pgfplotscoordmath{default}{op}{multiply}{{\noexpand\pgfmathresult}{\pgfplots@map@to@unit@scale}}% + \noexpand\pgfplotscoordmath{default}{tofixed}{\noexpand\pgfmathresult}% + }% + \endgroup +} + +\def\pgfplots@initsizes@setunitvector@ternary#1#2#3#4{% + % ternary axis are DIFFERENT here. + % They don't use the (xx,xy), (yx,yy), (zx,zy) vectors, so we can + % use them to implement *cartesian* coordinates. + % + % Thus, any \draw (0,0) inside of a ternary axis will yield + % cartesian coordinates. + % + % The relevant quantities to *draw* the diagram are the three + % axis, they are also prepared here. + % + \def#4{0}% whether we have (#1,0) or (0,#1) + \ifcase#2% + \pgfsetxvec{% + \pgfqpoint{\pgfplots@width@ternary pt}{0pt}% + }% + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100}% + \or + \pgfsetyvec{% + \pgfqpoint{0pt}{\pgfplots@width@ternary pt}% + }% + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010}% + \or + \pgfsetzvec{% + \pgfpointorigin + }% + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001}% + \fi + \expandafter\xdef\csname pgfplotspoint#1axis\endcsname{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + % +%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).}% +}% + +\def\pgfplots@computeunitvectorlengths@ternary{% + \pgfplots@computeunitvectorlengths@ternary@ x% + \pgfplots@computeunitvectorlengths@ternary@ y% + \pgfplots@computeunitvectorlengths@ternary@ z% +} +\def\pgfplots@computeunitvectorlengths@ternary@#1{% + \csname pgfplotspoint#1axis\endcsname + \pgfmathveclen{\pgf@x}{\pgf@y}% + \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + }% + \expandafter\xdef\csname pgfplotspoint#1axislength\endcsname{\pgfplots@x@veclength pt}% + % +}% + +\newif\ifpgfplots@ternary@next@is@unitinterval + +% Deduce z = 1-x-y after transformation to relative coordinates. +\def\pgfplotsqpointxy@ternary#1#2{% + \pgf@process{% + \ifpgfplots@ternary@next@is@unitinterval + \dimen1=#1pt + \dimen2=#2pt + \else + \pgfplots@ternary@map@to@unit@x{#1}% + \dimen1=\pgfmathresult pt + % + \pgfplots@ternary@map@to@unit@y{#2}% + \dimen2=\pgfmathresult pt + \fi + \dimen4=\dimen1 + \advance\dimen4 by\dimen2 + \dimen3=1pt + \advance\dimen3 by-\dimen4 + % + \global\pgfplots@ternary@next@is@unitintervalfalse + \pgfplotsqpointxyz@ternary@ + }% +}% +% gx(x,y,z) = 0.5 * (x + 2*z)/(x+y+z) +% gy(x,y,z) = (sqrt(3) / 2) * x / (x+y+z) +\def\pgfplotsqpointxyz@ternary#1#2#3{% + \pgf@process{% + \ifpgfplots@ternary@next@is@unitinterval + \dimen1=#1pt + \dimen2=#2pt + \dimen3=#3pt + \else + \pgfplots@ternary@map@to@unit@x{#1}% + \dimen1=\pgfmathresult pt + % + \pgfplots@ternary@map@to@unit@y{#2}% + \dimen2=\pgfmathresult pt + % + \pgfplots@ternary@map@to@unit@z{#3}% + \dimen3=\pgfmathresult pt + \fi + \global\pgfplots@ternary@next@is@unitintervalfalse + % + \pgfplotsqpointxyz@ternary@ + }% +}% +\def\pgfplotsqpointxyz@ternary@{% + %\dimen1=#1 + %\dimen2=#2 + %\dimen3=#3 + % FIXME . I didn't understand that stuff. + \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reversed + %\multiply\dimen1 by-1 + %\advance\dimen1 by1pt + %\dimen1=#2 + %\dimen2=#3 + %\dimen3=#1 + \fi + %-------------------------------------------------- + % \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reversed + % \multiply\dimen2 by-1 + % \advance\dimen2 by1pt + % \fi + % \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reversed + % \multiply\dimen3 by-1 + % \advance\dimen3 by1pt + % \fi + %-------------------------------------------------- + \pgfplotsqpointxyz@ternary@@% +}% +\def\pgfplotsqpointxyz@ternary@@{% + % Disable renormalization!? + %\dimen4=\dimen1 + %\advance\dimen4 by\dimen2 + %\advance\dimen4 by\dimen3 + %\edef\pgfplots@ternary@sum{\pgf@sys@tonumber{\dimen4}}% + %\pgfmathapproxequalto@{1}{\pgfplots@ternary@sum}% + \pgfmathcomparisontrue + \ifpgfmathcomparison + \let\pgfplots@ternary@scale=\pgfplots@width@ternary + \else + \pgfmath@basic@divide@ + {\pgfplots@width@ternary}% + {\pgfplots@ternary@sum}% + \let\pgfplots@ternary@scale=\pgfmathresult + \fi + % + \dimen4=2\dimen3 + \advance\dimen4 by \dimen1 + \divide\dimen4 by2 + \pgf@x=\pgfplots@ternary@scale\dimen4 + % + \dimen4=\dimen1 + \dimen4=0.866025403784\dimen4 % *= sqrt(3)/2 + \pgf@y=\pgfplots@ternary@scale\dimen4 + % +}% +\def\pgfplotspoint@initialisation@units@ternary{% + \let\pgfplotspointunitx\pgfplotspointxaxis + \let\pgfplotspointunity\pgfplotspointyaxis + \let\pgfplotsunitxlength=\pgfplots@x@veclength + \let\pgfplotsunitylength=\pgfplots@y@veclength + \let\pgfplotsunitxinvlength=\pgfplots@x@inverseveclength + \let\pgfplotsunityinvlength=\pgfplots@y@inverseveclength + \ifpgfplots@threedim + \let\pgfplotspointunitz=\pgfplotspointzaxis + \let\pgfplotsunitzlength=\pgfplots@z@veclength + \let\pgfplotsunitzinvlength=\pgfplots@z@inverseveclength + \fi +}% + +% POSTCONDITION: the macros +% \pgfplotspointminminmin +% \pgfplotspoint[xyz]axis +% \pgfplotspoint[xyz]axislength +% are defined (globally). +\def\pgfplotspoint@initialisation@axes@ternary{% + \xdef\pgfplotspointminminmin{\noexpand\pgfpointorigin}% + % + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100}% + \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse + \pgfqpointscale{-1}{}% + \fi + \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \expandafter\let\csname pgfplots@x@veclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@x@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@x@inverseveclength\endcsname=\pgfmathresult + }% + \xdef\pgfplotspointxaxislength{\pgfplots@x@veclength pt}% + % + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010}% + \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse + \pgfqpointscale{-1}{}% + \fi + \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \expandafter\let\csname pgfplots@y@veclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@y@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@y@inverseveclength\endcsname=\pgfmathresult + }% + \xdef\pgfplotspointyaxislength{\pgfplots@y@veclength pt}% + % + \pgfpointdiff + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010} + {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001}% + \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse + \pgfqpointscale{-1}{}% + \fi + \xdef\pgfplotspointzaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \pgfmathveclen{\pgf@x}{\pgf@y}% + \expandafter\let\csname pgfplots@z@veclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@z@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@z@inverseveclength\endcsname=\pgfmathresult + }% + \xdef\pgfplotspointzaxislength{\pgfplots@z@veclength pt}% + % +} +\def\pgfplots@prepare@ZERO@coordinates@ternary{% + \ifpgfplots@xislinear + \ifpgfplots@apply@datatrafo@x + \pgfplotscoordmath{x}{parsenumber}{0}% + \pgfplotscoordmath{x}{datascaletrafo}{\pgfmathresult}% + \global\let\pgfplots@logical@ZERO@x=\pgfmathresult + \else + \gdef\pgfplots@logical@ZERO@x{0}% + \fi + \pgfplotsmathmax{\pgfplots@logical@ZERO@x}{\pgfplots@xmin}% + \global\let\pgfplots@logical@ZERO@x=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@x}{\pgfplots@xmax}% + \global\let\pgfplots@logical@ZERO@x=\pgfmathresult + \else + \global\let\pgfplots@logical@ZERO@x=\pgfplots@xmin% + \fi + % + \ifpgfplots@yislinear + \ifpgfplots@apply@datatrafo@y + \pgfplotscoordmath{y}{parsenumber}{0}% + \pgfplotscoordmath{y}{datascaletrafo}{\pgfmathresult}% + \global\let\pgfplots@logical@ZERO@y=\pgfmathresult + \else + \gdef\pgfplots@logical@ZERO@y{0}% + \fi + \pgfplotsmathmax{\pgfplots@logical@ZERO@y}{\pgfplots@ymin}% + \global\let\pgfplots@logical@ZERO@y=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@y}{\pgfplots@ymax}% + \global\let\pgfplots@logical@ZERO@y=\pgfmathresult + \else + \global\let\pgfplots@logical@ZERO@y=\pgfplots@ymin% + \fi + % + \ifpgfplots@threedim + \ifpgfplots@zislinear + \ifpgfplots@apply@datatrafo@z + \pgfplotscoordmath{z}{parsenumber}{0}% + \pgfplotscoordmath{z}{datascaletrafo}{\pgfmathresult}% + \global\let\pgfplots@logical@ZERO@z=\pgfmathresult + \else + \gdef\pgfplots@logical@ZERO@z{0}% + \fi + \pgfplotsmathmax{\pgfplots@logical@ZERO@z}{\pgfplots@zmin}% + \global\let\pgfplots@logical@ZERO@z=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@z}{\pgfplots@zmax}% + \global\let\pgfplots@logical@ZERO@z=\pgfmathresult + \else + \global\let\pgfplots@logical@ZERO@z=\pgfplots@zmin% + \fi + \fi + % + % + \global\pgfplots@ternary@next@is@unitintervaltrue + \pgfplotsqpointxyz100% + \xdef\pgfplots@ZERO@x{\the\pgf@x}% + \xdef\pgfplots@ZERO@y{\the\pgf@y}% + \xdef\pgfplotspointaxisorigin{\noexpand\pgf@x=\pgfplots@ZERO@x\space\noexpand\pgf@y=\pgfplots@ZERO@y\space}% +}% + + +\def\pgfplots@draw@axis@ternary{% + % + % this should become the line for varying y: + \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmin}{0}% + \pgfplots@draw@axis@insurface yxz + % + % this should become the line for varying z: + \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}% + \pgfplots@draw@axis@insurface zyx + % + % + % this should become the line for varying x: + \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}% + \pgfplots@draw@axis@insurface xzy + % + \pgfplots@ternary@draw@axislines +}% +\def\pgfplots@ternary@draw@axislines{% + \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse + \pgfplots@separate@axis@linestrue + \fi + \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse + \pgfplots@separate@axis@linestrue + \fi + \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse + \pgfplots@separate@axis@linestrue + \fi + \ifpgfplots@separate@axis@lines + \scope[/pgfplots/every outer x axis line, + xdiscont,decoration={pre length=\csname xdisstart\endcsname, post length=\csname xdisend\endcsname}] + \draw decorate { + \pgfextra + \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \else + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \fi + \endpgfextra + }; + \endscope + % + \scope[/pgfplots/every outer y axis line, + ydiscont,decoration={pre length=\csname ydisstart\endcsname, post length=\csname ydisend\endcsname}] + \draw decorate { + \pgfextra + \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \else + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \fi + \endpgfextra + }; + \endscope + % + \scope[/pgfplots/every outer z axis line, + zdiscont,decoration={pre length=\csname zdisstart\endcsname, post length=\csname zdisend\endcsname}] + \draw decorate { + \pgfextra + \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \else + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \fi + \endpgfextra + }; + \endscope + \else + \draw[ + /pgfplots/every outer x axis line, % FIXME! these outer styles need much more attention :-( + /pgfplots/every outer y axis line] + \pgfextra{% + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \pgfpathclose + }; + \fi +}% +\def\pgfplots@clippath@prepare@for@axistype@ternary{% + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}% + \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% +}% + +\def\pgfplots@draw@axis@post@ternary{% + % do nothing. There is no 3d box to draw here. +}% + +\def\pgfplotspointouternormalvectorofaxis@ternary#1#2#3\relax{% + \edef\pgfplots@loc@TMPa{\if r\pgfkeysvalueof{/pgfplots/x dir/value}-\fi}% reverse + \edef\pgfplots@loc@TMPb{\if r\pgfkeysvalueof{/pgfplots/y dir/value}-\fi}% reverse + \edef\pgfplots@loc@TMPc{\if r\pgfkeysvalueof{/pgfplots/z dir/value}-\fi}% reverse + \if v#1% + \pgfpointadd + {\pgfqpointscale{\pgfplots@loc@TMPb-1}{\pgfplotspointyaxis}}% + {\pgfqpointscale{\pgfplots@loc@TMPc}{\pgfplotspointzaxis}}% + \else + \if v#2% + \pgfpointadd + {\pgfqpointscale{\pgfplots@loc@TMPa}{\pgfplotspointxaxis}}% + {\pgfqpointscale{\pgfplots@loc@TMPc-1}{\pgfplotspointzaxis}}% + \else + \pgfpointadd + {\pgfqpointscale{\pgfplots@loc@TMPa-1}{\pgfplotspointxaxis}}% + {\pgfqpointscale{\pgfplots@loc@TMPb}{\pgfplotspointyaxis}}% + \fi + \fi + \pgf@process{\pgfpointnormalised{}}% + \endgroup +}% + + +\def\pgfplotsclickable@check@enable@axistype@ternaryaxis{% + \def\pgfplotsretval{1}% +}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% tieline plots +% +\pgfplotsset{ + tieline/.code={% + \let\tikz@plot@handler=\pgfplotsplothandlertieline + \pgfkeysifdefined{/pgfplots/table/tie end x}{}{% + % provide these keys locally: + \pgfkeyslet{/pgfplots/table/tie end x}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end y}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end z}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end x index}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end y index}\pgfutil@empty% + \pgfkeyslet{/pgfplots/table/tie end z index}\pgfutil@empty% + }% + \pgfqkeys{/pgfplots/tieline}{#1}% + }, + tieline/every tieline/.style={}, + tieline/tieline style/.style={/pgfplots/tieline/every tieline/.append style={#1}}, + tieline/every curve/.style={}, + tieline/curve style/.style={/pgfplots/tieline/every curve/.append style={#1}}, + tieline/each nth tie/.initial=, +} +\def\pgfplotsplothandlertieline{% + \pgfplotsresetplothandler + \let\pgf@plotstreamstart=\pgfplotsplothandlervisbegin@tieline + \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@tieline + \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@tieline + \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@tieline +}% +\def\pgfplotsplothandlervisbegin@tieline{% + \pgfplotsapplistXnewempty\pgfp@binodal@A + \pgfplotsapplistXnewempty\pgfp@ties + \pgfplotsprependlistXnewempty{pgfp@binodal@B@reverse} + \def\b@pgfplotsplothandlersurveystart@tieline@even{1}% + % + \global\let\pgf@plotstreampoint=\pgfplotsplothandlervis@streampoint@tieline + \global\let\pgf@plotstreamend=\pgfplotsplothandlervis@streamend@tieline + % + \pgfkeysgetvalue{/pgfplots/tieline/each nth tie}\pgfplots@eachnth@tie + \ifx\pgfplots@eachnth@tie\pgfutil@empty + \def\pgfplots@eachnth@tie{1}% + \fi + \let\c@pgfplots@tiecounter=\c@pgfplotstable@counta + \c@pgfplots@tiecounter=0 +}% +\def\pgfplotsplothandlervis@streampoint@tieline#1{% + \pgf@process{#1}% + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplots@stream@withmeta@ + {\pgfplots@current@point@coordindex}% + {\the\pgf@x}{\the\pgf@y}% + {\pgfplots@current@point@meta}% + }% + \if1\b@pgfplotsplothandlersurveystart@tieline@even + \let\pgfplotsplothandlervis@streampoint@tieline@last=\pgfplots@loc@TMPa + \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfp@binodal@A + \def\b@pgfplotsplothandlersurveystart@tieline@even{0}% + \else + \expandafter\pgfplotsprependlistXpushfront\pgfplots@loc@TMPa\to{pgfp@binodal@B@reverse}% + % + \advance\c@pgfplots@tiecounter by1 + \ifnum\pgfplots@eachnth@tie=\c@pgfplots@tiecounter + \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}% + \t@pgfplots@tokb=\expandafter{\pgfplotsplothandlervis@streampoint@tieline@last}% + \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\noexpand\pgfplotsplothandlertieline@finishtie}% + \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfp@ties + \c@pgfplots@tiecounter=0 + \fi + % + \def\b@pgfplotsplothandlersurveystart@tieline@even{1}% + \fi +}% +\def\pgfplotsplothandlervis@streamend@tieline{% + \begingroup + \pgfplots@drawmodes@appendtrue + \path[/pgfplots/tieline/every curve]% + \pgfextra + \ifx\tikz@plot@handler\pgfplotsplothandlertieline + \let\tikz@plot@handler\pgfplothandlerlineto + \fi + \pgfplotsresetplothandler + \tikz@plot@handler + \pgf@plotstreamstart + % + \pgfplotsapplistXlet\pgfplots@loc@TMPa=\pgfp@binodal@A + \pgfplots@loc@TMPa + \pgfplotsapplistXnewempty\pgfp@binodal@A + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={pgfp@binodal@B@reverse}% + \pgfplots@loc@TMPa + \pgfplotsprependlistXnewempty{pgfp@binodal@B@reverse}% + % + \pgf@plotstreamend + \endpgfextra; + \endgroup + % + % + \pgfplotsset{/pgfplots/tieline/every tieline}% + \ifx\tikz@plot@handler\pgfplotsplothandlertieline + \let\tikz@plot@handler\pgfplothandlerlineto + \fi + \pgfplotsresetplothandler + \tikz@plot@handler + \pgf@plotstreamstart + % + \def\pgfplotsplothandlertieline@finishtie{% + \pgfplotsplothandlervisualizejump + }% + \pgfplotsapplistXlet\pgfplots@loc@TMPa=\pgfp@ties + \pgfplots@loc@TMPa + \pgfplotsapplistXnewempty\pgfp@ties + % + \pgf@plotstreamend +}% + +\def\pgfplotsplothandlersurveystart@tieline{% + \def\pgfplots@loc@TMPa{table}% + \ifx\pgfplotssurveyphaseinputclass\pgfplots@loc@TMPa + \else + \pgfplots@error{Sorry, 'tieline' plots are currently only supported for \string\addplot\space table}% + \fi + \def\b@pgfplotsplothandlersurveystart@tieline@init{0}% +}% +\def\pgfplotsplothandlersurveyend@tieline{% +}% + +\def\pgfplotsplothandlersurveypoint@tieline@init{% + \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor x\pgfplotsplothandlertieline@Bx + \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor y\pgfplotsplothandlertieline@By + \ifpgfplots@curplot@threedim + \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor z\pgfplotsplothandlertieline@Bz + \fi + % + \def\b@pgfplotsplothandlersurveystart@tieline@init{1}% +}% +\def\pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor#1#2{% + \let#2=\relax + \pgfkeysgetvalue{/pgfplots/table/tie end #1}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfkeysgetvalue{/pgfplots/table/tie end #1 index}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \edef#2{\noexpand\getthisrowno{\pgfplots@loc@TMPa}\noexpand\pgfmathresult}% + \fi + \else + \edef#2{\noexpand\getthisrow{\pgfplots@loc@TMPa}\noexpand\pgfmathresult}% + \fi + \ifx#2\relax + \pgfplotsplothandlersurveypoint@tieline@init@find@colindex@for #1\pgfplots@loc@ind + \c@pgf@countd=\pgfplots@loc@ind\relax + \advance\c@pgf@countd by3 + \ifnum\c@pgf@countd<\pgfplotstablecols\relax + \else + \c@pgf@countd=0 + \pgfplots@error{Sorry, I can't find the 'tie end #1 index' automatically. Please provide 'table[tie end #1={}]' or 'table[tie end #1 index=]' manually and verify the all, x,y and z components are correct}% + \fi + \edef\pgfplots@loc@ind{\the\c@pgf@countd}% + \pgfkeyslet{/pgfplots/table/tie end #1 index}\pgfplots@loc@ind + \edef#2{\noexpand\getthisrowno{\pgfplots@loc@ind}\noexpand\pgfmathresult}% + \fi +}% + +\def\pgfplotsplothandlersurveypoint@tieline@init@find@colindex@for#1#2{% + \pgfkeysgetvalue{/pgfplots/table/#1}{\pgfplots@loc@TMPa}% + \pgfkeysgetvalue{/pgfplots/table/#1 index}{\pgfplots@loc@TMPb}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \let#2=\pgfplots@loc@TMPb + \else + \def\pgfplots@loc@TMPb{\expandafter\pgfplotstablegetcolumnindexforname\expandafter{\pgfplots@loc@TMPa}\of}% + \expandafter\pgfplots@loc@TMPb\pgfplotstablename\to#2% + \fi +}% + +\def\pgfplotsplothandlersurveypoint@tieline{% + \if0\b@pgfplotsplothandlersurveystart@tieline@init + \pgfplotsplothandlersurveypoint@tieline@init + \fi + \pgfplotsplothandlersurveypoint@default + % + \pgfplotsplothandlertieline@Bx\let\pgfplots@current@point@x=\pgfmathresult + \pgfplotsplothandlertieline@By\let\pgfplots@current@point@y=\pgfmathresult + \ifpgfplots@curplot@threedim + \pgfplotsplothandlertieline@Bz\let\pgfplots@current@point@z=\pgfmathresult + \fi + \pgfplotsplothandlersurveypoint@default +}% +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.units.code.tex b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.units.code.tex new file mode 100644 index 0000000..084d076 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/libs/tikzlibrarypgfplots.units.code.tex @@ -0,0 +1,224 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2009 by Nick Papior Andersen. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +% +% This file contains the implementation for using units in labels. +% +% Default the unit setting system isn't used, It is thus required to use the key "use units". +% +% Programming Structure: +% +% 1. All associated keys are first set. This includes some prefix values of the unit system. +% In example one can redefine prefix and postfix such that units are shown on a per-user setting. +% +% 2. The other main thing is scaling of the dimension. If one uses units one might not +% have scaled the data. For this the keys "scaled ticks" are used at a base 10. +% Currently it is not provided to scale in other bases. +% FIXME Adding of other bases. +% +% 3. Some predefined SI prefixes are specified which should minimize mistakes. +% For example the key "change base, SI prefix=kilo" allows the +% to be rescaled according to the above at base 10 with a factor of -3 and sets the +% unit prefix to "k". +% FIXME Adding other basis systems than SI. For example the addition of CGS units. + +\newif\ifpgfplots@units@change@x@base +\newif\ifpgfplots@units@change@y@base +\newif\ifpgfplots@units@change@z@base + +% +% Constants for writing the unit marking +% +\def\pgfplots@units@marking@pre{} +\def\pgfplots@units@marking@post{} + +\pgfkeys{% + /pgfplots/use units/.is if=pgfplots@units@use,% + /pgfplots/use units=true,% So when called from \usepgfplotslibrary{units} it's automatically 'on' + % + % Setup basic x settings + % + /pgfplots/x unit/.initial={},% + /pgfplots/x unit prefix/.initial={},% + /pgfplots/change x base/.is if=pgfplots@units@change@x@base,% + /pgfplots/change x base=false,% + % + % Setup basic y settings + % + /pgfplots/y unit/.initial={},% + /pgfplots/y unit prefix/.initial={},% + /pgfplots/change y base/.is if=pgfplots@units@change@y@base,% + /pgfplots/change y base=false,% + % + % Setup basic z settings + % + /pgfplots/z unit/.initial={},% + /pgfplots/z unit prefix/.initial={},% + /pgfplots/change z base/.is if=pgfplots@units@change@z@base,% + /pgfplots/change z base=false,% + % + % default markings of units. I.e. the surroundings of the unit: + % [unit markings=curly braces] yields {} + % + /pgfplots/unit marking pre/.store in={\pgfplots@units@marking@pre},% + /pgfplots/unit marking post/.store in={\pgfplots@units@marking@post},% + /pgfplots/unit markings/.is choice,% + /pgfplots/unit markings/parenthesis/.style={/pgfplots/unit marking pre={\left(},/pgfplots/unit marking post={\right)}},% + /pgfplots/unit markings/square braces/.style={/pgfplots/unit marking pre={\left[},/pgfplots/unit marking post={\right]}},% + /pgfplots/unit markings/curly braces/.style={/pgfplots/unit marking pre={\left\{},/pgfplots/unit marking post={\right\}}},% + /pgfplots/unit markings/slash space/.style={/pgfplots/unit marking pre={/$\space$},/pgfplots/unit marking post={\relax}},% + /pgfplots/unit markings=square braces,% + % + % The code used to type units, and the base change code. + % + /pgfplots/unit code/.code 2 args={\mathrm{#1#2}},% + /pgfplots/axis base prefix/.code args={axis #1 base #2 prefix #3}{% + \csname ifpgfplots@units@change@#1@base\endcsname% + \pgfkeys{/pgfplots/#1\space unit prefix={#3},% + /pgfplots/scaled #1\space ticks={base 10:#2},% + /pgfplots/#1tick scale label code/.code={\relax}% + }% + \else% + \pgfkeys{/pgfplots/#1\space unit prefix={#3}}% + \fi% + },% + % + % x SI prefixes + % + /pgfplots/x SI prefix/.is choice,% + /pgfplots/x SI prefix/yocto/.style={/pgfplots/axis base prefix={axis x base 24 prefix y}},% + /pgfplots/x SI prefix/zepto/.style={/pgfplots/axis base prefix={axis x base 21 prefix z}},% + /pgfplots/x SI prefix/atto/.style={/pgfplots/axis base prefix={axis x base 18 prefix a}},% + /pgfplots/x SI prefix/femto/.style={/pgfplots/axis base prefix={axis x base 15 prefix f}},% + /pgfplots/x SI prefix/pico/.style={/pgfplots/axis base prefix={axis x base 12 prefix p}},% + /pgfplots/x SI prefix/nano/.style={/pgfplots/axis base prefix={axis x base 9 prefix n}},% + /pgfplots/x SI prefix/micro/.style={/pgfplots/axis base prefix={axis x base 6 prefix \mu}},% + /pgfplots/x SI prefix/milli/.style={/pgfplots/axis base prefix={axis x base 3 prefix m}},% + /pgfplots/x SI prefix/centi/.style={/pgfplots/axis base prefix={axis x base 2 prefix c}},% + /pgfplots/x SI prefix/deci/.style={/pgfplots/axis base prefix={axis x base 1 prefix d}},% + /pgfplots/x SI prefix/deca/.style={/pgfplots/axis base prefix={axis x base -1 prefix da}},% + /pgfplots/x SI prefix/hecto/.style={/pgfplots/axis base prefix={axis x base -2 prefix h}},% + /pgfplots/x SI prefix/kilo/.style={/pgfplots/axis base prefix={axis x base -3 prefix k}},% + /pgfplots/x SI prefix/mega/.style={/pgfplots/axis base prefix={axis x base -6 prefix M}},% + /pgfplots/x SI prefix/giga/.style={/pgfplots/axis base prefix={axis x base -9 prefix G}},% + /pgfplots/x SI prefix/tera/.style={/pgfplots/axis base prefix={axis x base -12 prefix T}},% + /pgfplots/x SI prefix/peta/.style={/pgfplots/axis base prefix={axis x base -15 prefix P}},% + /pgfplots/x SI prefix/exa/.style={/pgfplots/axis base prefix={axis x base -18 prefix E}},% + /pgfplots/x SI prefix/zetta/.style={/pgfplots/axis base prefix={axis x base -21 prefix Z}},% + /pgfplots/x SI prefix/yotta/.style={/pgfplots/axis base prefix={axis x base -24 prefix Y}},% + % + % y SI prefixes + % + /pgfplots/y SI prefix/.is choice,% + /pgfplots/y SI prefix/yocto/.style={/pgfplots/axis base prefix={axis y base 24 prefix y}},% + /pgfplots/y SI prefix/zepto/.style={/pgfplots/axis base prefix={axis y base 21 prefix z}},% + /pgfplots/y SI prefix/atto/.style={/pgfplots/axis base prefix={axis y base 18 prefix a}},% + /pgfplots/y SI prefix/femto/.style={/pgfplots/axis base prefix={axis y base 15 prefix f}},% + /pgfplots/y SI prefix/pico/.style={/pgfplots/axis base prefix={axis y base 12 prefix p}},% + /pgfplots/y SI prefix/nano/.style={/pgfplots/axis base prefix={axis y base 9 prefix n}},% + /pgfplots/y SI prefix/micro/.style={/pgfplots/axis base prefix={axis y base 6 prefix \mu}},% + /pgfplots/y SI prefix/milli/.style={/pgfplots/axis base prefix={axis y base 3 prefix m}},% + /pgfplots/y SI prefix/centi/.style={/pgfplots/axis base prefix={axis y base 2 prefix c}},% + /pgfplots/y SI prefix/deci/.style={/pgfplots/axis base prefix={axis y base 1 prefix d}},% + /pgfplots/y SI prefix/deca/.style={/pgfplots/axis base prefix={axis y base -1 prefix da}},% + /pgfplots/y SI prefix/hecto/.style={/pgfplots/axis base prefix={axis y base -2 prefix h}},% + /pgfplots/y SI prefix/kilo/.style={/pgfplots/axis base prefix={axis y base -3 prefix k}},% + /pgfplots/y SI prefix/mega/.style={/pgfplots/axis base prefix={axis y base -6 prefix M}},% + /pgfplots/y SI prefix/giga/.style={/pgfplots/axis base prefix={axis y base -9 prefix G}},% + /pgfplots/y SI prefix/tera/.style={/pgfplots/axis base prefix={axis y base -12 prefix T}},% + /pgfplots/y SI prefix/peta/.style={/pgfplots/axis base prefix={axis y base -15 prefix P}},% + /pgfplots/y SI prefix/exa/.style={/pgfplots/axis base prefix={axis y base -18 prefix E}},% + /pgfplots/y SI prefix/zetta/.style={/pgfplots/axis base prefix={axis y base -21 prefix Z}},% + /pgfplots/y SI prefix/yotta/.style={/pgfplots/axis base prefix={axis y base -24 prefix Y}},% + % + % z SI prefixes + % + /pgfplots/z SI prefix/.is choice,% + /pgfplots/z SI prefix/yocto/.style={/pgfplots/axis base prefix={axis z base 24 prefix y}},% + /pgfplots/z SI prefix/zepto/.style={/pgfplots/axis base prefix={axis z base 21 prefix z}},% + /pgfplots/z SI prefix/atto/.style={/pgfplots/axis base prefix={axis z base 18 prefix a}},% + /pgfplots/z SI prefix/femto/.style={/pgfplots/axis base prefix={axis z base 15 prefix f}},% + /pgfplots/z SI prefix/pico/.style={/pgfplots/axis base prefix={axis z base 12 prefix p}},% + /pgfplots/z SI prefix/nano/.style={/pgfplots/axis base prefix={axis z base 9 prefix n}},% + /pgfplots/z SI prefix/micro/.style={/pgfplots/axis base prefix={axis z base 6 prefix \mu}},% + /pgfplots/z SI prefix/milli/.style={/pgfplots/axis base prefix={axis z base 3 prefix m}},% + /pgfplots/z SI prefix/centi/.style={/pgfplots/axis base prefix={axis z base 2 prefix c}},% + /pgfplots/z SI prefix/deci/.style={/pgfplots/axis base prefix={axis z base 1 prefix d}},% + /pgfplots/z SI prefix/deca/.style={/pgfplots/axis base prefix={axis z base -1 prefix da}},% + /pgfplots/z SI prefix/hecto/.style={/pgfplots/axis base prefix={axis z base -2 prefix h}},% + /pgfplots/z SI prefix/kilo/.style={/pgfplots/axis base prefix={axis z base -3 prefix k}},% + /pgfplots/z SI prefix/mega/.style={/pgfplots/axis base prefix={axis z base -6 prefix M}},% + /pgfplots/z SI prefix/giga/.style={/pgfplots/axis base prefix={axis z base -9 prefix G}},% + /pgfplots/z SI prefix/tera/.style={/pgfplots/axis base prefix={axis z base -12 prefix T}},% + /pgfplots/z SI prefix/peta/.style={/pgfplots/axis base prefix={axis z base -15 prefix P}},% + /pgfplots/z SI prefix/exa/.style={/pgfplots/axis base prefix={axis z base -18 prefix E}},% + /pgfplots/z SI prefix/zetta/.style={/pgfplots/axis base prefix={axis z base -21 prefix Z}},% + /pgfplots/z SI prefix/yotta/.style={/pgfplots/axis base prefix={axis z base -24 prefix Y}}% +} +% +% The initial insert of labels. It utilizes the same method of implementation as +% the default label typesetting. +% +\def\pgfplots@label@units#1{% + \pgfkeysgetvalue{/pgfplots/#1label}{\pgfplots@loc@TMPa}% + \pgfplots@loc@TMPa\space\pgfplots@label@units@@{#1}% +} + +% +% The main macro for typesetting the units. In steps: +% +% 1. Save the unit prefix, unit and the unit code in macros. +% +% 2. If the unit isn't present then don't utilize any of the things. +% FIXME, should this also happen if the prefix is given? Currently it is not! +% +% 3. Defines \pgfplots@loc@TMPa as the real typeset label. +% It inserts the . +% It is encapsulated within a $$ notation. Currently this is enough. +% FIXME, maybe this should be changed to \ensuremath? +% +\def\pgfplots@label@units@@#1{% + \pgfkeysgetvalue{/pgfplots/#1\space unit prefix}{\pgfplots@loc@TMPb}% + \pgfkeysgetvalue{/pgfplots/#1\space unit}{\pgfplots@loc@TMPc}% + \ifx\pgfplots@loc@TMPc\pgfutil@empty% + \pgfutil@empty% + \else% + \ifx\pgfplots@loc@TMPb\pgfutil@empty% + $ + \pgfplots@units@marking@pre + \pgfplots@invoke@pgfkeyscode{/pgfplots/unit code/.@cmd}{{}{\pgfkeysvalueof{/pgfplots/#1\space unit}}} + \pgfplots@units@marking@post + $% + \else% + $ + \pgfplots@units@marking@pre + \pgfplots@invoke@pgfkeyscode{/pgfplots/unit code/.@cmd}{{\pgfkeysvalueof{/pgfplots/#1\space unit prefix}}{\pgfkeysvalueof{/pgfplots/#1\space unit}}} + \pgfplots@units@marking@post + $% + \fi% + \fi% +} +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex new file mode 100644 index 0000000..59b69da --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex @@ -0,0 +1,669 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This is a helper package with an elementary array datastructure, +% featuring O(1) index access and O(N) creation, deletion, copy. +% +% The following macros are supplied: +% +% \pgfplotsarraynewempty +% \pgfplotsarraynew +% \pgfplotsarrayresize +% \pgfplotsarraycopy +% \pgfplotsarraypushback +% \pgfplotsarraysize +% \pgfplotsarrayselect +% \pgfplotsarrayset +% \pgfplotsarrayletentry +% \pgfplotsarraycheckempty +% \pgfplotsarrayforeach +% \pgfplotsarraysort +% +% and a subset also for global arrays: +% \pgfplotsarraynewemptyglobal +% \pgfplotsarrayresizeglobal +% \pgfplotsarraysetglobal +% \pgfplotsarrayletentryglobal +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcount\c@pgfplotsarray@tmp +\newif\ifpgfplotsarrayempty + +% Creates a new, empty array. +\def\pgfplotsarraynewempty#1{% + \pgfplotsarray@@def{#1@size}{0}% +} +\def\pgfplotsarraynewemptyglobal#1{% + \expandafter\gdef\csname\string#1@size\endcsname{0}% +} + +% resizes (truncates) array #1 to size #2 +% +% the elements won't be initialised. Use 'set' for each element. +\def\pgfplotsarrayresize#1#2{% + \c@pgfplotsarray@tmp=#2 + \pgfplotsarray@@edef{#1@size}{\the\c@pgfplotsarray@tmp}% +} +\def\pgfplotsarrayresizeglobal#1#2{% + \c@pgfplotsarray@tmp=#2 + \expandafter\xdef\csname\string#1@size\endcsname{\the\c@pgfplotsarray@tmp}% +} + +% Invokes code '#2' if the array named '#1' exists and '#3' if it does +% not exist. +\def\pgfplotsarrayifdefined#1#2#3{% + \pgfutil@ifundefined{#1@size}{#3}{#2}% +}% + +% Creates a new array with an abirtrary number of elements. +% Arguments: +% #1: the array's name (a macro name) +% #2: the elements in one of the following forms +% a) a '\\' terminated list: +% first\\second\\third\\ ...\\ +% like in tabular with one column. The final '\\' necessary! +% b) a comma-separated list: +% first,second,third,5,10,last +% ATTENTION: arrays do not support the '...' syntax of tikz! +% +% Example: +% \pgfplotsarraynew\fooarray{First Element\\Second Element\\Third Element\\} +% \pgfplotsarraynew\fooarray{First Element,Second Element,Third Element} +% \pgfplotsarraynew\fooarray{0,1,2,...,10} +% +% +\long\def\pgfplotsarraynew#1#2{% + \pgfplots@check@backwards@compatible@list@format #2\\\pgfplots@EOI + \ifpgfplots@is@old@list@format + \pgfplotsarraynew@backslash{#1}{#2}% + \else + \pgfplotsarraynew@commasep{#1}{#2}% + \fi +} + +% #1 the array's name (a macro name +% #2 a list created by \pgfplotslistnew +\def\pgfplotsarrayfrompgfplotslist#1#2{% + \pgfplotsarraynewempty#1% + \pgfplotslistforeachungrouped#2\as\pgfplotsarray@TMPa{% + \expandafter\pgfplotsarraypushback\expandafter{\pgfplotsarray@TMPa}\to#1% + }% +}% + +\def\pgfplotsarraynew@backslash#1#2{% + \pgfplotsarraynewempty{#1}% + \long\def\pgfplotsarraynew@impl@rest{#2}% + \pgfutil@loop + \ifx\pgfplotsarraynew@impl@rest\pgfutil@empty + \pgfplots@loop@CONTINUEfalse + \else + \pgfplots@loop@CONTINUEtrue + \fi + \ifpgfplots@loop@CONTINUE + \expandafter\pgfplotsarraynew@impl\pgfplotsarraynew@impl@rest\toarray#1\relax + \pgfutil@repeat +}% + +% converts a comma-separated list (PGF foreach) to my internal list +% structure. +\long\def\pgfplotsarraynew@commasep#1#2{% + \pgfplotsarraynewempty{#1}% + \pgfplotsutilforeachcommasep{#2}\as\pgfplotsarraynew@elem{% + \expandafter\pgfplotsarraypushback\expandafter{\pgfplotsarraynew@elem}\to#1% + }% +} +% helper macro for \pgfplotsarraynew +\long\def\pgfplotsarraynew@impl#1\\#2\toarray#3{% + \pgfplotsarraypushback#1\to#3\relax% + \def\pgfplotsarraynew@impl@rest{#2}% +} + + +\def\pgfplotsarray@@let#1=#2{% + \def\pgfplotsarray@TMP@@{\expandafter\let\csname\string#1\endcsname}% + \expandafter\pgfplotsarray@TMP@@\csname\string#2\endcsname +}% + +\def\pgfplotsarray@@#1#2{% + \expandafter#1\csname\string#2\endcsname +}% +\def\pgfplotsarray@@def#1{% + \expandafter\def\csname\string#1\endcsname +}% +\def\pgfplotsarray@@edef#1{% + \expandafter\edef\csname\string#1\endcsname +}% + +\def\pgfplotsarray@@getsizeto#1#2{% + \pgfplotsarraysize{#1}\to\c@pgfplotsarray@tmp + \edef#2{\the\c@pgfplotsarray@tmp}% +}% + +% Copies array #1 to array #2. +\def\pgfplotsarraycopy#1\to#2{% + \pgfplotsarray@@let{#2@size}={#1@size}% + \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% + \c@pgfplotsarray@tmp=0 + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP + \pgfplotsarray@@let{#2@\the\c@pgfplotsarray@tmp}={#1@\the\c@pgfplotsarray@tmp}% + \advance\c@pgfplotsarray@tmp by1 + \pgfutil@repeat +} + + + +% #1: the item to append +% #2: the array as macro name +% Example: +% \pgfplotsarraypushback Next last element\to\fooarray +\long\def\pgfplotsarraypushback#1\to#2{% + \pgfplotsarraysize{#2}\to\c@pgfplotsarray@tmp + \pgfplotsarray@@def{#2@\the\c@pgfplotsarray@tmp}{#1}% + \advance\c@pgfplotsarray@tmp by1 + \pgfplotsarray@@edef{#2@size}{\the\c@pgfplotsarray@tmp}% +} +\long\def\pgfplotsarraypushbackglobal#1\to#2{% + \pgfplotsarraysize{#2}\to\c@pgfplotsarray@tmp + \pgfplotsarray@@\gdef{#2@\the\c@pgfplotsarray@tmp}{#1}% + \advance\c@pgfplotsarray@tmp by1 + \pgfplotsarray@@\xdef{#2@size}{\the\c@pgfplotsarray@tmp}% +} + +\long\def\pgfplotsarraypushbackglobal#1\to#2{% + \pgfplotsarraysize{#2}\to\c@pgfplotsarray@tmp + \pgfplotsarray@@\gdef{#2@\the\c@pgfplotsarray@tmp}{#1}% + \advance\c@pgfplotsarray@tmp by1 + \pgfplotsarray@@\xdef{#2@size}{\the\c@pgfplotsarray@tmp}% +} + +% Counts the number of elements in array #1, storing it into the count +% register #2. +% Example: +% \pgfplotsarraysize\foo\to{\count0}% +% \the\count0 +\long\def\pgfplotsarraysize#1\to#2{% + #2=\csname\string#1@size\endcsname\relax +} +\long\def\pgfplotsarraysizetomacro#1\to#2{% + \expandafter\let\expandafter#2\csname\string#1@size\endcsname +} + +% expands to the size of array #1. +\def\pgfplotsarraysizeof#1{\csname\string#1@size\endcsname}% + + +% Returns the #1th element of array #2 into macro #3 +% Arguments: +% #1: a count 0,...,N-1 where N is the array size. +% You may specify a number of a count. +% #2: a array +% #3: a macro name +% Example: +% Element 0: +% \pgfplotsarrayselect0\of\foo\to\elem +% \elem +% Element \count1: +% \pgfplotsarrayselect\count1\of\foo\to\elem +\def\pgfplotsarrayselect#1\of#2\to#3{% + \c@pgfplotsarray@tmp=#1\relax + \expandafter\let\expandafter#3\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname% + \ifx#3\relax + \pgfplotsthrow{no such element}{#1}{No such element: \string\pgfplotsarrayselect\the\c@pgfplotsarray@tmp\string\of{\string#2}}\pgfeov% + \fi +} + +% Expands to the value at index #1 of array #2. +% #1: a number (not a register) +% #2: an array +\def\pgfplotsarrayvalueofelem#1\of#2{\csname\string#2@#1\endcsname}% + +% Sets element '#1' of array '#2' to '#3'. +\def\pgfplotsarrayset#1\of#2\to#3{% + \c@pgfplotsarray@tmp=#1\relax + \pgfutil@namedef{\string#2@\the\c@pgfplotsarray@tmp}{#3}% +} +\def\pgfplotsarraysetglobal#1\of#2\to#3{% + \c@pgfplotsarray@tmp=#1\relax + \expandafter\gdef\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname{#3}% +} +\long\def\pgfplotsarrayletentry#1\of#2=#3{% + \c@pgfplotsarray@tmp=#1\relax + \expandafter\let\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname=#3\relax +} +\long\def\pgfplotsarrayletentryglobal#1\of#2=#3{% + \c@pgfplotsarray@tmp=#1\relax + \expandafter\global\expandafter\let\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname=#3\relax +} + +% Defines \pgfplotsretval to be a text-representation of the array. +% It will contain \t to separate cells. +% +\def\pgfplotsarraytotext#1{% + \begingroup + \pgfplotsapplistXnewempty\pgfplotsretval@ + \pgfplotsarrayforeachungrouped#1\as\entry{% + \pgfmathfloatparsenumber\entry + \pgfmathfloattosci\pgfmathresult + \edef\entry{\pgfmathresult\noexpand\t}% + \expandafter\pgfplotsapplistXpushback\entry\to\pgfplotsretval@ + }% + \pgfplotsapplistXlet\pgfplotsretval=\pgfplotsretval@ + \pgfmath@smuggleone\pgfplotsretval + \endgroup +} + +% Sets the boolean \ifpgfplotsarrayempty depending on whether array #1 is empty +% or not. +% Example: +% +% \pgfplotsarraycheckempty\fooarray +% \ifpgfplotsarrayempty +% List fooarray is empty! +% \else +% List is not empty. +% \fi +\def\pgfplotsarraycheckempty#1{% + \ifnum\csname\string#1@size\endcsname=0 + \pgfplotsarrayemptytrue + \else + \pgfplotsarrayemptyfalse + \fi +} + + +% Iterates through each array element, names it #2 and calls code #3. +% Example: +% \pgfplotsarraynew\fooarray{Eins\\Zwei\\Drei\\}% +% \pgfplotsarrayforeach\fooarray\as\foo{Element \foo\par}% +% results in +% Element Eins +% Element Zwei +% Element Drei +% Each single element will be grouped with TeX groups. +% +% During the loop, \pgfplotsarrayforeachindex expands to the current index. +\long\def\pgfplotsarrayforeach#1\as#2#3{% + \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% + \c@pgfplotsarray@tmp=0\relax + \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% + \long\def\pgfplotsarray@TMPb{#3}% + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP\relax + \begingroup + \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% + \pgfplotsarray@TMPb + \endgroup + \advance\c@pgfplotsarray@tmp by1 + \pgfutil@repeat + \let\pgfplotsarrayforeachindex=\relax% +} + +% The same but without groups around #3. +\long\def\pgfplotsarrayforeachungrouped#1\as#2#3{% + \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% + \c@pgfplotsarray@tmp=0\relax + \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP\relax + \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% + \begingroup + \toks0={#3}% + \xdef\pgfplotsarray@glob@TMP{% + \the\toks0 % + % restore loop state: + \c@pgfplotsarray@tmp=\the\c@pgfplotsarray@tmp\space + \noexpand\def\noexpand\pgfplotsarray@TMP{\pgfplotsarray@TMP}% + }% + \endgroup + \pgfplotsarray@glob@TMP + \advance\c@pgfplotsarray@tmp by1 + \pgfutil@repeat + \let\pgfplotsarrayforeachindex=\relax% +} + +\long\def\pgfplotsarrayforeachreversed#1\as#2#3{% + \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% + \c@pgfplotsarray@tmp=\pgfplotsarray@TMP\relax + \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% + \long\def\pgfplotsarray@TMPb{#3}% + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp>0 % + \advance\c@pgfplotsarray@tmp by-1 + \begingroup + \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% + \pgfplotsarray@TMPb + \endgroup + \pgfutil@repeat + \let\pgfplotsarrayforeachindex=\relax% +} + +\long\def\pgfplotsarrayforeachreversedungrouped#1\as#2#3{% + \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% + \c@pgfplotsarray@tmp=\pgfplotsarray@TMP\relax + \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% + \long\def\pgfplotsarray@TMPb{#3}% + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp>0 % + \advance\c@pgfplotsarray@tmp by-1 + \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% + \pgfplotsarray@TMPb + \pgfutil@repeat + \let\pgfplotsarrayforeachindex=\relax% +} + +\pgfkeys{% + /pgfplots/array/unscope pre/.code={% + % That's more or less efficient (although some runtime factors + % could be saved). + \c@pgfplotsarraysort@i=0 + \c@pgfplotsarray@tmp=\pgfplotsarraysizeof{#1}\relax + \pgfutil@loop + \ifnum\c@pgfplotsarraysort@i<\c@pgfplotsarray@tmp + \pgfplotsarrayselect{\c@pgfplotsarraysort@i}\of{#1}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarraysort@i by1 + \pgfutil@repeat + },% + /pgfplots/array/unscope post/.code={% + % copy from global temp -> #1 + \c@pgfplotsarray@tmp=0 + \pgfplotsarraysizetomacro{#1}\to\pgfplots@loc@TMPb + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp<\pgfplots@loc@TMPb + \pgfplotsarrayselect{\c@pgfplotsarray@tmp}\of{pgfparraytmp}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentry\c@pgfplotsarray@tmp\of{#1}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarray@tmp by1 + \pgfutil@repeat + },% +}% + +% Sorts array '#1' using N log N time. +% +% The sort key is provided as argument in +% /pgfplots/iflessthan/.code args={#1#2#3#4}, see docs in +% pgfplotsutil.code.tex. +% +% Remarks: +% - the sorting algorithm is a sub-optimal mergesort currently - +% but it has runtime N log N. +% - As usual, it is very difficult to move the final result out of the +% current scope. The initial configuration allocates a *global* copy of #1 +% to carry results out of one TeX group. This means that memory will NEVER be freed. +% I don't see a general N log N alternative for doing so (short of discarding +% the scopes for local groups). +% BUT: +% you can redefine the code key pair +% |/pgfplots/array/unscope pre| +% and +% |/pgfplots/array/unscope post| +% to define your own routine which may benefit from special needs of +% your application. The |... pre| command is invoked JUST before the +% \endgroup and the |... post| JUST after the |\endgroup|. +% +% +% EXAMPLE: +%-------------------------------------------------- +% \pgfplotsarraynewempty\testarray +% \pgfplotsarraypushback503\to\testarray +% \pgfplotsarraypushback087\to\testarray +% \pgfplotsarraypushback512\to\testarray +% \pgfplotsarraypushback061\to\testarray +% \pgfplotsarraypushback908\to\testarray +% \pgfplotsarraypushback170\to\testarray +% \pgfplotsarraypushback897\to\testarray +% \pgfplotsarraypushback275\to\testarray +% \pgfplotsarraypushback653\to\testarray +% \pgfplotsarraypushback426\to\testarray +% \pgfplotsarraypushback154\to\testarray +% \pgfplotsarraypushback509\to\testarray +% \pgfplotsarraypushback612\to\testarray +% \pgfplotsarraypushback677\to\testarray +% \pgfplotsarraypushback765\to\testarray +% \pgfplotsarraypushback703\to\testarray +% +% Unsorted: +% +% [\pgfplotsarrayforeach\testarray\as\elem{\elem\space}] +% +% \pgfplotsarraysort\testarray +% +% sorted: +% +% [\pgfplotsarrayforeach\testarray\as\elem{\elem\space}] +% +%-------------------------------------------------- +% +% @see \pgfplotsutilsortthree +% @see \pgfplotsutilsortfour +\def\pgfplotsarraysort{% + \pgfutil@ifnextchar[{\pgfplotsarraysort@opt}{\pgfplotsarraysort@opt[]}% +}% +\def\pgfplotsarraysort@opt[#1]#2{% + % I admit, the implementation is more-or less copy-paste of an + % experiment I had done at university. It does its job, but it is + % certainly not optimal (that means: it is slow). + \begingroup + \pgfqkeys{/pgfplots/array}{#1}% + \pgfkeysifdefined{/pgfplots/array/iflessthan/.@cmd}{% + \pgfplots@warning{Warning: /pgfplots/array/iflessthan/.@cmd is deprecated. Please use /pgfplots/iflessthan/.@cmd instead.}% + \pgfkeysgetvalue{/pgfplots/array/iflessthan/.@cmd}\pgfplotsarraysort@iflt + }{% + \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotsarraysort@iflt + }% + \pgfplotsarraysize{#2}\to\c@pgfplotsarray@tmp + \pgfplotsarrayresizeglobal{pgfparraytmp}{\the\c@pgfplotsarray@tmp}% + \countdef\c@pgfplotsarraysort@m=0 + \countdef\c@pgfplotsarraysort@k=1 + \countdef\c@pgfplotsarraysort@i=2 + \countdef\c@pgfplotsarraysort@l=3 + \countdef\c@pgfplotsarraysort@j=4 + \countdef\c@pgfplotsarraysort@q=5 + \def\pgfplotsarray@mergesort@{\pgfplotsarray@mergesort{#2}}% + \def\pgfplotsarray@mergesort@recurse@{\pgfplotsarray@mergesort@recurse{#2}}% + \edef\pgfplotsarray@mergesort@@{{0}{\the\c@pgfplotsarray@tmp}}% + \expandafter\pgfplotsarray@mergesort@\pgfplotsarray@mergesort@@ + % + % copy the complete, sorted result outside of the current scope. + \pgfkeysvalueof{/pgfplots/array/unscope pre/.@cmd}#2\pgfeov + \endgroup + \pgfkeysvalueof{/pgfplots/array/unscope post/.@cmd}#2\pgfeov +}% + +% #1: array name, +% #2: start offset (as string number) +% #3: number of elems (as string number) +\def\pgfplotsarray@mergesort#1#2#3{% + \ifnum#3<2 + % ready! + \else + \c@pgfplotsarraysort@m=#3\relax + \divide\c@pgfplotsarraysort@m by2 + \c@pgfplotsarraysort@q=#3\relax + \advance\c@pgfplotsarraysort@q by-\c@pgfplotsarraysort@m + \c@pgfplotsarraysort@i=\c@pgfplotsarraysort@m + \advance\c@pgfplotsarraysort@i by#2\relax + \edef\pgfplotsarray@mergesort@@{% + {#2}{\the\c@pgfplotsarraysort@m}% start1, N_1 + {\the\c@pgfplotsarraysort@i}{\the\c@pgfplotsarraysort@q}% start2, N_2 + }% + \expandafter\pgfplotsarray@mergesort@recurse@\pgfplotsarray@mergesort@@ + % + % Merge: + % restore 'm': + \c@pgfplotsarraysort@m=#3\relax + \divide\c@pgfplotsarraysort@m by2 + \c@pgfplotsarraysort@q=#3 + \advance\c@pgfplotsarraysort@q by-\c@pgfplotsarraysort@m + \c@pgfplotsarraysort@k=0 + \c@pgfplotsarraysort@l=0 + \c@pgfplotsarraysort@i=0 + % + % direct comparisons for merge: + \pgfutil@loop + \pgfplots@loop@CONTINUEtrue + \ifnum\c@pgfplotsarraysort@k<\c@pgfplotsarraysort@m + \ifnum\c@pgfplotsarraysort@l<\c@pgfplotsarraysort@q + \else + \pgfplots@loop@CONTINUEfalse + \fi + \else + \pgfplots@loop@CONTINUEfalse + \fi + \ifpgfplots@loop@CONTINUE + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@m + \advance\c@pgfplotsarraysort@j by\c@pgfplotsarraysort@l + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplotsarray@x@mpl + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@k + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplotsarray@x@k + \begingroup + \pgfplotsarraysort@iflt + {\pgfplotsarray@x@mpl}% + {\pgfplotsarray@x@k}% + {% x[m+l] < x[k] + \aftergroup\pgfplots@loc@tmptrue + }% + {% x[k] <= x[m+l] + \aftergroup\pgfplots@loc@tmpfalse + }% + \pgfeov + \endgroup + \ifpgfplots@loc@tmp + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@mpl + \advance\c@pgfplotsarraysort@i by1 + \advance\c@pgfplotsarraysort@l by1 + \else + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@k + \advance\c@pgfplotsarraysort@i by1 + \advance\c@pgfplotsarraysort@k by1 + \fi + \pgfutil@repeat + % + % append: + \pgfutil@loop + \ifnum\c@pgfplotsarraysort@k<\c@pgfplotsarraysort@m + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@k + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarraysort@i by1 + \advance\c@pgfplotsarraysort@k by1 + \pgfutil@repeat + \pgfutil@loop + \ifnum\c@pgfplotsarraysort@l<\c@pgfplotsarraysort@q + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@m + \advance\c@pgfplotsarraysort@j by\c@pgfplotsarraysort@l + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarraysort@i by1 + \advance\c@pgfplotsarraysort@l by1 + \pgfutil@repeat + % + % copy back from temporary to '#1' + \c@pgfplotsarraysort@i=0 + \c@pgfplotsarraysort@k=#3 + \pgfutil@loop + \ifnum\c@pgfplotsarraysort@i<\c@pgfplotsarraysort@k + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@i + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@i}\of{pgfparraytmp}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentry\c@pgfplotsarraysort@j\of{#1}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarraysort@i by1 + \pgfutil@repeat +%\pgfplotsarraysort@DEBUGTEST{#1}{after mergesort(start=#2,n=#3):}% + \fi +}% +\long\def\pgfplotsarraysort@DEBUGTEST#1#2{% + \par#2\par + [\pgfplotsarrayforeach{#1}\as\elem{\elem\space}]\par% +} +% #1: array name +% #2: start1 +% #3: N1 +% #4: start2 +% #5: N2 +\def\pgfplotsarray@mergesort@recurse#1#2#3#4#5{% + \pgfplotsarray@mergesort{#1}{#2}{#3}% + \pgfplotsarray@mergesort{#1}{#4}{#5}% +} + + +% A simple, ungrouped insert sort algorithm for small arrays. +% +% for i := 1; i < N; ++i do +% begin +% value := A[i]; +% j := i - 1; +% done := false; +% repeat +% if A[j] > value then +% begin +% A[j + 1] := A[j]; +% j := j - 1; +% if j < 0 then +% done := true; +% end +% else +% done := true; +% until done; +% A[j + 1] := value; +% end; +\def\pgfplotsarrayinsertionsort#1{% + \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotsarraysort@iflt + \pgfplotsarraysizetomacro#1\to\pgfplotsarrayinsertionsort@N + \c@pgf@countd=1 + \pgfplotsarrayinsertionsort@{#1}% +}% +\def\pgfplotsarrayinsertionsort@#1{% + \ifnum\c@pgf@countd<\pgfplotsarrayinsertionsort@N\relax + \pgfplotsarrayselect\c@pgf@countd\of#1\to\pgfplotsarrayinsertionsort@v + % + \c@pgf@countb=\c@pgf@countd + \advance\c@pgf@countb by-1 + % + \pgfplotsarrayinsertionsort@@{#1}% + \advance\c@pgf@countb by1 + \pgfplotsarrayletentry\c@pgf@countb\of#1=\pgfplotsarrayinsertionsort@v + % + \advance\c@pgf@countd by1 + \expandafter\pgfplotsarrayinsertionsort@\expandafter#1% + \fi +} +\def\pgfplotsarrayinsertionsort@@#1{% + \pgfplotsarrayselect\c@pgf@countb\of#1\to\pgfplotsarrayinsertionsort@j + \pgfplotsarraysort@iflt{\pgfplotsarrayinsertionsort@v}{\pgfplotsarrayinsertionsort@j} + {% + \advance\c@pgf@countb by1 + \pgfplotsarrayletentry\c@pgf@countb\of#1=\pgfplotsarrayinsertionsort@j + \advance\c@pgf@countb by-2 + \ifnum\c@pgf@countb<0 + \let\pgfplotsarrayinsertionsort@@next\relax% + \else + \def\pgfplotsarrayinsertionsort@@next{\pgfplotsarrayinsertionsort@@#1}% + \fi + }{% + \let\pgfplotsarrayinsertionsort@@next\relax% + }\pgfeov% + \pgfplotsarrayinsertionsort@@next +}% + diff --git a/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsdeque.code.tex b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsdeque.code.tex new file mode 100644 index 0000000..7a524f1 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsdeque.code.tex @@ -0,0 +1,125 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This is a helper package with an elementary double-ended-queue +% (deque) datastructure, +% featuring O(1) index access and O(N) creation, deletion, copy. +% +% The following macros are supplied: +% +% \pgfplotsdequenewempty +% \pgfplotsdequecopy +% \pgfplotsdequepushback +% \pgfplotsdequepopfront +% \pgfplotsdequecheckempty +% \pgfplotsdequeforeach +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% IMPLEMENTATION NOTES: +% I allocate an array which provides storage capacity and two pointers +% (indices) into that array. +% +% The deque is stored as +% - an array: \csname pgfpldq@\endcsname +% - the pointers: +% \csname pgfpldq@@beg\endcsname +% \csname pgfpldq@@end\endcsname (one after the end) +% +% ATTENTION: may NOT be a control sequence! +% this is in contrast to my other container structures. + + +% Allocates a new, empty deque #1. +% +% #1 the name of a deque (NO control sequence!) +% #2 is an integer denoting the maximum capacity. For now, this +% capacity is fixed afterwards and denotes the maximum number of +% entries. +\def\pgfplotsdequenewempty#1{% + \pgfutil@ifnextchar\capacity{% + \pgfplotsdequenewempty@{#1}% + }{% + \pgfplots@error{Expected \string\capacity\{the capacity\} after \string\pgfplotsdequenewempty...}% + \pgfplotsdequenewempty@{#1}\capacity{100}% + }% +}% +\def\pgfplotsdequenewempty@#1\capacity#2{% + \pgfplotsarrayresize{pgfpldq@#1}{#2}% + \pgfutil@namedef{pgfpldq@#1@beg}{0}% + \pgfutil@namedef{pgfpldq@#1@end}{0}% +}% + +\def\pgfplotsdequecopy#1\to#2{% + \pgfutil@namelet{pgfpldq@#1@beg}{pgfpldq@#2@beg}% + \pgfutil@namelet{pgfpldq@#1@end}{pgfpldq@#2@end}% + \pgfplotsarraycopy{pgfpldq@#1}\to{pgfpldq@#2}% +}% + +\def\pgfplotsdequepushback#1\to#2{% + \pgfplotsarrayset{\csname pgfpldq@#2@end\endcsname}\of{pgfpldq@#2}\to{#1}% + \c@pgfplotsarray@tmp=\csname pgfpldq@#2@end\endcsname + \advance\c@pgfplotsarray@tmp by1 + \ifnum\c@pgfplotsarray@tmp=\pgfplotsarraysizeof{pgfpldq@#2} + \c@pgfplotsarray@tmp=0 + \fi + \expandafter\edef\csname pgfpldq@#2@end\endcsname{\the\c@pgfplotsarray@tmp}% + \pgfplotsdequeifempty{#2}{\pgfplots@error{Error: \string\pgfplotsdeque\space capacity has been reached - it was too small. Sorry, I didn't write auto-enlargement...}}{}% +}% + +\def\pgfplotsdequepopfront#1\to#2{% + \pgfplotsarrayselect{\csname pgfpldq@#1@beg\endcsname}\of{pgfpldq@#1}\to{#2}% + \c@pgfplotsarray@tmp=\csname pgfpldq@#1@beg\endcsname + \advance\c@pgfplotsarray@tmp by1 + \ifnum\c@pgfplotsarray@tmp=\pgfplotsarraysizeof{pgfpldq@#1} + \c@pgfplotsarray@tmp=0 + \fi + \expandafter\edef\csname pgfpldq@#1@beg\endcsname{\the\c@pgfplotsarray@tmp}% +}% + +% invokes #2 if deque '#1' is empty and '#3' if it is not empty. +\def\pgfplotsdequeifempty#1#2#3{% + \ifnum\csname pgfpldq@#1@beg\endcsname=\csname pgfpldq@#1@end\endcsname\relax + #2% + \else + #3% + \fi +}% + + +\long\def\pgfplotsdequeforeach#1\as#2#3{% + \c@pgfplotsarray@tmp=\csname pgfpldq@#1@beg\endcsname + \long\def\pgfplotsdequeforeach@next{\pgfplotsdequeforeach@iter{#1}{#2}{#3}}% + \pgfplotsdequeforeach@next +}% +\long\def\pgfplotsdequeforeach@iter#1#2#3{% + \ifnum\c@pgfplotsarray@tmp=\csname pgfpldq@#1@end\endcsname + \def\pgfplotsdequeforeach@next{}% + \else + \pgfplotsarrayselect\c@pgfplotsarray@tmp\of pgfpldq@#1\to#2% + \edef\pgfplotsdequeforeach@{\the\c@pgfplotsarray@tmp}% + #3\relax + \c@pgfplotsarray@tmp=\pgfplotsdequeforeach@ + \advance\c@pgfplotsarray@tmp by1 + \ifnum\c@pgfplotsarray@tmp=\pgfplotsarraysizeof{pgfpldq@#1} + \c@pgfplotsarray@tmp=0 + \fi + \fi + \pgfplotsdequeforeach@next +}% diff --git a/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex new file mode 100644 index 0000000..3b96426 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex @@ -0,0 +1,435 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This is a helper package with an elementary list datastructure. +% +% Its implementation is based on Knuth's list macros in "The TeXbook". +% +% It features a convenient set of list macros, but it is not fast. +% In fact, every elementary operation requires time O(N), so working +% with this list easily leads to O(N^2) runtime. +% +% The following macros are supplied: +% +% \pgfplotslistnewempty +% \pgfplotslistnew +% \pgfplotslistcopy +% \pgfplotslistpopfront +% \pgfplotslistfront +% \pgfplotslistpushback +% \pgfplotslistpushfront +% \pgfplotslistsize +% \pgfplotslistselect +% \pgfplotslistset +% \pgfplotslistcheckempty +% \pgfplotslistforeach +% +% @see \pgfplotsapplist a "real" list with O(1) pushback, but limited application. +% @see \pgfplotsapplistX a preasymptotical fast list to accumulate elements. +% @see \pgfplotsapplistXX an optimized version of \pgfplotsapplistX. +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newif\ifpgfplotslistempty + +% Low-level IMPLEMENTATION NOTE +% the list is stored in the form +% '\pgfpl@@{}\pgfpl@@{}\pgfpl@@{}....\pgfpl@@{}' + +\newif\ifpgfplots@loop@CONTINUE +\newif\ifpgfplotslist@is@backslash@terminated + +% Creates a new, empty list. +\long\def\pgfplotslistnewempty#1{\let#1=\pgfutil@empty} + +% Creates a new list with an abirtrary number of elements. +% Arguments: +% #1: the list's name (a macro name) +% #2: the elements in the form +% first\\second\\third\\ ...\\ +% like in tabular with one column. +% You can also use comma-separated lists +% first,second,third +% +% Example: +% 1. +% \pgfplotslistnew\foolist{First Element\\Second Element\\Third Element\\} +% WARNING: do NOT forget the final '\\'! +% +% 2. +% \pgfplotslistnew\foolist{First Element,Second Element,Third Element} +% +% Use braces '{}' to use '\\' or ',' as arguments. +% +\long\def\pgfplotslistnew#1#2{% + \pgfplotslist@check@backslash@list #2\\\pgfplotslist@EOI + \ifpgfplotslist@is@backslash@terminated + \pgfplotslistnew@backslash@{#1}{#2}% + \else + \pgfplots@foreach@to@list{#2}\to#1% + \fi +} +% Is this here *ever* used!? I guess not. +\long\def\pgfplotslistnew@backslash#1#2{% + \pgfplotslistnewempty{#1}% + \pgfplotslist@check@backslash@list #2\\\pgfplotslist@EOI + \ifpgfplotslist@is@backslash@terminated + \long\def\pgfplotslistnew@impl@rest{#2\pgfplotslist@EOI\\}% + \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl{#1}}% + \else + \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl@comma{#1}}% + \long\def\pgfplotslistnew@impl@rest{#2\pgfplotslist@EOI,}% + \fi + \expandafter\pgfplotslistnew@backslash@loop\pgfplotslistnew@impl@rest +}% +\long\def\pgfplotslistnew@backslash@#1#2{% + \pgfplotslistnewempty{#1}% + \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl{#1}}% + \pgfplotslistnew@backslash@loop#2\pgfplotslist@EOI\\% +}% + +% helper macro for \pgfplotslistnew +\long\def\pgfplotslistnew@impl#1#2\\{% + \def\pgfplotslist@loc@TMPa{#2}% + \ifx\pgfplotslist@loc@TMPa\pgfplotslist@EOI + \else + \pgfplotslistpushback{#2}\to#1\relax% + \expandafter\pgfplotslistnew@backslash@loop + \fi +} +\long\def\pgfplotslistnew@impl@comma#1#2,{% + \def\pgfplotslist@loc@TMPa{#2}% + \ifx\pgfplotslist@loc@TMPa\pgfplotslist@EOI + \else + \pgfplotslistpushback{#2}\to#1\relax% + \expandafter\pgfplotslistnew@backslash@loop + \fi +} +\def\pgfplotslist@EOI{\pgfplotslist@EOI} +\def\pgfplotslist@backslashsep{\\} + +\long\def\pgfplotslist@check@backslash@list#1\\#2\pgfplotslist@EOI{% + \def\pgfplotslist@loc@TMPx{#2}% + \ifx\pgfplotslist@loc@TMPx\pgfutil@empty + \pgfplotslist@is@backslash@terminatedfalse + \let\pgfplotslist@check@backslash@list@next=\relax + \else + \def\pgfplotslist@loc@TMPy{ }% + \ifx\pgfplotslist@loc@TMPx\pgfplotslist@loc@TMPy + \pgfplotslist@is@backslash@terminatedfalse + \let\pgfplotslist@check@backslash@list@next=\relax + \else + \ifx\pgfplotslist@loc@TMPx\pgfplotslist@backslashsep + % ok. The list is something like 'a\\b\\' so the + % complete input is + % 'a\\b\\ \\ \EOI' + % we have iterated long enough to find only the '\\' + % right before the \EOI. It is thus backslash + % terminated. + \pgfplotslist@is@backslash@terminatedtrue + \let\pgfplotslist@check@backslash@list@next=\relax + \else + % Iterate. We want to check the last list element. + \long\def\pgfplotslist@check@backslash@list@next{\pgfplotslist@check@backslash@list#2\pgfplotslist@EOI}% + \fi + \fi + \fi + \pgfplotslist@check@backslash@list@next +}% + +% Copies list #1 to list #2. +\def\pgfplotslistcopy#1\to#2{\let#2=#1} + + + + +% #1: the item to prepend +% #2: the list as macro name +% Example: +% \pgfplotslistpushfront Next first Element\to\foolist +\long\def\pgfplotslistpushfront#1\to#2{% + \t@pgfplots@toka={\pgfpl@@{#1}}% + \t@pgfplots@tokb=\expandafter{#2}% + \edef#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% +} +\long\def\pgfplotslistpushfrontglobal#1\to#2{% + \t@pgfplots@toka={\pgfpl@@{#1}}% + \t@pgfplots@tokb=\expandafter{#2}% + \xdef#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% +} + +% Assembles a low-level list item representation into the token +% register #2. +\long\def\pgfplotslist@assembleentry#1\into#2{% + #2={\pgfpl@@{#1}}% +} + +% #1: the item to append +% #2: the list as macro name +% Example: +% \pgfplotslistpushback Next last element\to\foolist +\long\def\pgfplotslistpushback#1\to#2{% + \t@pgfplots@toka={\pgfpl@@{#1}}% + \ifx#2\pgfutil@empty + \t@pgfplots@tokb={}% + \else + \t@pgfplots@tokb=\expandafter{#2}% + \fi + \edef#2{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% +} +% Adds '#1' to the GLOBAL list '#2'. +\long\def\pgfplotslistpushbackglobal#1\to#2{% + \t@pgfplots@toka={\pgfpl@@{#1}}% + \ifx#2\pgfutil@empty + \t@pgfplots@tokb={}% + \else + \t@pgfplots@tokb=\expandafter{#2}% + \fi + \xdef#2{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% +} + +% Concatenates two lists #2 and #3 into #1 +% Example: +% \pgfplotslistconcat\result=\foolist&\bar +\long\def\pgfplotslistconcat#1=#2{% + \t@pgfplots@toka=\expandafter{#2}% + \t@pgfplots@tokb=\expandafter{#3}% + \edef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% +} + +% implements #2 := pop_front(#1) +% Example: +% \pgfplotslistpopfront\foolist\to\poppedfirstelem +\long\def\pgfplotslistpopfront#1\to#2{% + \pgfplotslistcheckempty#1\relax + \ifpgfplotslistempty + \pgfplotsthrow{no such element}{#1}{\string\pgfplotslistpopfront\ from \string#1\ although list is EMPTY}\pgfeov% + \else + \expandafter\pgfplotslistpopfront@impl#1\pgfplotslistpopfront@macronames#1#2% + \fi +} +\long\def\pgfplotslistfront#1\to#2{% + \pgfplotslistcheckempty#1\relax + \ifpgfplotslistempty + \pgfplotsthrow{no such element}{#2}{\string\pgfplotslistfront\ from \string#1\ although list is EMPTY}\pgfeov% + \else + \expandafter\pgfplotslistfront@impl#1\pgfplotslistpopfront@macronames#2% + \fi +} + +% implementation helper for listpopfront +\long\def\pgfplotslistpopfront@impl\pgfpl@@#1#2\pgfplotslistpopfront@macronames#3#4{% + \def#4{#1}% + \def#3{#2}% +} +\long\def\pgfplotslistfront@impl\pgfpl@@#1#2\pgfplotslistpopfront@macronames#3{% + \def#3{#1}% +} + +% Counts the number of elements in list #1, storing it into the count +% register #2. +% Example: +% \pgfplotslistsize\foo\to{\count0}% +% \the\count0 +\long\def\pgfplotslistsize#1\to#2{% + #2=0% + \long\def\pgfpl@@##1{\advance#2 by 1 }% + #1% +} + +% Returns the #1th element of list #2 into macro #3 +% Arguments: +% #1: a count 0,...,N-1 where N is the list size. +% You may specify a number of a count. +% #2: a list +% #3: a macro name +% Example: +% Element 0: +% \pgfplotslistselect0\of\foo\to\elem +% \elem +% Element \count1: +% \pgfplotslistselect\count1\of\foo\to\elem +\long\def\pgfplotslistselect#1\of#2\to#3{% + \global\def\pgfplotslistselect@tmp{\pgfplotsthrow{no such element}{#3}{The requested list entry with index #1 of \string#2 is too large; this list has not enough elements.}\pgfeov}% + \pgfplotslistselect@{#1}\of{#2}\to{#3}% +} +\long\def\pgfplotslistselect@#1\of#2\to#3{% + \begingroup + \count0=#1\relax + \long\def\pgfpl@@##1{% + \advance\count0 by-1\relax + \ifnum\count0=-1\relax + \global\def\pgfplotslistselect@tmp{\def#3{##1}}% + \fi% + }% + #2% + \endgroup + \pgfplotslistselect@tmp +} + +% Selects a list entry. If it does not exist, '#' will be empty. +\long\def\pgfplotslistselectorempty#1\of#2\to#3{% + \global\def\pgfplotslistselect@tmp{\def#3{}}% + \pgfplotslistselect@{#1}\of{#2}\to{#3}% +} + +% Changes the element at index '#1' of list '#2' to the content '#3'. +% +% This operation has quadratic (!) time in the worst case. +\long\def\pgfplotslistset#1\of#2\to#3{% + \ifcase#1\relax + % change first: + \def\pgfplotslistset@\pgfpl@@##1##2\relax{\def#2{\pgfpl@@{#3}##2}}% + \expandafter\pgfplotslistset@#2\relax + \or + % change second: + \def\pgfplotslistset@\pgfpl@@##1\pgfpl@@##2##3\relax{\def#2{\pgfpl@@{##1}\pgfpl@@{#3}##2}}% + \expandafter\pgfplotslistset@#2\relax + \or + \def\pgfplotslistset@\pgfpl@@##1\pgfpl@@##2\pgfpl@@##3##4\relax{\def#2{\pgfpl@@{##1}\pgfpl@@{##2}\pgfpl@@{#3}##3}}% + \expandafter\pgfplotslistset@#2\relax + \or + \def\pgfplotslistset@\pgfpl@@##1\pgfpl@@##2\pgfpl@@##3\pgfpl@@##4##5\relax{\def#2{\pgfpl@@{##1}\pgfpl@@{##2}\pgfpl@@{##3}\pgfpl@@{#3}##4}}% + \expandafter\pgfplotslistset@#2\relax + \else + \begingroup + \global\pgfplotslistnewempty\pgfplotslistnewempty\pgfplotslist@glob@TMPa + \let\pgfpl@@=\pgfutil@empty % make sure it is not \relax. + \count0=#1\relax + \count1=0 + \def\pgfplotslistset@newelem{#3}% + \expandafter\pgfplotslistset@loop#2\relax + \ifnum\count1 =\count0 + \else + \pgfplotsthrow{no such element}{\pgfplots@loc@TMPa}{\string\pgfplotslistset{\the\count0} failed because there are only \the\count1\space elements in the list. Use pushback to resize it.}\pgfeov% + \global\let\pgfplotslist@glob@TMPa=\pgfplots@loc@TMPa + \fi + \endgroup + \let#3=\pgfplotslist@glob@TMPa + \global\let\pgfplotslist@glob@TMPa=\relax + \fi +}% + +\def\pgfplotslistset@loop{% + \pgfutil@ifnextchar\relax{% + \pgfplotslistset@loop@break + }{% + \pgfplotslistset@loop@next + }% +} +\def\pgfplotslistset@loop@break#1\relax{% + % re-append remaining elements: + \expandafter\gdef\expandafter\pgfplotslist@glob@TMPa\expandafter{\pgfplotslist@glob@TMPa#1} +}% +\def\pgfplotslistset@loop@next\pgfpl@@#1{% + \ifnum\count1 =\count0 + % Ah - we found the element to replace! + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotslistset@newelem}\to\pgfplotslist@glob@TMPa + \expandafter\pgfplotslistset@loop@break + \else + \pgfplotslistpushbackglobal{#1}\to\pgfplotslist@glob@TMPa + \advance\count1 by1 + \expandafter\pgfplotslistset@loop + \fi +}% + +% Sets the boolean \ifpgfplotslistempty depending on whether list #1 is empty +% or not. +% Example: +% +% \pgfplotslistcheckempty\foolist +% \ifpgfplotslistempty +% List foolist is empty! +% \else +% List is not empty. +% \fi +\def\pgfplotslistcheckempty#1{% + \ifx#1\pgfutil@empty + \pgfplotslistemptytrue + \else + \ifx#1\relax + \pgfplots@warning{WARNING: possible logic error in script code: the command \string\pgfplotslistcheckempty{\string#1} encountered an undefined argument.}% + \pgfplotslistemptytrue + \else + \pgfplotslistemptyfalse + \fi + \fi +} + + +% Iterates through each list element, names it #2 and calls code #3. +% Example: +% \pgfplotslistnew\foolist{Eins\\Zwei\\Drei\\}% +% \pgfplotslistforeach\foolist\as\foo{Element \foo\par}% +% results in +% Element Eins +% Element Zwei +% Element Drei +% Each single element will be grouped with TeX groups. +\long\def\pgfplotslistforeach#1\as#2#3{% + \begingroup + \long\def\pgfpl@@##1{% + \t@pgfplots@tokc={##1}% this allows '#' inside of '##1' + \edef#2{\the\t@pgfplots@tokc}% + \begingroup #3\endgroup}% + #1\relax + \endgroup +} + +% The same but without groups around #3. +% +% The list can be nested. +\long\def\pgfplotslistforeachungrouped#1\as#2#3{% + \t@pgfplots@tokb={{#2}{#3}}% + \t@pgfplots@tokc=\expandafter{#1}% + \edef\pgfplotslist@loc@TMPa{% + \noexpand\pgfplotslistforeachungrouped@ + \the\t@pgfplots@tokb% + \the\t@pgfplots@tokc + \noexpand\pgfpl@@\noexpand\pgfplotslistforeachungrouped@EOI + }% + \pgfplotslist@loc@TMPa +}% + +% Technical helper method which performs the loop. +% ASSUMPTION: +% \pgfplotslistforeachungrouped@ +% {} +% {} +% \pgfpl@@{}\pgfpl@@{}\pgfpl@@{}\pgfpl@@\pgfplotslistforeachungrouped@EOI +% +% -> iterate through argument until \pgfplotslistforeachungrouped@EOI +% comes. +\long\def\pgfplotslistforeachungrouped@#1#2\pgfpl@@#3{% + \t@pgfplots@tokc={#3}% this allows '#' inside of '#3' + \edef\pgfplotslist@loc@TMPa{\the\t@pgfplots@tokc}% + \ifx\pgfplotslist@loc@TMPa\pgfplotslistforeachungrouped@EOI + % ok, terminate loop. + \let\pgfplotslistforeachungrouped@next=\relax + \else + % perform loop iteration ... + \let#1=\pgfplotslist@loc@TMPa + #2\relax + % and continue iterating. + \def\pgfplotslistforeachungrouped@next{\pgfplotslistforeachungrouped@{#1}{#2}}% + \fi + \pgfplotslistforeachungrouped@next +}% +\def\pgfplotslistforeachungrouped@EOI{\pgfplotslistforeachungrouped@EOI}% equals only itself in \ifx + diff --git a/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex new file mode 100644 index 0000000..fa90ea6 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex @@ -0,0 +1,615 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This is a helper package with an elementary list datastructure. +% In contrast to \pgfplotslist, this one features fast append and fast +% copy-to-macro. +% +% The 'pgfplotsapplist' is a list which has ONLY the features +% +% \pgfplotsapplistnewempty +% \pgfplotsapplistpushback O(1) +% \pgfplotsapplistedefcontenttomacro (N) +% \pgfplotsapplistxdefcontenttomacro (N) +% +% It has been designed to accumulate macro content in O(N) (in +% contrast to TeX's macro append routines which lead to O(N^2) +% runtime). +% +% Furthermore, there is the +% +% \pgfplotsapplistXnewempty +% \pgfplotsapplistXpushback +% \pgfplotsapplistXedefcontenttomacro (N) +% \pgfplotsapplistXxdefcontenttomacro (N) +% \pgfplotsapplistXlet (N) +% +% structure which features **preasymptotical** constant runtime for +% pushback. That means, as long as N < 80000, the runtime is linear. +% It is only slightly slower than \pgfplotsapplist, and that only due +% to its generality. It could easily be adopted to be FASTER than +% \pgfplotsapplist. +% +% Credits for \pgfplotsapplist go to Till Tantau: he developped it for +% the PGF kernel. +% +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% the applist defines one macro for each element, like +% +% \def\element{\element} +% \def\element{\element} +% \def\element{} +% +% The '' value belongs to the private interface and is part of the +% macro name. +% +% It features: +% - real O(1) pushback +% - O(N) edef to macro +% - O(N) execute +% - it requires O(N) different macros. +% - it ***can't*** be copied outside of the current TeX group! +% +% I have never used it (besides early tests) +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Time: O(1), number of macros: 3 +\def\pgfplotsapplistnewempty#1{% + \expandafter\def\csname\string#1@endno\endcsname{0}% + \edef#1{\expandafter\noexpand\csname\string#1@0\endcsname}% + \expandafter\def\csname\string#1@0\endcsname{}% +}% + +% Time: O(1), number of macros per list: about N +% #1: the item to append +% #2: the list as macro name +\long\def\pgfplotsapplistpushback#1\to#2{% + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname\string#2@endno\endcsname + \begingroup + \c@pgf@counta=\pgfplots@loc@TMPa\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname\string#2@endno\endcsname=\pgfplots@glob@TMPa% + \t@pgfplots@toka={#1}% + \t@pgfplots@tokb=\expandafter{\csname\string#2@\pgfplots@glob@TMPa\endcsname}% + \expandafter\edef\csname\string#2@\pgfplots@loc@TMPa\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \expandafter\let\the\t@pgfplots@tokb=\pgfutil@empty +}% + +% time O(N) +% Expands the complete content of list #1 as-is into the macro #2. +\def\pgfplotsapplistedefcontenttomacro#1\to#2{\edef#2{#1}} +\def\pgfplotsapplistxdefcontenttomacro#1\to#2{\xdef#2{#1}} + +% Foreach list element, the stored value will simply be processed by +% TeX. Characters will be printed and commands will be executed. +% time O(N) +\def\pgfplotsapplistexecute#1{#1}% + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% +% This list here is a general re-implementation of the list used in +% the PGF system layer. +% It employs two collect-buffers to reduce the runtime. +% +% - It has preasymptotical runtime O(N), but is O(N^2) asymptotically. +% - It requires only 5 macros per list. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Usage: +% \pgfplotsapplistXnewempty\macro +% \pgfplotsapplistXnewempty[to global]\macro +% +% The 'to global' flag will configure the list such that all +% assignments to \macro are global. The list accumulation is +% LOCAL, however: 'to global' is to be used inside of a local +% group such that the final result, when all buffers are flushed, +% is assigned globally. +% +% ATTENTION: maybe that [to global] thing is useless. +% Consider using the \pgfplotsapplistXglobal list (see below) +\def\pgfplotsapplistXnewempty{% + \pgfutil@ifnextchar[{% + \pgfplotsapplistXnewempty@opt + }{% + \pgfplotsapplistXnewempty@opt[]% + }% +} + +\def\pgfplotsapplistXnewempty@opt@TOGLOBAL{to global} + +\def\pgfplotsapplistXnewempty@opt[#1]#2{% + \def\pgfplots@loc@TMPa{#1}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \expandafter\let\csname\string#2@let\endcsname=\let% + \expandafter\let\csname\string#2@edef\endcsname=\edef + \else + \ifx\pgfplots@loc@TMPa\pgfplotsapplistXnewempty@opt@TOGLOBAL + \expandafter\def\csname\string#2@let\endcsname{\global\let}% + \expandafter\let\csname\string#2@edef\endcsname=\xdef + \else + \pgfplots@error{Sorry, the argument '#1' to \string\pgfplotsapplistXnewempty\ is unknown. Accepted is 'to global' or empty.}% + \fi + \fi + \pgfplotsapplistXnewempty@{#2}% +}% + +\def\pgfplotsapplistXnewempty@#1{% + \csname\string#1@let\endcsname#1=\pgfutil@empty + \expandafter\let\csname\string#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\let\csname\string#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#1@smallbuf@c\endcsname{0}% + \expandafter\def\csname\string#1@bigbuf@c\endcsname{0}% +}% + +% #1: the item to append +% #2: the list as macro name +\long\def\pgfplotsapplistXpushback#1\to#2{% + \begingroup + \c@pgf@counta=\csname\string#2@smallbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname\string#2@smallbuf@c\endcsname=\pgfplots@glob@TMPa + \ifnum\csname\string#2@smallbuf@c\endcsname<40 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \expandafter\edef\csname\string#2@smallbuf\endcsname{\the\t@pgfplots@toka}% + \else + \pgfplotsapplistXpushback@smallbufoverfl{#1}{#2}% + \fi +}% +\long\def\pgfplotsapplistXpushback@smallbufoverfl#1#2{% + \begingroup + \c@pgf@counta=\csname\string#2@bigbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname\string#2@bigbuf@c\endcsname=\pgfplots@glob@TMPa + % + \ifnum\csname\string#2@bigbuf@c\endcsname<30 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \expandafter\edef\csname\string#2@bigbuf\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \expandafter\let\csname\string#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#2@smallbuf@c\endcsname{0}% + \else% + \t@pgfplots@toka=\expandafter{#2}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \csname\string#2@edef\endcsname#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\let\csname\string#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#2@smallbuf@c\endcsname{0}% + \expandafter\let\csname\string#2@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#2@bigbuf@c\endcsname{0}% + \fi% +}% +\def\pgfplotsapplistXflushbuffers#1{% + \t@pgfplots@toka=\expandafter{#1}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#1@bigbuf\endcsname}% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#1@smallbuf\endcsname}% + \csname\string#1@edef\endcsname#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\let\csname\string#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#1@smallbuf@c\endcsname{0}% + \expandafter\let\csname\string#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#1@bigbuf@c\endcsname{0}% +}% + + +% Expands the complete content of list #1 as-is into the macro #2. +\def\pgfplotsapplistXedefcontenttomacro#1\to#2{% + \pgfplotsapplistXflushbuffers#1% + \edef#2{#1}} +\def\pgfplotsapplistXxdefcontenttomacro#1\to#2{% + \pgfplotsapplistXflushbuffers#1% + \xdef#2{#1}} +\def\pgfplotsapplistXlet#1=#2{% + \pgfplotsapplistXflushbuffers#2% + \let#1=#2} + +% Foreach list element, the stored value will simply be processed by +% TeX. Characters will be printed and commands will be executed. +\def\pgfplotsapplistXexecute#1{% + \pgfplotsapplistXflushbuffers#1% + #1}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% A variant of applist which has the same runtime requirements, but +% does PUSH FRONT only. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Usage: +% \pgfplotsprependlistXnewempty{liste} +\def\pgfplotsprependlistXnewempty#1{% + \expandafter\let\csname pgfpPRP@#1\endcsname=\pgfutil@empty + \expandafter\let\csname pgfpPRP@#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\let\csname pgfpPRP@#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@smallbuf@c\endcsname{0}% + \expandafter\def\csname pgfpPRP@#1@bigbuf@c\endcsname{0}% +}% + +% #1: the item to append +% #2: the list as macro name +\long\def\pgfplotsprependlistXpushfront#1\to#2{% + \begingroup + \c@pgf@counta=\csname pgfpPRP@#2@smallbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname pgfpPRP@#2@smallbuf@c\endcsname=\pgfplots@glob@TMPa + \ifnum\csname pgfpPRP@#2@smallbuf@c\endcsname<40 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}% + \t@pgfplots@tokb={#1}% + \expandafter\edef\csname pgfpPRP@#2@smallbuf\endcsname{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \else + \pgfplotsprependlistXpushfront@smallbufoverfl{#1}{#2}% + \fi +}% +\long\def\pgfplotsprependlistXpushfront@smallbufoverfl#1#2{% + \begingroup + \c@pgf@counta=\csname pgfpPRP@#2@bigbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname pgfpPRP@#2@bigbuf@c\endcsname=\pgfplots@glob@TMPa + % + \ifnum\csname pgfpPRP@#2@bigbuf@c\endcsname<30 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@bigbuf\endcsname}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}% + \t@pgfplots@tokc={#1}% + \expandafter\edef\csname pgfpPRP@#2@bigbuf\endcsname{\the\t@pgfplots@tokc\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \expandafter\let\csname pgfpPRP@#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#2@smallbuf@c\endcsname{0}% + \else% + \pgfplotsprependlistXflushbuffers{#2}% + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2\endcsname}% + \t@pgfplots@tokb={#1}% + \expandafter\edef\csname pgfpPRP@#2\endcsname{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \fi% +}% +\def\pgfplotsprependlistXflushbuffers#1{% + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1\endcsname}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@bigbuf\endcsname}% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@smallbuf\endcsname}% + \expandafter\edef\csname pgfpPRP@#1\endcsname{\the\t@pgfplots@tokc\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \expandafter\let\csname pgfpPRP@#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@smallbuf@c\endcsname{0}% + \expandafter\let\csname pgfpPRP@#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@bigbuf@c\endcsname{0}% +}% + +\def\pgfplotsprependlistXlet#1=#2{% + \pgfplotsprependlistXflushbuffers{#2}% + \expandafter\let\expandafter#1\csname pgfpPRP@#2\endcsname} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% +% This list \pgfplotsapplistXX here is essentially the SAME as \pgfplotslistX. +% +% But there can only be one such list at a time, so it is faster than +% \pgfplotslistX. +% +% This here is probably the fastest list. +% +% It is nothing else but a copy of Till Tantau's pgf kernel list. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 + + + +% WARNING: call \pgfplotsapplistclear if there is another list active. +\def\pgfplotsapplistXXnewempty{% + \pgfutil@ifundefined{pgfplotsapplistXX}{}{% + \ifx\pgfplotsapplistXX\pgfutil@empty + \else + \pgfplots@error{\string\pgfplotsapplistXXnewempty: there is already another list which is *not* empty. It currently contains '\meaning\pgfplotsapplistXX'. Please call '\string\pgfplotsapplistXXclear' before using a new list to ensure clean separations.}% + \fi + }% + \let\pgfplotsapplistXX=\pgfutil@empty + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \def\pgfplotsapplistXX@bigbuf@c{0}% +}% + + +\def\pgfplotsapplistXXclear{% + \pgfutil@ifundefined{pgfplotsapplistXX}{}{% + \let\pgfplotsapplistXX=\pgfutil@empty + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \def\pgfplotsapplistXX@bigbuf@c{0}% + }% +}% + +% #1: the item to append +% #2: the list as macro name +\long\def\pgfplotsapplistXXpushback#1{% + \begingroup + \c@pgf@counta=\pgfplotsapplistXX@smallbuf@c\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \let\pgfplotsapplistXX@smallbuf@c=\pgfplots@glob@TMPa + \ifnum\pgfplotsapplistXX@smallbuf@c<40 + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX@smallbuf#1}% + \edef\pgfplotsapplistXX@smallbuf{\the\t@pgfplots@toka}% + \else + \pgfplotsapplistXXpushback@smallbufoverfl{#1}% + \fi +}% +\long\def\pgfplotsapplistXXpushback@smallbufoverfl#1{% + \begingroup + \c@pgf@counta=\pgfplotsapplistXX@bigbuf@c\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \let\pgfplotsapplistXX@bigbuf@c=\pgfplots@glob@TMPa + % + \ifnum\pgfplotsapplistXX@bigbuf@c<30 + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX@bigbuf}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@smallbuf#1}% + \edef\pgfplotsapplistXX@bigbuf{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \else% + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@bigbuf}% + \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXX@smallbuf#1}% + \edef\pgfplotsapplistXX{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty + \def\pgfplotsapplistXX@bigbuf@c{0}% + \fi% +}% +\def\pgfplotsapplistXXflushbuffers{% + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@bigbuf}% + \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXX@smallbuf}% + \edef\pgfplotsapplistXX{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty + \def\pgfplotsapplistXX@bigbuf@c{0}% +}% + + +% Expands the complete content of list #1 as-is into the macro #2. +\def\pgfplotsapplistXXedefcontenttomacro#1{% + \pgfplotsapplistXXflushbuffers + \edef#1{\pgfplotsapplistXX}} +\def\pgfplotsapplistXXxdefcontenttomacro#1{% + \pgfplotsapplistXXflushbuffers% + \xdef#1{\pgfplotsapplistXX}} +\def\pgfplotsapplistXXlet#1{% + \pgfplotsapplistXXflushbuffers% + \let#1=\pgfplotsapplistXX} + +% Foreach list element, the stored value will simply be processed by +% TeX. Characters will be printed and commands will be executed. +\def\pgfplotsapplistXXexecute#1{% + \pgfplotsapplistXXflushbuffers + #1}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% +% \pgfplotslistXXglobal assigns to a global list. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +\def\pgfplotsapplistXXglobalnewempty{% + \pgfutil@ifundefined{pgfplotsapplistXXglobal}{}{% + \ifx\pgfplotsapplistXXglobal\pgfutil@empty + \else + \pgfplots@error{\string\pgfplotsapplistXXglobalnewempty: there is already another list which is *not* empty. It currently contains '\meaning\pgfplotsapplistXXglobal'. Please call '\string\pgfplotsapplistXXglobalclear' before using a new list to ensure clean separations.}% + \fi + }% + \global\let\pgfplotsapplistXXglobal=\pgfutil@empty + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}% +}% + + +\def\pgfplotsapplistXXglobalclear{% + \pgfutil@ifundefined{pgfplotsapplistXXglobal}{}{% + \global\let\pgfplotsapplistXXglobal=\pgfutil@empty + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}% + }% +}% + +% #1: the item to append +% #2: the list as macro name +\long\def\pgfplotsapplistXXglobalpushback#1{% + \begingroup + \c@pgf@counta=\pgfplotsapplistXXglobal@smallbuf@c\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \global\let\pgfplotsapplistXXglobal@smallbuf@c=\pgfplots@glob@TMPa + \ifnum\pgfplotsapplistXXglobal@smallbuf@c<40 + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}% + \xdef\pgfplotsapplistXXglobal@smallbuf{\the\t@pgfplots@toka}% + \else + \pgfplotsapplistXXglobalpushback@smallbufoverfl{#1}% + \fi +}% +\long\def\pgfplotsapplistXXglobalpushback@smallbufoverfl#1{% + \begingroup + \c@pgf@counta=\pgfplotsapplistXXglobal@bigbuf@c\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \global\let\pgfplotsapplistXXglobal@bigbuf@c=\pgfplots@glob@TMPa + % + \ifnum\pgfplotsapplistXXglobal@bigbuf@c<30 + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal@bigbuf}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}% + \xdef\pgfplotsapplistXXglobal@bigbuf{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \else% + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@bigbuf}% + \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}% + \xdef\pgfplotsapplistXXglobal{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}% + \fi% +}% +\def\pgfplotsapplistXXglobalflushbuffers{% + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@bigbuf}% + \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXXglobal@smallbuf}% + \xdef\pgfplotsapplistXXglobal{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}% +}% + + +% Expands the complete content of list #1 as-is into the macro #2. +% +% this assigns locally into #1. +\def\pgfplotsapplistXXglobaledefcontenttomacro#1{% + \pgfplotsapplistXXglobalflushbuffers + \edef#1{\pgfplotsapplistXXglobal}} +% this assigns locally into #1. +\def\pgfplotsapplistXXglobalxdefcontenttomacro#1{% + \pgfplotsapplistXXglobalflushbuffers% + \xdef#1{\pgfplotsapplistXXglobal}} +% this assigns locally into #1. +\def\pgfplotsapplistXXgloballet#1{% + \pgfplotsapplistXXglobalflushbuffers% + \let#1=\pgfplotsapplistXXglobal} + +% Foreach list element, the stored value will simply be processed by +% TeX. Characters will be printed and commands will be executed. +% this assigns locally into #1. +\def\pgfplotsapplistXXglobalexecute#1{% + \pgfplotsapplistXXglobalflushbuffers + #1}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \pgfplotsapplistXglobalnewempty --> same as \pgfplotsapplistX, but +% it always assigns everything *globally*. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\pgfplotsgloballet{\global\let}% + +% Usage: +% \pgfplotsapplistXglobalnewempty\macro +% \pgfplotsapplistXglobalnewempty[to global]\macro +% +% The 'to global' flag will configure the list such that all +% assignments to \macro are global. The list accumulation is +% LOCAL, however: 'to global' is to be used inside of a local +% group such that the final result, when all buffers are flushed, +% is assigned globally. +\def\pgfplotsapplistXglobalnewempty#1{% + \pgfplotsgloballet#1=\pgfutil@empty + \expandafter\pgfplotsgloballet\csname\string#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\pgfplotsgloballet\csname\string#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\gdef\csname\string#1@smallbuf@c\endcsname{0}% + \expandafter\gdef\csname\string#1@bigbuf@c\endcsname{0}% +}% + +% #1: the item to append +% #2: the list as macro name +\long\def\pgfplotsapplistXglobalpushback#1\to#2{% + \begingroup + \c@pgf@counta=\csname\string#2@smallbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \expandafter\xdef\csname\string#2@smallbuf@c\endcsname{\the\c@pgf@counta}% + \endgroup + \ifnum\csname\string#2@smallbuf@c\endcsname<40 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \expandafter\xdef\csname\string#2@smallbuf\endcsname{\the\t@pgfplots@toka}% + \else + \pgfplotsapplistXglobalpushback@smallbufoverfl{#1}{#2}% + \fi +}% +\long\def\pgfplotsapplistXglobalpushback@smallbufoverfl#1#2{% + \begingroup + \c@pgf@counta=\csname\string#2@bigbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \expandafter\xdef\csname\string#2@bigbuf@c\endcsname{\the\c@pgf@counta}% + \endgroup + % + \ifnum\csname\string#2@bigbuf@c\endcsname<30 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \expandafter\xdef\csname\string#2@bigbuf\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \expandafter\pgfplotsgloballet\csname\string#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\gdef\csname\string#2@smallbuf@c\endcsname{0}% + \else% + \t@pgfplots@toka=\expandafter{#2}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \xdef#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\pgfplotsgloballet\csname\string#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\gdef\csname\string#2@smallbuf@c\endcsname{0}% + \expandafter\pgfplotsgloballet\csname\string#2@bigbuf\endcsname=\pgfutil@empty + \expandafter\gdef\csname\string#2@bigbuf@c\endcsname{0}% + \fi% +}% +\def\pgfplotsapplistXglobalflushbuffers#1{% + \t@pgfplots@toka=\expandafter{#1}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#1@bigbuf\endcsname}% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#1@smallbuf\endcsname}% + \xdef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\pgfplotsgloballet\csname\string#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\gdef\csname\string#1@smallbuf@c\endcsname{0}% + \expandafter\pgfplotsgloballet\csname\string#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\gdef\csname\string#1@bigbuf@c\endcsname{0}% +}% + + +\def\pgfplotsapplistXgloballet#1=#2{% + \pgfplotsapplistXglobalflushbuffers#2% + \let#1=#2} diff --git a/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsmatrix.code.tex b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsmatrix.code.tex new file mode 100644 index 0000000..ddaf323 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/liststructure/pgfplotsmatrix.code.tex @@ -0,0 +1,544 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This is a helper package with an elementary (full) matrix datastructure, +% featuring O(1) index access and O(N) creation, deletion, copy. +% +% The following macros are supplied: +% +% \pgfplotsmatrixnewempty +% \pgfplotsmatrixresize +% \pgfplotsmatrixsize +% \pgfplotsmatrixselect +% \pgfplotsmatrixset +% \pgfplotsmatrixletentry +% \pgfplotsmatrixforeach +% \pgfplotsmatrixLUdecomp +% \pgfplotsmatrixLUsolve +% +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Creates a new, empty matrix. +\def\pgfplotsmatrixnewempty#1{% + \pgfplotsarray@@def{#1@rows}{0}% + \pgfplotsarray@@def{#1@cols}{1}% +} + +% resizes (truncates) matrix #1 to #2 rows and #3 cols. +% +% the elements won't be initialised. Use 'set' for each element. +\def\pgfplotsmatrixresize#1#2#3{% + \pgfplotsarray@@edef{#1@rows}{#2}% + \pgfplotsarray@@edef{#1@cols}{#3}% +} + +% Invokes code '#2' if the matrix named '#1' exists and '#3' if it does +% not exist. +\def\pgfplotsmatrixifdefined#1#2#3{% + \pgfutil@ifundefined{#1@rows}{#3}{#2}% +}% + + + +% Counts the number of rows/cols in matrix #1, storing it into the count +% registers #2, #3. +% Example: +% \pgfplotsmatrixsize\foo\to{\count0}{\count1}% +% \the\count0, \the\count1 +\long\def\pgfplotsmatrixsize#1\to#2#3{% + #2=\csname\string#1@rows\endcsname\relax + #3=\csname\string#1@cols\endcsname\relax +} + +\long\def\pgfplotsmatrixsizetomacro#1\to#2#3{% + \expandafter\let\expandafter#2\csname\string#1@rows\endcsname + \expandafter\let\expandafter#3\csname\string#1@cols\endcsname +} + + +% Returns the (#1,#2) element of matrix #3 into macro #4 +% Arguments: +% #1: a row index 0,...,N-1 where N is rowcount. +% #1 must expand to an integer. +% #2: a col index 0,...,N-1 where N is colcount. +% #2 must expand to an integer. +% #3: a matrix +% #4: a macro name +% Example: +% Element 0: +% \pgfplotsmatrixselect0,1\of\foo\to\elem +% \elem +% Element \count1: +% \pgfplotsmatrixselect\count1,2\of\foo\to\elem +\def\pgfplotsmatrixselect#1,#2\of#3\to#4{% + \expandafter\let\expandafter#4\csname\string#3@#1,#2\endcsname% + \ifx#4\relax + \pgfplotsthrow{no such element}{#1,#2}{No such element: \string\pgfplotsmatrixselect#1,#2\string\of{\string#3}}\pgfeov% + \fi +} + +% Expands to the value (#1,#2) of matrix #3. +% #1: a row index (not a register) +% #2: a col index +% #3: a matrix +\def\pgfplotsmatrixvalueofelem#1,#2\of#3{\csname\string#3@#1,#2\endcsname}% + +% Sets element '#1,#2' of matrix '#3' to '#4'. +\def\pgfplotsmatrixset#1,#2\of#3\to#4{% + \pgfutil@namedef{\string#3@#1,#2}{#4}% +} +\long\def\pgfplotsmatrixletentry#1,#2\of#3=#4{% + \expandafter\let\csname\string#3@#1,#2\endcsname=#4\relax +} + +% During the loop, \pgfplotsmatrixforeachrowindex expands to the +% current row index and \pgfplotsmatrixforeachcolindex to the actual +% col index. It invokes \pgfplotsmatrixforeachrowend after each +% complete row. +% +% This macro uses +% \c@pgf@counta,\c@pgf@countb,\c@pgf@countc,\c@pgf@countd +\long\def\pgfplotsmatrixforeach#1\as#2#3{% + \pgfplotsmatrixsize#1\to\c@pgf@countc\c@pgf@countd + \long\def\pgfplotsmatrixforeach@{#3}% + \def\pgfplotsmatrixforeach@assign##1{\def#2{##1}}% + \def\pgfplotsmat@select##1,##2\to{\pgfplotsmatrixselect##1,##2\of#1\to}% + \def\pgfplotsmatrixforeachrowindex{\the\c@pgf@counta}% + \def\pgfplotsmatrixforeachcolindex{\the\c@pgf@countb}% + \c@pgf@counta=0 + \pgfplotsmatrixforeach@loop + \let\pgfplotsmatrixforeachcolindex\relax + \let\pgfplotsmatrixforeachrowindex\relax% +}% +\let\pgfplotsmatrixforeachrowend=\relax +\def\pgfplotsmatrixforeach@loop{% + \ifnum\c@pgf@counta<\c@pgf@countc + \c@pgf@countb=0 + \pgfplotsmatrixforeach@loop@ + % + \pgfplotsmatrixforeachrowend + % + \advance\c@pgf@counta by1 + \expandafter\pgfplotsmatrixforeach@loop + \fi +}% +\def\pgfplotsmatrixforeach@loop@{% + \ifnum\c@pgf@countb<\c@pgf@countd + \pgfplotsmat@select\the\c@pgf@counta,\the\c@pgf@countb\to\pgfplotsmat@Aij + \expandafter\pgfplotsmatrixforeach@assign\expandafter{\pgfplotsmat@Aij}% + \pgfplotsmatrixforeach@ + % + \advance\c@pgf@countb by1 + \expandafter\pgfplotsmatrixforeach@loop@ + \fi +}% + +% Defines \pgfplotsretval to be a text-representation of the matrix. +% It will contain '\n' as newline macro and \t to separate cells. +% +\def\pgfplotsmatrixtotext#1{% + \begingroup + \pgfplotsapplistXnewempty\pgfplotsretval@ + \def\pgfplotsmatrixforeachrowend{% + \pgfplotsapplistXpushback\n\to\pgfplotsretval@ + }% + \pgfplotsmatrixforeach#1\as\entry{% + \pgfmathfloatparsenumber\entry + \pgfmathfloattosci\pgfmathresult + \edef\entry{\pgfmathresult\noexpand\t}% + \expandafter\pgfplotsapplistXpushback\entry\to\pgfplotsretval@ + }% + \pgfplotsapplistXlet\pgfplotsretval=\pgfplotsretval@ + \pgfmath@smuggleone\pgfplotsretval + \endgroup +} + +% Takes a matrix #1 and replaces it by its LU decomposition. +% The LU decomposition uses implicit pivoting; the pivoting +% information is stored in a permutation array #2 and a sign macro #3. +% +% It is to be used together with \pgfplotsmatrixsolveLEQS. +% +% #1: the input matrix (square size) +% #2: a macro name; will be used to store the permutation array for +% the pivoting. +% #3: a macro name, will contain the sign of the permutation (either +% +1 or -1). +% +% The algorithm has been converted from Numerical Recipes in C (I did +% not copy the comments, though). You find the complete reference in +% Chapter 2 of Numerical Recipes. +% +% If the matrix is singular, an exception will be raised. +% If the matrix is singular up to working precision, +% \pgfplotsmatrixLUdecompwarnsingular will be invoked and the +% algorithm continues with a small threshold. +% +% All arithmetics is computed with \pgfplotscoordmath{default} (which +% is float in the initial configuration). Use +% \pgfplotssetcoordmathfor{default}{pgfbasic} to switch it to standard +% pgf arithmetics. +% +% ATTENTION. This routine re-uses the four counters +% \c@pgf@counta,...\c@pgf@countd. +% Furthermore, it does not free any memory. +% Make sure you use it inside of local scopes. +\def\pgfplotsmatrixLUdecomp#1\perm#2\sign#3{% + \let\pgfplotsmat@i=\c@pgf@counta + \let\pgfplotsmat@imax=\c@pgf@countb + \let\pgfplotsmat@j=\c@pgf@countc + \let\pgfplotsmat@k=\c@pgf@countd + \countdef\pgfplotsmat@n=0 + \let\pgfplotsmat@big=\pgfutil@empty + \let\pgfplotsmat@dum=\pgfutil@empty + \let\pgfplotsmat@sum=\pgfutil@empty + \let\pgfplotsmat@temp=\pgfutil@empty + \pgfplotsmatrixsize#1\to\pgfplotsmat@n\c@pgf@countd + \ifnum\c@pgf@countd=\pgfplotsmat@n + \else + \pgfplots@error{Sorry, \string\pgfplotsmatrixLUdecomp\space expected an n x n matrix, but got \the\pgfplotsmat@n\space x \the\c@pgf@countd.}% + \fi + \pgfplotsarraynewempty\pgfplotsmat@vv + \pgfplotsarrayresize\pgfplotsmat@vv\pgfplotsmat@n + \pgfplotsarrayresize#2\pgfplotsmat@n + \def\pgfplotsmat@parity{1}% + \def\pgfplotsmat@select##1,##2\to{\pgfplotsmatrixselect##1,##2\of#1\to}% + \def\pgfplotsmat@letentry##1,##2={\pgfplotsmatrixletentry##1,##2\of#1=}% + \def\pgfplotsmat@letpermentry##1={\pgfplotsarrayletentry##1\of#2=}% + % + \pgfplotsmat@i=0 + \pgfplotsmatrixLUdecomp@scalingloop + % + \ifnum\pgfplotsmat@n>0 % this is used for error recovery. + % + \pgfplotsmat@j=0 + \pgfplotsmatrixLUdecomp@mainloop@j + % + \let#3=\pgfplotsmat@parity + \fi +}% +\def\pgfplotsmatrixLUdecomp@scalingloop{% + \ifnum\pgfplotsmat@i<\pgfplotsmat@n + \pgfplotscoordmath{default}{zero}% + \let\pgfplotsmat@big=\pgfmathresult + % + \pgfplotsmat@j=0 + \pgfplotsmatrixLUdecomp@scalingloop@ + % + \pgfplotscoordmath{default}{if is}{\pgfplotsmat@big}{0}{% + \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Singular matrix in \string\pgfplotsmatrixLUdecomp}\pgfeov% + \pgfplotsmat@n=-1 + }{% + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplotsmat@big}}% + \pgfplotsarrayletentry\pgfplotsmat@i\of\pgfplotsmat@vv=\pgfmathresult + }% + % + \advance\pgfplotsmat@i by1 + \expandafter\pgfplotsmatrixLUdecomp@scalingloop + \fi +}% +\def\pgfplotsmatrixLUdecomp@scalingloop@{% + \ifnum\pgfplotsmat@j<\pgfplotsmat@n + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@Aij + \pgfplotscoordmath{default}{parsenumber}{\pgfplotsmat@Aij}% + \let\pgfplotsmat@Aij=\pgfmathresult + \pgfplotsmat@letentry\the\pgfplotsmat@i,\the\pgfplotsmat@j=\pgfplotsmat@Aij + % + \pgfplotscoordmath{default}{op}{abs}{{\pgfplotsmat@Aij}}% + \let\pgfplotsmat@temp=\pgfmathresult + \pgfplotscoordmath{default}{max}{\pgfplotsmat@temp}{\pgfplotsmat@big}% + \let\pgfplotsmat@big=\pgfmathresult + % + \advance\pgfplotsmat@j by1 + \expandafter\pgfplotsmatrixLUdecomp@scalingloop@ + \fi +}% + +\def\pgfplotsmatrixLUdecomp@mainloop@j{% + \ifnum\pgfplotsmat@j<\pgfplotsmat@n + % + \pgfplotsmat@i=0 + \pgfplotsmatrixLUdecomp@mainloop@j@i + % + \pgfplotscoordmath{default}{zero}% + \let\pgfplotsmat@big=\pgfmathresult + % + \pgfplotsmat@i=\pgfplotsmat@j + \pgfplotsmatrixLUdecomp@mainloop@j@i@second + % + \ifnum\pgfplotsmat@j=\pgfplotsmat@imax + \else + % interchange rows... + \pgfplotsmat@k=0 + \pgfplotsmatrixLUdecomp@mainloop@j@k + % + \c@pgfplotsarray@tmp=-\pgfplotsmat@parity\relax% + \edef\pgfplotsmat@parity{\the\c@pgfplotsarray@tmp}% + % + % FIXME : this here is DIFFERENT. Seems there is something + % missing in Numerical Recipes book + \pgfplotsarrayselect\pgfplotsmat@j\of\pgfplotsmat@vv\to\pgfplotsmat@dum + %\pgfplotsarrayselect\pgfplotsmat@imax\of\pgfplotsmat@vv\to\pgfplotsmat@temp + %\pgfplotsarrayletentry\pgfplotsmat@j\of\pgfplotsmat@vv=\pgfplotsmat@temp + \pgfplotsarrayletentry\pgfplotsmat@imax\of\pgfplotsmat@vv=\pgfplotsmat@dum + \fi + % + \edef\pgfplotsmat@dum{\the\pgfplotsmat@imax}% + \pgfplotsmat@letpermentry\pgfplotsmat@j=\pgfplotsmat@dum + % + \pgfplotsmat@select\the\pgfplotsmat@j,\the\pgfplotsmat@j\to\pgfplotsmat@Ajj + \pgfplotscoordmath{default}{if is}{\pgfplotsmat@Ajj}{0}{% + \pgfplotscoordmath{default}{parsenumber}{1e-15}% + \pgfplotsmatrixLUdecompwarnsingular + \pgfplotsmat@letentry\the\pgfplotsmat@j,\the\pgfplotsmat@j=\pgfmathresult + }{% + }% + % + % + \advance\pgfplotsmat@j by1 + \ifnum\pgfplotsmat@j=\pgfplotsmat@n + \advance\pgfplotsmat@j by-1 + \else + \advance\pgfplotsmat@j by-1 + \pgfplotsmat@select\the\pgfplotsmat@j,\the\pgfplotsmat@j\to\pgfplotsmat@Ajj + \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplotsmat@Ajj}}% + \let\pgfplotsmat@dum=\pgfmathresult + \pgfplotsmat@i=\pgfplotsmat@j + \advance\pgfplotsmat@i by1 + \pgfplotsmatrixLUdecomp@mainloop@j@i@final + \fi + \advance\pgfplotsmat@j by1 + \expandafter\pgfplotsmatrixLUdecomp@mainloop@j + \fi +}% +\def\pgfplotsmatrixLUdecompwarnsingular{% + \pgfplotswarning{linear system singular}\pgfeov% +}% +\def\pgfplotsmatrixLUdecomp@mainloop@j@i{% + \ifnum\pgfplotsmat@i<\pgfplotsmat@j + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@sum + \pgfplotsmat@k=0 + \pgfplotsmatrixLUdecomp@mainloop@j@i@k + \pgfplotsmat@letentry\the\pgfplotsmat@i,\the\pgfplotsmat@j=\pgfplotsmat@sum + % + \advance\pgfplotsmat@i by1 + \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i + \fi +}% +\def\pgfplotsmatrixLUdecomp@mainloop@j@i@k{% + \ifnum\pgfplotsmat@k<\pgfplotsmat@i + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@k\to\pgfplotsmat@Aik + \pgfplotsmat@select\the\pgfplotsmat@k,\the\pgfplotsmat@j\to\pgfplotsmat@Akj + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@Aik}{\pgfplotsmat@Akj}}% + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotsmat@sum}{\pgfmathresult}}% + \let\pgfplotsmat@sum=\pgfmathresult + % + \advance\pgfplotsmat@k by1 + \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i@k + \fi +} +\def\pgfplotsmatrixLUdecomp@mainloop@j@i@second{% + \ifnum\pgfplotsmat@i<\pgfplotsmat@n + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@sum + % + \pgfplotsmat@k=0 + \pgfplotsmatrixLUdecomp@mainloop@j@i@second@k + \pgfplotsmat@letentry\the\pgfplotsmat@i,\the\pgfplotsmat@j=\pgfplotsmat@sum + % + \pgfplotscoordmath{default}{op}{abs}{{\pgfplotsmat@sum}}% + \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplotsarrayvalueofelem\the\pgfplotsmat@i\of\pgfplotsmat@vv}}% + \let\pgfplotsmat@dum=\pgfmathresult + \pgfplotscoordmath{default}{if less than}{\pgfplotsmat@dum}{\pgfplotsmat@big}{% + }{% + \let\pgfplotsmat@big=\pgfplotsmat@dum + \pgfplotsmat@imax=\pgfplotsmat@i + }% + % + \advance\pgfplotsmat@i by1 + \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i@second + \fi +}% +\def\pgfplotsmatrixLUdecomp@mainloop@j@i@second@k{% + \ifnum\pgfplotsmat@k<\pgfplotsmat@j + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@k\to\pgfplotsmat@Aik + \pgfplotsmat@select\the\pgfplotsmat@k,\the\pgfplotsmat@j\to\pgfplotsmat@Akj + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@Aik}{\pgfplotsmat@Akj}}% + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotsmat@sum}{\pgfmathresult}}% + \let\pgfplotsmat@sum=\pgfmathresult + % + \advance\pgfplotsmat@k by1 + \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i@second@k + \fi +}% + +\def\pgfplotsmatrixLUdecomp@mainloop@j@k{% + \ifnum\pgfplotsmat@k<\pgfplotsmat@n + % + \pgfplotsmat@select\the\pgfplotsmat@imax,\the\pgfplotsmat@k\to\pgfplotsmat@dum + \pgfplotsmat@select\the\pgfplotsmat@j,\the\pgfplotsmat@k\to\pgfplotsmat@Ajk + \pgfplotsmat@letentry\the\pgfplotsmat@imax,\the\pgfplotsmat@k=\pgfplotsmat@Ajk + \pgfplotsmat@letentry\the\pgfplotsmat@j,\the\pgfplotsmat@k=\pgfplotsmat@dum + % + \advance\pgfplotsmat@k by1 + \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@k + \fi +} +\def\pgfplotsmatrixLUdecomp@mainloop@j@i@final{% + \ifnum\pgfplotsmat@i<\pgfplotsmat@n + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@Aij + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@Aij}{\pgfplotsmat@dum}}% + \pgfplotsmat@letentry\the\pgfplotsmat@i,\the\pgfplotsmat@j=\pgfmathresult + % + \advance\pgfplotsmat@i by1 + \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i@final + \fi +} + + + +% Solves the set of n linear equations Ax = b where A = LU is given in +% (#1,#2) and b = #3. +% +% #1: is a result of \pgfplotsmatrixLUdecomp +% #2: is the permutation vector returned by \pgfplotsmatrixLUdecomp +% #3: the right hand side. On output, it will be *overwritten* with +% the solution. +% +% The algorithm has been converted from Numerical Recipes in C (I did +% not copy the comments, though). You find the complete reference in +% Chapter 2 of Numerical Recipes. +\def\pgfplotsmatrixLUbacksubst#1\perm#2\inout#3{% + \let\pgfplotsmat@i=\c@pgf@counta + \let\pgfplotsmat@ii=\c@pgf@countb + \let\pgfplotsmat@j=\c@pgf@countc + \let\pgfplotsmat@n=\c@pgf@countd + \let\pgfplotsmat@sum=\pgfutil@empty + \pgfplotsmatrixsize#1\to\pgfplotsmat@n\c@pgf@counta + \pgfplotsarraysize#3\to\c@pgf@counta + \ifnum\c@pgf@counta=\pgfplotsmat@n + \def\pgfplotsmat@select##1,##2\to{\pgfplotsmatrixselect##1,##2\of#1\to}% + \def\pgfplotsmat@selectperm##1\to{\pgfplotsarrayselect##1\of#2\to}% + \def\pgfplotsmat@selectb##1\to{\pgfplotsarrayselect##1\of#3\to}% + \def\pgfplotsmat@letresult##1={\pgfplotsarrayletentry##1\of#3=}% + % + \pgfplotsmat@ii=-1 + \pgfplotsmat@i=0 + \pgfplotsmatrixLUbacksubst@loop@i + % + \pgfplotsmat@i=\pgfplotsmat@n + \advance\pgfplotsmat@i by-1 + \pgfplotsmatrixLUbacksubst@loop@i@backw + \else + \pgfplots@error{Sorry, \string\pgfplotsmatrixLUbacksubst\space expected a vector of length \the\pgfplotsmat@n\space, not \the\c@pgf@counta}% + \fi +}% +\def\pgfplotsmatrixLUbacksubst@loop@i{% + \ifnum\pgfplotsmat@i<\pgfplotsmat@n + % + \pgfplotsmat@selectperm\pgfplotsmat@i\to\pgfplotsmat@ip + \pgfplotsmat@selectb\pgfplotsmat@ip\to\pgfplotsmat@sum + \pgfplotsmat@selectb\pgfplotsmat@i\to\pgfplotsmat@temp + % + \pgfplotscoordmath{default}{parsenumber}{\pgfplotsmat@sum}% + \let\pgfplotsmat@sum=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{\pgfplotsmat@temp}% + \let\pgfplotsmat@temp=\pgfmathresult + % + \pgfplotsmat@letresult\pgfplotsmat@ip=\pgfplotsmat@temp + % + \ifnum\pgfplotsmat@ii<0 + \pgfplotscoordmath{default}{if is}{\pgfplotsmat@sum}{0}{% + }{% + \pgfplotsmat@ii=\pgfplotsmat@i + }% + \else + \pgfplotsmat@j=\pgfplotsmat@ii + \pgfplotsmatrixLUbacksubst@loop@i@j + \fi + \pgfplotsmat@letresult\pgfplotsmat@i=\pgfplotsmat@sum + % + \advance\pgfplotsmat@i by1 + \expandafter\pgfplotsmatrixLUbacksubst@loop@i + \fi +}% +\def\pgfplotsmatrixLUbacksubst@loop@i@j{% + \ifnum\pgfplotsmat@j<\pgfplotsmat@i + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@Aij + \pgfplotsmat@selectb\pgfplotsmat@j\to\pgfplotsmat@temp + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@temp}{\pgfplotsmat@Aij}}% + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotsmat@sum}{\pgfmathresult}}% + \let\pgfplotsmat@sum=\pgfmathresult + % + \advance\pgfplotsmat@j by1 + \expandafter\pgfplotsmatrixLUbacksubst@loop@i@j + \fi +}% + +\def\pgfplotsmatrixLUbacksubst@loop@i@backw{% + \ifnum\pgfplotsmat@i<0 + \else + % + \pgfplotsmat@selectb\pgfplotsmat@i\to\pgfplotsmat@sum + \pgfplotsmat@j=\pgfplotsmat@i + \advance\pgfplotsmat@j by1 + \pgfplotsmatrixLUbacksubst@loop@i@backw@j + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@i\to\pgfplotsmat@Aii + \pgfplotscoordmath{default}{op}{divide}{{\pgfplotsmat@sum}{\pgfplotsmat@Aii}}% + \pgfplotsmat@letresult\pgfplotsmat@i=\pgfmathresult + % + \advance\pgfplotsmat@i by-1 + \expandafter\pgfplotsmatrixLUbacksubst@loop@i@backw + \fi +}% +\def\pgfplotsmatrixLUbacksubst@loop@i@backw@j{% + \ifnum\pgfplotsmat@j<\pgfplotsmat@n + % + \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@Aij + \pgfplotsmat@selectb\pgfplotsmat@j\to\pgfplotsmat@temp + \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@temp}{\pgfplotsmat@Aij}}% + \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotsmat@sum}{\pgfmathresult}}% + \let\pgfplotsmat@sum=\pgfmathresult + % + \advance\pgfplotsmat@j by1 + \expandafter\pgfplotsmatrixLUbacksubst@loop@i@backw@j + \fi +}% + +% Solves the linear equation system Ax = b. +% #1: the matrix A +% #2: the right-hand-side b. On output, #2 will contain the solution +% and A will be overwritten. +% +% ATTENTION. This routine re-uses the four counters +% \c@pgf@counta,...\c@pgf@countd. +% Furthermore, it does not free any memory. +% Make sure you use it inside of local scopes. +\def\pgfplotsmatrixsolveLEQS#1=#2{% + \pgfplotsmatrixLUdecomp#1\perm\pgfplotsmatrix@perm\sign\pgfplotsmatrix@sign + \pgfplotsmatrixLUbacksubst#1\perm\pgfplotsmatrix@perm\inout#2% +}% diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots.lua new file mode 100644 index 0000000..23aeaab --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots.lua @@ -0,0 +1,45 @@ + +require("pgfplots.binary") + +-- all classes/globals will be added to this table: +pgfplots = {} + +-- will be set by TeX: +pgfplots.pgfplotsversion = nil + +if _VERSION == "Lua 5.1" or _VERSION == "Lua 5.0" then + texio.write("pgfplots: setting 'lua support=false': the lua version on this system is " .. _VERSION .. "; expected at least 'Lua 5.2'. Use a more recent TeX distribution to benefit from LUA in pgfplots.\n") + + -- the entire lua backend will be switched off if this is false: + tex.sprint("\\pgfplotsset{lua support=false}") + return +else + -- well, 5.2 is what this stuff has been written for. + -- Is there a good reason why it shouldn't work on 5.1 !? No, I guess not. Except that it took me a long time + -- to figure out that 5.2 broke compatibility in lots of ways - and it was difficult enough to get it up and running. + -- If someone wants (and needs) to run it in 5.1 - I would accept patches. +end + +require("pgfplots.pgfplotsutil") + +-- see pgfrcs.code.tex -- all versions after 3.0.0 (excluding 3.0.0) will set this version: +if not pgf or not pgf.pgfversion then + pgfplots.log("log", "pgfplots.lua: loading complementary lua code for your pgf version...\n") + pgfplots.pgfluamathfunctions = require("pgfplotsoldpgfsupp.luamath.functions") + pgfplots.pgfluamathparser = require("pgfplotsoldpgfsupp.luamath.parser") +else + pgfplots.pgfluamathparser = require("pgf.luamath.parser") + pgfplots.pgfluamathfunctions = require("pgf.luamath.functions") +end +pgfplots.pgftonumber = pgfplots.pgfluamathfunctions.tonumber +pgfplots.tostringfixed = pgfplots.pgfluamathfunctions.tostringfixed +pgfplots.toTeXstring = pgfplots.pgfluamathfunctions.toTeXstring + + +require("pgfplots.plothandler") +require("pgfplots.meshplothandler") +require("pgfplots.colormap") +require("pgfplots.streamer") + +-- hm. perhaps this here should become a separate module: +require("pgfplots.pgfplotstexio") diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/binary.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/binary.lua new file mode 100644 index 0000000..7047784 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/binary.lua @@ -0,0 +1,41 @@ + +-- Attention: functions in this file are part of the backend driver. +-- They are supposed to work back with Lua 5.1 . +-- Note that most of the 'lua backend' requires Lua 5.2 (currently) + +pgfplotsGetLuaBinaryStringFromCharIndicesChunkSize = 7000; + +if unpack == nil then + -- LUA 0.76 renamed unpack to table.unpack + pgfplotsUnpack = table.unpack; +else + pgfplotsUnpack = unpack; +end + +-- Takes a table containing an arbitrary number of integers in the range 0..255 and converts it +-- into a binary stream of the corresponding binary chars. +-- +-- @param charIndices a table containing 0...N arguments; each in the range 0..255 +-- +-- @return a string containing binary content, one byte for each input integer. +function pgfplotsGetLuaBinaryStringFromCharIndices(charIndices) + -- unpack extracts only the indices (we can't provide a table to string.char). + -- note that pdf.immediateobj has been designed to avoid sanity checking for invalid UTF strings - + -- in other words: it accepts binary strings. + -- + -- unfortunately, this here fails for huge input tables: + -- pgfplotsretval=string.char(unpack(charIndices)); + -- we have to create it incrementally using chunks: + local len = #charIndices; + local chunkSize = pgfplotsGetLuaBinaryStringFromCharIndicesChunkSize; + local buf = {}; + -- ok, append all full chunks of chunkSize first: + local numFullChunks = math.floor(len/chunkSize); + for i = 0, numFullChunks-1, 1 do + table.insert(buf, string.char(pgfplotsUnpack(charIndices, 1+i*chunkSize, (i+1)*chunkSize))); + end + -- append the rest: + table.insert(buf, string.char(pgfplotsUnpack(charIndices, 1+numFullChunks*chunkSize))); + return table.concat(buf); +end + diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/colormap.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/colormap.lua new file mode 100644 index 0000000..28fd6dd --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/colormap.lua @@ -0,0 +1,98 @@ +-- +-- This file contains parts of pgfplotscolormap.code.tex +-- + +local math=math +local pgfplotsmath = pgfplots.pgfplotsmath +local io=io +local type=type +local tostring=tostring +local error=error +local table=table + +do +-- all globals will be read from/defined in pgfplots: +local _ENV = pgfplots +----------------------------------- + +ColorSpace = newClass() +function ColorSpace:constructor(numComponents) + self.numComponents=numComponents +end + +rgb = ColorSpace.new(3) +cmyk = ColorSpace.new(4) +gray = ColorSpace.new(1) + + +ColorMap = newClass() + +ColorMap.range =1000 + +-- h: mesh width between adjacent values +-- colorspace: an instance of ColorSpace +-- values: an array (1-based table) with color components. Each color component is supposed to be a table with K entries where K is colorspace:numComponents +function ColorMap:constructor( h, colorspace, values) + if not h or not colorspace or not values then error("arguments must not be nil")end + + self.name = name + self.h = h + self.invh = 1/h + self.colorspace = colorspace + self.values = values + + local numComponents = self.colorspace.numComponents + for i = 1,#self.values do + local value = self.values[i] + if #value ~= numComponents then + error("Some value has an unexpected number of color components, expected " .. self.colorspace.numComponents .. " but was ".. #value); + end + end +end + +function ColorMap:findPrecomputed(inMin, inMax, x) + local transformed + if inMin == 0 and inMax == ColorMap.range then + transformed = x + else + local scale = ColorMap.range / (inMax - inMin) + + transformed = (x - inMin) * scale + end + transformed = math.max(0, transformed) + transformed = math.min(ColorMap.range, transformed) + + local divh = transformed * self.invh + local intervalno = math.floor(divh) + local factor = divh - intervalno + local factor_two = 1-factor + + + -- Step 2: interpolate the desired RGB value using vector valued interpolation on the identified interval + if intervalno+1 == #self.values then + -- ah- we are at the right end! + return self.values[#self.values] + end + + local left = self.values[intervalno+1] + local right = self.values[intervalno+2] + if not left or not right then error("Internal error: the color map does not have enough values for interval no " .. intervalno )end + + local result = {} + for i = 1,self.colorspace.numComponents do + local result_i = factor_two * left[i] + factor * right[i] + + result[i] = result_i + end + + return result +end + +----------------------------------- + +-- global registry of all colormaps. +-- Key: colormap name +-- Value: an instance of ColorMap +ColorMaps = {} + +end diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/meshplothandler.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/meshplothandler.lua new file mode 100644 index 0000000..a3b492a --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/meshplothandler.lua @@ -0,0 +1,294 @@ +-- This file has dependencies to BOTH, the TeX part of pgfplots and the LUA part. +-- It is the only LUA component with this property. +-- +-- Its purpose is to encapsulate the communication between TeX and LUA in a central LUA file + +local pgfplotsmath = pgfplots.pgfplotsmath +local error=error +local table=table +local string=string +local tostring=tostring +local type=type +local io=io + +do +-- all globals will be read from/defined in pgfplots: +local _ENV = pgfplots + + +------------------------------------------------------- +-- A patch type. +-- @see \pgfplotsdeclarepatchclass + +PatchType = newClass() + +function PatchType:constructor(name, numVertices) + self.name = name + self.numVertices = numVertices +end + +function PatchType:__tostring() + return self.name +end + +function PatchType:newPatch(coords) + return Patch.new(self,coords) +end + +LinePatchType = newClassExtends(PatchType) + +function LinePatchType:constructor() + PatchType.constructor(self, "line", 2) +end + +TrianglePatchType = newClassExtends(PatchType) + +function TrianglePatchType:constructor() + PatchType.constructor(self, "triangle", 3) +end + + +RectanglePatchType = newClassExtends(PatchType) + +function RectanglePatchType:constructor() + PatchType.constructor(self, "rectangle", 4) +end + +------------------------------------------------------- +-- +-- a single patch. +-- @see \pgfplotsdeclarepatchclass + +Patch = newClass() + +function Patch:constructor(patchtype, coords) + if not patchtype or not coords then error("arguments must not be nil") end + if #coords ~= patchtype.numVertices then error("Unexpected number of coordinates provided; expected " .. tostring(patchtype.numVertices) .. " but got " .. tostring(#coords)) end + + self.patchtype = patchtype + self.coords = coords +end + +------------------------------------------------------- +-- Replicates \pgfplotsplothandlermesh (to some extend) +MeshPlothandler = newClassExtends(Plothandler) + +function MeshPlothandler:constructor(axis, pointmetainputhandler) + Plothandler.constructor(self,"mesh", axis, pointmetainputhandler) +end + +-- see \pgfplot@apply@zbuffer +function MeshPlothandler:reverseScanline(scanLineLength) + local coords = self.coords + local tmp + local scanlineOff + local numScanLines = #coords / scanLineLength + for scanline = 0,numScanLines-1,1 do + scanlineOff = scanline * scanLineLength + local reverseindex = scanlineOff + scanLineLength + for i = 0,scanLineLength/2-1,1 do + tmp = coords[1+scanlineOff+i] + coords[1+scanlineOff+i] = coords[reverseindex] + coords[reverseindex] = tmp + + reverseindex = reverseindex-1 + end + end +end + +-- see \pgfplot@apply@zbuffer +function MeshPlothandler:reverseTransposed(scanLineLength) + local coords = self.coords + local tmp + local scanlineOff + local numScanLines = #coords / scanLineLength + local reverseScanline = numScanLines-1 + for scanline = 0,numScanLines/2-1,1 do + scanlineOff = 1+scanline * scanLineLength + reverseScanlineOff = 1+reverseScanline * scanLineLength + for i = 0,scanLineLength-1 do + tmp = coords[scanlineOff+i] + coords[scanlineOff+i] = coords[reverseScanlineOff+i] + coords[reverseScanlineOff+i] = tmp + end + + reverseScanline = reverseScanline-1 + end +end + +-- see \pgfplot@apply@zbuffer +function MeshPlothandler:reverseStream() + local coords = self.coords + local tmp + local reverseindex = #coords + for i = 1,#coords/2 do + tmp = coords[i] + coords[i] = coords[reverseindex] + coords[reverseindex] = tmp + reverseindex = reverseindex-1 + end +end + + + +------------------------------------------------------- +-- +-- The (LUA!) visualizer for patch plots. It prepares stuff such that TeX only needs to work with lowlevel driver (PGF) streams. +-- + +MeshVisualizer = newClassExtends(PlotVisualizer) + +local COORDINATE_VALUE_OF_JUMPS = -16000 +local meshVisualizerTagEmptyCoordinates = function(pt) + pt.pgfXY= { COORDINATE_VALUE_OF_JUMPS, COORDINATE_VALUE_OF_JUMPS } + pt.x = { COORDINATE_VALUE_OF_JUMPS, COORDINATE_VALUE_OF_JUMPS, COORDINATE_VALUE_OF_JUMPS } +end + +function MeshVisualizer:constructor(sourcePlotHandler, patchType, rows, cols, isXVariesOrdering, isMatrixInput, isMatrixOutput, isZBufferSort) + PlotVisualizer.constructor(self,sourcePlotHandler) + self.patchType = patchType + self.isMatrixInput = isMatrixInput + self.isMatrixOutput = isMatrixOutput + self.isZBufferSort = isZBufferSort + self.rows = rows + self.cols = cols + self.isXVariesOrdering =isXVariesOrdering + + self.isOneDimMode= false + self.scanLineLength =-1 + if isMatrixInput then + -- isOneDimMode is ONLY interesting for matrix input + if cols <= 1 or rows <=1 then + self.isOneDimMode = true + self.patchType = LinePatchType.new() + -- this is not yet implemented (and cannot happen since the TeX call does catch this) + error("UNSUPPORTED OPERATION EXCEPTION") + end + + if isXVariesOrdering then + -- x varies (=rowwise) + self.scanLineLength = cols + else + -- y varies (=colwise) + self.scanLineLength = rows + end + + self.notifyJump = meshVisualizerTagEmptyCoordinates + else + -- disable any special handling + self.isXVariesOrdering = true + end + + -- log("initialized MeshVisualizer with " .. tostring(sourcePlotHandler) .. ", " .. tostring(patchType) .. ", isMatrixInput = " .. tostring(isMatrixInput) .. ", isMatrixOutput = " .. tostring(isMatrixOutput) .. ", isZBufferSort = " .. tostring(isZBufferSort) .. " rows = " ..tostring(rows) .. " cols = " ..tostring(cols) .. " is x varies=" .. tostring(isXVariesOrdering)) +end + +function MeshVisualizer:getVisualizationOutput() + local result = PlotVisualizer.getVisualizationOutput(self) + + if self.isMatrixInput and not self.isMatrixOutput then + result = self:decodeIntoPatches(result) + end + + if self.isZBufferSort then + result = self:applyZBufferSort(result) + end + + return result +end + +-- @param coords an array of Coord +function MeshVisualizer:applyZBufferSort(coords) + -- in order to sort this thing, we need to compute the sort key (view depth) for each coord. + -- furthermore, each list entry must be single patch... that means we need a (huge?) temporary table. + + local patchType = self.patchType + local numVertices = patchType.numVertices + + if (#coords % numVertices) ~= 0 then error("Got an unexpected number of input coordinates: each patch has " .. tostring(numVertices) .. " vertices, but the number of coords " .. tostring(#coords) .. " is no multiple of this number") end + local numPatches = #coords / numVertices + + -- STEP 1: compute an array of patches. + local patches = {} + local off=1 + for i = 1,numPatches do + local patchCoords = {} + for j = 1,numVertices do + local pt = coords[off] + off = off+1 + patchCoords[j] = pt + end + local patch = patchType:newPatch(patchCoords) + patches[i] = patch + end + if off ~= 1+#coords then error("Internal error: not all coordinates are part of patches (got " .. tostring(off) .. "/" .. tostring(#coords) ..")") end + + -- STEP 2: assign the sort key: the "element depth". + -- + -- the "element depth" is defined to be the MEAN of all + -- vertex depths. + -- And since the mean is 1/n * sum_{i=1}^n V_i, we can + -- directly omit the 1/n --- it is the same for every + -- vertex anyway, and we only want to compare the depth + -- values. + local axis = self.axis + local getVertexDepth = axis.getVertexDepth + for i=1,numPatches do + local patch = patches[i] + local patchcoords = patch.coords + + local sumOfVertexDepth = 0 + for j = 1,numVertices do + local vertex = patchcoords[j] + + local vertexDepth = getVertexDepth(axis,vertex) + + sumOfVertexDepth = sumOfVertexDepth + vertexDepth + end + patch.elementDepth = sumOfVertexDepth + end + + -- STEP 3: SORT. + local comparator = function(patchA, patchB) + return patchA.elementDepth > patchB.elementDepth + end + table.sort(patches, comparator) + + -- STEP 4: convert back into a list (in-place). + local off = 1 + for i=1,numPatches do + local patch = patches[i] + local patchcoords = patch.coords + for j = 1,numVertices do + coords[off] = patchcoords[j] + off = off+1 + end + end + if off ~= 1+#coords then error("Internal error: not all coordinates are part of patches (got " .. tostring(off) .. "/" .. tostring(#coords) ..")") end + + return coords +end + +function MeshVisualizer:decodeIntoPatches(coords) + local result = {} + + local scanLineLength = self.scanLineLength + local length = #coords + + local i = scanLineLength + while i < length do + local im = i-scanLineLength + + for j = 2,scanLineLength do + table.insert(result, coords[im+j-1]) -- (i-1,j-1) + table.insert(result, coords[im+j]) -- (i-1,j ) + table.insert(result, coords[i+j]) -- (i ,j ) + table.insert(result, coords[i+j-1]) -- (i ,j-1) + end + + i = i + scanLineLength + end + + return result +end + +end diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua new file mode 100644 index 0000000..ca8b894 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua @@ -0,0 +1,464 @@ +-- This file has dependencies to BOTH, the TeX part of pgfplots and the LUA part. +-- It is the only LUA component with this property. +-- +-- Its purpose is to encapsulate the communication between TeX and LUA in a central LUA file +-- +-- +-- Here is the idea how the TeX backend communicates with the LUA backend: +-- +-- * TeX can call LUA methods in order to "do something". The reverse direction is not true: LUA cannot call TeX methods. +-- +-- * the only way that LUA can read TeX input values or write TeX output values is the top layer (at the time of this writing: only pgfplotstexio.lua ). +-- +-- * The LUA backend has one main purpose: scalability and performance. +-- Its purpose is _not_ to run a standalone visualization. +-- +-- The precise meaning of "scalability" is: the LUA backend should do as much +-- as possible which is done for single coordinates. Coordinates constitute +-- "scalability": the number of coordinates can become arbitrarily large. +-- +-- "Performance" is related to scalability. But it is more: some dedicated +-- utility function might have a TeX backend and will be invoked whenever it +-- is needed. Candidates are colormap functions, z buffer arithmetics etc. +-- +-- Thus, the best way to ensure "scalability" is to move _everything_ which is to be done for a single coordinate to LUA. +-- +-- Sometimes, this will be impossible or too expensive. +-- Here, "Performance" might still be optimized by some dedicated LUA function. +-- +-- +-- Unfortunately, the LUA backend does not simplify the code base - it makes it more complicated. +-- This is due to the way it is used: one needs to know when the TeX backend +-- delegates all its work to LUA. It is also due to the fact that it +-- duplicates code: the same code is present in TeX and in LUA. I chose to keep +-- the two code bases close to each other. This has a chance to simplify maintenance: if I know +-- how something works in TeX, and I find some entry point in LUA, it will +-- hopefully be closely related. +-- +-- +-- It follows an overview over entry points into the LUA backend: +-- +-- * \begin{axis}. It invokes \pgfplots@prepare@LUA@api . +-- The purpose is to define the global pgfplots.gca "_g_et _c_urrent _a_xis" and to transfer some key presets. +-- +-- Log message: "lua backend=true: Activating LUA backend for axis." +-- +-- * \end{axis}. It invokes \pgfplots@LUA@visualization@update@axis . +-- The purpose is to transfer results of the survey phase to LUA; in particular axis properties like +-- the view direction, data scale transformations, axis wide limits and some related properties. +-- This has nothing to do with coordinates; the survey phase of coordinates is handled in a different way (see below). +-- +-- Eventually, \pgfplots@LUA@cleanup will clear the global pgfplots.gca . +-- +-- * \addplot . This has much to do with scalability, so much of its functionality is done in the LUA backend. +-- +-- Keep in mind that \addplot is part of the survey phase: it collects coordinates and updates axis limits. +-- Afterwards, it stores the survey results in the current axis. +-- +-- The survey phase currently has two different ways to communicate with the LUA backend: +-- +-- 1. PARTIAL MODE. In this mode, the coordinate stream comes from TeX: +-- some TeX code generates the coordinates. Whenever the stream is ready, +-- it will invoke \pgfplots@LUA@survey@point . This, in turn, calls the +-- LUA backend in order to complete the survey (which boils down to +-- pgfplots.texSurveyPoint). PARTIAL MODE saves lots of time, but its +-- scalability is limited due to the intensive use of TeX, it is less +-- powerful than COMPLETE MODE. +-- +-- 2. COMPLETE MODE. In this mode, the entire coordinate stream is on the +-- LUA side. The TeX code will merely call start the survey phase, call +-- LUA, and end the survey phase. This is the most efficient +-- implementation. At the time of this writing, it is limited to `\addplot +-- expression`: the code for `\addplot expression` tries to transfer the +-- entire processing to the LUA backend. If it succeeds, it will do +-- nothing on the TeX side. +-- +-- Both PARTIAL MODE and COMPLETE MODE call +-- \pgfplots@LUA@survey@start : transfer plot type and current axis arguments to LUA +-- and +-- \pgfplots@LUA@survey@end : copy LUA axis arguments back to TeX. +-- +-- Eventually, the axis will initiate the visualization phase for each plot. This is done by +-- a) \pgfplots@LUA@visualization@init : it calls pgfplots.texVisualizationInit() and results in the log message +-- "lua backend=true: Activating partial LUA backend for visualization of plot 0". +-- b) \pgfplots@LUA@visualization@of@current@plot : it transfers control +-- to LUA (pgfplots.texVisualizePlot) and does as much with the +-- coordinates as possible. Eventually, it streams the result back to +-- TeX which will visualize the stream by means of PGF's plot streams. +-- This is somewhat complicated since it modifies the TeX streaming. +local pgfplotsmath = pgfplots.pgfplotsmath +local tex=tex +local tostring=tostring +local error=error +local table=table +local string=string +local pairs=pairs +local pcall=pcall +local type=type +local lpeg = require("lpeg") +local math = math + +do +-- all globals will be read from/defined in pgfplots: +local _ENV = pgfplots + +local pgftonumber = pgfluamathfunctions.tonumber + +-- will be assigned by pgfplots at boot time. +LOAD_TIME_CATCODETABLE = nil + +-- Called during \addplot, i.e. during the survey phase. It is only called in PARTIAL MODE (see above). +function texSurveyPoint(x,y,z,meta) + local pt = Coord.new() + pt.x[1] = x + pt.x[2] = y + pt.x[3] = z + pt.meta = meta + + gca.currentPlotHandler:surveypoint(pt) +end + +-- Copies survey results of the current plot back to TeX. It prints a couple of executable TeX statements as result. +-- @see \pgfplots@LUA@survey@end +function texSurveyEnd() + local result = gca:surveyToPgfplots(gca.currentPlotHandler, true) + --log("returning " .. result .. "\n\n") + + tex.sprint(LOAD_TIME_CATCODETABLE, result); + gca.currentPlotHandler=nil +end + +-- A performance optimization: point meta transformation is done on the LUA side. +-- +-- expands to the transformed point meta +function texPerpointMetaTrafo(metaStr) + local meta = pgftonumber(metaStr) + local transformed = gca.currentPlotHandler:visualizationTransformMeta(meta); + tex.sprint(LOAD_TIME_CATCODETABLE, tostringfixed(transformed)); +end + +-- Called at the beginning of each plot visualization. +-- +-- expands to '1' if LUA is available for this plot and '0' otherwise. +-- @see texVisualizePlot +function texVisualizationInit(plotNum, plotIs3d) + if not plotNum or plotIs3d==nil then error("arguments must not be nil") end + + local currentPlotHandler = gca.plothandlers[plotNum+1] + gca.currentPlotHandler = currentPlotHandler; + if currentPlotHandler then + currentPlotHandler.plotIs3d = plotIs3d + currentPlotHandler:visualizationPhaseInit(); + tex.sprint("1") + else + -- ok, this plot has no LUA support. + tex.sprint("0") + end +end + +local pgfXyCoordSerializer = function(pt) + -- FIXME : it is unsure of whether this here really an improvement - or if it would be faster to compute that stuff in TeX... + if pt.pgfXY ~=nil then + return "{" .. tostringfixed(pt.pgfXY[1]) .. "}{" .. tostringfixed(pt.pgfXY[2]) .. "}" + else + return "{0}{0}" + end +end + +-- Actually does as much of the visualization of the current plot: it transforms all coordinates to some point where the TeX visualization mode continues. +-- +-- It expands to the resulting coordinates. Note that these coordinates are already mapped somehow (typically: to fixed point) +-- @see texVisualizationInit +function texVisualizePlot(visualizerFactory) + if not visualizerFactory then error("arguments must not be nil") end + if type(visualizerFactory) ~= "function" then error("arguments must be a function (a factory)") end + + local currentPlotHandler = gca.currentPlotHandler + if not currentPlotHandler then error("Illegal state: The current plot has no LUA plot handler!") end + + local visualizer = visualizerFactory(currentPlotHandler) + + local result = visualizer:getVisualizationOutput() + local result_str = currentPlotHandler:getCoordsInTeXFormat(gca, result, pgfXyCoordSerializer) + --log("returning " .. result_str .. "\n\n") + tex.sprint(LOAD_TIME_CATCODETABLE, result_str) +end + +-- Modifies the Surveyed coordinate list. +-- Expands to nothing +function texApplyZBufferReverseScanline(scanLineLength) + local currentPlotHandler = gca.currentPlotHandler + if not currentPlotHandler then error("This function cannot be used in the current context") end + + currentPlotHandler:reverseScanline(scanLineLength) +end + +-- Modifies the Surveyed coordinate list. +-- Expands to nothing +function texApplyZBufferReverseTransposed(scanLineLength) + local currentPlotHandler = gca.currentPlotHandler + if not currentPlotHandler then error("This function cannot be used in the current context") end + + currentPlotHandler:reverseTransposed(scanLineLength) +end + +-- Modifies the Surveyed coordinate list. +-- Expands to nothing +function texApplyZBufferReverseStream() + local currentPlotHandler = gca.currentPlotHandler + if not currentPlotHandler then error("This function cannot be used in the current context") end + + currentPlotHandler:reverseStream(scanLineLength) +end + +-- Modifies the Surveyed coordinate list. +-- +-- Note that this is UNRELATED to mesh/surface plots! They have their own (patch-based) z buffer. +-- +-- Expands to nothing +function texApplyZBufferSort() + local currentPlotHandler = gca.currentPlotHandler + if not currentPlotHandler then error("This function cannot be used in the current context") end + + currentPlotHandler:sortCoordinatesByViewDepth() +end + +-- Modifies the Surveyed coordinate list. +-- Expands to the resulting coordinates +function texGetSurveyedCoordsToPgfplots() + local currentPlotHandler = gca.currentPlotHandler + if not currentPlotHandler then error("This function cannot be used in the current context") end + + tex.sprint(LOAD_TIME_CATCODETABLE, currentPlotHandler:surveyedCoordsToPgfplots(gca)) +end + +-- Performance optimization: computes the colormap lookup. +function texColorMapPrecomputed(mapName, inMin, inMax, x) + local colormap = ColorMaps[mapName]; + if colormap then + local result = colormap:findPrecomputed( + pgftonumber(inMin), + pgftonumber(inMax), + pgftonumber(x)) + + local str = "" + for i = 1,#result do + if i>1 then str = str .. "," end + str = str .. tostringfixed(result[i]) + end + tex.sprint(LOAD_TIME_CATCODETABLE, str) + end +end + +local function isStripPrefixOrSuffixChar(char) + return char == ' ' or char == '{' or char == "}" +end + +-- Expressions can be something like +-- ( {(6+(sin(3*(x+3*y))+1.25)*cos(x))*cos(y)}, +-- {(6+(sin(3*(x+3*y))+1.25)*cos(x))*sin(y)}, +-- {((sin(3*(x+3*y))+1.25)*sin(x))} ); +-- +-- These result in expressions = { " {...}", " {...}", " {...} " } +-- -> this function removes the surrounding braces and the white spaces. +local function removeSurroundingBraces(expressions) + for i=1,#expressions do + local expr = expressions[i] + local startIdx + local endIdx + startIdx=1 + while startIdx<#expr and isStripPrefixOrSuffixChar(string.sub(expr,startIdx,startIdx)) do + startIdx = startIdx+1 + end + endIdx = #expr + while endIdx > 0 and isStripPrefixOrSuffixChar(string.sub(expr,endIdx,endIdx)) do + endIdx = endIdx-1 + end + + expr = string.sub(expr, startIdx, endIdx ) + expressions[i] = expr + end +end + +------------- +-- A parser for foreach statements - at least those which are supported in this LUA backend. +-- +local samplesAtToDomain +do + local P = lpeg.P + local C = lpeg.C + local V = lpeg.V + local match = lpeg.match + local space_pattern = P(" ")^0 + + local Exp = V"Exp" + local comma = P"," * space_pattern + -- this does not catch balanced braces. Ok for now... ? + local argument = C( ( 1- P"," )^1 ) * space_pattern + local grammar = P{ "initialRule", + initialRule = space_pattern * Exp * -1, + Exp = lpeg.Ct(argument * comma * argument * comma * P"..." * space_pattern * comma *argument ) + } + + -- Converts very simple "samples at" values to "domain=A:B, samples=N" + -- + -- @param foreachString something like -5,-4,...,5 + -- @return a table where + -- [0] = domain min + -- [1] = domain max + -- [2] = samples + -- It returns nil if foreachString is no "very simple value of 'samples at'" + samplesAtToDomain = function(foreachString) + local matches = match(grammar,foreachString) + + if not matches or #matches ~= 3 then + return nil + else + local arg1 = matches[1] + local arg2 = matches[2] + local arg3 = matches[3] + arg1= pgfluamathparser.pgfmathparse(arg1) + arg2= pgfluamathparser.pgfmathparse(arg2) + arg3= pgfluamathparser.pgfmathparse(arg3) + + if not arg1 or not arg2 or not arg3 then + return nil + end + + if arg1 > arg2 then + return nil + end + + local domainMin = arg1 + local h = arg2-arg1 + local domainMax = arg3 + + -- round to the nearest integer (using +0.5, should be ok) + local samples = math.floor((domainMax - domainMin)/h + 0.5) + 1 + + return domainMin, domainMax, samples + end + end +end + +-- This is the code which attempts to transfer control from `\addplot expression' to LUA. +-- +-- If it succeeds, the entire plot stream and the entire survey phase has been done in LUA. +-- +-- generates TeX output '1' on success and '0' on failure +-- @param debugMode one of a couple of strings: "off", "verbose", or "compileerror" +function texAddplotExpressionCoordinateGenerator( + is3d, + xExpr, yExpr, zExpr, + sampleLine, + domainxmin, domainxmax, + domainymin, domainymax, + samplesx, samplesy, + variablex, variabley, + samplesAt, + debugMode +) + local plothandler = gca.currentPlotHandler + local coordoutputstream = SurveyCoordOutputStream.new(plothandler) + + if samplesAt and string.len(samplesAt) >0 then + -- "samples at" has higher priority than domain. + -- Use it! + + domainxmin, domainxmax, samplesx = samplesAtToDomain(samplesAt) + if not domainxmin then + -- FAILURE: could not convert "samples at". + -- Fall back to a TeX based survey. + log("log", "LUA survey failed: The value of 'samples at= " .. tostring(samplesAt) .. "' is unsupported by the LUA backend (currently, only 'samples at={a,b,...,c}' is supported).\n") + tex.sprint("0") + return + end + + else + domainxmin= pgftonumber(domainxmin) + domainxmax= pgftonumber(domainxmax) + samplesx= pgftonumber(samplesx) + end + + local expressions + local domainMin + local domainMax + local samples + local variableNames + + -- allow both, even if sampleLine=1. We may want to assign a dummy value to y. + variableNames = { variablex, variabley } + + if sampleLine==1 then + domainMin = { domainxmin } + domainMax = { domainxmax } + samples = { samplesx } + else + local domainymin = pgftonumber(domainymin) + local domainymax = pgftonumber(domainymax) + local samplesy = pgftonumber(samplesy) + + domainMin = { domainxmin, domainymin } + domainMax = { domainxmax, domainymax } + samples = { samplesx, samplesy } + end + if is3d then + expressions = {xExpr, yExpr, zExpr} + else + expressions = {xExpr, yExpr} + end + removeSurroundingBraces(expressions) + + local generator = AddplotExpressionCoordinateGenerator.new( + coordoutputstream, + expressions, + domainMin, domainMax, + samples, + variableNames) + + local messageOnFailure + local compileErrorOnFailure + if debugMode == "compileerror" then + compileErrorOnFailure = true + messageOnFailure = true + elseif debugMode == "off" or debugMode == "verbose" then + messageOnFailure = true + compileErrorOnFailure = false + elseif debugMode == "off and silent" then + messageOnFailure = false + compileErrorOnFailure = false + else + error("Got unknown debugMode = " .. debugMode ) + end + + local success + if compileErrorOnFailure then + success = generator:generateCoords() + else + local resultOfGenerator + success, resultOfGenerator = pcall(generator.generateCoords, generator) + if success then + -- AH: "pcall" returned 'true'. In this case, 'success' is the boolean returned by generator + success = resultOfGenerator + end + + if messageOnFailure and not success and type(resultOfGenerator) ~= "boolean" then + log("log", "LUA survey failed: " .. resultOfGenerator .. ". Use \\pgfplotsset{lua debug} to see more.\n") + end + end + + if not type(success) == 'boolean' then error("Illegal state: expected boolean result") end + + if success then + tex.sprint("1") + else + tex.sprint("0") + end +end + +-- Creates the default plot visualizer factory. It simply applies data scale trafos. +function defaultPlotVisualizerFactory(plothandler) + return PlotVisualizer.new(plothandler) +end + +end diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/pgfplotsutil.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/pgfplotsutil.lua new file mode 100644 index 0000000..b3b09fe --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/pgfplotsutil.lua @@ -0,0 +1,139 @@ +local math=math +local string=string +local type=type +local tostring = tostring +local tonumber = tonumber +local setmetatable = setmetatable +local getmetatable = getmetatable +local print=print +local pairs = pairs +local table=table +local texio=texio + +do +local _ENV = pgfplots +--------------------------------------- +-- + +log=texio.write_nl + +local stringfind = string.find +local stringsub = string.sub +local tableinsert = table.insert + +-- Splits 'str' at delimiter and returns a table of strings +function stringsplit( str, delimiter ) + if not str or not delimiter then error("arguments must not be nil") end + local result = { } + local start = 1 + local findStart, findEnd = stringfind( str, delimiter, start ) + while findStart do + tableinsert( result, stringsub( str, start, findStart-1 ) ) + start = findEnd + 1 + findStart, findEnd = stringfind( str, delimiter, start ) + end + tableinsert( result, stringsub( str, start ) ) + return result +end + +function stringOrDefault(str, default) + if str == nil or type(str) == 'string' and string.len(str) == 0 then + return default + end + return tostring(str) +end + + +pgfplotsmath = {} + +function pgfplotsmath.isfinite(x) + if pgfplotsmath.isnan(x) or x == pgfplotsmath.infty or x == -pgfplotsmath.infty then + return false + end + return true +end + +local isnan = function(x) + return x ~= x +end + +pgfplotsmath.isnan = isnan + +local infty = 1/0 +pgfplotsmath.infty = infty + +local nan = math.sqrt(-1) +pgfplotsmath.nan = nan + +--------------------------------------- +-- + + +-- Creates and returns a new class object. +-- +-- Usage: +-- complexclass = newClass() +-- function complexclass:constructor() +-- self.re = 0 +-- self.im = 0 +-- end +-- +-- instance = complexclass.new() +-- +function newClass() + local result = {} + + -- we need this such that *instances* (which will have 'result' as meta table) + -- will "inherit" the class'es methods. + result.__index = result + local allocator= function (...) + local self = setmetatable({}, result) + self:constructor(...) + return self + end + result.new = allocator + return result +end + + + +-- Create a new class that inherits from a base class +-- +-- base = pgfplots.newClass() +-- function base:constructor() +-- self.variable= 'a' +-- end +-- +-- sub = pgfplots.newClassExtends(base) +-- function sub:constructor() +-- -- call super constructor. +-- -- it is ABSOLUTELY CRUCIAL to use .constructor here - not :constructor! +-- base.constructor(self) +-- end +-- +-- instance = base.new() +-- +-- instance2 = sub.new() +-- +-- @see newClass +function newClassExtends( baseClass ) + if not baseClass then error "baseClass must not be nil" end + + local new_class = newClass() + + -- The following is the key to implementing inheritance: + + -- The __index member of the new class's metatable references the + -- base class. This implies that all methods of the base class will + -- be exposed to the sub-class, and that the sub-class can override + -- any of these methods. + -- + local mt = {} -- getmetatable(new_class) + mt.__index = baseClass + setmetatable(new_class,mt) + + return new_class +end + + +end diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/plothandler.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/plothandler.lua new file mode 100644 index 0000000..e3fc089 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/plothandler.lua @@ -0,0 +1,962 @@ +-- +-- This file contains parts of pgfplotscoordprocessing.code.tex and pgfplotsplothandlers.code.tex . +-- +-- It contains +-- +-- pgfplots.Axis +-- pgfplots.Coord +-- pgfplots.Plothandler +-- +-- and some related classes. + +local math=math +local pgfplotsmath = pgfplots.pgfplotsmath +local type=type +local tostring=tostring +local error=error +local table=table +local pgfmathparse = pgfplots.pgfluamathparser.pgfmathparse + +do +-- all globals will be read from/defined in pgfplots: +local _ENV = pgfplots +----------------------------------- + +local pgftonumber =pgfluamathfunctions.tonumber + +Coord = newClass() + +function Coord:constructor() + self.x = { nil, nil, nil } + self.unboundedDir = nil + self.meta= nil + self.metatransformed = nil -- assigned during vis phase only + self.unfiltered = nil + self.pgfXY = nil -- assigned during visphase only + return self +end + +function Coord:copy(other) + for i = 1,#other.x do self.x[i] = other.x[i] end + self.meta = other.meta + self.metatransformed = other.metatransformed + self.unfiltered = nil -- not needed +end + +function Coord:__tostring() + local result = '(' .. stringOrDefault(self.x[1], "--") .. + ',' .. stringOrDefault(self.x[2], "--") .. + ',' .. stringOrDefault(self.x[3], "--") .. + ') [' .. stringOrDefault(self.meta, "--") .. ']' + + if not self.x[1] and self.unfiltered then + result = result .. "(was " .. tostring(self.unfiltered) .. ")" + end + return result +end + +local stringToFunctionMap = pgfluamathfunctions.stringToFunctionMap + +-- a reference to a Coord which is returned by math expressions involving 'x', 'y', or 'z' +-- see surveystart() +local pseudoconstant_pt = nil +local function pseudoconstant_x() return pseudoconstant_pt.x[1] end +local function pseudoconstant_y() return pseudoconstant_pt.x[2] end +local function pseudoconstant_z() return pseudoconstant_pt.x[3] end +local function pseudoconstant_rawx() return pgftonumber(pseudoconstant_pt.unfiltered.x[1]) end +local function pseudoconstant_rawy() return pgftonumber(pseudoconstant_pt.unfiltered.x[2]) end +local function pseudoconstant_rawz() return pgftonumber(pseudoconstant_pt.unfiltered.x[3]) end +local function pseudoconstant_meta() return pseudoconstant_pt.meta end + +-- @return the old value +local function updatePseudoConstants(pt) + local old = pseudoconstant_pt + pseudoconstant_pt = pt + return old +end + +------------------------------------------------------- + +LinearMap = newClass() + +-- A map such that +-- [inMin,inMax] is mapped linearly to [outMin,outMax] +-- +function LinearMap:constructor(inMin, inMax, outMin, outMax) + if not inMin or not inMax or not outMin or not outMax then error("arguments must not be nil") end + if inMin == inMax then + self.map = function (x) return inMin end + else + if inMin > inMax then error("linear map received invalid input domain " .. tostring(inMin) .. ":" .. tostring(inMax)) end + self.offset = outMin - (outMax-outMin)*inMin/(inMax-inMin) + self.scale = (outMax-outMin)/(inMax-inMin) + end +end + +function LinearMap:map(x) + return x*self.scale + self.offset +end + +PointMetaMap = newClass() + +function PointMetaMap:constructor(inMin,inMax, warnForfilterDiscards) + if not inMin or not inMax or warnForfilterDiscards == nil then error("arguments must not be nil") end + self._mapper = LinearMap.new(inMin,inMax, 0, 1000) + self.warnForfilterDiscards = warnForfilterDiscards +end + +function PointMetaMap:map(meta) + if pgfplotsmath.isfinite(meta) then + local result = self._mapper:map(meta) + result = math.max(0, result) + result = math.min(1000, result) + return result + else + if self.warnForfilterDiscards then + log("The per point meta data '" .. tostring(meta) .. " (and probably others as well) is unbounded - using the minimum value instead.\n") + self.warnForfilterDiscards=false + end + return 0 + end +end + + + +------------------------------------------------------- + +-- Abstract base class of all plot handlers. +-- It offers basic functionality for the survey phase. +Plothandler = newClass() + +-- @param name the plot handler's name (a string) +-- @param axis the parent axis +-- @param pointmetainputhandler an instance of PointMetaHandler or nil if there is none +function Plothandler:constructor(name, axis, pointmetainputhandler) + if not name or not axis then + error("arguments must not be nil") + end + self.axis = axis + self.config = PlothandlerConfig.new() + self.name = name + self.coordindex = 0 + self.metamin = math.huge + self.metamax = -math.huge + self.autocomputeMetaMin = true + self.autocomputeMetaMax = true + self.coords = {} + self.pointmetainputhandler = pointmetainputhandler + self.pointmetamap = nil -- will be set later + self.filteredCoordsAway = false + self.plotHasJumps = false + -- will be set before the visualization phase starts. At least. + self.plotIs3d = false + return self +end + +function Plothandler:__tostring() + return 'plot handler ' .. self.name +end + +-- @see \pgfplotsplothandlersurveybeforesetpointmeta +function Plothandler:surveyBeforeSetPointMeta() +end + +-- @see \pgfplotsplothandlersurveyaftersetpointmeta +function Plothandler:surveyAfterSetPointMeta() +end + +-- PRIVATE +-- +-- appends a fully surveyed point +function Plothandler:addSurveyedPoint(pt) + table.insert(self.coords, pt) + -- log("addSurveyedPoint(" .. tostring(pt) .. ") ...\n") +end + +-- PRIVATE +-- +-- assigns the point meta value by means of the PointMetaHandler +function Plothandler:setperpointmeta(pt) + if pt.meta == nil and self.pointmetainputhandler ~= nil then + self.pointmetainputhandler:assign(pt) + end +end + +-- PRIVATE +-- +-- updates point meta limits +function Plothandler:setperpointmetalimits(pt) + if pt.meta ~= nil then + if not type(pt.meta) == 'number' then error("got unparsed input "..tostring(pt)) end + if self.autocomputeMetaMin then + self.metamin = math.min(self.metamin, pt.meta ) + end + + if self.autocomputeMetaMax then + self.metamax = math.max(self.metamax, pt.meta ) + end + end +end + +-- @see \pgfplotsplothandlersurveystart +function Plothandler:surveystart() + stringToFunctionMap["x"] = pseudoconstant_x + stringToFunctionMap["y"] = pseudoconstant_y + stringToFunctionMap["z"] = pseudoconstant_z + stringToFunctionMap["rawx"] = pseudoconstant_rawx + stringToFunctionMap["rawy"] = pseudoconstant_rawy + stringToFunctionMap["rawz"] = pseudoconstant_rawz + stringToFunctionMap["meta"] = pseudoconstant_meta +end + +-- @see \pgfplotsplothandlersurveyend +-- returns executable TeX code to communicate return values. +function Plothandler:surveyend() + -- empty by default. + return "" +end + +-- @see \pgfplotsplothandlersurveypoint +function Plothandler:surveypoint(pt) + updatePseudoConstants(nil) + + local updateLimits = self.config.updateLimits + local current = self.axis:parsecoordinate(pt, self.config.filterExpressionByDir) + + -- this here defines the math functions for x, y, or z. + -- FIXME: are there any hidden callers which rely on these constants in parsecoordinate!? + updatePseudoConstants(current) + + if current.x[1] ~= nil then + current = self.axis:preparecoordinate(current) + if updateLimits then + self.axis:updatelimitsforcoordinate(current) + end + end + self.axis:datapointsurveyed(current, self) + + self.coordindex = self.coordindex + 1; +end + +-- PUBLIC +-- +-- @return a string containing all surveyed coordinates in the format which is accepted \pgfplotsaxisdeserializedatapointfrom +function Plothandler:surveyedCoordsToPgfplots(axis) + return self:getCoordsInTeXFormat(axis, self.coords) +end + +-- PUBLIC +-- +-- @return a string containing all coordinates in the format which is accepted \pgfplotsaxisdeserializedatapointfrom +-- @param extraSerializer a function which takes an instance of Coord and returns a string. can be nil. +function Plothandler:getCoordsInTeXFormat(axis, coords, extraSerializer) + if not axis then error("arguments must not be nil") end + local result = {} + for i = 1,#coords,1 do + local pt = coords[i] + local ptstr = self:serializeCoordToPgfplots(pt) + local axisPrivate = axis:serializeCoordToPgfplotsPrivate(pt) + if extraSerializer then + axisPrivate = extraSerializer(pt) .. "{" .. axisPrivate .. "}" + end + local serialized = "{" .. axisPrivate .. ";" .. ptstr .. "}" + table.insert(result, serialized) + end + return table.concat(result) +end + +-- PRIVATE +-- +-- does the same as \pgfplotsplothandlerserializepointto +function Plothandler:serializeCoordToPgfplots(pt) + return + toTeXstring(pt.x[1]) .. "," .. + toTeXstring(pt.x[2]) .. "," .. + toTeXstring(pt.x[3]) +end + +function Plothandler:visualizationPhaseInit() + if self.pointmetainputhandler ~=nil then + local rangeMin + local rangeMax + if self.config.pointmetarel == PointMetaRel.axiswide then + rangeMin = self.axis.axiswidemetamin + rangeMax = self.axis.axiswidemetamax + else + rangeMin = self.metamin + rangeMax = self.metamax + end + self.pointmetamap = PointMetaMap.new(rangeMin, rangeMax, self.config.warnForfilterDiscards) + end +end + +-- PRECONDITION: visualizationPhaseInit() has been called some time before. +function Plothandler:visualizationTransformMeta(meta) + if meta == nil then + log("could not access the 'point meta' (used for example by scatter plots and color maps). Maybe you need to add '\\addplot[point meta=y]' or something like that?\n") + return 1 + else + return self.pointmetamap:map(meta) + end +end + +-- Modifies coords inplace. +-- @return nothing. +-- see \pgfplots@apply@zbuffer@sort@coordinates +function Plothandler:sortCoordinatesByViewDepth() + local coords = self.coords + + local axis = self.axis + local viewdir = axis.viewdir + + -- Step 1: compute view depth for every coordinate + local getVertexDepth = axis.getVertexDepth + for i=1,#coords do + local vertexDepth = getVertexDepth(axis,coords[i]) + coords[i].vertexDepth = vertexDepth + end + + -- Step 2: sort (inplace) + local comparator = function(ptA, ptB) + return ptA.vertexDepth > ptB.vertexDepth + end + table.sort(coords, comparator) + + -- Step 3: cleanup: do not leave 'vertexDepth' inside of the array + for i=1,#coords do + coords[i].vertexDepth = nil + end +end + +------------------------------------------------------- +-- Generic plot handler: one which has the default survey phase +-- It is actually the same as Plothandler... + +GenericPlothandler = newClassExtends(Plothandler) + +function GenericPlothandler:constructor(name, axis, pointmetainputhandler) + Plothandler.constructor(self,name, axis, pointmetainputhandler) +end + + +------------------------------------------------------- + +UnboundedCoords = { discard="d", jump="j" } + +PointMetaRel = { axiswide = 0, perplot =1 } + + +-- contains static configuration entities. +PlothandlerConfig = newClass() + +function PlothandlerConfig:constructor() + self.unboundedCoords = UnboundedCoords.discard + self.warnForfilterDiscards=true + self.pointmetarel = PointMetaRel.axiswide + self.updateLimits = true + self.filterExpressionByDir = {"", "", ""} + return self +end + +------------------------------------------------------- +-- a PlotVisualizer takes an input Plothandler and visualizes its results. +-- +-- "Visualize" can mean +-- * apply the plot handler's default visualization phase +-- * visualize just plot marks at each of the collected coordinates +-- * visualize just error bars at each collected coordinate +-- * ... +-- + +-- this class offers basic visualization support. "Basic" means that it will merely transform and finalize input coordinates. +PlotVisualizer = newClass() +-- @param sourcePlotHandler an instance of Plothandler +function PlotVisualizer:constructor(sourcePlotHandler) + if not sourcePlotHandler then error("arguments must not be nil") end + self.axis = sourcePlotHandler.axis + self.sourcePlotHandler=sourcePlotHandler + if sourcePlotHandler.plotIs3d then + self.qpointxyz = self.axis.qpointxyz + else + self.qpointxyz = self.axis.qpointxy + end +end + +-- Visualizes the results. +-- +-- @return any results. The format of the results is currently a list of Coord, but I am unsure of whether it will stay this way. +-- +-- Note that a PlotVisualizer does _not_ modify self.sourcePlotHandler.coords +function PlotVisualizer:getVisualizationOutput() + local result = {} + local coords = self.sourcePlotHandler.coords + + -- standard z buffer choices (not mesh + sort) is currently handled in TeX + -- as well as other preparations + + -- FIXME : stacked plots? + -- FIXME : error bars? + + for i = 1,#coords do + local result_i + local result_i = Coord.new() + result_i:copy(coords[i]) + + if result_i.x[1] ~= nil then + self:visphasegetpoint(result_i) + else + self:notifyJump(result_i) + end + + result[i] = result_i + end + + return result +end + +-- PROTECTED +-- resembles \pgfplotsplothandlervisualizejump -- or at least that part which can be done in LUA. +-- It does not visualize anything, but it can be used to modify the coordinate +function PlotVisualizer:notifyJump(pt) + -- do nothing. +end + +function PlotVisualizer:visphasegetpoint(pt) + pt.untransformed = {} + for j = 1,#pt.x do + pt.untransformed[j] = pt.x[j] + end + + self.axis:visphasetransformcoordinate(pt) + + -- FIXME : prepare data point (only for stacked) + + pt.pgfXY = self.qpointxyz(pt.x) +end + + + +------------------------------------------------------- + +-- An abstract base class for a handler of point meta. +-- @see \pgfplotsdeclarepointmetasource +PointMetaHandler = newClass() + +-- @param isSymbolic +-- expands to either '1' or '0' +-- A numeric source will be processed numerically in float +-- arithmetics. Thus, the output of the @assign routine should be +-- a macro \pgfplots@current@point@meta in float format. +-- +-- The output of a numeric point meta source will result in meta +-- limit updates and the final map to [0,1000] will be +-- initialised automatically. +-- +-- A symbolic input routine won't be processed. +-- Default is '0' +-- +-- @param explicitInput +-- expands to either +-- '1' or '0'. In case '1', it expects explicit input from the +-- coordinate input routines. For example, 'plot file' will look for +-- further input after the x,y,z coordinates. +-- Default is '0' +-- +function PointMetaHandler:constructor(isSymbolic, explicitInput) + self.isSymbolic =isSymbolic + self.explicitInput = explicitInput + return self +end + +-- During the survey phase, this macro is expected to assign +-- \pgfplots@current@point@meta +-- if it is a numeric input method, it should return a +-- floating point number. +-- It is allowed to return an empty string to say "there is no point +-- meta". +-- PRECONDITION for '@assign': +-- - the coordinate input method has already assigned its +-- '\pgfplots@current@point@meta' (probably as raw input string). +-- - the other input coordinates are already read. +-- POSTCONDITION for '@assign': +-- - \pgfplots@current@point@meta is ready for use: +-- - EITHER a parsed floating point number +-- - OR an empty string, +-- - OR a symbolic string (if the issymbolic boolean is true) +-- The default implementation is +-- \let\pgfplots@current@point@meta=\pgfutil@empty +-- +function PointMetaHandler.assign(pt) + error("This instance of PointMetaHandler is not implemented") +end + + +-- A PointMetaHandler which merely acquires values of either x,y, or z. +CoordAssignmentPointMetaHandler = newClassExtends( PointMetaHandler ) +function CoordAssignmentPointMetaHandler:constructor(dir) + PointMetaHandler.constructor(self, false,false) + if not dir then error "nil argument for 'dir' is unsupported." end + self.dir=dir +end + +function CoordAssignmentPointMetaHandler:assign(pt) + if not pt then error("arguments must not be nil") end + pt.meta = pgftonumber(pt.x[self.dir]) +end + +XcoordAssignmentPointMetaHandler = CoordAssignmentPointMetaHandler.new(1) +YcoordAssignmentPointMetaHandler = CoordAssignmentPointMetaHandler.new(2) +ZcoordAssignmentPointMetaHandler = CoordAssignmentPointMetaHandler.new(3) + +-- A class of PointMetaHandler which takes the 'Coord.meta' as input +ExplicitPointMetaHandler = newClassExtends( PointMetaHandler ) +function ExplicitPointMetaHandler:constructor() + PointMetaHandler.constructor(self, false,true) +end + +function ExplicitPointMetaHandler:assign(pt) + if pt.unfiltered ~= nil and pt.unfiltered.meta ~= nil then + pt.meta = pgftonumber(pt.unfiltered.meta) + end +end + +-- a point meta handler which evaluates a math expression. +-- ATTENTION: the expression cannot depend on TeX macro values +ExpressionPointMetaHandler = newClassExtends( PointMetaHandler ) + +-- @param expression an expression. It can rely on functions which are only available in plot context (in plot expression, x and y are typically defined) +function ExpressionPointMetaHandler:constructor(expression) + PointMetaHandler.constructor(self, false,false) + self.expression = expression +end + +function ExpressionPointMetaHandler:assign(pt) + pt.meta = pgfmathparse(self.expression) + if not pt.meta then + error("point meta=" .. self.expression .. ": expression has been rejected.") + end +end + + +------------------------------------------------------- + +DatascaleTrafo = newClass() + +function DatascaleTrafo:constructor(exponent, shift) + self.exponent=exponent + self.shift=shift + self.scale = math.pow(10, exponent) +end + +function DatascaleTrafo:map(x) + return self.scale * x - self.shift +end + + +------------------------------------------------------- + +-- An axis. +Axis = newClass() + +function Axis:constructor() + self.is3d = false + self.clipLimits = true + self.autocomputeAllLimits = true -- FIXME : redundant!? + self.autocomputeMin = { true, true, true } + self.autocomputeMax = { true, true, true } + self.isLinear = { true, true, true } + self.min = { math.huge, math.huge, math.huge } + self.max = { -math.huge, -math.huge, -math.huge } + self.datamin = { math.huge, math.huge, math.huge } + self.datamax = { -math.huge, -math.huge, -math.huge } + self.axiswidemetamin = { math.huge, math.huge } + self.axiswidemetamax = { -math.huge, -math.huge } + -- will be populated by the TeX code: + self.plothandlers = {} + -- needed during visualization phase: + self.datascaleTrafo={} + -- needed during visualization phase: a vector of 3 elements, each is a vector of 2 elements. + -- self.unitvectors[1] is (\pgf@xx,\pgf@xy) + self.unitvectors={} + -- needed during visualization phase -- but only for 3d! + self.viewdir = {} + return self +end + +function Axis:getVertexDepth(pt) + local vertexDepth = 0 + local vertex = pt.x + local viewdir = self.viewdir + if vertex[1] == nil then + -- an empty coordinate. Get rid of it. + return 0 + end + + if #vertex ~=3 then + error("Cannot compute vertex depth of " .. tostring(pt) .. ": expected a 3d point but got " .. tostring(#vertex)) + end + if not viewdir or #viewdir~=3 then error("got unexpected view dir " ..tostring(viewdir) ) end + + for k = 1,3 do + local component = vertex[k] + vertexDepth = vertexDepth + component*viewdir[k] + end + + return vertexDepth +end + +function Axis:setunitvectors(unitvectors) + if not unitvectors or #unitvectors ~= 3 then error("got illegal arguments " .. tostring(unitvectors)) end + self.unitvectors = unitvectors + + local pgfxx = unitvectors[1][1] + local pgfxy = unitvectors[1][2] + local pgfyx = unitvectors[2][1] + local pgfyy = unitvectors[2][2] + local pgfzx = unitvectors[3][1] + local pgfzy = unitvectors[3][2] + + self.qpointxyz = function(xyz) + local result = {} + result[1] = xyz[1] * pgfxx + xyz[2] * pgfyx + xyz[3] * pgfzx + result[2] = xyz[1] * pgfxy + xyz[2] * pgfyy + xyz[3] * pgfzy + return result + end + + if pgfxy==0 and pgfyx ==0 then + self.qpointxy = function(xy) + local result = {} + result[1] = xy[1] * pgfxx + result[2] = xy[2] * pgfyy + return result + end + else + self.qpointxy = function(xyz) + local result = {} + result[1] = xyz[1] * pgfxx + xyz[2] * pgfyx + result[2] = xyz[1] * pgfxy + xyz[2] * pgfyy + return result + end + end +end + +-- PRIVATE +-- +-- applies user transformations and logs +-- +-- @see \pgfplots@prepared@xcoord +function Axis:preparecoord(dir, value) + -- FIXME : user trafos, logs (switches off LUA backend) + return value +end + +function Axis:filtercoord(dir, ptCoords, filterExpressionByDir) + if not dir or not ptCoords or not filterExpressionByDir then error("Arguments must not be nil") end + local result = ptCoords.x[dir] + if filterExpressionByDir[dir]:len() > 0 then + + for j = 1,#ptCoords.x do + ptCoords.x[j] = pgftonumber(ptCoords.x[j]) + end + local old = updatePseudoConstants(ptCoords) + + result = pgfmathparse(filterExpressionByDir[dir]) + + updatePseudoConstants(old) + end + return result +end + +-- PRIVATE +-- @see \pgfplotsaxisserializedatapoint@private +function Axis:serializeCoordToPgfplotsPrivate(pt) + return toTeXstring(pt.meta) +end + + +-- PRIVATE +-- +function Axis:validatecoord(dir, point) + if not dir or not point then error("arguments must not be nil") end + local result = pgftonumber(point.x[dir]) + + if result == nil then + result = nil + elseif result == pgfplotsmath.infty or result == -pgfplotsmath.infty or pgfplotsmath.isnan(result) then + result = nil + point.unboundedDir = dir + end + + point.x[dir] = result +end + +-- PRIVATE +-- +-- @see \pgfplotsaxisparsecoordinate +function Axis:parsecoordinate(pt, filterExpressionByDir) + -- replace empty strings by 'nil': + for i = 1,3 do + pt.x[i] = stringOrDefault(pt.x[i], nil) + end + pt.meta = stringOrDefault(pt.meta) + + if pt.x[3] ~= nil then + self.is3d = true + end + + local result = Coord.new() + + local unfiltered = Coord.new() + unfiltered.x = {} + unfiltered.meta = pt.meta + for i = 1,3 do + unfiltered.x[i] = pt.x[i] + end + result.unfiltered = unfiltered + + -- copy values such that filtercoord can access them in the same order as the TeX impl. + for i = 1,self:loopMax() do + result.x[i] = pt.x[i] + end + + -- FIXME : self:prefilter(pt[i]) + for i = 1,self:loopMax() do + result.x[i] = self:preparecoord(i, pt.x[i]) + result.x[i] = self:filtercoord(i, result, filterExpressionByDir) + end + -- FIXME : result.x = self:xyzfilter(result.x) + + for i = 1,self:loopMax() do + self:validatecoord(i, result) + end + + local resultIsBounded = true + for i = 1,self:loopMax() do + if result.x[i] == nil then + resultIsBounded = false + end + end + + if not resultIsBounded then + result.x = { nil, nil, nil} + end + + return result +end + +-- PROTECTED +-- +-- @see \pgfplotsaxispreparecoordinate +function Axis:preparecoordinate(pt) + -- the default "preparation" is to return it as is (no number parsing) + -- + -- FIXME : data cs! Stacking! + return pt +end + +-- PRIVATE +-- +-- returns either 2 if this axis is 2d or 3 otherwise +-- +-- FIXME : shouldn't this depend on the current plot handler!? +function Axis:loopMax() + if self.is3d then return 3 else return 2 end +end + +-- PRIVATE: +-- +-- updates axis limits for pt +-- @param pt an instance of Coord +function Axis:updatelimitsforcoordinate(pt) + local isClipped = false + if self.clipLimits then + for i = 1,self:loopMax(),1 do + if not self.autocomputeMin[i] then + isClipped = isClipped or pt.x[i] < self.min[i] + end + if not self.autocomputeMax[i] then + isClipped = isClipped or pt.x[i] > self.max[i] + end + end + end + + if not isClipped then + for i = 1,self:loopMax(),1 do + if self.autocomputeMin[i] then + self.min[i] = math.min(pt.x[i], self.min[i]) + end + + if self.autocomputeMax[i] then + self.max[i] = math.max(pt.x[i], self.max[i]) + end + end + end + + -- Compute data range: + if self.autocomputeAllLimits then + -- the data range will be acquired simply from the axis + -- range, see below! + else + for i = 1,self:loopMax(),1 do + self.datamin[i] = math.min(pt.x[i], self.min[i]) + self.datamax[i] = math.max(pt.x[i], self.max[i]) + end + end +end + +-- PRIVATE +-- +-- unfinished, see its fixmes +function Axis:addVisualizationDependencies(pt) + -- FIXME : 'visualization depends on' + -- FIXME : 'execute for finished point' + return pt +end + +-- PROTECTED +-- +-- indicates that a data point has been surveyed by the axis and that it can be consumed +function Axis:datapointsurveyed(pt, plothandler) + if not pt or not plothandler then error("arguments must not be nil") end + if pt.x[1] ~= nil then + plothandler:surveyBeforeSetPointMeta() + plothandler:setperpointmeta(pt) + plothandler:setperpointmetalimits(pt) + plothandler:surveyAfterSetPointMeta() + + -- FIXME : error bars + -- FIXME: collect first plot as tick + + -- note that that TeX code would also remember the first/last coordinate in a stream. + -- This is unnecessary here. + + local serialized = self:addVisualizationDependencies(pt) + plothandler:addSurveyedPoint(serialized) + else + -- COORDINATE HAS BEEN FILTERED AWAY + if plothandler.config.unboundedCoords == UnboundedCoords.discard then + plothandler.filteredCoordsAway = true + if plothandler.config.warnForfilterDiscards then + local reason + if pt.unboundedDir == nil then + reason = "of a coordinate filter." + else + reason = "it is unbounding (in " .. tostring(pt.unboundedDir) .. ")." + end + log("NOTE: coordinate " .. tostring(pt) .. " has been dropped because " .. reason .. "\n") + end + elseif plothandler.config.unboundedCoords == UnboundedCoords.jump then + if pt.unboundedDir == nil then + plothandler.filteredCoordsAway = true + if plothandler.config.warnForfilterDiscards then + local reason = "of a coordinate filter." + log("NOTE: coordinate " .. tostring(pt) .. " has been dropped because " .. reason .. "\n") + end + else + plothandler.plotHasJumps = true + + local serialized = self:addVisualizationDependencies(pt) + plothandler:addSurveyedPoint(serialized) + end + end + end + + -- note that the TeX variant would increase the coord index here. + -- We do it it surveypoint. +end + +local function axisLimitToTeXString(name, value) + if value == math.huge or value == -math.huge then + return "" + end + return "\\gdef" .. name .. "{" .. toTeXstring(value) .. "}" +end + +local function toTeXxyzCoord(namePrefix, pt ) + local x = toTeXstring(pt.x[1]) + local y = toTeXstring(pt.x[2]) + local z = toTeXstring(pt.x[3]) + return + "\\gdef" .. namePrefix .. "@x{" .. x .. "}" .. + "\\gdef" .. namePrefix .. "@y{" .. y .. "}" .. + "\\gdef" .. namePrefix .. "@z{" .. z .. "}"; +end + +local function findFirstValidCoord(coords) + for i=1,#coords do + local pt = coords[i] + if pt.x[1] ~=nil then + return pt + end + end + return nil +end + +local function findLastValidCoord(coords) + for i=#coords,1,-1 do + local pt = coords[i] + if pt.x[1] ~=nil then + return pt + end + end + return nil +end + +-- PUBLIC +-- +-- @return a set of (private) key-value pairs such that the TeX code of pgfplots can +-- access survey results of the provided plot handler +-- +-- @param plothandler an instance of Plothandler +function Axis:surveyToPgfplots(plothandler) + local plothandlerResult = plothandler:surveyend() + local firstCoord = findFirstValidCoord(plothandler.coords) or Coord.new() + local lastCoord = findLastValidCoord(plothandler.coords) or Coord.new() + + local result = + plothandlerResult .. + toTeXxyzCoord("\\pgfplots@currentplot@firstcoord", firstCoord) .. + toTeXxyzCoord("\\pgfplots@currentplot@lastcoord", lastCoord) .. + axisLimitToTeXString("\\pgfplots@metamin", plothandler.metamin) .. + axisLimitToTeXString("\\pgfplots@metamax", plothandler.metamax) .. + "\\c@pgfplots@coordindex=" .. tostring(plothandler.coordindex) .. " " .. + axisLimitToTeXString("\\pgfplots@xmin", self.min[1]) .. + axisLimitToTeXString("\\pgfplots@ymin", self.min[2]) .. + axisLimitToTeXString("\\pgfplots@xmax", self.max[1]) .. + axisLimitToTeXString("\\pgfplots@ymax", self.max[2]); + if self.is3d then + result = result .. + axisLimitToTeXString("\\pgfplots@zmin", self.min[3]) .. + axisLimitToTeXString("\\pgfplots@zmax", self.max[3]) .. + "\\global\\pgfplots@threedimtrue "; + end + if plothandler.plotHasJumps then + result = result .. + "\\def\\pgfplotsaxisplothasjumps{1}" + else + result = result .. + "\\def\\pgfplotsaxisplothasjumps{0}" + end + if plothandler.filteredCoordsAway then + result = result .. + "\\def\\pgfplotsaxisfilteredcoordsaway{1}" + else + result = result .. + "\\def\\pgfplotsaxisfilteredcoordsaway{0}" + end + + return result +end + +-- resembles \pgfplotsaxisvisphasetransformcoordinate +function Axis:visphasetransformcoordinate(pt) + for i = 1,#pt.x do + pt.x[i] = self.datascaleTrafo[i]:map( pt.x[i] ) + end +end + +-- will be set by TeX code (in \begin{axis}) +gca = nil + + +end diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/statistics.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/statistics.lua new file mode 100644 index 0000000..5735025 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/statistics.lua @@ -0,0 +1,400 @@ +-- This file has dependencies to BOTH, the TeX part of pgfplots and the LUA part. +-- It is the only LUA component with this property. +-- +-- Its purpose is to encapsulate the communication between TeX and LUA in a central LUA file + +local pgfplotsmath = pgfplots.pgfplotsmath +local error=error +local table=table +local string=string +local tostring=tostring +local type=type +local io=io +local mathfloor=math.floor +local mathceil=math.ceil +local pgfmathparse = pgfplots.pgfluamathparser.pgfmathparse + +do +-- all globals will be read from/defined in pgfplots: +local _ENV = pgfplots + +local pgftonumber =pgfluamathfunctions.tonumber + +function texBoxPlotSurveyPoint(data) + gca.currentPlotHandler:semiSurveyedValue(data) +end + +------------------------------------------------------- + +PercentileEstimator = newClass() + +function PercentileEstimator:constructor() +end + +function PercentileEstimator:getIndex(data, i) + local idx = i + if idx < 1 then idx = 1 end + if idx > #data then idx = #data end + + local result = data[idx] + if not result then + error("Box plot percentile estimator '" .. tostring(self) .." accessed illegal array index " .. tostring(idx) .. " in array of length " .. tostring(#data)) + end + return result +end + + +-- @param percentile the requested percentile. Use 0.5 for the median, 0.25 for the first quartile, 0.95 for the 95% percentile etc. +function PercentileEstimator:getValue(percentile, data) + error("Use implementation of PercentileEstimator, not interface") +end + +-- LegacyPgfplotsPercentileEstimator is a minimally repaired percentile estimator as it has been shipped with pgfplots.10 . +-- I decided to mark it as deprecated because it is non-standard and not comparable with other programs. +LegacyPgfplotsPercentileEstimator = newClassExtends(PercentileEstimator) +function LegacyPgfplotsPercentileEstimator:constructor() +end +function LegacyPgfplotsPercentileEstimator:__tostring() + return "estimator=legacy"; +end +function LegacyPgfplotsPercentileEstimator:getValue(percentile, data) + if not percentile or not data then error("Arguments must not be nil") end + local numCoords = #data + local h = numCoords * percentile + + local offset_low = mathfloor(h) + local isInt = ( h==offset_low ) + + local offset_high = offset_low+1 + + local x_low = self:getIndex(data, offset_low) + local x_up = self:getIndex(data, offset_high) + local res = x_low + if not isInt then + res = 0.5 * (res + x_up) + end + return res +end + +-- LegacyBadPgfplotsPercentileEstimator is _the_ percentile estimator as it has been shipped with pgfplots 1.10. +-- It has bugs and is non-standard. Don't use it. +LegacyBadPgfplotsPercentileEstimator = newClassExtends(PercentileEstimator) +function LegacyBadPgfplotsPercentileEstimator:constructor() +end +function LegacyBadPgfplotsPercentileEstimator:__tostring() + return "estimator=legacy*"; +end +function LegacyBadPgfplotsPercentileEstimator:getValue(percentile, data) + if not percentile or not data then error("Arguments must not be nil") end + local numCoords = #data + local h = (numCoords-1) * percentile + + local offset_low = mathfloor(h) + local isInt = ( h==offset_low ) + + local offset_high = offset_low+1 + + local x_low = self:getIndex(data, offset_low+1) + local x_up = self:getIndex(data, offset_high+1) + local res = x_low + if not isInt then + res = 0.5 * (res + x_up) + end + return res +end +---------------- + +ParameterizedPercentileEstimator = newClassExtends(PercentileEstimator) + +function ParameterizedPercentileEstimator:__tostring() + return "estimator=" .. tostring(self.typeFlag) ; +end + +function ParameterizedPercentileEstimator:constructor( typeFlag ) + -- http://en.wikipedia.org/wiki/Quantile + self.typeFlag = typeFlag + + local getIndex = self.getIndex + + local stdLookup = function(data, h ) + local h_low = mathfloor(h) + local x_low = getIndex(self, data, h_low ) + local x_up = getIndex(self, data, h_low +1 ) + return x_low + (h - h_low) * (x_up - x_low) + end + + if typeFlag == 1 then + -- R1 + self.getValue = function(self, percentile, data) + local h= #data * percentile + return getIndex(self, data, mathceil(h) ) + end + elseif typeFlag == 2 then + -- R2 + self.getValue = function(self, percentile, data) + local h= #data * percentile + 0.5 + return 0.5*(getIndex(self, data, mathceil(h-0.5)) + getIndex(self, data, mathfloor(h+0.5) ) ) + end + elseif typeFlag == 3 then + -- R3 + self.getValue = function(self, percentile, data) + local h= #data * percentile + return getIndex(self, data, pgfluamathfunctions.round(h) ) + end + elseif typeFlag == 4 then + -- R4 + self.getValue = function(self, percentile, data) + local h= #data * percentile + return stdLookup(data,h) + end + elseif typeFlag == 5 then + -- R5 + self.getValue = function(self, percentile, data) + local h= #data * percentile + 0.5 + return stdLookup(data,h) + end + elseif typeFlag == 6 then + -- R6 + self.getValue = function(self, percentile, data) + local h= (#data +1) * percentile + return stdLookup(data,h) + end + elseif typeFlag == 7 then + -- R7 (Excel) + self.getValue = function(self, percentile, data) + local h= (#data -1) * percentile + 1 + return stdLookup(data,h) + end + elseif typeFlag == 8 then + -- R8 + self.getValue = function(self, percentile, data) + local h= (#data + 1/3) * percentile + 1/3 + return stdLookup(data,h) + end + elseif typeFlag == 9 then + -- R9 + self.getValue = function(self, percentile, data) + local h= (#data + 1/4) * percentile + 3/8 + return stdLookup(data,h) + end + else + error("Got unsupported type '" .. tostring(typeFlag) .. "'") + end +end + + +getPercentileEstimator = function(estimatorName) + if estimatorName == "legacy" then + return LegacyPgfplotsPercentileEstimator.new() + elseif estimatorName == "legacy*" then + return LegacyBadPgfplotsPercentileEstimator.new() + elseif estimatorName == "R1" then + return ParameterizedPercentileEstimator.new(1) + elseif estimatorName == "R2" then + return ParameterizedPercentileEstimator.new(2) + elseif estimatorName == "R3" then + return ParameterizedPercentileEstimator.new(3) + elseif estimatorName == "R4" then + return ParameterizedPercentileEstimator.new(4) + elseif estimatorName == "R5" then + return ParameterizedPercentileEstimator.new(5) + elseif estimatorName == "R6" then + return ParameterizedPercentileEstimator.new(6) + elseif estimatorName == "R7" then + return ParameterizedPercentileEstimator.new(7) + elseif estimatorName == "R8" then + return ParameterizedPercentileEstimator.new(8) + elseif estimatorName == "R9" then + return ParameterizedPercentileEstimator.new(9) + end + + error("Unknown estimator '" .. tostring(estimatorName) .. "'") +end + +BoxPlotRequest = newClass() + +-- @param lowerQuartialPercent: typically 0.25 +-- @param upperQuartialPercent: typically 0.75 +-- @param whiskerRange: typically 1.5 +-- @param estimator: an instance of PercentileEstimator +-- @param morePercentiles: either nil or an array of percentiles to compute +function BoxPlotRequest:constructor(lowerQuartialPercent, upperQuartialPercent, whiskerRange, estimator, morePercentiles) + if not lowerQuartialPercent or not upperQuartialPercent or not whiskerRange or not estimator then error("Arguments must not be nil") end + self.lowerQuartialPercent = pgftonumber(lowerQuartialPercent) + self.upperQuartialPercent = pgftonumber(upperQuartialPercent) + self.whiskerRange = pgftonumber(whiskerRange) + self.estimator = estimator + if not morePercentiles then + self.morePercentiles = {} + else + self.morePercentiles = morePercentiles + end +end + +------------------------------------------------------- + +BoxPlotResponse = newClass() + +function BoxPlotResponse:constructor() + self.lowerWhisker = nil + self.lowerQuartile = nil + self.median = nil + self.upperQuartile = nil + self.upperWhisker = nil + self.average = nil + self.morePercentiles = {} + self.outliers = {} +end + +-- @param boxPlotRequest an instance of BoxPlotRequest +-- @param data an indexed array with float values +-- @return an instance of BoxPlotResponse +function boxPlotCompute(boxPlotRequest, data) + if not boxPlotRequest or not data then error("Arguments must not be nil") end + + for i = 1,#data do + local data_i = data[i] + if data_i == nil or type(data_i) ~= "number" then + error("Illegal input array at index " .. tostring(i) .. ": " .. tostring(data_i)) + end + end + + table.sort(data) + + local sum = 0 + for i = 1,#data do + sum = sum + data[i] + end + + local numCoords = #data + + local lowerWhisker + local lowerQuartile = boxPlotRequest.estimator:getValue(boxPlotRequest.lowerQuartialPercent, data) + local median = boxPlotRequest.estimator:getValue(0.5, data) + local upperQuartile = boxPlotRequest.estimator:getValue(boxPlotRequest.upperQuartialPercent, data) + + local morePercentileValues = {} + for i = 1,#boxPlotRequest.morePercentiles do + morePercentileValues[i] = boxPlotRequest.estimator:getValue(boxPlotRequest.morePercentiles[i], data) + end + + local upperWhisker + local average = sum / numCoords + + local whiskerRange = boxPlotRequest.whiskerRange + local whiskerWidth = whiskerRange*(upperQuartile - lowerQuartile) + local upperWhiskerValue = upperQuartile + whiskerWidth + local lowerWhiskerValue = lowerQuartile - whiskerWidth + + local outliers = {} + for i = 1,numCoords do + local current = data[i] + if current < lowerWhiskerValue then + table.insert(outliers, current) + else + lowerWhisker = current + break + end + end + + for i = numCoords,1,-1 do + local current = data[i] + if upperWhiskerValue < current then + table.insert(outliers, current) + else + upperWhisker = current + break + end + end + + local result = BoxPlotResponse.new() + result.lowerWhisker = lowerWhisker + result.lowerQuartile = lowerQuartile + result.median = median + result.upperQuartile = upperQuartile + result.upperWhisker = upperWhisker + result.average = average + result.morePercentiles = morePercentileValues + result.outliers = outliers + + return result +end + +------------------------------------------------------- +-- Replicates the survey phase of \pgfplotsplothandlerboxplot +BoxPlotPlothandler = newClassExtends(Plothandler) + +-- drawDirection : either "x" or "y". +function BoxPlotPlothandler:constructor(boxPlotRequest, drawDirection, drawPosition, axis, pointmetainputhandler) + if not boxPlotRequest or not drawDirection or not drawPosition then error("Arguments must not be nil") end + Plothandler.constructor(self,"boxplot", axis, pointmetainputhandler) + self.boxPlotRequest = boxPlotRequest + + local function evaluateDrawPosition() + local result = pgfmathparse(drawPosition) + return result + end + + if drawDirection == "x" then + self.boxplotsetxy = function (a,b) return a,evaluateDrawPosition() + b end + elseif drawDirection == "y" then + self.boxplotsetxy = function (a,b) return evaluateDrawPosition() + b,a end + else + error("Illegal argument drawDirection="..tostring(drawDirection) ) + end +end + +function BoxPlotPlothandler:surveystart() + self.boxplotInput = {} + self.boxplotSurveyMode = true +end + + +function BoxPlotPlothandler:surveyend() + self.boxplotSurveyMode = false + + local computed = boxPlotCompute( self.boxPlotRequest, self.boxplotInput ) + + local texResult = + "\\pgfplotsplothandlersurveyend@boxplot@set{lower whisker}{" .. toTeXstring(computed.lowerWhisker) .. "}" .. + "\\pgfplotsplothandlersurveyend@boxplot@set{lower quartile}{" .. toTeXstring(computed.lowerQuartile) .. "}" .. + "\\pgfplotsplothandlersurveyend@boxplot@set{median}{" .. toTeXstring(computed.median) .. "}" .. + "\\pgfplotsplothandlersurveyend@boxplot@set{upper quartile}{" .. toTeXstring(computed.upperQuartile) .. "}" .. + "\\pgfplotsplothandlersurveyend@boxplot@set{upper whisker}{" .. toTeXstring(computed.upperWhisker) .. "}" .. + "\\pgfplotsplothandlersurveyend@boxplot@set{sample size}{" .. toTeXstring(# self.boxplotInput) .. "}" + + self.boxplotInput = nil + Plothandler.surveystart(self) + + local outliers = computed.outliers + for i =1,#outliers do + local outlier = outliers[i] + local pt = Coord.new() + -- this here resembles \pgfplotsplothandlersurveypoint@boxplot@prepared when it is invoked during boxplot: + local X,Y = self.boxplotsetxy(outlier, 0) + pt.x = { X, Y, nil } + Plothandler.surveypoint(self,pt) + end + Plothandler.surveyend(self) + + return texResult +end + +function BoxPlotPlothandler:semiSurveyedValue(data) + local result = pgftonumber(data) + if result then + table.insert( self.boxplotInput, result ) + end +end + +function BoxPlotPlothandler:surveypoint(pt) + if self.boxplotSurveyMode then + error("Unsupported Operation encountered: box plot survey in LUA are only in PARTIAL mode (i.e. only if almost all has been prepared in TeX. Use 'lua backend=false' to get around this.") + else + Plothandler.surveypoint(self,pt) + end +end + +------------------------------------------------------- + +end diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/streamer.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/streamer.lua new file mode 100644 index 0000000..ab5b605 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplots/streamer.lua @@ -0,0 +1,193 @@ +-- Contains coordinate streamers, i.e. classes which generate coordinates and stream them to some output stream + +local math=math +local pgfplotsmath = pgfplots.pgfplotsmath +local type=type +local tostring=tostring +local error=error +local table=table + +do +-- all globals will be read from/defined in pgfplots: +local _ENV = pgfplots +----------------------------------- + +CoordOutputStream = newClass() + +function CoordOutputStream:constructor() +end + +-- @param pt an instance of Coord +function CoordOutputStream:coord(pt) +end + +----------------------------------- + +SurveyCoordOutputStream = newClassExtends(CoordOutputStream) + +function SurveyCoordOutputStream:constructor(targetPlothandler) + if not targetPlothandler then error("arguments must not be nil") end + self.plothandler= targetPlothandler +end + +function SurveyCoordOutputStream:coord(pt) + self.plothandler:surveypoint(pt) +end + +------------- +-- This is a partial reimplementation of \addplot expression: it samples points -- but entirely in LUA. Only the results are serialized back to TeX. + +AddplotExpressionCoordinateGenerator = newClass() + +function AddplotExpressionCoordinateGenerator:constructor(coordoutputstream, expressionsByDimension, domainMin, domainMax, samples, variableNames) + if not coordoutputstream or not expressionsByDimension or not domainMin or not domainMax or not samples or not variableNames then error("arguments must not be nil") end + if #variableNames ~= 2 then error("Expected 2 variableNames") end + self.coordoutputstream = coordoutputstream + self.is3d = #expressionsByDimension == 3 + self.expressions = expressionsByDimension + self.domainMin = domainMin + self.domainMax = domainMax + self.samples = samples + self.variableNames = variableNames + + -- log("initialized " .. tostring(self) .. "\n") +end + +-- @return true on success or false if the operation cannot be carried out. +-- this method is a replicate of \pgfplots@addplotimpl@expression@@ +function AddplotExpressionCoordinateGenerator:generateCoords() + local stringToFunctionMap = pgfluamathfunctions.stringToFunctionMap + -- create a backup of the 'x' and 'y' math expressions which + -- have been defined in \pgfplots@coord@stream@start: + local old_global_function_x = stringToFunctionMap["x"] + local old_global_function_y = stringToFunctionMap["y"] + + local coordoutputstream = self.coordoutputstream + local is3d = self.is3d + local expressions = self.expressions + local xExpr = expressions[1] + local yExpr = expressions[2] + local zExpr = expressions[3] + + local domainMin = self.domainMin + local domainMax = self.domainMax + local samples = self.samples + local h = {} + for i = 1,#domainMin do + h[i] = (domainMax[i] - domainMin[i]) / (samples[i]-1) + end + + local variableNames = self.variableNames + + local x,y + local sampleLine = #samples==1 + + local function pseudoconstantx() return x end + local pseudoconstanty + if sampleLine then + if yExpr ~= variableNames[2] then + -- suppress the warning - we want to allow (x,y,x^2) in this case. + pseudoconstanty = function() return 0 end + else + local didWarn = false + pseudoconstanty = function() + if not didWarn then + log("Sorry, you can't use 'y' in this context. PGFPlots expected to sample a line, not a mesh. Please use the [mesh] option combined with [samples y>0] and [domain y!=0:0] to indicate a twodimensional input domain\n") + didWarn = true + end + return 0 + end + end + else + pseudoconstanty = function() return y end + end + + local pgfmathparse = pgfluamathparser.pgfmathparse + local prepareX + if xExpr == variableNames[1] then + prepareX = function() return x end + else + prepareX = function() return pgfmathparse(xExpr) end + end + + local prepareY + if yExpr == variableNames[2] then + prepareY = function() return y end + else + prepareY = function() return pgfmathparse(yExpr) end + end + + local function computeXYZ() + stringToFunctionMap[variableNames[1]] = pseudoconstantx + stringToFunctionMap[variableNames[2]] = pseudoconstanty + local X = prepareX() + local Y = prepareY() + local Z = nil + if is3d then + Z = pgfmathparse(zExpr) + end + + local pt = Coord.new() + pt.x = { X, Y, Z} + + -- restore 'x' and 'y' + -- FIXME : defining the resulting x/y coordinates as 'x' and 'y' constants was a really really bad idea in the first place :-( + stringToFunctionMap["x"] = old_global_function_x + stringToFunctionMap["y"] = old_global_function_y + + coordoutputstream:coord(pt) + end + + if not sampleLine then + local xmin = domainMin[1] + local ymin = domainMin[2] + local hx = h[1] + local hy = h[2] + local max_i = samples[1]-1 + local max_j = samples[2]-1 + -- samples twodimensionally (a lattice): + for j = 0,max_j do + -- FIXME : pgfplots@plot@data@notify@next@y + y = ymin + j*hy + -- log("" .. j .. "\n") + for i = 0,max_i do + -- FIXME : pgfplots@plot@data@notify@next@x + x = xmin + i*hx + computeXYZ() + end + -- FIXME : \pgfplotsplothandlernotifyscanlinecomplete + end + else + local xmin = domainMin[1] + local hx = h[1] + local max_i = samples[1]-1 + for i = 0,max_i do + -- FIXME : pgfplots@plot@data@notify@next@x + x = xmin + i*hx + computeXYZ() + end + end + + stringToFunctionMap[variableNames[1]] = nil + stringToFunctionMap[variableNames[2]] = nil + return true +end + +function AddplotExpressionCoordinateGenerator:__tostring() + local result = "AddplotExpressionCoordinateGenerator[\n" + result = result .. "\n variable(s)=" .. self.variableNames[1] .. " " .. self.variableNames[2] + result = result .. "\n expressions=" + for i = 1,#self.expressions do + result = result .. self.expressions[i] ..", " + end + result = result .. "\n domain=" .. self.domainMin[1] .. ":" .. self.domainMax[1] + result = result .. "\n samples=" .. self.samples[1] + if #self.domainMin == 2 then + result = result .. "\n domain y=" .. self.domainMin[2] .. ":" .. self.domainMax[2] + result = result .. "\n samples y=" .. self.samples[2] + end + result = result .. "]" + return result +end + +end diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/functions.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/functions.lua new file mode 100644 index 0000000..e5573f2 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/functions.lua @@ -0,0 +1,649 @@ +-------------------------------------------------------------------------------------------------- +------ This file is a copy of some part of PGF/Tikz. +------ It has been copied here to provide : +------ - compatibility with older PGF versions +------ - availability of PGF contributions by Christian Feuersaenger +------ which are necessary or helpful for pgfplots. +------ +------ For reasons of simplicity, I have copied the whole file, including own contributions AND +------ PGF parts. The copyrights are as they appear in PGF. +------ +------ Note that pgfplots has compatible licenses. +------ +------ This copy has been modified in the following ways: +------ - nested \input commands have been updated +------ +-- +-- Support for the contents of this file will NOT be done by the PGF/TikZ team. +-- Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +-- with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +-- This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +---------------------------------------------------------------------------------------------------- +-- Date of this copy: Mi 14. Jan 21:15:32 CET 2015 --- + + + +-- Copyright 2011 by Christophe Jorssen +-- +-- This file may be distributed and/or modified +-- +-- 1. under the LaTeX Project Public License and/or +-- 2. under the GNU Public License. +-- +-- See the file doc/generic/pgf/licenses/LICENSE for more details. +-- +-- $Id: functions.lua,v 1.2 2015/01/14 20:15:13 cfeuersaenger Exp $ +-- + +local pgfluamathfunctions = pgfluamathfunctions or {} + +-- Maps function names to their function. +-- +-- Note that this allows to register functions which are not in pgfluamathfunctions. +-- +-- Note that the string keys are not necessarily the same as the function +-- names. In particular, the math expression "not(1,1)" will execute notPGF(1,1) +-- +-- Note that each function which is added to pgfluamathfunctions will _automatically_ be inserted into this map, see __newindex. +-- (I fear it will not be erased directly...) +pgfluamathfunctions.stringToFunctionMap = {} + +local newFunctionAllocatedCallback = function(table,key,value) + local keyName = tostring(key):gsub("PGF","") + if not value then + stringToFunctionMap[keyName] = nil + elseif type(value) == 'function' then + -- remember it, and strip PGF suffix (i.e. remember 'not' instead of 'notPGF') + pgfluamathfunctions.stringToFunctionMap[keyName] = value + end + rawset(table,key,value) +end + +setmetatable(pgfluamathfunctions, { __newindex = newFunctionAllocatedCallback }) + +local mathabs, mathacos, mathasin = math.abs, math.acos, math.asin +local mathatan, mathceil = math.atan, math.ceil +local mathcos, mathdeg = math.cos, math.deg +local mathexp, mathfloor, mathfmod = math.exp, math.floor, math.fmod +local mathlog, mathmax = math.log, math.max +local mathmin, mathpi = math.min, math.pi +local mathrad, mathrandom = math.rad, math.random +local mathrandomseed, mathsin = math.randomseed, math.sin +local mathsqrt = math.sqrt +local mathtan = math.tan + +local trigFormatToRadians = mathrad + +local radiansToTrigFormat = mathdeg + +pgfluamathfunctions.TrigFormat = { 'deg', 'rad' } +pgfluamathfunctions.stringToFunctionMap["TrigFormat"] = nil + +-- choice is one of the valid choices in TrigFormat. +function pgfluamathfunctions.setTrigFormat(choice) + if choice == 'deg' then + trigFormatToRadians = mathrad + radiansToTrigFormat = mathdeg + elseif choice == 'rad' then + local identity = function(x) return x end + trigFormatToRadians = identity + radiansToTrigFormat = identity + else + error("The argument '" .. tostring(choice) .. "' is no valid choice for setTrigFormat.") + end +end +pgfluamathfunctions.stringToFunctionMap["setTrigFormat"] = nil + +pgfluamathfunctions.setRandomSeed = mathrandomseed +pgfluamathfunctions.stringToFunctionMap["setRandomSeed"] = nil + +------------------------------------------- + +function pgfluamathfunctions.add(x,y) + return x+y +end + +function pgfluamathfunctions.subtract(x,y) + return x-y +end + +function pgfluamathfunctions.neg(x) + return -x +end + +function pgfluamathfunctions.multiply(x,y) + return x*y +end + +function pgfluamathfunctions.veclen(x,y) + return mathsqrt(x*x+y*y) +end + +function pgfluamathfunctions.divide(x,y) + return x/y +end + +function pgfluamathfunctions.div(x,y) + return mathfloor(x/y) +end + +function pgfluamathfunctions.pow(x,y) + -- do not use math.pow -- it is deprecated as of LUA 5.3 + return x^y +end + +function pgfluamathfunctions.factorial(x) +-- TODO: x must be an integer + if x == 0 then + return 1 + else + return x * pgfluamathfunctions.factorial(x-1) + end +end + +function pgfluamathfunctions.ifthenelse(x,y,z) + if x~= 0 then + return y + else + return z + end +end + +function pgfluamathfunctions.equal(x,y) + if x == y then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.greater(x,y) + if x > y then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.less(x,y) + if x < y then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.min(x,y) + return mathmin(x,y) +end + +function pgfluamathfunctions.max(x,y) + return mathmax(x,y) +end + +function pgfluamathfunctions.notequal(x,y) + if x ~= y then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.notless(x,y) + if x >= y then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.notgreater(x,y) + if x <= y then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.andPGF(x,y) + if (x ~= 0) and (y ~= 0) then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.orPGF(x,y) + if (x ~= 0) or (y ~= 0) then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.notPGF(x) + if x == 0 then + return 1 + else + return 0 + end +end + +function pgfluamathfunctions.pi() + return mathpi +end + +function pgfluamathfunctions.e() + return mathexp(1) +end + +function pgfluamathfunctions.abs(x) + return mathabs(x) +end + +function pgfluamathfunctions.floor(x) + return mathfloor(x) +end + +function pgfluamathfunctions.ceil(x) + return mathceil(x) +end + +function pgfluamathfunctions.exp(x) + return mathexp(x) +end + +function pgfluamathfunctions.ln(x) + return mathlog(x) +end + +local logOf10 = mathlog(10) +function pgfluamathfunctions.log10(x) + return mathlog(x) / logOf10 +end + +local logOf2 = mathlog(2) +function pgfluamathfunctions.log2(x) + return mathlog(x) / logOf2 +end + +function pgfluamathfunctions.sqrt(x) + return mathsqrt(x) +end + +function pgfluamathfunctions.sign(x) + if x < 0 then + return -1.0 + elseif x == 0 then + return 0.0 + else + return 1.0 + end +end +function pgfluamathfunctions.real(x) + -- "ensure that x contains a decimal point" is kind of a no-op here, isn't it!? + return x +end + +function pgfluamathfunctions.rnd() + return mathrandom() +end + +function pgfluamathfunctions.rand() + return -1 + mathrandom() *2 +end + +function pgfluamathfunctions.random(x,y) + if x == nil and y == nil then + return mathrandom() + elseif y == nil then + return mathrandom(x) + else + return mathrandom(x,y) + end +end + +function pgfluamathfunctions.deg(x) + return mathdeg(x) +end + +function pgfluamathfunctions.rad(x) + return mathrad(x) +end + +function pgfluamathfunctions.round(x) + if x<0 then + return -mathfloor(mathabs(x)+0.5) + else + return mathfloor(x + 0.5) + end +end + +function pgfluamathfunctions.gcd(a, b) + if b == 0 then + return a + else + return pgfluamathfunctions.gcd(b, a%b) + end +end + +function pgfluamathfunctions.isprime(a) + local ifisprime = true + if a == 1 then + ifisprime = false + elseif a == 2 then + ifisprime = true +-- if a > 2 then + else + local i, imax = 2, mathceil(mathsqrt(a)) + 1 + while ifisprime and (i < imax) do + if pgfluamathfunctions.gcd(a,i) ~= 1 then + ifisprime = false + end + i = i + 1 + end + end + if ifisprime then + return 1 + else + return 0 + end +end + + +function pgfluamathfunctions.split_braces_to_explist(s) + -- (Thanks to mpg and zappathustra from fctt) + -- Make unpack available whatever lua version is used + -- (unpack in lua 5.1 table.unpack in lua 5.2) + local unpack = table.unpack or unpack + local t = {} + for i in s:gmatch('%b{}') do + table.insert(t, tonumber(i:sub(2, -2))) + end + return unpack(t) +end + +function pgfluamathfunctions.split_braces_to_table(s) + local t = {} + for i in s:gmatch('%b{}') do + table.insert(t, tonumber(i:sub(2, -2))) + end + return t +end + +function pgfluamathfunctions.mathtrue() + return 1.0 +end +pgfluamathfunctions.stringToFunctionMap["true"] = pgfluamathfunctions.mathtrue + +function pgfluamathfunctions.mathfalse() + return 0.0 +end +pgfluamathfunctions.stringToFunctionMap["false"] = pgfluamathfunctions.mathfalse + +function pgfluamathfunctions.frac(a) + -- should be positive, apparently + return mathabs(a - pgfluamathfunctions.int(a)) +end + +function pgfluamathfunctions.int(a) + if a < 0 then + return -mathfloor(mathabs(a)) + else + return mathfloor(a) + end +end + +function pgfluamathfunctions.iseven(a) + if (a % 2) == 0 then + return 1.0 + else + return 0.0 + end +end + +function pgfluamathfunctions.isodd(a) + if (a % 2) == 0 then + return 0.0 + else + return 1.0 + end +end + +function pgfluamathfunctions.mod(x,y) + if x/y < 0 then + return -(mathabs(x)%mathabs(y)) + else + return mathabs(x)%mathabs(y) + end +end + +function pgfluamathfunctions.Mod(x,y) + local tmp = pgfluamathfunctions.mod(x,y) + if tmp < 0 then + tmp = tmp + y + end + return tmp +end + +function pgfluamathfunctions.Sin(x) + return mathsin(trigFormatToRadians(x)) +end +pgfluamathfunctions.sin=pgfluamathfunctions.Sin + + +function pgfluamathfunctions.cosh(x) + -- math.cosh is deprecated as of LUA 5.3 . reimplement it: + return 0.5* (mathexp(x) + mathexp(-x)) +end +function pgfluamathfunctions.sinh(x) + -- math.sinh is deprecated as of LUA 5.3 . reimplement it: + return 0.5* (mathexp(x) - mathexp(-x)) +end + +local sinh = pgfluamathfunctions.sinh +local cosh = pgfluamathfunctions.cosh +function pgfluamathfunctions.tanh(x) + -- math.tanh is deprecated as of LUA 5.3 . reimplement it: + return sinh(x)/cosh(x) +end + +function pgfluamathfunctions.Cos(x) + return mathcos(trigFormatToRadians(x)) +end +pgfluamathfunctions.cos=pgfluamathfunctions.Cos + +function pgfluamathfunctions.Tan(x) + return mathtan(trigFormatToRadians(x)) +end +pgfluamathfunctions.tan=pgfluamathfunctions.Tan + +function pgfluamathfunctions.aSin(x) + return radiansToTrigFormat(mathasin(x)) +end +pgfluamathfunctions.asin=pgfluamathfunctions.aSin + +function pgfluamathfunctions.aCos(x) + return radiansToTrigFormat(mathacos(x)) +end +pgfluamathfunctions.acos=pgfluamathfunctions.aCos + +function pgfluamathfunctions.aTan(x) + return radiansToTrigFormat(mathatan(x)) +end +pgfluamathfunctions.atan=pgfluamathfunctions.aTan + +local mathatan2 +if math.atan2 == nil then + -- math.atan2 has been deprecated since LUA 5.3 + mathatan2 = function (y,x) return mathatan(y,x) end +else + mathatan2 = math.atan2 +end + +function pgfluamathfunctions.aTan2(y,x) + return radiansToTrigFormat(mathatan2(y,x)) +end +pgfluamathfunctions.atan2=pgfluamathfunctions.aTan2 +pgfluamathfunctions.atantwo=pgfluamathfunctions.aTan2 + +function pgfluamathfunctions.cot(x) + return pgfluamathfunctions.cos(x) / pgfluamathfunctions.sin(x) +end +function pgfluamathfunctions.sec(x) + return 1 / pgfluamathfunctions.cos(x) +end +function pgfluamathfunctions.cosec(x) + return 1 / pgfluamathfunctions.sin(x) +end + +function pgfluamathfunctions.pointnormalised (pgfx, pgfy) + local pgfx_normalised, pgfy_normalised + if pgfx == 0. and pgfy == 0. then + -- Orginal pgf macro gives this result + tex.dimen['pgf@x'] = "0pt" + tex.dimen['pgf@y'] = "1pt" + else + pgfx_normalised = pgfx/math.sqrt(pgfx^2 + pgfy^2) + pgfx_normalised = pgfx_normalised - pgfx_normalised%0.00001 + pgfy_normalised = pgfy/math.sqrt(pgfx^2 + pgfy^2) + pgfy_normalised = pgfy_normalised - pgfy_normalised%0.00001 + tex.dimen['pgf@x'] = tostring(pgfx_normalised) .. "pt" + tex.dimen['pgf@y'] = tostring(pgfy_normalised) .. "pt" + end + return nil +end + +local isnan = function(x) + return x ~= x +end + +pgfluamathfunctions.isnan = isnan + +local infty = 1/0 +pgfluamathfunctions.infty = infty + +local nan = math.sqrt(-1) +pgfluamathfunctions.nan = nan + +local stringlen = string.len +local globaltonumber = tonumber +local stringsub=string.sub +local stringformat = string.format +local stringsub = string.sub + +-- like tonumber(x), but it also accepts nan, inf, infty, and the TeX FPU format +function pgfluamathfunctions.tonumber(x) + if type(x) == 'number' then return x end + if not x then return x end + + local len = stringlen(x) + local result = globaltonumber(x) + if not result then + if len >2 and stringsub(x,2,2) == 'Y' and stringsub(x,len,len) == ']' then + -- Ah - some TeX FPU input of the form 1Y1.0e3] . OK. transform it + local flag = stringsub(x,1,1) + if flag == '0' then + -- ah, 0.0 + result = 0.0 + elseif flag == '1' then + result = globaltonumber(stringsub(x,3, len-1)) + elseif flag == '2' then + result = globaltonumber("-" .. stringsub(x,3, len-1)) + elseif flag == '3' then + result = nan + elseif flag == '4' then + result = infty + elseif flag == '5' then + result = -infty + end + else + local lower = x:lower() + if lower == 'nan' then + result = nan + elseif lower == 'inf' or lower == 'infty' then + result = infty + elseif lower == '-inf' or lower == '-infty' then + result = -infty + end + end + end + + return result +end + +local stringlen = string.len +local globaltonumber = tonumber +local stringformat = string.format +local stringsub = string.sub +local stringfind = string.find +local stringbyte = string.byte +local NULL_CHAR = string.byte("0",1) + +local function discardTrailingZeros(x) + local result = x + -- printf is too stupid: I would like to have + -- 1. a fast method + -- 2. a reliable method + -- 3. full precision of x + -- 4. a fixed point representation + -- the 'f' modifier has trailing zeros (stupid!) + -- the 'g' modified can switch to scientific notation (no-go!) + local periodOff = stringfind(result, '.',1,true) + if periodOff ~= nil then + -- strip trailing zeros + local chars = { stringbyte(result,1,#result) }; + local lastNonZero = #chars + for i = #chars, periodOff, -1 do + if chars[i] ~= NULL_CHAR then lastNonZero=i; break; end + end + if lastNonZero ~= #chars then + -- Ah: we had at least one trailing zero. + -- discard all but the last. + lastNonZero = mathmax(periodOff+1,lastNonZero) + end + result = stringsub(result, 1, lastNonZero) + end + return result; +end + +local function discardTrailingZerosFromMantissa(x) + local mantissaStart = stringfind(x, "e") + + local mantissa = stringsub(x,1,mantissaStart-1) + local exponent = stringsub(x,mantissaStart) + + return discardTrailingZeros(mantissa) .. exponent +end + + +-- a helper function which has no catcode issues when communicating with TeX: +function pgfluamathfunctions.tostringfixed(x) + if x == nil then + return "" + end + + return discardTrailingZeros(stringformat("%f", x)) +end + +-- converts an input number to a string which is accepted by the TeX FPU +function pgfluamathfunctions.toTeXstring(x) + local result = "" + if x ~= nil then + if x == infty then result = "4Y0.0e0]" + elseif x == -infty then result = "5Y0.0e0]" + elseif isnan(x) then result = "3Y0.0e0]" + elseif x == 0 then result = "0Y0.0e0]" + else + result = discardTrailingZerosFromMantissa(stringformat("%.10e", x)) + if x > 0 then + result = "1Y" .. result .. "]" + else + result = "2Y" .. stringsub(result,2) .. "]" + end + end + end + return result +end + +return pgfluamathfunctions diff --git a/tex/.texmf/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/parser.lua b/tex/.texmf/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/parser.lua new file mode 100644 index 0000000..cc9663f --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/parser.lua @@ -0,0 +1,495 @@ +-------------------------------------------------------------------------------------------------- +------ This file is a copy of some part of PGF/Tikz. +------ It has been copied here to provide : +------ - compatibility with older PGF versions +------ - availability of PGF contributions by Christian Feuersaenger +------ which are necessary or helpful for pgfplots. +------ +------ For reasons of simplicity, I have copied the whole file, including own contributions AND +------ PGF parts. The copyrights are as they appear in PGF. +------ +------ Note that pgfplots has compatible licenses. +------ +------ This copy has been modified in the following ways: +------ - nested \input commands have been updated +------ +-- +-- Support for the contents of this file will NOT be done by the PGF/TikZ team. +-- Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +-- with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +-- This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +---------------------------------------------------------------------------------------------------- +-- Date of this copy: Mi 14. Jan 21:15:32 CET 2015 --- + + + +-- Copyright 2011 by Christophe Jorssen and Mark Wibrow +-- Copyright 2014 by Christian Feuersaenger +-- +-- This file may be distributed and/or modified +-- +-- 1. under the LaTeX Project Public License and/or +-- 2. under the GNU Public License. +-- +-- See the file doc/generic/pgf/licenses/LICENSE for more details. +-- +-- $Id: parser.lua,v 1.1 2014/12/27 14:11:49 cfeuersaenger Exp $ +-- +-- usage: +-- +-- pgfluamathparser = require("pgfplotsoldpgfsupp.luamath.parser") +-- +-- local result = pgfluamathparser.pgfmathparse("1+ 2*4^2") +-- +-- This LUA class has a direct backend in \pgfuselibrary{luamath}, see the documentation of that TeX package. + +local pgfluamathparser = pgfluamathparser or {} + +pgfluamathfunctions = require("pgfplotsoldpgfsupp.luamath.functions") + +-- lpeg is always present in luatex +local lpeg = require("lpeg") + +local S, P, R = lpeg.S, lpeg.P, lpeg.R +local C, Cc, Ct = lpeg.C, lpeg.Cc, lpeg.Ct +local Cf, Cg, Cs = lpeg.Cf, lpeg.Cg, lpeg.Cs +local V = lpeg.V +local match = lpeg.match + +local space_pattern = S(" \n\r\t")^0 +local tex_unit = + P('pt') + P('mm') + P('cm') + P('in') + + -- while valid units, the font-depending ones need special attention... move them to the TeX side. For now. + -- P('ex') + P('em') + + P('bp') + P('pc') + + P('dd') + P('cc') + P('sp'); + +local one_digit_pattern = R("09") +local positive_integer_pattern = one_digit_pattern^1 +-- FIXME : it might be a better idea to remove '-' from all number_patterns! Instead, rely on the prefix operator 'neg' to implement negative numbers. +-- Is that wise? It is certainly less efficient... +local integer_pattern = S("+-")^-1 * positive_integer_pattern +-- Valid positive decimals are |xxx.xxx|, |.xxx| and |xxx.| +local positive_integer_or_decimal_pattern = positive_integer_pattern * ( P(".") * one_digit_pattern^0)^-1 + + (P(".") * one_digit_pattern^1) +local integer_or_decimal_pattern = S("+-")^-1 * positive_integer_or_decimal_pattern +local fpu_pattern = R"15" * P"Y" * positive_integer_or_decimal_pattern * P"e" * P("-")^-1 * R("09")^1 * P"]" +local unbounded_pattern = P"inf" + P"INF" + P"nan" + P"NaN" + P"Inf" +local number_pattern = C(unbounded_pattern + fpu_pattern + integer_or_decimal_pattern * (S"eE" * integer_pattern + C(tex_unit))^-1) + +local underscore_pattern = P("_") + +local letter_pattern = R("az","AZ") +local alphanum__pattern = letter_pattern + one_digit_pattern + underscore_pattern + +local identifier_pattern = letter_pattern^1 * alphanum__pattern^0 + +local openparen_pattern = P("(") * space_pattern +local closeparen_pattern = P(")") +local opencurlybrace_pattern = P("{") +local closecurlybrace_pattern = P("}") +local openbrace_pattern = P("[") +local closebrace_pattern = P("]") + +-- hm. what about '\\' or '\%' ? +-- accept \pgf@x, \count0, \dimen42, \c@pgf@counta, \wd0, \ht0, \dp 0 +local controlsequence_pattern = P"\\" * C( (R("az","AZ") + P"@")^1) * space_pattern* C( R"09"^0 ) + +-- local string = P('"') * C((1 - P('"'))^0) * P('"') + +local comma_pattern = P(",") * space_pattern + + +---------------- +local TermOp = C(S("+-")) * space_pattern +local RelationalOp = C( P"==" + P"!=" + P"<=" + P">=" + P"<" + P">" ) * space_pattern +local FactorOp = C(S("*/")) * space_pattern + +-- Grammar +local Exp, Term, Factor = V"Exp", V"Term", V"Factor" +local Prefix = V"Prefix" +local Postfix = V"Postfix" + + + +local function eval (v1, op, v2) + if (op == "+") then return v1 + v2 + elseif (op == "-") then return v1 - v2 + elseif (op == "*") then return v1 * v2 + elseif (op == "/") then return v1 / v2 + else + error("This function must not be invoked for operator "..op) + end +end + +local pgfStringToFunctionMap = pgfluamathfunctions.stringToFunctionMap +local function function_eval(name, ... ) + local f = pgfStringToFunctionMap[name] + if not f then + error("Function '" .. name .. "' is undefined (did not find pgfluamathfunctions."..name .." (looked into pgfluamathfunctions.stringToFunctionMap))") + end + -- FIXME: validate signature + return f(...) +end + + +local func = + (C(identifier_pattern) * space_pattern * openparen_pattern * Exp * (comma_pattern * Exp)^0 * closeparen_pattern) / function_eval; + +local functionWithoutArg = identifier_pattern / function_eval + +-- this is what can occur as exponent after '^'. +-- I have the impression that the priorities could be implemented in a better way than this... but it seems to work. +local pow_exponent = + -- allows 2^-4, 2^1e4, 2^2 + -- FIXME : why not 2^1e2 ? + Cg(C(integer_or_decimal_pattern) + -- 2^pi, 2^multiply(2,2) + + Cg(func+functionWithoutArg) + -- 2^(2+2) + + openparen_pattern * Exp * closeparen_pattern ) + +local function prefix_eval(op, x) + if op == "-" then + return pgfluamathfunctions.neg(x) + elseif op == "!" then + return pgfluamathfunctions.notPGF(x) + else + error("This function must not be invoked for operator "..op) + end +end + + +local prefix_operator = C( S"-!" ) +local prefix_operator_pattern = (prefix_operator * space_pattern * Cg(Prefix) ) / prefix_eval + +-- apparently, we need to distinghuish between ! and != : +local postfix_operator = C( S"r!" - P"!=" ) + C(P"^") * space_pattern * pow_exponent + + +local ternary_eval = pgfluamathfunctions.ifthenelse + +local factorial_eval = pgfluamathfunctions.factorial +local deg = pgfluamathfunctions.deg +local pow_eval = pgfluamathfunctions.pow + +-- @param prefix the argument before the postfix operator. +-- @param op either nil or the postfix operator +-- @param arg either nil or the (mandatory) argument for 'op' +local function postfix_eval(prefix, op, arg) + local result + if op == nil then + result = prefix + elseif op == "r" then + if arg then error("parser setup error: expected nil argument") end + result = deg(prefix) + elseif op == "!" then + if arg then error("parser setup error: expected nil argument") end + result = factorial_eval(prefix) + elseif op == "^" then + if not arg then error("parser setup error: ^ with its argument") end + result = pow_eval(prefix, arg) + else + error("Parser setup error: " .. tostring(op) .. " unexpected in this context") + end + return result +end + +local function relational_eval(v1, op, v2) + local fct + if (op == "==") then fct = pgfluamathfunctions.equal + elseif (op == "!=") then fct = pgfluamathfunctions.notequal + elseif (op == "<") then fct = pgfluamathfunctions.less + elseif (op == ">") then fct = pgfluamathfunctions.greater + elseif (op == ">=") then fct = pgfluamathfunctions.notless + elseif (op == "<=") then fct = pgfluamathfunctions.notgreater + else + error("This function must not be invoked for operator "..op) + end + return fct(v1,v2) +end + +-- @return either the box property or nil +-- @param cs "wd", "ht", or "dp" +-- @param intSuffix some integer +local function get_tex_box(cs, intSuffix) + -- assume get_tex_box is only called when a dimension is required. + local result + pgfluamathparser.units_declared = true + local box =tex.box[tonumber(intSuffix)] + if not box then error("There is no box " .. intSuffix) end + if cs == "wd" then + result = box.width / 65536 + elseif cs == "ht" then + result = box.height / 65536 + elseif cs == "dp" then + result = box.depth / 65536 + else + result = nil + end + return result +end + + +local function controlsequence_eval(cs, intSuffix) + local result + if intSuffix and #intSuffix >0 then + if cs == "count" then + result= pgfluamathparser.get_tex_count(intSuffix) + elseif cs == "dimen" then + result= pgfluamathparser.get_tex_dimen(intSuffix) + else + result = get_tex_box(cs,intSuffix) + if not result then + -- this can happen - we cannot expand \chardef'ed boxes here. + -- this will be done by the TeX part + error('I do not know/support the TeX register "\\' .. cs .. '"') + end + end + else + result = pgfluamathparser.get_tex_register(cs) + end + return result +end + +pgfluamathparser.units_declared = false +function pgfluamathparser.get_tex_register(register) + -- register is a string which could be a count or a dimen. + if pcall(tex.getcount, register) then + return tex.count[register] + elseif pcall(tex.getdimen, register) then + pgfluamathparser.units_declared = true + return tex.dimen[register] / 65536 -- return in points. + else + error('I do not know the TeX register "' .. register .. '"') + return nil + end + +end + +function pgfluamathparser.get_tex_count(count) + -- count is expected to be a number + return tex.count[tonumber(count)] +end + +function pgfluamathparser.get_tex_dimen(dimen) + -- dimen is expected to be a number + pgfluamathparser.units_declared = true + return tex.dimen[tonumber(dimen)] / 65536 +end + +function pgfluamathparser.get_tex_sp(dimension) + -- dimension should be a string + pgfluamathparser.units_declared = true + return tex.sp(dimension) / 65536 +end + + +local initialRule = V"initial" + +local Summand = V"Summand" +local Relational = V"Relational" +local LogicalOr = V"LogicalOr" +local LogicalAnd = V"LogicalAnd" + +local pgftonumber = pgfluamathfunctions.tonumber +local tonumber_withunit = pgfluamathparser.get_tex_sp +local function number_optional_units_eval(x, unit) + if not unit then + return pgftonumber(x) + else + return tonumber_withunit(x) + end +end + +-- @param scale the number. +-- @param controlsequence either nil in which case just the number must be returned or a control sequence +-- @see controlsequence_eval +local function scaled_controlsequence_eval(scale, controlsequence, intSuffix) + if controlsequence==nil then + return scale + else + return scale * controlsequence_eval(controlsequence, intSuffix) + end +end + +-- Grammar +-- +-- for me: +-- - use '/' to evaluate all expressions which contain a _constant_ number of captures. +-- - use Cf to evaluate expressions which contain a _dynamic_ number of captures +-- +-- see unittest_luamathparser.tex for tons of examples +local G = P{ "initialRule", + initialRule = space_pattern* Exp * -1; + -- ternary operator (or chained ternary operators): + -- FIXME : is this chaining a good idea!? + Exp = Cf( Relational * Cg(P"?" * space_pattern * Relational * P":" *space_pattern * Relational )^0, ternary_eval) ; + -- FIXME : do we really allow something like " 1 == 1 != 2" ? I would prefer (1==1) != 2 !? + Relational = Cf(LogicalOr * Cg(RelationalOp * LogicalOr)^0, relational_eval); + LogicalOr = Cf(LogicalAnd * (P"||" * space_pattern * LogicalAnd)^0, pgfluamathfunctions.orPGF); + LogicalAnd = Cf(Summand * (P"&&" * space_pattern * Summand)^0, pgfluamathfunctions.andPGF); + Summand = Cf(Term * Cg(TermOp * Term)^0, eval) ; + Term = Cf(Prefix * Cg(FactorOp * Prefix)^0, eval); + Prefix = prefix_operator_pattern + Postfix; + -- this calls 'postfix_eval' with nil arguments if it is no postfix operation.. but that does not hurt (right?) + Postfix = Factor * (postfix_operator * space_pattern)^-1 / postfix_eval; + Factor = + ( + number_pattern / number_optional_units_eval * + -- this construction will evaluate number_pattern with 'number_optional_units_eval' FIRST. + -- also accept '0.5 \pgf@x' here: + space_pattern *controlsequence_pattern^-1 / scaled_controlsequence_eval + + func + + functionWithoutArg + + openparen_pattern * Exp * closeparen_pattern + + controlsequence_pattern / controlsequence_eval + ) *space_pattern + ; +} + +-- does not reset units_declared. +local function pgfmathparseinternal(str) + local result = match(G,str) + if result == nil then + error("The string '" .. str .. "' is no valid PGF math expression. Please check for syntax errors.") + end + return result +end + + +-- This is the math parser function in this module. +-- +-- @param str a string like "1+1" which is accepted by the PGF math language +-- @return the result of the expression. +-- +-- Throws an error if the string is no valid expression. +function pgfluamathparser.pgfmathparse(str) + pgfluamathparser.units_declared = false + + return pgfmathparseinternal(str) +end + +local pgfmathparse = pgfluamathparser.pgfmathparse +local tostringfixed = pgfluamathfunctions.tostringfixed +local tostringfpu = pgfluamathfunctions.toTeXstring + +local tmpFunctionArgumentPrefix = "tmpVar" +local stackOfLocalFunctions = {} + +-- This is a backend for PGF's 'declare function'. +-- \tikzset{declare function={mu(\x,\i)=\x^\i;}} +-- will boil down to +-- pgfluamathparser.declareExpressionFunction("mu", 2, "#1^#2") +-- +-- The local function will be pushed on a stack of known local functions and is +-- available until popLocalExpressionFunction() is called. TeX will call this using +-- \aftergroup. +-- +-- @param name the name of the new function +-- @param numArgs the number of arguments +-- @param expression an expression containing #1, ... #n where n is numArgs +-- +-- ATTENTION: local functions behave DIFFERENTLY in LUA! +-- In LUA, local variables are not expanded whereas TeX expands them. +-- The difference is +-- +-- declare function={mu1(\x,\i)=\x^\i;} +-- \pgfmathparse{mu1(-5,2)} --> -25 +-- \pgfluamathparse{mu1(-5,2)} --> 25 +-- +-- x = -5 +-- \pgfmathparse{mu1(x,2)} --> 25 +-- \pgfluamathparse{mu1(x,2)} --> 25 +-- +-- In an early prototype, I simulated TeX's expansion to fix the first case (successfully). +-- BUT: that "simulated expansion" broke the second case because LUA will evaluate "x" and hand -5 to the local function. +-- I decided to keep it as is. Perhaps we should fix PGF's expansion approach in TeX (which is ugly anyway) +function pgfluamathparser.pushLocalExpressionFunction(name, numArgs, expression) + -- now we have "tmpVar1^tmpVar2" instead of "#1^#2" + local normalizedExpr = expression:gsub("#", tmpFunctionArgumentPrefix) + local restores = {} + local tmpVars = {} + for i=1,numArgs do + local tmpVar = tmpFunctionArgumentPrefix .. tostring(i) + tmpVars[i] = tmpVar + end + + local newFunction = function(...) + local args = table.pack(...) + + -- define "tmpVar1" ... "tmpVarN" to return args[i]. + -- Of course, we need to restore "tmpVar" after we return! + for i=1,numArgs do + local tmpVar = tmpVars[i] + local value = args[i] + restores[i] = pgfStringToFunctionMap[tmpVar] + pgfStringToFunctionMap[tmpVar] = function () return value end + end + + -- parse our expression. + + -- FIXME : this here is an attempt to mess around with "units_declared". + -- It would be better to call pgfmathparse and introduce some + -- semaphore to check if pgfmathparse is a nested call-- in this case, it should + -- not reset units_declared. But there is no "finally" block and pcall is crap (looses stack trace). + local success,result = pcall(pgfmathparseinternal, normalizedExpr) + + -- remove 'tmpVar1', ... from the function table: + for i=1,numArgs do + local tmpVar = tmpVars[i] + pgfStringToFunctionMap[tmpVar] = restores[i] + end + + if success==false then error(result) end + return result + end + table.insert(stackOfLocalFunctions, name) + pgfStringToFunctionMap[name] = newFunction +end + +function pgfluamathparser.popLocalExpressionFunction() + local name = stackOfLocalFunctions[#stackOfLocalFunctions] + pgfStringToFunctionMap[name] = nil + -- this removes the last element: + table.remove(stackOfLocalFunctions) +end + + +-- A Utility function which simplifies the interaction with the TeX code +-- @param expression the input expression (string) +-- @param outputFormatChoice 0 if the result should be a fixed point number, 1 if it should be in FPU format +-- @param showErrorMessage (boolean) true if any error should be displayed, false if errors should simply result in an invocation of TeX's parser (the default) +-- +-- it defines \pgfmathresult and \ifpgfmathunitsdeclared +function pgfluamathparser.texCallParser(expression, outputFormatChoice, showErrorMessage) + local success, result + if showErrorMessage then + result = pgfmathparse(expression) + success = true + else + success, result = pcall(pgfmathparse, expression) + end + + if success and result then + local result_str + if outputFormatChoice == 0 then + -- luamath/output format=fixed + result_str = tostringfixed(result) + else + -- luamath/output format=fixed + result_str = tostringfpu(result) + end + tex.sprint("\\def\\pgfmathresult{" .. result_str .. "}") + if pgfluamathparser.units_declared then + tex.sprint("\\pgfmathunitsdeclaredtrue") + else + tex.sprint("\\pgfmathunitsdeclaredfalse") + end + else + tex.sprint("\\def\\pgfmathresult{}") + tex.sprint("\\pgfmathunitsdeclaredfalse") + end +end + +return pgfluamathparser diff --git a/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstable.code.tex b/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstable.code.tex new file mode 100644 index 0000000..4d44a17 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstable.code.tex @@ -0,0 +1,2998 @@ +%-------------------------------------------- +% +% Package pgfplotstable +% +% Provides support to read and work with abstact numeric tables of the +% form +% +% COLUMN1 COLUMN2 COLUMN3 +% 1 2 3 +% 4 4 552 +% 1e124 0.00001 1.2345e-12 +% ... +% +% Copyright 2007-2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + + +% This file provides a high-level table manipulation and typesetting +% package. +% +% see pgfplotstableshared.code.tex for the low level routines. + + +\newif\ifpgfplotstabletypesetdebug +\newif\ifpgfplotstable@sort +\newif\ifpgfplotstabletypesetskipcoltypes +\newif\ifpgfplotstabletypesetresult +\newif\ifpgfplotstableuserow +\newif\ifpgfplotstabletypeset@includeoutfiles +\newif\ifpgfplotstabletypeset@force@remake +\newif\ifpgfplotstable@disable@rowcolstyles + +\let\pgfplotstable@outfile=\w@pgf@writea + +\input pgfplotstable.coltype.code.tex + +% #1= floating point number +% #2= TeX code to execute if #1 == 0 +% #3= TeX code to execute if #1 != 0 +\def\pgfplots@ifzero#1#2#3{% + \expandafter\pgfmathfloat@decompose@F#1\relax\pgfmathfloat@a@S + \ifnum\pgfmathfloat@a@S=0 #2\else#3\fi +}% + +% just make sure no-one complaints if manual example are used without +% booktabs loaded: +\pgfutil@IfUndefined{toprule}{% + \def\toprule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\toprule}}% + \def\midrule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\midrule}}% + \def\bottomrule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\bottomrule}}% +}{\relax}% + +% keys which are NOT predefined: +% /pgfplots/table/alias//.initial={} +% /pgfplots/table/columns//.style={} +% /pgfplots/table/display columns//.style={} +% /pgfplots/table/create on use//.style={create options} +\pgfkeys{% + /pgfplots/table/disable rowcol styles/.is if=pgfplotstable@disable@rowcolstyles, + /pgfplots/table/disable rowcol styles/.default=true, + /pgfplots/table/row predicate/.code={}, + /pgfplots/table/skip rows between index/.style 2 args={% + /pgfplots/table/row predicate/.append code={% + \ifnum##1<#1\relax + \else + \ifnum##1<#2\relax + \pgfplotstableuserowfalse + \fi + \fi} + }, + /pgfplots/table/select equal part entry of/.style 2 args={% + /pgfplots/table/row predicate/.code={% + \pgfplotstableuserowtrue + \begingroup + % this group re-uses counters as temporary variables. + \c@pgfplotstable@colindex=\pgfplotstablerows\relax + \divide\c@pgfplotstable@colindex by#2\relax + \edef\pgfplotstablepartsize{\the\c@pgfplotstable@colindex}% + % This here should create empty cells such that + % remaining entries are distributed equally: + \c@pgfplotstable@rowindex=\c@pgfplotstable@colindex + \multiply\c@pgfplotstable@rowindex by#2\relax + \ifnum\c@pgfplotstable@rowindex<\pgfplotstablerows\relax + \c@pgfplotstable@colindex=\pgfplotstablerows\relax + \advance\c@pgfplotstable@colindex by-\c@pgfplotstable@rowindex + \advance\c@pgfplotstable@colindex by\pgfplotstablepartsize + \edef\pgfplotstablepartsize{\the\c@pgfplotstable@colindex}% + \fi + % + \multiply\c@pgfplotstable@colindex by#1\relax + \ifnum##1<\c@pgfplotstable@colindex\relax + \aftergroup\pgfplotstableuserowfalse + \else + \advance\c@pgfplotstable@colindex by\pgfplotstablepartsize\relax + \ifnum##1<\c@pgfplotstable@colindex\relax + \else + \aftergroup\pgfplotstableuserowfalse + \fi + \fi + \endgroup + }% + }, + % #1: colname + /pgfplots/table/unique/.code={% + \pgfkeys{/pgfplots/table/row predicate/.append code={% + \ifnum\pgfplotstablerow=0 + \ifnum\pgfplotstablecol=0 + \pgfutil@ifundefined{pgfplotstable@unique@bitlist@backup}{% + }{% + \pgfplots@error{It seems there are *multiple* 'unique' keys running on one table. That doesn't work correctly, I guess. Consider using '\string\pgfplotstableset{row predicate/.code={}}' to reset it.}% + }% + % PREPARE ONCE! Assemble the boolean results into + % a list which is used for the complete table: + \def\pgfplotstable@loc@TMPd{\pgfplotstablegetcolumnfromstruct{#1}\of}% + \expandafter\pgfplotstable@loc@TMPd\pgfplotstablename\to\pgfplotstable@unique@col + \pgfplotslistnewempty\pgfplotstable@unique@bitlist + \let\pgfplotstable@unique@LAST=\pgfutil@empty + \pgfplotslistforeachungrouped\pgfplotstable@unique@col\as\pgfplotstable@unique@cur{% + \def\pgfplotstable@unique@bit{1}% + \ifx\pgfplotstable@unique@LAST\pgfutil@empty + \else + \ifx\pgfplotstable@unique@LAST\pgfplotstable@unique@cur + \def\pgfplotstable@unique@bit{0}% + \fi + \fi + \ifpgfplotstabletypesetdebug + \pgfplots@message{unique={#1}: cur == last <=> ( \pgfplotstable@unique@cur\space == \pgfplotstable@unique@LAST ) = \pgfplotstable@unique@bit.}% + \fi + \expandafter\pgfplotslistpushback\pgfplotstable@unique@bit\to\pgfplotstable@unique@bitlist + \let\pgfplotstable@unique@LAST=\pgfplotstable@unique@cur + }% + \global\let\pgfplotstable@unique@bitlist@backup=\pgfplotstable@unique@bitlist + \else + \pgfutil@ifundefined{pgfplotstable@unique@bitlist@backup}{% + % this sanity checking is NOT fool proof: it + % fails if there are different occurances of + % unique in the same file + \pgfplotsthrow{invalid argument}{Sorry, the row predicate /pgfplots/table/unique={#1} has been used in the wrong context: it needs to be invoked for the very first processed column, not column no \pgfplotstablecol. Please provide it as argument to \string\pgfplotstabletypeset[unique={#1}] and not inside of column-specific styles}\pgfeov% + }{}% + \fi + % acquire the assembled list here: we'll do a lot of + % popfronts with it. + \let\pgfplotstable@unique@bitlist=\pgfplotstable@unique@bitlist@backup + \fi + \pgfplotslistcheckempty\pgfplotstable@unique@bitlist + \ifpgfplotslistempty + % should not happen! + \pgfplotstableuserowfalse + \else + \pgfplotslistpopfront\pgfplotstable@unique@bitlist\to\pgfplots@loc@TMPa + \if\pgfplots@loc@TMPa0% + \pgfplotstableuserowfalse + \fi + \fi + % cleanup: + {% + \count0=\pgfplotstablecol\relax \advance\count0 by1 + \ifnum\count0=\pgfplotstablecols\relax + \count0=\pgfplotstablerow\relax \advance\count0 by1 + \ifnum\count0=\pgfplotstablerows\relax + \global\let\pgfplotstable@unique@bitlist@backup=\relax + \fi + \fi + }% + }}% + },% + % columns={name1,name2} + % or + % columns={[index]2,name2,name3,[index]5} + /pgfplots/table/columns/.initial=, + % + % this choice allows + % \pgfplotstableset{ + % column name={}, % means: the column's display name is an empty string! + % column name=\pgfkeysnovalue, % means: no value specified. In this case, + % the column's display name will default to column's name. + % } + /pgfplots/table/column name/.initial=\pgfkeysnovalue, + % + % this thing here allows to MODIFY 'column name'. + % + % Argument #1 is the current column name, that means after + % evaluating 'column name'. If this key changes anything, it + % should write its result back into 'column name'. + % + % That means you can use 'column name' to assign the name as such + % and 'assign column name' to generate final TeX code (for example + % to insert \multicolumn{1}{c}{#1} or so). + % default is empty which means no change. + %/pgfplots/table/assign column name/.code={ + % \pgfkeyssetvalue{/pgfplots/table/column name}{#1}% + %}, + % + % + % + % A style which inserts \multicolumn{1}{#1}{} for + % each column name. + % The column name as such can be set with the 'column name' option. + /pgfplots/table/multicolumn names/.style={% + /pgfplots/table/assign column name/.code={% + \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{1}{#1}{##1}}% + }% + }, + /pgfplots/table/multicolumn names/.default=c, + /pgfplots/table/dec sep align/.code={% + \pgfplots@assert@LaTeX@package@loaded{array}{dec sep align}% + \def\pgfplotstable@scisepalign@headeralign{#1}% + \pgfkeysalso{% + /pgf/number format/assume math mode, + /pgf/number format/@dec sep mark={$&$}, + /pgfplots/table/assign column name/.code={% + \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}% + },% + /pgfplots/table/column type={% + r<{\pgfplotstableresetcolortbloverhangright}% + @{}% + l<{\pgfplotstableresetcolortbloverhangleft}% + }, + /pgfplots/table/assign cell content/.code={% + \def\pgfmathresult{##1}% + \let\continue=\pgfutil@empty + % allow special handling: + \pgfplots@invoke@pgfkeyscode{/pgfplots/table/dec sep align/process/.@cmd}{##1}% + \ifx\continue\pgfutil@empty + % nothing has changed. Processed as usual: + \ifx\pgfmathresult\pgfutil@empty + \def\pgfmathresult{&}% + \else + % -6.90000001e-01 -> \meaning\pgfmathresult = macro:->-0$&$.69 + \pgfmathprintnumberto{\pgfmathresult}\pgfmathresult% + % now make sure we have math mode for the single + % columns: + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}% + \fi + \fi + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + }, + }% + }, + /pgfplots/table/dec sep align/.default=c, + % + % A part of dec sep align which can be used to process special + % cases. + % + % #1: the unprocessed input argument. + % PRECONDITION: + % \pgfmathresult contains '#1', not more. + % \continue is empty. + % + % POSTCONDITION: + % If \continue is empty, `dec sep align' will continue just as + % if the 'process' key hadn't been invoked. + % It will, however, use the current value of \pgfmathresult. + % + % If \continue is NOT empty, for example \def\continue{0}, + % `dec sep align' assumes that \pgfmathresult contains the + % completely typeset cell, including any alignment material. + /pgfplots/table/dec sep align/process/.code=,% + /pgfplots/table/dec sep align/no unbounded/.style={% + % FIXME : this thing doesn't work as intended! It looks ugly! + /pgfplots/table/dec sep align/process/.code={% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathfloatparsenumber\pgfmathresult + \pgfmathfloatiffinite{\pgfmathresult}{% + % do nothing, just communicate the parsed + % \pgfmathresult + }{% + \begingroup + \t@pgfplots@toka=\expandafter{\pgfplotstable@scisepalign@headeralign}% + \t@pgfplots@tokb={\pgfkeyslet{/pgf/number format/@dec sep mark}\pgfutil@empty\pgfmathprintnumber}% + \t@pgfplots@tokc=\expandafter{\pgfmathresult}% + \xdef\pgfplotstable@glob@TMPc{% + \noexpand\multicolumn{2}{\the\t@pgfplots@toka}% + {\the\t@pgfplots@tokb{\the\t@pgfplots@tokc}}% + }% + \endgroup + \let\pgfmathresult=\pgfplotstable@glob@TMPc + \def\continue{0}% + }% + \fi + },% + },% + /pgfplots/table/sci sep align/.code={% + \pgfplots@assert@LaTeX@package@loaded{array}{sci sep align}% + \pgfkeysalso{% + /pgf/number format/assume math mode, + /pgf/number format/@sci exponent mark={$&$}, + /pgfplots/table/assign column name/.code={% + \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}% + },% + /pgfplots/table/column type={% + r<{\pgfplotstableresetcolortbloverhangright}% + @{}% + l<{\pgfplotstableresetcolortbloverhangleft}% + }, + /pgfplots/table/assign cell content/.code={% + \def\pgfmathresult{##1}% + \ifx\pgfmathresult\pgfutil@empty + \def\pgfmathresult{&}% + \else + \pgfmathprintnumberto{##1}\pgfmathresult% + \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}% + % now make sure we have math mode for the single + % columns: + \ifpgfutil@in@ + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}% + \else + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter\pgfutilensuremath\expandafter{\pgfmathresult}&}% + \fi + \fi + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + }, + }% + }, + /pgfplots/table/sci sep align/.default=c, + % + % A style which can be used together with the 'dcolumn' package by + % David Carlisle. + % #1: the dcolumn type, defaults to 'D{.}{.}{2}' + % #2: the column name type, defaults to 'c' + /pgfplots/table/dcolumn/.style 2 args={% + /pgf/number format/assume math mode, + column type={#1}, + multicolumn names=#2, + }, + /pgfplots/table/dcolumn/.default={D{.}{.}{2}}{c}, + /pgfplots/table/column type/.initial={c}, + /pgfplots/table/every even row/.style={}, + /pgfplots/table/every odd row/.style={}, + /pgfplots/table/every last row/.style={}, + /pgfplots/table/every first row/.style={}, + /pgfplots/table/every head row/.style={}, + /pgfplots/table/every first column/.style={}, + /pgfplots/table/every last column/.style={}, + /pgfplots/table/every even column/.style={}, + /pgfplots/table/every odd column/.style={}, + /pgfplots/table/every nth row/.code 2 args={% + \pgfplotstabletypeset@append@every@nth@row{#1}{#2}% + }, + /pgfplots/table/every nth row/.style 2 args/.code 2 args={% + \pgfplotstabletypeset@append@every@nth@row{#1}{#2}% + }, + /pgfplots/table/before row/.initial=, + /pgfplots/table/after row/.initial=, + /pgfplots/table/begin table/.initial={\begin{tabular}}, + /pgfplots/table/end table/.initial={\end{tabular}}, + /pgfplots/table/outfile/.initial=, + /pgfplots/table/include outfiles/.is if=pgfplotstabletypeset@includeoutfiles, + /pgfplots/table/include outfiles/.default=true, + /pgfplots/table/force remake/.is if=pgfplotstabletypeset@force@remake, + /pgfplots/table/force remake/.default=true, + /pgfplots/table/write to macro/.initial=, + /pgfplots/table/typeset/.is if=pgfplotstabletypesetresult, + /pgfplots/table/typeset=true, + /pgfplots/table/skip coltypes/.is if=pgfplotstabletypesetskipcoltypes, + /pgfplots/table/skip coltypes/.default=true, + /pgfplots/table/debug/.is if=pgfplotstabletypesetdebug, + /pgfplots/table/debug level/.initial=0,% + % + % will be redefined by |assign cell content| for every cell: + /pgfplots/table/@cell content/.initial=, + % + % #1: the cells content as it has been found in the input table + % this command key should somehow fill |cell content|. + /pgfplots/table/assign cell content/.code={% + \def\pgfmathresult{#1}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathprintnumberto{#1}\pgfmathresult% + \fi + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + }, + % + % this here is the default formatting. It uses + % \pgfmathprintnumber. + /pgfplots/table/assign cell content as number/.code={% + \def\pgfmathresult{#1}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathprintnumberto{#1}\pgfmathresult% + \fi + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + }, + /pgfplots/table/numeric type/.code={% + \pgfkeysgetvalue{/pgfplots/table/assign cell content as number/.@cmd}\pgfplotstable@loc@TMPa% + \pgfkeyslet{/pgfplots/table/assign cell content/.@cmd}\pgfplotstable@loc@TMPa + }, + /pgfplots/table/string type/.style={% + /pgfplots/table/assign cell content/.style={% + /pgfplots/table/@cell content={##1}% + }% + },% + /pgfplots/table/verb string type/.style={% + /pgfplots/table/assign cell content/.code={% + \def\pgfplotstable@loc@TMPa{##1}% + \pgfplots@command@to@string\pgfplotstable@loc@TMPa\pgfplotstable@loc@TMPa + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplotstable@loc@TMPa}% + }% + },% + /pgfplots/table/numeric as string type/.style={% + /pgfplots/table/assign cell content/.code={% + \def\pgfmathresult{##1}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathifisint{##1}{\let\pgfmathresult=\pgfretval}{\pgfmathfloattosci{\pgfretval}}% + \fi + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + }% + },% + /pgfplots/table/date type/.style={% + /pgfplots/table/assign cell content/.code={% + \begingroup + \pgfcalendardatetojulian{##1}\c@pgfplotstable@counta + \pgfcalendarjuliantodate{\c@pgfplotstable@counta}\year\month\day + \pgfcalendarjuliantoweekday\c@pgfplotstable@counta\c@pgf@countc + \edef\weekday{\the\c@pgf@countc }% + \edef\weekdayname{\pgfcalendarweekdayname\c@pgf@countc}% + \edef\weekdayshortname{\pgfcalendarweekdayshortname\c@pgf@countc}% + \edef\monthname{\pgfcalendarmonthname\month}% + \edef\monthshortname{\pgfcalendarmonthshortname\month}% + \xdef\pgfplots@glob@TMPa{#1}% + \endgroup + \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPa% + }% + },% + /pgfplots/table/date type/.default={\year/\month/\day},% + /pgfplots/table/set content/.style={% + /pgfplots/table/postproc cell content/.style={% + /pgfplots/table/@cell content={#1}% + }% + },% + % + /pgfplots/table/postproc cell content/.code={}, + /pgfplots/table/preproc cell content/.code={}, + % + /pgfplots/table/clear infinite/.style={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\pgfmatharga=\pgfmathresult + {% + \pgfmathfloatgetflags\pgfmatharga\c@pgfplotstable@counta + \xdef\pgfplots@glob@TMPc{\the\c@pgfplotstable@counta}% + }% + \ifnum\pgfplots@glob@TMPc<3 + \pgfmathfloattosci@\pgfmathresult + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \else + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfutil@empty}% + \fi + \fi + } + }, + /pgfplots/table/string replace/.style 2 args={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \def\pgfplots@loc@TMPa{#1}% + \ifx\pgfmathresult\pgfplots@loc@TMPa + \def\pgfplots@loc@TMPb{#2}% + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplots@loc@TMPb}% + \fi + } + }, + /pgfplots/table/string replace*/.style 2 args={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \def\pgfplots@loc@TMPa{\pgfplotsutilstrreplace{#1}{#2}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplotsretval}% + } + }, + /pgfplots/table/preproc/expr/.code={% + \ifpgfplots@usefpu + \pgfkeysalso{/pgf/fpu=true,/pgf/fpu/output format=sci}% + \fi + \expandafter\def\csname pgfplotstable@preproc@expr@thisrow@\pgfplotstablecolname\endcsname{\pgfkeysvalueof{/pgfplots/table/@cell content}}% + \def\thisrow##1{% + \pgfutil@ifundefined{pgfplotstable@preproc@expr@thisrow@##1}{% + --inaccessable--% + }{% + \csname pgfplotstable@preproc@expr@thisrow@##1\endcsname + }% + }% + \pgfkeysalso{/pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathparse{#1}% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult% + \fi + }% + }% + }, + /pgfplots/table/multiply -1/.style={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\pgfmatharga=\pgfmathresult + \pgfmathfloatcreate{2}{1.0}{0}% + \let\pgfmathargb=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmatharga}{\pgfmathargb}% + \pgfmathfloattosci@\pgfmathresult + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \fi + } + }, + /pgfplots/table/multiply with/.style={/pgfplots/table/multiply by={#1}},% + /pgfplots/table/multiply by/.code={% + \pgfmathfloatparsenumber{#1}% + \let\pgfplotstable@scale=\pgfmathresult + \pgfkeysalso{ + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\pgfmatharga=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmatharga}{\pgfplotstable@scale}% + \pgfmathfloattosci@\pgfmathresult + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \fi + }% + }% + }, + /pgfplots/table/divide by/.code={% + \pgfkeysalso{/pgfplots/table/multiply by=#1}% + \let\pgfplotstable@divisor=\pgfplotstable@scale + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfplotstable@ONE=\pgfmathresult + \pgfmathfloatdivide@{\pgfplotstable@ONE}{\pgfplotstable@divisor}% + \let\pgfplotstable@scale=\pgfmathresult + }, + /pgfplots/table/sqrt/.style={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\pgfmatharga=\pgfmathresult + \pgfmathfloatsqrt@{\pgfmatharga}% + \pgfmathfloattosci@\pgfmathresult + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \fi + }% + }, + /pgfplots/table/empty cells with/.style={% + /pgfplots/table/postproc cell content/.append code={% + \ifnum\pgfplotstablepartno=0 + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}% + \fi + \fi + }% + }, + /pgfplots/table/fonts by sign/.style 2 args={% + /pgfplots/table/postproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfplotsretval + \ifx\pgfplotsretval\pgfutil@empty + \else + \t@pgfplots@toka=\expandafter{\pgfplotsretval}% + \t@pgfplots@tokb={#1}% + \t@pgfplots@tokc={#2}% + \pgfmathfloatparsenumber{\pgfkeysvalueof{/pgfplots/table/@preprocessed cell content}}% + \pgfmathfloatifflags{\pgfmathresult}{-}{% + \edef\pgfmathresult{{\the\t@pgfplots@tokc{\the\t@pgfplots@toka}}}% + }{% + \edef\pgfmathresult{{\the\t@pgfplots@tokb{\the\t@pgfplots@toka}}}% + }% + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \fi + }% + },% + % + /pgfplots/table/font/.initial=, + /pgfplots/table/.search also={/pgf/number format,/pgfplots/table/create col}, + %-------------------------------------------------- + % /pgfplots/table/.unknown/.code={% + % \let\pgfplots@table@curkeyname=\pgfkeyscurrentname + % \pgfqkeys{/pgf/number format}{\pgfplots@table@curkeyname=#1}% + % },% + %-------------------------------------------------- + /pgfplots/table/create col/assign first/.style={ + /pgfplots/table/create col/assign% + }, + /pgfplots/table/create col/assign last/.style={ + /pgfplots/table/create col/assign% + }, + /pgfplots/table/create col/assign/.style={ + /pgfplots/table/create col/next content={}% + }, + /pgfplots/table/create col/next content/.initial={}, + /pgfplots/table/create col/copy/.style={% + /pgfplots/table/create col/assign/.code={% + \getthisrow{#1}\pgfmathresult + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + }, + /pgfplots/table/create col/set/.style={% + /pgfplots/table/create col/assign/.code={% + \def\pgfmathresult{#1}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + },% + /pgfplots/table/create col/set list/.code={% + \pgfplots@assign@list\pgfmathaccumb{#1}% + \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}% + },% + /pgfplots/table/create col/expr accum/.code 2 args={% + \ifpgfplots@usefpu + \pgfkeysalso{/pgf/fpu=true,/pgf/fpu/output format=sci}% + \fi + \pgfkeysdef{/pgfplots/table/create col/assign}{% + \ifx\pgfmathaccuma\pgfutil@empty + \pgfmathparse{#2}% + \let\pgfmathaccuma=\pgfmathresult + \fi + \pgfmathparse{#1}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \let\pgfmathaccuma=\pgfmathresult + }% + }, + /pgfplots/table/create col/expr/.style={% + /pgfplots/table/create col/expr accum={#1}{0}% + },% + /pgfplots/table/create col/copy column from table/.code 2 args={% + \pgfplotstablegetcolumn{#2}\of{#1}\to\pgfmathaccumb + \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}% + }, + /pgfplots/table/create col/@from list struct/.code={% + \pgfplotslistcopy#1\to\pgfmathaccumb + \pgfkeysdef{/pgfplots/table/create col/assign}{% + \pgfplotslistcheckempty\pgfmathaccumb + \ifpgfplotslistempty + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + \else + \pgfplotslistpopfront\pgfmathaccumb\to\pgfmathresult + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \fi + }% + }, + /pgfplots/table/create col/linear regression/.code={% + \pgfplotstable@linear@regression{#1}% + \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfplotsretval}% + }, + /pgfplots/table/create col/linear regression/.default=,% + /pgfplots/table/create col/linear regression/x/.initial=,% + /pgfplots/table/create col/linear regression/y/.initial=,% + /pgfplots/table/create col/linear regression/table/.initial=,% + /pgfplots/table/create col/linear regression/variance/.initial=,% + /pgfplots/table/create col/linear regression/variance list/.initial=,% + /pgfplots/table/create col/linear regression/variance src/.initial=,% + /pgfplots/table/create col/linear regression/xmode/.initial=,% auto + /pgfplots/table/create col/linear regression/ymode/.initial=,% auto + /pgfplots/table/create col/quotient/.style={% + /pgfplots/table/columns={#1}, + /pgfplots/table/create col/assign first/.style={% + /pgfplots/table/create col/next content= + },% + /pgfplots/table/create col/assign/.code={% + \pgfmathfloatparsenumber{\prevrow{#1}}% + \let\pgfmatharga=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathargb=\pgfmathresult + \let\pgfmathaccuma=\pgfmathargb + \pgfplots@ifzero\pgfmathargb{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + }% + },% + /pgfplots/table/create col/iquotient/.style={% + /pgfplots/table/columns={#1}, + /pgfplots/table/create col/assign first/.style={% + /pgfplots/table/create col/next content= + },% + /pgfplots/table/create col/assign/.code={% + \pgfmathfloatparsenumber{\prevrow{#1}}% + \let\pgfmathargb=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmatharga=\pgfmathresult + \let\pgfmathaccuma=\pgfmathargb + \pgfplots@ifzero\pgfmathargb{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + }% + },% + % + % Produces 'log2( \prevrow{#1}/\thisrow{#1} ) + % + % Assumeing that every row contains error(h) = O(h^alpha) + % and h_this = h_prev/2, this result in 'alpha', the convergence + % rate. + /pgfplots/table/create col/dyadic refinement rate/.style={% + /pgfplots/table/columns={#1}, + /pgfplots/table/create col/assign first/.style={% + /pgfplots/table/create col/next content= + },% + /pgfplots/table/create col/assign/.code={% + \pgfmathfloatparsenumber{\prevrow{#1}}% + \let\pgfmatharga=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathargb=\pgfmathresult + \let\pgfmathaccuma=\pgfmathargb + \pgfplots@ifzero\pgfmathargb{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \pgfmathlog@float{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathmultiply@{1.442695}{\pgfmathresult}% + \fi + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + }% + },% + /pgfplots/table/create col/idyadic refinement rate/.style={% + /pgfplots/table/columns={#1}, + /pgfplots/table/create col/assign first/.style={% + /pgfplots/table/create col/next content= + },% + /pgfplots/table/create col/assign/.code={% + \pgfmathfloatparsenumber{\prevrow{#1}}% + \let\pgfmathargb=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmatharga=\pgfmathresult + \let\pgfmathaccuma=\pgfmathargb + \pgfplots@ifzero\pgfmathargb{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \pgfmathlog@float{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathmultiply@{1.442695}{\pgfmathresult}% + \fi + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + }% + },% + /pgfplots/table/create col/gradient/.style 2 args={% + /pgfplots/table/columns={#1,#2}, + /pgfplots/table/create col/assign first/.code={% + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathaccuma=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#2}}% + \let\pgfmathaccumb=\pgfmathresult + \def\pgfmathresult{}% leave first empty. + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + /pgfplots/table/create col/assign/.code={% + \let\pgfmathcur@x=\pgfmathaccuma + \let\pgfmathcur@y=\pgfmathaccumb + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathnext@x=\pgfmathresult + \let\pgfmathaccuma=\pgfmathnext@x + \pgfmathfloatparsenumber{\thisrow{#2}}% + \let\pgfmathnext@y=\pgfmathresult + \let\pgfmathaccumb=\pgfmathnext@y + \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}% + \let\pgfmathdiff@x=\pgfmathresult + \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% + \let\pgfmathdiff@y=\pgfmathresult + \pgfplots@ifzero\pgfmathdiff@x{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + },% + },% + /pgfplots/table/create col/gradient loglog/.style 2 args={% + /pgfplots/table/columns={#1,#2}, + /pgfplots/table/create col/assign first/.code={% + \pgfmathlog{\thisrow{#1}}% + \let\pgfmathaccuma=\pgfmathresult + \pgfmathlog{\thisrow{#2}}% + \let\pgfmathaccumb=\pgfmathresult + \def\pgfmathresult{}% leave first empty. + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + /pgfplots/table/create col/assign/.code={% + \let\pgfmathcur@x=\pgfmathaccuma + \let\pgfmathcur@y=\pgfmathaccumb + \pgfmathlog{\thisrow{#1}}% + \let\pgfmathnext@x=\pgfmathresult + \let\pgfmathaccuma=\pgfmathresult + \pgfmathlog{\thisrow{#2}}% + \let\pgfmathnext@y=\pgfmathresult + \let\pgfmathaccumb=\pgfmathresult + \pgfplots@loop@CONTINUEtrue + \ifx\pgfmathcur@x\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi + \ifx\pgfmathcur@y\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi + \ifx\pgfmathnext@x\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi + \ifx\pgfmathnext@y\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi + \ifpgfplots@loop@CONTINUE + \pgfmathsubtract@{\pgfmathnext@x}{\pgfmathcur@x}% + \let\pgfmathdiff@x=\pgfmathresult + \pgfmathsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% + \let\pgfmathdiff@y=\pgfmathresult + % FPU is more robust: + \pgfmathfloatparsenumber\pgfmathdiff@x\let\pgfmathdiff@x=\pgfmathresult + \pgfmathfloatparsenumber\pgfmathdiff@y\let\pgfmathdiff@y=\pgfmathresult + \pgfplots@ifzero\pgfmathdiff@x{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + \else + % \pgfmathfloatcreate{3}{0.0}{0}% + % \pgfmathfloattosci@\pgfmathresult + % \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + \fi + },% + },% + /pgfplots/table/create col/gradient semilogx/.style 2 args={% + /pgfplots/table/columns={#1,#2}, + /pgfplots/table/create col/assign first/.code={% + \pgfmathfloatparsenumber{\thisrow{#1}} + \pgfmathfloatln@{\pgfmathresult}% + \let\pgfmathaccuma=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#2}}% + \let\pgfmathaccumb=\pgfmathresult + \def\pgfmathresult{}% leave first empty. + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + /pgfplots/table/create col/assign/.code={% + \let\pgfmathcur@x=\pgfmathaccuma + \let\pgfmathcur@y=\pgfmathaccumb + \pgfmathfloatparsenumber{\thisrow{#1}} + \pgfmathfloatln@{\pgfmathresult}% + \let\pgfmathnext@x=\pgfmathresult + \let\pgfmathaccuma=\pgfmathresult + % + \pgfmathfloatparsenumber{\thisrow{#2}}% + \let\pgfmathnext@y=\pgfmathresult + \let\pgfmathaccumb=\pgfmathresult + \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}% + \let\pgfmathdiff@x=\pgfmathresult + \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% + \let\pgfmathdiff@y=\pgfmathresult + \pgfplots@ifzero\pgfmathdiff@x{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + },% + },% + /pgfplots/table/create col/gradient semilogy/.style 2 args={% + /pgfplots/table/columns={#1,#2}, + /pgfplots/table/create col/assign first/.code={% + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathaccuma=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#2}} + \pgfmathfloatln@{\pgfmathresult}% + \let\pgfmathaccumb=\pgfmathresult + \def\pgfmathresult{}% leave first empty. + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + /pgfplots/table/create col/assign/.code={% + \let\pgfmathcur@x=\pgfmathaccuma + \let\pgfmathcur@y=\pgfmathaccumb + \pgfmathfloatparsenumber{\thisrow{#2}} + \pgfmathfloatln@{\pgfmathresult}% + \let\pgfmathnext@y=\pgfmathresult + \let\pgfmathaccumb=\pgfmathresult + % + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathnext@x=\pgfmathresult + \let\pgfmathaccuma=\pgfmathresult + \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}% + \let\pgfmathdiff@x=\pgfmathresult + \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% + \let\pgfmathdiff@y=\pgfmathresult + \pgfplots@ifzero\pgfmathdiff@x{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + },% + },% + /pgfplots/table/typeset cell/.code={% + \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax + \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1\\}% + \else + \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1&}% + \fi + }, + % this can be omitted to omit the header row: + /pgfplots/table/output empty row/.style={% + /pgfplots/table/typeset cell/.code={% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfutil@empty% + }% + }, + /pgfplots/table/reset styles/.style={ + /pgfplots/table/every table/.code=, + /pgfplots/table/every odd column/.code=, + /pgfplots/table/every even column/.code=, + /pgfplots/table/every first column/.code=, + /pgfplots/table/every last column/.code=, + /pgfplots/table/every head row/.code=, + /pgfplots/table/every odd row/.code=, + /pgfplots/table/every even row/.code=, + /pgfplots/table/every first row/.code=, + /pgfplots/table/every last row/.code=, + /pgfplots/table/postproc cell content/.code=, + /pgfplots/table/preproc cell content/.code=, + }, + /pgfplots/table/colnames from/.initial=,% for \pgfplotstabletranspose + /pgfplots/table/input colnames to/.initial=colnames,% for \pgfplotstabletranspose + /pgfplots/table/sort/.is if=pgfplotstable@sort, + /pgfplots/table/sort/.default=true, + /pgfplots/table/sort key/.initial=[index]0,% + % the argument of `sort cmp' will be evaluates as style in the key + % path /pgfplots/. See pgfplotsutil.code.tex for available + % styles. + /pgfplots/table/sort cmp/.initial=float <, + /pgfplots/table/sort key from/.initial=, +} +% 'function graph cut y'={}{}{comma-separated-list of specs where to get yi} +% +% fills the column with x1,...,xN such that yi(xi) == epsilon where +% +% In other words, it computes cuts points between the line +% y == epsilon and one or more other plots yi(x) and returns the 'x' +% values of the cuts. +% +% Example: +% \pgfplotstableset{ +% create on use/cut/.style={create col/function graph cut y={7e-4}{x=Basis,ymode=log,xmode=log}{{table=regtable,y=special-L2}}}, +%} +\pgfkeysdefnargs{/pgfplots/table/create col/function graph cut y}{3}{\pgfplotstable@fgc@init{#1}{#2}{#3}{y}{x}} +\pgfkeysdefnargs{/pgfplots/table/create col/function graph cut x}{3}{\pgfplotstable@fgc@init{#1}{#2}{#3}{x}{y}} +\pgfkeys{% + /pgfplots/table/create col/function graph cut/xmode/.is choice, + /pgfplots/table/create col/function graph cut/xmode/linear/.code={\def\pgfplotstable@fgc@xmode{0}},% + /pgfplots/table/create col/function graph cut/xmode/log/.code={\def\pgfplotstable@fgc@xmode{1}},% + /pgfplots/table/create col/function graph cut/ymode/.is choice, + /pgfplots/table/create col/function graph cut/ymode/linear/.code={\def\pgfplotstable@fgc@ymode{0}},% + /pgfplots/table/create col/function graph cut/ymode/log/.code={\def\pgfplotstable@fgc@ymode{1}},% + /pgfplots/table/create col/function graph cut/x/.initial=, + /pgfplots/table/create col/function graph cut/y/.initial=, + /pgfplots/table/create col/function graph cut/table/.initial=, + % foreach={\d in {1,2,3,4}}{{table\d}} + /pgfplots/table/create col/function graph cut/foreach/.initial=, +} + + +\pgfkeyslet{/pgfplots/table/TeX comment}\pgfplots@PERCENT@TEXT +\pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent@EMPTY + + +% A helper macro to automatically remove the "hangover" created by +% 'colortbl'. +% This allows compatibility between my 'sci sep align' and 'dec sep align' +% implementations and \rowcolor. Otherwise, the hangover +% would overwrite digits near the separator. +% +% @remark This does also work if colortbl is not loaded. +\def\pgfplotstableresetcolortbloverhangright{% + \pgfutil@ifundefined{CT@row@color}{\relax}{% + \global\let\pgfplots@origrowcolorcmd=\CT@row@color + \gdef\CT@row@color{% + \pgfplots@origrowcolorcmd + \@tempdimc=0pt + \global\let\CT@row@color=\pgfplots@origrowcolorcmd + }% + }% +}% +\def\pgfplotstableresetcolortbloverhangleft{% + \pgfutil@ifundefined{CT@row@color}{\relax}{% + \global\let\pgfplots@origrowcolorcmd=\CT@row@color + \gdef\CT@row@color{% + \pgfplots@origrowcolorcmd + \@tempdimb=0pt + \global\let\CT@row@color=\pgfplots@origrowcolorcmd + }% + }% +}% + + +% \pgfplotstablesave[]{<\tablename>}{file name} +\def\pgfplotstablesave{% + \pgfutil@ifnextchar[{% + \pgfplotstablesave@impl + }{% + \pgfplotstablesave@impl[]% + }% +} + +\def\pgfplotstablesave@impl[#1]#2#3{% + \pgfplotstabletypeset[% + reset styles,% + disable rowcol styles,% + begin table={},% + end table={},% + typeset cell/.code={% + \begingroup + \t@pgfplots@toka={##1}% + \ifcase\pgfplotstableread@OUTCOLSEP@CASE\relax + % col sep=SPACE: + \t@pgfplots@tokb=\expandafter{\pgfplotstableread@tab}% + \pgfplots@ifempty{##1}{% + \t@pgfplots@toka={{}}% + }{}% + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \or + % col sep=comma: + \t@pgfplots@tokb={,}% + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \or + % col sep=semicolon: + \t@pgfplots@tokb={;}% + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \or + % col sep=colon: + \t@pgfplots@tokb={:}% + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \or + % col sep=braces: + \xdef\pgfplots@glob@TMPc{{\the\t@pgfplots@toka}}% + \or + % col sep=tab: + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\pgfplotstableread@tab}% + \or + % col sep=&: + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka&}% + \fi + \endgroup + \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPc% + },% + before row=,% + after row=,% + skip coltypes,% + typeset=false,% + string type,% + TeX comment=,% + columns=,% + font=,% + /pgfplots/table/col sep/.is choice,% + /pgfplots/table/col sep/space/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{0}},% + /pgfplots/table/col sep/comma/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{1}},% + /pgfplots/table/col sep/semicolon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{2}},% + /pgfplots/table/col sep/colon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{3}},% + /pgfplots/table/col sep/braces/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{4}},% + /pgfplots/table/col sep/tab/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{5}},% + /pgfplots/table/col sep/&/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{6}},% + /pgfplots/table/col sep/ampersand/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{6}},% + /pgfplots/table/col sep=space,% + /pgfplots/table/in col sep/.is choice,% + /pgfplots/table/in col sep/space/.code = {\def\pgfplotstableread@COLSEP@CASE{0}},% + /pgfplots/table/in col sep/comma/.code = {\def\pgfplotstableread@COLSEP@CASE{1}},% + /pgfplots/table/in col sep/semicolon/.code = {\def\pgfplotstableread@COLSEP@CASE{2}},% + /pgfplots/table/in col sep/colon/.code = {\def\pgfplotstableread@COLSEP@CASE{3}},% + /pgfplots/table/in col sep/braces/.code = {\def\pgfplotstableread@COLSEP@CASE{4}},% + /pgfplots/table/in col sep/tab/.code = {\def\pgfplotstableread@COLSEP@CASE{5}},% + /pgfplots/table/in col sep/&/.code = {\def\pgfplotstableread@COLSEP@CASE{6}},% + /pgfplots/table/in col sep/ampersand/.code = {\def\pgfplotstableread@COLSEP@CASE{6}},% + /pgfplots/table/in col sep=space,% + % WARNING: you NEED a '%' before '#1': + #1,% + /pgfplots/table/include outfiles=false, + /pgfplots/table/outfile={#3}% + ]{#2}% +}% + +% clears the table. +\def\pgfplotstableclear#1{% + \let#1=\relax + \expandafter\let\csname \string#1@@table@name\endcsname=\relax +}% + + +% \pgfplotstablenew[]{}{<\name>} +% \pgfplotstablenew*[]{}{<\name>} +% +% Creates a new table from scratch. +% +% The new table will contain all columns listed in the 'columns' key +% which must be present in . The starred version +% \pgfplotstablenew* is not that strict: it will use the current value +% of the columns key (not matter where and when it has been set). +% +% Furthermore, there must be 'create on use' statements for every +% column which shall be generated. Columns are generated +% independently, in the order of appearance in 'columns'. +% The table will contain exactly rows. +\def\pgfplotstablenew{% + \begingroup + \pgfutil@ifnextchar*{\pgfplotstablenew@star}{\pgfplotstablenew@nostar}} +\def\pgfplotstablenew@star*{\pgfutil@ifnextchar[{\pgfplotstablenew@impl}{\pgfplotstablenew@impl[]}}% +\def\pgfplotstablenew@nostar{% + % reset columns key: + \pgfkeyslet{/pgfplots/table/columns}{\pgfutil@empty}% + \pgfutil@ifnextchar[{\pgfplotstablenew@impl}{\pgfplotstablenew@impl[]}} + +\def\pgfplotstablenew@impl[#1]#2#3{% + \ifx#3\pgfutil@undefined + \else + \ifx#3\relax + \else + % oh - there *is* already such a table. The 'getcolumnbyname' method suffers from a flaw in 'ifexists' that I do not want to fix right now. + % To work around that flaw, I merely clear the old table here: + % let's hope that '#3' really *was* a table and not some other junk... + \pgfplotslistforeachungrouped#3\as\pgfplotstable@loc@TMPa{% + \expandafter\let\csname\string#3@\pgfplotstable@loc@TMPa\endcsname=\relax% + }% + \fi + \fi + % + \pgfplotsscanlinelengthinitzero + % create a temporary column with the desired number of rows: + \pgfutil@in@\pgfplotstablegetrowsof{#2}% + \ifpgfutil@in@ + #2% + \let\pgfplotstable@loc@TMPa=\pgfmathresult + \else + \def\pgfplotstable@loc@TMPa{#2}% + \fi + \pgfplotslistnew#3{@@@@@temporary@column@\\}% + \expandafter\pgfplots@assign@list\csname\string#3@@@@@@temporary@column@\endcsname{1,2,...,\pgfplotstable@loc@TMPa}% + % + % now, create all real columns: + \pgfplotstableset{#1,% + /pgf/fpu/handlers/empty number/.code 2 args={% + \pgfmathfloatcreate{0}{0.0}{0}% + }% + }% + \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% + \ifx\pgfplotstable@colnames\pgfutil@empty + \pgfplots@warning{\string\pgfplotstablenew[columns={},...]{#2}{\string#3} has been invoked - but empty tables are currently not really supported, sorry. You will have to live with an artifical column which contains temporary values.}% + \else + \expandafter\pgfplots@assign@list\expandafter\pgfplotstablenew@cols\expandafter{\pgfplotstable@colnames}% + % make sure every requested column exists: + \pgfutil@loop + \pgfplotslistcheckempty\pgfplotstablenew@cols + \ifpgfplotslistempty + \pgfplots@loop@CONTINUEfalse + \else + \pgfplots@loop@CONTINUEtrue + \fi + \ifpgfplots@loop@CONTINUE + \pgfplotslistpopfront\pgfplotstablenew@cols\to\pgfplotstablenew@col + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstablenew@col}\of#3\to\pgfplotstable@loc@TMPa + \pgfutil@repeat + % remove the temporary column: + % FIXME this should be done after the '\fi'. But that will + % lead to an error because empty tables are currently + % unsupported! + \pgfplotslistpopfront#3\to\pgfplotstable@loc@TMPa + \fi + \pgfplotsscanlinelengthcleanup + \pgfplotstable@copy@to@globalbuffers#3{newlycreatedtable}% + \endgroup + \pgfplotstable@copy@globalbuffers@to#3% +}% + +% \pgfplotstablevertcat{}{} +% appends the contents of to . To be more precise, +% only columns which exist already in will be used. +% +% If is undefined, will be copied completely to +% . +% +% #1 a table macro. +% #2 either a file name or a table macro. +\long\def\pgfplotstablevertcat#1#2{% + \pgfplotstable@isloadedtable{#2}{% + \pgfplotstable@isloadedtable{#1}{% + % for each column in '#1': + \pgfplotslistforeachungrouped#1\as\pgfplotstable@loc@TMPa{% + % for each row in the corresponding column of '#2': + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@loc@TMPa}\of{#2}\to\pgfplotstable@loc@TMPb + \pgfplotslistforeachungrouped\pgfplotstable@loc@TMPb\as\pgfplotstable@loc@TMPc{% + \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPc}% + \edef\pgfplotstable@loc@TMPd{% + \noexpand\pgfplotslistpushback{\the\t@pgfplots@toka}\to\expandafter\noexpand\csname\string#1@\pgfplotstable@loc@TMPa\endcsname + }% + \pgfplotstable@loc@TMPd + }% + }% + }{% + \pgfplotstablecopy{#2}\to{#1}% + }% + }{% + % FIXME : restore memory here !? SCOPING BUG + \pgfplotstableread{#2}\pgfplotstable@tmptbl + \pgfplotstablevertcat{#1}{\pgfplotstable@tmptbl}% + }% +} + +% \pgfplotstabletranspose{<\outtable>}{} +% \pgfplotstabletranspose[]{<\outtable>}{} +% Defines <\outtable> to be the transposed of . +% +% If is not empty, the respective column's entries will be used to +% make output column names. +% +% #1: a table macro name which will be overwritten (redefined) +% #2: either a file name or a table macro (loaded table). +\def\pgfplotstabletranspose{% + \begingroup + \pgfutil@ifnextchar*{% + \pgfplotstabletranspose@star% + }{% + \pgfkeyslet{/pgfplots/table/columns}\pgfutil@empty% clear! + \pgfplotstabletranspose@star*% + }% +} +\def\pgfplotstabletranspose@star*{\pgfutil@ifnextchar[{\pgfplotstabletranspose@opt}{\pgfplotstabletranspose@opt[]}}% +\long\def\pgfplotstabletranspose@opt[#1]#2#3{% + \pgfplotstable@isloadedtable{#3}{% + \pgfplotstabletranspose@[#1]{#2}{#3}% + }{% + \pgfplotstableread{#3}\pgfplotstable@tmptbl + \pgfplotstabletranspose@[#1]{#2}{\pgfplotstable@tmptbl}% + }% +}% + + +% Creates a new column named #1 and appends it to table #2. +% +% The column entries will be created using the command keys +% 'create col/assign' +% 'create col/assign last' +% +% The key 'create col/assign' will be invoked for every row of table #2. +% It is supposed to assign the key 'create col/next content'. +% During evaluation of 'create col/assign', the macro '\thisrow{}' +% expands to the current row's value of the column named by . +% Furthermore, '\nextrow{}' expands to the \emph{next} row's +% value of the designated column. +% +% Since the "next row" is not available if we are currently processing +% the last row, 'create col/assign last' is used in for the last row's +% value. +% +% You can use +% - \thisrow{}, +% - \getthisrow{}{\macro} +% - \nextrow{}, +% - \getnextrow{}{\macro} +% +% FIXME this documentation is incomplete. Please refer to pgfplotstable.pdf . +\def\pgfplotstablecreatecol{% + \pgfutil@ifnextchar[{% + \pgfplotstablecreatecol@opt + }{% + \pgfplotstablecreatecol@opt[]% + }% +}% + + +% Typesets a table. +% +% \pgfplotstabletypeset[]<\tablestructure> +% or +% \pgfplotstabletypeset[]{} +% +% If you do not select any columns, the complete table is drawn. +% +% There are several options and styles which are available in +% , see the declaration above. +% +% ATTENTION: the default implementation employs +% \begin{tabular}...\end{tabular} and is therefor only usable with +% LaTeX! +% +% You will need to reconfigure the tables. +% +% Inside of \pgfplotstabletypeset, the macros +% \pgfplotstablecol,\pgfplotstablecolname and +% \pgfplotstablerow will expand to the current column index, column +% name and row index, respectively. +\def\pgfplotstabletypeset{% + \pgfutil@ifnextchar[{% + \pgfplotstabletypeset@opt + }{% + \pgfplotstabletypeset@opt[]% + }% +} +\long\def\pgfplotstabletypeset@opt[#1]{% + \begingroup + \ifpgfplots@table@options@areset + \else + \pgfplotstableset{#1}% + \fi + \pgfplotstablecollectoneargwithpreparecatcodes{% + \pgfplotstabletypeset@opt@collectarg[#1]% + }% +} +\long\def\pgfplotstabletypeset@opt@collectarg[#1]#2{% + \pgfplotstable@isloadedtable{#2}% + {\pgfplotstabletypeset@opt@[#1]{#2}}% + {\pgfplotstabletypesetfile@opt@[#1]{#2}}% +} + + +% Like \pgfplotstabletypeset, but the first argument is a file name. +% This is the same now; it will be recognised automatically. +\let\pgfplotstabletypesetfile=\pgfplotstabletypeset +\long\def\pgfplotstabletypesetfile@opt@[#1]#2{% + %\begingroup <--- is already opened! + \ifpgfplots@table@options@areset + \else + \pgfplotstableset@every@table{#2}{#1}% + \pgfplots@table@options@aresettrue + \fi + \ifpgfplotstabletypeset@force@remake + \pgfplotstabletypeset@includeoutfilesfalse + \else + \ifpgfplotstabletypeset@includeoutfiles + \pgfplotstabletypeset@includeoutfilesfalse + \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename + \ifx\pgfplotstable@outfilename\pgfutil@empty + \else + \openin\r@pgfplots@reada=\pgfplotstable@outfilename\relax + \ifeof\r@pgfplots@reada + \else + \pgfplotstabletypeset@includeoutfilestrue + \fi + \closein\r@pgfplots@reada + \fi + \fi + \fi + \ifpgfplotstabletypeset@includeoutfiles + \input \pgfplotstable@outfilename\relax + \else + \pgfplotstableread{#2}\pgfplotstabletypesetfile@opt@@ + \ifx\pgfplotstabletypesetfile@opt@@\relax + % ERROR. + \else + \pgfplotstabletypeset\pgfplotstabletypesetfile@opt@@ + \fi + \fi + \pgfkeysgetvalue{/pgfplots/table/write to macro}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\pgfplots@loc@TMPa{\pgfutil@empty}% + \else + \expandafter\ifx\pgfplots@loc@TMPa\relax + % is it really defined? NO! Sanity checking here: + \def\pgfplots@loc@TMPa{\pgfutil@empty}% + \fi + \fi + \expandafter\pgfmath@smuggleone\pgfplots@loc@TMPa + \endgroup +}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% IMPLEMENTATION +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%% + + +% #1: the original value +% #2: the output macro +\long\def\pgfplotstabletypeset@getfinalentry#1#2{% + \begingroup + \def\pgfkeysdefaultpath{/pgfplots/table/}% + \def\pgfplotstablepartno{0}% + \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}% + \pgfkeyssetvalue{/pgfplots/table/@unprocessed cell content}{#1}% + \ifpgfplotstable@disable@rowcolstyles + \else + \def\pgfplots@loc@TMPb##1{% + \edef\pgfplotstable@loc@TMPa{/pgfplots/table/every row ##1\pgfplotstablerow\space column ##1\pgfplotstablecol}% + \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{% + \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}% + }{}% + \edef\pgfplotstable@loc@TMPa{/pgfplots/table/every row ##1\pgfplotstablerow\space column \pgfplotstable@colname@for@styles}% + \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{% + \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}% + }{}% + }% + \pgfplots@loc@TMPb{}% + % also accept the same with the 'row no' style: + \pgfplots@loc@TMPb{no }% + \pgfplotstable@debug@notify@cellcontent@afterrowcolstyles% + \fi + \pgfplotstable@debug@notify@cellcontent% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \pgfkeyslet{/pgfplots/table/@cell content after rowcol styles}\pgfmathresult% + \pgfkeysgetvalue{/pgfplots/table/preproc cell content/.@cmd}\pgfplotstable@assigncell + \expandafter\pgfplotstable@assigncell\pgfmathresult\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \pgfkeyslet{/pgfplots/table/@preprocessed cell content}\pgfmathresult% + \pgfplotstable@debug@notify@cellcontent@preprocessed% + % + \pgfkeysgetvalue{/pgfplots/table/assign cell content/.@cmd}\pgfplotstable@assigncell + \expandafter\pgfplotstable@assigncell\pgfmathresult\pgfeov + \pgfplotstable@debug@notify@cellcontent@assigned% + % + \pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent + \ifx\pgfplotstable@postproccellcontent\pgfplotstable@postproccellcontent@EMPTY + \else + % apply postprocessing to final cell content. + \def\pgfplotstabletypeset@rawinput{#1}% + % + % This is complicated if there is an '&' in '@cell content', + % so handle that specially! + % + % FIXME also support more than one '&' ? + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}% + \ifpgfutil@in@ + \expandafter\pgfplotstabletypeset@postproc@separately\pgfmathresult\pgfplotstable@EOI + \else + \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov + \fi + \fi + \pgfplotstable@debug@notify@cellcontent@postprocessed% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let#2=\pgfmathresult +}% + +\def\pgfplotstable@debug@notify@cellcontent{}% +\def\pgfplotstable@debug@notify@cellcontent@preprocessed{}% +\def\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles{}% +\def\pgfplotstable@debug@notify@cellcontent@assigned{}% +\def\pgfplotstable@debug@notify@cellcontent@postprocessed{}% +\def\pgfplotstable@debug@notify@preprocess@incol#1{}% +\def\pgfplotstable@debug@notify@preprocess@col#1{}% +\def\pgfplotstable@debug@notify@preprocessed@col#1{}% +\def\pgfplotstable@debug@notify@balancingcell{}% + +\def\pgfplotstable@debug@notify@cellcontent@ACTIVE{% + \begingroup + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \toks0=\expandafter{\pgfmathresult}% + \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: Before cell content processing: `\the\toks0'}% + \endgroup +}% +\def\pgfplotstable@debug@notify@cellcontent@preprocessed@ACTIVE{% + \begingroup + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \toks0=\expandafter{\pgfmathresult}% + \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After '@preproc cell content : `\the\toks0'}% + \endgroup +}% +\def\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles@ACTIVE{% + \begingroup + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \toks0=\expandafter{\pgfmathresult}% + \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After applying 'every row * column [no] *' styles : `\the\toks0'}% + \endgroup +}% +\def\pgfplotstable@debug@notify@cellcontent@assigned@ACTIVE{% + \begingroup + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \toks0=\expandafter{\pgfmathresult}% + \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After 'assign cell content : `\the\toks0'}% + \endgroup +}% +\def\pgfplotstable@debug@notify@cellcontent@postprocessed@ACTIVE{% + \begingroup + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \toks0=\expandafter{\pgfmathresult}% + \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After 'postproc cell content : `\the\toks0'}% + \endgroup +} +\def\pgfplotstable@debug@notify@balancingcell@ACTIVE{% + \immediate\write16{Row --/out \the\c@pgfplotstable@counta: Inserting empty cell to balance rows}% +}% +\def\pgfplotstable@debug@notify@preprocess@incol@ACTIVE#1{% + \begingroup + \toks0=\expandafter{#1}% + \immediate\write16{>=== Loading input column `\the\toks0' <===}% + \endgroup +}% +\def\pgfplotstable@debug@notify@preprocess@col@ACTIVE#1{% + \begingroup + \toks0=\expandafter{#1}% + \immediate\write16{>=== Preprocessing output column `\the\toks0' <===}% + \endgroup +}% +\def\pgfplotstable@debug@notify@preprocessed@col@ACTIVE#1{% + \begingroup + \toks0=\expandafter{#1}% + \immediate\write16{>=== output column `\the\toks0' prepared, ok. <===}% + \endgroup +}% +\def\pgfplotstable@debug@activate{% + \ifnum\pgfkeysvalueof{/pgfplots/table/debug level}>0 + \let\pgfplotstable@debug@notify@preprocess@incol=\pgfplotstable@debug@notify@preprocess@incol@ACTIVE + \let\pgfplotstable@debug@notify@preprocess@col=\pgfplotstable@debug@notify@preprocess@col@ACTIVE + \let\pgfplotstable@debug@notify@preprocessed@col=\pgfplotstable@debug@notify@preprocessed@col@ACTIVE + \let\pgfplotstable@debug@notify@cellcontent=\pgfplotstable@debug@notify@cellcontent@ACTIVE + \let\pgfplotstable@debug@notify@cellcontent@preprocessed=\pgfplotstable@debug@notify@cellcontent@preprocessed@ACTIVE + \let\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles=\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles@ACTIVE + \let\pgfplotstable@debug@notify@cellcontent@assigned=\pgfplotstable@debug@notify@cellcontent@assigned@ACTIVE + \let\pgfplotstable@debug@notify@cellcontent@postprocessed=\pgfplotstable@debug@notify@cellcontent@postprocessed@ACTIVE + \let\pgfplotstable@debug@notify@balancingcell=\pgfplotstable@debug@notify@balancingcell@ACTIVE + \fi +}% + +% This routine invokes 'postproc cell content' for columns which +% contain the column separator '&'. +% +% #1 is the formatted number, the result of 'dec sep align +% #3 is the (unformatted) input number. +\def\pgfplotstabletypeset@postproc@separately#1\pgfplotstable@EOI{% + \def\pgfmathresult{#1}% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfplotstable@entry@a + % + \def\pgfplotstablepartno{1}% + \def\pgfmathresult{#2}% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry@a}% + \t@pgfplots@tokb=\expandafter{\pgfmathresult}% + \edef\pgfmathresult{\the\t@pgfplots@toka&\the\t@pgfplots@tokb}% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult +} + +% processes the option 'assign column name' +% FIXME : seems to be deprecated +\def\pgfplotstabletypeset@assign@final@colname#1#2{% + \pgfkeysifdefined{/pgfplots/table/assign column name/.@cmd}{% + \pgfkeyssetvalue{/pgfplots/table/column name}{#1}% + \pgfkeysvalueof{/pgfplots/table/assign column name/.@cmd}#1\pgfeov + \pgfkeysgetvalue{/pgfplots/table/column name}{#2}% + }{}% +} +\def\pgfplotstabletypeset@nocolname{\pgfkeysnovalue} + +% checks if #1 contains invalid chars for pgfkeys and sets +% \ifpgfutil@in@ to true if that is the case. +\def\pgfplotstable@checkspecialchars@pgfkeys#1\pgfplotstable@EOI{% + \pgfutil@in@/{#1}% + \ifpgfutil@in@ + \else + \pgfutil@in@={#1}% + \ifpgfutil@in@ + \else + \pgfutil@in@,{#1}% + \fi + \fi +}% + +% Upon execution, \pgfplotsretval contains a set of /pgfplots/table +% keys from 'every nth row' styles. +% +% @PRECONDITION this macro assumes it is run in \pgfplotstabletypeset. +\def\pgfplots@each@nth@styles{\let\pgfplotsretval\pgfutil@empty}% + +% Defines an 'every nth row' style for an integer #1. +% +% #1: integer +% #2: style arguments +% +% All these styles are accumulated into the macro +% \pgfplots@each@nth@styles. +\def\pgfplotstabletypeset@append@every@nth@row#1#2{% + \edef\pgfplots@loc@TMPa{#1}% + % chech for the special 'each nth row={3[+1]}{...} format: + \expandafter\pgfutil@in@\expandafter[\expandafter{\pgfplots@loc@TMPa}% + \ifpgfutil@in@ + \expandafter\pgfplotstabletypeset@append@every@nth@row@getshift\pgfplots@loc@TMPa% + \t@pgfplots@toka={#2}% + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplotstabletypeset@append@every@nth@row@{\pgfplots@loc@TMPa}{\the\t@pgfplots@toka}{\pgfplots@loc@TMPb}% + }% + \pgfplots@loc@TMPa + \else + \expandafter\pgfplotstabletypeset@append@every@nth@row@\expandafter{\pgfplots@loc@TMPa}{#2}{0}% + \fi +}% +\def\pgfplotstabletypeset@append@every@nth@row@getshift#1[#2]{% + \def\pgfplots@loc@TMPa{#1}% + \ifnum#2<0 + \c@pgf@countc=#1\relax + \advance\c@pgf@countc by#2 + \edef\pgfplots@loc@TMPb{\the\c@pgf@countc}% + \else + \def\pgfplots@loc@TMPb{#2}% + \fi +}% +% #3 is an additional shift. It is usually 0 +\def\pgfplotstabletypeset@append@every@nth@row@#1#2#3{% + \expandafter\def\expandafter\pgfplots@each@nth@styles\expandafter{% + \pgfplots@each@nth@styles + \expandafter\pgfplotsmathmodint\expandafter{\the\c@pgfplotstable@rowindex}{#1}% + \ifnum\pgfmathresult=#3\relax + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{#2}% + \else + \expandafter\def\expandafter\pgfplotsretval\expandafter{\pgfplotsretval,% + #2}% + \fi + \fi + }% +} + +\def\pgfplotstable@insertemptycells@forbalance{% + \pgfutil@loop + \ifnum\c@pgfplotstable@counta<\pgfplotstable@firstnumrows\relax + \pgfplotstable@debug@notify@balancingcell + % let's hope @getfinalentry handles empty strings! + \pgfplotstabletypeset@getfinalentry{}{\pgfplotstable@entry}% + \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed + \pgfplotslistpushback\to\pgfplotstable@col@processed + \advance\c@pgfplotstable@counta by1\relax + \pgfutil@repeat +} + +% TODO +% - replace grouped list foreach by popfront-loop and use arrays +% directly -> group only the pgfkeys eval +\long\def\pgfplotstabletypeset@opt@[#1]#2{% + %\begingroup <--- is already opened! + %-------------------------------------------------- + % \pgfutil@ifundefined{#2}{% + % \pgfplots@error{There is no such table '\string#2' loaded into memory. Maybe you meant to use '\string\pgfplotstabletypesetfile{\string#2}' instead of '\string\pgfplotstabletypeset{\string#2}'?}% + % \pgfplotslistnewempty#2 + % }{}% + %-------------------------------------------------- + \def\pgfplotstablename{#2}% the name of the actual table struct + \def\pgfplotstablecolname{\pgfplotstable@colname}% + \def\pgfplotstablecol{\the\c@pgfplotstable@colindex}% + \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}% + \def\pgfplotstablecols{\the\c@pgfplotstable@numcols}% + \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}% + \ifpgfplots@table@options@areset + \else + \pgfplotstablegetname{#2}\pgfplotstable@loc@TMPa + \expandafter\pgfplotstableset@every@table\expandafter{\pgfplotstable@loc@TMPa}{#1}% + \fi + \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename + \pgfkeysgetvalue{/pgfplots/table/TeX comment}\pgfplots@TeX@comment + \ifpgfplotstabletypeset@force@remake + \pgfplotstabletypeset@includeoutfilesfalse + \else + \ifpgfplotstabletypeset@includeoutfiles + \pgfplotstabletypeset@includeoutfilesfalse + \ifx\pgfplotstable@outfilename\pgfutil@empty + \else + \pgfplots@logfileopen{\pgfplotstable@outfilename}% + \openin\r@pgfplots@reada=\pgfplotstable@outfilename\relax + \ifeof\r@pgfplots@reada \else\pgfplotstabletypeset@includeoutfilestrue \fi + \closein\r@pgfplots@reada + \fi + \fi + \fi + \ifpgfplotstabletypeset@includeoutfiles + \def\pgfplots@loc@TMPa{% + \input \pgfplotstable@outfilename\relax + \endgroup + }% + \else + \def\pgfplots@loc@TMPa{% + \pgfplotstabletypeset@opt@prepare{#2}% + }% + \fi + \pgfplots@loc@TMPa +}% +\def\pgfplotstabletypeset@opt@prepare#1{% + % + % Prepare outfile and debug options: + \let\pgfplotstable@notify@finished@line=\pgfutil@empty + % + % FLUSH assumes that \pgfplotstable@curline is finished. It + % appends all its contents as-is to \pgfplotstable@result. + % + % Furthermore, it calls \pgfplotstable@notify@finished@line which + % in turn may invoke additional output routines for the debug and + % outfile options. + % + % Finally, it resets \pgfplotstable@curline. + \def\pgfplotstable@curline@FLUSH{% + \pgfplotstable@notify@finished@line + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \let\pgfplotstable@curline=\pgfutil@empty + }% + \ifpgfplotstabletypesetdebug + \immediate\write16{------- PGFPLOTSTABLE DEBUG MODE: --------}% + \expandafter\def\expandafter\pgfplotstable@notify@finished@line\expandafter{\pgfplotstable@notify@finished@line + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \immediate\write16{\the\t@pgfplots@toka\pgfplots@TeX@comment}% + }% + \pgfplotstable@debug@activate + \fi + \ifx\pgfplotstable@outfilename\pgfutil@empty + \else + \immediate\openout\pgfplotstable@outfile=\pgfplotstable@outfilename\relax + \expandafter\def\expandafter\pgfplotstable@notify@finished@line\expandafter{\pgfplotstable@notify@finished@line + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \immediate\write\pgfplotstable@outfile{\the\t@pgfplots@toka\pgfplots@TeX@comment}% + }% + \fi + % + % Start operation: + \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% + \ifx\pgfplotstable@colnames\pgfutil@empty + \pgfplotstablegetcolumnlist#1\to\pgfplotstable@colnames + \else + \expandafter\pgfplotslistnew\expandafter\pgfplotstable@colnames\expandafter{\pgfplotstable@colnames}% + \fi + % + % + \ifpgfplotstable@sort + % make sure any columns exist (especially create on use). + % this can be done by calling getcolumnbyname once for every + % column: + \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{% + \pgfplotstable@is@colname\pgfplotstable@colname + \ifpgfplotstableread@foundcolnames + \else + \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#1\to\pgfplotstable@colname + \fi + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@colname}\of#1\to\pgfplotstable@col + }% + \let\pgfplotstable@colname=\relax + \let\pgfplotstable@col=\relax + % + \def\pgfplots@loc@TMPa{% + \pgfplotstablesort\pgfplotstable@sortedtbl{#1}% + \pgfplotstabletypeset@opt@@{\pgfplotstable@sortedtbl}% + }% + \else + \def\pgfplots@loc@TMPa{% + \pgfplotstabletypeset@opt@@{#1}% + }% + \fi + \pgfplots@loc@TMPa +} +\def\pgfplotstabletypeset@opt@@#1{% + \global\pgfplotslistnewempty\pgfplotstabletypeset@final@colnames + \global\pgfplotslistnewempty\pgfplotstabletypeset@final@coltypes + \global\pgfplotslistnewempty\pgfplotstabletypeset@final@cols + \let\c@pgfplotstable@numcols=\c@pgf@counta + \let\c@pgfplotstable@numrows=\c@pgf@countd + \let\c@pgfplotstable@rowindex=\c@pgf@countc + \let\c@pgfplotstable@colindex=\c@pgf@countb + \pgfplotslistsize\pgfplotstable@colnames\to\c@pgfplotstable@numcols + \def\pgfplotstable@firstnumrows{-1}% + \c@pgfplotstable@numrows=-1\relax + \c@pgfplotstable@colindex=0\relax + % FOREACH COLUMN: + \pgfplotslistforeach\pgfplotstable@colnames\as\pgfplotstable@colname{% + \pgfplotstable@debug@notify@preprocess@incol\pgfplotstable@colname + % + \c@pgfplotstable@rowindex=0\relax + \pgfplotstable@is@colname\pgfplotstable@colname + \ifpgfplotstableread@foundcolnames + \else + \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#1\to\pgfplotstable@colname + \fi + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@colname}\of#1\to\pgfplotstable@col + % + % Init number of *input* rows here. This may not be the same + % as the number of *output* rows (see the row predicate + % below). + % + % Accessable with \pgfplotstablerows in style keys. + \ifnum\c@pgfplotstable@numrows=-1\relax + \pgfplotslistsize\pgfplotstable@col\to\c@pgfplotstable@numrows + \global\c@pgfplotstable@numrows=\c@pgfplotstable@numrows + \fi + % + % + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % Set keys for columns! + \ifodd\c@pgfplotstable@colindex + \t@pgfplots@toka={every odd column}% + \else + \t@pgfplots@toka={every even column}% + \fi + \ifnum\c@pgfplotstable@colindex=0\relax + \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first column}% + \fi + % save this now before we increment '\c@pgfplotstable@colindex': + \edef\pgfplotstable@displaycolkey{display columns/\the\c@pgfplotstable@colindex/.try,every col no \the\c@pgfplotstable@colindex/.try}% + % + \global\advance\c@pgfplotstable@colindex by1\relax + \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols + \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last column}% + \fi + % temporarily restore it: we may need it in row predicates: + \global\advance\c@pgfplotstable@colindex by-1\relax + \ifpgfplotstable@disable@rowcolstyles + % ok, then don't check for 'columns/' and + % 'display columns/': + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka}% + \else + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname}% + \expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\t@pgfplots@tokb\pgfplotstable@EOI + \ifpgfutil@in@ + \edef\pgfplotstable@colname@for@styles{{\the\t@pgfplots@tokb}}% + \else + \edef\pgfplotstable@colname@for@styles{\the\t@pgfplots@tokb}% + \fi + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/\pgfplotstable@colname@for@styles/.try}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@displaycolkey}% + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% + \fi + \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}% + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % + \pgfkeysgetvalue{/pgfplots/table/column name}{\pgfplotstable@colname@out}% + \ifx\pgfplotstable@colname@out\pgfplotstabletypeset@nocolname + \let\pgfplotstable@colname@out=\pgfplotstable@colname + \fi + \expandafter\pgfplotstabletypeset@assign@final@colname\expandafter{\pgfplotstable@colname@out}\pgfplotstable@colname@out + % + \pgfplotstable@debug@notify@preprocess@col\pgfplotstable@colname@out + % + \expandafter\pgfplotslistpushbackglobal\pgfplotstable@colname@out\to\pgfplotstabletypeset@final@colnames + \pgfkeysgetvalue{/pgfplots/table/column type}{\pgfplotstable@coltype}% + \expandafter\pgfplotslistpushbackglobal\pgfplotstable@coltype\to\pgfplotstabletypeset@final@coltypes + % + \pgfplotslistnewempty\pgfplotstable@col@processed + \c@pgfplotstable@counta=0 + \pgfplotslistforeachungrouped\pgfplotstable@col\as\pgfplotstable@entry{% + \pgfplotstableuserowtrue + \edef\pgfplotstable@loc@TMPa{\noexpand\pgfkeysvalueof{/pgfplots/table/row predicate/.@cmd}\the\c@pgfplotstable@rowindex}% + \pgfplotstable@loc@TMPa\pgfeov + \ifpgfplotstableuserow + \ifnum\pgfplotstable@firstnumrows=-1\relax + \else + \ifnum\c@pgfplotstable@counta<\pgfplotstable@firstnumrows\relax + \else + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname@out}% + \pgfplots@warning{Unbalanced cell with content '\the\t@pgfplots@toka' of column '\the\t@pgfplots@tokb' has been skipped: row count \the\c@pgfplotstable@counta+1 > \pgfplotstable@firstnumrows (which is the number of rows in the first column)}% + \pgfplotstableuserowfalse + \fi + \fi + \ifpgfplotstableuserow + \expandafter\pgfplotstabletypeset@getfinalentry\expandafter{\pgfplotstable@entry}{\pgfplotstable@entry}% + \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed + \advance\c@pgfplotstable@counta by1\relax + \fi + \fi + \advance\c@pgfplotstable@rowindex by1\relax + }% + \ifnum\pgfplotstable@firstnumrows=-1\relax + \xdef\pgfplotstable@firstnumrows{\the\c@pgfplotstable@counta}% + \else + % balance columns: + \pgfplotstable@insertemptycells@forbalance + \fi + % + \pgfplotstable@debug@notify@preprocessed@col\pgfplotstable@colname@out + % + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols + \global\advance\c@pgfplotstable@colindex by1\relax + }% + % + \pgfplotstable@disable@column@styles + % + \pgfplotslistcheckempty\pgfplotstabletypeset@final@colnames + \ifpgfplotslistempty + \let\pgfplotstable@result=\pgfutil@empty + \else + % Ok, I have now everything which will come into the final table. + % + % But I have it column-oriented; I need to transpose the storage. + % + % The following code assembles a + % \begin{tabular}{} + % ... + % \end{tabular} + % statement piece after piece. + % + %\message{I have now \meaning\pgfplotstabletypeset@final@colnames, and \meaning\pgfplotstabletypeset@final@cols.}% + % Step 1: column names. + \c@pgfplotstable@colindex=0\relax + \c@pgfplotstable@rowindex=-1\relax + \let\pgfplotstable@result=\pgfutil@empty + % + \pgfkeysgetvalue{/pgfplots/table/font}{\pgfplotstable@font}% + \ifx\pgfplotstable@font\pgfutil@empty + \else + \t@pgfplots@toka=\expandafter{\pgfplotstable@font}% + \edef\pgfplotstable@curline{\noexpand\begingroup\the\t@pgfplots@toka}% + \pgfplotstable@curline@FLUSH + \fi + % + \pgfkeysgetvalue{/pgfplots/table/begin table}{\pgfplotstable@entry}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka}% + % + \ifpgfplotstabletypesetskipcoltypes + \else + % STEP 1.1: collect column types: + \def\pgfplotstable@resulttypes{}% + \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@coltypes\as\pgfplotstable@coltype{% + \t@pgfplots@toka=\expandafter{\pgfplotstable@resulttypes}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@coltype}% + \edef\pgfplotstable@resulttypes{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + }% + \ifx\pgfplotstable@resulttypes\pgfutil@empty + \else + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@resulttypes}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}% + \fi + \fi + \ifx\pgfplotstable@curline\pgfutil@empty + \else + \pgfplotstable@curline@FLUSH + \fi + % + % Step 1.2: Collect FIRST ROW (column names) + \begingroup + \pgfplotstableset{every head row}% + \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}% + \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% + \xdef\pgfplots@glob@TMPc{% + \noexpand\def\noexpand\pgfplotstable@before{\the\t@pgfplots@toka}% + \noexpand\def\noexpand\pgfplotstable@after{\the\t@pgfplots@tokb}% + }% + \pgfkeysgetvalue{/pgfplots/table/typeset cell/.@cmd}\pgfplots@loc@TMPa + \global\let\pgfplots@glob@TMPd=\pgfplots@loc@TMPa + \endgroup + \pgfplots@glob@TMPc + \let\pgfplotstable@headrow@typesetcell=\pgfplots@glob@TMPd + % insert 'before row' here: + \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}% + \edef\pgfplotstable@curline{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + % + \def\pgfplotstablecolname{\pgfplotstable@colname@out}% + \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@colnames\as\pgfplotstable@colname@out{% + % + \advance\c@pgfplotstable@colindex by1\relax + % typeset the cell: + \expandafter\pgfplotstable@headrow@typesetcell\pgfplotstable@colname@out\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + % + % append this cell: + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \t@pgfplots@tokb=\expandafter{\pgfmathresult}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + }% + % insert 'after row' here: + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + % + \pgfplotstable@curline@FLUSH + % + %\message{I have now \meaning\pgfplotstable@result.}% + % Step 2: column contents. + % I will first convert \pgfplotstabletypeset@final@cols into an array. + \c@pgfplotstable@colindex=0\relax + \pgfplotsarraynewempty\pgfplotstabletypeset@final@cols@array + \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@cols\as\pgfplotstable@col@processed{% + \expandafter\pgfplotsarraypushback\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols@array + }% + % init numrows: + \pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed + \pgfplotslistsize\pgfplotstable@col@processed\to\c@pgfplotstable@numrows + % + % Now, we loop over every column as long as there are still rows + % left. We assemble rows while we go. + % + \c@pgfplotstable@rowindex=0\relax + \ifnum\c@pgfplotstable@colindex<\c@pgfplotstable@numcols + \pgfplots@loop@CONTINUEtrue + \else + \pgfplots@loop@CONTINUEfalse + \fi + \def\pgfplotstablecolname{\pgfplotstable@error{Sorry, you can't evaluate \string\pgfplotstablecolname\space in this context.}}% + \pgfutil@loop + \ifpgfplots@loop@CONTINUE + \pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed + \pgfplotslistcheckempty\pgfplotstable@col@processed + \ifpgfplotslistempty + % assume that each column has the same number of entries + % (normalised tables): + \pgfplots@loop@CONTINUEfalse + \else + \ifnum\c@pgfplotstable@colindex=0\relax + % Install styles for the next row. + \begingroup + \ifodd\c@pgfplotstable@rowindex + \t@pgfplots@toka={every odd row}% + \else + \t@pgfplots@toka={every even row}% + \fi + \ifnum\c@pgfplotstable@rowindex=0\relax + \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first row}% + \fi + \ifpgfplotstable@disable@rowcolstyles + \else + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,every row no \the\c@pgfplotstable@rowindex/.try}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% + % + \ifnum\c@pgfplotstable@rowindex=0\relax + \else + % process 'every nth row' styles: + \begingroup + \pgfplots@each@nth@styles + \pgfmath@smuggleone\pgfplotsretval + \endgroup + \ifx\pgfplotsretval\pgfutil@empty + \else + \t@pgfplots@tokb=\expandafter{\pgfplotsretval}% + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% + \fi + \fi + \fi + % misuse as temporary variable: + \c@pgfplotstable@colindex=\c@pgfplotstable@rowindex + \advance\c@pgfplotstable@colindex by1\relax + \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numrows + \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last row}% + \fi + \expandafter\pgfplotstableset\expandafter{\the\t@pgfplots@toka}% + \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}% + \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% + \xdef\pgfplots@glob@TMPc{% + \noexpand\def\noexpand\pgfplotstable@before{\the\t@pgfplots@toka}% + \noexpand\def\noexpand\pgfplotstable@after{\the\t@pgfplots@tokb}% + }% + \endgroup + \pgfplots@glob@TMPc + % insert 'before row' here: + \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}% + \edef\pgfplotstable@curline{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \fi + % + % + \pgfplotslistpopfront\pgfplotstable@col@processed\to\pgfplotstable@entry + \pgfplotsarrayletentry\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array=\pgfplotstable@col@processed + \advance\c@pgfplotstable@colindex by1\relax + % typeset the cell: + \pgfkeysgetvalue{/pgfplots/table/typeset cell/.@cmd}\pgfplots@loc@TMPa + \expandafter\pgfplots@loc@TMPa\pgfplotstable@entry\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + % + % append this cell: + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \t@pgfplots@tokb=\expandafter{\pgfmathresult}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + % + \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax + \c@pgfplotstable@colindex=0\relax + % insert 'after row' here: + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \advance\c@pgfplotstable@rowindex by1\relax + \pgfplotstable@curline@FLUSH + \fi + %\message{I have now \meaning\pgfplotstable@result.}% + \fi + \pgfutil@repeat + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \pgfkeysgetvalue{/pgfplots/table/end table}{\pgfplotstable@entry}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \ifx\pgfplotstable@curline\pgfutil@empty + \else + \pgfplotstable@curline@FLUSH + \fi + % + \ifx\pgfplotstable@font\pgfutil@empty + \else + \edef\pgfplotstable@curline{\noexpand\endgroup}% + \pgfplotstable@curline@FLUSH + \fi + \ifx\pgfplotstable@outfilename\pgfutil@empty + \else + \immediate\closeout\pgfplotstable@outfile + \fi + %\message{I have now \meaning\pgfplotstable@result.}% + \def\pgfplotstablecol{\pgfplotstable@error{Sorry, you can't access the \string\pgfplotstablecol\ in this context. It is ONLY valid during the preparation routines (please check the 'display columns/' style in the manual).}}% + \def\pgfplotstablerow{\pgfplotstable@error{Sorry, you can't access the \string\pgfplotstablerow\ in this context. It is ONLY valid during the preparation routines (please check the 'every row no ' style).}}% + \ifpgfplotstabletypesetresult + \pgfplotstable@result + \fi + \fi + \pgfkeysgetvalue{/pgfplots/table/write to macro}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \global\let\pgfplots@glob@TMPa=\relax + \else + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \xdef\pgfplots@glob@TMPa{\noexpand\def\expandafter\noexpand\pgfplots@loc@TMPa{\the\t@pgfplots@toka}}% + \fi + \endgroup + \pgfplots@glob@TMPa% execute 'write to macro' if set. +}% + +\def\pgfplotstable@disable@column@styles@error#1{% + \pgfplotsthrow{invalid argument}\pgfplots@loc@TMPa{Sorry, the key '#1' has been assigned while processing row options. However, it needs to be invoked while processing column options. If your options depend on specific row indices, consider using \string\pgfplotstablerow\space and \string\pgfplotstablerows}\pgfeov% +}% +\def\pgfplotstable@disable@column@styles@#1{% + \pgfkeysdef{/pgfplots/table/#1/.code}{\pgfplotstable@disable@column@styles@error{#1}}% + \pgfkeysdef{/pgfplots/table/#1/.append code}{\pgfplotstable@disable@column@styles@error{#1}}% + \pgfkeysdefargs{/pgfplots/table/#1/.add code}{##1##2}{\pgfplotstable@disable@column@styles@error{#1}}% + \pgfkeysdef{/pgfplots/table/#1/.append style}{\pgfplotstable@disable@column@styles@error{#1}}% +} +\def\pgfplotstable@disable@column@styles{% + \pgfplotstable@disable@column@styles@{postproc cell content}% + \pgfplotstable@disable@column@styles@{preproc cell content}% + \pgfplotstable@disable@column@styles@{assign cell content}% +}% + +\newif\ifpgfplotstable@isfirstrow +\newif\ifpgfplotstable@islastrow +\newif\ifpgfplotstablecreatecol@isreallynew + +\def\pgfplotstablecreatecol@opt[#1]#2#3{% + \begingroup + \def\pgfplotstablename{#3}% the name of the table struct + \pgfplotstableset{columns=,#1,% + /pgf/fpu/handlers/empty number/.code 2 args={% + \pgfmathfloatcreate{0}{0.0}{0}% + }% + }% + \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% + \ifx\pgfplotstable@colnames\pgfutil@empty + \pgfplotstablegetcolumnlist#3\to\pgfplotstable@colnames + \else + \expandafter\pgfplotslistnew\expandafter\pgfplotstable@colnames\expandafter{\pgfplotstable@colnames}% + \fi + \pgfplotslistnewempty\pgfplotstable@colnames@real + \t@pgfplots@toka=\expandafter{#2}% this should handle macro names in '#2'. + \edef\pgfplotstable@newcolname{\the\t@pgfplots@toka}% + \global\pgfplotstablecreatecol@isreallynewtrue + \c@pgf@countd=0 + \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{% + \pgfplotstable@is@colname\pgfplotstable@colname + \ifpgfplotstableread@foundcolnames + \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@colname}\to\pgfplotstable@colnames@real + \else + \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#2\to\pgfplotstable@colname + \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@colname}\to\pgfplotstable@colnames@real + \fi + \ifx\pgfplotstable@colname\pgfplotstable@newcolname + \global\pgfplotstablecreatecol@isreallynewfalse + \fi + \expandafter\edef\csname pgfplotstablecreate@index@to@name@\the\c@pgf@countd\endcsname{\pgfplotstable@colname}% + \advance\c@pgf@countd by1 + }% + \edef\pgfplotstablecols{\the\c@pgf@countd}% + \pgfplotstable@isfirstrowtrue + \pgfplotstable@islastrowfalse + \pgfplotslistnewempty\pgfplotstable@newcol + % + \let\c@pgfplotstable@numrows=\c@pgf@countd + \let\c@pgfplotstable@rowindex=\c@pgf@countc + \c@pgfplotstable@numrows=-1\relax + \c@pgfplotstable@rowindex=0\relax + \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}% + \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}% + % + \def\prevrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@prev@}{\pgfplotstable@thisrow@impl@}}% + \def\thisrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@cur@}{\pgfplotstable@thisrow@impl@}}% + \def\nextrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@next@}{\pgfplotstable@thisrow@impl@}}% + \def\pgfplotstable@rowno@impl##1##2{% + \pgfutil@ifundefined{pgfplotstablecreate@index@to@name@##1}{% + \csname ##2row\endcsname{colindex##1}% + }{% + \csname ##2row\endcsname{\csname pgfplotstablecreate@index@to@name@##1\endcsname}% + }% + }% + \def\prevrowno##1{\pgfplotstable@rowno@impl{##1}{prev}}% + \def\thisrowno##1{\pgfplotstable@rowno@impl{##1}{this}}% + \def\nextrowno##1{\pgfplotstable@rowno@impl{##1}{next}}% + % + \def\getprevrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@prev@##1\endcsname}% + \def\getthisrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@cur@##1\endcsname}% + \def\getnextrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@next@##1\endcsname}% + % + \pgfplots@loop@CONTINUEtrue + % allow this here to accumulate something. + \pgfutil@ifundefined{pgfmathaccuma}{% + \let\pgfmathaccuma=\pgfutil@empty + }{}% + \pgfutil@ifundefined{pgfmathaccumb}{% + \let\pgfmathaccumb=\pgfutil@empty + }{}% + \pgfutil@loop% loop over each row until there are no more rows. + \ifpgfplots@loop@CONTINUE + \ifnum\c@pgfplotstable@numrows=-1\relax + \pgfplotslistfront\pgfplotstable@colnames\to\pgfplotstable@colname + \expandafter\pgfplotslistsize\csname\string#3@\pgfplotstable@colname\endcsname\to\c@pgfplotstable@numrows + \fi + \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{% + \expandafter\pgfplotstableresolvecolname\expandafter{\pgfplotstable@colname}\of#3\to\pgfplotstable@real@colname + \ifpgfplotstable@isfirstrow + \expandafter\pgfplotslistcheckempty\csname\string#3@\pgfplotstable@real@colname\endcsname + \ifpgfplotslistempty + % the table is completely empty. break. + \pgfplots@loop@CONTINUEfalse + \else + \expandafter\let\csname pgfplotstablecreate@prev@\pgfplotstable@colname\endcsname=\pgfutil@empty + \expandafter\pgfplotslistpopfront\csname\string#3@\pgfplotstable@real@colname\endcsname\to\pgfplotstable@entry + \expandafter\let\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname=\pgfplotstable@entry + \fi + \else + \expandafter\let\expandafter\pgfplotstable@prev\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname + \expandafter\let\csname pgfplotstablecreate@prev@\pgfplotstable@colname\endcsname=\pgfplotstable@prev + % + \expandafter\let\expandafter\pgfplotstable@next\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname + \expandafter\let\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname=\pgfplotstable@next + \fi + \expandafter\pgfplotslistcheckempty\csname\string#3@\pgfplotstable@real@colname\endcsname + \ifpgfplotslistempty + \expandafter\let\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname=\pgfutil@empty + \pgfplotstable@islastrowtrue + \else + \expandafter\pgfplotslistpopfront\csname\string#3@\pgfplotstable@real@colname\endcsname\to\pgfplotstable@entry + \expandafter\let\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname=\pgfplotstable@entry + \fi + }% + \ifpgfplots@loop@CONTINUE + % Compute content: + % + \begingroup + \ifpgfplotstable@isfirstrow + \pgfkeysvalueof{/pgfplots/table/create col/assign first/.@cmd}\pgfeov + \else + \ifpgfplotstable@islastrow + \pgfkeysvalueof{/pgfplots/table/create col/assign last/.@cmd}\pgfeov + \else + \pgfkeysvalueof{/pgfplots/table/create col/assign/.@cmd}\pgfeov + \fi + \fi + \pgfkeysgetvalue{/pgfplots/table/create col/next content}{\pgfplotstable@entry}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}% + \t@pgfplots@tokb=\expandafter{\pgfmathaccuma}% + \xdef\pgfplots@glob@TMPc{% + \noexpand\def\noexpand\pgfplotstable@entry{\the\t@pgfplots@toka}% + \noexpand\def\noexpand\pgfmathaccuma{\the\t@pgfplots@tokb}% + }% + \pgfmath@smuggleone\pgfmathaccumb + \endgroup + \pgfplots@glob@TMPc + \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@entry}\to\pgfplotstable@newcol + % + \ifpgfplotstable@islastrow + \pgfplots@loop@CONTINUEfalse + \fi + \fi + \pgfplotstable@isfirstrowfalse + \advance\c@pgfplotstable@rowindex by1\relax + \pgfutil@repeat + \global\let\pgfplots@glob@TMPc=\pgfplotstable@newcol + \global\let\pgfplots@glob@TMPb=\pgfplotstable@newcolname + \endgroup + \ifpgfplotstablecreatecol@isreallynew + \expandafter\pgfplotslistpushback\expandafter{\pgfplots@glob@TMPb}\to#3% + \fi + \expandafter\let\csname\string#3@\pgfplots@glob@TMPb\endcsname=\pgfplots@glob@TMPc +}% + + +%----------------------------------------------------------- +% +% Implementation of '/pgfplots/table/create col/function graph cut y': +% +%----------------------------------------------------------- + +% create on use/cut/.style={create col/function graph cut y={7e-4}{x=Basis,ymode=log,xmode=log}{{table=regtable,y=special-L2}}}, +% #1 = value of fixed line (I call it epsilon) +% #2 = options +% #3 = specification where to get the y from. It is a comma separated +% list of key-value sets, on set for every y(x) graph which shall be +% used. +% #4 = the direction in which the line does NOT vary (either 'x' or 'y') +% #5 = the direction in which the line DOES vary (either 'x' or 'y') +\def\pgfplotstable@fgc@init#1#2#3#4#5{% + \def\pgfplotstable@fgc@xmode{0}% + \def\pgfplotstable@fgc@ymode{0}% + % + \pgfkeysalso{/pgf/fpu=true}% + % + \pgfqkeys{/pgfplots/table/create col/function graph cut}{#2}% + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/x}\pgfplotstable@fgc@x + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/y}\pgfplotstable@fgc@y + \ifx\pgfplotstable@fgc@table\pgfutil@empty + % no table here, ok. + \else + % ok, we need to query (or load) a table! + \expandafter\pgfplotstable@isloadedtable\expandafter{\pgfplotstable@fgc@table}{% + \expandafter\let\expandafter\pgfplotstable@fgc@table\pgfplotstable@fgc@table + }{% + \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}% + }% + \fi + % + \ifnum\csname pgfplotstable@fgc@#4mode\endcsname=1 + \pgfmathparse{ln(#1)}% + \else + \pgfmathparse{#1}% + \fi + \let\pgfplotstable@fgc@eps=\pgfmathresult + \pgfplots@assign@list\pgfmathaccumb{#3}% + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/foreach}\pgfplotstable@fgc@foreach@ + \ifx\pgfplotstable@fgc@foreach@\pgfutil@empty + \else + \edef\pgfplotstable@fgc@foreach@process@append{x={\pgfplotstable@fgc@x},y={\pgfplotstable@fgc@y}}% + % we have something like + % foreach={\d in {1,2,3,4}}{table\d} + % -> process it! + % This will modify \pgfmathaccumb + \expandafter\pgfplotstable@fgc@foreach@process\pgfplotstable@fgc@foreach@\pgfplots@EOI + \pgfkeyssetvalue{/pgfplots/table/create col/function graph cut/foreach}{}% + \fi + % + \pgfkeysdef{/pgfplots/table/create col/assign}{% +%\message{working on next cell ...}% + \pgfplotslistcheckempty\pgfmathaccumb + \ifpgfplotslistempty + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + \else + \pgfplotslistpopfront\pgfmathaccumb\to\pgfmathresult +%\message{working on next cell: \meaning\pgfmathresult ...}% + \global\let\pgfplotstable@fgc@foreach=\pgfutil@empty + \begingroup + % set local keys: + \def\pgfplots@loc@TMPa{\pgfqkeys{/pgfplots/table/create col/function graph cut}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% + % acquire any sources: + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/x}\pgfplotstable@fgc@x + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/y}\pgfplotstable@fgc@y + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/foreach}\pgfplotstable@fgc@foreach@ + \ifx\pgfplotstable@fgc@foreach@\pgfutil@empty + \ifx\pgfplotstable@fgc@table\pgfutil@empty + \else + % ok, we need to query (or load) a table! + \expandafter\pgfplotstable@isloadedtable\expandafter{\pgfplotstable@fgc@table}{% + \expandafter\let\expandafter\pgfplotstable@fgc@table\pgfplotstable@fgc@table + }{% + \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}% + }% + \fi + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@x}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@x@col + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@y}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@y@col + % + % search for epsilon in the y values: + \expandafter\pgfplotstable@fgc@findintervalwitheps\expandafter{\csname pgfplotstable@fgc@#4@col\endcsname}{\csname pgfplotstable@fgc@#4mode\endcsname}% + \ifx\pgfplotstable@fgc@second\pgfutil@empty + \let\pgfmathresult=\pgfutil@empty + \else + % + % acquire the associated x values: + \expandafter\pgfplotstable@fgc@getassociated\expandafter{\csname pgfplotstable@fgc@#5@col\endcsname}{\csname pgfplotstable@fgc@#5mode\endcsname}% + % + % Interpolate: + \pgfmathparse{ + \pgfplotstable@fgc@abscissafirst + + (\pgfplotstable@fgc@eps - \pgfplotstable@fgc@first) / (\pgfplotstable@fgc@second-\pgfplotstable@fgc@first) + * (\pgfplotstable@fgc@abscissasecond - \pgfplotstable@fgc@abscissafirst) }% + \if\pgfplotstable@fgc@xmode1 + \pgfmathfloatexp@{\pgfmathresult}% + \fi + \pgflibraryfpuifactive{\pgfmathfloattosci{\pgfmathresult}}{}% +%\message{FGC: found \pgfplotstable@fgc@eps\space in no \pgfplotstable@fgc@index; \pgfplotstable@fgc@first:\pgfplotstable@fgc@second; lastwasless=\pgfplotstable@fgc@lastwasless; abscissa interval = \pgfplotstable@fgc@abscissafirst:\pgfplotstable@fgc@abscissasecond; result = \pgfmathresult}% + \fi + \else + \global\let\pgfplotstable@fgc@foreach=\pgfplotstable@fgc@foreach@ + \edef\pgfmathresult{x={\pgfplotstable@fgc@x},y={\pgfplotstable@fgc@y}}% + \fi + % + \pgfmath@smuggleone\pgfmathresult + \endgroup + \ifx\pgfplotstable@fgc@foreach\pgfutil@empty + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \else + % we have something like + % foreach={\d in {1,2,3,4}}{table\d} + % -> process it! + % This will modify \pgfmathaccumb + \let\pgfplotstable@fgc@foreach@process@append=\pgfmathresult + \expandafter\pgfplotstable@fgc@foreach@process\pgfplotstable@fgc@foreach\pgfplots@EOI + \fi + \fi + }% +}% + +\def\pgfplotstable@fgc@foreach@process{% + \pgfutil@ifnextchar\bgroup + {\pgfplotstable@fgc@foreach@process@a}{% + \pgfplotstable@fgc@foreach@process@error}% +}% +\def\pgfplotstable@fgc@foreach@process@a#1{% + \pgfutil@ifnextchar\bgroup + {\pgfplotstable@fgc@foreach@process@b{#1}}{% + \pgfplotstable@fgc@foreach@process@error}% +}% +\def\pgfplotstable@fgc@foreach@process@error#1\pgfplots@EOI{% + \def\pgfplots@loc@TMPa{#1}% + \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, I expected two arguments for /pgfplots/table/create col/function graph cut/foreach, but I found 'foreach=\pgfplots@loc@TMPb'. Perhaps the braces are not as expected?}\pgfeov% +}% +\def\pgfplotstable@fgc@foreach@process@b#1#2#3\pgfplots@EOI{% + \global\pgfplotslistnewempty\pgfplots@glob@TMPa + \begingroup + \foreach #1 {% + \edef\pgfplots@loc@TMPa{#2}% + \expandafter\pgfplotslistpushfrontglobal\pgfplots@loc@TMPa\to\pgfplots@glob@TMPa + }% + \endgroup + \pgfplotslistforeachungrouped\pgfplots@glob@TMPa\as\pgfplots@loc@TMPa{% + \edef\pgfplots@loc@TMPa{table={\pgfplots@loc@TMPa},\pgfplotstable@fgc@foreach@process@append}% + \expandafter\pgfplotslistpushfront\pgfplots@loc@TMPa\to\pgfmathaccumb + }% +}% + +% #1 : the coordinate list to query +% #2 : the mode +% +% POSTCONDITION: +% - \pgfplotstable@fgc@abscissafirst and \pgfplotstable@fgc@abscissasecond +% contain the abscissa values +% +\def\pgfplotstable@fgc@getassociated#1#2{% + \c@pgfplotstable@counta=\pgfplotstable@fgc@index + \pgfplotslistselect\c@pgfplotstable@counta\of#1\to\pgfplotstable@fgc@abscissasecond + \advance\c@pgfplotstable@counta by-1 + \pgfplotslistselect\c@pgfplotstable@counta\of#1\to\pgfplotstable@fgc@abscissafirst + \pgfmathfloatparsenumber{\pgfplotstable@fgc@abscissafirst}% + \let\pgfplotstable@fgc@abscissafirst=\pgfmathresult + \pgfmathfloatparsenumber{\pgfplotstable@fgc@abscissasecond}% + \let\pgfplotstable@fgc@abscissasecond=\pgfmathresult + \if1#2 + \pgfmathln@{\pgfplotstable@fgc@abscissafirst}% + \let\pgfplotstable@fgc@abscissafirst=\pgfmathresult + \pgfmathln@{\pgfplotstable@fgc@abscissasecond}% + \let\pgfplotstable@fgc@abscissasecond=\pgfmathresult + \fi +}% + +% Search for the (first) interval in #1 containing epsilon and return +% \pgfplotstable@fgc@first and \pgfplotstable@fgc@second. +% +% #1 : the list of values. +% #2 : the mode (0 = linear, 1 = log) +% +% PRECONDITION: +% - \pgfplotstable@fgc@eps contains the value to search for +% +% POSTCONDITION +% On success, +% - \pgfplotstable@fgc@first and \pgfplotstable@fgc@second contain the interval. +% - \pgfplotstable@fgc@index contains the index of the @second coordinate. +% - \pgfplotstable@fgc@lastwasless is +% 1 if \pgfplotstable@fgc@second < eps +% 0 if \pgfplotstable@fgc@second >= eps +% If there was no such interval, +% \pgfplotstable@fgc@second will be empty. +\def\pgfplotstable@fgc@findintervalwitheps#1#2{% + \global\let\pgfplotstable@fgc@first=\pgfutil@empty + \global\let\pgfplotstable@fgc@second=\pgfutil@empty + \global\def\pgfplotstable@fgc@lastwasless{2}% + \global\def\pgfplotstable@fgc@break{0}% + \global\def\pgfplotstable@fgc@index{0}% + \pgfplotslistforeach#1\as\pgfplotstable@fgc@val{% + \if\pgfplotstable@fgc@break0 + \pgfmathfloatparsenumber{\pgfplotstable@fgc@val}% + \let\pgfplotstable@fgc@val=\pgfmathresult + \ifnum#2=1 + \pgfmathln@{\pgfplotstable@fgc@val}% + \let\pgfplotstable@fgc@val=\pgfmathresult + \fi + \pgfmathfloatlessthan@{\pgfplotstable@fgc@val}{\pgfplotstable@fgc@eps}% + \ifpgfmathfloatcomparison + \pgfplotstable@fgc@findintervalwitheps@updateresult 01 + \else + \pgfplotstable@fgc@findintervalwitheps@updateresult 10 + \fi + \fi + }% +} + +% #1 : the value of \pgfplotstable@fgc@lastwasless for which the loop +% shall break. +% #2 : the next value for \pgfplotstable@fgc@lastwasless +\def\pgfplotstable@fgc@findintervalwitheps@updateresult#1#2{% + \if\pgfplotstable@fgc@lastwasless#1 + % found it ! + \global\let\pgfplotstable@fgc@second=\pgfplotstable@fgc@val + \global\def\pgfplotstable@fgc@break{1}% + \else + \global\let\pgfplotstable@fgc@first=\pgfplotstable@fgc@val + \c@pgfplotstable@counta=\pgfplotstable@fgc@index + \advance\c@pgfplotstable@counta by1 + \xdef\pgfplotstable@fgc@index{\the\c@pgfplotstable@counta}% + \fi + \global\def\pgfplotstable@fgc@lastwasless{#2}% +}% + + + +\def\pgfplotstabletranspose@[#1]#2#3{% + %\begingroup is already in \pgfplotstabletranspose + \def\pgfplotstable@loc@TMPa{#1}% + \ifx\pgfplotstable@loc@TMPa\pgfutil@empty + \else + \pgfplotstableset{#1}% + \fi + % + \pgfkeysgetvalue{/pgfplots/table/colnames from}\pgfplotstabletranspose@outcolnames + \pgfkeysgetvalue{/pgfplots/table/input colnames to}\pgfplotstabletranspose@incolnames + \pgfkeysgetvalue{/pgfplots/table/columns}\pgfplotstable@colnames + % + \ifx\pgfplotstable@colnames\pgfutil@empty + \pgfplotstableforeachcolumn{#3}\as\pgfplots@colname{% + \t@pgfplots@toka=\expandafter{\pgfplots@colname}% + \ifnum\pgfplotstablecol=0 + \edef\pgfplotstable@colnames{{\the\t@pgfplots@toka}}% + \else + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colnames}% + \edef\pgfplotstable@colnames{\the\t@pgfplots@tokb,{\the\t@pgfplots@toka}}% + \fi + }% + \fi + % + % sanity checking: + \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty + \else + \def\pgfplotstabletranspose@outcolnames@foundit{0}% + \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotstable@colnames}\as\pgfplots@colname{% + \ifx\pgfplots@colname\pgfplotstabletranspose@outcolnames + \def\pgfplotstabletranspose@outcolnames@foundit{1}% + \fi + }% + \if1\pgfplotstabletranspose@outcolnames@foundit + \else + % insert the 'colnames from' column into 'columns': + \pgfplots@warning{table transposition: the 'colnames from=\pgfplotstabletranspose@outcolnames' is not part of 'columns'. Adding it.}% + \t@pgfplots@toka=\expandafter{\pgfplotstabletranspose@outcolnames}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colnames}% + \edef\pgfplotstable@colnames{\the\t@pgfplots@tokb,{\the\t@pgfplots@toka}}% + \fi + \fi + % + % The column NAMES are collected into this list: + \global\pgfplotslistnewempty\pgfplotstable@colnames@glob + % this thing counts output columns: + \let\c@pgfplotstable@numoutcols=\c@pgf@countd + \c@pgfplotstable@numoutcols=0 + \let\c@pgfplotstable@rowindex=\c@pgf@counta + \c@pgfplotstable@rowindex=0 + % + \ifx\pgfplotstabletranspose@incolnames\pgfutil@empty + \else + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstabletranspose@incolnames}\to\pgfplotstable@colnames@glob + \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}% + \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@0\endcsname + \advance\c@pgfplotstable@numoutcols by1 + \fi + \def\pgfplotstable@isfirstcol{1}% + \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotstable@colnames}\as\pgfplots@colname{% + \c@pgfplotstable@rowindex=0 + \ifx\pgfplotstabletranspose@incolnames\pgfutil@empty + \else + \def\pgfplotstabletranspose@useit{1}% + \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty + \else + \ifx\pgfplotstabletranspose@outcolnames\pgfplots@colname + \def\pgfplotstabletranspose@useit{0}% + \fi + \fi + \if1\pgfplotstabletranspose@useit + \expandafter\pgfplotslist@assembleentry\expandafter{\pgfplots@colname}\into\t@pgfplots@tokc + \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}% + \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname + \fi + \advance\c@pgfplotstable@rowindex by1 + \fi + % + \pgfplotstableforeachcolumnelement\pgfplots@colname\of#3\as\pgfplots@cell{% + \if1\pgfplotstable@isfirstcol + % prepare a new column for the output: + \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}% + \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname + % + \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty + \edef\pgfplotstable@loc@TMPa{\pgfplotstablerow}% + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames@glob + \fi + \advance\c@pgfplotstable@numoutcols by1 + \fi + \def\pgfplotstabletranspose@useit{1}% + \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty + \else + \ifx\pgfplotstabletranspose@outcolnames\pgfplots@colname + \pgfutil@ifundefined{pgfplotstabletranspose@@\pgfplots@cell}{% + }{% + \let\pgfplots@loc@TMPa=\pgfplots@cell + \pgfplotsthrow{non unique colname}{\pgfplots@loc@TMPa}{Sorry, 'colnames from=\pgfplotstabletranspose@outcolnames' doesn't yield unique column names (`\pgfplots@cell' comes twice)}\pgfeov% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \edef\pgfplots@cell{row no \pgfplotstablerow}% + \fi + }% + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@cell}\to\pgfplotstable@colnames@glob + \expandafter\def\csname pgfplotstabletranspose@@\pgfplots@cell\endcsname{1}% + \def\pgfplotstabletranspose@useit{0}% + \fi + \fi + \if1\pgfplotstabletranspose@useit + % append everything to the output column with index + % \pgfplotstablerow + \expandafter\pgfplotslist@assembleentry\expandafter{\pgfplots@cell}\into\t@pgfplots@tokc + \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}% + \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname + \fi + \advance\c@pgfplotstable@rowindex by1 + }% + \def\pgfplotstable@isfirstcol{0}% + }% + % + % flush the buffers of the applistX things: + \c@pgfplotstable@rowindex=0 + \pgfutil@loop + \ifnum\c@pgfplotstable@rowindex<\c@pgfplotstable@numoutcols + \expandafter\pgfplotsapplistXflushbuffers\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname + \advance\c@pgfplotstable@rowindex by1 + \pgfutil@repeat + % finalize the global buffers: + \def\pgfplotsscanlinelength{-1}% + \edef\pgfplots@loc@TMPa{\pgfplotstablenameof{#3}_transposed}% + \expandafter\pgfplotstable@copy@to@globalbuffers@simple\expandafter{\pgfplots@loc@TMPa}% + \endgroup + \pgfplotstable@copy@globalbuffers@to{#2}% +}% + +% #1: keys +\def\pgfplotstable@linear@regression#1{% + \begingroup + \pgfqkeys{/pgfplots/table/create col/linear regression}{/pgf/fpu,#1}% + \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/x}{\pgfplotstable@xsrc}% + \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/y}{\pgfplotstable@ysrc}% + \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/table}{\pgfplotstable@table}% + \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/xmode}{\pgfplotstable@xmode}% + \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/ymode}{\pgfplotstable@ymode}% + \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance}{\pgfplotstable@variance@colname}% + \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance list}{\pgfplotstable@variance@list}% + \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance src}{\pgfplotstable@variance@table}% + % + \ifx\pgfplotstable@table\pgfutil@empty + \pgfutil@ifundefined{pgfplotstablename}{}{% query the name of the actual table struct + \let\pgfplotstable@table=\pgfplotstablename + }% + \fi + \ifx\pgfplotstable@table\pgfutil@empty + \pgfplots@error{Sorry, I couldn't determine a value for create col/linear regression/table. Which table should I load?}% + \fi + \ifx\pgfplotstable@xsrc\pgfutil@empty + \pgfplotsifinaddplottablestruct{% + \pgfutil@ifundefined{pgfplots@plot@tbl@x}{}{% + \let\pgfplotstable@xsrc=\pgfplots@plot@tbl@x + \ifx\pgfplotstable@ysrc\pgfutil@empty + \pgfplotstablegetcolsof\pgfplots@table + \ifnum\pgfplotsretval=2 + \else + \pgfplotsthrow{invalid argument}{\pgfplotstable@ysrc}{Sorry, I don't which column should be used as `y' for the linear regression. Please provide 'linear regression={y=}'}\pgfeov% + \fi + \fi + }% + }{}% + \fi + \ifx\pgfplotstable@xsrc\pgfutil@empty + \def\pgfplotstable@xsrc{[index]0}% + \fi + \ifx\pgfplotstable@ysrc\pgfutil@empty + \def\pgfplotstable@ysrc{[index]1}% + \fi + % + \t@pgfplots@toka=\expandafter{\pgfplotstable@table}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@xsrc}% + \t@pgfplots@tokc=\expandafter{\pgfplotstable@ysrc}% + \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}% + \edef\pgfplots@loc@TMPb{{\the\t@pgfplots@tokc}\noexpand\of{\the\t@pgfplots@toka}}% + \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@X + \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPb\to\pgfplotstable@Y + % + \edef\pgfplotstable@xmode{\pgfplotstable@xmode}% + \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@xmode}{x}%% + \edef\pgfplotstable@ymode{\pgfplotstable@ymode}% + \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@ymode}{y}%% + % + \ifx\pgfplotstable@variance@list\pgfutil@empty + % check 'variance' key (loaded from table) + \pgfplotslistnewempty\pgfplotstable@VARIANCE + \ifx\pgfplotstable@variance@colname\pgfutil@empty + \else + \ifx\pgfplotstable@variance@table\pgfutil@empty + \t@pgfplots@toka=\expandafter{\pgfplotstable@table}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@colname}% + \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}% + \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@VARIANCE + \else + \t@pgfplots@toka=\expandafter{\pgfplotstable@variance@colname}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@table}% + \edef\pgfplotstable@loc@TMPa{% + \noexpand\pgfplotstablegetcolumn{\the\t@pgfplots@toka}\noexpand\of{\the\t@pgfplots@tokb}\noexpand\to\noexpand\pgfplotstable@VARIANCE}% + \pgfplotstable@loc@TMPa + \fi + \fi + \else + % load from list: + \expandafter\pgfplotslistnew\expandafter\pgfplotstable@VARIANCE\expandafter{\pgfplotstable@variance@list}% + \fi + % + \pgfplotslistnewempty\pgfplotstable@Xparsed + % + \pgfmathfloatcreate{0}{0.0}{0}% + \let\pgfplotstable@S=\pgfmathresult + \let\pgfplotstable@Sxx=\pgfmathresult + \let\pgfplotstable@Sx=\pgfmathresult + \let\pgfplotstable@Sy=\pgfmathresult + \let\pgfplotstable@Sxy=\pgfmathresult + \pgfutil@loop + \pgfplotslistcheckempty\pgfplotstable@X + \ifpgfplotslistempty + \pgfplots@loop@CONTINUEfalse + \else + \pgfplots@loop@CONTINUEtrue + \fi + \ifpgfplots@loop@CONTINUE + \pgfplotslistpopfront\pgfplotstable@X\to\pgfplotstable@x + \pgfplotslistpopfront\pgfplotstable@Y\to\pgfplotstable@y + % + \pgfplotstableparsex{\pgfplotstable@x}% + \let\pgfplotstable@x=\pgfmathresult + \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@Xparsed + \pgfplotstableparsey{\pgfplotstable@y}% + \let\pgfplotstable@y=\pgfmathresult + % + \pgfplotslistcheckempty\pgfplotstable@VARIANCE + \ifpgfplotslistempty + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfplotstable@invsqr=\pgfmathresult + \else + \pgfplotslistpopfront\pgfplotstable@VARIANCE\to\pgfplotstable@variance + \pgfmathfloatparsenumber{\pgfplotstable@variance}% + \let\pgfplotstable@variance=\pgfmathresult + \pgfmathfloatmultiply@{\pgfplotstable@variance}{\pgfplotstable@variance}% + \let\pgfplotstable@sqr=\pgfmathresult + \pgfmathfloatreciprocal@{\pgfplotstable@sqr}% + \let\pgfplotstable@invsqr=\pgfmathresult + \fi + % + \pgfmathfloatadd@{\pgfplotstable@S}{\pgfplotstable@invsqr}% + \let\pgfplotstable@S=\pgfmathresult + % + \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@invsqr}% + \let\pgfplots@table@accum=\pgfmathresult + \pgfmathfloatadd@{\pgfplotstable@Sx}{\pgfplots@table@accum}% + \let\pgfplotstable@Sx=\pgfmathresult + % + \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}% + \let\pgfplots@table@accum=\pgfmathresult + \pgfmathfloatadd@{\pgfplotstable@Sxx}{\pgfplots@table@accum}% + \let\pgfplotstable@Sxx=\pgfmathresult + % + \pgfmathfloatmultiply@{\pgfplotstable@y}{\pgfplotstable@invsqr}% + \let\pgfplots@table@accum=\pgfmathresult + \pgfmathfloatadd@{\pgfplotstable@Sy}{\pgfplots@table@accum}% + \let\pgfplotstable@Sy=\pgfmathresult + % + \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}% + \let\pgfplots@table@accum=\pgfmathresult + \pgfmathfloatadd@{\pgfplotstable@Sxy}{\pgfplots@table@accum}% + \let\pgfplotstable@Sxy=\pgfmathresult + \pgfutil@repeat + % + \pgfmathparse{\pgfplotstable@S * \pgfplotstable@Sxx - \pgfplotstable@Sx *\pgfplotstable@Sx}% + \let\pgfplotstable@delta=\pgfmathresult + % + \pgfmathparse{(\pgfplotstable@S * \pgfplotstable@Sxy - \pgfplotstable@Sx * \pgfplotstable@Sy) / \pgfplotstable@delta}% + \let\pgfplotstable@a=\pgfmathresult + % + \pgfmathparse{(\pgfplotstable@Sxx * \pgfplotstable@Sy - \pgfplotstable@Sx * \pgfplotstable@Sxy) / \pgfplotstable@delta}% + \let\pgfplotstable@b=\pgfmathresult + % + \pgfplotslistnewempty\pgfplotstable@RESULT + \pgfplotslistforeachungrouped\pgfplotstable@Xparsed\as\pgfplotstable@x{% + \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@a}% + \let\pgfplotstable@tmp=\pgfmathresult + \pgfmathfloatadd@{\pgfplotstable@tmp}{\pgfplotstable@b}% + \ifx\pgfplotstableparseylogbase\pgfutil@empty + \else + \pgfplotstableparseyinv@{\pgfmathresult}% + \fi + \pgfmathfloattosci{\pgfmathresult}% + \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@RESULT + }% + \pgfmathfloattosci\pgfplotstable@a + \let\pgfplotstable@a=\pgfmathresult + % + \pgfmathfloattosci\pgfplotstable@b + \let\pgfplotstable@b=\pgfmathresult + % + \global\let\pgfplotstableregressiona\pgfplotstable@a% + \global\let\pgfplotstableregressionb\pgfplotstable@b% + \let\pgfplotsretval=\pgfplotstable@RESULT + \pgfmath@smuggleone\pgfplotsretval + \endgroup +}% +\def\pgfplotstable@linear@regression@prepare@mode#1#2{% + \expandafter\def\csname pgfplotstableparse#2\endcsname##1{\pgfmathfloatparsenumber{##1}}% + \expandafter\def\csname pgfplotstableparse#2logbase\endcsname{}% + \edef\pgfplots@loc@TMPa{#1}% + \def\pgfplots@loc@TMPb{auto}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \def\pgfplots@loc@TMPa{}% auto == empty string + \fi + % + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % `auto' mode. + \pgfplotsifinaxis{% + \pgfplots@if{pgfplots@#2islinear}{% + \def\pgfplots@loc@TMPa{linear}% + }{% + \def\pgfplots@loc@TMPa{log}% + }% + }{% + \def\pgfplots@loc@TMPa{linear}% + }% + \fi + % + \def\pgfplots@loc@TMPb{linear}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \else + \def\pgfplots@loc@TMPb{log}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \pgfplotsmathdefinemacrolnbase{pgfplotstableparse#2}{\pgfkeysvalueof{/pgfplots/log basis #2}}% + \else + \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, the value '#1' is unexpected for 'linear regression/#2mode'}\pgfeov% + \fi + \fi +}% + + +% Sorts table #3 according to options defined in #1 and writes result +% to #2. +% +% \pgfplotstablesort[sort key=]\result{} +% \pgfplotstablesort[sort key=,sort key source=<\table>]\result{} +\def\pgfplotstablesort{\pgfutil@ifnextchar[{\pgfplotstablesort@opt}{\pgfplotstablesort@opt[]}} +\def\pgfplotstablesort@opt[#1]#2{% + \begingroup + \pgfplotstableset{#1}% + \pgfplotstablecollectoneargwithpreparecatcodes{% + \pgfplotstablesort@{#2}% + }% +} +\def\pgfplotstablesort@#1#2{% + \pgfkeysgetvalue{/pgfplots/table/sort key}\pgfplotstable@sort@key@colname + \pgfkeysgetvalue{/pgfplots/table/sort key from}\pgfplotstable@sort@key@table + \pgfkeysgetvalue{/pgfplots/table/sort cmp}\pgfplotstable@sort@cmp + % + % + \pgfplotstable@isloadedtable{#2}{% + \pgfplotstablegetrowsof{#2}% + \let\pgfplotstable@numrows=\pgfplotsretval + % + \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp{#2}% + \def\pgfplotstable@table{#2}% + \let\pgfplotstable@input@colnames=#2\relax + }{% + \pgfplotstableread{#2}\pgfp@tmp@in + \pgfplotstablegetrowsof\pgfp@tmp@in + \let\pgfplotstable@numrows=\pgfplotsretval + \def\pgfplotstable@table{\pgfp@tmp@in}% + \let\pgfplotstable@input@colnames=\pgfp@tmp@in + % + \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp\pgfp@tmp@in + }% + % + \ifx\pgfplotstable@sort@key@colname\pgfutil@empty + \else + \ifx\pgfplotstable@sort@key@table\pgfutil@empty + \t@pgfplots@toka=\expandafter{\pgfplotstable@table}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@sort@key@colname}% + \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}% + \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@sort@key + \else + \t@pgfplots@toka=\expandafter{\pgfplotstable@sort@key@colname}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@sort@key@table}% + \edef\pgfplotstable@loc@TMPa{% + \noexpand\pgfplotstablegetcolumn{\the\t@pgfplots@toka}\noexpand\of{\the\t@pgfplots@tokb}\noexpand\to\noexpand\pgfplotstable@sort@key}% + \pgfplotstable@loc@TMPa + \fi + \fi + \pgfplotsarraynewempty\pgfplotstable@sort@key@array + \pgfplotslistforeachungrouped{\pgfplotstable@sort@key}\as\pgfplotstable@loc@TMPa{% + \expandafter\pgfplotsarraypushback\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@sort@key@array + }% + % + % + % use a side effect: columns are integers, they are stored as + % '\pgfp@tmp@'. Thus, column names and array indices are + % essentially the same! That simplifies the operation and explains + % why we transposed the table. + % We simply interprete the transposed table as array. We don't + % even need to copy anything. + \pgfplotsarrayresize{\pgfp@tmp}{\pgfplotstable@numrows}% + % Oh, we also need the index to access the sort key. Well, then we + % did not win anything. + \pgfplotsarrayforeachungrouped\pgfp@tmp\as\pgfplotstable@loc@TMPa{% + \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% + \edef\pgfplotstable@loc@TMPa{\pgfplotsarrayforeachindex:{\the\t@pgfplots@toka}}% + \pgfplotsarrayletentry{\pgfplotsarrayforeachindex}\of\pgfp@tmp=\pgfplotstable@loc@TMPa + }% + % extract current row index and row content: + \def\pgfplotstable@sort@extractindex##1:##2{% + \def\pgfmathresult{##1}% + \def\pgfplotstable@row{##2}% + }% + % + \expandafter\pgfplotsset\expandafter{\pgfplotstable@sort@cmp}% + \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotstable@sort@cmp@routine + \def\pgfplotstable@sort@iflt##1##2##3##4{\pgfplotstable@sort@cmp@routine{##1}{##2}{##3}{##4}\pgfeov}% + % + \pgfkeysdefargs{/pgfplots/iflessthan}{##1##2##3##4}{% + \expandafter\pgfplotstable@sort@extractindex##1% + \pgfplotsarrayselect{\pgfmathresult}\of\pgfplotstable@sort@key@array\to\pgfplotstable@arga + \expandafter\pgfplotstable@sort@extractindex##2% + \pgfplotsarrayselect{\pgfmathresult}\of\pgfplotstable@sort@key@array\to\pgfplotstable@argb + \pgfplotstable@sort@iflt{\pgfplotstable@arga}{\pgfplotstable@argb}{##3}{##4}% + }% + \pgfkeysdef{/pgfplots/array/unscope pre}{% + % remove the row index: + \pgfplotsarrayforeachungrouped\pgfp@tmp\as\pgfplotstable@loc@TMPa{% + \expandafter\pgfplotstable@sort@extractindex\pgfplotstable@loc@TMPa% + \pgfplotsarrayletentry{\pgfplotsarrayforeachindex}\of\pgfp@tmp=\pgfplotstable@row + }% + % restore original form: + \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp@result\pgfp@tmp + % technical, transport result out of the current scope ... + \pgfplotstable@copy@to@globalbuffers\pgfp@tmp@result{\pgfplotstablenameof\pgfp@tmp}% + % ... and use this lowlevel thing to transport the original column names. + \global\let\pgfplotstable@colnames@glob=\pgfplotstable@input@colnames + }% + \pgfkeysdef{/pgfplots/array/unscope post}{}% + \pgfplotsarraysort{\pgfp@tmp}% + \endgroup + \pgfplotstable@copy@globalbuffers@to{#1}% +}% + +\pgfutil@IfUndefined{pgfcalendardatetojulian}{% + \def\pgfcalendardatetojulian#1#2{\pgfplots@error{Sorry, you need to use \string\usepackage{pgfcalendar} before using date specific methods}}% +}{}% +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstable.coltype.code.tex b/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstable.coltype.code.tex new file mode 100644 index 0000000..8c0000b --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstable.coltype.code.tex @@ -0,0 +1,93 @@ +%-------------------------------------------- +% +% Package numtable. +% +% This file provides support for column types in LaTeX tabular +% environments, i.e. +% +%\begin{tabular}{>{\pgfplotstablecoltype}c<{\endpgfplotstablecoltype}} +% 1 \\ +% 2 \\ +% 3 \\ +%\end{tabular} +% +% +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + + + +% If I did not get it wrong, the tabular package, initialised with a +% column type like +% >{\pgfplotstablecoltype}c<{\endpgfplotstablecoltype} +% yields +% +% \pgfplotstablecoltype \ignorespaces \unskip \endpgfplotstablecoltype +% OR +% \pgfplotstablecoltype \ignorespaces \\ \endpgfplotstablecoltype +% +% So, I define \pgfplotstablecoltype to skip \ignorespaces and \unskip and simply +% get . +\def\pgfplotstablecoltype{% + \begingroup + \let\pgfplotstablecoltype@content=\empty + \pgfutil@ifnextchar[{% + \pgfplotstablecoltype@ + }{% + \pgfplotstablecoltype@until@end@start + }% +}% +\def\pgfplotstablecoltype@[#1]{% + \pgfqkeys{/pgf/number format}{#1}% + \pgfplotstablecoltype@until@end@start +}% + +\def\pgfplotstablecoltype@until@end@start\ignorespaces{% + \pgfplotstablecoltype@until@end +}% +\def\pgfplotstablecoltype@until@end{% + \pgfutil@ifnextchar\\{% + \pgfplotstablecoltype@finish% + }{% + \pgfutil@ifnextchar{\unskip}{% + \pgfplotstablecoltype@finish% + }{% + \pgfplotstablecoltype@next + }% + }% +} +\def\pgfplotstablecoltype@next#1{% + \expandafter\def\expandafter\pgfplotstablecoltype@content\expandafter{\pgfplotstablecoltype@content#1}% + \pgfplotstablecoltype@until@end +} +\def\pgfplotstablecoltype@finish{% +%\message{COLLECTED \meaning\pgfplotstablecoltype@content}% + \edef\pgfplotstablecoltype@content{\pgfplotstablecoltype@content}% + % + % trim white space: + \expandafter\pgfkeys@spdef\expandafter\pgfplotstablecoltype@content\expandafter{\pgfplotstablecoltype@content}% + % + \ifx\pgfplotstablecoltype@content\pgfutil@empty + \else + \pgfmathprintnumber{\pgfplotstablecoltype@content}% + \fi + \endgroup +}% + +%\def\pgfplotstablecoltype{\message{COLLECT}}% +\def\endpgfplotstablecoltype{}% diff --git a/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex b/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex new file mode 100644 index 0000000..8d470b6 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex @@ -0,0 +1,2003 @@ +%-------------------------------------------- +% +% Package pgfplotstable +% +% Provides support to read and work with abstact numeric tables of the +% form +% +% COLUMN1 COLUMN2 COLUMN3 +% 1 2 3 +% 4 4 552 +% 1e124 0.00001 1.2345e-12 +% ... +% +% Copyright 2007-2010 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +% This file provides a high-level table manipulation and typesetting +% package. +% +% +% --------------------------------------------- +% Implementation notes for programmers: +% --------------------------------------------- +% +% The table data structure consists of +% 1. A name which must be a valid TeX macro like '\table' +% 2. A column list in the \pgfplotslist format. +% In fact, the column list is stored in the table's name: +% \pgfplotslistnewempty\table +% 3. A "file name" stored in +% \csname\string<\namemacro>@@table@name\endcsname +% 4. A "scan line length" number stored in +% \csname\string<\namemacro>@@table@scanline\endcsname +% It contains the value of \pgfplotsscanlinelength which has +% been identified right after \pgfplotstableread. +% 5. foreach column, there is a list of row-values (a row-vector) in +% the \pgfplotslist format named +% \csname\string<\namemacro>@\endcsname +% + +\newif\ifpgfplotstable@search@header +\newif\ifpgfplotstable@firstline@is@header +\newcount\c@pgfplotstable@counta +\newtoks\t@pgfplotstable@a +\newif\ifpgfplots@addplotimpl@readcompletely +% should always be false; use only in grouped internal macros +\newif\ifpgfplots@table@options@areset +\newif\ifpgfplots@tableread@to@listener +\newif\ifpgfplots@tableread@use@begingroup +\newif\ifpgfplotstable@trimcells + +\pgfkeys{% + /pgfplots/table/every table/.style={}, + /pgfplots/table/.unknown/.code={% + \pgfplotstable@error@pkg{Sorry, I do not know the key `\pgfkeyscurrentkeyRAW' and I am going to ignore it. Perhaps you need \string\usepackage{pgfplotstable}? (The table typesetting parts are a separate package)}% + },% + /pgfplots/table/header/.is choice, + /pgfplots/table/header/true/.code={\pgfplotstable@firstline@is@headerfalse\pgfplotstable@search@headertrue}, + /pgfplots/table/header/false/.code={\pgfplotstable@firstline@is@headerfalse\pgfplotstable@search@headerfalse}, + /pgfplots/table/header/has colnames/.code={\pgfplotstable@firstline@is@headertrue\pgfplotstable@search@headerfalse}, + /pgfplots/table/header=true, + /pgfplots/table/x index/.initial=0, + /pgfplots/table/x/.initial=, + /pgfplots/table/x expr/.initial=, + /pgfplots/table/y index/.initial=1, + /pgfplots/table/y/.initial=, + /pgfplots/table/y expr/.initial=, + /pgfplots/table/z index/.initial=2, + /pgfplots/table/z/.initial=, + /pgfplots/table/z expr/.initial=, + /pgfplots/table/meta index/.initial=, + /pgfplots/table/meta/.initial=, + /pgfplots/table/meta expr/.initial=, + /pgfplots/table/x error index/.style={ + x error plus index={#1},% + x error minus index={#1}% + }, + /pgfplots/table/y error index/.style={ + y error plus index={#1},% + y error minus index={#1}% + }, + /pgfplots/table/z error index/.style={ + z error plus index={#1},% + z error minus index={#1}% + }, + /pgfplots/table/x error/.style={ + x error plus={#1},% + x error minus={#1}% + }, + /pgfplots/table/y error/.style={ + y error plus={#1},% + y error minus={#1}% + }, + /pgfplots/table/z error/.style={ + z error plus={#1},% + z error minus={#1}% + }, + /pgfplots/table/x error expr/.style={ + x error plus expr={#1},% + x error minus expr={#1}% + }, + /pgfplots/table/y error expr/.style={ + y error plus expr={#1},% + y error minus expr={#1}% + }, + /pgfplots/table/z error expr/.style={ + z error plus expr={#1},% + z error minus expr={#1}% + }, + /pgfplots/table/x error plus index/.initial=, + /pgfplots/table/y error plus index/.initial=, + /pgfplots/table/z error plus index/.initial=, + /pgfplots/table/x error plus/.initial=, + /pgfplots/table/y error plus/.initial=, + /pgfplots/table/z error plus/.initial=, + /pgfplots/table/x error plus expr/.initial=, + /pgfplots/table/y error plus expr/.initial=, + /pgfplots/table/z error plus expr/.initial=, + /pgfplots/table/x error minus index/.initial=, + /pgfplots/table/y error minus index/.initial=, + /pgfplots/table/z error minus index/.initial=, + /pgfplots/table/x error minus/.initial=, + /pgfplots/table/y error minus/.initial=, + /pgfplots/table/z error minus/.initial=, + /pgfplots/table/x error minus expr/.initial=, + /pgfplots/table/y error minus expr/.initial=, + /pgfplots/table/z error minus expr/.initial=, + /pgfplots/table/ignore chars/.initial=, + /pgfplots/table/white space chars/.initial=, + /pgfplots/table/comment chars/.initial=, + /pgfplots/table/skip first n/.initial=0, + /pgfplots/table/trim cells/.is if=pgfplotstable@trimcells, + /pgfplots/table/trim cells/.default=true, + /pgfplots/table/read completely/.is choice, + /pgfplots/table/read completely/true/.code= \pgfplots@addplotimpl@readcompletelytrue\def\pgfplots@addplotimpl@readcompletely@auto{0}, + /pgfplots/table/read completely/false/.code=\pgfplots@addplotimpl@readcompletelyfalse\def\pgfplots@addplotimpl@readcompletely@auto{0}, + /pgfplots/table/read completely/auto/.code=\pgfplots@addplotimpl@readcompletelyfalse\def\pgfplots@addplotimpl@readcompletely@auto{1}, + /pgfplots/table/read completely/.default=true, + /pgfplots/table/read completely=auto, + /pgfplots/table/col sep/.is choice, + /pgfplots/table/col sep/space/.code = {\def\pgfplotstableread@COLSEP@CASE{0}}, + /pgfplots/table/col sep/comma/.code = {\def\pgfplotstableread@COLSEP@CASE{1}}, + /pgfplots/table/col sep/semicolon/.code = {\def\pgfplotstableread@COLSEP@CASE{2}}, + /pgfplots/table/col sep/colon/.code = {\def\pgfplotstableread@COLSEP@CASE{3}}, + /pgfplots/table/col sep/braces/.code = {\def\pgfplotstableread@COLSEP@CASE{4}}, + /pgfplots/table/col sep/tab/.code = {\def\pgfplotstableread@COLSEP@CASE{5}}, + /pgfplots/table/col sep/&/.code = {\def\pgfplotstableread@COLSEP@CASE{6}\pgfplotstable@trimcellstrue}, + /pgfplots/table/col sep/ampersand/.code = {\def\pgfplotstableread@COLSEP@CASE{6}\pgfplotstable@trimcellstrue}, + /pgfplots/table/col sep=space, + /pgfplots/table/format/.is choice, + /pgfplots/table/format/auto/.code = {\def\pgfplotstableread@FORMAT@CASE{0}}, + /pgfplots/table/format/inline/.code = {\def\pgfplotstableread@FORMAT@CASE{1}}, + /pgfplots/table/format/file/.code = {\def\pgfplotstableread@FORMAT@CASE{2}}, + /pgfplots/table/format=auto, + /pgfplots/table/row sep/.code={% + \pgfplotsutilifstringequal{#1}{\\}{% + \def\pgfplotstableread@ROWSEP@CASE{1}% + }{% + \pgfplotsutilifstringequal{#1}{crcr}{% + \def\pgfplotstableread@ROWSEP@CASE{1}% + }{% + \pgfplotsutilifstringequal{#1}{newline}{% + \def\pgfplotstableread@ROWSEP@CASE{0}% + }{% + {% + \t@pgfplots@tokc={#1}% + \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, the choice `row sep=\the\t@pgfplots@tokc' is not known. Maybe you misspelled it? Try `\string\\' or `newline'.}\pgfeov% + }% + }% + }% + }% + },% + /pgfplots/table/row sep=newline, +} + +\pgfkeys{ + % #1: the argument which should have been assigned. + % #2: an error message. + /pgfplots/exception/non unique colname/.code 2 args={% + \ifx\pgfplotsexceptionmsg\relax + \pgfplots@error{#2}% + \else + \pgfplots@error{\pgfplotsexceptionmsg}% + \fi + \let#1=\pgfutil@empty + },% + /pgfplots/exception/table columns unbalanced/.code={% + \ifx\pgfplotsexceptionmsg\relax + \pgfplots@error{#1}% + \else + \pgfplots@error{\pgfplotsexceptionmsg}% + \fi + }, +} + +% \pgfplotstableread[OPTIONS] {FILE} to \name +% +% This method reads a table from FILE to macro \name. +% +% FILE is something like +% G Basis dof L2 A Lmax cgiter maxlevel eps +% 5 5 5 8.31160034e-02 0.00000000e+00 1.80007647e-01 2 2 -1 +% 17 17 17 2.54685628e-02 0.00000000e+00 3.75580565e-02 5 3 -1 +% ... +% +% A number format line is also understood: +% G Basis dof L2 A Lmax cgiter maxlevel eps +% $flags int int int sci:8 sci:8 sci:8 int int std:8 +% 5 5 5 8.31160034e-02 0.00000000e+00 1.80007647e-01 2 2 -1 +% +% or a three-column-gnuplot file with 2 comment headers like +% #Curve 0, 20 points +% #x y type +% 0.00000 0.00000 i +% 0.52632 0.50235 i +% +% The table data is stored columnwise in lists and can be accessed +% with the other methods of this package. +% +% \pgfplotstableread[]{}{<\macro>} +% \pgfplotstableread[]{} to listener{<\macro>} +% \pgfplotstableread* ... +% +% The '*' does not protect its local variables with TeX groups, +% everything is added to the current scope (useful to the 'to +% listener' thing. +% +% The 'to listener' variant does NOT assemble a table data structure. +% Instead, it processes the input table row-wise and invokes <\macro> +% after each complete row. During the evaluation of <\macro>, the +% following methods can be used to query values: +% \pgfplotstablereadgetcolindex{}{<\macro>} +% \pgfplotstablereadgetcolname{}{<\macro>} +% \pgfplotstablereadvalueofcolname{} +% \pgfplotstablereadvalueofcolindex{} +% \thisrow{} (equivalent to \pgfplotstablereadvalueofcolname) +% \getthisrow{}{<\macro>} (equivalent to \pgfplotstablereadgetcolname) +% \thisrowno{} (equivalent to \pgfplotstablereadvalueofcolindex) +% \getthisrowno{}{<\macro>} +% \pgfplotstableforeachcolumn\as{<\iteratemacro>}{} +% (the '\as' is required directly after +% \pgfplotstableforeachcolumn in this context) +% Attention: 'to listener' is scoped by TeX groups, so any assignments +% need to be done globally (or with aftergroup magic). +% +% More remarks about scoping: +% \pgfplotstableread to listener works as follows: +% \begingroup +% // load table +% while file has more lines: +% load line, read every column; +% invoke listener; +% repeat +% \endgroup +% +% In short: all invocations of listener have the same level of +% scoping: they are inside of one TeX group. But single listener +% invocations as such are not scoped. Make sure you don't +% accidentally overwrite one of the internals in listener. And: make +% sure you don't change temporary registers without scoping them! +% +% Note: this command also updates \pgfplotsscanlinelength. +\def\pgfplotstableread{% + \pgfutil@ifnextchar*{% + \pgfplots@tableread@use@begingroupfalse + \pgfplotstableread@impl@star + }{% + \pgfplots@tableread@use@begingrouptrue + \pgfplotstableread@impl@star*% + }% +}% +\def\pgfplotstableread@impl@star*{% + \pgfutil@ifnextchar[{% + \pgfplotstableread@impl + }{% + \pgfplotstableread@impl[]% + }% +} + +% BACKWARDS COMPATIBILITY +\let\pgfnumtableread=\pgfplotstableread + +% Invokes #2 if '#1' is an already loaded table and #3 if not. +\long\def\pgfplotstable@isloadedtable#1#2#3{% + \ifcase\pgfplotstableread@ROWSEP@CASE\relax + % row sep=newline + \let\pgfplots@loc@TMPa=\pgfplotstableread@NL@other% + \or + % row sep=crcr + \def\pgfplots@loc@TMPa{\\}% + \fi + % + \expandafter\pgfutil@in@\expandafter{\pgfplots@loc@TMPa}{#1}% + \ifpgfutil@in@ + % Hah! it contains the row separator! This is NO macro name! + % -> it is an inline table definition. Don't try to + % assemble a macro name (may run into out-of-memory) + #3\relax% + \else + % ok, the early-out was not met. Make check: + \pgfplotsutil@ifdefinedui@withsuffix{#1}{@@table@name}{#2}{#3}% + \fi +}% + +% If the colum name `#1' is a `create on use' speicifcation, #2 is +% invoked, #3 otherwise. +\long\def\pgfplotstableifiscreateonuse#1#2#3{% + \pgfkeysifdefined{/pgfplots/table/create on use/#1/.@cmd}{#2}{% + \pgfutil@in@{create col/}{#1}% + \ifpgfutil@in@ + #2% + \else + #3% + \fi + }% +}% + +% Defines \pgfplotsretval to be a column name which does not already +% occur in the column names of table #1. +\def\pgfplotstablegenerateuniquecolnamefor#1{% + \begingroup + \c@pgf@countd=0 + \pgfplotstableforeachcolumn{#1}\as\pgfplots@loc@TMPa{% + \def\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + \edef\pgfplots@loc@TMPb{autocol\the\c@pgf@countd}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \advance\c@pgf@countd by1 + \fi + }% + \edef\pgfplotsretval{autocol\the\c@pgf@countd}% + \pgfmath@smuggleone\pgfplotsretval + \endgroup +} + +% Returns a column vector in form of \pgfplotslist +% into #3. +% +% #1: the column name (not a macro) +% #2: the table structure +% #3: the output macro name. +% +% @throw `no such element' on error +\def\pgfplotstablegetcolumnbyname#1\of#2\to#3{% + \let#3=\pgfutil@empty% just for sanity checking. + \pgfplotstable@getcol{#1}\of{#2}\to{#3}\getcolmethod{STD}% +} + +% Declares a new getcolmethod class #1. +% The argument '#1' can then be used as argument for +% \pgfplotstable@getcol...\getcolmethod{#1}. +% +% #2: a set of keys which redefine the behavior. +% See below for available choices. +\def\pgfplotstable@definegetcolmethod#1#2{% + \edef\pgfplotstable@definegetcolmethod@{#1}% + \pgfqkeys{/pgfplots/table/@getcol}{% + % Checks if column '#1' exists in table `#2' and invokes `#3' if that + % is the case and `#4' if not. + % + % Note that the check is only for physically existent colums, no alias + % or create on use is checked here. + % #1: colname + % #2: table struct + % #3: true code + % #4: false code + % FIXME : THIS IS BUGGY: the macro may exist, but is it + % (still) part of the table!? Currently, there is a workaround + % such that \pgfplotstablenew cleans up and avoids that case.. + % and we have no "drop column" currently. + ifexists =\pgfutil@ifundefined{\string##2@##1}{##4}{##3}, + % + % Low level method to return (the actual content) of column #1 of + % table #2 to macro #3. + % #1: colname + % #2: table struct + % #3: result macro + getexisting =\expandafter\let\expandafter##3\csname\string##2@##1\endcsname, + % + % no arguments, the value is a boolean (0 or 1) + createonuse =1, + % + % error handling. + % #1: colname + % #2: table struct + % #3: result macro + lazyforbidden=\pgfplotstablegetcolumnbyname@impl@createonuseforbidden{##1}\of{##2}\to{##3}, + noalias =\pgfplotstablegetcolumnbyname@impl@nosuchalias{##1}\of{##2}\to{##3}, + nocol =\pgfplotstablegetcolumnbyname@impl@nocolumn{##1}\of{##2}\to{##3}, + #2% + }% +}% +\pgfqkeys{/pgfplots/table/@getcol}{% + ifexists/.code ={\expandafter\def\csname pgfplotstable@getcol@ifexists@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2##3##4{#1}},% + getexisting/.code ={\expandafter\def\csname pgfplotstable@getcol@getexisting@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},% + createonuse/.code ={\expandafter\def\csname pgfplotstable@getcol@createonuse@\pgfplotstable@definegetcolmethod@\endcsname{#1}},% + lazyforbidden/.code ={\expandafter\def\csname pgfplotstable@getcol@lazyforbidden@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},% + noalias/.code ={\expandafter\def\csname pgfplotstable@getcol@noalias@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},% + nocol/.code ={\expandafter\def\csname pgfplotstable@getcol@nocol@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},% +}% + +\pgfplotstable@definegetcolmethod{STD}{}% +\pgfplotstable@definegetcolmethod{getptr}{% + ifexists =\pgfutil@ifundefined{pgfplotstblread@colindex@for@name#1}{#4}{#3},% + getexisting =\edef#3{\csname pgfplotstblread@colindex@for@name#1\endcsname},% +} +\pgfplotstable@definegetcolmethod{resolvename}{% + getexisting =\edef#3{#1},% +} + +% The low level implementation of \pgfplotstablegetcolumnbyname. +% +% #4: is a getcolmethod declared with \pgfplotstable@definegetcolmethod +% +% ATTENTION: this macro should be expandable! It is also used inside +% of \thisrow{}. +\def\pgfplotstable@getcol#1\of#2\to#3\getcolmethod#4{% + \csname pgfplotstable@getcol@ifexists@#4\endcsname{#1}\of{#2}{% + \csname pgfplotstable@getcol@getexisting@#4\endcsname{#1}\of{#2}\to#3% + }{% + % Oh, there is no column '#1' in table '#2'! + % + % Ok, then check for special features. + % + % 1. 'create col/...' + % 2. 'create on use' + % 3. 'alias' + % + % WARNING : this code has been REPLICATED in + % *** \pgfplotstablereadvalueofcolname *** + \if1\csname pgfplotstable@getcol@createonuse@#4\endcsname% + \pgfutil@in@{create col/}{#1}% + \ifpgfutil@in@ + \pgfplotstablegenerateuniquecolnamefor{#2}% + \def\pgfplotstable@loc@TMPa##1{% + \pgfkeysdef{/pgfplots/table/create on use/##1}{\pgfkeysalso{#1}}% + \pgfplotstablecreatecol[/pgfplots/table/create on use/##1]{##1}{#2}% + % and return the newly generated col: + \csname pgfplotstable@getcol@getexisting@#4\endcsname{##1}\of{#2}\to#3% + }% + \expandafter\pgfplotstable@loc@TMPa\expandafter{\pgfplotsretval}% + \else + \pgfplotstable@getcol@next{#1}\of{#2}\to{#3}\getcolmethod{#4}% + \fi + \else + \pgfplotstable@getcol@next{#1}\of{#2}\to{#3}\getcolmethod{#4}% + \fi + }% +}% +\def\pgfplotstable@getcol@next#1\of#2\to#3\getcolmethod#4{% + \pgfkeysifdefined{/pgfplots/table/create on use/#1/.@cmd}{% + % aah - a 'create on use' style exists. Apply it! + \if1\csname pgfplotstable@getcol@createonuse@#4\endcsname% + \pgfplotstablecreatecol[/pgfplots/table/create on use/#1]{#1}{#2}% + % and return the newly generated col: + \csname pgfplotstable@getcol@getexisting@#4\endcsname{#1}\of{#2}\to#3% + \else + \csname pgfplotstable@getcol@lazyforbidden@#4\endcsname{#1}\of{#2}\to#3% + \fi + }{% + % ok, then it is either an alias or it simply doesn't exist + \pgfkeysifdefined{/pgfplots/table/alias/#1}{% + \csname pgfplotstable@getcol@ifexists@#4\endcsname{\pgfkeysvalueof{/pgfplots/table/alias/#1}}\of{#2}{% + \csname pgfplotstable@getcol@getexisting@#4\endcsname{\pgfkeysvalueof{/pgfplots/table/alias/#1}}\of{#2}\to#3% + }{% + \csname pgfplotstable@getcol@noalias@#4\endcsname{#1}\of{#2}\to{#3}% + }% + }{% + \csname pgfplotstable@getcol@nocol@#4\endcsname{#1}\of{#2}\to{#3}% + }% + }% +} +\def\pgfplotstablegetcolumnbyname@impl@createonuseforbidden#1\of#2\to#3{% + \pgfplotstablegetcolumnbyname@impl@nocolumn@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@ +} + +\def\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@#1{% + \space Note that I found a 'create on use/#1' style, but unfortunately, I can't evaluate it in this context. Please use the 'read completely' key such that it is processed earlier (see the manual for details)% +}% +\def\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable#1{}% + +\def\pgfplotstablegetcolumnbyname@impl@nosuchalias#1\of#2\to#3{ + \pgfplotstablegetcolumnbyname@impl@nosuchalias@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable +}% + +\def\pgfplotstablegetcolumnbyname@impl@nosuchalias@#1\of#2\to#3#4{% + \pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve aliased column '\pgfkeysvalueof{/pgfplots/table/alias/#1}' from table '\pgfplotstablenameof{#2}'. The original request was for '#1', which does not exist either.#4{#1}}\pgfeov% +}% + +\def\pgfplotstablegetcolumnbyname@impl@nocolumn#1\of#2\to#3{% + \pgfplotstablegetcolumnbyname@impl@nocolumn@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable +}% +\def\pgfplotstablegetcolumnbyname@impl@nocolumn@#1\of#2\to#3#4{% + \pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve column '#1' from table '\pgfplotstablenameof{#2}'. Please check spelling (or introduce name aliases).#4{#1}}\pgfeov% +}% + + +% Retrieves the column *NAME* '#1' of table #2 and writes it into +% '#3'. +% +% If there is no such column, column aliases will be checked. Finally +% if there are no aliases, the command fails with an error. +% +% The 'create on use' statements can't be used in this context. +% @see \pgfplotstablegetcolumnbyname +% +% #1: a column name (not a macro) +% #2: the table structure +% #3: a macro name which will be filled with the (probably modified) +% column name into #2. +\def\pgfplotstableresolvecolname#1\of#2\to#3{% + \let#3=\pgfutil@empty% just for sanity checking. + \pgfplotstable@getcol{#1}\of{#2}\to{#3}\getcolmethod{resolvename}% +} + +% Invokes either \pgfplotstablegetcolumnbyindex or +% \pgfplotstablegetcolumnbyname. +% +% #1: either a column name, alias or create on use specification, or +% [index] denoting a column index. +% #2: either a loaded table or a table macro. +% #3: a macro name which will be filled with the column, in the format +% accepted of \pgfplotslist... +\long\def\pgfplotstablegetcolumn#1\of#2\to#3{% + \begingroup + \pgfplotstable@isloadedtable{#2}{% + \pgfplotstablegetcolumnfromstruct{#1}\of{#2}\to{#3}% + }{% + \pgfplotstableread{#2}\pgfplotstable@tmptbl + \pgfplotstablegetcolumnfromstruct{#1}\of\pgfplotstable@tmptbl\to{#3}% + }% + \pgfmath@smuggleone#3% + \endgroup +}% +\def\pgfplotstablegetcolumnfromstruct#1\of#2\to#3{% + \def\pgfplotstable@loc@TMPc{#1}% + \pgfplotstable@is@colname{\pgfplotstable@loc@TMPc}%% + \ifpgfplotstableread@foundcolnames + \else + \expandafter\pgfplotstablegetcolumnnamebyindex\pgfplotstable@loc@TMPc\of{#2}\to\pgfplotstable@loc@TMPc + \fi + \expandafter\pgfplotstablegetcolumnbyname\pgfplotstable@loc@TMPc\of#2\to{#3}% +}% + +% Defines #3 to be the column name of the column with index '#1'. +% +% #1: a column index (starting with 0) +% #2: a loaded table structure +% #3: an output macro name. +\def\pgfplotstablegetcolumnnamebyindex#1\of#2\to#3{% + \pgfplotslistselect#1\of#2\to#3\relax +}% + +% Defines #3 to be the column index of the column with name '#1'. +% +% #1: a column name +% #2: a loaded table structure +% #3: an output macro name which will be filled with the index (or -1 +% if there is no such index) +\def\pgfplotstablegetcolumnindexforname#1\of#2\to#3{% + \def#3{-1}% + \edef\pgfplotstablegetcolumnindexforname@@{#1}% + \pgfplotstableforeachcolumn{#2}\as\pgfplotstablegetcolumnindexforname@{% + \relax + \ifx\pgfplotstablegetcolumnindexforname@\pgfplotstablegetcolumnindexforname@@ + \edef#3{\pgfplotstablecol}% + \fi + }% +}% +\def\pgfplotstablegetcolumnbyindex#1\of#2\to#3{% + \pgfplotslistselect#1\of#2\to#3\relax + \expandafter\pgfplotstablegetcolumnbyname#3\of#2\to{#3}% +} + +\def\pgfplotstablecopy#1\to#2{% + \let#2=#1% + \pgfplotstablegetname#1\pgfplotstable@loc@TMPa + \expandafter\let\csname\string#2@@table@name\endcsname=\pgfplotstable@loc@TMPa + \expandafter\edef\csname\string#2@@table@scanline\endcsname{\pgfplotstablescanlinelengthof{#1}}% + \pgfplotslistforeachungrouped#1\as\pgfplotstable@loc@TMPa{% + \def\pgfplotstable@loc@TMPb{% + \expandafter\let\csname\string#2@\pgfplotstable@loc@TMPa\endcsname}% + \expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname + }% +} + +% Returns the file name of table '#1' into macro #2. +\def\pgfplotstablegetname#1#2{% + \expandafter\let\expandafter#2\csname\string#1@@table@name\endcsname +} + +% expands to the table file name of table '#1' +\def\pgfplotstablenameof#1{% + \csname\string#1@@table@name\endcsname +} + +% Returns the value of \pgfplotsscanlinelength for table '#1' into +% macro #2. +\def\pgfplotstablegetscanlinelength#1#2{% + \expandafter\let\expandafter#2\csname\string#1@@table@scanline\endcsname +}% + +% Expands to the scan line length of table '#1'. +\def\pgfplotstablescanlinelengthof#1{\csname\string#1@@table@scanline\endcsname}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% IMPLEMENTATION +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newif\ifpgfplotstableread@curline@contains@colnames +\newif\ifpgfplotstableread@foundcolnames +\newif\ifpgfplotstableread@skipline + +% A method which is necessary to work with inline table data. +% +% It does nothing if format=file. +% +% It needs to be invoked BEFORE the inline table data has been +% seen the first time. "Seen" means collected as argument! +% +% The macro changes \catcodes in order to implement the 'row sep=newline', +% some special 'col sep' choices and the 'ignore chars' features. +% +% ATTENTION: this changes the processing of ALL following newline +% characters. +% @see \pgfplotstablecollectoneargwithpreparecatcodes +\def\pgfplotstablereadpreparecatcodes{% + \ifx\pgfplotstablereadrestorecatcodes\relax + \edef\pgfplotstablereadrestorecatcodes{% + \noexpand\pgfplotstableuninstallignorechars + \noexpand\catcode`\noexpand\^^M=\the\catcode`\^^M\noexpand\space + \noexpand\catcode`\noexpand\ =\the\catcode`\ \noexpand\space + \noexpand\catcode`\noexpand\;=\the\catcode`\;\noexpand\space + \noexpand\catcode`\noexpand\:=\the\catcode`\:\noexpand\space + \noexpand\catcode`\noexpand\^^I=\the\catcode`\^^I\noexpand\space + \noexpand\let\noexpand\pgfplotstablereadrestorecatcodes=\noexpand\relax + }% + \ifcase\pgfplotstableread@FORMAT@CASE\relax + % format=auto + \pgfplotstablereadpreparecatcodes@ + \or + % format=inline + \pgfplotstablereadpreparecatcodes@ + \fi + \fi +} +\let\pgfplotstablereadrestorecatcodes=\relax +\def\pgfplotstablereadpreparecatcodes@{% + \if0\pgfplotstableread@ROWSEP@CASE\relax + % row sep = newline + \catcode`\^^M=12 + \fi + \ifcase\pgfplotstableread@COLSEP@CASE\relax + % col sep=space: + \catcode`\ =10 + \or + % col sep=comma: + \or + % col sep=semicolon: + \catcode`\;=12 + \or + % col sep=colon: + \catcode`\:=12 + \or + % col sep=brace: + \or + % col sep=tab: + \catcode`\^^I=12 + \fi + \pgfplotstableinstallignorechars +}% + +% Logically, this routine does +% \pgfplotstablereadpreparecatcodes +% #1 +% and that's all. However, It makes sure that any white space +% characters (especially newlines) between '#1' and the following +% argument are gobbled! +% +% To show the problem, consider +% \pgfplotstabletypeset[] +% \loadedtable +% +% and we want to set the catcodes *before* \loadedtable is seen. +% Well, there is a newline character after ']'! If we change the +% catcodes, this newline will be considered as character and will make +% up the first argument, the \loadedtable will be ignored. +% +% \pgfplotstablecollectoneargwithpreparecatcodes avoids this problem +% by gobbling all space (newline) characters *before* collecting the +% directly following argument token. Furthermore, it restores the +% catcodes directly after the argument has been collected. +% +% @see \pgfplotstablecollectoneargwithpreparecatcodesnorestore +\long\def\pgfplotstablecollectoneargwithpreparecatcodes#1{% + \begingroup + \t@pgfplotstable@a{{#1}}% this allows '#' characters in '#1' + \def\pgfplotstablecollectoneargwithpreparecatcodes@@{% + \pgfplotstablereadpreparecatcodes + \expandafter\pgfplotstablecollectoneargwithpreparecatcodes@end\the\t@pgfplotstable@a% + }% + % equivalent to + %\let\pgfplotstable@loc@TMPa=\pgfplotstablecollectoneargwithpreparecatcodes@@ + \futurelet\pgfplotstable@loc@TMPa\pgfplotstablecollectoneargwithpreparecatcodes@@ + % this employs a side effect: \futurelet gobbles any spaces + % (including newlines). +}% +\long\def\pgfplotstablecollectoneargwithpreparecatcodes@end#1#2{% + \endgroup + #1{#2}% +}% + +% An overloaded method of +% \pgfplotstablecollectoneargwithpreparecatcodes which does not +% restore the catcodes after collecting one arg. +\long\def\pgfplotstablecollectoneargwithpreparecatcodesnorestore#1{% + \t@pgfplotstable@a{{#1}}% + \def\pgfplotstablecollectoneargwithpreparecatcodes@@{% + \expandafter\pgfplotstablereadpreparecatcodes\t@pgfplotstable@a + }% + % equivalent to + %\let\pgfplotstable@loc@TMPa=\pgfplotstablecollectoneargwithpreparecatcodes@@ + \futurelet\pgfplotstable@loc@TMPa\pgfplotstablecollectoneargwithpreparecatcodes@@ +}% + +% Accept one of +% \pgfplotstableread[#1]{}{<\macro>} +% \pgfplotstableread[#1]{} to listener{<\macro>} +% or +% \pgfplotstableread[#1]{} to {<\macro>} (DEPRECATED) +\long\def\pgfplotstableread@impl[#1]{% + \ifpgfplots@tableread@use@begingroup + \begingroup + \def\endgroup@@pgfplotstableread{\endgroup}% + \else + \let\endgroup@@pgfplotstableread=\relax% + \fi + % set options here, although we can't evaluate 'every table' yet + % (the file name is not yet known). + % But #1 may contain input format specifiers which are important + % for \catcodes, BEFORE we have read the second argument: + \pgfplotstableset{#1}% + % + \pgfplotstablecollectoneargwithpreparecatcodes{% + \pgfplotstableread@impl@collectfirstarg{#1}% + }% +}% +\long\def\pgfplotstableread@impl@collectfirstarg#1#2{% + \pgfplotsutil@ifnextchar t{% + \pgfplotstableread@impl@@{#1}{#2}% + }{% + \pgfplotstableread@impl@{#1}{#2}% + }% +}% + + +% I don't know why; but I started with +% >> \pgfplotstableread[]{file} to \macro +% That ' to ' is really ugly. This here is for backwards +% compatibility: +\long\def\pgfplotstableread@impl@@#1#2to {% + \pgfutil@ifnextchar l{% + \pgfplotstableread@impl@@listener{#1}{#2}% + }{% + \pgfplotstableread@impl@{#1}{#2}% + }% +}% +\long\def\pgfplotstableread@impl@@listener#1#2listener#3{% + \pgfplots@tableread@to@listenertrue + \pgfplotstableread@impl@{#1}{#2}{#3}% + \pgfplots@tableread@to@listenerfalse +}% + +\newif\ifpgfplotstableread@inline +\long\def\pgfplotstableread@checkinlineformat@CRCR#1\\#2\pgfplotstable@EOI{% + \def\pgfplotstable@loc@TMPa{#2}% + \ifx\pgfplotstable@loc@TMPa\pgfutil@empty + \pgfplotstableread@inlinefalse + \else + \pgfplotstableread@inlinetrue + \let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@CRCR + \fi +}% +\long\def\pgfplotstableread@loop@next@CRCR#1\\{% + \long\def\pgfplotstable@LINE{#1}% + \pgfplotstableread@loop@processnextline + \pgfplotstableread@loop@over@lines +}% +\begingroup +\catcode`\^^M=12\relax% +\gdef\pgfplotstableread@NL@other{^^M}% +\long\gdef\pgfplotstableread@checkinlineformat@NL@#1^^M#2\pgfplotstable@EOI{% + \def\pgfplotstable@loc@TMPa{#2}% + \ifx\pgfplotstable@loc@TMPa\pgfutil@empty% + \pgfplotstableread@inlinefalse% + \else% + \pgfplotstableread@inlinetrue% + \let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@NL% + \fi% +}% +\long\gdef\pgfplotstableread@checkinlineformat@NL#1{% + \pgfplotstableread@checkinlineformat@NL@ #1^^M\pgfplotstable@EOI% +}% +\long\gdef\pgfplotstableread@loop@next@NL#1^^M{% + \long\def\pgfplotstable@LINE{#1}% + \pgfplotstableread@loop@processnextline% + \pgfplotstableread@loop@over@lines% +}% +\endgroup + +% #1: options. +% #2: the table content (file name or inline data) +% #3: the result macro. +\long\def\pgfplotstableread@impl@#1#2#3{% + \ifcase\pgfplotstableread@FORMAT@CASE\relax + % format=auto + \ifcase\pgfplotstableread@ROWSEP@CASE\relax + % row sep=newline + \pgfplotstableread@checkinlineformat@NL{#2}% + \or + % row sep=crcr + \pgfplotstableread@checkinlineformat@CRCR #2\\\pgfplotstable@EOI + \fi + \or + % format=inline + \pgfplotstableread@inlinetrue + \ifcase\pgfplotstableread@ROWSEP@CASE\relax + % row sep=newline + \let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@NL + \or + % row sep=crcr + \let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@CRCR + \fi + \or + \pgfplotstableread@inlinefalse + \fi + % + \ifpgfplotstableread@inline + \else + \if1\pgfplotstableread@ROWSEP@CASE + % row sep=crcr + \pgfplotsthrow{unsupported operation}{Sorry, the choice 'row sep=crcr' is currently only available for inline tables, not for external files}\pgfeov + \fi + \fi + % + % optimizations: + \pgfkeysgetvalue{/pgfplots/table/comment chars}\pgfplots@loc@TMPd + \ifx\pgfplots@loc@TMPd\pgfutil@empty + \let\pgfplotstableread@checkspecial@line@default=\relax + \fi + \pgfkeysgetvalue{/pgfplots/table/skip first n}\pgfplots@loc@TMPd + \ifx\pgfplots@loc@TMPd\pgfutil@empty \let\pgfplotstableread@check@skipfirstn=\relax \fi + \ifnum\pgfplots@loc@TMPd=0 \let\pgfplotstableread@check@skipfirstn=\relax \fi + % + \ifpgfplotstableread@inline + \def\pgfplotstableread@impl@fCLOSE{}% + \let\pgfplotstableread@loop@over@lines=\pgfplotstableread@loop@over@lines@frominline% + \long\def\pgfplotstableread@start@loop{% + \pgfplotstableread@loop@over@lines #2\pgfplotstable@EOI + }% + \def\pgfplotstableread@ready{1}% + \def\pgfplotstableread@filename{}% + \else + \def\pgfplotstableread@ready{1}% + \def\pgfplotstableread@filename{#2}% + \pgfplotstableread@openfile + \def\pgfplotstableread@impl@fCLOSE{% + \closein\r@pgfplots@reada + }% + \let\pgfplotstableread@loop@over@lines=\pgfplotstableread@loop@over@lines@fromfile% + \def\pgfplotstableread@start@loop{\pgfplotstableread@loop@over@lines}% + \pgfplotstableinstallignorechars + \fi + \edef\pgfplotstableread@oldendlinechar{\the\endlinechar}% + \endlinechar=-1 % do not append a white space after each line for file input +%\pgfplots@message{ATTEMPTING TO READ \pgfplotstableread@filename}% + % + \def\pgfplots@loc@TMPa{\pgfplotstableread@impl@prepare{#1}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotstableread@filename}{#3}% + % + \if1\pgfplotstableread@ready + \pgfplotstableread@start@loop + % + \pgfplotstableread@impl@fCLOSE% + % + \pgfplotstableread@finish + % + \fi + \endlinechar=\pgfplotstableread@oldendlinechar + \pgfplotsscanlinelengthcleanup + \expandafter\pgfplotstable@copy@to@globalbuffers@simple\expandafter{\pgfplotstableread@filename}% + \endgroup@@pgfplotstableread + \ifpgfplots@tableread@to@listener + % there are no data structures in this case. + \let\pgfplotsscanlinelength=\pgfplotstable@glob@buf@scanline + \else + % Now, we can access the global variables! + % copy them to #3. + \pgfplotstable@copy@globalbuffers@to#3% + \fi +} + +{\catcode`\"=12 \gdef\pgfplots@dquote{"}} + +% Opens \pgfplotstableread@filename. +\def\pgfplotstableread@openfile{% + \def\pgfplotstable@loc@TMPa{\pgfutil@in@{ }}% + \expandafter\pgfplotstable@loc@TMPa\expandafter{\pgfplotstableread@filename}% + \ifpgfutil@in@ + \t@pgfplots@toka=\expandafter{\pgfplotstableread@filename}% + \edef\pgfplotstableread@filename{\pgfplots@dquote\the\t@pgfplots@toka\pgfplots@dquote}% + \fi + \let\pgfplotstableread@old@crcr=\\% + \def\\{\string\\}% just to make sure we don't try to open inline table data... + \openin\r@pgfplots@reada=\pgfplotstableread@filename.tex + \ifeof\r@pgfplots@reada + \openin\r@pgfplots@reada=\pgfplotstableread@filename\relax + \else + \pgfplots@warning{% + You requested to open table '\pgfplotstableread@filename', but there is also a '\pgfplotstableread@filename.tex'. + TeX will automatically append the suffix '.tex', so I will now open '\pgfplotstableread@filename.tex'. + Please make sure you don't accidentally load TeX files - this may produce unrecoverable errors.}% + \closein\r@pgfplots@reada + \openin\r@pgfplots@reada=\pgfplotstableread@filename\relax + \fi + % + \ifeof\r@pgfplots@reada + \pgfplotsthrow{no such table file}{\pgfplots@loc@TMPa}{\pgfplotstableread@filename}{Could not read table file '\pgfplotstableread@filename'. In case you intended to provide inline data: maybe TeX screwed up your end-of-lines? Try `row sep=crcr' and terminate your lines with `\string\\' (refer to the pgfplotstable manual for details)}\pgfeov% + \global\let\pgfplotstable@colnames@glob=\pgfplots@loc@TMPa + \def\pgfplotstableread@ready{0}% + \fi + \pgfplots@logfileopen{\pgfplotstableread@filename}% + \let\\=\pgfplotstableread@old@crcr +} + +\def\pgfplotstableinstallignorechars{% + \ifx\pgfplotstableuninstallignorechars\pgfutil@empty + \pgfkeysgetvalue{/pgfplots/table/ignore chars}\pgfplotstable@loc@TMPa + \ifx\pgfplotstable@loc@TMPa\pgfutil@empty + \else + \pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{9}% + \fi + \pgfkeysgetvalue{/pgfplots/table/white space chars}\pgfplotstable@loc@TMPa + \ifx\pgfplotstable@loc@TMPa\pgfutil@empty + \else + \pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{10}% + \fi + \ifx\pgfplotstableuninstallignorechars\pgfutil@empty + \else + \expandafter\def\expandafter\pgfplotstableuninstallignorechars\expandafter{% + \pgfplotstableuninstallignorechars + \let\pgfplotstableuninstallignorechars=\pgfutil@empty + }% + \fi + \fi +}% +\let\pgfplotstableuninstallignorechars\pgfutil@empty% +% #1 macro containing the characters as comma-separated list +% #2 the catcode to assign +\def\pgfplotstableinstallignorechars@#1#2{% + \expandafter\pgfplotsutilforeachcommasep\expandafter{#1}\as\pgfplotstable@loc@TMPa{% + \t@pgfplots@toka=\expandafter{\pgfplotstableuninstallignorechars}% + \edef\pgfplotstableuninstallignorechars{% + \the\t@pgfplots@toka + \noexpand\catcode`\expandafter\noexpand\pgfplotstable@loc@TMPa=\expandafter\the\expandafter\catcode\expandafter`\pgfplotstable@loc@TMPa\noexpand\space + }% + \expandafter\catcode\expandafter`\pgfplotstable@loc@TMPa=#2\relax + }% +}% + +% #1: any options to set (respect \ifpgfplots@table@options@areset ) +% #2: the file name (if any) +% #3: the output macro (or listener) +\def\pgfplotstableread@impl@prepare#1#2#3{% + \ifpgfplots@table@options@areset + \else + \pgfplotstableset@every@table{#2}{#1}% + \fi + % + \def\pgfplotstablename{\pgfplotstable@colnames@glob}% provide the name of the actual table struct (during \pgfplotstableread, only partial functionality is available!) + % + % local counter definitions: + \ifpgfplots@tableread@use@begingroup + \let\pgfplotstableread@lineno=\c@pgf@counta + \let\pgfplotstableread@numcols=\c@pgf@countb + \let\pgfplotstableread@curcol=\c@pgf@countc + \let\pgfplotstableread@usablelineno=\c@pgf@countd + \def\thepgfplotstableread@lineno{\the\pgfplotstableread@lineno}% + \def\thepgfplotstableread@usablelineno{\the\pgfplotstableread@usablelineno}% + \def\thepgfplotstableread@curcol{\the\pgfplotstableread@curcol}% + \def\thepgfplotstableread@numcols{\the\pgfplotstableread@numcols}% + \def\pgfplotstableread@countreset##1{##1=0 }% + \def\pgfplotstableread@countset##1##2{##1=##2\relax}% + \def\pgfplotstableread@countadvance##1{\advance##1 by1 }% + \else + % don't re-use integers! We have no protecting scopes! + \def\thepgfplotstableread@lineno{\pgfplotstableread@lineno}% + \def\thepgfplotstableread@usablelineno{\pgfplotstableread@usablelineno}% + \def\thepgfplotstableread@curcol{\pgfplotstableread@curcol}% + \def\thepgfplotstableread@numcols{\pgfplotstableread@numcols}% + \def\pgfplotstableread@countreset##1{\def##1{0}}% + \def\pgfplotstableread@countset##1##2{\def##1{##2}}% + \def\pgfplotstableread@countadvance##1{\pgfplotsutil@advancestringcounter{##1}}% + \fi + \pgfplotstableread@countreset\pgfplotstableread@lineno + \pgfplotstableread@countreset\pgfplotstableread@usablelineno + \pgfplotstableread@countreset\pgfplotstableread@numcols + \pgfplotstableread@countreset\pgfplotstableread@curcol + % + \pgfplotstableread@impl@prepare@DO + \def\pgfplotstableread@isgnuplotformat{0}% + \global\pgfplotslistnewempty\pgfplotstable@colnames@glob + \pgfplotsscanlinelengthinitzero + \ifpgfplots@tableread@to@listener + \def\pgfplotstablerow{\thepgfplotstableread@usablelineno}% + \def\pgfplotstablelineno{\thepgfplotstableread@lineno}% + \let\pgfplotstable@listener=#3% + \let\pgfplotstableread@impl@nextrow@NEXT=\pgfplotstableread@impl@nextrow@NEXT@listener + \let\pgfplotstablereadgetcolindex=\pgfplotstablereadgetcolindex@ + \let\pgfplotstablereadgetcolname=\pgfplotstablereadgetcolname@ + \let\pgfplotstablereadgetptrtocolname=\pgfplotstablereadgetptrtocolname@ + \let\pgfplotstablereadgetptrtocolindex=\pgfplotstablereadgetptrtocolindex@ + \let\pgfplotstablereadevalptr=\pgfplotstablereadevalptr@ + \let\pgfplotstablereadvalueofptr=\pgfplotstablereadvalueofptr@ + \let\pgfplotstableforeachcolumn=\pgfplotstableforeachcolumn@listener + \let\pgfplotstablereadvalueofcolname=\pgfplotstablereadvalueofcolname@ + \let\pgfplotstablereadvalueofcolindex=\pgfplotstablereadvalueofcolindex@ + \let\getthisrow=\pgfplotstablereadgetcolname + \let\thisrow=\pgfplotstablereadvalueofcolname + \let\thisrowno=\pgfplotstablereadvalueofcolindex + \let\getthisrowno=\pgfplotstablereadgetcolindex + \fi +}% + +% Copies the table column list and the column vectors of #1 to global buffers. +% @see \pgfplotstable@copy@globalbuffers@to +% +% Use these two methods to avoid scoping problems. +% +% #1: the <\macro> name of the table which is to be copied to global buffers. +% #2: the table file name. +\def\pgfplotstable@copy@to@globalbuffers#1#2{% + \global\let\pgfplotstable@colnames@glob=#1\relax + \c@pgfplotstable@counta=0\relax% + \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{% + \def\pgfplotstable@loc@TMPb{% + \expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname% + }% + \expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname + \advance\c@pgfplotstable@counta by1\relax + }% + \pgfplotstable@copy@to@globalbuffers@simple{#2}% +}% +% A variant of \pgfplotstable@copy@to@globalbuffers which copies only +% the member variables of a loaded table (the name and scanline length) to +% global buffers. +% +% #1: the table's file name. +% +% @PRECONDITION: any other variables and cell data of the table are already stored +% in global buffers. +\def\pgfplotstable@copy@to@globalbuffers@simple#1{% + \gdef\pgfplotstable@glob@buf@name{#1}% + \global\let\pgfplotstable@glob@buf@scanline=\pgfplotsscanlinelength +}% + +% copies the global column list and the global column vectors to #1 +% (NOT the table file name). +% @see \pgfplotstable@copy@to@globalbuffers +% +% @PRECONDITION the global buffers contain all members of a table. +% +% @POSTCONDITION The table '#1' is be initialised to these members. +% Furthermore, \pgfplotsscanlinelength is set. +\def\pgfplotstable@copy@globalbuffers@to#1{% + \let#1=\pgfplotstable@colnames@glob + \c@pgfplotstable@counta=0\relax% + \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{% + \def\pgfplotstable@loc@TMPb{% + \expandafter\let\csname\string#1@\pgfplotstable@loc@TMPa\endcsname}% + \expandafter\pgfplotstable@loc@TMPb\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname +%\message{Column '\pgfplotstable@loc@TMPa' has entries: \expandafter\meaning\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname}% + \expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname=\pgfutil@empty + \advance\c@pgfplotstable@counta by1\relax + }% + \global\let\pgfplotstable@colnames@glob=\pgfutil@empty + \expandafter\let\csname\string#1@@table@scanline\endcsname=\pgfplotstable@glob@buf@scanline + \expandafter\let\csname\string#1@@table@name\endcsname=\pgfplotstable@glob@buf@name + \let\pgfplotsscanlinelength=\pgfplotstable@glob@buf@scanline +}% + +\def\pgfplotstableread@finish{% + \pgfplotsscanlinecomplete + \ifpgfplots@tableread@to@listener + \else + \ifpgfplotstableread@foundcolnames + \else + \pgfplotstableread@create@column@names@with@numbers + \fi + \pgfplotstableread@countreset\pgfplotstableread@curcol% + \pgfutil@loop + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax + \expandafter\pgfplotsapplistXflushbuffers\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname + \pgfplotstableread@countadvance\pgfplotstableread@curcol + \pgfutil@repeat + \fi +} + +\def\pgfplotstableread@loop@over@lines@fromfile{% + \ifeof\r@pgfplots@reada +%\pgfplots@message{EOF}% + \else + \read\r@pgfplots@reada to\pgfplotstable@LINE + \ifeof\r@pgfplots@reada + \else + \pgfplotstableread@loop@processnextline + \fi + \expandafter\pgfplotstableread@loop@over@lines + \fi +}% +\def\pgfplotstableread@loop@over@lines@frominline{% + \pgfutil@ifnextchar\pgfplotstable@EOI{% + \pgfutil@gobble + }{% + \pgfplotstableread@loop@next + }% +}% + +\def\pgfplotstableread@check@skipfirstn{% + \ifnum\pgfplotstableread@lineno<\pgfkeysvalueof{/pgfplots/table/skip first n} % + \pgfplotstableread@skiplinetrue + \fi +}% + +% PRECONDITION: +% \pgfplotstable@LINE contains the current input line. +\def\pgfplotstableread@loop@processnextline{% + \expandafter\pgfplotstableread@checkspecial@line\pgfplotstable@LINE\pgfplotstable@EOI + \pgfplotstableread@check@skipfirstn + \ifpgfplotstableread@skipline + \def\pgfplotstableread@gnuplotcheck{####x y type}% + \ifx\pgfplotstableread@gnuplotcheck\pgfplotstable@LINE + \def\pgfplotstableread@isgnuplotformat{1}% + \fi + \def\pgfplotstableread@gnuplotcheck{####x y z type}% + \ifx\pgfplotstableread@gnuplotcheck\pgfplotstable@LINE + \def\pgfplotstableread@isgnuplotformat{1}% + \fi + \else + %-------------------------------------------------- + % \ifnum\pgfplotstableread@lineno=0 + % \let\pgfplotstable@firstline=\pgfplotstable@LINE + % \fi + %-------------------------------------------------- +%\pgfplots@message{READING LINE \thepgfplotstableread@lineno: '\meaning\pgfplotstable@LINE'.}% + \pgfplotstableread@curline@contains@colnamesfalse + \ifnum\pgfplotstableread@numcols=0\relax + % STEP 0: initialise + % - count columns + % - find header data + \pgfplotstableread@countreset\pgfplotstableread@curcol + \ifpgfplotstable@firstline@is@header + \pgfplotstableread@curline@contains@colnamestrue + \fi + \pgfplotstableread@impl@DO\pgfplotstableread@impl@countcols@and@identifynames@NEXT\pgfplotstable@LINE + \pgfplotstableread@countset\pgfplotstableread@numcols{\pgfplotstableread@curcol}% + \edef\pgfplotstablecols{\thepgfplotstableread@numcols}% + \pgfplotstableread@countreset\pgfplotstableread@curcol + % Create empty column lists: + \pgfplotstableread@create@column@lists + % + \ifnum\pgfplotstableread@usablelineno=0\relax + \if1\pgfplotstableread@isgnuplotformat% + % The file started with + % #... + % #x y type + % X Y i + % -> thats a gnuplot file! + \pgfplotstableread@curline@contains@colnamesfalse + \fi + \fi + % Now, read the first line. + % It contains either + % - column names, + % - numerical data, + % - nothing (comments). + \ifpgfplotstableread@curline@contains@colnames + \pgfplotstableread@foundcolnamestrue + \pgfplotstableread@countreset\pgfplotstableread@curcol + \pgfplotstableread@impl@DO\pgfplotstableread@impl@collectcolnames@NEXT\pgfplotstable@LINE + \else + \pgfplotsscanlinelengthincrease + \pgfplotstableread@foundcolnamesfalse + \pgfplotstableread@countreset\pgfplotstableread@curcol + % Leave column name lists empty... + \pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE + \fi +%\pgfplots@message{After reading first row: found '\thepgfplotstableread@numcols' columns; column name list='\meaning\pgfplotstable@colnames@glob'}% + \else + \pgfplotsscanlinelengthincrease + \pgfplotstableread@countreset\pgfplotstableread@curcol + \pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE + \fi + \ifnum\pgfplotstableread@curcol=\pgfplotstableread@numcols\relax + \else + \pgfplotsthrow{table columns unbalanced}{input table '\pgfplotstableread@filename' has an unbalanced number of columns in row '\thepgfplotstableread@lineno' (expected '\thepgfplotstableread@numcols' cols; got '\thepgfplotstableread@curcol'). Maybe the input table is corrupted? If you need unbalanced data, consider using 'nan' in empty cells (perhaps combined with 'unbounded coords=jump')}\pgfeov% + \fi + \ifpgfplots@tableread@to@listener + \ifpgfplotstableread@curline@contains@colnames + \else + % report row! + \pgfplotstable@listener + \fi + \fi + \pgfplotstableread@countadvance\pgfplotstableread@usablelineno + \fi + \pgfplotstableread@countadvance\pgfplotstableread@lineno +}% + +% WARNING: this routine is also used in pgfplots.code.tex ... +\def\pgfplotstableread@checkspecial@line{% + \futurelet\pgfplotstableread@tmp\pgfplotstableread@checkspecial@line@ +}% +\def\pgfplotstableread@checkspecial@line@{% + \pgfplotstableread@skiplinefalse + \let\pgfplotstableread@checkspecial@line@@\pgfplotstableread@impl@gobble% + % + \let\pgfplotstableread@tmpb=##% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb + \pgfplotstableread@skiplinetrue + \else + \let\pgfplotstableread@tmpb=$% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb + \let\pgfplotstableread@checkspecial@line@@=\pgfplotstableread@process@flags@line + \else + \let\pgfplotstableread@tmpb=\pgfplotstable@EOI% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb + \pgfplotstableread@skiplinetrue + \pgfplotsscanlinecomplete% the line is empty; same as \par! + \else + \let\pgfplotstableread@tmpb=\par% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb + \pgfplotstableread@skiplinetrue + \pgfplotsscanlinecomplete% the line is empty; + \else + \pgfplotstableread@checkspecial@line@default% + \fi + \fi + \fi + \fi + \pgfplotstableread@checkspecial@line@@ +}% +\def\pgfplotstableread@checkspecial@line@default{% + % this routine can be optimized away + \pgfkeysgetvalue{/pgfplots/table/comment chars}\pgfplots@loc@TMPd + \ifx\pgfplots@loc@TMPd\pgfutil@empty + \else + \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots@loc@TMPd}\as\pgfplots@loc@TMPd{% + \expandafter\let\expandafter\pgfplotstableread@tmpb\pgfplots@loc@TMPd + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb + \pgfplotstableread@skiplinetrue + \fi + }% + \fi +}% + +%-------------------------------------------------- +% \def\pgfplotstableread@checkspecial@line{% +% \pgfutil@ifnextchar##{% +% \pgfplotstableread@skiplinetrue +% \pgfplotstableread@impl@gobble +% }{% +% \pgfutil@ifnextchar${% +% \pgfplotstableread@process@flags@line +% }{% +% \pgfutil@ifnextchar\pgfplotstable@EOI{% +% \pgfplotstableread@skiplinetrue +% \pgfplotsscanlinecomplete% the line is empty; same as \par! +% \pgfplotstableread@impl@gobble +% }{% +% \pgfutil@ifnextchar\par{% +% \pgfplotstableread@skiplinetrue +% \pgfplotsscanlinecomplete +% \pgfplotstableread@impl@gobble +% }{% +% \pgfplotstableread@skiplinefalse +% \pgfplotstableread@impl@gobble +% }% +% }% +% }% +% }% +% } +%-------------------------------------------------- + +\long\def\pgfplotstableread@process@flags@line$flags {% +%\pgfplots@message{Ignoring flags line ...}% + \pgfplotstableread@skiplinetrue + \pgfplotstableread@impl@gobble +} + +\def\pgfplotstableread@create@column@lists{% + \pgfutil@loop + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax + \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}% + \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname + \pgfplotstableread@countadvance\pgfplotstableread@curcol + \pgfutil@repeat +} + +\def\pgfplotstableread@create@column@names@with@numbers{% + \pgfplotstableread@countreset\pgfplotstableread@curcol + \pgfutil@loop + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax + \edef\pgfplotstable@loc@TMPb{\thepgfplotstableread@curcol}% + \expandafter\pgfplotslistpushbackglobal\pgfplotstable@loc@TMPb\to\pgfplotstable@colnames@glob + \pgfplotstableread@countadvance\pgfplotstableread@curcol + \pgfutil@repeat +} + +\long\def\pgfplotstableread@impl@gobble#1\pgfplotstable@EOI{}% + +\def\pgfplotstable@EOI{\pgfplotstable@EOI}% + +% A loop command which processes every single entry in a raw data row #2 +% and invokes the macro #1{} for each found column entry. +% +% Columns are separated by the /pgfplots/table/col sep character. +% +% #1: a command which takes precisely one argument. It will be called +% for each found column entry +% +% #2: a macro containing a raw data line with separated +% entries. +\long\def\pgfplotstableread@impl@DO#1#2{% + \ifpgfplotstable@trimcells + \long\def\pgfplotstableread@impl@ITERATE@NEXT@##1{% + \pgfkeys@spdef\pgfplotstableread@impl@ITERATE@NEXT@@@{##1}% + \expandafter#1\expandafter{\pgfplotstableread@impl@ITERATE@NEXT@@@}% + }% + \else + \let\pgfplotstableread@impl@ITERATE@NEXT@=#1\relax + \fi + \expandafter\pgfplotstableread@impl@DO@\expandafter{#2}% +} +{% + \catcode`\ =10 + \catcode`\;=12 + \catcode`\:=12 + \gdef\pgfplotstableread@impl@prepare@DO{% + \ifcase\pgfplotstableread@COLSEP@CASE\relax + % col sep=space: + \catcode`\ =10 + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1 \pgfplotstable@EOI}% + \or + % col sep=comma: + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COMMA + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1,\pgfplotstable@EOI}% + \or + % col sep=semicolon: + \catcode`\;=12 + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1;\pgfplotstable@EOI}% + \or + % col sep=colon: + \catcode`\:=12 + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COLON + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1:\pgfplotstable@EOI}% + \or + % col sep=brace: + % allow multi line cells: + \endlinechar=\pgfplotstableread@oldendlinechar\relax + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@BRACE + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1\pgfplotstable@EOI}% + \or + % col sep=tab: + \catcode`\^^I=12 + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@TAB + \long\edef\pgfplotstableread@impl@DO@##1{\noexpand\pgfplotstableread@impl@ITERATE##1\pgfplotstableread@tab\noexpand\pgfplotstable@EOI}% + \or + % col sep=&: + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@AMPERSAND + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1&\pgfplotstable@EOI}% + \fi + }% +}% +\long\def\pgfplotstableread@impl@ITERATE{% + \pgfutil@ifnextchar\pgfplotstable@EOI{% + \pgfplotstableread@impl@gobble + }{% + \pgfplotstableread@impl@ITERATE@NEXT + }% +}% +\long\def\pgfplotstableread@impl@ITERATE@NEXT#1 {% + \pgfplotstableread@impl@ITERATE@NEXT@{#1}% + \pgfplotstableread@impl@ITERATE +}% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@COMMA#1,{% + \pgfplotstableread@impl@ITERATE@NEXT@{#1}% + \pgfplotstableread@impl@ITERATE +}% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON#1;{% + \pgfplotstableread@impl@ITERATE@NEXT@{#1}% + \pgfplotstableread@impl@ITERATE +}% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@COLON#1:{% + \pgfplotstableread@impl@ITERATE@NEXT@{#1}% + \pgfplotstableread@impl@ITERATE +}% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@BRACE#1{% + \pgfplotstableread@impl@ITERATE@NEXT@{#1}% + \pgfplotstableread@impl@ITERATE +}% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@AMPERSAND#1&{% + \pgfplotstableread@impl@ITERATE@NEXT@{#1}% + \pgfplotstableread@impl@ITERATE +}% +\begingroup +\catcode`\^^I=12 +\gdef\pgfplotstableread@tab{^^I}% +\long\gdef\pgfplotstableread@impl@ITERATE@NEXT@TAB#1^^I{% the following white spaces are SPACES, not tabs: + \pgfplotstableread@impl@ITERATE@NEXT@{#1}% + \pgfplotstableread@impl@ITERATE +}% +\endgroup +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% these values are only usable for a read-listener, that means: +% when using +% +% \pgfplotstableread{} to listener<\macro> +% +% -> <\macro> can than use the methods +% +% \pgfplotstablereadgetcolindex{}{<\content>} +% performs \let\content= > +\def\pgfplotstablereadgetcolindex@#1#2{% + \pgfutil@ifundefined{pgfplotstblread@colcontent@no#1}{% + \pgfplotsthrow{no such element}{#2}{Sorry, the requested column number '#1' in table '\pgfplotstableread@filename' does not exist!? Please verify you used the correct index 0 <= i < N.}\pgfeov% + }{% + \expandafter\let\expandafter#2\csname pgfplotstblread@colcontent@no#1\endcsname + }% +}% + +\pgfkeysdef{/pgfplots/table/@undefined column text}{#1__column_not_found.}% +\def\pgfplotstable@undefinedtext#1{\pgfkeysvalueof{/pgfplots/table/@undefined column text/.@cmd}#1\pgfeov}% + +% As \pgfplotstablereadgetcolindex, but +% \pgfplotstablereadvalueofcolindex{} +% directly expands to the value stored in the desired column. +% +% Example: +% \pgfplotstablereadvalueofcolindex{3} -> expands to '42' if '42' is +% written in column no 3. +% +% Column indexing starts at 0. +% +% @ATTENTION: since such a command may occur within an \edef or an +% \csname, it can't perform sanity checking. Proving an invalid index +% expands to \pgfkeysvalueof{/pgfplots/table/@undefined column text}. +\def\pgfplotstablereadvalueofcolindex@#1{% + \pgfutil@ifundefined{pgfplotstblread@colcontent@no#1}{% + \pgfplotstable@undefinedtext{colindex#1}% + }{% + \csname pgfplotstblread@colcontent@no#1\endcsname + }% +} + +% \pgfplotstablereadgetcolname{}{<\content>} +% performs \let\content= > +\def\pgfplotstablereadgetcolname@#1#2{% + \pgfplotstablereadgetptrtocolname{#1}{\pgfplots@loc@TMPa}% + \pgfplotstablereadevalptr\pgfplots@loc@TMPa{#2}% +}% + +% This here is the implementation of \pgfplotstablereadvalueofcolname +% (and \thisrow{}) for use inside of the 'read to listener' +% framework. +% +% Like \pgfplotstablereadgetcolname, but this one expands directly to +% the value of the desired column. +% +% #1: a column name or a column alias. +% +% @ATTENTION: since such a command may occur within an \edef or an +% \csname, it can't perform sanity checking. Proving an invalid index +% expands to \pgfkeysvalueof{/pgfplots/table/@undefined column text}. +\def\pgfplotstablereadvalueofcolname@#1{% + \pgfplotstable@thisrow@impl{#1}{pgfplotstblread@colindex@for@name}{\pgfplotstable@thisrow@impl@read}% +}% +\def\pgfplotstable@thisrow@impl@read#1{\csname pgfplotstblread@colcontent@no#1\endcsname}% + +% This implements \thisrow in different contexts. +% +% Usage: +% \def\thisrow#1{\pgfplotstable@thisrow@impl{#1}{macroprefix@}{\pgfplotstable@thisrow@impl@}} +% +% Then, \thisrow{existingcol} +% will expand to +% -> \pgfplotstable@thisrow@impl@{\csname macroprefix@existingcol\endcsname} +% -> \csname macroprefix@existingcol\endcsname +% +% Furthermore, if '#1' is no existing col and there exists /pgfplots/table/alias/#1, +% \thisrow{aliased} +% will expand to +% -> \pgfplotstable@thisrow@impl@{\csname macroprefix@\pgfkeysvalueof{/pgfplots/table/alias/aliased}\endcsname} +% -> \csname macroprefix@\pgfkeysvalueof{/pgfplots/table/alias/aliased}\endcsname +% +% #1: the argument for \thisrow{#1} +% #2: a macro prefix such that \csname #2\endcsname contains +% the value of the current row for (physical) column +% #3: the name of a one-argument-macro which will get \csname #2\endcsname +% as argument. This is the last step of \thisrow. It allows indirect +% access by translating colnames to col indices in '\pgfplotstableread to listener' +\def\pgfplotstable@thisrow@impl#1#2#3{% + \pgfutil@ifundefined{#2#1}% + {% + % WARNING : this code has been REPLICATED in + % *** \pgfplotstablereadgetptrtocolname *** + % *** \pgfplotstablegetcolumnbyname *** + % *** \pgfplotstableresolvecolname *** + % *** \pgfplotstablereadvalueofcolname *** + \pgfkeysifdefined{/pgfplots/table/alias/#1}{% + \pgfutil@ifundefined{#2\pgfkeysvalueof{/pgfplots/table/alias/#1}}{% + \pgfplotstable@undefinedtext{\pgfkeysvalueof{/pgfplots/table/alias/#1}}% + }{% + #3{\csname #2\pgfkeysvalueof{/pgfplots/table/alias/#1}\endcsname}% + }% + }{% + \pgfplotstable@undefinedtext{#1}% + }% + }% + {% + #3{\csname #2#1\endcsname}% + }% +}% +\def\pgfplotstable@thisrow@impl@#1{#1}% + +% \pgfplotstablereadgetptrtocolname{}{\ptr} +% Creates some sort of "pointer" to the column named . This +% pointer can than be used every time a new line has been reported to +% the listener. It works like this: +% +% \let\ptr=\pgfutil@empty +% \def\macro{% +% \ifx\ptr\empty +% \pgfplotstablereadgetptrtocolname{}{\ptr}% +% \fi +% \pgfplotstablereadevalptr{\ptr}{\content}% +% -> do something with \content! +% } +% +% \pgfplotstableread{} to listener<\macro> +% +% -> will evaluate \macro foreach row. +% +% The advantage of such a prepared pointer over \thisrow{#1} or +% \getthisrow{#1} is simply efficiency and sanity checking: the checks +% are done at the time of pointer creation, dereferencing the pointer +% is fast. +\def\pgfplotstablereadgetptrtocolname@#1#2{% + \def#2{0}% + \pgfplotstable@getcol{#1}\of{\pgfplotstableread@filename}\to{#2}\getcolmethod{getptr}% +}% + +% As \pgfplotstablereadgetptrtocolname, but this here accesses columns +% by index. +\def\pgfplotstablereadgetptrtocolindex@#1#2{\edef#2{#1}}% + +% \pgfplotstablereadevalptr{<\ptr>}{<\content} +% writes the current value of <\ptr> to <\content>. The pointer <\ptr> +% must be initialised with \pgfplotstablereadgetptrtocolname +\let\pgfplotstablereadevalptr@=\pgfplotstablereadgetcolindex@ + +% \pgfplotstablereadvalueofptr{<\ptr>} -> expands to the pointers value. +% +% The pointer \ptr must be initialised with +% \pgfplotstablereadgetptrtocolname. +\let\pgfplotstablereadvalueofptr@=\pgfplotstablereadvalueofcolindex@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\long\def\pgfplotstableread@impl@nextrow@NEXT@listener#1{% + \expandafter\def\csname pgfplotstblread@colcontent@no\thepgfplotstableread@curcol\endcsname{#1}% + \pgfplotstableread@countadvance\pgfplotstableread@curcol +} + +\long\def\pgfplotstableread@impl@nextrow@NEXT#1{% +%\pgfplots@message{Inserting '#1' at (\thepgfplotstableread@lineno, \thepgfplotstableread@curcol).}% + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax + \pgfplotslist@assembleentry{#1}\into\t@pgfplots@tokc + \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}% + \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname + \pgfplotstableread@countadvance\pgfplotstableread@curcol + \else + \begingroup + \t@pgfplots@tokc={#1}% + \pgfplotsthrow{table columns unbalanced}{Table '\pgfplotstableread@filename' appears to have too many columns in line \thepgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. PGFPlots found that the number of columns is larger than the previously determined number of columns. Please verify that every cell entry is separated correctly (use braces {} if necessary. Also verify that column names are plain ASCII.). This error is not critical}\pgfeov% + \endgroup + \fi +} + + + +\long\def\pgfplotstableread@impl@collectcolnames@NEXT#1{% + \edef\pgfplotstable@loc@TMPa{#1}% + \ifx\pgfplotstable@loc@TMPa\pgfutil@empty + \edef\pgfplotstable@loc@TMPa{\thepgfplotstableread@curcol}% + \pgfplotswarning{empty column name}{\pgfplotstableread@filename}{\pgfplotstable@loc@TMPa'}\pgfeov% + \fi + \expandafter\pgfplotstableread@impl@collectcolnames@NEXT@\expandafter{\pgfplotstable@loc@TMPa}% +} +\long\def\pgfplotstableread@impl@collectcolnames@NEXT@#1{% +%\pgfplots@message{Got column name no \thepgfplotstableread@curcol\ as '#1'}% + \pgfutil@ifundefined{pgfplotstableread@impl@COLNAME@#1}{% + \def\pgfplotstable@loc@TMPa{#1}% + }{% generate unique column names warning: + \pgfplots@warning{Table '\pgfplotstableread@filename' has non-unique column name '#1'. Only the first occurence can be accessed via column names.}% + \edef\pgfplotstable@loc@TMPa{#1--index\thepgfplotstableread@curcol}% + }% + \expandafter\def\csname pgfplotstableread@impl@COLNAME@#1\endcsname{foo}% remember this name. + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames@glob + \ifpgfplots@tableread@to@listener + % create an associative container colindex -> colname + % for use in a listener. + \expandafter\edef\csname pgfplotstblread@colindex@for@name#1\endcsname{\thepgfplotstableread@curcol}% + \fi + \pgfplotstableread@countadvance\pgfplotstableread@curcol +} + + + + +\long\def\pgfplotstableread@impl@countcols@and@identifynames@NEXT#1{% + \pgfplotstableread@countadvance\pgfplotstableread@curcol + \ifpgfplotstable@search@header + \ifpgfplotstableread@curline@contains@colnames + \else + \pgfplotstableread@isnumber@ITERATE#1\pgfplotstable@EOI +%\ifpgfplotstableread@curline@contains@colnames\pgfplots@message{'#1' is a column name!}\else\pgfplots@message{'#1' is NO column name!}\fi + \fi + \fi +} +\def\pgfplotstableread@isnumber@plus{+} +\def\pgfplotstableread@isnumber@minus{-} +\def\pgfplotstableread@isnumber@zero{0} +\def\pgfplotstableread@isnumber@one{1} +\def\pgfplotstableread@isnumber@two{2} +\def\pgfplotstableread@isnumber@three{3} +\def\pgfplotstableread@isnumber@four{4} +\def\pgfplotstableread@isnumber@five{5} +\def\pgfplotstableread@isnumber@six{6} +\def\pgfplotstableread@isnumber@seven{7} +\def\pgfplotstableread@isnumber@eight{8} +\def\pgfplotstableread@isnumber@nine{9} +\def\pgfplotstableread@isnumber@e{e} +\def\pgfplotstableread@isnumber@E{E} +\def\pgfplotstableread@isnumber@period{.} + +\def\pgfplotstableread@isnumber@ITERATE#1{% + \def\pgfplotstableread@CURTOK{#1}% + \ifx\pgfplotstableread@CURTOK\pgfplotstable@EOI + \def\pgfplotstableread@NEXT{}% + \else + \def\pgfplotstableread@NEXT{\pgfplotstableread@isnumber@ITERATE}% + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@plus + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@minus + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@zero + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@one + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@two + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@three + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@four + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@five + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@six + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@seven + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@eight + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@nine + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@e + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@E + \else + \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@period + \else +%\message{NO ITS NOT! Token: '\meaning\pgfplotstableread@CURTOK'}% + % it's no number, so it is a column name. + \pgfplotstableread@curline@contains@colnamestrue + \def\pgfplotstableread@NEXT{\pgfplotstableread@impl@gobble}% + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi + \fi + \pgfplotstableread@NEXT +} + +\def\pgfplotstable@error#1{\pgfplotsthrow{unsupported operation}{#1}\pgfeov}% + + +\def\pgfplotstableset{% + \pgfqkeys{/pgfplots/table}% +}% + +% Accepts a macro #1 which contains an argument denoting a column +% name. +% +% It checks whether #1 starts with '[index]', indicating that it is actually +% a column INDEX. If that is the case, +% \ifpgfplotstableread@foundcolnames is set to false and the index is +% returned into #1. +% +% Otherwise, \ifpgfplotstableread@foundcolnames is set to true. +\def\pgfplotstable@is@colname#1{% + \expandafter\pgfplotstabletypeset@is@colname@#1\pgfplotstable@EOI + \ifpgfplotstableread@foundcolnames + \else + \let#1=\pgfplotstable@loc@TMPa + \fi +}% +\def\pgfplotstabletypeset@is@colname@{% + \pgfutil@ifnextchar[{% + \pgfplotstabletypeset@is@colname@index + }{% + \pgfplotstableread@foundcolnamestrue + \pgfplotstabletypeset@is@colname@name + }% +} +\def\pgfplotstabletypeset@is@colname@index@@{index}% +\def\pgfplotstabletypeset@is@colname@index[#1]#2\pgfplotstable@EOI{% + \def\pgfplotstable@loc@TMPa{#1}% + \ifx\pgfplotstable@loc@TMPa\pgfplotstabletypeset@is@colname@index@@ + \pgfplotstableread@foundcolnamesfalse + \edef\pgfplotstable@loc@TMPa{#2}% + \else + \pgfplotstableread@foundcolnamestrue + \fi +}% +\def\pgfplotstabletypeset@is@colname@name#1\pgfplotstable@EOI{}% + +% calls \pgfplotstableset{every table={#1}} where '#1' is the table +% file name. +% +% Note that 'every table' is usually set *AFTER* any other option. In +% other words: settings in 'every table' have higher precedence than +% those provided, for example, at +% \pgfplotstabletypeset[]{...}. +% +% Why? Well, the need to be set *before* the file name +% argument is read. After all, it might contain an inline table for +% which \catcodes need to be adjusted -- and might explain +% how. +% +% REMARK: An early attempt to change the precendence for 'every table' +% was to set again after 'every table'. But that is +% incompatible with, for example '/.add={}{}' key handlers. +% +% This macro does nothing if 'every table' is empty. +% +% #1: the table name (argument to 'every table') +% #2: The which have already been set. +\long\def\pgfplotstableset@every@table#1#2{% + \pgfkeysgetvalue{/pgfplots/table/every table/.@cmd}\pgfplotstable@loc@TMPa + \ifx\pgfplotstable@loc@TMPa\pgfplots@empty@style@key + \else + \pgfplotstableset{/pgfplots/table/every table={#1}}%,#2}% + \fi +}% + +\def\pgfplotstabletypeset{% + \pgfutil@ifnextchar[{% + \pgfplotstabletypeset@opt + }{% + \pgfplotstabletypeset@opt[]% + }% +} +\long\def\pgfplotstabletypeset@opt[#1]#2{% + \pgfplotstable@error@pkg{Please load \string\usepackage{pgfplotstable} before using \string\pgfplotstabletypeset}% +} +\let\pgfplotstabletypesetfile=\pgfplotstabletypeset + +\def\pgfplotstablecreatecol{% + \pgfutil@ifnextchar[{% + \pgfplotstablecreatecol@opt + }{% + \pgfplotstablecreatecol@opt[]% + }% +}% +\def\pgfplotstablecreatecol@opt[#1]#2#3{% + \pgfplotstable@error@pkg{Please load \string\usepackage{pgfplotstable} before using \string\pgfplotstablecreatecol}% +}% + +% Iterates through every column of table '#1' and invokes the code +% '#3' for each column. The current column name will be available as +% '#2' and the current column index as |\pgfplotstablecol| (starting +% with 0). +% +% Example: +% \pgfplotstableforeachcolumn{\table}\as\colname{% +% The column name is `\colname'; its index \pgfplotstablecol.\par +% }% +% +% REMARK: this routine does NOT introduce TeX groups. +\long\def\pgfplotstableforeachcolumn#1\as#2#3{% + \def\pgfplotstablecol{0}% + \pgfplotslistforeachungrouped#1\as#2{% + #3\relax% + \pgfplotsutil@advancestringcounter\pgfplotstablecol + }% + \let\pgfplotstablecol=\relax +}% +\let\pgfplotstableforeachcolumn@orig=\pgfplotstableforeachcolumn + +% A variant of \pgfplotstableforeachcolumn which is used inside of +% \pgfplotstableread to listener. +% +% It is used as \pgfplotstableforeachcolumn\as\cur{} +\long\def\pgfplotstableforeachcolumn@listener#1\as#2#3{% + \pgfplotstableforeachcolumn@orig\pgfplotstable@colnames@glob\as{#2}{#3}% +}% + +% Reports every element t_{ij} for a fixed column j (in read-only +% mode). +% +% For every cell, the code '#4' will be executed where '#3' will +% contain the cell's value. During code '#4', the macro +% \pgfplotstablerow will contain the current row index. +% +% #1: either a column name or the string '[index]' followed by a +% number denoting a column index Access by column name is much faster.. +% #2: the table (macro or file name) +% #3: the macro in which the cell values shall be written +% #4: the code to execute. +% +% Example: +% \pgfplotstableforeachcolumnelement{colname}\of\table\as\cellelem{% +% I have now cell element `\cellelem' at row index +% `\pgfplotstablerow'. +% \par +% } +% +% REMARK: this routine does NOT introduce TeX groups. +\long\def\pgfplotstableforeachcolumnelement#1\of#2\as#3#4{% + \def\pgfplotstablerow{0}% + \pgfplotstablegetcolumn{#1}\of{#2}\to\pgfplotstableforeachcolumnelement@list + \pgfplotslistforeachungrouped\pgfplotstableforeachcolumnelement@list\as#3{% + % allow nesting by copying the old value of \pgfplotstablerow: + \expandafter\pgfplotstableforeachcolumnelement@\expandafter{\pgfplotstablerow}{#4}% + }% + \let\pgfplotstablerow=\relax +}% +% helper method to allow nesting. It copies \pgfplotstablerow. +% #1: the expanded value of \pgfplotstablerow. +\long\def\pgfplotstableforeachcolumnelement@#1#2{% + #2\relax + \def\pgfplotstablerow{#1}% restore to old value. + % advance. + \pgfplotsutil@advancestringcounter\pgfplotstablerow +}% + +% A routine which is similar to \pgfplotstableforeachcolumnelement, +% but this here checks for changes in \pgfplotsretval and writes them +% back into the respected cell. +% +% The runtime is quadratic in the number of rows. +\long\def\pgfplotstablemodifyeachcolumnelement#1\of#2\as#3#4{% + \def\pgfplotstablerow{0}% + % + % Step 0: get the REAL column name for '#1'. + % This needs modifications if '#1' is [index]. + % -> store the colname to \pgfplotstable@loc@TMPc: + \def\pgfplotstable@loc@TMPc{#1}% + \pgfplotstable@is@colname{\pgfplotstable@loc@TMPc}%% + \ifpgfplotstableread@foundcolnames + \else + \expandafter\pgfplotstablegetcolumnnamebyindex\pgfplotstable@loc@TMPc\of{#2}\to\pgfplotstable@loc@TMPc + \fi + % Step 0.1: prepare a command which re-assembles column '#1' + % (using the real column name). + % The re-assemblation command will be invoked at the end of each + % iteration. This complicated macro preparation allows nested + % calls to \pgfplotstablemodifyeachcolumnelement. + \t@pgfplots@toka={\expandafter\pgfplotslistpushback\expandafter{#3}\to}% + \edef\pgfplotstable@loc@TMPd{% + \the\t@pgfplots@toka{\expandafter\noexpand\csname\string#2@\pgfplotstable@loc@TMPc\endcsname}}% + % Step 1: copy the column data to \pgfplotstable@loc@TMPb + \expandafter\pgfplotstablegetcolumnbyname\pgfplotstable@loc@TMPc\of#2\to\pgfplotstable@loc@TMPb% + % + % clear the original column: + \expandafter\pgfplotslistnewempty\csname\string#2@\pgfplotstable@loc@TMPc\endcsname + % + % Call loop. The prepared re-assemble macro will be provided as macro argument + % to allow nested calls: + \expandafter\pgfplotstablemodifyeachcolumnelement@\expandafter{\pgfplotstable@loc@TMPd} + {\pgfplotstable@loc@TMPb}{#3}{#4}% + \let\pgfplotstablerow=\relax +}% +% #1: post-iteration code +% #2: the row list +% #3: the loop macro to assign +% #4: the loop body +\long\def\pgfplotstablemodifyeachcolumnelement@#1#2#3#4{% + \pgfplotslistforeachungrouped{#2}\as#3{% + % allow nesting by copying the old value of \pgfplotstablerow: + \expandafter\pgfplotstableforeachcolumnelement@\expandafter{\pgfplotstablerow}{#4}% + #1% + }% +} + +% Selects a single table element at row #1 and column #2 from table +% #3. +% +% #1: a row index. +% #2: a column name or the string '[index]' followed by a number +% denoting a column index. Access by column name is much faster. +% #3: the table (macro or file name). +% +% The cell value will be written into the macro \pgfplotsretval. +% +% REMARK: +% this routine is supposed to be very slow: it needs time O(N) where N +% is the number of rows. This may change in future versions. +% +% Example: +% \pgfplotstablegetelem{0}{[index]2}\of\table +% The elem is `\pgfplotsretval'. +\def\pgfplotstablegetelem#1#2\of#3{% + \begingroup + \pgfplotstablegetcolumn{#2}\of{#3}\to\pgfplotstable@loc@TMPa + \def\pgfplotsexceptionmsg{Sorry, row `#1' does not exist in table \pgfplotstablenameof{#3}}% + \pgfplotslistselect#1\of\pgfplotstable@loc@TMPa\to\pgfplotsretval + \pgfmath@smuggleone\pgfplotsretval + \endgroup +}% + +\def\pgfplotstablegetcolumnlist#1\to#2{\let#2=#1} + +% Defines \pgfmathresult (and now also \pgfplotsretval) to be the number of rows in table #1. +% +% #1 may be either a loaded table structure (a macro name) or a table +% file name. In the latter case, the file will be loaded temporarily. +\long\def\pgfplotstablegetrowsof#1{% + \pgfplotstable@isloadedtable{#1}{% + % ah - it is an already loaded table! + \begingroup + \pgfplotslistfront#1\to\pgfplotstablegetrows@@ + \expandafter\pgfplotslistsize\csname\string#1@\pgfplotstablegetrows@@\endcsname\to\c@pgfplotstable@counta + \edef\pgfmathresult{\the\c@pgfplotstable@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + }{% + % ah - it is a file name. + \begingroup + \pgfplotstableread{#1}\pgfplotstablegetrows@ + \pgfplotstablegetrowsof{\pgfplotstablegetrows@}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + }% + \let\pgfplotsretval=\pgfmathresult +}% + +% Defines \pgfplotsretval to contain the number of columns in table +% #1. +% +% #1 may be either a loaded table structure (a macro name) or a table +% file name. In the latter case, the file will be loaded temporarily. +\long\def\pgfplotstablegetcolsof#1{% + \pgfplotstable@isloadedtable{#1}{% + % ah - it is an already loaded table! + \begingroup + \pgfplotslistsize#1\to\c@pgfplotstable@counta + \edef\pgfplotsretval{\the\c@pgfplotstable@counta}% + \pgfmath@smuggleone\pgfplotsretval + \endgroup + }{% + % ah - it is a file name. + \begingroup + \pgfplotstableread{#1}\pgfplots@table + \pgfplotstablegetcolsof{\pgfplots@table}% + \pgfmath@smuggleone\pgfplotsretval + \endgroup + }% + \let\pgfmathresult=\pgfplotsretval +} diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex new file mode 100644 index 0000000..ced1ab3 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex @@ -0,0 +1,146 @@ + +%\input pgfplotsoldpgfsupp_pgfmathparse.opt.code.tex +%\beginpgfmathparsecheckfornumber + +\pgfutil@ifundefined{pgfmathlessthan@}{% + \let\pgfmathlessthan@=\pgfmathless@ + \let\pgfmathgreaterthan@=\pgfmathgreater@ +}{}% + + +\def\pgfplotsusecompatibilityfile#1{% + \pgfutil@IfUndefined{pgfplotsusecompatibilityfile@loaded@#1}{% + \expandafter\gdef\csname pgfplotsusecompatibilityfile@loaded@#1\endcsname{1}% + \input pgfplotsoldpgfsupp_#1 + }{% + % already loaded. + }% +}% + + +\def\pgfmathfloatrounddisplaystyle@shared@impl@WRONG#1#2{% + {\toks0={#1}% + \toks1=\expandafter{\pgfmathfloatrounddisplaystyle@e@mark #2}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + }% + \let\pgfmathresult=\pgfmathfloat@glob@TMP +}% + +% check whether we need to load supplementary code. +% The development of pgfplots and pgf is intermingled, so pgfplots +% always uses up-to-date pgf CVS versions - the relevant complements between +% PGF 2.10 and PGF CVS are loaded here: +% +% #1: for backwards compatibility +% #2: for normal processing. +\def\pgfplots@ifneedspgfcompabitibilitycode@has@pgf@one@zero@zero#1#2{% + %\pgfkeysifdefined{/pgf/number format/sci precision/.@cmd}{#2}{#1}% + \pgfutil@ifundefined{pgfmathprintnumber@RELATIVE@choice@roundtofixed}{#1}{#2}% +}% + +\let\pgfplots@ifneedspgfcompabitibilitycode=\pgfplots@ifneedspgfcompabitibilitycode@has@pgf@one@zero@zero + +\pgfplots@ifneedspgfcompabitibilitycode + {% + \immediate\write16{Package pgfplots: loading complementary code for your PGF version...} + \input pgfplotsoldpgfsupp_misc.code.tex + \let\pgfkeysloaded=\undefined + \input pgfplotsoldpgfsupp_pgfkeys.code.tex + \input pgfplotsoldpgfsupp_pgfmathfloat.code.tex + \input pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex + \input pgfplotsoldpgfsupp_pgflibraryfpu.code.tex + \input pgfplotsoldpgfsupp_pgfcorescopes.code.tex + \input pgfplotsoldpgfsupp_pgfcorelayers.code.tex + }% + {% + \pgfplots@iffileexists{pgflibraryfpu.code.tex}{% + \usepgflibrary{fpu}% + }{% + \immediate\write16{Package pgfplots: loading FPU library which doesn't appear to exist in your PGF version...} + \input pgfplotsoldpgfsupp_pgflibraryfpu.code.tex + }% + }% + +\pgfutil@ifundefined{pgfmathfloatatan2}{ + \immediate\write16{Package pgfplots: loading complementary arithmetics for your pgf version...} + \input pgfplotsoldpgfsupp_pgflibraryfpu.code.tex + \input pgfplotsoldpgfsupp_pgfmathfloat.code.tex +} +{}% + +\pgfutil@IfUndefined{pgfmathdeclarefunction}{ + \pgfplots@warning{Parts of pgfplots require PGF 2.10; you have PGF 2.00 . Consider upgrading if you experience problems.}% +}{% +}% + +\pgfutil@IfUndefined{pgfapplistnewempty}{% + \immediate\write16{Package pgfplots: loading complementary utilities for your pgf version...} + \csname newtoks\endcsname\t@pgf@toka + \csname newtoks\endcsname\t@pgf@tokb + \csname newtoks\endcsname\t@pgf@tokc + \gdef\pgfutil@advancestringcounter{\pgfplotsutil@advancestringcounter}% + \input pgfplotsoldpgfsupp_pgfutil-common-lists.tex +}{}% + +\pgfutil@IfUndefined{pgfmathiftrigonometricusesdeg}{% + \pgfutil@ifundefined{pgfmathdeclarefunction}{% + % PGF 2.00 !? Well, trig format won't work here. + }{% + \input pgfplotsoldpgfsupp_trig_format.code.tex + }% +}{}% + +\ifpgfplots@LUA@supported + \def\PATCH@pgfmath@local@function@body#1;{% + \def\pgfmath@local@body{#1}% + \begingroup% + \c@pgf@counta=0\relax% + \ifx\pgfmath@local@args\pgfmath@empty% + \expandafter\pgfmath@toks\expandafter=\expandafter{\pgfmath@local@body}% + \else% + \pgfmath@toks={}% + \expandafter\pgfmath@local@function@@body\pgfmath@local@args,,% + \fi% + \xdef\pgfmath@local@temp{% + \noexpand\pgfmathnotifynewdeclarefunction{\pgfmath@local@name}{\the\c@pgf@counta}% + {\the\pgfmath@toks}% + }% + \endgroup% + \pgfmath@local@temp% + } + % #1: the name + % #2: the number of arguments + % #3: a math expression containing '#1', '#2', ... ,'#' + % This callback is overwritten by pgflibraryluamath. + \def\PATCH@pgfmathnotifynewdeclarefunction#1#2#3{% + \pgfmathdeclarefunction{#1}{#2}{\pgfmathparse{#3}}% + }% + % + % currently, pgfplots does NOT call directly call any TeX macros + % from this library - but it relies on the fact that "trig + % format", \pgfmathsetseed and other configuration macros also + % mirror their values in LUA. + % And this mirroring is done in library luamath: + \def\pgfplots@glob@TMPa{3.0.0}% + \ifx\pgfversion\pgfplots@glob@TMPa + % 3.0.0 does not have the (correct) luamath library. + \let\pgfmathnotifynewdeclarefunction=\PATCH@pgfmathnotifynewdeclarefunction + \let\pgfmath@local@function@body=\PATCH@pgfmath@local@function@body + \pgfplotsusecompatibilityfile{pgflibraryluamath.code.tex} + \else + \pgfutil@IfFileExists{pgflibraryluamath.code.tex}{% + % ah - we have a very recent version of PGF. + % Well, it will hopefully come with a suitable version of the + % luamath library! Use it. + \usepgflibrary{luamath}% + }{% + % hm. PGF 2.10 ? + % + % FIXME + %\pgfplots@LUA@supportedfalse + }% + \fi +\fi + + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex new file mode 100644 index 0000000..36aafda --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex @@ -0,0 +1,885 @@ +% ====================================================== +% compatibility with PGF 2.10 +% ====================================================== +% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% It contains a couple of patches such that selected changes which +%%% are also part of PGF/TikZ (and can be found in the development +%%% version of PGF/TikZ) are available within pgfplots. +%%% +%%% Typically, these modifications have been done by the pgfplots team +%%% as contribution to PGf/TIKZ +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +\def\pgfdeclarelayer#1{% + \pgfutil@ifundefined{pgf@layerbox@#1}{% + \expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerbox@#1\endcsname% + \expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerboxsaved@#1\endcsname% + }{}% +} + +\def\tikz@key@name@path@wrong#1#2{% + \tikz@addmode{% + \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round% + \pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath% + \ifx\tikz@intersect@namedpaths\pgfutil@empty% + \else% + \tikz@intersect@namedpaths% + \pgfutil@ifundefined{tikz@intersect@path@name@#1}{}% + {% + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@intersect@@temppath% + \expandafter\expandafter\expandafter{\csname tikz@intersect@path@name@#1\endcsname}% + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@intersect@temppath% + \expandafter\expandafter\expandafter{\expandafter\tikz@intersect@temppath\tikz@intersect@temppath}% + }% + \fi% + \tikz@intersect@addto@path@names{#1}{#2}% + }% +}% + +\def\tikz@key@name@path@new#1#2{% + \tikz@addmode{% + \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round% + \pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath% + \ifx\tikz@intersect@namedpaths\pgfutil@empty% + \else% + \tikz@intersect@namedpaths% + \fi% + \tikz@intersect@addto@path@names{#1}{#2}% + }% +}% + +\ifx\tikz@key@name@path@wrong\tikz@key@name@path + \let\tikz@key@name@path=\tikz@key@name@path@new +\fi + +\def\pgfutil@insertatbegincurrentpagefrombox@WRONG#1{% + \global\setbox\pgfutil@abb\hbox{\unhbox\pgfutil@abb#1}% +} + +% needed for dvipdfmx and shader=interp +\def\pgfutil@insertatbegincurrentpagefrombox@FIXED#1{% + \edef\pgf@temp{\the\wd\pgfutil@abb}% + \global\setbox\pgfutil@abb\hbox{% + \unhbox\pgfutil@abb + % + % the order in which \pgfutil@insertatbegincurrentpagefrombox + % matters unless we make the following -shift! + % To see this, consider writing two such statements. The second + % one will (naturally) be placed more to the right, although there + % is no apparent reason why it should. + % + % CF observed problems when placing patterns in XObjects without + % this skip (dvipdfmx driver for pgfplots shader=interp) + \hskip-\pgf@temp\relax + #1% + }% +} +\expandafter\ifx\csname pgfutil@insertatbegincurrentpagefrombox\endcsname\pgfutil@insertatbegincurrentpagefrombox@WRONG + \let\pgfutil@insertatbegincurrentpagefrombox=\pgfutil@insertatbegincurrentpagefrombox@FIXED +\fi + +% check if \endtikzpicture deals with layerlist: +\expandafter\pgfutil@in@\expandafter\pgf@remember@layerlist@globally\expandafter{\endtikzpicture}% +\ifpgfutil@in@ +\else + \def\endtikzpicture{% + \tikz@atend@picture% + \global\let\pgf@shift@baseline@smuggle=\pgf@baseline% + \global\let\pgf@trimleft@final@smuggle=\pgf@trimleft% + \global\let\pgf@trimright@final@smuggle=\pgf@trimright% + \global\let\pgf@remember@smuggle=\ifpgfrememberpicturepositiononpage% + \pgf@remember@layerlist@globally + \endscope% + \let\pgf@baseline=\pgf@shift@baseline@smuggle% + \let\pgf@trimleft=\pgf@trimleft@final@smuggle% + \let\pgf@trimright=\pgf@trimright@final@smuggle% + \let\ifpgfrememberpicturepositiononpage=\pgf@remember@smuggle% + \pgf@restore@layerlist@from@global + \endpgfpicture} +\fi + +% ====================================================== +% compatibility with PGF 2.0 +% ====================================================== +\def\pgfutil@gobble@until@relax#1\relax{} + +\expandafter\ifx\csname w@pgf@writea\endcsname\relax +\csname newwrite\endcsname\w@pgf@writea +\fi + +\expandafter\ifx\csname r@pgf@reada\endcsname\relax +\csname newread\endcsname\r@pgf@reada +\fi +\let\pgfutil@inputcheck=\r@pgf@reada + +\pgfutil@ifundefined{pgf@texdist@protect}{% + \def\pgf@texdist@protect{}% +}{} + +% from pgfutil-common.tex: + +% Usage: +% \pgfutilstrreplace{}{}{} +% +% -> will assign the modified string into \pgfretval. +% +% #1: the string to search (one or more tokens) +% #2: zero, one or more tokens which will be inserted instead of '#1'. +% #3: the string to search in +\long\def\pgfutilstrreplace#1#2#3{% + \def\pgfretval{}% + \long\def\pgfutil@search@and@replace@@##1#1##2\pgf@EOI{% + \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval ##1#2}% + \pgfutil@search@and@replace@loop{#1}{##2}% + }% + \pgfutil@search@and@replace@loop{#1}{#3}% +} +\long\def\pgfutil@search@and@replace@loop#1#2{% + \pgfutil@in@{#1}{#2}% + \ifpgfutil@in@ + \def\pgf@loc@TMPa{\pgfutil@search@and@replace@@ #2\pgf@EOI}% + \else + \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #2}% + \let\pgf@loc@TMPa=\relax + \fi + \pgf@loc@TMPa +}% +% Solves a linear equation system of size 2x2 using gauss elimination. +% +% It employs TeX register arithmetics to do so. +% #1: should contain 4 sets of braces with matrix entries, +% {}{} +% {}{} +% where each entry should be a number without unit. +% #2: should contain 2 sets of braces with the right-hand-side, +% {}{} +% where each entry should be a number without unit. +% +% It will assign \pgfmathresult to contain two sets of braces with the +% result. +% +% Example: +% \pgfutilsolvetwotwoleq{ +% {0.24}{1} +% {-0.97}{0} +% }{ +% {-7} +% {18} +% } +% -> yields \pgfmathresult={−18.55618}{−2.54642} +% +% The algorithm employs column pivotisation. +\def\pgfutilsolvetwotwoleq#1#2{% + \begingroup + \dimendef\aa=0 + \dimendef\ab=1 + \dimendef\ba=2 + \dimendef\bb=3 + \dimendef\ra=4 + \dimendef\rb=5 + \dimendef\tmpa=6 + \dimendef\tmpb=7 + \edef\pgf@temp{#1}% + \expandafter\pgfutilsolvetwotwoleq@A\pgf@temp + \edef\pgf@temp{#2}% + \expandafter\pgfutilsolvetwotwoleq@r\pgf@temp + % + \pgfutilsolvetwotwoleq@ifislarger\aa\ba{% + % identity "permutation": + \def\Pa{a}% + \def\Pb{b}% + }{% + % permutation matrix: switch rows! + \def\Pa{b}% + \def\Pb{a}% + }% + % \pivot := 1/aa + \pgfmathreciprocal@ + {\csname m\Pa a\endcsname}% + \let\pivot=\pgfmathresult + % + % \factor := 1/aa * ba + \csname \Pb a\endcsname=\pivot\csname \Pb a\endcsname + \edef\factor{\expandafter\pgf@sys@tonumber\csname \Pb a\endcsname}% + % + % bb -= ba/aa * ab + \tmpa=-\factor\csname \Pa b\endcsname + \advance\csname \Pb b\endcsname by\tmpa + % + % rb -= ba/aa * ra + \tmpa=-\factor\csname r\Pa\endcsname + \advance\csname r\Pb\endcsname by\tmpa + % + % xb := rb / bb (the modified rb and modified bb!) + \pgfmathdivide@ + {\expandafter\pgf@sys@tonumber\csname r\Pb\endcsname} + {\expandafter\pgf@sys@tonumber\csname \Pb b\endcsname}% + \expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult + % + % ra -= xb * ab + \tmpa=\csname pgfmathresult\Pb\endcsname\csname \Pa b\endcsname + \advance\csname r\Pa\endcsname by-\tmpa + % + % xa := 1/aa * ra (the modified ra!) + \tmpa=\pivot\csname r\Pa\endcsname + \expandafter\edef\csname pgfmathresult\Pa\endcsname{\pgf@sys@tonumber\tmpa}% + % + \edef\pgfmathresult{% + {\csname pgfmathresult\Pa\endcsname}% + {\csname pgfmathresult\Pb\endcsname}% + }% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfutilsolvetwotwoleq@ifislarger#1#2#3#4{% + \tmpa=#1 + \ifdim\tmpa<0pt + \multiply\tmpa by-1 + \fi + \tmpb=#2 + \ifdim\tmpb<0pt + \multiply\tmpb by-1 + \fi + \ifdim\tmpa>\tmpb + #3% + \else + #4% + \fi +}% +\def\pgfutilsolvetwotwoleq@A#1#2#3#4{% + \def\maa{#1}\def\mab{#2}% + \def\mba{#3}\def\mbb{#3}% + \aa=#1pt \ab=#2pt + \ba=#3pt \bb=#4pt +} +\def\pgfutilsolvetwotwoleq@r#1#2{% + \ra=#1pt \rb=#2pt +}% + + +%%%%%%% +%%%%%%% + +% from pgfmoduleshapes.code.tex: +% Invoke an anchor +\def\pgf@sh@reanchor#1#2{% + \pgfutil@ifundefined{pgf@anchor@#1@#2}% + {% + \pgfutil@ifundefined{pgf@anchor@generic@#2}{% + \pgfmathsetcounter{pgf@counta}{#2}% + \csname pgf@anchor@#1@border\endcsname{\pgfqpointpolar{\c@pgf@counta}{1pt}}% + }{% + \csname pgf@anchor@generic@#2\endcsname{#1}% + }% + }% + {\csname pgf@anchor@#1@#2\endcsname}% +} + +% Defines a generic anchor, i.e. one which gets the associated shape +% as first argument. +% +% #1: the anchor name. +% #2: the code of the anchor. It may depend upon '##1', the shape's +% name. +% +% The anchor will be defined locally in the current TeX scope. +\def\pgfdeclaregenericanchor#1#2{% + \expandafter\def\csname pgf@anchor@generic@#1\endcsname##1{#2}% +}% + +% from pgfcoretransformations.code.tex : +\def\pgfgettransformentries#1#2#3#4#5#6{% + \edef#1{\pgf@pt@aa}% + \edef#2{\pgf@pt@ab}% + \edef#3{\pgf@pt@ba}% + \edef#4{\pgf@pt@bb}% + \edef#5{\the\pgf@pt@x}% + \edef#6{\the\pgf@pt@y}% +}% +\def\pgfsettransformentries#1#2#3#4#5#6{% + \pgfsettransform{{#1}{#2}{#3}{#4}{#5}{#6}}% +}% + +% pgfutil@loop (from plain.tex) + +\def\pgfutil@loop#1\pgfutil@repeat{\def\pgfutil@body{#1}\pgfutil@iterate} +\def\pgfutil@iterate{\pgfutil@body \let\pgfutil@next\pgfutil@iterate \else\let\pgfutil@next\relax\fi \pgfutil@next} +\let\pgfutil@repeat=\fi % this makes \loop...\if...\repeat skippable + +\def\pgfqpointxy#1#2{% + \pgf@x=#1\pgf@xx% + \advance\pgf@x by #2\pgf@yx% + \pgf@y=#1\pgf@xy% + \advance\pgf@y by #2\pgf@yy} +\def\pgfqpointxyz#1#2#3{% + \pgf@x=#1\pgf@xx% + \advance\pgf@x by #2\pgf@yx% + \advance\pgf@x by #3\pgf@zx% + \pgf@y=#1\pgf@xy% + \advance\pgf@y by #2\pgf@yy% + \advance\pgf@y by #3\pgf@zy} +\def\pgfcoordinate#1#2{% + \edef\pgf@temp{#1}% + \ifx\pgf@temp\pgfutil@empty% do nothing + \else% + \pgf@process{\pgfpointtransformed{#2}}% + \expandafter\gdef\csname pgf@sh@ns@#1\endcsname{coordinate}% + \expandafter\xdef\csname pgf@sh@np@#1\endcsname{% + \noexpand\def\noexpand\centerpoint{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + } + \expandafter\gdef\csname pgf@sh@nt@#1\endcsname{{1}{0}{0}{1}{0pt}{0pt}}% + \expandafter\global\expandafter\let\csname pgf@sh@ma@#1\endcsname\pgfutil@empty% + \expandafter\gdef\csname pgf@sh@pi@#1\endcsname{\pgfpictureid}% + \fi% +} +% A "quick" variant of \pgfpointscale which doesn't invoke the math parser for '#1'. +% #1 must be a number without units, no registers are accepted. +\def\pgfqpointscale#1#2{% + \pgf@process{#2}% + \pgf@x=#1\pgf@x% + \pgf@y=#1\pgf@y% +} +% ====================================================== + +\def\pgfutilensuremath#1{% + \ifmmode#1\else$#1$\fi +} +\def\tikzifinpicture#1#2{% + \pgfutil@ifundefined{filldraw}{#2}{#1}% +}% + +\def\tikz@fig@scan@name(#1){% + \pgfkeysvalueof{/tikz/name/.@cmd}#1\pgfeov% CF : this is now ALWAYS consistent with 'name=' option; allows overrides. + \tikz@@scan@fig}% + +\tikzoption{ybar}[]{\let\tikz@plot@handler=\pgfplothandlerybar} +\tikzoption{xbar}[]{\let\tikz@plot@handler=\pgfplothandlerxbar} +\tikzoption{ybar interval}[]{\let\tikz@plot@handler=\pgfplothandlerybarinterval} +\tikzoption{xbar interval}[]{\let\tikz@plot@handler=\pgfplothandlerxbarinterval} +\tikzoption{const plot}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto} +\tikzoption{const plot mark left}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto} +\tikzoption{const plot mark right}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkright} +\tikzoption{const plot mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkmid} +\tikzoption{jump mark right}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkright} +\tikzoption{jump mark left}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkleft} +\tikzoption{jump mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkmid} + +\def\tikz@plot@samples{25} +\def\tikz@plot@domain{-5:5} +\def\tikz@plot@var{\x} +\def\tikz@plot@samplesat{-5,-4.5833333,...,5} + +\tikzoption{mark}{ + \def\tikz@plot@mark{#1}% + \def\tikz@temp{none}% this check is relatively new + \ifx\tikz@temp\tikz@plot@mark + \let\tikz@plot@mark=\pgfutil@empty + \fi +} + +% the 'pt' suffix is new: +\pgfdeclareplotmark{ball} +{% + \def\tikz@shading{ball}% + \shade (0pt,0pt) circle (\pgfplotmarksize);% +} + +% the 'every mark' style is new: +\tikzset{ + no marks/.style={mark=none},% + every mark/.style={}, + mark options/.style={% + every mark/.style={#1}% + }} +\def\tikz@@@plot{% + \def\pgfplotlastpoint{\pgfpointorigin}% + \tikz@plot@handler% + \tikz@plot@data% + \global\let\tikz@@@temp=\pgfplotlastpoint% + \ifx\tikz@plot@mark\pgfutil@empty% + \else% + % Marks are drawn after the path. + \setbox\tikz@figbox=\hbox{% + \unhbox\tikz@figbox% + \hbox{{% + \pgfinterruptpath% + \pgfscope% + \let\tikz@options=\pgfutil@empty% + \let\tikz@transform=\pgfutil@empty% + \tikzset{every mark}% + \tikz@options% + \ifx\tikz@mark@list\pgfutil@empty% + \pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}% + \else + \pgfplothandlermarklisted{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}{\tikz@mark@list}% + \fi + \tikz@plot@data% + \endpgfscope + \endpgfinterruptpath% + }}% + }% + \fi% + \global\setbox\tikz@tempbox=\copy\tikz@figbox% + %\global\let\tikz@after@path@smuggle=\tikz@after@path + \endgroup% + \setbox\tikz@figbox=\box\tikz@tempbox% + \tikz@make@last@position{\tikz@@@temp}% + %\expandafter\tikz@scan@next@command\tikz@after@path@smuggle% + \tikz@scan@next@command% +} + + + + +% ====================================================== + + +\newif\ifpgfmathcomparison + +% Assigns \pgfmathresult to 1.0 if #1 ~= #1. +% +% It will also set the boolean \ifpgfmathcomparison accordingly +% (globally). +\def\pgfmathapproxequalto#1#2{% + \edef\pgfmath@marshal{% + \noexpand\pgfmathparse{#2} + \noexpand\let\noexpand\pgfmath@arg\noexpand\pgfmathresult% + \noexpand\pgfmathparse{#1}% + }% + \pgfmath@marshal% + \pgfmathapproxequalto@{\pgfmathresult}{\pgfmath@arg}} +\def\pgfmathapproxequalto@#1#2{% + \begingroup% + \pgfmath@x#1pt% + \pgfmath@y#2pt% + \advance\pgfmath@x-\pgfmath@y% + \ifdim\pgfmath@x<0pt + \multiply\pgfmath@x by-1 + \fi + \ifdim\pgfmath@x<0.0001pt\relax% + \def\pgfmathresult{1.0}% + \global\pgfmathcomparisontrue + \else% + \def\pgfmathresult{0.0}% + \global\pgfmathcomparisonfalse + \fi% + \pgfmath@smuggleone\pgfmathresult + \endgroup% +} + +\newif\ifpgfmarktext@usetikznode +\pgfkeys{ + /pgf/text mark/.initial=p, + /pgf/text mark style/.initial=, + /pgf/text mark as node/.is if=pgfmarktext@usetikznode, + /pgf/text mark as node/.default=true, + % + % backw. compat: the extra search path confuses the '.unknown' + % handlers, so this here is deprecated: + /pgf/text mark/style/.style={/pgf/text mark style={#1}},% + /pgf/text mark/as node/.style={/pgf/text mark as node=#1},% +}% + +\pgfdeclareplotmark{text} +{ + \pgfkeysgetvalue{/pgf/text mark style}\pgfmarktext@style + \pgfkeysgetvalue{/pgf/text mark}\pgfmarktext@ + \ifpgfmarktext@usetikznode + \expandafter\node\expandafter[\pgfmarktext@style]{\pgfmarktext@}; + \else + \expandafter\pgftext\expandafter[\pgfmarktext@style]{\pgfmarktext@}% + \fi +} + +% A fix for the overlay option and matrices: +\def\pgf@matrix@startcell{% + % + % Step 1: Init the list of nodes for this cell + % + \let\pgf@nodecallback=\pgf@matrix@nodecallback% + % + % Step 2: Setup the bounding box + % + \pgfinterruptboundingbox% + % + % Step 3: Reset the transformation matrix + % + \pgftransformreset% + % + % Step 4: Collect everything in a cell box + % + \setbox\pgf@matrix@cell=\hbox\bgroup\bgroup% + % make sure that cell pictures are not affected if matrizes have + % 'overlay' option on: + \pgf@relevantforpicturesizetrue + \pgfsys@beginpicture% + \normalbaselines% + % Find out whether the cell is empty: + \pgfutil@ifnextchar\let% + {% ok, candidate, check following symbol + \afterassignment\pgf@matrix@empty@check\let\pgf@matrix@temp=% get rid of \let + }% + {% no, not empty + \pgf@matrix@empty@cell@false% + \pgfmatrixbegincode% + }% +} + +% From pgfmoduleplot.code.tex: +{ + \catcode`\%=12 + \catcode`\"=12 + \xdef\pgf@gnuplot@head@pgf@two@oo#1{set terminal table; set output "#1.table"; set format "%.5f"} + \ifx\pgf@gnuplot@head\pgf@gnuplot@head@pgf@two@oo + \xdef\pgf@gnuplot@head#1{set table "#1.table"; set format "%.5f"} + \else + \xdef\pgf@gnuplot@head{set table \noexpand\pgf@plottablefile@quoted; set format "%.5f"} + \fi +} + +% From pgfcorescopes.code.tex: +\def\pgfresetboundingbox{% + \global\pgf@picmaxx=-16000pt\relax% + \global\pgf@picminx=16000pt\relax% + \global\pgf@picmaxy=-16000pt\relax% + \global\pgf@picminy=16000pt\relax% +}% + +% from pgfcorepathconstruct.code.tex: + + +\def\pgfpatharctomaxstepsize{45} + +% A specialized arc operation for an arc on an (axis--parallel) ellipse. +% +% In contrast to \pgfpatharc, it explicitly interpolates start- and end points. +% +% In contrast to \pgfpatharcto, this routine is numerically stable and +% quite fast since it relies on a lot of precomputed information. +% +% #1 center of ellipse +% #2 angle of last path position inside of the ellipse +% #3 end angle +% #4 end point (a \pgfpoint) +% #5 xradius +% #6 yradius +% #7 the ratio xradius/yradius of the ellipse +% #8 the ratio yradius/xradius of the ellipse +% Example: +% \def\cx{1cm}% center x +% \def\cy{1cm}% center y +% \def\startangle{0}% +% \def\endangle{45}% +% \def\a{5cm}% xradius +% \def\b{10cm}% yradius +% \pgfmathparse{\a/\b}\let\abratio=\pgfmathresult +% \pgfmathparse{\b/\a}\let\baratio=\pgfmathresult +% +% \pgfpathmoveto{\pgfpoint{\cx+\a*cos(\startangle)}{\cy+\b*sin(\startangle)}}% +% \pgfpatharctoprecomputed +% {\pgfpoint{\cx}{\cy}} +% {\startangle} +% {\endangle} +% {\pgfpoint{\cx+\a*cos(\endangle)}{\cy+\b*sin(\endangle)}}% +% {\a} +% {\b} +% {\abratio} +% {\baratio} +% +\def\pgfpatharctoprecomputed#1#2#3#4#5#6#7#8{% + \begingroup + % Implementation idea: + % + % let + % m = center (#1) + % \gamma_0 = start angle + % \gamma_1 = end angle + % a = x radius + % b = y radius + % + % an axis parallel ellipse is parameterized by + % C(\gamma) = m + ( a cos(\gamma), b sin(\gamma) ), \gamma in [0,360]. + % + % Now, consider the segment \gamma(t), + % \gamma:[0,1] -> [\gamma_0,\gamma_1], + % t -> \gamma_0 + t(\gamma_1 - \gamma_0) + % and + % C(\gamma(t)) which is defined on [0,1]. + % + % I'd like to approximate the arc by one or more cubic bezier + % splines which interpolate through the last and first provided + % points. + % + % In general, a Bezier spline C:[0,1] -> \R of order n fulfills + % C'(0) = n ( P_1 - P_0 ), + % C'(1) = n ( P_n - P_{n-1} ). + % For n=3 and given P_0 and P_3, I can directly compute P_1 and P_2 once I know + % the derivatives at t=0 and t=1. + % + % The derivatives in our case are + % ( C \circ \gamma )'(t) = C'[\gamma(t)] * \gamma'(t) + % = ( -a pi/180 sin(\gamma(t)), b pi/180 cos(\gamma(t)) ) * (\gamma_1 - \gamma_0). + % The pi/180 comes into play since we are working with degrees. + % + % Expression (C\circ\gamma)'(0) using P_0 and (C \circ \gamma)'(1) + % using P_3 yields the expressions + % (C \circ \gamma)'(0) = + % pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_0^y - my), b/a (P_0^x - mx) ] + % (C \circ \gamma)'(1) = + % pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_3^y - my), b/a (P_3^x - mx) ] + % + % defining + % scaleA = a/b * pi / (3*180) * (\gamma_1 - \gamma_0) + % and + % scaleB = b/a * pi / (3*180) * (\gamma_1 - \gamma_0) + % yields the direct expressions for the intermediate bezier + % control points + % + % P_1 = [ + % P_0^x - scaleA* ( P_0^y -my), + % P_0^y + scaleB* ( P_0^x -mx) ] + % and + % P_2 = [ + % P_3^x + scaleA* ( P_3^y -my), + % P_3^y - scaleB* ( P_3^x -mx) ]. + % + % This works fast, with few operations, if + % - a/b and b/a are known in advance + % - P_0 and P_3 are known in advance + % - \gamma_0 and \gamma_1 are known. + % + % It is also reliable if (\gamma_1 - \gamma_0) is small + % + \pgf@process{#1}% + \edef\pgfpath@center@x{\the\pgf@x}% + \edef\pgfpath@center@y{\the\pgf@y}% + \def\pgfpath@completearcend{#4}% + % compute scale (#3-#2) * pi/(3*180) = (#3 - #2) * pi/27 * 1/20 + % splitting pi/(3*180) into two scales has higher TeX accuracy + \pgf@xa=#2pt + \pgf@xb=#3pt + \edef\pgfpath@startangle{#2pt}% + \edef\pgfpath@endangle{\pgf@sys@tonumber\pgf@xb}% + % + \pgf@ya=\pgf@xb + \advance\pgf@ya by-\pgf@xa + % + \ifx\pgfpatharctomaxstepsize\pgfutil@empty + \def\pgfpath@N{1}% + \pgf@xc=\pgf@ya + \else + \pgf@xc=\pgf@ya% compute N = floor((gamma_1 - gamma_0) / max) +1 + \ifdim\pgf@xc<0pt + \multiply\pgf@xc by-1 + \fi + \divide\pgf@xc by\pgfpatharctomaxstepsize\relax + \afterassignment\pgfutil@gobble@until@relax + \c@pgf@counta=\the\pgf@xc\relax + \advance\c@pgf@counta by1 + \edef\pgfpath@N{\the\c@pgf@counta}% + % + \pgf@xc=\pgf@ya + \divide\pgf@xc by\c@pgf@counta + \fi + % + \edef\pgfpath@h{\pgf@sys@tonumber\pgf@xc}% + % +%\message{pgfpathellipse: using N =\pgfpath@N\space spline points y0 = \pgfpath@startangle, y0+i*h, yN=\pgfpath@endangle, i=1,...,(\pgfpath@N-1), with h=\pgfpath@h\space mesh width (total arc angle \pgf@sys@tonumber\pgf@ya).}% + % + % + \pgf@xc=0.116355283466289\pgf@xc % pi/27 + \divide\pgf@xc by20 + \pgf@xa=#7\pgf@xc + \edef\pgfpath@scale@A{\pgf@sys@tonumber\pgf@xa}% + \pgf@xa=#8\pgf@xc + \edef\pgfpath@scale@B{\pgf@sys@tonumber\pgf@xa}% + % + % compute intermediate spline segments for + % i = 1,...,N-1 + % this is a no-op for N=1. + \c@pgf@countd=1 + \pgfutil@loop + \ifnum\c@pgf@countd<\pgfpath@N\relax + % + \pgf@xa=\pgfpath@startangle % compute \pgf@xa = y_0 + i*h + \pgf@xb=\pgfpath@h pt + \multiply\pgf@xb by\c@pgf@countd + \advance\pgf@xa by\pgf@xb + \edef\pgfpath@angle@i{\pgf@sys@tonumber\pgf@xa}% +%\message{angle \the\c@pgf@countd: \pgfpath@angle@i...}% + % + \pgfpatharcofellipse@{% + \pgfpoint + {\pgfpath@center@x + #5*cos(\pgfpath@angle@i)} + {\pgfpath@center@y + #6*sin(\pgfpath@angle@i)} + }% + % + \advance\c@pgf@countd by1 + \pgfutil@repeat + % + % compute final spline segment. It only differs insofar as the + % final point is already known explicitly and should be + % interpolated without additional math error. +%\message{angle \pgfpath@N: \pgfpath@endangle...}% + \pgfpatharcofellipse@{\pgfpath@completearcend}% + \endgroup +}% +\def\pgfpatharcofellipse@#1{% + \begingroup + \pgf@process{#1}% + \edef\pgfpath@endpt{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + % + \pgfpathcurveto{ + \begingroup + \global\pgf@x=\pgf@path@lastx + \global\pgf@y=\pgf@path@lasty + \pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x + \pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y + \global\advance\pgf@x by-\pgfpath@scale@A\pgf@ya + \global\advance\pgf@y by \pgfpath@scale@B\pgf@xa + \endgroup + }{% + \begingroup + \pgfpath@endpt + \pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x + \pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y + \global\advance\pgf@x by \pgfpath@scale@A\pgf@ya + \global\advance\pgf@y by-\pgfpath@scale@B\pgf@xa + \endgroup + }{% + \pgfpath@endpt + }% + \endgroup +} + +% bugfix for pgf 2.10, pgfmathfunctions.basic.code.tex : +% +\newif\ifpgfmath@divide@period +\def\pgfmathdivide@#1#2{% + \begingroup% + \pgfmath@x=#1pt\relax% + \pgfmath@y=#2pt\relax% + \let\pgfmath@sign=\pgfmath@empty% + \ifdim0pt=\pgfmath@y% + \pgfmath@error{You've asked me to divide `#1' by `#2', % + but I cannot divide any number by `#2'}% + \fi% + \afterassignment\pgfmath@xa% + \c@pgfmath@counta\the\pgfmath@y\relax% + \ifdim0pt=\pgfmath@xa% + \divide\pgfmath@x by\c@pgfmath@counta% + \else% + \ifdim0pt>\pgfmath@x% + \def\pgfmath@sign{-}% + \pgfmath@x=-\pgfmath@x% + \fi% + \ifdim0pt>\pgfmath@y% + \expandafter\def\expandafter\pgfmath@sign\expandafter{\pgfmath@sign-}% + \pgfmath@y=-\pgfmath@y% + \fi% + \ifdim1pt>\pgfmath@y% + \pgfmathreciprocal@{\pgfmath@tonumber{\pgfmath@y}}% + \pgfmath@x=\pgfmath@sign\pgfmathresult\pgfmath@x% + \else% + \def\pgfmathresult{0}% + \pgfmath@divide@periodtrue% + \c@pgfmath@counta=0\relax% + \pgfmathdivide@@% + \pgfmath@x=\pgfmath@sign\pgfmathresult pt\relax% + \fi% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} +\def\pgfmath@small@number{0.00002} +\def\pgfmathdivide@@{% + \let\pgfmath@next=\relax% + \ifdim\pgfmath@small@number pt<\pgfmath@x% + \ifdim\pgfmath@small@number pt<\pgfmath@y% + \ifdim\pgfmath@y>\pgfmath@x% + \ifpgfmath@divide@period% + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult.}% + \pgfmath@divide@periodfalse% + \fi% + \pgfmathdivide@dimenbyten\pgfmath@y% + \ifdim\pgfmath@y>\pgfmath@x% + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult0}% + \fi% + \else% + \c@pgfmath@counta=\pgfmath@x% + \c@pgfmath@countb=\pgfmath@y% + \divide\c@pgfmath@counta by\c@pgfmath@countb% + \pgfmath@ya=\c@pgfmath@counta\pgfmath@y% + \advance\pgfmath@x by-\pgfmath@ya% + \def\pgfmath@next{% + \toks0=\expandafter{\pgfmathresult}% + \edef\pgfmathresult{\the\toks0 \the\c@pgfmath@counta}% + }% + \ifpgfmath@divide@period + \else + % we are behind the period. It may happen that the + % result is more than one digit - in that case, + % introduce special handling: + \ifnum\c@pgfmath@counta>9 % + \expandafter\pgfmathdivide@advance@last@digit\pgfmathresult CCCCC\@@ + \advance\c@pgfmath@counta by-10 % + \ifnum\c@pgfmath@counta=0 + \let\pgfmath@next=\relax + \fi + \fi + \fi + \pgfmath@next + \fi% + \let\pgfmath@next=\pgfmathdivide@@% + \fi% + \fi% + \pgfmath@next% +} + +% advances the last digit found in the number. Any missing digits are +% supposed to be filled with 'C'. +\def\pgfmathdivide@advance@last@digit#1.#2#3#4#5#6#7\@@{% + \pgfmath@ya=\pgfmathresult pt % + \if#2C% + \pgfmath@xa=1pt % + \else + \if#3C% + \pgfmath@xa=0.1pt % + \else + \if#4C% + \pgfmath@xa=0.01pt % + \else + \if#5C% + \pgfmath@xa=0.001pt % + \else + \if#6C% + \pgfmath@xa=0.0001pt % + \else + \pgfmath@xa=0.00001pt % + \fi + \fi + \fi + \fi + \fi + \advance\pgfmath@ya by\pgfmath@xa + \edef\pgfmathresult{\pgfmath@tonumber@notrailingzero\pgfmath@ya}% +}% + +{ +\catcode`\p=12 +\catcode`\t=12 +\gdef\Pgf@geT@NO@TRAILING@ZERO#1.#2pt{% + #1.% + \ifnum#2=0 \else #2\fi +} +} +\def\pgfmath@tonumber@notrailingzero#1{\expandafter\Pgf@geT@NO@TRAILING@ZERO\the#1} diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex new file mode 100644 index 0000000..733cb47 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex @@ -0,0 +1,562 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Mi 9. Jul 15:41:39 CEST 2014 %%% + + + +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreexternal.code.tex,v 1.20 2013/07/15 12:05:31 tantau Exp $ + + + +\newif\ifpgfexternal@aux@in@dpth +\newif\ifpgfexternal@info + +\pgfkeys{ + /pgf/images/include external/.code={\pgfimage{#1}}, + /pgf/images/aux in dpth/.is if=pgfexternal@aux@in@dpth, + /pgf/images/aux in dpth/.default=true, + /pgf/images/trim external/.code n args={4}{% + \def\pgf@external@kern@left{#1}% + \def\pgf@external@kern@bottom{#2}% + \def\pgf@external@kern@right{#3}% + \def\pgf@external@kern@top{#4}% + \ifx\pgf@external@kern@left\pgfutil@empty\def\pgf@external@kern@left{0sp}\fi% + \ifx\pgf@external@kern@bottom\pgfutil@empty\def\pgf@external@kern@bottom{0sp}\fi% + \ifx\pgf@external@kern@right\pgfutil@empty\def\pgf@external@kern@right{0sp}\fi% + \ifx\pgf@external@kern@top\pgfutil@empty\def\pgf@external@kern@top{0sp}\fi% + }, + /pgf/images/trim external={1truein}{1truein}{1truein}{1truein}, + /pgf/images/external info/.is if=pgfexternal@info, + /pgf/images/external info/.default=true, +} + +% The external read/write mechanism is used as follows: +% +% In your document, you put a number or all of your pgfpicture (or +% tikzpicture) environments inside a pair of \beginpgfexternal and +% \endpgfexternal. The \beginpgfexternal gets one parameter called the +% graphics name. +% +% Once this is done, the next step is to declare the names of your +% graphics in the document at the beginning using the +% \pgfdeclaregraphicname command. +% +% Now, when you typeset your document, each time a \beginpgfexternal +% command is encountered, it will be checked whether the corresponding +% graphics file exists. If this is the case, it will be included and +% the code between \beginpgfexternal and \endpgfexternal is +% ignored. Otherwise, the code is executed normally. +% +% Things change when you run tex on your file with the \jobname set to +% the name of a decalred graphics name. In this case, only your +% graphic will be typeset, the rest of the document will be "thrown away". +% To be more precise, everything is gobbled up to the beginning +% of the first \beginpgfexternal with the given graphics name. Then, +% the content of the "environment" is put in a box (this "environment" +% need not contain a graphics, it may contain anything that can be put +% in a box). Then a single page is output whose size is exactly the +% size of the picture. +% +% So, once you have run tex repeatedly, each time with the jobname set +% to each of the graphics, you can then run tex on the whole document +% and this will cause all graphics to be included rather than begin +% typeset. +% +% Finally, once all the graphics have been created, you can also say +% \input pgfexternal.tex instead of including pgf/TikZ. + + +\newif\ifpgfexternalreadmainaux +\pgfexternalreadmainauxtrue + +% Tells pgf which jobname is the name of the real file +% +% #1 = name +% +% Description: +% +% This command is used to tell pgf that the file named #1 should be +% typeset normally. If \jobname is not equal to #1, only +% the graphic called \jobname will be typeset. +% +% Example: +% +% \pgfrealjobname{survey} +% +% Note that afterwards, \jobname will be set to the argument. In our +% example, \jobname will be 'survey'. This is to accomplish +% compatibility with aux-file generation. + +\def\pgfrealjobname#1{% + \global\let\pgfactualjobname=\jobname + \edef\pgf@tempa{\expandafter\string\csname #1\endcsname}% + \edef\pgf@tempb{\expandafter\string\csname\jobname\endcsname}% + \ifx\pgf@tempa\pgf@tempb% + \else% + \pgf@external@grabshipouttrue% + \pgfexternal@nofiles% see also \pgf@external@init@aux@in@dpth + \ifpgfexternalreadmainaux + % and reset the jobname. This should allow to handle any + % \label/\ref constructions which are stored in \jobname.aux (and + % which won't be found otherwise) + \gdef\jobname{#1}% + \fi + \ifpgfexternal@aux@in@dpth + \csname newwrite\endcsname\w@pgfexternal@auxout + \fi + \pgfexternal@geometry@compatibility + \fi% + \gdef\pgfrealjobname##1{}% avoid multiple calls. +} + +\def\pgfexternal@geometry@compatibility{% + % check if \usepackage{geometry} is loaded: + \pgfutil@ifundefined{geometry}{% + }{% + % The geometry package hooks into \begin{document}, evaluates + % its driver -- and generates \special instructions to set the + % paper size. + % + % Unfortunately, this confuses dvips utterly - and perhaps + % other drivers as well. + % + % Thus, if we currently about to generate some external + % graphics, we WANT to disable geometry (it has no purpose in + % this context anyway). + % + % This here works well: + \immediate\write16{Package TikZ externalization: calling \string\geometry{driver=none} during externalization.^^J}% + \geometry{driver=none}% + }% +}% + +\def\pgfexternal@nofiles{% + % replace \relax. The \nofiles macros does + % \let\makeglossary=\relax + % but the glossary.sty calls \renewcommand\makeglossary (which + % will fail if \makeglossary=\relax). Stupid, but it works. + \let\pgfexternal@nofiles@=\relax + \def\relax{\relax}% + % + % suppress generation of LaTeX .aux, .toc etc files. + % generation of these files is not thread-safe. + % the \csname \endcsname yields \relax if \nofiles doesn't exist. + \csname nofiles\endcsname + % + \let\relax=\pgfexternal@nofiles@ +}% + +\newif\ifpgf@external@grabshipout +\newbox\pgfexternal@startupbox + +\pgfutil@ifundefined{AtBeginDocument}{}{% + \AtBeginDocument{% + \ifpgf@external@grabshipout% + \global\let\pgfexternal@originalshipout=\shipout% + \global\def\shipout{\setbox\pgfpic=}% + \maxdeadcycles=10000% + % Ok, gather everything we have seen up to now in a box. This box + % will contain any specials that have been used. + {% + \output{\global\setbox\pgfexternal@startupbox=\vbox{\csname @begindvi\endcsname\unvbox255}}% + \hbox{}\eject% + }% + \fi% + } +}% + +\pgfutil@ifundefined{AtEndDocument}{}{% + \AtEndDocument{% + \ifpgf@external@grabshipout + \pgfutil@ifundefined{pgfexternal@did@a@shipout}{% + \pgfexternal@error@no@shipout + }{}% + \fi + }% +} + +% This will be overwritten by the tikz external lib if it is loaded. +\def\pgfexternal@error@no@shipout{% + \pgferror{Sorry, image externalization failed: the resulting image was EMPTY. I tried to externalize '\pgfactualjobname'. Perhaps there was a typo somewhere? Please check that your document contains '\string\beginpgfgraphicnamed{\pgfactualjobname} ... \string\endpgfgraphicnamed'}% +}% + + +% "Environment" for an external graphic. +% +% #1 = graphic name +% +% Example: +% +% \beginpgfgraphicnamed{main-graphic2} +% \begin{tikzpicture} +% ... +% \end{tikzpicture} +% \endpgfgraphicnamed + +\def\pgf@externalbegin#1{% + % First, check whether we wish to grab this graphic: + \let\pgf@next=\pgf@external@normal% + \ifpgf@external@grabshipout% + \edef\pgf@tempa{\expandafter\string\csname #1\endcsname}% + \edef\pgf@tempb{\expandafter\string\csname\pgfactualjobname\endcsname}% + \ifx\pgf@tempa\pgf@tempb% + \let\pgf@next=\pgf@external@grab% + \fi% + \fi% + \pgf@next{#1}% +} + + +\AtBeginDocument{ + \let\beginpgfgraphicnamed=\pgf@externalbegin% overwrite definition of pgfexternal.tex if necessary + \let\endpgfgraphicnamed=\unskip +} + + +% Normal operation: Include an external graphic instead of the +% picture, if such an external picture exists. +\def\pgf@external@normal#1{% + \let\pgf@filename=\pgfutil@empty% + \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#1}% + \ifx\pgf@filename\pgfutil@empty% + % Ok, no such image... Just typeset the picture normally. + \let\pgf@next=\relax% + \else% + \let\pgf@next=\pgf@replacepicturebygraphic% + \fi% + \pgf@next% +} + +\long\def\pgf@replacepicturebygraphic#1\endpgfgraphicnamed{% + \expandafter\pgfincludeexternalgraphics\expandafter{\pgf@filename}\unskip +} + +% This is almost the same as \includegraphics{#1}, but it checks +% whether '#1.dpth' exists. In such case, it restores the boxes depth +% stored in #1.dpth. +% +% Furthermore, the .dpth file may contain .aux related information +% collected for the external graphics (references). They start after +% the first line (if any). +\def\pgfincludeexternalgraphics#1{% + \begingroup + \pgfexternalreaddpth{#1}% + \pgfkeysifdefined{/pgf/images/include external/#1/.@cmd}{% + \pgfkeysgetvalue{/pgf/images/include external/#1/.@cmd}\pgf@tempa + \pgfkeyslet{/pgf/images/include external/.@cmd}\pgf@tempa + }{}% + \setbox1=\hbox{\pgfkeysvalueof{/pgf/images/include external/.@cmd}{#1}\pgfeov}% + \ifdim\pgfexternaltrimleft=0sp \else \kern\pgfexternaltrimleft\relax \fi + \ifdim\pgfexternaldepth=0pt + \box1 + \else + \dimen0=\pgfexternaldepth\relax + \hbox{\lower\dimen0 \box1 }% + \fi + \ifdim\pgfexternaltrimright=0sp \else \kern\pgfexternaltrimright\relax \fi + \endgroup +} + +% Reads the .dpth file which contains meta data of the external +% picture. +% +% This command handles the following stuff: +% - it defines \pgfexternaldepth . The macro contains the contents of +% a line which does not start with a control sequence (for example a +% line containing '50pt') +% - it defines \pgfexternaltrimleft and \pgfexternaltrimright +% - it checks if the .dpth file contains content stored by means of +% \pgfexternalstorecommand. If so, the argument of +% \pgfexternalstorecommand will be restored. +% - anything else will be appended to the main .aux file, assuming that +% it contains \label or \ref information (only if the LaTeX switch +% \if@filesw is \iftrue). +% +% +% #1: the image file name (such that #1.dpth exists) +\def\pgfexternalreaddpth#1{% + % no \begingroup. Handle that manually: + \edef\pgfexternalreaddpth@restore{% + \noexpand\endlinechar=\the\endlinechar\space + \noexpand\catcode`\noexpand\@=\the\catcode`\@\space + }% + % + \def\pgfexternaldepth{0sp}% + \def\pgfexternaltrimleft{0sp}% + \def\pgfexternaltrimright{0sp}% + \endlinechar=-1 % suppress white space at end + \catcode`\@=11 + \openin\r@pgf@reada=#1.dpth + \pgfincludeexternalgraphics@read@dpth + % + \pgfexternalreaddpth@restore +}% +% +% The .dpth consists of 0-N lines, where each is either a single +% dimension (the box' depth) or something which belongs to the .aux +% file (such lines will always start with a macro). +\def\pgfincludeexternalgraphics@read@dpth{% + \ifeof\r@pgf@reada + \closein\r@pgf@reada + \else + \read\r@pgf@reada to\pgfincludeexternalgraphics@auxline + \ifx\pgfincludeexternalgraphics@auxline\pgfutil@empty + \else + \expandafter\pgfincludeexternalgraphics@read@dpth@line\pgfincludeexternalgraphics@auxline\pgfincludeexternalgraphics@read@dpth@line@EOI + \fi + \expandafter\pgfincludeexternalgraphics@read@dpth + \fi +}% + +\def\pgfexternal@restore#1{#1}% + +\long\def\pgfincludeexternalgraphics@read@dpth@line@getfirst#1#2\pgfincludeexternalgraphics@read@dpth@line@EOI{% + \def\pgf@first{#1}% +}% +\long\def\pgfincludeexternalgraphics@read@dpth@line#1\pgfincludeexternalgraphics@read@dpth@line@EOI{% + \pgfincludeexternalgraphics@read@dpth@line@getfirst#1\pgfincludeexternalgraphics@read@dpth@line@EOI + \expandafter\ifcat\expandafter\noexpand\pgf@first\relax + % Ah -- the first token is a control sequence. It belongs to + % the .aux file. + % + \expandafter\ifx\pgf@first\pgfexternal@restore + % if the first line in the .dpth file starts with the + % magic string \pgfexternal@restore, the complete line + % will be executed as-is. Example: + % \pgfexternal@restore{\def\somevalue{1}} + #1% + \else + % do NOT execute #1! many LaTeX commands don't support it (\label for example) + \pgfutil@ifundefined{if@filesw}{% + % sorry, .aux file support only for latex + }{% + % append to main .aux file (for forward references) + \if@filesw + {% + \toks0={#1}% + % believe it or not, but the + % \def\dpthimport{...}\dpthimport *makes* a + % difference! In ensures any occuring `##' characters are properly expanded to `#'. + \immediate\write\@auxout{% + \noexpand\def\noexpand\dpthimport{\the\toks0}\noexpand\dpthimport}% + }% + \fi + }% + \fi + \else% it is the depth (which is simply a number for backwards compatibility) + \def\pgfexternaldepth{#1}% + \fi +}% + +% Stores '#1' (expanded!) into the .dpth file of the currently +% exported image. +% +% This command has only an effect if an image is being exported. +% +% The stored contents will be read in the context where +% /pgf/images/include external is active (i.e. by +% \pgfexternalreaddpth). +% +\def\pgfexternalstorecommand#1{% +}% +\def\pgfexternalstorecommand@isexporting#1{% + \immediate\write\w@pgfexternal@auxout{\noexpand\pgfexternal@restore{#1}}% +}% + + + +% Grab operation: If jobname matches the graphic name, typeset this +% picture normall. +% REMARK: +% this method is also invoked from within the tikz external library. +\def\pgf@external@grab#1{% + \def\pgf@filename{#1}% + \ifpgfexternal@aux@in@dpth + \begingroup + \pgf@external@init@aux@in@dpth + \let\G@refundefinedtrue=\pgf@external@grab@refundefinedtrue + \fi + \gdef\pgf@trimleft@final{0sp}% + \gdef\pgf@trimright@final{0sp}% + \setbox\pgfpic=\hbox\bgroup\bgroup% + \let\endpgfgraphicnamed=\pgf@externalend% +} + +{\catcode`\^=12 \gdef\pgfexternal@hat{^}} + +\expandafter\let\expandafter\pgf@external@grab@refundefinedtrue@orig\csname G@refundefinedtrue\endcsname + +\def\pgf@external@grab@refundefinedtrue{% + \pgf@external@grab@refundefinedtrue@orig + \begingroup + \def\n{\pgfexternal@hat\pgfexternal@hat J}% + \pgfexternalstorecommand{% + \noexpand\immediate\noexpand\write16{\pgf@external@grab@refundefinedtrue@warning}% + \noexpand\G@refundefinedtrue + }% + \endgroup +}% +\def\pgf@external@grab@refundefinedtrue@warning{% + LaTeX Warning: External picture `\pgfactualjobname' contains undefined references\noexpand\on@line.\n +}% + +\let\pgf@external@@protected@write@orig=\protected@write +\long\def\pgf@external@@protected@write@immediate#1#2#3{% + \begingroup + \let\pgf@write@=\write + \def\write{\noexpand\immediate\pgf@write@}% + \pgf@external@@protected@write@orig{#1}{#2}{#3}% + \endgroup +}% + +\def\pgf@external@init@aux@in@dpth{% + \let\pgfexternalstorecommand=\pgfexternalstorecommand@isexporting + % + % tell LaTeX to write aux files... + \csname @fileswtrue\endcsname + % ... but redirect output to the .dpth file! + \immediate\openout\w@pgfexternal@auxout=\pgf@filename.dpth + \let\@auxout=\w@pgfexternal@auxout + % ... and disable the correct page numbers. I can't get that + % (because the correct page number is only available in the + % shipout routine). Use immediate output: + \let\protected@write=\pgf@external@@protected@write@immediate +}% + +\def\pgf@externalend@storeshifts#1{% + \immediate\write#1{\the\dp\pgfpic}% store the depth simply as number for backw. compat. + \ifx\pgf@trimleft@final\pgfutil@empty\else + \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimleft{\pgf@trimleft@final}}}% + \fi + \ifx\pgf@trimright@final\pgfutil@empty\else + \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimright{\pgf@trimright@final}}}% + \fi + \ifpgfexternal@info + \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalwidth{\the\wd\pgfpic}}}% + \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalheight{\the\dimen0}}}% + \fi +} +% REMARK: +% this method is also invoked from within the tikz external library. +\def\pgf@externalend{% + \unskip\egroup\egroup% + {% + \def\pgf@external@trim{0}% + \def\pgf@external@store@dpth{0}% + % + \ifpgf@trim@lowlevel + \gdef\pgf@trimleft@final{}% + \gdef\pgf@trimright@final{}% + \else + \ifdim\pgf@trimleft@final=0sp \gdef\pgf@trimleft@final{} \else\def\pgf@external@trim{1}\fi + \ifdim\pgf@trimright@final=0sp \gdef\pgf@trimright@final{} \else\def\pgf@external@trim{1}\fi + \if1\pgf@external@trim + % UNDO the trimming! export to pdf doesn't supported trimmed + % bounding boxes (has to do with the mediabox/trimbox etc). + % I'll keep the bounding box intact and store the trim information + % into the .dpth file. + \setbox\pgfpic=\hbox{% + \ifx\pgf@trimleft@final\pgfutil@empty\else\kern-\pgf@trimleft@final\fi + \box\pgfpic + \ifx\pgf@trimright@final\pgfutil@empty\else\kern-\pgf@trimright@final\fi + }% + \def\pgf@external@store@dpth{1}% + \fi + \fi + % + \parindent0pt % leave the space +% \leftmargin0pt% +% \rightmargin0pt% + \hoffset=0pt % reset to default + \voffset=0pt + \dimen0\ht\pgfpic% + \advance\dimen0\dp\pgfpic% + \ifdim\dp\pgfpic=0pt\relax + \else% store the picture's depth. Otherwise, it would be lost. + \def\pgf@external@store@dpth{1}% + \fi + \ifpgfexternal@info + \def\pgf@external@store@dpth{1}% + \fi + % + \if1\pgf@external@store@dpth + \ifpgfexternal@aux@in@dpth + \pgf@externalend@storeshifts\@auxout + \immediate\closeout\@auxout + \else + \immediate\openout\pgf@plotwrite=\pgf@filename.dpth + \pgf@externalend@storeshifts\pgf@plotwrite + \immediate\closeout\pgf@plotwrite + \fi + \fi + \pgfsys@prepare@papersize{\the\wd\pgfpic}{\the\dimen0}% + % + \setbox0=\vbox{% + % I admit that I don't know why there is this kerning: + \kern -\pgf@external@kern@top\relax% + \hbox{% + \kern -\pgf@external@kern@left\relax% + \hbox to0pt{% + \wd\pgfexternal@startupbox=0pt % + \ht\pgfexternal@startupbox=0pt % + \dp\pgfexternal@startupbox=0pt % + \box\pgfexternal@startupbox% + \pgfsys@atbegindocument\hss}% + \box\pgfpic% + \kern\pgf@external@kern@right\relax% + }% + \kern\pgf@external@kern@bottom\relax% + }% + % + % compatibility with eso-pic package: \nointerlineskip is not + % allowed here, but the eso-pic package uses \nointerlineskip in + % its shipout routine. + \let\pgfexternal@nointerlineskip@orig=\nointerlineskip + \let\nointerlineskip=\pgfexternal@nointerlineskip + % + \pgfexternal@originalshipout\box0 % + \gdef\pgfexternal@did@a@shipout{1}% + }% + \ifpgfexternal@aux@in@dpth + \endgroup + \fi +} + +\def\pgfexternal@nointerlineskip{% + \ifvmode + \pgfexternal@nointerlineskip@orig + \else + \relax% \nointerlineskip in horizontal mode not allowed. Silently ignore the error message. + \fi +}% + +\endinput +% vi: tabstop=4 shiftwidth=2 expandtab diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreimage.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreimage.code.tex new file mode 100644 index 0000000..f352550 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreimage.code.tex @@ -0,0 +1,585 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Mon Mar 22 16:42:03 CET 2010 %%% + + + +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreimage.code.tex,v 1.14 2010/03/19 09:50:32 ludewich Exp $ + + + +% Declare an image +% +% #1 = optional argument: width, height, page specification +% #2 = name of the image for later use +% #4 = filename without extension, automatic extensions are .pdf, +% .jpg, and .png for PDF and .ps, .eps, .epsi for postscript. +% +% Description: +% +% This command declares an image file for later use. Even if the image +% is used several times in the document, in PDF it will only be stored +% once. +% +% Example: +% +% \pgfdeclareimage[width=2cm,page=2]{myimage}{imagefilename} + +\def\pgfdeclareimage{\pgfutil@ifnextchar[{\pgf@declareimage}{\pgf@declareimage[]}} +\def\pgf@declareimage[#1]#2#3{% + \pgfqkeys{/pgf/images}{height=,width=,page=,interpolate=false,mask=,#1}% + % Try to find the file + \gdef\pgf@filename{}% + % If page= parameter is not empty, try that file first: + \ifx\pgf@imagepage\pgfutil@empty% + \else% + \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3.page\pgf@imagepage}% + \fi% + \ifx\pgf@filename\pgfutil@empty% + \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3}% + \else% + \pgfkeys{/pgf/images/page=}% make page empty + \fi% + \ifx\pgf@filename\pgfutil@empty% + \PackageWarning{pgf}% + {File "#3" not found when defining image "#2".\MessageBreak + Tried all extensions in "\pgfsys@imagesuffixlist"}% + \pgf@declaredraftimage{#2}{#3}% + \else% + \ifpgf@draftmode% + \pgf@declaredraftimage{#2}{#3}% + \else% + \pgfsys@defineimage% + \fi% + \fi% + \expandafter\global\expandafter\let\csname pgf@image@#2!\endcsname=\pgf@image% +} + +\newif\ifpgfexternal@allow@aux + +\pgfkeys{ + /pgf/images/include external/.code={\pgfimage{#1}}, + /pgf/images/aux in dpth/.is if=pgfexternal@allow@aux, + /pgf/images/aux in dpth/.default=true, + /pgf/images/draft/.is if=pgf@draftmode, + /pgf/images/draft/.default=true} +\pgfkeys{/pgf/images/width/.estore in=\pgf@imagewidth} +\pgfkeys{/pgf/images/height/.estore in=\pgf@imageheight} +\pgfkeys{/pgf/images/page/.estore in=\pgf@imagepage} +\pgfkeys{/pgf/images/interpolate/.cd,.code=\edef\pgf@imageinterpolate{#1},.default=true} +\pgfkeys{/pgf/images/mask/.code=% + {% + \edef\pgf@imagemask{#1}% + \ifx\pgf@imagemask\pgfutil@empty% + \else% + \pgfutil@ifundefined{pgf@mask@#1}% + {\PackageError{pgf}{Undefined mask "#1".}{}% + \edef\pgf@imagemask{}}% + {\edef\pgf@imagemask{\csname pgf@mask@#1\endcsname}% + }% + \fi% + }} + + +\def\pgf@findfile#1:#2+#3{% + \pgfutil@IfFileExists{#3#1}% + {\xdef\pgf@filename{#3#1}}% + {\def\pgf@mightbeempty{#2}% + \ifx\pgf@mightbeempty\pgfutil@empty\else% + \pgf@findfile#2+{#3}% + \fi}} + +% #1: image name +% #2: file name +\def\pgf@declaredraftimage#1#2{% + \ifx\pgf@imagewidth\pgfutil@empty% + \PackageWarning{pgf}{Missing width for image "#1" ("#2") in draft mode.\MessageBreak Using 1cm instead}% + \edef\pgf@imagewidth{1cm}% + \fi% + \ifx\pgf@imageheight\pgfutil@empty% + \PackageWarning{pgf}{Missing height for image "#1" ("#2") in draft mode.\MessageBreak Using 1cm instead}% + \edef\pgf@imageheight{1cm}% + \fi% + \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepagetext{ page \pgf@imagepage}\fi% + \edef\pgf@image{% + \hbox to \pgf@imagewidth{% + \vrule\kern-0.4pt% + \vbox to \pgf@imageheight{% + \hrule\vfil% + \hbox to \pgf@imagewidth{\hskip-10cm\hfil\noexpand\tiny#2\pgf@imagepage\hfil\hskip-10cm}% + \vfil\hrule}% + \kern-0.4pt\vrule}% + }% +} + + + +% Declare a soft mask +% +% #1 = optional argument: matte specification. default matte is +% white. +% #2 = name of the mask for later use +% #3 = filename without extension, automatic extensions are .pdf, +% .jpg, and .png for PDF. Postscript is not supported. +% +% Description: +% +% This command declares a soft mask for later masking an image. The +% declared mask should be used together with an image of exactly the +% same height/width if matte is defined. Matte should be the +% preblended background color (see pdf spec for details). +% +% Example: +% +% \pgfdeclaremask[matte=white]{maskname}{maskfilename} +% \pgfdeclareimage[mask=maskname]{image}{imagefilename} + +\def\pgfdeclaremask{\pgfutil@ifnextchar[\pgf@declaremask{\pgf@declaremask[]}} +\def\pgf@declaremask[#1]#2#3{% + \pgfqkeys{/pgf/images/mask}{matte={1 1 1},#1}% defaults + \def\pgf@mask{}% + % Try to find the file + \gdef\pgf@filename{}% + \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3}% + \ifx\pgf@filename\pgfutil@empty% + \PackageWarning{pgf}% + {File "#3" not found when defining mask "#2".\MessageBreak + Tried all extensions in "\pgfsys@imagesuffixlist"}% + \else% + \pgfsys@definemask{#2}% + \fi% + \expandafter\global\expandafter\let\csname pgf@mask@#2\endcsname=\pgf@mask% +} + +\pgfkeys{/pgf/images/mask/matte/.cd,.estore in=\pgf@maskmatte,.value required} + + + +% Create an alias name for an image +% +% #1 = name of the alias +% #2 = name of the original +% +% Example: +% +% \pgfdeclareimage{image}{1cm}{1cm}{filename +% \pgfaliasimage{alias}{image} +% \pgfuseimage{alias} + +\def\pgfaliasimage#1#2{% + \expandafter\global\expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@image@#2!\endcsname% + \expandafter\global\expandafter\let\csname pgf@image@#1!\endcsname=\pgf@temp% + } + + +% Use an image +% +% #1 = name of a previously declared image +% +% Example: +% +% \pgfputat{\pgforigin}{\pgfbox[left,base]{\pgfuseimage{myimage}}} + +\def\pgfuseimage#1{% + \def\pgf@imagename{pgf@image@#1}% + \pgf@tryextensions{\pgf@imagename}{\pgfalternateextension}% + \expandafter\pgfutil@ifundefined\expandafter{\pgf@imagename}% + {\PackageError{pgf}{Undefined image "#1"}{}}% + {{\leavevmode\csname\pgf@imagename\endcsname}}} + +\def\pgf@tryextensions#1#2{% + \edef\pgf@args{[#2!]}\expandafter\pgf@@tryextensions\pgf@args{#1}} +\def\pgf@@tryextensions[#1!#2]#3{% + \expandafter\pgfutil@ifundefined\expandafter{#3#1!#2}% + {\def\pgf@temp{#2}% + \ifx\pgf@temp\pgfutil@empty% + \edef#3{#3!}% + \else% + \pgf@@tryextensions[#2]{#3}% + \fi}% + {\edef#3{#3#1!#2}}} + + +% Alternate image +% +% Description: +% +% When an image is used, pgf first attempts to use the image with the +% alternate extension added. If this fails, the original image is +% used. If the alternate extension contains ``!'', then the text up to +% the ! is successively removed and the remainder is tried as an +% alternate extension. +% +% Example: +% +% \def\pgfalternateextension{20!white} + +\def\pgfalternateextension{} + + + +% Directly insert an image +% +% #1 = optional argument: width, height, page specification +% #2 = file name +% +% Description: +% +% Directly inserts an image without declaration. You can, however, +% still access this image using the name pgflastimage. By using +% pgfaliasimage, you can also save this image for later. +% +% Example: +% +% \pgfimage[height=2cm]{filename} + +\def\pgfimage{\pgfutil@ifnextchar[\pgf@imagecom{\pgf@imagecom[]}} +\def\pgf@imagecom[#1]#2{% + \pgfdeclareimage[#1]{pgflastimage}{#2}% + \pgfuseimage{pgflastimage}} + + + + + + + + +% The external read/write mechanism is used as follows: +% +% In your document, you put a number or all of your pgfpicture (or +% tikzpicture) environments inside a pair of \beginpgfexternal and +% \endpgfexternal. The \beginpgfexternal gets one parameter called the +% graphics name. +% +% Once this is done, the next step is to declare the names of your +% graphics in the document at the beginning using the +% \pgfdeclaregraphicname command. +% +% Now, when you typeset your document, each time a \beginpgfexternal +% command is encountered, it will be checked whether the corresponding +% graphics file exists. If this is the case, it will be included and +% the code between \beginpgfexternal and \endpgfexternal is +% ignored. Otherwise, the code is executed normally. +% +% Things change when you run tex on your file with the \jobname set to +% the name of a decalred graphics name. In this case, only your +% graphic will be typeset, the rest of the document will be "thrown away". +% To be more precise, everything is gobbled up to the beginning +% of the first \beginpgfexternal with the given graphics name. Then, +% the content of the "environment" is put in a box (this "environment" +% need not contain a graphics, it may contain anything that can be put +% in a box). Then a single page is output whose size is exactly the +% size of the picture. +% +% So, once you have run tex repeatedly, each time with the jobname set +% to each of the graphics, you can then run tex on the whole document +% and this will cause all graphics to be included rather than begin +% typeset. +% +% Finally, once all the graphics have been created, you can also say +% \input pgfexternal.tex instead of including pgf/TikZ. + + +\newif\ifpgfexternalreadmainaux +\pgfexternalreadmainauxtrue + +% Tells pgf which jobname is the name of the real file +% +% #1 = name +% +% Description: +% +% This command is used to tell pgf that the file named #1 should be +% typeset normally. If \jobname is not equal to #1, only +% the graphic called \jobname will be typeset. +% +% Example: +% +% \pgfrealjobname{survey} +% +% Note that afterwards, \jobname will be set to the argument. In our +% example, \jobname will be 'survey'. This is to accomplish +% compatibility with aux-file generation. + +\def\pgfrealjobname#1{% + \global\let\pgfactualjobname=\jobname + \edef\pgf@tempa{\expandafter\string\csname #1\endcsname}% + \edef\pgf@tempb{\expandafter\string\csname\jobname\endcsname}% + \ifx\pgf@tempa\pgf@tempb% + \else% + \pgf@external@grabshipouttrue% + \pgfexternal@nofiles + \ifpgfexternalreadmainaux + % and reset the jobname. This should allow to handle any + % \label/\ref constructions which are stored in \jobname.aux (and + % which won't be found otherwise) + \gdef\jobname{#1}% + \fi + \ifpgfexternal@allow@aux + \csname newwrite\endcsname\w@pgfexternal@auxout + \fi + \fi% + \gdef\pgfrealjobname##1{}% avoid multiple calls. +} + +\def\pgfexternal@nofiles{% + % replace \relax. The \nofiles macros does + % \let\makeglossary=\relax + % but the glossary.sty calls \renewcommand\makeglossary (which + % will fail if \makeglossary=\relax). Stupid, but it works. + \let\pgfexternal@nofiles@=\relax + \def\relax{\relax}% + % + % suppress generation of LaTeX .aux, .toc etc files. + % generation of these files is not thread-safe. + % the \csname \endcsname yields \relax if \nofiles doesn't exist. + \csname nofiles\endcsname + % + \let\relax=\pgfexternal@nofiles@ +}% + +\newif\ifpgf@external@grabshipout +\newbox\pgfexternal@startupbox + +\AtBeginDocument{% + \ifpgf@external@grabshipout% + \global\let\pgfexternal@originalshipout=\shipout% + \global\def\shipout{\setbox\pgfpic=}% + \maxdeadcycles=10000% + % Ok, gather everything we have seen up to now in a box. This box + % will contain any specials that have been used. + {% + \output{\global\setbox\pgfexternal@startupbox=\vbox{\csname @begindvi\endcsname\unvbox255}}% + \hbox{}\eject% + }% + \fi% +} + + +% "Environment" for an external graphic. +% +% #1 = graphic name +% +% Example: +% +% \beginpgfgraphicnamed{main-graphic2} +% \begin{tikzpicture} +% ... +% \end{tikzpicture} +% \endpgfgraphicnamed + +\def\pgf@externalbegin#1{% + % First, check whether we wish to grab this graphic: + \let\pgf@next=\pgf@external@normal% + \ifpgf@external@grabshipout% + \edef\pgf@tempa{\expandafter\string\csname #1\endcsname}% + \edef\pgf@tempb{\expandafter\string\csname\pgfactualjobname\endcsname}% + \ifx\pgf@tempa\pgf@tempb% + \let\pgf@next=\pgf@external@grab% + \fi% + \fi% + \pgf@next{#1}% +} + + +\AtBeginDocument{ + \let\beginpgfgraphicnamed=\pgf@externalbegin% overwrite definition of pgfexternal.tex if necessary + \let\endpgfgraphicnamed=\unskip +} + + +% Normal operation: Include an external graphic instead of the +% picture, if such an external picture exists. +\def\pgf@external@normal#1{% + \let\pgf@filename=\pgfutil@empty% + \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#1}% + \ifx\pgf@filename\pgfutil@empty% + % Ok, no such image... Just typeset the picture normally. + \let\pgf@next=\relax% + \else% + \let\pgf@next=\pgf@replacepicturebygraphic% + \fi% + \pgf@next% +} + +\long\def\pgf@replacepicturebygraphic#1\endpgfgraphicnamed{% + \expandafter\pgfincludeexternalgraphics\expandafter{\pgf@filename}\unskip +} + +% This is almost the same as \includegraphics{#1}, but it checks +% whether '#1.dpth' exists. In such case, it restores the boxes depth +% stored in #1.dpth. +% +% Furthermore, the .dpth file may contain .aux related information +% collected for the external graphics (references). They start after +% the first line (if any). +\def\pgfincludeexternalgraphics#1{% + \begingroup + \setbox1=\hbox{\pgfkeysvalueof{/pgf/images/include external/.@cmd}{#1}\pgfeov}% + % + \let\pgfincludeexternalgraphics@dp=\pgfutil@empty + \endlinechar=-1 % suppress white space at end + \catcode`\@=11 + \openin\r@pgf@reada=#1.dpth + \pgfincludeexternalgraphics@read@dpth + \ifx\pgfincludeexternalgraphics@dp\pgfutil@empty + \box1 + \else + \dimen0=\pgfincludeexternalgraphics@dp\relax + \hbox{\lower\dimen0 \box1 }% + \fi + \endgroup +} +% +% The .dpth consists of 0-N lines, where each is either a single +% dimension (the box' depth) or something which belongs to the .aux +% file (such lines will always start with a macro). +\def\pgfincludeexternalgraphics@read@dpth{% + \ifeof\r@pgf@reada + \closein\r@pgf@reada + \else + \read\r@pgf@reada to\pgfincludeexternalgraphics@auxline + \ifx\pgfincludeexternalgraphics@auxline\pgfutil@empty + \else + \expandafter\pgfincludeexternalgraphics@read@dpth@line\pgfincludeexternalgraphics@auxline\pgfincludeexternalgraphics@read@dpth@line@EOI + \fi + \expandafter\pgfincludeexternalgraphics@read@dpth + \fi +}% +\long\def\pgfincludeexternalgraphics@read@dpth@line#1#2\pgfincludeexternalgraphics@read@dpth@line@EOI{% + \ifcat\noexpand#1\relax + % Ah -- the first token is a control sequence. It belongs to + % the .aux file. + % + % #1#2\relax% do NOT set the information! many LaTeX commands don't support it (\label for example) + \pgfutil@ifundefined{if@filesw}{% + % sorry, .aux file support only for latex + }{% + % append to main .aux file (for forward references) + \if@filesw + {% + \toks0={#1#2}% + % believe it or not, but the + % \def\dpthimport{...}\dpthimport *makes* a + % difference! In ensures any occuring `##' characters + % are properly expanded to `#'. + \immediate\write\@auxout{\noexpand\def\noexpand\dpthimport{\the\toks0 }\noexpand\dpthimport }% + }% + \fi + }% + \else + \def\pgfincludeexternalgraphics@dp{#1#2}% + \fi +}% + + + +% Grab operation: If jobname matches the graphic name, typeset this +% picture normall. +% REMARK: +% this method is also invoked from within the tikz external library. +\def\pgf@external@grab#1{% + \def\pgf@filename{#1}% + \ifpgfexternal@allow@aux + \begingroup + \pgf@external@init@aux@in@dpth + \fi + \setbox\pgfpic=\hbox\bgroup\bgroup% + \let\endpgfgraphicnamed=\pgf@externalend% +} + +\let\pgf@external@@protected@write@orig=\protected@write +\long\def\pgf@external@@protected@write@immediate#1#2#3{% + \begingroup + \let\pgf@write@=\write + \def\write{\noexpand\immediate\pgf@write@}% + \pgf@external@@protected@write@orig{#1}{#2}{#3}% + \endgroup +}% + +\def\pgf@external@init@aux@in@dpth{% + % tell LaTeX to write aux files... + \csname @fileswtrue\endcsname + % ... but redirect output to the .dpth file! + \immediate\openout\w@pgfexternal@auxout=\pgf@filename.dpth + \let\@auxout=\w@pgfexternal@auxout + % ... and disable the correct page numbers. I can't get that + % (because the correct page number is only available in the + % shipout routine). Use immediate output: + \let\protected@write=\pgf@external@@protected@write@immediate +}% + +% REMARK: +% this method is also invoked from within the tikz external library. +\def\pgf@externalend{% + \unskip\egroup\egroup% + {% + \parindent0pt % leave the space +% \leftmargin0pt% +% \rightmargin0pt% + \dimen0\ht\pgfpic% + \advance\dimen0\dp\pgfpic% + \ifdim\dp\pgfpic=0pt\relax + \else% store the picture's depth. Otherwise, it would be lost. + \ifpgfexternal@allow@aux + \immediate\write\@auxout{\the\dp\pgfpic}% + \immediate\closeout\@auxout + \else + \immediate\openout\pgf@plotwrite=\pgf@filename.dpth + \immediate\write\pgf@plotwrite{\the\dp\pgfpic}% + \immediate\closeout\pgf@plotwrite + \fi + \fi + \pgfsys@papersize{\the\wd\pgfpic}{\the\dimen0}% + \setbox0=\vbox{% + \kern -1truein % + \hbox{% + \kern -1truein % + \hbox to0pt{% + \wd\pgfexternal@startupbox=0pt % + \ht\pgfexternal@startupbox=0pt % + \dp\pgfexternal@startupbox=0pt % + \box\pgfexternal@startupbox% + \pgfsys@atbegindocument\hss}% + \box\pgfpic% + \kern 1truein }% + \kern1truein }% + \pgfexternal@originalshipout\box0 % + }% + \ifpgfexternal@allow@aux + \endgroup + \fi +} + + +\endinput + diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcorelayers.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcorelayers.code.tex new file mode 100644 index 0000000..7665a76 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcorelayers.code.tex @@ -0,0 +1,217 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%% + + + +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorelayers.code.tex,v 1.5 2012/11/07 19:23:16 ludewich Exp $ + + +% Creates a new pgf layer +% +% #1 = layer name +% +% Declares a new layer for pgf. +% +% Example: +% +% \pgfdeclarelayer{background} + +\def\pgfdeclarelayer#1{% + \pgfutil@ifundefined{pgf@layerbox@#1}{% + \expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerbox@#1\endcsname% + \expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerboxsaved@#1\endcsname% + }{}% +} +\let\pgf@newbox=\newbox % avoid plain TeX outer problem + +% Sets the layers that compose the picture +% +% #1 = List of layers +% +% Description: +% +% Sets the list of layers that make up the picture. The layers will be +% put on top of each other in the order given. +% +% This command can also be given inside of a picture in which case it +% applies only to that very picture. +% +% Example: +% +% \pgfsetlayers{background,main} + +\def\pgfsetlayers#1{\edef\pgf@layerlist{#1}} +\pgfsetlayers{main} + +% Adds code to a layer +% +% #1 = layer name +% +% Note: +% +% You cannot add anything to the ``main'' layer using this command. +% +% Example: +% +% \begin{pgfonlayer}{background} +% \fill[red] (0,0) -- (1,1); +% \end{pgfonlayer} + +\def\pgfonlayer@name{main} + +\def\pgfonlayer#1{% + \pgfutil@ifundefined{pgf@layerbox@#1}{% + \PackageError{pgf}{Sorry, the requested layer '#1' could not be found. Maybe you misspelled it?}{}% + \bgroup + \begingroup + }{% + \begingroup + \edef\pgf@temp{#1}% + \ifx\pgf@temp\pgfonlayer@name + % we are already on this layer. + \def\pgf@temp{% + \bgroup + \begingroup + }% + \else + \let\pgfonlayer@name=\pgf@temp + \pgfonlayer@assert@is@active + \def\pgf@temp{% + \expandafter\global\expandafter% + \setbox\csname pgf@layerbox@#1\endcsname=\hbox to 0pt% + \bgroup% + \expandafter\box\csname pgf@layerbox@#1\endcsname% + \begingroup% + }% + \fi + \pgf@temp + }% +} +\def\endpgfonlayer{% + \endgroup% + \hss + \egroup% + \endgroup +} + +\let\startpgfonlayer=\pgfonlayer +\let\stoppgfonlayer=\endpgfonlayer + +\def\pgfdiscardlayername{discard} + +\def\pgfonlayer@assert@is@active{% + \ifx\pgfonlayer@name\pgfdiscardlayername + % this special layer name can be used as /dev/null without + % warning. + \else + \begingroup + \def\pgfonlayer@isactive{0}% + \expandafter\pgf@assert@layer@is@active@loop\pgf@layerlist,,\relax% + \if0\pgfonlayer@isactive + \pgfonlayer@assert@fail + \fi + \endgroup + \fi +}% +\def\pgfonlayer@assert@fail{% + \PackageError{pgf}{Sorry, the requested layer '\pgfonlayer@name' is not + part of the layer list. Please verify that you provided + \string\pgfsetlayers\space and that '\pgfonlayer@name' is part of this list}{}% +}% +\def\pgf@assert@layer@is@active@loop#1,#2,\relax{% + \edef\pgf@test{#1}% + \ifx\pgf@test\pgfonlayer@name + \def\pgfonlayer@isactive{1}% + \else + \def\pgf@test{#2}% + \ifx\pgf@test\pgfutil@empty% + \else% + \pgf@assert@layer@is@active@loop#2,\relax% + \fi% + \fi +} + +% Hooks into the scoping: + +\def\pgf@insertlayers{% + \expandafter\pgf@dolayer\pgf@layerlist,,\relax% +} +\def\pgf@maintext{main}% +\def\pgf@dolayer#1,#2,\relax{% + \def\pgf@test{#1}% + \ifx\pgf@test\pgf@maintext% + \box\pgf@layerbox@main% + \else% + \pgfsys@beginscope% + \expandafter\box\csname pgf@layerbox@#1\endcsname% + \pgfsys@endscope% + \fi% + \def\pgf@test{#2}% + \ifx\pgf@test\pgfutil@empty% + \else% + \pgf@dolayer#2,\relax% + \fi% +} + +\def\pgf@savelayers{% + \expandafter\pgf@dosavelayer\pgf@layerlist,,\relax% +} +\def\pgf@dosavelayer#1,#2,\relax{% + \def\pgf@test{#1}% + \ifx\pgf@test\pgf@maintext% + \else% + \setbox\csname pgf@layerboxsaved@#1\endcsname=\box\csname pgf@layerbox@#1\endcsname% + \fi% + \def\pgf@test{#2}% + \ifx\pgf@test\pgfutil@empty% + \else% + \pgf@dosavelayer#2,\relax% + \fi% +} + +\def\pgf@restorelayers{% + \expandafter\pgf@dorestorelayer\pgf@layerlist,,\relax% +} +\def\pgf@dorestorelayer#1,#2,\relax{% + \def\pgf@test{#1}% + \ifx\pgf@test\pgf@maintext% + \else% + \global\setbox\csname pgf@layerbox@#1\endcsname=\box\csname pgf@layerboxsaved@#1\endcsname% + \fi% + \def\pgf@test{#2}% + \ifx\pgf@test\pgfutil@empty% + \else% + \pgf@dorestorelayer#2,\relax% + \fi% +} + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcorescopes.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcorescopes.code.tex new file mode 100644 index 0000000..69ef0d9 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcorescopes.code.tex @@ -0,0 +1,607 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%% + + + +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorescopes.code.tex,v 1.38 2012/11/30 12:00:51 tantau Exp $ + +% Globals + +\newbox\pgfpic +\newbox\pgf@hbox + +\newbox\pgf@layerbox@main + +\newcount\pgf@picture@serial@count + + + +% This if decides whether the position of pictures on the page is +% protocolled or not. Normally, +% this is switched off as it works only with certain drivers and it +% causes external files to be written. When switched on, the position +% of pgfpictures are protocolled and can be referenced using +% \pgfsys@getposition{XXX} where XXX is the value of \pgfpictureid +% inside the picture. +\newif\ifpgfrememberpicturepositiononpage + + + + +% Scopes + + +% Pgf scope environment. All changes of the graphic state are local to +% the scope. +% +% Example: +% +% \begin{pgfscope} +% \pgfsetlinewidth{3pt} +% \pgfline{\pgfxy(0,0)}{\pgfxy(3,3)} +% \end{pgfscope} + +\def\pgfscope{% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \pgfsys@beginscope% + \pgf@resetpathsizes% + \edef\pgfscope@linewidth{\the\pgflinewidth}% + \begingroup} +\def\endpgfscope{% + \endgroup% + \global\pgflinewidth=\pgfscope@linewidth% + \pgfsys@endscope} + + + + +% Quickly insert a box can contain normal TeX text at the origin. +% +% #1 = box of width/height and depth 0pt +% +% Example: +% +% \pgfqbox{\mybox} + +\def\pgfqbox#1{% + \pgfsys@hbox#1% +} + + +% Insert a box that can contain normal TeX text at the origin, but +% with the current coordinate transformation matrix synced with the +% low-level transformation matrix. +% +% #1 = box of width/height and depth 0pt +% +% In essence, this command does the same as if you first said +% \pgflowlevelsynccm and then \pgfqbox. However, pgf will use a +% ``TeX-translation'' for the translation part of the transformation +% cm. This will ensure that hyperlinks ``survive'' at least +% translations. +% +% Example: +% +% \pgfqboxsynced{\mybox} + +\def\pgfqboxsynced#1{% + \pgfsys@hboxsynced#1% +} + + +% Puts some text in a box and inserts it with the current +% transformations applied. +% +% #1 = List of optional positioning. Possible values are ``left'', ``right'', +% ``top'', ``bottom'' and ``base''. +% #2 = TeX text. May contain verbatims. +% +% Example: +% +% \pgftransformshift{\pgfpoint{1cm}{0cm}} +% \pgftext{Hello World!} + +\def\pgftext{\pgfutil@ifnextchar[\pgf@text{\pgf@text[]}}% +\def\pgf@text[#1]{% + \def\pgf@text@options{#1}% + \pgf@maketext\pgf@after@text} +\def\pgf@after@text{% + {% + \def\pgf@text@hshift{center}% + \def\pgf@text@vshift{center}% + \expandafter\pgf@text@setkeys\expandafter{\pgf@text@options}% + \csname pgf@halign\pgf@text@hshift\endcsname% + \csname pgf@valign\pgf@text@vshift\endcsname% + % Protocol sizes: + \pgf@process{\pgfpointtransformed{\pgfqpoint{0pt}{\dp\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfqpoint{\wd\pgf@hbox}{\dp\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfqpoint{0pt}{\ht\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgf@process{\pgfpointtransformed{\pgfqpoint{\wd\pgf@hbox}{\ht\pgf@hbox}}}% + \pgf@protocolsizes{\pgf@x}{\pgf@y}% + \pgfqboxsynced{\pgf@hbox}% + }% +} +\def\pgf@text@setkeys{\pgfqkeys{/pgf/text}}% + +\pgfkeys{/pgf/text/left/.code=\def\pgf@text@hshift{left}} +\pgfkeys{/pgf/text/center/.code=} +\pgfkeys{/pgf/text/right/.code=\def\pgf@text@hshift{right}} +\pgfkeys{/pgf/text/top/.code=\def\pgf@text@vshift{top}} +\pgfkeys{/pgf/text/bottom/.code=\def\pgf@text@vshift{bottom}} +\pgfkeys{/pgf/text/base/.code=\def\pgf@text@vshift{base}} +\pgfkeys{/pgf/text/at/.cd,.code=\pgftransformshift{#1},.value required} +\pgfkeys{/pgf/text/x/.cd,.code=\pgftransformxshift{#1},.value required} +\pgfkeys{/pgf/text/y/.cd,.code=\pgftransformyshift{#1},.value required} +\pgfkeys{/pgf/text/rotate/.cd,.code=\pgftransformrotate{#1},.value required} + +\def\pgf@halignleft{}% do nothing +\def\pgf@haligncenter{\pgftransformxshift{+-.5\wd\pgf@hbox}} +\def\pgf@halignright{\pgftransformxshift{+-\wd\pgf@hbox}}% +\def\pgf@valignbase{}% do nothing +\def\pgf@valignbottom{\pgftransformyshift{+\dp\pgf@hbox}}% +\def\pgf@valigncenter{\pgftransformyshift{+.5\dp\pgf@hbox}\pgftransformyshift{+-.5\ht\pgf@hbox}}% +\def\pgf@valigntop{\pgftransformyshift{+-\ht\pgf@hbox}}% + + +% Internal function for creating a hbox. +\def\pgf@maketext#1{% + \def\pgf@@maketextafter{#1}% + \setbox\pgf@hbox=\hbox\bgroup% + \pgfinterruptpicture% + \bgroup% + \aftergroup\pgf@collectresetcolor% + \let\next=% +} +\def\pgf@collectresetcolor{% + \pgfutil@ifnextchar\reset@color% + {\reset@color\afterassignment\pgf@collectresetcolor\let\pgf@temp=}% + {\pgf@textdone}% +} +\def\pgf@textdone{% + \endpgfinterruptpicture% + \egroup% + \pgf@@maketextafter% +} + +\long\def\pgf@makehbox#1{% + \setbox\pgf@hbox=\hbox{{% + \pgfinterruptpicture% + #1% + \endpgfinterruptpicture% + }}} + + + +% Picture environment +% +% Example: +% +% \begin{pgfpicture} +% \pgfsetendarrow{\pgfarrowto} +% \pgfpathmoveto{\pgfpointxy{-0.9}{0.2}} +% \pgfpathlineto{\pgfpointxy{0.9}{0.4}} +% \pgfusepath{stroke} +% \end{pgfpicture} + +\newif\ifpgfpicture + +\def\pgfresetboundingbox{% + \global\pgf@picmaxx=-16000pt\relax% + \global\pgf@picminx=16000pt\relax% + \global\pgf@picmaxy=-16000pt\relax% + \global\pgf@picminy=16000pt\relax% +}% + +\def\pgfpicture{% + \begingroup% + \pgfpicturetrue% + \global\advance\pgf@picture@serial@count by1\relax% + \edef\pgfpictureid{pgfid\the\pgf@picture@serial@count}% + \let\pgf@nodecallback=\pgfutil@gobble% + \pgf@picmaxx=-16000pt\relax% + \pgf@picminx=16000pt\relax% + \pgf@picmaxy=-16000pt\relax% + \pgf@picminy=16000pt\relax% + \pgf@relevantforpicturesizetrue% + \pgf@resetpathsizes% + \pgfutil@ifnextchar\bgroup\pgf@oldpicture\pgf@picture} +\def\pgf@oldpicture#1#2#3#4{% + \pgfmathsetlength\pgf@picminx{#1}% + \pgfmathsetlength\pgf@picminy{#2}% + \pgfmathsetlength\pgf@picmaxx{#3}% + \pgfmathsetlength\pgf@picmaxy{#4}% + \pgf@relevantforpicturesizefalse% + \pgf@picture} + +\def\pgf@picture{% + \setbox\pgfpic\hbox to0pt\bgroup% + \begingroup% + \pgfsys@beginpicture% + \pgfsys@beginscope% + \begingroup% + \pgfsetcolor{.}% + \pgfsetlinewidth{0.4pt}% + \pgftransformreset% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \begingroup% + \let\pgf@setlengthorig=\setlength% + \let\pgf@addtolengthorig=\addtolength% + \let\pgf@selectfontorig=\selectfont% + \let\setlength=\pgf@setlength% + \let\addtolength=\pgf@addtolength% + \let\selectfont=\pgf@selectfont% + \nullfont\spaceskip0pt\xspaceskip0pt% + \setbox\pgf@layerbox@main\hbox to0pt\bgroup% + \begingroup% + } +\def\endpgfpicture{% + \ifpgfrememberpicturepositiononpage% + \hbox to0pt{\pgfsys@markposition{\pgfpictureid}}% + \fi% + % ok, now let's position the box + \ifdim\pgf@picmaxx=-16000pt\relax% + % empty picture. make size 0. + \global\pgf@picmaxx=0pt\relax% + \global\pgf@picminx=0pt\relax% + \global\pgf@picmaxy=0pt\relax% + \global\pgf@picminy=0pt\relax% + \fi% + % Shift baseline outside: + \pgf@relevantforpicturesizefalse% + \pgf@process{\pgf@baseline}% + \xdef\pgf@shift@baseline{\the\pgf@y}% + % + \pgf@process{\pgf@trimleft}% + \global\advance\pgf@x by-\pgf@picminx + % prepare \hskip\pgf@trimleft@final. + % note that \pgf@trimleft@final is also queried + % by the pgf image externalization. + \xdef\pgf@trimleft@final{-\the\pgf@x}% + % + \pgf@process{\pgf@trimright}% + \global\advance\pgf@x by-\pgf@picmaxx + % prepare \hskip\pgf@trimright@final. + % note that \pgf@trimright@final is also queried + % by the pgf image externalization. + \xdef\pgf@trimright@final{\the\pgf@x}% + % + \pgf@remember@layerlist@globally + \endgroup% + \hss% + \egroup% + \pgf@restore@layerlist@from@global + \pgf@insertlayers% + \endgroup% + \pgfsys@discardpath% + \endgroup% + \pgfsys@endscope% + \pgfsys@endpicture% + \endgroup% + \hss + \egroup% + \pgfsys@typesetpicturebox\pgfpic% + \endgroup% +} + +\def\pgf@remember@layerlist@globally{% + \global\let\pgf@layerlist@=\pgf@layerlist +}% +\def\pgf@restore@layerlist@from@global{% + \let\pgf@layerlist=\pgf@layerlist@ +}% +\def\pgf@insertlayers{% + \box\pgf@layerbox@main% +} + +\def\pgf@selectfont{\pgf@selectfontorig\nullfont} + +\def\pgf@setlength#1#2{% these will be used only when \nullfont is active + \begingroup% keep font setting local + \pgfutil@selectfont% restore font + \pgf@setlengthorig#1{#2}% calculate dimension (possibly using calc) + \expandafter% + \endgroup% + \expandafter#1\expandafter=\the#1\relax} +\def\pgf@addtolength#1#2{% + \begingroup% keep font setting local + \pgfutil@selectfont% restore font + \pgf@addtolengthorig#1{#2}% calculate dimension (possibly using calc) + \expandafter% + \endgroup% + \expandafter#1\expandafter=\the#1\relax} + + +% Sets the baseline at the y-coordinate of a given point +% +% #1 = point +% +% Sets the baseline of the picture to the y-coordinate of a given +% point. However, the point will be evaluated *at the end of the +% picture*. +% +% Example: +% +% \pgfsetbaselinepointlater{\pgfpointanchor{mynode}{base}} + +\def\pgfsetbaselinepointlater#1{\def\pgf@baseline{#1}} + + +% Sets the baseline at the y-coordinate of a given point, now +% +% #1 = point +% +% Sets the baseline of the picture to the y-coordinate of a given +% point. +% +% Example: +% +% \pgfsetbaselinepointnow{\pgfpoint{1cm}{2pt}} + +\def\pgfsetbaselinepointnow#1{% + \pgf@process{#1}% + \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfsetbaselinepointlater{\pgf@setter@baseline}% +} + +\def\pgf@default@text{default}% + +% Sets the baseline +% +% #1 = baseline +% +% Sets the baseline of the picture. Default is the lower border, which +% is the same as \pgf@picminy +% +% Example: +% +% \pgfsetbaseline{1cm+2pt} +% \pgfsetbaseline{default}% resets to default value + +\def\pgfsetbaseline#1{% + \def\pgf@temp{#1}% + \ifx\pgf@temp\pgf@default@text + \pgfsetbaseline{\pgf@picminy}% + \else + \pgfsetbaselinepointlater{\pgfpoint{0pt}{#1}}% + \fi +} +\pgfsetbaseline{\pgf@picminy} + +% controls how the image externalization implements trim: +\newif\ifpgf@trim@lowlevel +\pgfkeys{ + /pgf/trim lowlevel/.is if=pgf@trim@lowlevel, + /pgf/trim lowlevel/.default=true, +} + +% Same as the y-baseline for horizontal alignment. +% The effect is different, though: it is some kind of trimming which +% leaves the bounding box intact. +\def\pgfsettrimleftpointlater#1{\def\pgf@trimleft{#1}} +\def\pgfsettrimleftpointnow#1{% + \pgf@process{#1}% + \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfsettrimleftpointlater{\pgf@setter@baseline}% +} +% \pgfsettrimleft{} +% or +% \pgfsettrimleft{default} +\def\pgfsettrimleft#1{% + \def\pgf@temp{#1}% + \ifx\pgf@temp\pgf@default@text + \pgfsettrimleft{\pgf@picminx} + \else + \pgfsettrimleftpointlater{\pgfpoint{#1}{0pt}}% + \fi +} +\pgfsettrimleft{\pgf@picminx} + +\def\pgfsettrimrightpointlater#1{\def\pgf@trimright{#1}} +\def\pgfsettrimrightpointnow#1{% + \pgf@process{#1}% + \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfsettrimrightpointlater{\pgf@setter@baseline}% +} +% \pgfsettrimright{} +% or +% \pgfsettrimright{default} +\def\pgfsettrimright#1{% + \def\pgf@temp{#1}% + \ifx\pgf@temp\pgf@default@text + \pgfsettrimright{\pgf@picmaxx}% + \else + \pgfsettrimrightpointlater{\pgfpoint{#1}{0pt}}% + \fi +} +\pgfsettrimright{\pgf@picmaxx} + + +% Interrupt path +% +% Description: +% +% The environment can be used to insert some drawing commands while +% constructing a path. The drawing commands inside the environment +% will not interfere with the path being constructed ``outside.'' +% However, you must ward against graphic state changes using a scope. +% +% Example: Draw two parallel lines +% +% \pgfmoveto{\pgfpoint{0cm}{0cm}} +% \begin{pgfinterruptpath} +% \pgfmoveto{\pgfpoint{1cm}{0cm}} +% \pgfmoveto{\pgfpoint{1cm}{1cm}} +% \pgfusepath{stroke} +% \end{pgfinterruptpath} +% \pgflineto{\pgfpoint{0cm}{1cm}} +% \pgfusepath{stroke} + +\def\pgfinterruptpath +{% + \begingroup% + % save all sorts of things... + \edef\pgf@interrupt@savex{\the\pgf@path@lastx}% + \edef\pgf@interrupt@savey{\the\pgf@path@lasty}% + \pgf@getpathsizes\pgf@interrupt@pathsizes% + \pgfsyssoftpath@getcurrentpath\pgf@interrupt@path% + \pgfsyssoftpath@setcurrentpath\pgfutil@empty% + \edef\pgfscope@linewidth{\the\pgflinewidth}% + \let\pgf@interrupt@lastmoveto=\pgfsyssoftpath@lastmoveto% + \begingroup% +} +\def\endpgfinterruptpath +{% + \endgroup% + \global\pgflinewidth=\pgfscope@linewidth% + \pgfsyssoftpath@setcurrentpath\pgf@interrupt@path% + \pgf@setpathsizes\pgf@interrupt@pathsizes% + \global\pgf@path@lastx=\pgf@interrupt@savex% + \global\pgf@path@lasty=\pgf@interrupt@savey% + \global\let\pgfsyssoftpath@lastmoveto=\pgf@interrupt@lastmoveto% + \endgroup% +} + + + +% Interrupt bounding box +% +% Description: +% +% The environment can be used to temporarily setup a new bounding box +% computation. The bounding box will be made empty at the beginning of +% the environment and will be reset to its old value after the +% environment. +% +% Example: +% +% \begin{pgfinterruptboundinbox} +% \pgfmoveto{\pgfpoint{1cm}{0cm}} +% \pgfmoveto{\pgfpoint{1cm}{1cm}} +% \pgfusepath{stroke} +% \end{pgfinterruptboundinbox} + +\def\pgfinterruptboundingbox +{% + \begingroup% + \edef\pgf@interrupt@savemaxx{\the\pgf@picmaxx}% + \edef\pgf@interrupt@saveminx{\the\pgf@picminx}% + \edef\pgf@interrupt@savemaxy{\the\pgf@picmaxy}% + \edef\pgf@interrupt@saveminy{\the\pgf@picminy}% + \pgf@picmaxx=-16000pt\relax% + \pgf@picminx=16000pt\relax% + \pgf@picmaxy=-16000pt\relax% + \pgf@picminy=16000pt\relax% + \pgf@size@hookedfalse% + \let\pgf@path@size@hook=\pgfutil@empty% +} +\def\endpgfinterruptboundingbox +{% + \global\pgf@picmaxx=\pgf@interrupt@savemaxx% + \global\pgf@picmaxy=\pgf@interrupt@savemaxy% + \global\pgf@picminx=\pgf@interrupt@saveminx% + \global\pgf@picminy=\pgf@interrupt@saveminy% + \endgroup% +} + + + + + +% Interrupts a picture +% +% Description: +% +% This environment interrupts a picture and temporarily returns to +% normal TeX mode. All sorts of things are saved and restored by this +% environment. +% +% WARNING: Using this environment in conjuction with low level +% transformations can *strongly* upset the typesetting. Typically, the +% contents of this environment should have size/height/depth 0pt in +% the end. +% +% WARNING: This environment should only be used inside typesetting a +% box and this box must in turn be inserted using \pgfqbox. +% +% Example: Draw two parallel lines +% +% \pgfmoveto{\pgfpoint{0cm}{0cm}} +% \setbox\mybox=\hbox{ +% \begin{pgfinterruptpicture} +% This is normal text. +% \begin{pgfpicture} % a subpicture +% \pgfmoveto{\pgfpoint{1cm}{0cm}} +% \pgfmoveto{\pgfpoint{1cm}{1cm}} +% \pgfusepath{stroke} +% \end{pgfpicture} +% More text. +% \end{pgfinterruptpicture} +% } +% \ht\mybox=0pt +% \wd\mybox=0pt +% \dp\mybox=0pt +% \pgfqbox{\mybox}% +% \pgfpathlineto{\pgfpoint{0cm}{1cm}} +% \pgfusepath{stroke} + +\def\pgfinterruptpicture +{% + \begingroup% + \pgfinterruptboundingbox% + \pgftransformreset% + \pgfinterruptpath% + \ifx\pgf@selectfontorig\@undefined% + \else% + \let\setlength\pgf@setlengthorig% + \let\addtolength\pgf@addtolengthorig% + \let\selectfont\pgf@selectfontorig% + \fi% + \pgfutil@selectfont% + \pgfpicturefalse% + \let\pgf@positionnodelater@macro\relax% + \pgf@savelayers% +} +\def\endpgfinterruptpicture +{% + \pgf@restorelayers% + \endpgfinterruptpath% + \endpgfinterruptboundingbox% + \endgroup% +} + +\let\pgf@savelayers=\relax +\let\pgf@restorelayers=\relax + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex new file mode 100644 index 0000000..c2edfcc --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex @@ -0,0 +1,1067 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%% + + + +% Copyright 2007 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + + +% The files pgfkeys.code.tex and pgfkeysfiltered.code.tex are +% perfectly self-contained, except that the catcode of @ +% should be made a letter. + + +% Guard against reading twice +\ifx\pgfkeysloaded\undefined + \let\pgfkeysloaded=\relax +\else + \expandafter\endinput +\fi + +% The purpose of this file is to provide a general settings engine that +% works with all TeX formats and has no save-stack impact + + +% This is useful: + +\def\pgfkeys@ifcsname#1\endcsname#2\else#3\fi{\expandafter\ifx\csname#1\endcsname\relax#3\else#2\fi}% +\ifx\eTeXrevision\undefined% +\else% + \expandafter\let\expandafter\pgfkeys@ifcsname\csname ifcsname\endcsname% +\fi + +\def\pgfkeys@empty{} + +% This also: + +\ifx\PackageError\undefined + \def\pgfkeys@error#1{\immediate\write-1{Package pgfkeys: Error! #1.}}% +\else + \def\pgfkeys@error#1{\PackageError{pgfkeys}{#1}{}}% +\fi + +% Set a key to a value +% +% #1 = key +% #2 = tokens +% +% Description: +% +% This command sets the key to the given tokens. The tokens are stored as +% is and can even contain things like #9. +% +% Keys are organized hierarchically using something similar to Unix +% paths. Thus, a typically key might be called "/tikz/length" or +% "/tikz/length dimension/.@cmd". Some keys starting with a dot are +% special, so they should not be used as normal key names (they are +% similar to Unix files starting with a dot -- you can use them, but +% be careful). +% +% Keys are always local to the current TeX group. +% +% Example: +% +% \pgfkeyssetvalue{/tikz/length}{2cm-3cm} +% \pgfkeyssetvalue{/algo/swap}{{#2}{#1}} + +\long\def\pgfkeyssetvalue#1#2{% + \pgfkeys@temptoks{#2}\expandafter\edef\csname pgfk@#1\endcsname{\the\pgfkeys@temptoks}% +} + + + +% Add text to a key at the end +% +% #1 = key +% #2 = a value to be added at the beginning +% #3 = a value to be added at the end +% +% Description: +% +% This command adds #2 to the definition of the key. The key should +% have been set previously using \pgfkeyssetvalue. +% +% Example: +% +% \pgfkeysaddvalue{/tikz/length}{}{-3cm} + +\long\def\pgfkeysaddvalue#1#2#3{% + {% + \toks0{#2}% + \pgfkeysifdefined{#1} + {\pgfkeys@temptoks\expandafter\expandafter\expandafter{\csname pgfk@#1\endcsname}}% + {\pgfkeys@temptoks{}}% + \toks1{#3}% + \xdef\pgfkeys@global@temp{\the\toks0 \the\pgfkeys@temptoks \the\toks1}% believe or don't: the spaces are important + }% + \pgfkeyslet{#1}\pgfkeys@global@temp% +} + + + +% Makes a key equal a given code +% +% #1 = key +% #2 = a code name +% +% Description: +% +% This command executes a \let command so that a key gets the same +% value as the parameter #2. +% +% Keys are always local to the current TeX group. +% +% Example: +% +% \pgfkeyslet{/algo/swap}{\myswap} + +\def\pgfkeyslet#1#2{% + \expandafter\let\csname pgfk@#1\endcsname#2% +} + + +% Retrieve the code stored in a key into a code +% +% #1 = key +% #2 = code +% +% Description: +% +% This command will set #2 to "point" to the value stored in the key. +% +% Example: +% +% \pgfkeysgetvalue{/tikz/swap}{\myswap} + +\def\pgfkeysgetvalue#1#2{\expandafter\let\expandafter#2\csname pgfk@#1\endcsname} + + + +% Retrieve the value stored in a key +% +% #1 = key +% +% Description: +% +% This command will expand to the value stored in the key. The key +% should previously have been set using \pgfkeyasetkey or \pgfkeyslet. +% +% Example: +% +% The length is \pgfkeysvalue{/tikz/length}. + +\def\pgfkeysvalueof#1{\csname pgfk@#1\endcsname} + + + +% If for testing whether a key exists +% +% #1 = key +% #2 = if-case +% #3 = else-case +% +% Description: +% +% This if will be executed if the key exists. In eTeX mode this works +% like a normal if, in normal TeX mode you need to provide an \else. +% +% Example: +% +% \pgfkeysifdefined{/tikz/length}{key exists}{does not exist} + +\long\def\pgfkeysifdefined#1#2#3{\pgfkeys@ifcsname pgfk@#1\endcsname#2\else#3\fi} + +% Tests whether a key is assignable. For standard keys which just +% store their value, this is identical to \pgfkeysifdefined. +% +% But \pgfkeysifassignable is true for command keys as well (but not +% for handled keys). +\long\def\pgfkeysifassignable#1#2#3{% + \pgfkeysifdefined{#1}% + {#2} + {\pgfkeysifdefined{#1/.@cmd}% + {#2}% + {#3}}% +}% + + + +% Execute settings +% +% #1 = list of settings +% +% Description: +% +% The list of settings should contain comma-separated settings. Each +% setting has the following form: +% +% /path/key=value +% +% The parts "/path/" and "=value" are optional. When the path is not +% specified, the value of the token register "\pgfkeypath" is used. If +% "=value" is missing, the value of the setting "/path/key/.@def" is used +% instead. If this key is set to "\pgfvaluerequired", the key +% "/errors/value required/.@cmd" is executed. Theis error handler, +% like all other error handlers, will get the current key as its first +% parameter (unexpanded) and the current value as its second value +% (also unexpanded). +% +% Any spaces at the beginning and at the end and around the +% equals-sign are removed. The key with the complete path is set to +% the code \pgfcurrentkey. +% +% The setting is then processed according to the following rules: +% +% 1) If the key /path/key/.@cmd" is present, its code is executed +% with the value computed above, followed by \pgfeov (end of +% value). So, to handle +% +% "/stuff/height= 1.5 ," +% +% /stuff/height/.@cmd should be set to some code, that can +% handle the parameter +% +% "1.5\pgfeov" +% +% For instance, saying +% +% \pgfkeys{/stuff/height/.@cmd}{#1\pgfeov}{\def\myheight{#1}} +% +% will do nicely. +% +% 2) Otherwise, if the key /path/key is present, this key is +% set to the value computed above. +% +% 3) Otherwise, if the key /handlers/key/.@cmd is present, it is executed +% with the same parameters as in 1). Additionally, the +% token register \pgfcurrentkeypath will be set to "/path/" and the +% macor \pgfcurrentkeywithoutpath to "key". So, in the above +% example if neither "/stuff/height/.@cmd" nor +% "/stuff/height" is present, but "/handlers/height" is, +% then "/handlers/height" is executed with the parameters: +% +% "1.5\pgfeov" +% +% and \pgfcurrentkey is set to "/stuff/height" and \pgfcurrentkeypath +% is set to "/stuff/" and \pgfcurrentkeywithoutpath to "height". +% +% 4) Otherwise, if the key "/path/.unknown/.@cmd" is present, its code is +% executed with the same parameters as in 3). +% +% 5) Otherwise, the key "/handlers/.unknown/.@cmd" is executed with the same +% parameters as in 1). +% +% After all settings have been processed, the value of the token +% register \pgfdefaultkeypath is set to its original value. Thus, any local +% change of this token register has no effect outside the call. +% +% Example: +% +% \pgfkeys{/tikz/.is family} +% \pgfkeys{/tikz/line width/.cd, +% .def=\pgfsetlinewidth{##1}, +% .set default=.4pt} +% \pgfkeys{tikz,line width=1pt} + +\newtoks\pgfkeys@pathtoks +\def\pgfkeyscurrentpath{\the\pgfkeys@pathtoks} +\newtoks\pgfkeys@temptoks + +\def\pgfkeys@root{/} +\let\pgfkeysdefaultpath\pgfkeys@root + +\def\pgfkeys{\expandafter\pgfkeys@@set\expandafter{\pgfkeysdefaultpath}}% +\long\def\pgfkeys@@set#1#2{% + \let\pgfkeysdefaultpath\pgfkeys@root% + \pgfkeys@parse#2,\pgfkeys@mainstop% + \def\pgfkeysdefaultpath{#1}} + +\def\pgfkeys@parse{\futurelet\pgfkeys@possiblerelax\pgfkeys@parse@main} +\def\pgfkeys@parse@main{% + \ifx\pgfkeys@possiblerelax\pgfkeys@mainstop% + \expandafter\pgfkeys@cleanup% + \else% + \expandafter\pgfkeys@normal% + \fi% +} +\newif\ifpgfkeys@syntax@handlers +\def\pgfkeys@normal{% + \ifpgfkeys@syntax@handlers% + \expandafter\pgfkeys@syntax@handlers% + \else% + \expandafter\pgfkeys@@normal% + \fi% +} +\def\pgfkeys@syntax@handlers{\pgfutil@ifnextchar\relax\pgfkeys@syntax@@handlers\pgfkeys@syntax@@handlers}%get rid of spaces +\def\pgfkeys@syntax@@handlers{\futurelet\pgfkeys@first@char\pgfkeys@syntax@handlers@test} +\def\pgfkeys@syntax@handlers@test{% + \pgfkeysgetvalue{/handlers/first char syntax/\meaning\pgfkeys@first@char}\pgfkeys@the@handler% + \ifx\pgfkeys@the@handler\relax% + \expandafter\pgfkeys@@normal% + \else% + \expandafter\pgfkeys@use@handler% + \fi% +} +\long\def\pgfkeys@use@handler#1,{% + \pgfkeys@the@handler{#1}% + \pgfkeys@parse% +} + +\long\def\pgfkeys@@normal#1,{% + \pgfkeys@unpack#1=\pgfkeysnovalue=\pgfkeys@stop% + \pgfkeys@parse% +} +\def\pgfkeys@cleanup\pgfkeys@mainstop{} + +\def\pgfkeys@mainstop{\pgfkeys@mainstop} % equals only itself +\def\pgfkeys@novalue{} % equals only itself +\def\pgfkeysnovalue{\pgfkeys@novalue} % equals only itself +\def\pgfkeysnovalue@text{\pgfkeysnovalue} +\def\pgfkeysvaluerequired{\pgfkeysvaluerequired} % equals only itself + +\long\def\pgfkeys@unpack#1=#2=#3\pgfkeys@stop{% + \pgfkeys@spdef\pgfkeyscurrentkey{#1}% + \edef\pgfkeyscurrentkey{\pgfkeyscurrentkey}% + \ifx\pgfkeyscurrentkey\pgfkeys@empty% + % Skip + \else% + \pgfkeys@add@path@as@needed% + \pgfkeys@spdef\pgfkeyscurrentvalue{#2}% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyscurrentkey/.@def}% + {\pgfkeysgetvalue{\pgfkeyscurrentkey/.@def}{\pgfkeyscurrentvalue}} + {}% no default, so leave it + \fi% + \ifx\pgfkeyscurrentvalue\pgfkeysvaluerequired% + \pgfkeysvalueof{/errors/value required/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% + \else% + \pgfkeys@case@one% + \fi% + \fi} + +\def\pgfkeys@case@one{% + \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}% + {\pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} + {\pgfkeys@case@two}% +} + +\def\pgfkeys@case@two{% + \pgfkeysifdefined{\pgfkeyscurrentkey}% + {\pgfkeys@case@two@extern}% + {\pgfkeys@case@three}% +} + +\def\pgfkeys@case@two@extern{% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \pgfkeysvalueof{\pgfkeyscurrentkey}% + \else% + \pgfkeyslet{\pgfkeyscurrentkey}\pgfkeyscurrentvalue% + \fi% +} + + +% either handled key or unknown. +% +% This macro will be replaced by the /handler config/handle only existing +% configuration, see below. +\def\pgfkeys@case@three{% + \pgfkeys@split@path% + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}% + {\pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} + {\pgfkeys@unknown}% +} +\let\pgfkeys@case@three@handleall=\pgfkeys@case@three +\def\pgfkeys@case@three@handle@restricted{% + \pgfkeys@split@path% + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% + \pgfkeys@ifexecutehandler{% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + }{% + % this here is necessary: /my search path/key/.code + % won't be called, so \pgfkeyscurrentpath == '/my search path/key' + % -> it should be one directory higher! We want to invoke the + % .unknown handler in + % '/my search path' + % + % Idea: + % set + % - path := '/my search path' + % - name := 'key/.code' + % - key = '/my search path/key/.code' + \let\pgfkeys@temp=\pgfkeyscurrentkey + \let\pgfkeys@tempb=\pgfkeyscurrentname + \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% + \pgfkeys@split@path% + \let\pgfkeyscurrentkey=\pgfkeys@temp + \edef\pgfkeyscurrentname{\pgfkeyscurrentname/\pgfkeys@tempb}% + \pgfkeys@unknown + }% + }{% + \pgfkeys@unknown + }% +} + +% this macro is to implement the |handly only existing| key in key filtering: +% #1: the code to invoke IF the key handler shall be executed +% #2: the code to invoke if it shall not run. +\def\pgfkeys@ifexecutehandler#1#2{#1}% +\let\pgfkeys@ifexecutehandler@handleall=\pgfkeys@ifexecutehandler +\def\pgfkeys@ifexecutehandler@handleonlyexisting#1#2{% + \pgfkeys@ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname% + #1% ok, this particular key handler is known and should be processed in any case (for example .try) + \else + % implement the 'only existing' feature here: + \pgfkeysifdefined{\pgfkeyscurrentpath}{#1}{% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{#1}{#2}% + }{}% + \fi% +}% +\def\pgfkeys@ifexecutehandler@handlefullorexisting#1#2{% + \ifpgfkeysaddeddefaultpath + \pgfkeys@ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname% +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentname' is an exception; processing it (on \pgfkeyscurrentpath).}% + #1% ok, this particular key handler is known and be processed in any case (for example .try) + \else + % implement the 'only existing' feature here: + \pgfkeysifdefined{\pgfkeyscurrentpath}{% +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath' does exist. Executing '\pgfkeyscurrentname'.}% + #1% + }{% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{% +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath/.@cmd' does exist. Executing '\pgfkeyscurrentname'.}% + #1% + }{% +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath' does NOT exist. Skipping '\pgfkeyscurrentname'.}% + #2% + }% + }% + \fi% + \else +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): Fully qualified key provided. Executing '\pgfkeyscurrentname'.}% + #1% ok, always true if the USER explicitly provided the full key path. + \fi +}% +\def\pgfkeysaddhandleonlyexistingexception#1{\expandafter\def\csname pgfk@excpt@#1\endcsname{1}}% + +\def\pgfkeys@unknown{% + \pgfkeysifdefined{\pgfkeyscurrentpath/.unknown/.@cmd}% + {% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.unknown/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} + {% + \pgfkeysgetvalue{/handlers/.unknown/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% + }% +} + + +\long\def\pgfkey@argumentisspace#1{% + \long\def\pgfkeys@spdef##1##2{% + \futurelet\pgfkeys@possiblespace\pgfkeys@sp@a##2\pgfkeys@stop\pgfkeys@stop#1\pgfkeys@stop\relax##1}% + \def\pgfkeys@sp@a{% + \ifx\pgfkeys@possiblespace\pgfkeys@sptoken% + \expandafter\pgfkeys@sp@b% + \else% + \expandafter\pgfkeys@sp@b\expandafter#1% + \fi}% + \long\def\pgfkeys@sp@b#1##1 \pgfkeys@stop{\pgfkeys@sp@c##1}% +} +\pgfkey@argumentisspace{ } +\long\def\pgfkeys@sp@c#1\pgfkeys@stop#2\relax#3{\pgfkeys@temptoks{#1}\edef#3{\the\pgfkeys@temptoks}} +{\def\:{\global\let\pgfkeys@sptoken= } \: } + + + +\def\pgfkeys@add@path@as@needed{% Should add the path if the + % \pgfkeyscurrentkey does not start with / + \expandafter\futurelet\expandafter\pgfkeys@possibleslash\expandafter\pgfkeys@check@slash\pgfkeyscurrentkey\relax% +} +\newif\ifpgfkeysaddeddefaultpath +\def\pgfkeys@check@slash{% + \ifx\pgfkeys@possibleslash/% + \expandafter\pgfkeys@nevermind% + \else% + \expandafter\pgfkeys@addpath% + \fi% +} + +\def\pgfkeys@nevermind#1\relax{% + \pgfkeysaddeddefaultpathfalse + \let\pgfkeyscurrentkeyRAW\pgfkeyscurrentkey +} +\def\pgfkeys@addpath#1\relax{% + \pgfkeysaddeddefaultpathtrue + \def\pgfkeyscurrentkeyRAW{#1}% + \edef\pgfkeyscurrentkey{\pgfkeysdefaultpath#1}% +} + + +\def\pgfkeys@split@path{% Should assign the two codes + % \pgfkeyscurrentname and \pgfcurrentlkeypath + \pgfkeys@pathtoks{}% + \expandafter\pgfkeys@splitter\pgfkeyscurrentkey//% +} +\def\pgfkeys@splitter#1/#2/{% + \def\pgfkeys@temp{#2}% + \ifx\pgfkeys@temp\pgfkeys@empty% + % Ah. done + \def\pgfkeyscurrentname{#1}% + \expandafter\pgfkeys@gobbletoslash% + \else% + \expandafter\pgfkeys@pathtoks\expandafter{\the\pgfkeys@pathtoks#1/}% + \fi% + \pgfkeys@splitter#2/% +} +\def\pgfkeys@gobbletoslash\pgfkeys@splitter/{\expandafter\pgfkeys@remove@slash\the\pgfkeys@pathtoks\relax}% +\def\pgfkeys@remove@slash#1/\relax{\pgfkeys@pathtoks{#1}} + + + +% Quickly set keys +% +% #1 = default path +% #2 = key-value pairs +% +% Desscription: +% +% This command starts the execution with the default path set to +% #1. This command should only be used when speed is important (like +% in a heavily used macro like \tikzset). Normally, keys should be +% used to set the path. Note that if #1 equals /, then \pgfkeys will +% actually be quicker! +% +% Example: +% +% \pgfqkeys{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} + +\def\pgfqkeys{\expandafter\pgfkeys@@qset\expandafter{\pgfkeysdefaultpath}}% +\long\def\pgfkeys@@qset#1#2#3{\def\pgfkeysdefaultpath{#2/}\pgfkeys@parse#3,\pgfkeys@mainstop\def\pgfkeysdefaultpath{#1}} + + +% Sets keys while setting keys +% +% #1 = key-value pairs +% +% Desscription: +% +% This code may only be called inside the code that is executed for a +% key. The #1 should be a list of settings pairs. They will be executed +% as if they had been given as the argument to the \pgfkeys command. +% +% Example: +% +% \pgfkeys{tikz,myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} + +\long\def\pgfkeysalso#1{\pgfkeys@parse#1,\pgfkeys@mainstop} + + + +% Quickly sets keys while setting keys +% +% #1 = default path +% #2 = key-value pairs +% +% Desscription: +% +% This command executes #2 with the default path set to #1. This +% command will cause chaos if used incorrectly. The only safe +% place to use it instead of \pgfkeys is at the beginning of a TeX group. +% +% Example: +% +% \begingroup +% \pgfqkeysalso{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} + +\long\def\pgfqkeysalso#1#2{\def\pgfkeysdefaultpath{#1/}\pgfkeys@parse#2,\pgfkeys@mainstop} + + + + +% Now setup the default handelers and keys: + +% Define a key macro with one argument (\def or \edef) +% +% #1 = key +% #2 = code +% +% Description: +% +% This command will setup things so the key/.@cmd contains a macro +% that takes one parameter and has #2 as its code. +% +% Example: +% +% \pgfkeysdef{/my key}{\show#1} + +\long\def\pgfkeysdef#1#2{% + \long\def\pgfkeys@temp##1\pgfeov{#2}% + \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% +} +\long\def\pgfkeysedef#1#2{% + \long\edef\pgfkeys@temp##1\pgfeov{#2}% + \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% +} + + +% Define a key macro with mutliple arguments (\def or \edef) +% +% #1 = key +% #2 = argument pattern +% #2 = code +% +% Description: +% +% This command will setup things so the key/.@cmd contains a macro +% that takes #2 as its parameter pattern and has #3 as its code. +% +% Example: +% +% \pgfkeysdefargs{/swap}{#1#2}{#2#1} + +\long\def\pgfkeysdefargs#1#2#3{% + \long\def\pgfkeys@temp#2\pgfeov{#3}% + \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% + \pgfkeyssetvalue{#1/.@args}{#2\pgfeov}% + \pgfkeyssetvalue{#1/.@body}{#3}% +} +\long\def\pgfkeysedefargs#1#2#3{% + \long\edef\pgfkeys@temp#2\pgfeov{#3}% + \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% + \pgfkeyssetvalue{#1/.@args}{#2\pgfeov}% + \pgfkeyssetvalue{#1/.@body}{#3}% +} + +% Like \pgfkeysdefargs, but `#2' is an integer denoting the expected +% *number* of arguments. +% +% There is a subtle difference between the 'args' command, when it +% comes to spaces: +% a key defined with defargs{#1#2} must not have spaces between the +% arguments when it is used. +% +% See this: +% +%-------------------------------------------------- +% % defnargs: +% \pgfkeysdefnargs{/a}{2}{1=`#1', 2=`#2'} +% \pgfkeys{ +% /a= +% {1} +% {2} +% } +% ->defnargs: 1=`1', 2=`2' +% +% defargs: +% \pgfkeysdefargs{/b}{#1#2}{1=`#1', 2=`#2'} +% \pgfkeys{ +% /b= +% {1} +% {2} +% } +% ->defargs: 1=`1', 2=` 2' (note the space!) +% +% defargs: +% \pgfkeysdefargs{/b}{#1#2}{1=`#1', 2=`#2'} +% \pgfkeys{ +% /b= +% {1}% +% {2} +% } +% ->defargs: 1=`1', 2=`2' +%-------------------------------------------------- +\long\def\pgfkeysdefnargs#1#2#3{\pgfkeysdefnargs@{#1}{#2}{#3}{\def}}% +\long\def\pgfkeysedefnargs#1#2#3{\pgfkeysdefnargs@{#1}{#2}{#3}{\edef}}% +\long\def\pgfkeysdefnargs@#1#2#3#4{% + \ifcase#2\relax + \pgfkeyssetvalue{#1/.@args}{}% + \or + \pgfkeyssetvalue{#1/.@args}{##1}% + \or + \pgfkeyssetvalue{#1/.@args}{##1##2}% + \or + \pgfkeyssetvalue{#1/.@args}{##1##2##3}% + \or + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4}% + \or + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5}% + \or + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6}% + \or + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7}% + \or + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8}% + \or + \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8##9}% + \else + \pgfkeys@error{\string\pgfkeysdefnargs: expected <= 9 arguments, got #2}% + \fi + \pgfkeysgetvalue{#1/.@args}\pgfkeys@tempargs + \def\pgfkeys@temp{\expandafter#4\csname pgfk@#1/.@@body\endcsname}% + \expandafter\pgfkeys@temp\pgfkeys@tempargs{#3}% + % eliminate the \pgfeov at the end such that TeX gobbles spaces + % by using + % \pgfkeysdef{#1}{\pgfkeysvalueof{#1/.@@body}##1} + % (with expansion of '#1'): + \edef\pgfkeys@tempargs{\noexpand\pgfkeysvalueof{#1/.@@body}}% + \def\pgfkeys@temp{\pgfkeysdef{#1}}% + \expandafter\pgfkeys@temp\expandafter{\pgfkeys@tempargs##1}% + \pgfkeyssetvalue{#1/.@body}{#3}% +} + + + +% Defining a key command + +\pgfkeysdef{/handlers/.code}{\pgfkeysdef{\pgfkeyscurrentpath}{#1}} +\pgfkeysdef{/handlers/.code 2 args}{\pgfkeysdefargs{\pgfkeyscurrentpath}{##1##2}{#1}} +\pgfkeysdef{/handlers/.ecode}{\pgfkeysedef{\pgfkeyscurrentpath}{#1}} +\pgfkeysdef{/handlers/.ecode 2 args}{\pgfkeysedefargs{\pgfkeyscurrentpath}{##1##2}{#1}} +\pgfkeysdefnargs{/handlers/.code args}{2}{\pgfkeysdefargs{\pgfkeyscurrentpath}{#1}{#2}} +\pgfkeysdefnargs{/handlers/.ecode args}{2}{\pgfkeysedefargs{\pgfkeyscurrentpath}{#1}{#2}} +\pgfkeysdefnargs{/handlers/.code n args}{2}{\pgfkeysdefnargs{\pgfkeyscurrentpath}{#1}{#2}} +\pgfkeysdefnargs{/handlers/.ecode n args}{2}{\pgfkeysedefnargs{\pgfkeyscurrentpath}{#1}{#2}} + +% Adding to a key command + +\pgfkeys{/handlers/.add code/.code 2 args=% + % Find out, whether with args or not. + \pgfkeysifdefined{\pgfkeyscurrentpath/.@args}% + {% Yes, so add to body and reuse args + \pgfkeysaddvalue{\pgfkeyscurrentpath/.@body}{#1}{#2}% + % Redefine code + {% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@args}{\pgfkeys@tempargs}% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@body}{\pgfkeys@tempbody}% + \def\pgfkeys@marshal{\expandafter\gdef\expandafter\pgfkeys@global@temp\pgfkeys@tempargs}% + \expandafter\pgfkeys@marshal\expandafter{\pgfkeys@tempbody}% + }% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@@body}{% + % support for \pgfkeysndefargs: + \pgfkeyslet{\pgfkeyscurrentpath/.@@body}{\pgfkeys@global@temp}% + }{% + % support for \pgfkeysdefargs: + \pgfkeyslet{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@global@temp}% + }% + }% + {% + % No, so single argument (simple \pgfkeysdef). Redefine accordingly. + {% + \toks0{#1}% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% + {\pgfkeys@temptoks\expandafter\expandafter\expandafter{\csname pgfk@\pgfkeyscurrentpath/.@cmd\endcsname##1\pgfeov}}% + {\pgfkeys@temptoks{}}% + \toks1{#2}% + \xdef\pgfkeys@global@temp{\the\toks0 \the\pgfkeys@temptoks \the\toks1 }% + }% + \expandafter\def\expandafter\pgfkeys@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + \pgfkeyslet{\pgfkeyscurrentpath/.@cmd}\pgfkeys@temp% + }% +} +\pgfkeys{/handlers/.prefix code/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={#1}{}}}% +\pgfkeys{/handlers/.append code/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={}{#1}}}% + + +% Defining a style + +\pgfkeys{/handlers/.style/.code=\pgfkeys{\pgfkeyscurrentpath/.code=\pgfkeysalso{#1}}} +\pgfkeys{/handlers/.estyle/.code=\pgfkeys{\pgfkeyscurrentpath/.ecode=\noexpand\pgfkeysalso{#1}}} +\pgfkeys{/handlers/.style args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.code args={#1}{\pgfkeysalso{#2}}}} +\pgfkeys{/handlers/.estyle args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.ecode args={#1}{\noexpand\pgfkeysalso{#2}}}} +\pgfkeys{/handlers/.style 2 args/.code=\pgfkeys{\pgfkeyscurrentpath/.code 2 args=\pgfkeysalso{#1}}} +\pgfkeys{/handlers/.style n args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.code n args={#1}{\pgfkeysalso{#2}}}} + +% Adding to a style + +\pgfkeys{/handlers/.add style/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.add code={\pgfkeysalso{#1}}{\pgfkeysalso{#2}}}}% +\pgfkeys{/handlers/.prefix style/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={\pgfkeysalso{#1}}{}}}% +\pgfkeys{/handlers/.append style/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={}{\pgfkeysalso{#1}}}}% + + +% Defining a value + +\pgfkeys{/handlers/.initial/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath}{#1}} +\pgfkeys{/handlers/.add/.code 2 args=\pgfkeysaddvalue{\pgfkeyscurrentpath}{#1}{#2}} +\pgfkeys{/handlers/.prefix/.code=\pgfkeysaddvalue{\pgfkeyscurrentpath}{#1}{}} +\pgfkeys{/handlers/.append/.code=\pgfkeysaddvalue{\pgfkeyscurrentpath}{}{#1}} +\pgfkeys{/handlers/.get/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath}{#1}} +\pgfkeys{/handlers/.link/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath}{\pgfkeysvalueof{#1}}} + + +% Defining a default + +\pgfkeys{/handlers/.default/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath/.@def}{#1}} +\pgfkeys{/handlers/.value required/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeysvaluerequired}} +\pgfkeys{/handlers/.value forbidden/.code=\pgfkeys{\pgfkeyscurrentpath/.add code=% +{% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \else% + \pgfkeysvalueof{/errors/value forbidden/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% + \fi% +}{}}} + + +% High-level cmds + +\pgfkeys{/handlers/.store in/.code=\pgfkeysalso{\pgfkeyscurrentpath/.code=\def#1{##1}}} +\pgfkeys{/handlers/.estore in/.code=\pgfkeysalso{\pgfkeyscurrentpath/.code=\edef#1{##1}}} + +\pgfkeys{/handlers/.is if/.code=\pgfkeysalso{% + \pgfkeyscurrentpath/.code=\pgfkeys@handle@boolean{#1}{##1}, + \pgfkeyscurrentpath/.default=true% + }% +} +\def\pgfkeys@handle@boolean#1#2{% + \pgfkeys@ifcsname#1#2\endcsname% + \csname#1#2\endcsname% + \else% + \pgfkeysvalueof{/errors/boolean expected/.@cmd}\pgfkeyscurrentkey{#2}\pgfeov% + \fi +} + +\pgfkeys{/handlers/.is choice/.code=% + \pgfkeys{% + \pgfkeyscurrentpath/.cd,% + .code=\expandafter\pgfkeysalso\expandafter{\pgfkeyscurrentkey/##1}, + .unknown/.style={/errors/unknown choice value=\pgfkeyscurrentkey\pgfkeyscurrentvalue}}} + + +% Repeatedly setting a key + +\pgfkeys{/handlers/.list/.code=% + {% + % Use foreach to unfold the list + \let\pgf@keys@temp=\pgfutil@empty% + \foreach \pgf@keys@key in{#1}% + {\expandafter\expandafter\expandafter\gdef% + \expandafter\expandafter\expandafter\pgf@keys@temp% + \expandafter\expandafter\expandafter{\expandafter\pgf@keys@temp\expandafter{\pgf@keys@key}}}% + \edef\pgf@keys@list@path{\pgfkeyscurrentpath}% + \expandafter\expandafter\expandafter\pgf@keys@do@list% + \expandafter\expandafter\expandafter{\expandafter\pgf@keys@list@path\expandafter}\pgf@keys@temp\pgf@stop% + }% +} +\def\pgf@keys@do@list#1{\pgfutil@ifnextchar\bgroup{\pgf@keys@do@list@item{#1}}\pgfutil@gobble} +\def\pgf@keys@do@list@item#1#2{\pgfkeysalso{#1={#2}}\pgf@keys@do@list{#1}} + + +% Forwarding + +\pgfkeys{/handlers/.forward to/.code=% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{}{\pgfkeysdef{\pgfkeyscurrentpath}{}} + \pgfkeys{\pgfkeyscurrentpath/.add code={}{\pgfkeys{#1={##1}}}} +} + + +% Inspection handlers + +\pgfkeys{/handlers/.show value/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath}{\pgfkeysshower}\show\pgfkeysshower} % inspect the value +\pgfkeys{/handlers/.show code/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath/.@cmd}{\pgfkeysshower}\show\pgfkeysshower} % inspect the body of the command + + +% First char syntax handlers +\pgfkeys{/handlers/first char syntax/.is if=pgfkeys@syntax@handlers} + +% Path handling + +% Prepares the .unknown handler used by '.search also'. +% It will be stored into \pgfkeys@global@temp. +\def\pgfkeys@searchalso@prepare@unknown@handler#1{% + \global\def\pgfkeys@global@temp##1\pgfeov{}% + \pgfkeys@searchalso@parse#1,\pgfkeys@mainstop + {% + \toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% + \toks1={\def\pgfutilnext{\pgfkeysvalueof{/handlers/.unknown/.@cmd}##1\pgfeov}\pgfutilnext}% + \xdef\pgfkeys@global@temp{% + \noexpand\ifpgfkeysaddeddefaultpath + \noexpand\pgfkeyssuccessfalse + \noexpand\let\noexpand\pgfkeys@searchalso@name=\noexpand\pgfkeyscurrentkeyRAW + \the\toks0 % one or more /.try things; one for each path. The last element won't have a /.try + %\noexpand\ifpgfkeyssuccess + %\noexpand\else + % \the\toks1 % invoke /handlers/.unknown handler + %\noexpand\fi + \noexpand\else + \the\toks1 % invoke /handlers/.unknown handler + \noexpand\fi + }% + \expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + }% +}% + +\def\pgfkeys@searchalso@parse{\futurelet\pgfkeys@possiblerelax\pgfkeys@searchalso@parse@main} +\def\pgfkeys@searchalso@parse@main{% + \ifx\pgfkeys@possiblerelax\pgfkeys@mainstop% + \expandafter\pgfkeys@cleanup% + \else% + \expandafter\pgfkeys@searchalso@appendentry% + \fi% +} +\def\pgfkeys@searchalso@appendentry#1,#2{% + \def\pgfkeys@searchalso@nexttok{#2}% + \pgfkeys@spdef\pgfkeys@temp{#1}% + {% + \toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% + \toks1=\expandafter{\pgfkeys@temp}% + \toks2={##1}% + \xdef\pgfkeys@global@temp{% + \the\toks0 % the space is important! + \noexpand\ifpgfkeyssuccess\noexpand\else + \noexpand\pgfqkeys{\the\toks1 }{\noexpand\pgfkeys@searchalso@name + \ifx\pgfkeys@searchalso@nexttok\pgfkeys@mainstop\else/.try\fi={\the\toks2 }}% + \noexpand\fi}% + \expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + }% + \pgfkeys@searchalso@parse#2% +} +\pgfkeys{% + /handlers/.is family/.code=\pgfkeys{\pgfkeyscurrentpath/.ecode=\edef\noexpand\pgfkeysdefaultpath{\pgfkeyscurrentpath/}},% + /handlers/.cd/.code=\edef\pgfkeysdefaultpath{\pgfkeyscurrentpath/},% + /handlers/.search also/.code={% + \pgfkeys@searchalso@prepare@unknown@handler{#1}% +%\message{I prepared the '\pgfkeyscurrentpath/.unknown' handler \meaning\pgfkeys@global@temp\space for '#1'.}% + \pgfkeyslet{\pgfkeyscurrentpath/.unknown/.@cmd}{\pgfkeys@global@temp}% + } +}% + + +% Value expansion + +\pgfkeys{/handlers/.expand once/.code=\expandafter\pgfkeys@exp@call\expandafter{#1}} +\pgfkeys{/handlers/.expand twice/.code=\expandafter\expandafter\expandafter\pgfkeys@exp@call\expandafter\expandafter\expandafter{#1}} +\pgfkeys{/handlers/.expanded/.code=\edef\pgfkeys@temp{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfkeys@temp}} + +\long\def\pgfkeys@exp@call#1{\pgfkeysalso{\pgfkeyscurrentpath={#1}}} + +% Try to set a key and do nothing if not define + +\newif\ifpgfkeyssuccess +\pgfkeys{/handlers/.try/.code=\pgfkeys@try} +\pgfkeys{/handlers/.retry/.code=\ifpgfkeyssuccess\else\pgfkeys@try\fi} +\def\pgfkeys@try{% + \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% make sure that \pgfkeys@code doesn't know about 'try'. Important for .is choice + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyscurrentpath/.@def}% + {\pgfkeysgetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeyscurrentvalue}} + {}% no default, so leave it + \fi% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% + {% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% + \pgfkeyssuccesstrue% + }% + {% + \pgfkeysifdefined{\pgfkeyscurrentpath}% + {% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \pgfkeysvalueof{\pgfkeyscurrentpath}% + \else% + \pgfkeyslet{\pgfkeyscurrentpath}\pgfkeyscurrentvalue% + \fi% + \pgfkeyssuccesstrue% + }% + {% + \pgfkeys@split@path% + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% + % in the standard configuration, this check here is redundand + % because pgfkeys@ifexecutehandler === true. + % It is only interesting for 'handle only existing'. + \pgfkeys@ifexecutehandler{% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + \pgfkeyssuccesstrue% + }{% + \pgfkeyssuccessfalse + }% + }{% + \pgfkeyssuccessfalse + }% + }% + }% +} + +% Utilities + +\pgfkeys{/utils/exec/.code=#1} % simply execute the given code directly. + + +% Errors + +\pgfkeys{/errors/boolean expected/.code 2 args=\pgfkeys@error{% + Boolean parameter of key '#1' must be 'true' or 'false', not + '#2'. I am going to ignore it}} +\pgfkeys{/errors/value required/.code 2 args=\pgfkeys@error{% + The key '#1' requires a value. I am going to ignore this key}{}} +\pgfkeys{/errors/value forbidden/.code 2 args=\pgfkeys@error{% + You may not specify a value for the key '#1'. I am going to ignore + the value '#2' that you provided}} +\pgfkeys{/errors/unknown choice value/.code 2 args=\pgfkeys@error{% + Choice '\pgfkeyscurrentname' unknown in key + '\pgfkeyscurrentpath'. I am going to ignore this key}} +\pgfkeys{/errors/unknown key/.code 2 args=\pgfkeys@error{% + I do not know the key '#1' and I am going to ignore it. Perhaps + you misspelled it}} + +\pgfkeys{/handlers/.unknown/.code=% + {% + \let\pgfkeys@orig@key=\pgfkeyscurrentkey% + \pgfkeysalso{/errors/unknown key=\pgfkeys@orig@key{}}% + } +} + +\pgfkeys{ + /handler config/.is choice, + /handler config/all/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handleall + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleall + }, + /handler config/only existing/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleonlyexisting + }, + /handler config/full or existing/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handlefullorexisting + }, + /handler config/only existing/add exception/.code={\pgfkeysaddhandleonlyexistingexception{#1}}, +}% +\pgfkeysaddhandleonlyexistingexception{.cd}% +\pgfkeysaddhandleonlyexistingexception{.try}% +\pgfkeysaddhandleonlyexistingexception{.retry}% +\pgfkeysaddhandleonlyexistingexception{.lastretry}% +\pgfkeysaddhandleonlyexistingexception{.unknown}% + + +\input pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex new file mode 100644 index 0000000..b40528c --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex @@ -0,0 +1,1041 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%% + + + +% Copyright 2008 by Christian Feuersaenger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. +% +% This file contains additions to pgfkeys.code.tex (loaded +% automatically at the end of pgfkeys.code.tex) +% +% Improvements: +% +% - option filtering +% you provide +% - a boolean predicate +% - a "filter handler" which will be invoked for non-matching options, +% - a key=value list as usual. +% The filter sets only matching options and invokes the handler for +% unmatching ones. +% +% - Fast family support as in xkeyval. +% - A key like /my tree/my option can be associated with /my family +% - You can efficiently set keys which belong to a set of "active" +% families. +% Remaining options can be collected into a macro. + +% WARNING: +% this file overwrites +% \pgfkeys@addpath +% \pgfkeys@nevermind +% +% all other features are 'additive' + + +% these implementations will be switched dynamically with their +% filtered versions (in \pgfkeys@install@filter@and@invoke) +\let\pgfkeys@orig@case@one=\pgfkeys@case@one +\let\pgfkeys@orig@@set=\pgfkeys@@set +\let\pgfkeys@orig@@qset=\pgfkeys@@qset +\let\pgfkeys@orig@try=\pgfkeys@try +\let\pgfkeys@orig@unknown=\pgfkeys@unknown + +\newif\ifpgfkeysfilteringisactive +\newif\ifpgfkeysfiltercontinue +\let\pgfkeys@key@predicate=\pgfkeys@empty +\let\pgfkeys@filtered@handler=\pgfkeys@empty +\newtoks\pgfkeys@tmptoks + +% Performs 'filtered' key settings. +% +% For every option for which the path prefixing has already been done, +% the current key filter predicate will be invoked. If the predicate +% returns true, pgfkeys will process this key in the normal manner. +% If not, a key filter handler will be invoked. +% +% The *predicate* and *handler* semantics are as follows: +% PRECONDITION: +% 1. The variables +% \pgfkeyscurrentkey (full path including name) +% \pgfkeyscurrentkeyRAW (the current key as it has been +% found in the key=value list +% without path modification) +% \pgfkeyscurrentvalue +% are all set. If the current key is a handler variable, +% \pgfkeyscurrentname +% and +% \pgfkeyscurrentpath +% are also set. +% 2. The type of option has already been checked, that means +% case (1) whether '.@cmd' exists +% case (2) whether the key as such has its value +% case (3) it is a handler like '.code', '.cd' or whatever. +% case (0) it is unknown. +% The actual case number (0-3) will be provided as contents +% of the macro +% \pgfkeyscasenumber. +% It is always a one-character token, so it may be compared +% with both, \ifnum or \if. +% Please note that unknown options will be processed with +% the usual '.unknown' handlers unless the key filter takes +% control over unknown options as well. +% +% POSTCONDITION: +% the predicate sets +% \pgfkeysfiltercontinuetrue +% or +% \pgfkeysfiltercontinuefalse +% (the boolean \ifpgfkeysfiltercontinue). +% Depending on this 'if', option processing will be continued or +% skipped. +% +% The handler can do anything with the option, for example collect +% unmatched ones. +% +% ATTENTION: \pgfkeysfiltered can't be nested (yet). Use the +% \pgfkeyspredicateAND if you need multiple predicates at once. +% Nesting would produce unexpected results because the current filter +% state can't be stored/restored without TeX-groups, therefor it is +% disabled. +% +% ATTENTION: you can't filter error messages. +% +% REMARK: In case (3), the macros \pgfkeyscurrentpath and +% \pgfkeyscurrentname have already been computed, you do not need to +% invoke \pgfkeyssplitpath. In any other case, neither path nor name +% are required for the options processing - if you need them for +% predicates/handlers, you need to compute them by hand. +% +% +% Example: +% \def\unmatched{} +% \pgfkeys{/pgf/key filters/is descendant of/.install key filter=/my group} +% \pgfkeys{/pgf/key filter handlers/append filtered to/.install key filter handler=\unmatched} +% \pgfkeysfiltered% +% {/my group/option 1=value 1,/tikz/option 2=value 2} +% -> +% will set '/my group/option 1' as usual, but '/tikz/option 2' will not +% be set. Instead, it will be appended to '\unmatched' such that +% \unmatched = {/tikz/option 2=value2} +% after the operation. +% +% Arguments: +% #1: key-value list. +\def\pgfkeysfiltered{% + % produce + % '{}' + % each expanded exactly one time into the register: + \expandafter\pgfkeysfiltered@@install\expandafter{\pgfkeysdefaultpath}% +} + +% #1: old value of default path. +% #2: key-value-list. +\def\pgfkeysfiltered@@install#1#2{% + \pgfkeys@install@filter@and@invoke{% + \let\pgfkeysdefaultpath\pgfkeys@root% + \pgfkeys@parse#2,\pgfkeys@mainstop% + \def\pgfkeysdefaultpath{#1}% + }% +} + +% Assuming that macro #1 contains a key=value list, this command +% performs an \pgfkeysalso command for the content of macro #1. +% +% It can be used in conjunction with +% - \pgfkeysfiltered and +% - \pgfkeysappendfilterednamestomacro: +% the first pass fill only process options matching the filter, then, +% a \pgfkeysalsofrom can be used at a later time to set the remaining +% options. +% +% Example: +% \pgfkeys{/my group/.cd,/utils/exec=\pgfkeysalsofrom\filtered} +\long\def\pgfkeysalsofrom#1{% + \expandafter\pgfkeysalso\expandafter{#1}% +} + +% The same as \pgfkeysalsofrom, but it invokes \pgfkeysalsofiltered. +\long\def\pgfkeysalsofilteredfrom#1{% + \expandafter\pgfkeysalsofiltered\expandafter{#1}% +} + +% #1 = options +\long\long\def\pgfkeysalsofiltered#1{% + \pgfkeys@install@filter@and@invoke{\pgfkeysalso{#1}}% +}% + +% The same like \pgfkeysfiltered, but with quick search path setting. +% +% #1: default path +% #2: key-value-pairs +\long\def\pgfqkeysfiltered#1{% + \expandafter\pgfqkeysfiltered@@install\expandafter{\pgfkeysdefaultpath}{#1}% +} + +% #1: old value of default path. +% #2: default path +% #3: key-value-list. +\long\def\pgfqkeysfiltered@@install#1#2#3{% + \pgfkeys@install@filter@and@invoke{% + \def\pgfkeysdefaultpath{#2/}\pgfkeys@parse#3,\pgfkeys@mainstop\def\pgfkeysdefaultpath{#1}% + }% +} + +% Family management +% +% The family code provides the following features: +% 1. every key can be associated with 0 or 1 'family'. +% 2. Families are a loose association which are independend of the key +% hierarchy. +% For example, /my tree/key1 can belong to family /tikz. +% +% 3. It is possible to "activate" or "deactivate" single families. +% Furthermore, it is possible to set only keys which belong to +% active families (using \pgfkeysfiltered). +% 4. Runtime complexities: +% If you have N options and you only want to process K active +% families, the runtime is O( N + K ): +% - activate every family O(K) +% - use \pgfkeyshasactivefamily as filter predicate O(N) +% - deactivate every family O(K) + + +% Activates family #1. +% +% #1 maybe a macro. +\def\pgfkeysactivatefamily#1{% + \pgfkeysiffamilydefined + {#1}% + {\csname pgfk@#1/familyactivetrue\endcsname}% + {\pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov}% +%\message{[ACTIVATING FAMILY #1]}% +} + +% Deactivates family #1. +% +% #1 maybe a macro. +\def\pgfkeysdeactivatefamily#1{% + \pgfkeysiffamilydefined + {#1}% + {\csname pgfk@#1/familyactivefalse\endcsname}% + {\pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov}% +%\message{[DEACTIVATING FAMILY #1]}% +} + +% Activates all families in the comma separated list #1. +% +% It will also generate code for deactivation of all those families +% into the command #2. +% +% #1: a comma-separated list of fully qualified family names. +% #2: a command which will be filled with a deactivate-all command. +\def\pgfkeysactivatefamilies#1#2{% + \pgfkeyssavekeyfilterstateto\pgfkeys@cur@state + \expandafter\pgfkeysactivatefamilies@impl\expandafter{\pgfkeys@cur@state}{#1}{#2}% +} +% #1: commands needed to restore the old filtering state +% #2: family name list +% #3: macro name for de-activate command +\def\pgfkeysactivatefamilies@impl#1#2#3{% + \pgfkeysinstallkeyfilter{/pgf/key filters/false}{}% + \let#3=\pgfkeys@empty% + \def\pgfkeys@filtered@handler{\pgfkeys@family@activate@handler{#3}}% + \pgfkeysalsofiltered{#2}% + #1% +} + +\def\pgfkeys@family@activate@handler#1{% + \pgfkeysactivatefamily{\pgfkeyscurrentkey}% + % produce + % '\pgfkeysdeactivatefamily{' '}' + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter#1\expandafter\pgfkeysdeactivatefamily\expandafter{\pgfkeyscurrentkey}}% + \edef#1{\the\pgfkeys@tmptoks}% +} + +% If for testing whether a family exists. +% +% #1 = fully qualified family name +% #2 = if-case +% #3 = else-case +% +% Description: +% +% If the family exists, #2 will be executed. Otherwise, #3 will be +% called. +\long\def\pgfkeysiffamilydefined#1#2#3{\pgfkeys@ifcsname ifpgfk@#1/familyactive\endcsname#2\else#3\fi} + +% Sets the TeX boolean +% \ifpgfkeysfiltercontinue := ( family #1 is active ) +% +% Argument: +% #1 the family name. Maybe a macro. +\def\pgfkeysisfamilyactive#1{% + \pgfkeysiffamilydefined{#1}{% + \expandafter\let\expandafter\ifpgfkeysfiltercontinue\csname ifpgfk@#1/familyactive\endcsname + }{% + \pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov% + \expandafter\expandafter\expandafter\let\csname ifpgfkeysfiltercontinue\endcsname\csname iffalse\endcsname + }% +}% + +% Retrieve the family of full key #1 into macro #2. +% +% Will set the TeX boolean \ifpgfkeyssuccess to whether the full key +% really has a family. +% +% The family for any key is stored in the sub-key #1/family. +% +% Parameters: +% #1: the full key name for which the family is requested. Maybe a +% macro. +% #2: a macro name which will be filled with the result. +\def\pgfkeysgetfamily#1#2{% + \pgfkeysifdefined{#1/family}{\pgfkeysgetvalue{#1/family}{#2}\pgfkeyssuccesstrue}{\pgfkeyssuccessfalse}% +} + +% Equivalent to \pgfkeys{#1/.belongs to family=#2} +\def\pgfkeyssetfamily#1#2{% + \pgfkeysiffamilydefined{#2}{% + \pgfkeyssetvalue{#1/family}{#2}% + }{% + \pgfkeysalso{/errors/family unknown=#2}% + }% +}% + + +% Sets \ifpgfkeysfiltercontinue to true iff the current key belongs to +% the /errors tree. +\long\def\pgfkeys@cur@is@descendant@of@errors{% + \expandafter\pgfkeys@cur@is@descendant@of@errors@impl\pgfkeyscurrentkey/errors\pgf@@eov +}% +\long\def\pgfkeys@cur@is@descendant@of@errors@impl#1/errors#2\pgf@@eov{% + \def\pgfkeyspred@TMP{#1}% + \ifx\pgfkeyspred@TMP\pgfkeys@empty +%\message{[SPECIAL CHECK] '\pgfkeyscurrentkey' is descendant of '/errors': TRUE.}% + \pgfkeysfiltercontinuetrue + \else +%\message{[SPECIAL CHECK] '\pgfkeyscurrentkey' is descendant of '/errors': FALSE.}% + \pgfkeysfiltercontinuefalse + \fi +}% + +% \pgfkeysinterruptkeyfilter +% ... +% \endpgfkeysinterruptkeyfilter +% temporarily interrupts key filtering and enables it in +% \endpgfkeysinterruptkeyfilter. +% +% If key filtering it not active, this has no effect at all. +% +% REMARK: +% \pgfkeysinterruptkeyfilter...\endpgfkeysinterruptkeyfilter does NOT +% introduce a \TeX-group. +\def\pgfkeysinterruptkeyfilter{% + \ifpgfkeysfilteringisactive + \let\pgfkeys@case@one=\pgfkeys@orig@case@one + \let\pgfkeys@try=\pgfkeys@orig@try + \let\pgfkeys@unknown=\pgfkeys@orig@unknown + \fi +} + +\def\endpgfkeysinterruptkeyfilter{% + \ifpgfkeysfilteringisactive + \let\pgfkeys@case@one=\pgfkeys@case@one@filtered + \let\pgfkeys@try=\pgfkeys@try@filtered + \let\pgfkeys@unknown=\pgfkeys@unknown@filtered + \fi +} + +% Activates families #1, calls \pgfkeysfiltered and deactivates the +% families afterwards. +% +% REMARK: you need to install a family-based key filter predicate +% manually to benefit from the activated families! +% +% #1: comma separated family list +% #2: key-value pairs +% +% @see \pgfkeysactivatefamiliesandfilteroptions +\def\pgfkeysactivatefamiliesandfilteroptions#1#2{% + \pgfkeysactivatefamilies{#1}{\pgfkeys@family@deactivation}% + \pgfkeysfiltered{#2}% + \pgfkeys@family@deactivation +} + +% The "quick" variant of \pgfkeysactivatefamiliesandfilteroptions: it +% also assigns a default path. +% +% #1: comma separated family list +% #2: default path +% #3: key-value pairs +\def\pgfqkeysactivatefamiliesandfilteroptions#1#2#3{% + \pgfkeysactivatefamilies{#1}{\pgfkeys@family@deactivation}% + \pgfqkeysfiltered{#2}{#3}% + \pgfkeys@family@deactivation +} + +% Public version of split path: +\def\pgfkeyssplitpath{\pgfkeys@split@path}% + + +% The same as \pgfkeysactivatefamiliesandfilteroptions but just for +% ONE family. +% +% #1: family (maybe a macro) +% #2: key-value pairs +\def\pgfkeysactivatesinglefamilyandfilteroptions#1#2{% + \pgfkeysactivatefamily{#1}% + \pgfkeysfiltered{#2}% + \pgfkeysdeactivatefamily{#1}% +} + +% The "quick" variant of \pgfkeysactivatesinglefamilyandfilteroptions +% +% #1: family (maybe a macro) +% #2: default path +% #3: key-value pairs +\def\pgfqkeysactivatesinglefamilyandfilteroptions#1#2#3{% + \pgfkeysactivatefamily{#1}% + \pgfqkeysfiltered{#2}{#3}% + \pgfkeysdeactivatefamily{#1}% +} + +% Installs the key filter '#1' with argument '#2'. +% This is equivalent to +% \pgfkeys{#1/.install key filter=#2} +% +% The current values of the key filter handler is stored into the public +% macros +% \pgfkeyscurrentkeyfilter +% and +% \pgfkeyscurrentkeyfilterargs +% +% #1: a full key name; may be a macro +% #2: optional arguments for the key. If the key expects more than one +% argument, supply '{{first}{second}}' +\def\pgfkeysinstallkeyfilter#1#2{% + \pgfkeysifdefined{#1/.@cmd}{% + \edef\pgfkeyscurrentkeyfilter{#1}% + \def\pgfkeyscurrentkeyfilterargs{#2}% + \pgfkeysgetvalue{#1/.@cmd}{\pgfkeys@key@predicate@}% + \def\pgfkeys@key@predicate{\pgfkeys@key@predicate@#2\pgfeov}% + }{% + \pgfkeysvalueof{/errors/no such key filter/.@cmd}{#1}{#2}\pgfeov% + }% +} + +% Installs the key filter handler '#1' with argument '#2'. +% This is equivalent to +% \pgfkeys{#1/.install key filter handler=#2} +% +% The current values of the key filter handler is stored into the public +% macros +% \pgfkeyscurrentkeyfilterhandler +% and +% \pgfkeyscurrentkeyfilterhandlerargs +% +% #1: a full key name; may be a macro +% #2: optional arguments for the handler. If the handler expects more than one +% argument, supply '{{first}{second}}' +\def\pgfkeysinstallkeyfilterhandler#1#2{% + \pgfkeysifdefined{#1/.@cmd}{% + \edef\pgfkeyscurrentkeyfilterhandler{#1}% + \def\pgfkeyscurrentkeyfilterhandlerargs{#2}% + \pgfkeysgetvalue{#1/.@cmd}{\pgfkeys@filtered@handler@}% + \def\pgfkeys@filtered@handler{\pgfkeys@filtered@handler@#2\pgfeov}% + }{% + \pgfkeysvalueof{/errors/no such key filter handler/.@cmd}{#1}{#2}\pgfeov% + }% +} + +% Creates a macro which contains commands to re-activate the current +% key filter and key filter handler. It can be used to temporarily +% switch the key filter. +\def\pgfkeyssavekeyfilterstateto#1{% + % produce the string + % \pgfkeysinstallkeyfilter{...}{...} + % \pgfkeysinstallkeyfilterhandler{...}{...} + % where each argument is expanded once + % FIXME: Do the same with less overhead! + \pgfkeys@tmptoks={\pgfkeysinstallkeyfilter}% + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilter}}% + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterargs}\pgfkeysinstallkeyfilterhandler}% + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterhandler}}% + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterhandlerargs}}% + \edef#1{% + \the\pgfkeys@tmptoks + }% +} + + +\pgfkeys{% + /errors/family unknown/.code=\pgfkeys@error{% + Sorry, I do not know family '#1' and can't work with any assoicated family handling. Perhaps you misspelled it?}, + /errors/no such key filter/.code 2 args=\pgfkeys@error{Sorry, there is no such key filter '#1'.}, + /errors/no such key filter handler/.code 2 args=\pgfkeys@error{Sorry, there is no such key filter handler '#1'.}, + % HANDLERS: + % + % .is family should + % 1. '.cd' into the families' path, + % 2. define booleans to activate/deactive the family + % (see \pgfkeysisfamilyactive) + % 3. make sure that \pgfkeyshasactivefamily returns true for + % the family itsself. + /handlers/.is family/.append code={% + %\newif is an \outer macro in plain tex, so this here is not portable: + %\expandafter\newif\csname if\pgfkeyscurrentpath/familyactive\endcsname + \edef\pgfkeyspred@TMP{pgfk@\pgfkeyscurrentpath/familyactive}% + \expandafter\pgfkeys@non@outer@newif\expandafter{\pgfkeyspred@TMP}% + \edef\pgfkeyspred@TMP{\pgfkeyscurrentpath/.belongs to family=\pgfkeyscurrentpath}% + \expandafter\pgfkeysalso\expandafter{\pgfkeyspred@TMP}% + },% + /handlers/.activate family/.code=\pgfkeysactivatefamily{\pgfkeyscurrentpath}, + /handlers/.deactivate family/.code=\pgfkeysdeactivatefamily{\pgfkeyscurrentpath}, + /handlers/.belongs to family/.code={\pgfkeyssetfamily{\pgfkeyscurrentpath}{#1}},% + % + % + % An addition to the '.try' and '.retry' handlers: + % + % It is the same as '.retry', but if the option is still unknown, the + % usual handlers for unknown keys will be invoked. + /handlers/.lastretry/.code={% + \ifpgfkeyssuccess\else + \pgfkeys@try + \ifpgfkeyssuccess\else + % discard the '.lastretry' suffix: + \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% + \pgfkeys@split@path% + \pgfkeys@unknown + \fi + \fi + }, + % + % + /handlers/.install key filter/.code={% + \pgfkeysinstallkeyfilter{\pgfkeyscurrentpath}{#1}% + },% + /handlers/.install key filter handler/.code={% + \pgfkeysinstallkeyfilterhandler{\pgfkeyscurrentpath}{#1}% + },% + % + % + % KEY FILTER HANDLERS: + % + /pgf/key filter handlers/append filtered to/.code={% + % Produce + % '={' '}' + % where both, the key and the value are expanded just ONCE: + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\pgfkeyscurrentkeyRAW\expandafter=\expandafter{\pgfkeyscurrentvalue}}% + \ifx#1\pgfkeys@empty + \else + % Produce ',' '={' '}' + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter#1\expandafter,\the\pgfkeys@tmptoks}% + \fi + \edef#1{\the\pgfkeys@tmptoks}% + },% + /pgf/key filter handlers/ignore/.code={}, + /pgf/key filter handlers/ignore/.install key filter handler, + /pgf/key filter handlers/log/.code={% + \immediate\write16{LOG: the option '\pgfkeyscurrentkey' (was originally '\pgfkeyscurrentkeyRAW') (case \pgfkeyscasenumber) has not been processed due to pgfkeysfiltered.}% + }, + % + % + % KEY FILTER PREDICATES: + % + % Returns true iff the currently processed key belongs to an active family. + % A family is active if it has been activated before. + /pgf/key filters/active families/.code={% + \if\pgfkeyscasenumber0% + % unknown options shall be processed with the + % unknown-handlers. + \pgfkeysfiltercontinuetrue + \else + \if\pgfkeyscasenumber3% + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \else% Ok, it does not belong to any family. + \pgfkeysfiltercontinuefalse + \fi + \fi + },% + % + % + % + % This filter works as follows: + % 1. if the current key belongs to a family: + % return whether its family is active, + % 2. if the current key does NOT belong to a family: + % return the result of criterion '#1', + % 3. the current key is unknown: + % return the result of criterion '#2'. + % + % Arguments: + % #1: the predicate which will be invoked in case 2. + % It will be invoked with the current case number as argument. + % #2: the predicate which will be invoked in case 3 with + % the current case number as argument. + /pgf/key filters/active families or no family/.code 2 args={% + \if\pgfkeyscasenumber0% + \pgfkeysevalkeyfilterwith{#2}% + \else + \if\pgfkeyscasenumber3% + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \else% Ok, it does not belong to any family. + \pgfkeysevalkeyfilterwith{#1}% + \fi + \fi + }, + /pgf/key filters/active families or no family DEBUG/.code 2 args={% + \if\pgfkeyscasenumber0% + \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) invoking unknown handler '#2']}% + \pgfkeysevalkeyfilterwith{#2}% + \else + \if\pgfkeyscasenumber3% + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \ifpgfkeysfiltercontinue + \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) family is ACTIVE]}% + \else + \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) family is NOT active.]}% + \fi + \else% Ok, it does not belong to any family. + \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) invoking has-no-family-handler '#1']}% + \pgfkeysevalkeyfilterwith{#1}% + \fi + \fi + }, + % + % A (faster) shortcut for + % /pgf/key filters/active families or no family= + % {/pgf/keys filters/false} + % {/pgf/keys filters/false} + /pgf/key filters/active families and known/.code={% + \if\pgfkeyscasenumber0% + \pgfkeysfiltercontinuefalse + \else + \if\pgfkeyscasenumber3% + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \else% Ok, it does not belong to any family. + \pgfkeysfiltercontinuefalse + \fi + \fi + }, + % A (faster) shortcut for + % /pgf/key filters/active families or no family= + % {/pgf/key filters/is descendant of=#1}% for keys without family + % {/pgf/keys filters/false} + /pgf/key filters/active families or descendants of/.code={% + \if\pgfkeyscasenumber0% + \pgfkeysfiltercontinuefalse + \else + \if\pgfkeyscasenumber3% + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \else% Ok, it does not belong to any family. + % the 'is descendendant of' implementation has been + % COPY PASTED here: + % + % string prefix comparison: + \def\pgfkeysisdescendantof@impl##1#1##2\pgf@@eov{% + \def\pgfkeyspred@TMP{##1}% + \ifx\pgfkeyspred@TMP\pgfkeys@empty + \pgfkeysfiltercontinuetrue + \else + \pgfkeysfiltercontinuefalse + \fi + }% + \expandafter\pgfkeysisdescendantof@impl\pgfkeyscurrentkey#1\pgf@@eov + \fi + \fi + }, + % + % Processes only options which are childs of #1. + % Example: + % is descendant of/.install key filter=/foo + % will be true for + % /foo/bar/x=y + % /foo/.cd + % /foo/bar/.style=... + % but not for + % /bar/foo/... + /pgf/key filters/is descendant of/.code={% + \if\pgfkeyscasenumber0% +%\message{'\pgfkeyscurrentkey' (case \pgfkeyscasenumber) is UNKNOWN. Calling unknown handler.}% + % unknown options shall be processed with the + % unknown-handlers. + \pgfkeysfiltercontinuetrue + \else + % string prefix comparison: + % [ note : this has been COPY-PASTED to + % |active families or descendants of| ] + \def\pgfkeysisdescendantof@impl##1#1##2\pgf@@eov{% + \def\pgfkeyspred@TMP{##1}% + \ifx\pgfkeyspred@TMP\pgfkeys@empty +%\message{'\pgfkeyscurrentkey' (case \pgfkeyscasenumber) is descendant of '#1': TRUE.}% + \pgfkeysfiltercontinuetrue + \else +%\message{'\pgfkeyscurrentkey' (case \pgfkeyscasenumber) is descendant of '#1': FALSE.}% + \pgfkeysfiltercontinuefalse + \fi + }% + \expandafter\pgfkeysisdescendantof@impl\pgfkeyscurrentkey#1\pgf@@eov + \fi + },% + % + % + % + % Returns true if the currently processed full key equals #2. + /pgf/key filters/equals/.code={% + \if\pgfkeyscasenumber0% + % Unknown option: + \pgfkeysfiltercontinuetrue + \else + \def\pgfkeyspred@TMP{#1}% + \ifx\pgfkeyscurrentkey\pgfkeyspred@TMP + \pgfkeysfiltercontinuetrue + \else + \pgfkeysfiltercontinuefalse + \fi + \fi + },% + % + % + % Argument #1 can be any other (evaluated) filter predicate, its logical return + % value will be inverted. + % Example: + % not/.install key filter={is descendend of=/tikz} + % will install a key filter which evaluates 'is descendant of' with argument '/tikz' and returns the logical negation of the result. + % + /pgf/key filters/not/.code={% + \pgfkeysevalkeyfilterwith{#1}% + \ifpgfkeysfiltercontinue + \pgfkeysfiltercontinuefalse + \else + \pgfkeysfiltercontinuetrue + \fi + },% + /pgf/key filters/and/.code 2 args={% + \pgfkeysevalkeyfilterwith{#1}% + \ifpgfkeysfiltercontinue + \pgfkeysevalkeyfilterwith{#2}% + \fi + },% + /pgf/key filters/or/.code 2 args={% + \pgfkeysevalkeyfilterwith{#1}% + \ifpgfkeysfiltercontinue + \else + \pgfkeysevalkeyfilterwith{#2}% + \fi + },% + /pgf/key filters/true/.code={\pgfkeysfiltercontinuetrue},% + /pgf/key filters/true/.install key filter, + /pgf/key filters/false/.code={% + \pgfkeysfiltercontinuefalse + },% + % + % Returns false if the current key is unknown, which avoids calling + % the unknown handlers. + /pgf/key filters/defined/.code={% + \if\pgfkeyscasenumber0% + \pgfkeysfiltercontinuefalse + \else + \pgfkeysfiltercontinuetrue + \fi + }, +}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Private IMPLEMENTATION +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% This command does THE SAME work as \pgfkeys@case@one, +% but it applies filtering whenever it identified the type of an +% option. +\def\pgfkeys@case@one@filtered{% + \pgfkeys@cur@is@descendant@of@errors + \ifpgfkeysfiltercontinue + \pgfkeys@orig@case@one + \else + \pgfkeysfiltercontinuetrue + \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}{% + % CASE ONE: a command option + \def\pgfkeyscasenumber{1}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + \else +%\message{FILTERED OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi + }{% + % CASE TWO: a normal value option + \pgfkeysifdefined{\pgfkeyscurrentkey}{% + \def\pgfkeyscasenumber{2}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + \pgfkeys@case@two@extern + \else +%\message{FILTEReD OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi + }{% + \pgfkeys@split@path + % CASE THREE: a handler + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% + \pgfkeys@ifexecutehandler{% + \def\pgfkeyscasenumber{3}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + \else +%\message{FILTERED OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi + }{% + \pgfkeys@unknown + }% + }{% + \pgfkeys@unknown + }% + }% + }% + \fi +}% + +\def\pgfkeys@unknown@filtered{% + % CASE ZERO: an unknown option. + \def\pgfkeyscasenumber{0}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + % start normal 'unknown' handlers: + \pgfkeys@orig@unknown + \else +%\message{FILTEReD OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi +} + +% Does the same as \pgfkeys@try, but it also invokes the key filters. +\def\pgfkeys@try@filtered{% + \ifpgfkeysfiltercontinue + \pgfkeys@orig@try + \else + \pgfkeysfiltercontinuetrue + \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% make sure that \pgfkeys@code doesn't know about 'try'. Important for .is choice + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyscurrentpath/.@def}% + {\pgfkeysgetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeyscurrentvalue}} + {}% no default, so leave it + \fi% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% + {% + % CASE ONE: a command option + \def\pgfkeyscasenumber{1}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue + \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% + \else + \pgfkeys@filtered@handler% + \fi + \pgfkeyssuccesstrue% + }% + {% + \pgfkeysifdefined{\pgfkeyscurrentpath}% + {% CASE TWO: a normal value option + \def\pgfkeyscasenumber{2}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \pgfkeysvalueof{\pgfkeyscurrentpath}% + \else% + \pgfkeyslet{\pgfkeyscurrentpath}\pgfkeyscurrentvalue% + \fi% + \else + \pgfkeys@filtered@handler% + \fi + \pgfkeyssuccesstrue% + }% + {% + \pgfkeys@split@path% + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% + % CASE THREE: a handled key + % + % in the standard configuration, this check here is redundand + % because pgfkeys@ifexecutehandler === true. + % It is only interesting for 'handle only existing'. + \pgfkeys@ifexecutehandler{% + \def\pgfkeyscasenumber{3}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + \else +%\message{FILTERED OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi + \pgfkeyssuccesstrue% + }{% + \pgfkeyssuccessfalse + }% + }{% + \pgfkeyssuccessfalse + }% + }% + }% + \fi +} + + +% #1 the code to invoke after init and before cleanup +\def\pgfkeys@install@filter@and@invoke#1{% + \ifpgfkeysfilteringisactive + \pgfkeys@error{Sorry, nested calls to key filtering routines are not allowed. (reason: It is not possible to properly restore the previous filtering state after returning from the nested call)}% + \fi + \pgfkeysfilteringisactivetrue + \let\pgfkeys@case@one=\pgfkeys@case@one@filtered + \let\pgfkeys@try=\pgfkeys@try@filtered + \let\pgfkeys@unknown=\pgfkeys@unknown@filtered + #1% + \let\pgfkeys@case@one=\pgfkeys@orig@case@one + \let\pgfkeys@try=\pgfkeys@orig@try + \let\pgfkeys@unknown=\pgfkeys@orig@unknown + \pgfkeysfilteringisactivefalse +} + + +%-------------------------------------------------- +% \def\pgfkeys@eval@key@filter@subroutine@case@one{% +% \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}{% +% \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% +% \let\pgfkeyspred@TMP=\pgfkeyscurrentvalue +% \pgfkeys@eval@key@filter@subroutine@restorestate +% \expandafter\pgfkeys@code\pgfkeyspred@TMP\pgfeov +% }{% +% \pgfkeysvalueof{/errors/no such key filter/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% +% }% +% } +% % THIS VERSION IS TOO SLOW. See below. +% \def\pgfkeysevalkeyfilterwith#1{% +% \edef\pgfkeys@eval@key@filter@subroutine@restorestate{% +% \noexpand\def\noexpand\pgfkeyscurrentkey{\pgfkeyscurrentkey}% +% \noexpand\def\noexpand\pgfkeyscurrentkeyRAW{\pgfkeyscurrentkeyRAW}% +% \noexpand\def\noexpand\pgfkeyscurrentname{\pgfkeyscurrentname}% +% \noexpand\def\noexpand\pgfkeyscurrentvalue{\pgfkeyscurrentvalue}% +% \noexpand\pgfkeys@pathtoks={\pgfkeyscurrentpath}% +% }% +% \pgfkeysinterruptkeyfilter +% \let\pgfkeys@case@one=\pgfkeys@eval@key@filter@subroutine@case@one +% \pgfkeysalso{#1}% +% \endpgfkeysinterruptkeyfilter% this here also restored \pgfkeys@case@one. +% \pgfkeys@eval@key@filter@subroutine@restorestate +% }% +%-------------------------------------------------- + + +% Evaluates a key filter '#1'. Example: +% \pgfkeysevalkeyfilterwith{/pgf/key filters/equals=/tikz} +% +% \pgfkeysevalkeyfilterwith works only if key filtering is +% active. +% +% The argument '#1' MUST be a FULL KEY. +% +% The implementation employs a subset of the \pgfkeysalso code. +\long\def\pgfkeysevalkeyfilterwith#1{% + \pgfkeys@eval@key@filter@subroutine@unpack#1=\pgfkeysnovalue=\pgfkeys@stop +}% +\long\def\pgfkeys@eval@key@filter@subroutine@unpack#1=#2=#3\pgfkeys@stop{% + \pgfkeys@spdef\pgfkeyspred@TMP{#1}% + \edef\pgfkeyspred@TMP{\pgfkeyspred@TMP}% + \pgfkeys@spdef\pgfkeyspred@TMPB{#2}% TMPB=value + \ifx\pgfkeyspred@TMPB\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyspred@TMP/.@def}% + {\pgfkeysgetvalue{\pgfkeyspred@TMP/.@def}{\pgfkeyspred@TMPB}} + {}% no default, so leave it + \fi% + \ifx\pgfkeyspred@TMPB\pgfkeysvaluerequired% + \pgfkeysvalueof{/errors/value required/.@cmd}\pgfkeyspred@TMP\pgfkeyspred@TMPB\pgfeov% + \else% + \pgfkeysifdefined{\pgfkeyspred@TMP/.@cmd}{% + \pgfkeysgetvalue{\pgfkeyspred@TMP/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyspred@TMPB\pgfeov + }{% + \pgfkeysvalueof{/errors/no such key filter/.@cmd}\pgfkeyspred@TMP\pgfkeyspred@TMPB\pgfeov% + }% + \fi% +} + + +\def\pgfkeys@non@outer@newif@#1#2{% + \expandafter\edef\csname #2true\endcsname{\noexpand\let\noexpand#1=\noexpand\iftrue}% + \expandafter\edef\csname #2false\endcsname{\noexpand\let\noexpand#1=\noexpand\iffalse}% + \csname #2false\endcsname +}% + +% For latex and context, this here has the same effect as a \newif +% applied to 'if#1'. For plain tex, it has also the same effect, but +% it is not an \outer macro as the plain-tex \newif. +\def\pgfkeys@non@outer@newif#1{% + \expandafter\pgfkeys@non@outer@newif@\csname if#1\endcsname{#1}% +} +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex new file mode 100644 index 0000000..8b5784c --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex @@ -0,0 +1,2211 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: So 11. Jan 18:03:19 CET 2015 %%% + + + +% Copyright 2008/2009 by Christian Feuersaenger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU General Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\newif\ifpgfmathfloatparseactive +\newif\ifpgfmathfloat@scaleactive + +% public macro which invokes '#1' if the fpu is installed and ready and '#2' +% otherwise. +\def\pgflibraryfpuifactive#1#2{% + \ifpgfmathfloatparseactive + #1% + \else + #2% + \fi +}% + +\pgfqkeys{/pgf}{ + % enable the FPU parser if it is not yet active + % + % It will be deactivated after the current TeX group + fpu/.is choice, + fpu/true/.code={% + \ifpgfmathfloatparseactive + \else + \pgfutil@ifundefined{pgfmathdeclarefunction}{% + % Ohoh - we are running on a TeX distribution with + % PGF 2.00 which doesn't have the new math engine. + % I can provide special treatment here, provided that + % all float commands are still able to run (that means + % more information needs to be copied from the pgf cvs + % to pgf 2.00 - for example pgfmathfloat.code.tex). + % + % I employ this to work with pgfplots and pgf 2.00 + % using all new features. + \pgfmathfloat@parser@install@pgf@two@null@null% + }{% + \pgfmathfloat@parser@install% + }% + \pgfmathfloatparseactivetrue + % improve compatibility with Marks FP library: + \pgfkeysalso{/pgf/fixed point arithmetic/.prefix style={/pgf/fpu=false}}% + \fi + },% + fpu/false/.code={% + \ifpgfmathfloatparseactive + \pgfmathfloat@uninstall% + \pgfmathfloatparseactivefalse + \fi + },% + fpu/.default=true, + % Use this to introduce a result scaling. + % Every expression in which the prefix '*' occurs + % will be multiplied with the result and converted to fixed point + % representation. + fpu/scale results/.code={% + \ifpgfmathfloatparseactive + \pgfmathparse{#1}% + \else + \pgfmathfloatparsenumber{#1}% + \fi + \let\pgfmathfloatscale=\pgfmathresult% + },% + % determines the output format of each complete expression parsing + % process. If 'scale results' is active, 'fixed' is assumed + % automatically. + fpu/output format/.is choice, + fpu/output format/float/.code= {\let\pgfmathfloatparse@output=\relax}, + fpu/output format/sci/.code= {\def\pgfmathfloatparse@output{\pgfmathfloattosci@{\pgfmathresult}}}, + fpu/output format/fixed/.code= {\def\pgfmathfloatparse@output{\pgfmathfloattofixed@{\pgfmathresult}}}, + fpu/output format/float, + fpu/rel thresh/.code={% + \pgfmathfloatparsenumber{#1}% + \let\pgfmathfloat@relthresh=\pgfmathresult + }, + fpu/rel thresh=1e-4, +} + +\pgfmathfloatcreate{1}{1.0}{0}\let\pgfmathfloatscale=\pgfmathresult + +% This is the replacement parser invocation. +% It does two things which are different to \pgfmathparse: +% 1. it disables any dimension dependand scalings, +% 2. it implements the 'scale results' feature. +\def\pgfmathfloatparse{% + \begingroup% + % disable any dimension-dependant scalings: + \let\pgfmathpostparse=\relax% + \pgfmath@catcodes% + \pgfmath@quickparsefalse% + \pgfmathfloatparse@} + +% for pgf 2.00 : +\def\pgfmathfloatparse@pgf@two@null@null{% + \pgfmath@quickparsefalse% + \pgfmathfloatparse@} + +\def\pgfmathfloatparse@#1{% + \edef\pgfmathfloat@expression{#1}% + \expandafter\pgfmathfloatparse@@\pgfmathfloat@expression\pgfmathfloat@ + \ifpgfmathfloat@scaleactive + \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfmathfloatscale} + \pgfmathfloattofixed{\pgfmathresult}% + \else + \pgfmathfloatparse@output + \fi +} + +\def\pgfmathfloat@char@asterisk{*} +\def\pgfmathfloatparse@@#1#2\pgfmathfloat@{% + \def\pgfmathfloat@test{#1}% + \ifx\pgfmathfloat@test\pgfmathfloat@char@asterisk% + \def\pgfmathfloat@expression{#2}% + \pgfmathfloat@scaleactivetrue + \fi% + \expandafter\pgfmathparse@\expandafter{\pgfmathfloat@expression}% + % \endgroup provided by \pgfpathmarse@end +} + +% Crude handling of file plots +% +\pgfkeys{/pgf/fpu/.cd, + scale file plot x/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscalex{\pgfmathresult*}, + scale file plot y/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscaley{\pgfmathresult*}, + scale file plot z/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscalez{\pgfmathresult*} +} + +\def\pgfmathfloat@uninstall@appendcmd#1{% + \expandafter\gdef\expandafter\pgfmathfloat@uninstall\expandafter{\pgfmathfloat@uninstall #1}% +}% + +% If the uninstall command is already assembled, it will skip the +% uninstall assemblation. +\def\pgfmathfloat@plots@checkuninstallcmd{% + \pgfutil@ifundefined{pgfmathfloat@uninstall}{% + \global\let\pgfmathfloat@uninstall=\pgfutil@empty + }{% + % We already HAVE an uninstall command (prepared globally). + % So: don't waste time assembling one! + \def\pgfmathfloat@uninstall@appendcmd##1{}% + \def\pgfmathfloat@prepareuninstallcmd##1{}% + }% +}% + +% This assembles an uninstall command globally ON FIRST USAGE. +% See \pgfmathfloat@plots@checkuninstallcmd +\def\pgfmathfloat@prepareuninstallcmd#1{% + % and store backup information (globally - I don't want to do that + % all the time when the FPU is used!): + \expandafter\global\expandafter\let\csname pgfmathfloat@backup@\string#1\endcsname=#1% + \expandafter\gdef\expandafter\pgfmathfloat@uninstall\expandafter{\pgfmathfloat@uninstall + \expandafter\let\expandafter#1\csname pgfmathfloat@backup@\string#1\endcsname% + }% +} + +\def\pgfmathfloat@install#1=#2{% + \pgfmathfloat@prepareuninstallcmd{#1}% + \let#1=#2% +} +\def\pgfmathfloat@install@csname#1#2{% + \expandafter\pgfmathfloat@prepareuninstallcmd\csname #1\endcsname% + \pgfutil@namelet{#1}{#2}% +} +\def\pgfmathfloat@install@unimplemented#1{% + \expandafter\pgfmathfloat@prepareuninstallcmd\csname pgfmath@#1@\endcsname% + \expandafter\def\csname pgfmath#1@\endcsname##1{\pgfmathfloat@notimplemented{#1}}% +} +\def\pgfmathfloat@plots@install{% + \let\pgfmathfloatplotscalex=\pgfutil@empty + \let\pgfmathfloatplotscaley=\pgfutil@empty + \let\pgfmathfloatplotscalez=\pgfutil@empty + \pgfmathfloat@install\pgf@parsexyline=\pgfmathfloat@parsexyline% + \pgfmathfloat@install\pgf@parsexyzline=\pgfmathfloat@parsexyzline% +} +\def\pgfmathfloat@parsexyline#1 #2 #3\pgf@stop{% + \edef\pgfmathfloat@marshal{% + \noexpand\pgfplotstreampoint{\noexpand\pgfpointxy{\pgfmathfloatplotscalex#1}{\pgfmathfloatplotscaley#2}}% + }% + \pgfmathfloat@marshal% +} +\def\pgfmathfloat@parsexyzline#1 #2 #3 #4\pgf@stop{% + \edef\pgfmathfloat@marshal{% + \noexpand\pgfplotstreampoint{% + \noexpand\pgfpointxyz{\pgfmathfloatplotscalex#1}{\pgfmathfloatplotscaley#2}{\pgfmathfloatplotscalez#3}% + }% + }% + \pgfmathfloat@marshal% +} + +% +\def\pgfmathfloat@parser@install@functions{% + % Install float commands... + % + \pgfmathfloat@install\pgfmathadd@=\pgfmathfloatadd@% + \pgfmathfloat@install\pgfmathsubtract@=\pgfmathfloatsubtract@% + \pgfmathfloat@install\pgfmathneg@=\pgfmathfloatneg@% + \pgfmathfloat@install\pgfmathmultiply@=\pgfmathfloatmultiply@% + \pgfmathfloat@install\pgfmathdivide@=\pgfmathfloatdivide@% + \pgfmathfloat@install\pgfmathabs@=\pgfmathfloatabs@% + \pgfmathfloat@install\pgfmathsign@=\pgfmathfloatsign@% + \pgfmathfloat@install\pgfmathround@=\pgfmathfloatround@% + \pgfmathfloat@install\pgfmathfloor@=\pgfmathfloatfloor@% + \pgfmathfloat@install\pgfmathmod@=\pgfmathfloatmod@% + \pgfmathfloat@install\pgfmathmax@=\pgfmathfloatmax@% + \pgfmathfloat@install\pgfmathmin@=\pgfmathfloatmin@% + \pgfmathfloat@install\pgfmathsin@=\pgfmathfloatsin@% + \pgfmathfloat@install\pgfmathcos@=\pgfmathfloatcos@% + \pgfmathfloat@install\pgfmathtan@=\pgfmathfloattan@% + \pgfmathfloat@install\pgfmathdeg@=\pgfmathfloatdeg@% + \pgfmathfloat@install\pgfmathrad@=\pgfmathfloatrad@% + \pgfmathfloat@install\pgfmathatan@=\pgfmathfloatatan@% + \pgfmathfloat@install\pgfmathasin@=\pgfmathfloatasin@% + \pgfmathfloat@install\pgfmathacos@=\pgfmathfloatacos@% + \pgfmathfloat@install\pgfmathcot@=\pgfmathfloatcot@% + \pgfmathfloat@install\pgfmathsec@=\pgfmathfloatsec@% + \pgfmathfloat@install\pgfmathcosec@=\pgfmathfloatcosec@% + \pgfmathfloat@install\pgfmathexp@=\pgfmathfloatexp@% + \pgfmathfloat@install\pgfmathln@=\pgfmathfloatln@% + \pgfmathfloat@install@csname{pgfmathlog10@}{pgfmathfloatlog10@}% + \pgfmathfloat@install@csname{pgfmathlog2@}{pgfmathfloatlog2@}% + \pgfmathfloat@install\pgfmathsqrt@=\pgfmathfloatsqrt@% + \pgfmathfloat@install\pgfmath@pi=\pgfmathfloatpi@% + \pgfmathfloat@install\pgfmathpi=\pgfmathfloatpi@% + \pgfmathfloat@install\pgfmathe@=\pgfmathfloate@% + \pgfmathfloat@install\pgfmathe=\pgfmathfloate@% + \pgfmathfloat@install\pgfmathlessthan@=\pgfmathfloatlessthan@% + \pgfmathfloat@install\pgfmathnotless@=\pgfmathfloatnotless@% + \pgfmathfloat@install\pgfmathnotgreater@=\pgfmathfloatnotgreater@% + \pgfmathfloat@install\pgfmathless@=\pgfmathfloatlessthan@% + \pgfmathfloat@install\pgfmathgreaterthan@=\pgfmathfloatgreaterthan@% + \pgfmathfloat@install\pgfmathgreater@=\pgfmathfloatgreaterthan@% + \pgfmathfloat@install\pgfmathifthenelse@=\pgfmathfloatifthenelse@% + \pgfmathfloat@install\pgfmathequal@=\pgfmathfloatequal@% + \pgfmathfloat@install\pgfmathequalto@=\pgfmathfloatequal@% + \pgfmathfloat@install\pgfmathnotequal@=\pgfmathfloatnotequal@% + \pgfmathfloat@install\pgfmathnotequalto@=\pgfmathfloatnotequal@% + \pgfmathfloat@install\pgfmathpow@=\pgfmathfloatpow@ + \pgfmathfloat@install\pgfmathrand@=\pgfmathfloatrand@ + \pgfmathfloat@install\pgfmathrand=\pgfmathfloatrand@ + \pgfmathfloat@install\pgfmathrnd@=\pgfmathfloatrnd@ + \pgfmathfloat@install\pgfmathrnd=\pgfmathfloatrnd@ + \pgfmathfloat@install\pgfmathtrue@=\pgfmathfloattrue@ + \pgfmathfloat@install\pgfmathfalse@=\pgfmathfloatfalse@ + \pgfmathfloat@install\pgfmathnot@=\pgfmathfloatnot@ + \pgfmathfloat@install\pgfmathhex@=\pgfmathfloathex@ + \pgfmathfloat@install\pgfmathHex@=\pgfmathfloatHex@ + \pgfmathfloat@install\pgfmathoct@=\pgfmathfloatoct@ + \pgfmathfloat@install\pgfmathbin@=\pgfmathfloatbin@ + \pgfmathfloat@install\pgfmathand@=\pgfmathfloatand@ + \pgfmathfloat@install\pgfmathor@=\pgfmathfloator@ + \pgfmathfloat@install\pgfmathfactorial@=\pgfmathfloatfactorial@ + \pgfmathfloat@install\pgfmathveclen@=\pgfmathfloatveclen@ + \pgfmathfloat@install\pgfmathcosh@=\pgfmathfloatcosh@ + \pgfmathfloat@install\pgfmathsinh@=\pgfmathfloatsinh@ + \pgfmathfloat@install\pgfmathtanh@=\pgfmathfloattanh@ + \expandafter\pgfmathfloat@install\csname pgfmathatan2@\endcsname=\pgfmathfloatatantwo@ + \pgfmathfloat@install@unimplemented{ceil}% + \pgfmathfloat@install@unimplemented{frac}% + \pgfmathfloat@install@unimplemented{random}% + \pgfmathfloat@install@unimplemented{setseed}% + \pgfmathfloat@install@unimplemented{Mod}% + \pgfmathfloat@install@unimplemented{real}% +% \pgfmathfloat@install@unimplemented{height}% + % + % + \pgfmathfloat@install\pgfmathscientific=\pgfmathfloatscientific% +} + +\def\pgfmathfloat@parser@install{% + \pgfmathfloat@plots@checkuninstallcmd + \pgfmathfloat@plots@install% + \pgfmathfloat@parser@install@functions + % + % + % + % The following methods actually enable the parser to work with + % the internal floating point number representation. + % + % The idea is as follows: + % 1. Every operand must be given in internal float representation. + % 2. The internal float repr can be distinguished by a normal + % number. This is accomplished by introducing a new "exponent" + % token. + % 3. The stack-push-operation checks whether the argument is a + % float. If not, it is parsed properly before pushing it. + \pgfmath@tokens@make{exponent}{\pgfmathfloat@POSTFLAGSCHAR}% + \pgfmathfloat@uninstall@appendcmd{% + \expandafter\let\csname pgfmath@token@exponent@\pgfmathfloat@POSTFLAGSCHAR\endcsname=\relax + }% + \let\pgfmath@basic@parse@exponent=\pgfmath@parse@exponent% + \let\pgfmath@basic@stack@push@operand=\pgfmath@stack@push@operand + \pgfmathfloat@install\pgfmath@stack@push@operand=\pgfmathfloat@stack@push@operand + \pgfmathfloat@install\pgfmath@parse@exponent=\pgfmathfloat@parse@float@or@exponent + % + \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse% + %\pgfmathfloat@install\pgfmathparse@trynumber@token=\pgfmathfloat@parse@trynumber@token + \pgfmathfloat@install\pgfmathparse@expression@is@number=\pgfmathfloat@parse@expression@is@number +}% + +% This here might bring speed improvements... if implemented +% correctly. +% However, this heuristics might fail in cases like "1+1" vs "1e+1" ... +%\def\pgfmathfloat@parse@trynumber@token{numericfpu} +%\pgfmath@tokens@make{numericfpu}{eE+-Y.0123456789} + +\def\pgfmathfloat@parse@expression@is@number{% + \pgfmathfloatparsenumber{\pgfmath@expression}% + \pgfmath@smuggleone\pgfmathresult% + \endgroup + \ignorespaces +}% + +\def\pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG#1{% + \edef\pgfmathfloat@loc@TMPa{% + \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1\endcsname{% + \noexpand\let\noexpand\pgfmath@parsepostgroup\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname% + \noexpand\expandafter\noexpand\pgfmath@parse@}% + \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname{% + \noexpand\expandafter\expandafter\noexpand\csname pgfmath#1@\endcsname\noexpand\expandafter{\noexpand\pgfmathresult}% + \noexpand\pgfmath@postfunction% + }% + }% + \pgfmathfloat@loc@TMPa +}% +\def\pgfmathfloat@parser@install@pgf@two@null@null{% + \pgfmathfloat@plots@checkuninstallcmd + \pgfmathfloat@plots@install% + \pgfmathfloat@parser@install@functions + \let\pgfmathrand@=\pgfmath@basic@rand@ + \let\pgfmathrnd@=\pgfmath@basic@rnd@ + \pgfmathfloat@install\pgfmathmax@=\pgfmathfloatmaxtwo% + \pgfmathfloat@install\pgfmathmin@=\pgfmathfloatmintwo% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{factorial}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{hex}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{bin}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{oct}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{tanh}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{sinh}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{cosh}% + % + % The following methods actually enable the parser to work with + % the internal floating point number representation. + % + % The idea is as follows: + % 1. Every operand must be given in internal float representation. + % 2. The internal float repr can be distinguished by a normal + % number. This is accomplished by introducing a new "exponent" + % token. + % 3. The stack-push-operation checks whether the argument is a + % float. If not, it is parsed properly before pushing it. + \let\pgfmath@basic@parsedecimalpoint=\pgfmath@parsedecimalpoint% + \let\pgfmath@basic@stack@push@operand=\pgfmath@stackpushoperand + \pgfmathfloat@install\pgfmath@stackpushoperand=\pgfmathfloat@stack@push@operand + \pgfmathfloat@install\pgfmath@parsedecimalpoint=\pgfmathfloat@parsedecimalpoint@pgf@two@null@null + \pgfmathfloat@install\pgfmath@endparse=\pgfmathfloat@endparse@pgf@two@null@null + \pgfmathfloat@install\pgfmath@endparsegroup=\pgfmathfloat@endparsegroup@pgf@two@null@null + \pgfmathfloat@install\pgfmath@postfunction=\pgfmathfloat@postfunction@pgf@two@null@null + \pgfmathfloat@install\pgfmath@@parseoperandgroup=\pgfmathfloat@@parseoperandgroup + % + \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse@pgf@two@null@null% +}% + +\pgfutil@ifundefined{pgfmathdeclarefunction}{% + % BACKWARDS COMPATIBILITY: We have PGF 2.00 : + \def\pgfmathdeclarepseudoconstant#1#2{% + \begingroup + \toks0=\expandafter{\csname pgfmath#1@\endcsname}% + \toks1={\pgfmath@postfunction}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \xdef\pgfmathfloat@glob@TMPb{\the\toks0 }% + \endgroup + \expandafter\let\csname pgfmath@parsefunction@#1\endcsname=\pgfmathfloat@glob@TMP + \expandafter\let\csname pgfmath#1\endcsname=\pgfmathfloat@glob@TMPb + \expandafter\def\csname pgfmath#1@\endcsname{#2}% + }% + \let\pgfmathredeclarepseudoconstant=\pgfmathdeclarepseudoconstant +}{% + \pgfutil@ifundefined{pgfmathdeclarepseudoconstant}{% + \def\pgfmathdeclarepseudoconstant#1#2{\pgfmathdeclarefunction*{#1}{0}{#2}} + }{}% +}% + +\pgfmathdeclarepseudoconstant{inf}{\def\pgfmathresult{inf}} +\pgfmathdeclarepseudoconstant{infty}{\def\pgfmathresult{inf}} +\pgfmathdeclarepseudoconstant{nan}{\def\pgfmathresult{nan}} +\pgfmathdeclarepseudoconstant{NaN}{\def\pgfmathresult{nan}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Hacks to the basic level pgf math engine: +% +% WARNING: These methods rely heavily on the internal float representation! +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% for pgf2.00 : +\def\pgfmathfloat@parsedecimalpoint@pgf@two@null@null#1{% + \expandafter\ifx\pgfmathfloat@POSTFLAGSCHAR#1% check whether it is a float + \let\pgfmath@next=\pgfmathfloat@return@float@pgf@two@null@null% + \else + \def\pgfmath@next{\pgfmath@basic@parsedecimalpoint#1}% + \fi + \pgfmath@next +} +% for pgf2.00: +\def\pgfmathfloat@return@float@pgf@two@null@null#1]{% + \edef\pgfmathresult{\the\c@pgfmath@parsecounta\pgfmathfloat@POSTFLAGSCHAR#1]}% + \let\pgfmath@resulttemp=\pgfmathresult + \pgfmath@parseoperator% +}% +% for pgf2.00: +\def\pgfmathfloat@endparse@pgf@two@null@null#1\pgfmath@empty{% + \pgfmath@processalloperations% + \pgfmath@stackpop{\pgfmathresult}% + % delete the final unit scalings + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup% + \ignorespaces% +} +% for pgf2.00: +\def\pgfmathfloat@endparsegroup@pgf@two@null@null{% + \pgfmath@processalloperations% + \pgfmath@stackpop{\pgfmathresult}% + % eliminated register usage here... + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup% + \pgfmath@parsepostgroup% +} +% for pgf2.00: +\def\pgfmathfloat@postfunction@pgf@two@null@null{% + \let\pgfmath@parsepostgroup\pgfmath@parseoperator% + \ifnum\pgfmath@sign1<0 + \pgfmathfloatneg@{\pgfmathresult}% + \let\pgfmath@sign\pgfutil@empty + \fi + \pgfmath@parseoperator} +% for pgf2.00: +\def\pgfmathfloat@@parseoperandgroup{% + \let\pgfmath@postparsegroup\pgfmath@parseoperator% + \ifnum\pgfmath@sign1<0 + \pgfmathfloatneg@{\pgfmathresult}% + \let\pgfmath@sign\pgfutil@empty + \fi + \pgfmath@parseoperator% +} + + + + + + +% PRECONDITION: +% either +% e +% ^ +% -> read the exponent. +% or +% \pgfmathfloat@POSTFLAGSCHAR +% ^ +% -> we have a parsed floating point number -> read it. +\def\pgfmathfloat@parse@float@or@exponent{% + \if\pgfmath@token \pgfmathfloat@POSTFLAGSCHAR% + % Ok, we actually HAVE a pre-parsed floating point number! + % Return it. + \expandafter\pgfmathfloat@return@float\expandafter\pgfmath@token@next + \else + % We have a standard number in scientific format. Parse it. + \expandafter\pgfmath@basic@parse@exponent + \fi +}% +\def\pgfmathfloat@return@float#1]{% + \edef\pgfmathresult{\pgfmath@number \pgfmathfloat@POSTFLAGSCHAR#1]}% + \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}% + \pgfmath@parse@@operator% +}% + +% This extends the functionality of the basic level operand stack: it +% assures every element on the stack is a float. +\def\pgfmathfloat@stack@push@operand#1{% + \pgfutil@ifnextchar\bgroup{% + \let\pgfmathfloat@stack@push@operand@list@=\pgfutil@empty + \pgfmathfloat@stack@push@operand@list + }{% + \pgfmathfloat@stack@push@operand@single + }% + #1\relax +}% +\def\pgfmathfloat@stack@push@operand@single#1\relax{% + \expandafter\pgfutil@in@\pgfmathfloat@POSTFLAGSCHAR{#1}% + \ifpgfutil@in@ + \pgfmath@basic@stack@push@operand{#1}% + \else + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}% + \fi +}% +\def\pgfmathfloat@stack@push@operand@GOBBLE#1\relax{}% +\def\pgfmathfloat@stack@push@operand@list#1{% + \expandafter\pgfutil@in@ \pgfmathfloat@POSTFLAGSCHAR{#1}% + \ifpgfutil@in@ + \expandafter\def\expandafter\pgfmathfloat@stack@push@operand@list@\expandafter{% + \pgfmathfloat@stack@push@operand@list@{#1}% + }% + \else + \pgfmathfloatparsenumber{#1}% + \begingroup + \toks0=\expandafter{\pgfmathfloat@stack@push@operand@list@}% + \toks1=\expandafter{\pgfmathresult}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 {\the\toks1}}% + \endgroup + \let\pgfmathfloat@stack@push@operand@list@=\pgfmathfloat@glob@TMP + \fi + \pgfutil@ifnextchar\relax{% + \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathfloat@stack@push@operand@list@}% + \pgfmathfloat@stack@push@operand@GOBBLE + }{% + \pgfmathfloat@stack@push@operand@list + }% +}% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% --- END --- Hacks to the basic level pgf math engine +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Here starts the implementation of the floating point +% routines. +% +% They can be used even if the FPU parser is not active. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Remember the basic math commands. They will be invoked as subroutines in floating point routines. +\let\pgfmath@basic@add@=\pgfmathadd@ +\let\pgfmath@basic@subtract@=\pgfmathsubtract@ +\let\pgfmath@basic@multiply@=\pgfmathmultiply@ +\let\pgfmath@basic@divide@=\pgfmathdivide@ +\let\pgfmath@basic@reciprocal@=\pgfmathreciprocal@ +\let\pgfmath@basic@abs@=\pgfmathabs@ +\let\pgfmath@basic@round@=\pgfmathround@ +\let\pgfmath@basic@rand@=\pgfmathrand@ +\let\pgfmath@basic@rnd@=\pgfmathrnd@ +\let\pgfmath@basic@setseed@=\pgfmathsetseed@ +\let\pgfmath@basic@random@=\pgfmathrandom@ +\let\pgfmath@basic@floor@=\pgfmathfloor@ +\let\pgfmath@basic@ceil@=\pgfmathceil@ +\let\pgfmath@basic@mod@=\pgfmathmod@ +\let\pgfmath@basic@max@=\pgfmathmax@ +\let\pgfmath@basic@min@=\pgfmathmin@ +\let\pgfmath@basic@sin@=\pgfmathsin@ +\let\pgfmath@basic@cos@=\pgfmathcos@ +\let\pgfmath@basic@tan@=\pgfmathtan@ +\let\pgfmath@basic@deg@=\pgfmathdeg@ +\let\pgfmath@basic@rad@=\pgfmathrad@ +\let\pgfmath@basic@atan@=\pgfmathatan@ +\let\pgfmath@basic@asin@=\pgfmathasin@ +\let\pgfmath@basic@acos@=\pgfmathacos@ +\let\pgfmath@basic@cot@=\pgfmathcot@ +\let\pgfmath@basic@sec@=\pgfmathsec@ +\let\pgfmath@basic@cosec@=\pgfmathcosec@ +\let\pgfmath@basic@pow@=\pgfmathpow@ +\let\pgfmath@basic@exp@=\pgfmathexp@ +\let\pgfmath@basic@ln@=\pgfmathln@ +\let\pgfmath@basic@sqrt@=\pgfmathsqrt@ +\let\pgfmath@basic@@pi=\pgfmath@pi +\let\pgfmath@basic@veclen@=\pgfmathveclen@ +\let\pgfmath@basic@e@=\pgfmathe@ +\let\pgfmath@basic@lessthan@=\pgfmathlessthan@ +\let\pgfmath@basic@greaterthan@=\pgfmathgreaterthan@ +\let\pgfmath@basic@equalto@=\pgfmathequalto@ +\let\pgfmath@basic@equal@=\pgfmathequal@ +\let\pgfmath@basic@true@=\pgfmathtrue@ +\let\pgfmath@basic@false@=\pgfmathfalse@ + +\def\pgfmathfloatscientific#1#2{% + \edef\pgfmathresult{#1e#2}% + \expandafter\pgfmathfloatparsenumber\expandafter{\pgfmathresult}% +} +% Compares #1 with #2 and sets \pgfmathresult either to 1.0 or 0.0. +% +% It also sets the boolean \ifpgfmathfloatcomparison (globally). +\def\pgfmathfloatlessthan@#1#2{% +%\def\pgfmathfloatlessthan#1#2#3\and#4#5#6{% + \global\pgfmathfloatcomparisonfalse + \begingroup + \edef\pgfmathfloat@loc@TMPa{#1}% + \edef\pgfmathfloat@loc@TMPb{#2}% + \expandafter\pgfmathfloat@decompose\pgfmathfloat@loc@TMPa\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E + \expandafter\pgfmathfloat@decompose\pgfmathfloat@loc@TMPb\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E + \ifcase\pgfmathfloat@a@S + % x = 0 -> (x y >0) + \ifcase\pgfmathfloat@b@S + % y = 0 + \or% y > 0 + \global\pgfmathfloatcomparisontrue + \or% y < 0 + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty + \fi + \or + % x > 0 -> (x ( y > 0 && |x| < |y|) ) + \ifcase\pgfmathfloat@b@S + % y = 0 + \or% y>0: + \pgfmathfloatlessthan@positive + \or% y < 0 + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty + \fi + \or + % x < 0 -> (x (y >= 0 || |x| > |y|) ) + \ifcase\pgfmathfloat@b@S + % y = 0 + \global\pgfmathfloatcomparisontrue + \or%y > 0 + \global\pgfmathfloatcomparisontrue + \or% 'y<0': + \pgfmathfloatgreaterthan@positive + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty + \fi + \or + % x = nan. + \or + % x = +infty + \or + % x = -infty + \ifnum\pgfmathfloat@b@S=3 + \else + \global\pgfmathfloatcomparisontrue + \fi + \fi + \endgroup + \ifpgfmathfloatcomparison + \def\pgfmathresult{1.0}% + \else + \def\pgfmathresult{0.0}% + \fi +} +\let\pgfmathfloatlessthan=\pgfmathfloatlessthan@ +\let\pgfmathfloatless@=\pgfmathfloatlessthan@ + +% ! (#1 < #2) <=> (#1 >= #2) +\def\pgfmathfloatnotless@#1#2{% + \pgfmathfloatless@{#1}{#2}% + \ifpgfmathfloatcomparison + \def\pgfmathresult{0.0}% + \else + \def\pgfmathresult{1.0}% + \fi +}% +% ! (#1 > #2) <=> (#1 <= #2) +\def\pgfmathfloatnotgreater@#1#2{% + \pgfmathfloatless@{#2}{#1}% + \ifpgfmathfloatcomparison + \def\pgfmathresult{0.0}% + \else + \def\pgfmathresult{1.0}% + \fi +}% + +% compares \pgfmathfloat@a@[SME] < \pgfmathfloat@b@[SME] +\def\pgfmathfloatlessthan@positive{% + \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E + \global\pgfmathfloatcomparisontrue + \else + \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E + \ifdim\pgfmathfloat@a@M<\pgfmathfloat@b@M + \global\pgfmathfloatcomparisontrue + \fi + \fi + \fi +} + +% compares \pgfmathfloat@a@[SME] > \pgfmathfloat@b@[SME] +\def\pgfmathfloatgreaterthan@positive{% + \ifnum\pgfmathfloat@a@E>\pgfmathfloat@b@E + \global\pgfmathfloatcomparisontrue + \else + \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E + \ifdim\pgfmathfloat@a@M>\pgfmathfloat@b@M + \global\pgfmathfloatcomparisontrue + \fi + \fi + \fi +} + + +\def\pgfmathfloatgreaterthan@#1#2{\pgfmathfloatlessthan@{#2}{#1}} +\let\pgfmathfloatgreaterthan=\pgfmathfloatgreaterthan@ +\let\pgfmathfloatgreater@=\pgfmathfloatgreaterthan@ + +\def\pgfmathfloatmax@#1{% + \begingroup + \pgfmathfloatcreate{2}{1.0}{2147483644}% + \let\pgfmathmaxsofar=\pgfmathresult + \pgfmathfloatmax@@#1{}% +}% +\def\pgfmathfloatmax@@#1{% + \def\pgfmath@temp{#1}% + \ifx\pgfmath@temp\pgfmath@empty% + \expandafter\pgfmathfloatmax@@@% + \else% + \pgfmathfloatlessthan{\pgfmathmaxsofar}{#1}% + \ifpgfmathfloatcomparison + \edef\pgfmathmaxsofar{#1}% + \fi + \expandafter\pgfmathfloatmax@@% + \fi% +}% +\def\pgfmathfloatmax@@@{% + \let\pgfmathresult=\pgfmathmaxsofar + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup +}% +\def\pgfmathfloatmin@#1{% + \begingroup + \pgfmathfloatcreate{1}{1.0}{2147483644}% + \let\pgfmathminsofar=\pgfmathresult + \pgfmathfloatmin@@#1{}% +}% +\def\pgfmathfloatmin@@#1{% + \def\pgfmath@temp{#1}% + \ifx\pgfmath@temp\pgfmath@empty% + \expandafter\pgfmathfloatmin@@@% + \else% + \pgfmathfloatlessthan{#1}{\pgfmathminsofar}% + \ifpgfmathfloatcomparison + \edef\pgfmathminsofar{#1}% + \fi + \expandafter\pgfmathfloatmin@@% + \fi% +}% +\def\pgfmathfloatmin@@@{% + \let\pgfmathresult=\pgfmathminsofar + \pgfmath@smuggleone{\pgfmathresult}% + \endgroup +}% + +\def\pgfmathfloatmaxtwo#1#2{% + \pgfmathfloatlessthan{#1}{#2}% + \ifpgfmathfloatcomparison + \edef\pgfmathresult{#2}% + \else + \edef\pgfmathresult{#1}% + \fi +} +\let\pgfmathfloatmax=\pgfmathfloatmaxtwo + +\def\pgfmathfloatmintwo#1#2{% + \pgfmathfloatlessthan{#1}{#2}% + \ifpgfmathfloatcomparison + \edef\pgfmathresult{#1}% + \else + \edef\pgfmathresult{#2}% + \fi +} +\let\pgfmathfloatmin=\pgfmathfloatmintwo + +% Renormalizes #1 to extended precision mantisse, meaning +% 100 <= m < 1000 +% instead of 1 <= m < 10. +% +% The 'extended precision' means we have higher accuracy when we apply pgfmath operations to mantissas. +% +% The input argument is expected to be a normalized floating point number; the output argument is a non-normalized floating point number (well, normalized to extended precision). +% +% The operation is supposed to be very fast. +% +% @see \pgfmathfloatsetextprecision +% +% There is a routine for internal usage, +% \pgfmathfloattoextentedprecision@a. It also provides exponent and +% sign of #1 in output arguments and may be used to increase speed. +\def\pgfmathfloattoextentedprecision#1{% + \begingroup + \pgfmathfloattoextentedprecision@a{#1}% + \pgfmathfloatcreate{\pgfmathfloat@a@S}{\pgfmathresult}{\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\def\pgfmathfloattoextentedprecision@@zero#1\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1}% +}% +\def\pgfmathfloattoextentedprecision@@one#1.#2#3\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1#2.#3}% +}% +\def\pgfmathfloattoextentedprecision@@two#1.#2#3#4\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1#2#3.#4}% +}% +\def\pgfmathfloattoextentedprecision@@three#1.#2#3#4#5\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1#2#3#4.#5}% +}% + +% Sets extended precision to 10^#1. +% +% The different choices are +% +% - 0: normalization 0 <= m < 1 (disable extended precision) +% - 1: normalization 10 <= m < 100 +% - 2: normalization 100 <= m < 1000 (default) +% - 3: normalization 1000 <= m < 10000 +% +% #1 is the exponent, #1 = 0,1,2 or 3. +% +% This setting applies to \pgfmathfloattoextentedprecision and friends. +\def\pgfmathfloatsetextprecision#1{% + \ifcase#1\relax + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@zero + \def\pgfmathfloatextprec@shift{0}% + \or + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@one + \def\pgfmathfloatextprec@shift{1}% + \or + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@two + \def\pgfmathfloatextprec@shift{2}% + \else + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@three + \def\pgfmathfloatextprec@shift{3}% + \fi +}% +\pgfmathfloatsetextprecision{2}% + +% Does the "hard" work for \pgfmathfloattoextentedprecision. It +% provides additional outputs. +% +% INPUT: +% #1 normalized floating point number. Maybe a macro (it will be expanded ONCE) +% +% OUTPUT: +% - \pgfmathresult : the mantisse in extended precision +% - \pgfmathfloat@a@S : the sign of #1 +% - \pgfmathfloat@a@E : the exponent of #1, adjusted for extended precision +% - \pgfmathfloat@a@Mtok : undefined (its contents will be destroyed. +% +\def\pgfmathfloattoextentedprecision@a#1{% + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@S<3 + \advance\pgfmathfloat@a@E by-\pgfmathfloatextprec@shift\relax% compensate for shift + \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 000\pgfmathfloat@EOI + \fi +}% + + +% Similar to \pgfmathfloattoextentedprecision@a, this one here fills the '@b' registers. +\def\pgfmathfloattoextentedprecision@b#1{% + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E + \ifnum\pgfmathfloat@b@S<3 + \advance\pgfmathfloat@b@E by-\pgfmathfloatextprec@shift\relax + \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 00\pgfmathfloat@EOI + \fi +}% + +% Addition of two floating point numbers using 8 significant digits. +\def\pgfmathfloatadd@#1#2{% + \begingroup + % + % renormalize argument to 100 <= m < 1000 for extended accuracy: + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloattoextentedprecision@b{#2}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + \edef\pgfmathresult{#2}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}% + \fi + \ifcase\pgfmathfloat@b@S + \edef\pgfmathresult{#1}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@argb{-\pgfmathfloat@argb}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}% + \fi + \ifpgfmathfloatcomparison + % Shift lesser mantisse to fit the larger one: + \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E + \pgfmathfloatadd@shift{\pgfmathfloat@arga}{\pgfmathfloat@a@E}{\pgfmathfloat@b@E}% + \else + \pgfmathfloatadd@shift{\pgfmathfloat@argb}{\pgfmathfloat@b@E}{\pgfmathfloat@a@E}% + \fi + % add them! + \pgfmath@basic@add@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% #1= floating point number +% #2= TeX code to execute if #1 == 0 +% #3= TeX code to execute if #1 != 0 +\def\pgfmathfloatifzero#1#2#3{% + \pgfmathfloatgetflagstomacro{#1}\pgfmathfloat@loc@TMPa + \if\pgfmathfloat@loc@TMPa0 #2\else#3\fi +}% + +\def\pgfmathfloatiffinite#1#2#3{% + \pgfmathfloatgetflagstomacro{#1}\pgfmathfloatiffinite@ + \ifnum\pgfmathfloatiffinite@>2 #3\else #2\fi +}% + +\def\pgfmathfloatifthenelse@#1#2#3{% + \pgfmathfloatifflags{#1}{0}{% + \edef\pgfmathresult{#3}%% + }{% + \edef\pgfmathresult{#2}% + }% +} +\def\pgfmathfloatequal@#1#2{% + \pgfmathfloatifapproxequalrel{#1}{#2}{% + \def\pgfmathresult{1}% + \pgfmathfloatcomparisontrue + }{% + \def\pgfmathresult{0}% + \pgfmathfloatcomparisonfalse + }% +} +\let\pgfmathfloatequalto@=\pgfmathfloatequal@ + +\def\pgfmathfloatnotequal@#1#2{% + \pgfmathfloatifapproxequalrel{#1}{#2}{% + \def\pgfmathresult{0}% + \pgfmathfloatcomparisonfalse + }{% + \def\pgfmathresult{1}% + \pgfmathfloatcomparisontrue + }% +} +\let\pgfmathfloatnotequalto@=\pgfmathfloatnotequal@ + +% Computes the relative error between #1 and #2 (assuming #2 != 0) and +% invokes #3 if the relative error is below `/pgf/fpu/rel thresh' and +% #4 if that is not the case. +\long\def\pgfmathfloatifapproxequalrel#1#2#3#4{% + \begingroup + \pgfmathfloatparsenumber{#1}% + \let\pgfmathfloatarga=\pgfmathresult + \pgfmathfloatparsenumber{#2}% + \let\pgfmathfloatargb=\pgfmathresult + \pgfmathfloatrelerror@\pgfmathfloatarga\pgfmathfloatargb + \let\pgfmathfloatarga=\pgfmathresult + \pgfmathfloatlessthan@\pgfmathfloatarga\pgfmathfloat@relthresh + \ifpgfmathfloatcomparison + \def\pgfmathfloat@loc@TMPa{#3}% + \else + \def\pgfmathfloat@loc@TMPa{#4}% + \fi + \expandafter\endgroup + \pgfmathfloat@loc@TMPa +}% + +% Invokes code '#3' if the flags of the floating point number '#1' +% match the flag provided in '#2'. +% +% \pgfmathfloatcreate{1}{1.0}{2} +% \pgfmathfloatifflags{\pgfmathresult}{0}{It's zero!}{It's not zero!}% +% \pgfmathfloatifflags{\pgfmathresult}{1}{It's positive!}{It's not positive!}% +% \pgfmathfloatifflags{\pgfmathresult}{2}{It's negative!}{It's not negative!}% +% or, equivalently +% \pgfmathfloatifflags{\pgfmathresult}{+}{It's positive!}{It's not positive!}% +% \pgfmathfloatifflags{\pgfmathresult}{-}{It's negative!}{It's not negative!}% +% it also supports #2=u which means 'unbounded' +\def\pgfmathfloatifflags#1#2#3#4{% + \if#2-% + \pgfmathfloatifflags{#1}{2}{#3}{#4}% + \else + \if#2+% + \pgfmathfloatifflags{#1}{1}{#3}{#4}% + \else + \pgfmathfloatgetflagstomacro{#1}\pgfmathfloat@loc@TMPa + \if#2u% + \ifnum\pgfmathfloat@loc@TMPa>2 + #3\relax + \else + #4\relax + \fi + \else + \if\pgfmathfloat@loc@TMPa#2% + #3\relax + \else + #4\relax + \fi + \fi + \fi + \fi +}% + +% #1=mantisse which needs to be shifted (with smaller exponent) +% #2=smaller exponent +% #3=larger exponent +% +% ATTENTION: this helper method DESTROYS contents of \pgfmathfloat@a@S. +\def\pgfmathfloatadd@shift#1#2#3{% + \pgf@xa=#1 pt% + \pgfmathfloat@a@S=#3\relax + \advance\pgfmathfloat@a@S by-#2\relax + \ifcase\pgfmathfloat@a@S + \or + \divide\pgf@xa by10\relax + \or + \divide\pgf@xa by100\relax + \or + \divide\pgf@xa by1000\relax + \or + \divide\pgf@xa by10000\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by10\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by100\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by1000\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by10000\relax + \else + \pgf@xa=0pt% + \fi + #2=#3\relax + \edef#1{\pgf@sys@tonumber\pgf@xa}% +} + +\let\pgfmathfloatadd=\pgfmathfloatadd@ + + +% Subtracts two floating point numbers. +\def\pgfmathfloatsubtract@#1#2{% + \begingroup + \edef\pgfmathresult{#2}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E + \ifcase\pgfmathfloat@b@S + \edef\pgfmathresult{#1}% + \or + \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}% + \let\pgfmathfloatsub@arg=\pgfmathresult + \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}% + \or + \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}% + \let\pgfmathfloatsub@arg=\pgfmathresult + \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}% + \else + \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\let\pgfmathfloatsubtract=\pgfmathfloatsubtract@ + +% Scales a floating point number #1 with a fixed point number #2 using pgfmathmultiply. +% +% Use this method if #2 is small number. +\def\pgfmathfloatmultiplyfixed@#1#2{% + \begingroup + % + % renormalize argument to 100 <= m < 1000 for extended accuracy: + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + \edef\pgfmathresult{#1}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}% + \fi + \ifpgfmathfloatcomparison + \pgfmath@basic@multiply@{\pgfmathfloat@arga}{#2}% + % renormalize product. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\let\pgfmathfloatmultiplyfixed=\pgfmathfloatmultiplyfixed@ + + +\def\pgfmathfloatmultiply@#1#2{% + \begingroup + \pgfmathfloatsetextprecision{1}% + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloattoextentedprecision@b{#2}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + % 0 + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% + + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{1}% + \or + \def\pgfmathresult@S{2}% + \else + \expandafter\pgfmathfloatcreate\the\pgfmathfloat@b@S{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% - + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{2}% + \or + \def\pgfmathresult@S{1}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% nan + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% +infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% -infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \fi + \ifpgfmathfloatcomparison + \pgfmath@basic@multiply@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatmultiply=\pgfmathfloatmultiply@ + +% Defines \pgfmathresult to be #1 / #2 for two floating point numbers. +% +% It employs the basic math engine internally to divide mantissas. +\def\pgfmathfloatdivide@#1#2{% + \begingroup + \pgfmathfloatsetextprecision{1}% is not too important, I think. After all, 0.1 <= #1/#2 < 10 or so due to normalization (no matter, which) + \edef\pgfmathfloat@arga{#1}% + \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \edef\pgfmathfloat@argb{#2}% + \pgfmathfloattoextentedprecision@b{\pgfmathfloat@argb}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + % 0 + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% + + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{1}% + \or + \def\pgfmathresult@S{2}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \else + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% - + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{2}% + \or + \def\pgfmathresult@S{1}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \else + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% nan + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% +infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% what is inf/inf ? + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% or inf/-inf ? + \pgfmathfloatcomparisonfalse + \fi + \or% -infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \fi + \ifpgfmathfloatcomparison + \pgfmath@basic@divide@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + \advance\pgfmathfloat@a@E by-\pgfmathfloat@b@E + % renormalize. This is the only part were an expensive float routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + % And re-insert the proper sign: + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatdivide=\pgfmathfloatdivide@ + +\def\pgfmathfloatreciprocal@#1{% + \begingroup + % FIXME optimize + \edef\pgfmathfloat@loc@TMPa{#1}% + \pgfmathfloatcreate{1}{1.0}{0}% + \pgfmathfloatdivide@{\pgfmathresult}{\pgfmathfloat@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% Computes sqrt(#1) in floating point arithmetics. +% +% It employs sqrt( m * 10^e ) = sqrt(m) * sqrt(10^e). +\def\pgfmathfloatsqrt@#1{% + \begingroup + \pgfmathfloatsetextprecision{3}% + \edef\pgfmathfloat@arga{#1}% + \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \ifcase\pgfmathfloat@a@S + % 0 + \pgfmathfloatcreate{0}{0.0}{0}% + \or% + + \pgfmath@basic@sqrt@{\pgfmathfloat@arga}% + \ifodd\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@E>0 + \expandafter\pgfmath@basic@multiply@\expandafter{\pgfmathresult}{3.16227766}% * sqrt(10) + \else + \expandafter\pgfmath@basic@multiply@\expandafter{\pgfmathresult}{0.316227766}% * sqrt(0.1) + \fi + \fi + \divide\pgfmathfloat@a@E by2 % sqrt(10^e) = 10^{e/2} (see above for odd e) + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathfloat@arga{\pgfmathresult e\the\pgfmathfloat@a@E}% + \pgfmathfloatqparsenumber{\pgfmathfloat@arga}% + \or% - + \pgfmathfloatcreate{3}{0.0}{0}% + \or% nan + \pgfmathfloatcreate{3}{0.0}{0}% + \or% +infty + \pgfmathfloatcreate{4}{0.0}{0}% + \or% -infty + \pgfmathfloatcreate{3}{0.0}{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatsqrt=\pgfmathfloatsqrt@ + +% Returns the integer part of the floating point number #1. +% +% The result is returned as floating point as well. +% +% This operation is not limited to TeX's range of count registers (it +% works symbolly) +% +% @see \pgfmathfloattoint +\def\pgfmathfloatint@#1{% + \begingroup + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + % 0: nothing to do. + \or% + + \expandafter\pgfmathfloatint@@\the\pgfmathfloat@a@Mtok\pgfmathfloat@EOI + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or% - + \expandafter\pgfmathfloatint@@\the\pgfmathfloat@a@Mtok\pgfmathfloat@EOI + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \else + % nothing to do + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloatint@@#1.{% + \ifnum\pgfmathfloat@a@E<0 + \pgfmathfloat@a@S=0 + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0 + \expandafter\pgfmathfloatint@@loop@gobble + \else + \pgfmathfloat@a@Mtok={#1.}% + \pgfmathfloat@b@E=\pgfmathfloat@a@E + \expandafter\pgfmathfloatint@@loop + \fi +}% +\def\pgfmathfloatint@@loop#1{% + \def\pgfmathfloatint@@loop@{#1}% + \ifx\pgfmathfloatint@@loop@\pgfmathfloat@EOI + \let\pgfmathfloatint@@loop@next=\relax + \else + \ifnum\pgfmathfloat@b@E=0 + \let\pgfmathfloatint@@loop@next=\pgfmathfloatint@@loop@gobble + \else + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \advance\pgfmathfloat@b@E by-1 + \let\pgfmathfloatint@@loop@next=\pgfmathfloatint@@loop + \fi + \fi + \pgfmathfloatint@@loop@next +}% +\def\pgfmathfloatint@@loop@gobble#1\pgfmathfloat@EOI{}% +\let\pgfmathfloatint=\pgfmathfloatint@ +\let\pgfmathfloatfloor=\pgfmathfloatint +\let\pgfmathfloatfloor@=\pgfmathfloatint@ + +\def\pgfmathfloat@notimplemented#1{% + \pgfmath@error{Sorry, the operation '#1' has not yet been implemented in the floating point unit :-(}{}% + \pgfmathfloatcreate{0}{0.0}{0}% +}% + +% Divides or multiplies the input number by 10^#4 using an arithmetic +% left/right shift. +% +% Input: +% #1 a normalised floating point number. +% #2 a positive or negative integer number denoting the shift. +% +% Example: +% \pgfmathfloatshift{11e3}{4}% +% -> pgfmathresult = 11e7 +\def\pgfmathfloatshift@#1#2{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \advance\pgfmathfloat@a@E by#2\relax + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloatshift=\pgfmathfloatshift@ + +% Defines \pgfmathresult to be |#1|, the absolute value of the +% normalized floating point number #1. +\def\pgfmathfloatabs@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + % 0: do nothing. + \or + % +: ok, is positive. + \or + % -: multiply with -1: + \pgfmathfloat@a@S=1 + \or + % nan: do nothing. + \or + % +infty: ok. + \or + % -infty: multiply with -1: + \pgfmathfloat@a@S=4 + \fi + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +% +% Defines \pgfmathresult to be sign(#1) +\def\pgfmathfloatsign@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + % 0: + \pgfmathfloatcreate{0}{0.0}{0}% + \or + % +: ok, is positive. + \pgfmathfloatcreate{1}{1.0}{0}% + \or + % -: + \pgfmathfloatcreate{2}{1.0}{0}% + \or + % nan: do nothing. + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or + % +infty:. + \pgfmathfloatcreate{1}{1.0}{0}% + \or + % -infty: + \pgfmathfloatcreate{2}{1.0}{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatsign=\pgfmathfloatsign@ + +% Computes the absolute error |#1 - #2| into \pgfmathresult. +\def\pgfmathfloatabserror@#1#2{% + \pgfmathfloatsubtract@{#1}{#2}% + \pgfmathfloatabs@{\pgfmathresult}% +}% +\let\pgfmathfloatabserror=\pgfmathfloatabserror@ + +% Computes the relative error |#1 - #2|/|#2| into \pgfmathresult, +% assuming #2 != 0. +\def\pgfmathfloatrelerror@#1#2{% + \pgfmathfloatsubtract@{#1}{#2}% + \let\pgfmathfloat@subtract=\pgfmathresult + \pgfmathfloatifflags{#2}{0}{% + \let\pgfmathresult=\pgfmathfloat@subtract + }{% + \pgfmathfloatdivide@{\pgfmathfloat@subtract}{#2}% + }% + \pgfmathfloatabs@{\pgfmathresult}% +}% +\let\pgfmathfloatrelerror=\pgfmathfloatrelerror@ + +% Computes \pgfmathresult = #1 mod #2 using truncated division. +% +\def\pgfmathfloatmod@#1#2{% + \begingroup + \pgfmathfloatdivide@{#1}{#2}% + \pgfmathfloatint@{\pgfmathresult}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloatmod=\pgfmathfloatmod@ + + +% A modification of \pgfmathfloatmod@ where #3 = 1/#2 is already +% known. This may be faster. +\def\pgfmathfloatmodknowsinverse@#1#2#3{% + \begingroup + \pgfmathfloatmultiply@{#1}{#3}% + \pgfmathfloatint@{\pgfmathresult}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloatmodknowsinverse=\pgfmathfloatmodknowsinverse@ + +\def\pgfmathfloatpi@{% + \pgfmathfloatcreate{1}{3.14159265358979}{0}% +}% +\let\pgfmathfloatpi=\pgfmathfloatpi@ + +\def\pgfmathfloate@{% + \pgfmathfloatcreate{1}{2.71828182845905}{0}% +} +\let\pgfmathfloate=\pgfmathfloate@ + +% Converts #1 from radians to degrees. +\def\pgfmathfloatdeg@#1{% + \expandafter\ifx\csname pgfmfltdeg@factor\endcsname\relax + % Lazy evaluation: + \pgfmathfloatcreate{1}{5.72957795130823}{1}% + \global\let\pgfmfltdeg@factor=\pgfmathresult + \fi + \pgfmathfloatmultiply@{#1}\pgfmfltdeg@factor% +} +\let\pgfmathfloatdeg=\pgfmathfloatdeg@ + +% Converts #1 from degree to radians. +\def\pgfmathfloatrad@#1{% + \expandafter\ifx\csname pgfmfltrad@factor\endcsname\relax + % Lazy evaluation: + \pgfmathfloatcreate{1}{1.74532925199433}{-2}% + \global\let\pgfmfltrad@factor=\pgfmathresult + \fi + \pgfmathfloatmultiply@{#1}\pgfmfltrad@factor% +} +\let\pgfmathfloatrad=\pgfmathfloatrad@ + +% Computes #1(#2) where #1 is a trigonometric function, i.e. +% #1(#2) = #1( #2 + r*360 ) +% +% #1 is a one-argument macro which assigns \pgfmathresult. +\def\pgfmathfloatTRIG@#1#2{% + \if0\pgfmath@trig@format@choice + % trig format=deg + \expandafter\ifx\csname pgfmathfloatTRIG@NUM\endcsname\relax% + % Lazy evaluation: + \pgfmathfloatcreate{1}{3.6}{2}% + \global\let\pgfmathfloatTRIG@NUM=\pgfmathresult + \pgfmathfloatcreate{1}{2.77777777777778}{-3}% + \global\let\pgfmathfloatTRIG@NUM@INV=\pgfmathresult + \fi + \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@NUM}{\pgfmathfloatTRIG@NUM@INV}% + \else + % trig format=rad + \expandafter\ifx\csname pgfmathfloatTRIG@rad@NUM\endcsname\relax% + % Lazy evaluation: + \pgfmathfloatcreate{1}{6.28318530717959}{0}% + \global\let\pgfmathfloatTRIG@rad@NUM=\pgfmathresult + \pgfmathfloatcreate{1}{1.59154943091895}{-1}% + \global\let\pgfmathfloatTRIG@rad@NUM@INV=\pgfmathresult + \fi + \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@rad@NUM}{\pgfmathfloatTRIG@rad@NUM@INV}% + \fi + \pgfmathfloattofixed@{\pgfmathresult}% + \expandafter#1\expandafter{\pgfmathresult}% + \pgfmathfloatparsenumber{\pgfmathresult}% +}% + +\def\pgfmathfloatsin@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}} +\let\pgfmathfloatsin=\pgfmathfloatsin@ +\def\pgfmathfloatcos@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}} +\let\pgfmathfloatcos=\pgfmathfloatcos@ +\def\pgfmathfloattan@#1{% + % compute sin(#1) / cos(#1) + \begingroup + \pgfmathfloatcos@{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatsin@{#1}% + \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloattan=\pgfmathfloattan@ + +\def\pgfmathfloatcot@#1{% + % compute cos(#1) / sin(#1) + \begingroup + \pgfmathfloatsin@{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatcos@{#1}% + \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatcot=\pgfmathfloatcot@ + +\def\pgfmathfloatatan@#1{% + \begingroup + \expandafter\ifx\csname pgfmathfloatatan@TMP\endcsname\relax% + \pgfmathfloatcreate{1}{1.6}{4}% + \global\let\pgfmathfloatatan@TMP=\pgfmathresult + \pgfmathfloatcreate{2}{1.6}{4}% + \global\let\pgfmathfloatatan@TMPB=\pgfmathresult + \fi + \pgfmathfloatgreaterthan@{#1}{\pgfmathfloatatan@TMP}% + \ifpgfmathfloatcomparison + \pgfmathiftrigonometricusesdeg{% + \pgfmathfloatcreate{1}{9.0}{1}% + }{% + \pgfmathfloatcreate{1}{1.570796326794}{0}% + }% + \else + \pgfmathfloatlessthan{#1}{\pgfmathfloatatan@TMPB}% + \ifpgfmathfloatcomparison + \pgfmathiftrigonometricusesdeg{% + \pgfmathfloatcreate{2}{9.0}{1}% + }{% + \pgfmathfloatcreate{2}{1.570796326794}{0}% + }% + \else + \pgfmathfloattofixed@{#1}% + \expandafter\pgfmath@basic@atan@\expandafter{\pgfmathresult}% + \pgfmathfloatparsenumber{\pgfmathresult}% + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatatan=\pgfmathfloatatan@ + +\def\pgfmathfloatatantwo#1#2{% + % Note: first parameter is y (!), second is x (!) + \begingroup% + \let\pgfmath@trig@format@choice@@=\pgfmath@trig@format@choice + \def\pgfmath@trig@format@choice{0}% + % + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \expandafter\pgfmathfloat@decompose#2\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E + \ifnum\pgfmathfloat@a@S=0 + \pgfmathfloat@a@E=-16 % + \fi + % + \ifnum\pgfmathfloat@a@E<-3 % + \ifnum\pgfmathfloat@b@S=2 % + % #2 < 0 + \pgfmathfloatcreate{1}{1.8}{2}% +180 + \else + \ifnum\pgfmathfloat@b@S=1 % + % #2 >0 + \pgfmathfloatcreate{0}{0.0}{0}% + \else + % + or - 90, just use the sign of #1: + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{9.0}{1}% + \fi + \fi + \else% + \pgfmathfloatabs@{#1}\let\pgfmath@tempa\pgfmathresult% + \pgfmathfloatabs@{#2}\let\pgfmath@tempb\pgfmathresult% + \pgfmathfloatgreaterthan@{\pgfmath@tempa}{\pgfmath@tempb}% + \ifpgfmathfloatcomparison + \pgfmathfloatdivide@{#2}{\pgfmath@tempa}% + \expandafter\pgfmathfloatatan@\expandafter{\pgfmathresult}% + \let\pgfmath@tempa=\pgfmathresult + \pgfmathfloatcreate{1}{9.0}{1}% + \let\pgfmath@tempb=\pgfmathresult + \pgfmathfloatsubtract@{\pgfmath@tempb}{\pgfmath@tempa}% + \else% + \pgfmathfloatdivide@{\pgfmath@tempa}{#2}% + \expandafter\pgfmathfloatatan@\expandafter{\pgfmathresult}% + \expandafter\pgfmathfloatifflags\expandafter{\pgfmathresult}{2}{% + \let\pgfmath@tempa=\pgfmathresult + \pgfmathfloatcreate{1}{1.8}{2}% + \let\pgfmath@tempb=\pgfmathresult + \pgfmathfloatadd@{\pgfmath@tempa}{\pgfmath@tempb}% + }{}% + \fi% + % + \pgfmathfloatifflags{#1}{-}{% + % #1 < 0: + \pgfmathfloatmultiplyfixed@{\pgfmathresult}{-1}% + }{}% + \fi% + \if1\pgfmath@trig@format@choice@@ + % trig format=rad + \pgfmathfloat@scale@deg@to@rad\pgfmathresult + \fi + \pgfmath@smuggleone\pgfmathresult% + \endgroup% +}% +\let\pgfmathfloatatantwo@=\pgfmathfloatatantwo +\expandafter\let\csname pgfmathfloatatan2\endcsname=\pgfmathfloatatantwo +\expandafter\let\csname pgfmathfloatatan2@\endcsname=\pgfmathfloatatantwo@ + +\def\pgfmathfloat@scale@deg@to@rad#1{% + \edef\pgfmathfloat@loc@TMPb{#1}% + \pgfmathfloatcreate{1}{1.74532925199433}{-2}% = pi / 180 + \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@loc@TMPb}% +}% + +\def\pgfmathfloatsec@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}} +\let\pgfmathfloatsec=\pgfmathfloatsec@ +\def\pgfmathfloatcosec@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}} +\let\pgfmathfloatcosec=\pgfmathfloatcosec@ + +% Expands #2 using \edef and invokes #1 with the resulting string. +% +% DEPRECATED +% Example: +% \pgfmath@y=7.9pt +% \pgfmathlog@invoke@expanded\pgfmathexp@{{\pgf@sys@tonumber{\pgfmath@y}}}% +% will invoke +% \pgfmathexp@{7.9} +\def\pgfmathlog@invoke@expanded#1#2{% + \edef\pgfmath@resulttemp{#2}% + \expandafter#1\pgfmath@resulttemp +} + +\def\pgfmathfloatln@#1{% + \pgfmathlog@float{#1}% + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloatcreate{3}{0.0}{0}% + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \fi +} +\let\pgfmathfloatln=\pgfmathfloatln@ + +\expandafter\def\csname pgfmathfloatlog10@\endcsname#1{% + \pgfmathfloatln@{#1}% + \let\pgfmathfloat@log@ten=\pgfmathresult + \pgfmathfloatcreate{1}{4.34294481903252}{-1}% 1/ln(10) + \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@log@ten}% +}% +\expandafter\def\csname pgfmathfloatlog2@\endcsname#1{% + \pgfmathfloatln@{#1}% + \let\pgfmathfloat@log@two=\pgfmathresult + \pgfmathfloatcreate{1}{1.44269504088896}{0}% 1/ln(2) + \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@log@two}% +}% + +% Computes log(x) into \pgfmathresult. +% +% This allows numbers such at 10000000 or 5.23e-10 to be represented +% properly, although TeX-registers would produce overflow/underflow +% errors in these cases. +% +% The natural logarithm is computed using log(X*10^Y) = log(X) + log(10)*Y +% +% FIXME This routine is only kept for backwards compatibility! +% It does not work as expected because +% 1. it calls \pgfmathfloatparsenumber +% 2. it returns the result as fixed point number +% Use \pgfmathln@ instead! +\def\pgfmathlog@#1{% + \pgfmathfloatparsenumber{#1}% + \pgfmathlog@float{\pgfmathresult}% +} +\let\pgfmathlog=\pgfmathlog@ +\def\pgfmathlog@float#1{% + \begingroup% + % compute #1 = M*10^E with normalised mantisse M = [+-]*[1-9].XXXXX + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@S=1 + % Now, compute log(#1) = log(M) + E*log(10) + \expandafter\pgfmath@basic@ln@\expandafter{\the\pgfmathfloat@a@Mtok}% + \pgfmathfloat@b@M=\pgfmathresult pt% + \pgfmathfloat@a@M=2.302585pt% = log(10) + \multiply\pgfmathfloat@a@M by\pgfmathfloat@a@E\relax + \advance\pgfmathfloat@b@M by\pgfmathfloat@a@M + \edef\pgfmathresult{\pgf@sys@tonumber{\pgfmathfloat@b@M}}% + \else + \let\pgfmathresult=\pgfutil@empty% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup% +} + + +% Computes exp(#1) in floating point. +% +% The algorithm employs the identity +% exp(x) = exp(x - log(10^k) + log(10^k) +% = 10^k exp( x - k*log 10 ) +% with k choosen such that exp( x - k*log10) can be computed with the +% basic level math engine. +% +% The precision (relative error) is between 10^{-4} and 10^{-6}. For +% #1 = 700, it is even 10^{-3}. I will need to improve that someday. +\def\pgfmathfloatexp@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + % #1 = 0: + \pgfmathfloatcreate{1}{1.0}{0}% + \or% #1 > 0 + \pgfmathfloatexp@@{#1}% + \or% #1 < 0 + \pgfmathfloatexp@@{#1}% + \else + \edef\pgfmathresult{#1}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloatexp@@#1{% + % Employ the identity + % exp(x) = exp(x - log(10^k) + log(10^k)) = 10^k exp( x - k *log(10)) + % + % I'd like to have x - k*log(10) <= 1 + % => compute k := int( (x - 1) * 1/log(10) ) + % that should suffice since \pgfmathexp@ should be + % accurate enough for those numbers. + % + % please note that we can do all this in TeX registers. + % exp(700) is almost the maximum of double precision + % anyway, and exp(16000) is certainly the largest we will + % ever need. + \pgfmathfloattofixed@{#1}% + \pgf@xa=\pgfmathresult pt + \pgf@xa=0.434294481\pgf@xa\relax + \edef\pgfmathfloat@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}% + \expandafter\pgfmathfloatexp@@toint\pgfmathfloat@loc@TMPa\relax + \pgf@xa=2.302585092pt + \multiply\pgf@xa by-\pgfmathfloat@k\relax + \advance\pgf@xa by\pgfmathresult pt + \edef\pgfmathfloat@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}% +%\message{computing exp(\pgfmathresult) = 10^\pgfmathfloat@k * exp(\pgfmathfloat@loc@TMPa)...}% + \pgfmath@basic@exp@{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatparsenumber{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathfloatshift@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@k}% +} +% determine 'k'. This is a heuristics. The exponential series +% converges best for |x| <= 1. However, the fixed point arithmetics +% for tex results in best results for large |x|. Well, I'll need to +% tune this here. +\def\pgfmathfloatexp@@toint#1.#2\relax{% + \c@pgf@counta=#1\relax + \ifnum\c@pgf@counta<0 +\advance\c@pgf@counta by-1 % FIXME . this is a test for optimizations. + \c@pgf@countb=#2\relax + \ifnum\c@pgf@countb>0 + \advance\c@pgf@counta by-1 + \fi + \fi + \edef\pgfmathfloat@k{\the\c@pgf@counta}% +}% +\let\pgfmathfloatexp=\pgfmathfloatexp@ + +\def\pgfmathfloatround@#1{% + \begingroup + \pgfkeysvalueof{/pgf/number format/precision/.@cmd}0\pgfeov + \pgfmathfloattofixed{#1}% + \pgfmathroundto{\pgfmathresult}% + \pgfmathfloatparsenumber{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + + +\def\pgfmathfloatneg@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S\relax + % 0: + \edef\pgfmathresult{#1}% + \or + % +: + \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or + % -: + \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or + % nan: + \edef\pgfmathresult{#1}% + \or + % +infty: + \pgfmathfloatcreate{5}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \or + % -infty: + \pgfmathfloatcreate{4}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + + +\def\pgfmathfloatpow@#1#2{% + \begingroup% + \expandafter\pgfmathfloat@decompose@tok#2\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S\relax + % #1 ^ 0 = 1 + \pgfmathfloatcreate{1}{1.0}{0}% + \or + % #2 > 0 + \pgfmathfloatpow@@{#1}{#2}% + \or + % #2 < 0 + \pgfmathfloatpow@@{#1}{#2}% + \or + % #2 = nan + \edef\pgfmathresult{#2}% + \or + % #2 = inf + \edef\pgfmathresult{#2}% + \or + % #2 = -inf + \pgfmathfloatcreate{0}{0.0}{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% computes #1^#2 +% PRECONDITIONS +% - #2 is positive. +\def\pgfmathfloatpow@@#1#2{% + \pgfmathfloattofixed@{#2}% + \afterassignment\pgfmath@x% + \expandafter\c@pgfmath@counta\pgfmathresult pt\relax% + \ifdim\pgfmath@x=0pt % + % loop "manually"; we have an integer exponent! + \ifnum\c@pgfmath@counta<0 + \pgfmathfloatreciprocal@{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \c@pgfmath@counta=-\c@pgfmath@counta + \else + \edef\pgfmathfloat@loc@TMPa{#1}% + \fi + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \pgfmathloop + \ifnum\c@pgfmath@counta>0\relax% + \ifodd\c@pgfmath@counta% + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPb}{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPb=\pgfmathresult + \fi + \ifnum\c@pgfmath@counta>1\relax% + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \fi% + \divide\c@pgfmath@counta by2\relax% + \repeatpgfmathloop% + \else + \pgfmathfloatgetflags{#1}\c@pgfmath@counta + \ifnum0=\c@pgfmath@counta + % ah: 0^x + \pgfmathfloatgetflags{#2}\c@pgfmath@counta + \ifnum0=\c@pgfmath@counta + % ah: 0^0 + \pgfmathfloatcreate{1}{1.0}{0}% + \else + % ah: 0^x with x!=0: + \pgfmathfloatcreate{0}{0.0}{0}% + \fi + \else + % employ #1^#2 = exp( #2 * ln(#1) ) + \pgfmathfloatln@{#1}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \edef\pgfmathfloat@loc@TMPb{#2}% + \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPb}% + \pgfmathfloatexp@{\pgfmathresult}% + \fi + \fi +} + +\def\pgfmathfloat@definemethodfrombasic@NOARG#1{% + \pgfutil@ifundefined{pgfmath@basic@#1@}{% + \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}% + }{}% + \edef\pgfmathfloat@glob@TMP{% + \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname + \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}% + }% + \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP% + \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP% +}% +\def\pgfmathfloat@definemethodfrombasic@ONEARG#1{% + \pgfutil@ifundefined{pgfmath@basic@#1@}{% + \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}% + }{}% + \edef\pgfmathfloat@glob@TMP##1{% + \noexpand\pgfmathfloattofixed{##1}% + \noexpand\expandafter + \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname\noexpand\expandafter% + {\noexpand\pgfmathresult}% + \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}% + }% + \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP% + \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP% +}% +\def\pgfmathfloat@definemethodfrombasic@TWOARGS#1{% + \pgfutil@ifundefined{pgfmath@basic@#1@}{% + \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}% + }{}% + \edef\pgfmathfloat@glob@TMP##1##2{% + \noexpand\pgfmathfloattofixed{##2}% + \noexpand\let\noexpand\pgfmathfloat@loc@TMPa=\noexpand\pgfmathresult + \noexpand\pgfmathfloattofixed{##1}% + \noexpand\expandafter + \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname\noexpand\expandafter% + {\noexpand\pgfmathresult}{\noexpand\pgfmathfloat@loc@TMPa}% + \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}% + }% + \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP% + \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP% +}% +\pgfmathfloat@definemethodfrombasic@NOARG{rand} +\pgfmathfloat@definemethodfrombasic@NOARG{rnd} +\pgfmathfloat@definemethodfrombasic@NOARG{false} +\pgfmathfloat@definemethodfrombasic@NOARG{true} +% arcsin, arccos +\pgfmathfloat@definemethodfrombasic@ONEARG{asin} +\pgfmathfloat@definemethodfrombasic@ONEARG{acos} +\pgfmathfloat@definemethodfrombasic@ONEARG{not} +\pgfmathfloat@definemethodfrombasic@ONEARG{hex} +\pgfmathfloat@definemethodfrombasic@ONEARG{Hex} +\pgfmathfloat@definemethodfrombasic@ONEARG{oct} +\pgfmathfloat@definemethodfrombasic@ONEARG{bin} +\pgfmathfloat@definemethodfrombasic@TWOARGS{and} +\pgfmathfloat@definemethodfrombasic@TWOARGS{or} + +\pgfutil@ifundefined{pgfmathdeclarefunction}{% + % special treatment: \pgfmathrand@ was not properly defined for pgf 2.00: + \let\pgfmath@basic@rand=\pgfmathrand + \let\pgfmath@basic@rand@=\pgfmathrand@ + \def\pgfmathfloatrand@{% + \pgfmath@basic@rand + \pgfmathfloatparsenumber{\pgfmathresult}% + }% + \let\pgfmathfloatrand=\pgfmathfloatrand@% + % + % special treatment: \pgfmathrnd@ was not properly defined for pgf 2.00: + \let\pgfmath@basic@rnd=\pgfmathrnd + \let\pgfmath@basic@rnd@=\pgfmathrnd@ + \def\pgfmathfloatrnd@{% + \pgfmath@basic@rnd + \pgfmathfloatparsenumber{\pgfmathresult}% + }% + \let\pgfmathfloatrnd=\pgfmathfloatrnd@% +}{} + +% Implements the factorial of '#1'. +% This does only work if '#1 < 2^32'. +\def\pgfmathfloatfactorial@#1{% + \begingroup + \pgfmathfloattofixed{#1}% + % collect integer part into a 32 bit register: + \afterassignment\pgfmath@gobbletilpgfmath@% + \expandafter\c@pgfmath@counta\pgfmathresult\relax\pgfmath@% + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \pgfmathloop + \ifnum\c@pgfmath@counta<2 % + \else + \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}% + \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}% + \let\pgfmathfloat@loc@TMPa=\pgfmathresult + \advance\c@pgfmath@counta by-1\relax% + \repeatpgfmathloop + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% Implements the vector length of a 2D vector. +% +% ATTENTION: this does NOT use the improved code of the basic layer! +% It simply computed sqrt( #1^2 + #2^2 )! +\def\pgfmathfloatveclen@#1#2{% + \begingroup + \edef\pgfmathfloat@@a{#1}% + \pgfmathfloatmultiply@{\pgfmathfloat@@a}{\pgfmathfloat@@a}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \edef\pgfmathfloat@@b{#2}% + \pgfmathfloatmultiply@{\pgfmathfloat@@b}{\pgfmathfloat@@b}% + \let\pgfmathfloat@@b=\pgfmathresult + % + \pgfmathfloatadd@{\pgfmathfloat@@a}{\pgfmathfloat@@b}% + \pgfmathfloatsqrt@{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\def\pgfmathfloatcosh@#1{% + \begingroup + \pgfmathfloatexp@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatneg@{#1}% + \pgfmathfloatexp@{\pgfmathresult}% + % + \pgfmathfloatadd@{\pgfmathresult}{\pgfmathfloat@@a}% + \expandafter\pgfmathfloatmultiplyfixed@\expandafter{\pgfmathresult}{0.5}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloatsinh@#1{% + \begingroup + \pgfmathfloatexp@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatneg@{#1}% + \pgfmathfloatexp@{\pgfmathresult}% + % + \pgfmathfloatsubtract@{\pgfmathfloat@@a}{\pgfmathresult}% + \expandafter\pgfmathfloatmultiplyfixed@\expandafter{\pgfmathresult}{0.5}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloattanh@#1{% + \begingroup + \pgfmathfloatsinh@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatcosh@{#1}% + \let\pgfmathfloat@@b=\pgfmathresult + % + \pgfmathfloatdivide@{\pgfmathfloat@@a}{\pgfmathfloat@@b}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex new file mode 100644 index 0000000..0e07fdc --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex @@ -0,0 +1,1018 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Fr 14. Feb 21:37:39 CET 2014 %%% + + + +% Copyright 2008 by Mark Wibrow +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% Note: at the time of this writing, the library has quadratic runtime. +% Experimentally, it performed well while computing ~12 intersections of two +% plots, each with 600 samples. It failed when the number of samples exceeded 700. + +\usepgflibrary{fpu} + +\newcount\pgf@intersect@solutions + +\newif\ifpgf@intersect@sort +\newif\ifpgf@intersect@sort@by@second@path + +\def\pgfintersectionsortbyfirstpath{% + \pgf@intersect@sorttrue% + \pgf@intersect@sort@by@second@pathfalse% +} + +\def\pgfintersectionsortbysecondpath{% + \pgf@intersect@sorttrue% + \pgf@intersect@sort@by@second@pathtrue% +} + +% #1: the index. It starts at 1 and ends with \pgfintersectionsolutions (inclusive). +% Invalid values will implicitly result in the origin. +\def\pgfpointintersectionsolution#1{% + \ifnum#1<1\relax% + \pgfpoint@intersect@solution@orgin% + \else% + \ifnum#1>\pgfintersectionsolutions\relax% + \pgfpoint@intersect@solution@orgin% + \else% + \csname pgfpoint@intersect@solution@#1\endcsname% + \fi% + \fi% +} + +% Gets the segment indices of solution #1. +% +% #1: the solution index (i.e. the same argument as in \pgfpointintersectionsolution) +% #2: [output] a macro name which will contain the segment index of the first path which contains the solution +% #3: [output] a macro name which will contain the segment index of the second path which contains the solution +% +% Example: \pgfintersectiongetsolutionsegmentindices{0}{\first}{\second} +% +% -> \first may be 0 if point #0 is in the 0'th segment +% -> \second may be 42 if point #0 is in the 42'th segment +% +% The "segment index" is actually close to the "time" of the solution. +% If a solution is at "time" 42.2, it will have segment index 42. +\def\pgfintersectiongetsolutionsegmentindices#1#2#3{% + \ifnum#1<1\relax% + \let#2=\pgfutil@empty + \let#3=\pgfutil@empty + \else% + \ifnum#1>\pgfintersectionsolutions\relax% + \let#2=\pgfutil@empty + \let#3=\pgfutil@empty + \else% + \def\pgf@temp##1##2##3##4{% + \edef#2{##1}% + \edef#3{##2}% + }% + \expandafter\let\expandafter\pgf@tempb\csname pgf@intersect@solution@props@#1\endcsname + \expandafter\pgf@temp\pgf@tempb + \fi% + \fi% +}% + +% Gets the time indices of solution #1. +% +% #1: the solution index (i.e. the same argument as in \pgfpointintersectionsolution) +% #2: [output] a macro name which will contain the time of the first path which contains the solution +% It will never be empty. +% #3: [output] a macro name which will contain the time of the second path which contains the solution +% It will never be empty. +% +% Example: \pgfintersectiongetsolutiontimes{0}{\first}{\second} +% +% -> \first may be 0.5 if point #0 is in just in the middle of the path +% -> \second may be 42.8 if point #0 is in the 42'th segment (compare +% \pgfintersectiongetsolutionsegmentindices) and is at 80% of the +% 42'th segment +% +% Note that the precise time inside of a segment may be unavailable +% (currently, it is only computed for curveto paths and not +% necessarily for lineto). If the precise time is unavailable, this +% call will return the value of +% \pgfintersectiongetsolutionsegmentindices (which is a +% "coarse-grained" time). +\def\pgfintersectiongetsolutiontimes#1#2#3{% + \ifnum#1<1\relax% + \let#2=\pgfutil@empty + \let#3=\pgfutil@empty + \else% + \ifnum#1>\pgfintersectionsolutions\relax% + \let#2=\pgfutil@empty + \let#3=\pgfutil@empty + \else% + \def\pgf@temp##1##2##3##4{% + \edef#2{##3}% + \edef#3{##4}% + % + % check for fallback to segment indices: + \ifx#2\pgfutil@empty \edef#2{##1}\fi + \ifx#3\pgfutil@empty \edef#3{##2}\fi + }% + \expandafter\let\expandafter\pgf@tempb\csname pgf@intersect@solution@props@#1\endcsname + \expandafter\pgf@temp\pgf@tempb + \fi% + \fi% +}% + +\def\pgfpoint@intersect@solution@orgin{% + \begingroup% + \pgftransforminvert% + \pgfpointorigin% + \pgf@pos@transform{\pgf@x}{\pgf@y}% + \global\pgf@x=\pgf@x% + \global\pgf@y=\pgf@y% + \endgroup% +} + +% #1 code which assigns the first path using \pgfsetpath. +% #2 code which assigns the second path using \pgfsetpath. +% +% On output, the points, their properties, and the number of points are set. +% Use \pgfintersectionsolutions which expands to the number of intersections +\long\def\pgfintersectionofpaths#1#2{% + \begingroup% + \pgfinterruptpath% + #1% + \pgfgetpath\pgf@intersect@path@a% + \global\let\pgf@intersect@path@temp=\pgf@intersect@path@a% + \endpgfinterruptpath% + \endgroup% + \let\pgf@intersect@path@a=\pgf@intersect@path@temp% + % + \begingroup% + \pgfinterruptpath% + #2% + \pgfgetpath\pgf@intersect@path@b% + \global\let\pgf@intersect@path@temp=\pgf@intersect@path@b% + \endpgfinterruptpath% + \endgroup% + \let\pgf@intersect@path@b=\pgf@intersect@path@temp% + % + \pgf@intersect@solutions=0\relax% + \pgf@intersect@path@reset@a + % + \ifpgf@intersect@sort@by@second@path% + \let\pgf@intersect@temp=\pgf@intersect@path@a% + \let\pgf@intersect@path@a=\pgf@intersect@path@b% + \let\pgf@intersect@path@b=\pgf@intersect@temp% + \fi% + % + \pgfprocessround\pgf@intersect@path@a\pgf@intersect@path@a% + \pgfprocessround\pgf@intersect@path@b\pgf@intersect@path@b% + % + \let\pgf@intersect@token@after=\pgf@intersect@path@process@a% + \expandafter\pgf@intersectionofpaths\pgf@intersect@path@a\pgf@stop% + \edef\pgfintersectionsolutions{\the\pgf@intersect@solutions}% + \pgfmathloop% + \ifnum\pgfmathcounter>\pgfintersectionsolutions\relax% + \else% + \pgfutil@namelet{pgfpoint@intersect@solution@\pgfmathcounter}% + {pgfpoint@g@intersect@solution@\pgfmathcounter}% + \edef\pgf@marshal{\noexpand\pgf@intersection@set@properties{\csname pgfpoint@g@intersect@solution@\pgfmathcounter @props\endcsname}}% + \pgf@marshal + \ifpgf@intersect@sort% + \pgfutil@namelet{pgf@intersect@solution@\pgfmathcounter @time@a}% + {pgf@g@intersect@solution@\pgfmathcounter @time@a}% + \fi% + \repeatpgfmathloop% + \ifpgf@intersect@sort% + \pgfintersectionsolutionsortbytime% + \fi% +} + +\def\pgf@intersection@set@properties#1{% + \pgfutil@namedef{pgf@intersect@solution@props@\pgfmathcounter}{#1}% +}% + +% #1 a global name prefix to store properties. +\def\pgf@intersection@store@properties#1{% + % we store the time offsets as well and make them available programmatically: + % note that \pgf@intersect@time@a and \pgf@intersect@time@b may be empty. + % + % However, \pgf@intersect@time@offset and + % \pgf@intersect@time@offset@b are *always* valid. In fact,they + % resemble a part of the time: it holds + % 0 <= \pgf@intersect@time@a < 1 + % and \pgf@intersect@time@offset > 0. + % + % If we have an intersection in segment 42 of path A, + % \pgf@intersect@time@offset will be 42. The time inside of that + % segment is given as number in the interval [0,1]. If it is 0.3, + % the total time will be 42.3 and that number will be stored as + % \pgf@intersect@time@a. + % + \expandafter\xdef\csname #1@props\endcsname{{\pgf@intersect@time@offset}{\pgf@intersect@time@offset@b}{\pgf@intersect@time@a}{\pgf@intersect@time@b}}% +} + +\def\pgf@intersectionofpaths#1{% + \ifx#1\pgf@stop% + \let\pgf@intersect@next=\relax% + \else% + \ifx#1\pgfsyssoftpath@movetotoken% + \let\pgf@intersect@next=\pgf@intersect@token@moveto% + \else% + \ifx#1\pgfsyssoftpath@linetotoken% + \let\pgf@intersect@next=\pgf@intersect@token@lineto% + \else% + \ifx#1\pgfsyssoftpath@closepathtoken% + \let\pgf@intersect@next=\pgf@intersect@token@lineto% + \else% + \ifx#1\pgfsyssoftpath@curvetosupportatoken% + \let\pgf@intersect@next=\pgf@intersect@token@curveto% + \else% + \ifx#1\pgfsyssoftpath@rectcornertoken% + \let\pgf@intersect@next=\pgf@intersect@token@rect% + \fi% + \fi% + \fi% + \fi% + \fi% + \fi% + \pgf@intersect@next} + +\def\pgf@intersect@token@moveto#1#2{% + \def\pgfpoint@intersect@start{\pgfqpoint{#1}{#2}}% + \pgf@intersectionofpaths% +} + +\def\pgf@intersect@token@lineto#1#2{% + \def\pgfpoint@intersect@end{\pgfqpoint{#1}{#2}}% + \def\pgf@intersect@type{line}% + \pgf@intersect@token@after% +} +\def\pgf@intersect@token@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{% + \def\pgfpoint@intersect@firstsupport{\pgfqpoint{#1}{#2}}% + \def\pgfpoint@intersect@secondsupport{\pgfqpoint{#3}{#4}}% + \def\pgfpoint@intersect@end{\pgfqpoint{#5}{#6}}% + \def\pgf@intersect@type{curve}% + \pgf@intersect@token@after% +} + +\def\pgf@intersect@token@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{% + \pgf@xa=#1\relax% + \advance\pgf@xa by#3\relax% + \pgf@ya=#2\relax% + \advance\pgf@ya by#4\relax% + \edef\pgf@marshal{% + \noexpand\pgfsyssoftpath@movetotoken{#1}{#2}% + \noexpand\pgfsyssoftpath@linetotoken{#1}{\the\pgf@ya}% + \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{\the\pgf@ya}% + \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{#2}% + \noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}% + }% + \expandafter\pgf@intersectionofpaths\pgf@marshal% +} + +\def\pgf@intersect@path@process@a{% + \pgf@intersect@path@getpoints@a% + \let\pgf@intersect@token@after=\pgf@intersect@path@process@b% + \pgf@intersect@path@reset@b + \expandafter\pgf@intersectionofpaths\pgf@intersect@path@b\pgf@stop% + \let\pgfpoint@intersect@start=\pgfpoint@intersect@end@a% + \let\pgf@intersect@token@after=\pgf@intersect@path@process@a% + \c@pgf@counta=\pgf@intersect@time@offset\relax% + \advance\c@pgf@counta by1\relax% + \edef\pgf@intersect@time@offset{\the\c@pgf@counta}% + \pgf@intersectionofpaths% +} + +\def\pgf@intersect@path@reset@a{% + \def\pgf@intersect@time@offset{0}% + \def\pgf@intersect@time@a{}% +}% + +\def\pgf@intersect@path@reset@b{% + \def\pgf@intersect@time@offset@b{0}% + \def\pgf@intersect@time@b{}% +}% + +\def\pgf@intersect@path@getpoints@a{% + \let\pgfpoint@intersect@start@a=\pgfpoint@intersect@start% + \let\pgfpoint@intersect@end@a=\pgfpoint@intersect@end% + \let\pgfpoint@intersect@firstsupport@a=\pgfpoint@intersect@firstsupport% + \let\pgfpoint@intersect@secondsupport@a=\pgfpoint@intersect@secondsupport% + \let\pgf@intersect@type@a=\pgf@intersect@type% +} + +\def\pgf@intersect@path@process@b{% + \pgf@intersect@path@getpoints@b% + \csname pgf@intersect@\pgf@intersect@type@a @and@\pgf@intersect@type@b\endcsname% + \let\pgfpoint@intersect@start=\pgfpoint@intersect@end@b% + \c@pgf@counta=\pgf@intersect@time@offset@b\relax% + \advance\c@pgf@counta by1\relax% + \edef\pgf@intersect@time@offset@b{\the\c@pgf@counta}% + \pgf@intersectionofpaths} + +\def\pgf@intersect@path@getpoints@b{% + \let\pgfpoint@intersect@start@b=\pgfpoint@intersect@start% + \let\pgfpoint@intersect@end@b=\pgfpoint@intersect@end% + \let\pgfpoint@intersect@firstsupport@b=\pgfpoint@intersect@firstsupport% + \let\pgfpoint@intersect@secondsupport@b=\pgfpoint@intersect@secondsupport% + \let\pgf@intersect@type@b=\pgf@intersect@type% +} + +\def\pgf@intersect@line@and@line{% + \pgf@intersectionoflines{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}% + {\pgfpoint@intersect@start@b}{\pgfpoint@intersect@end@b}% +}% + +\def\pgf@intersect@line@and@curve{% + \pgf@intersectionoflineandcurve% + {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@end@a}}% + {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@firstsupport@b}}% + {\pgf@process{\pgfpoint@intersect@secondsupport@b}}{\pgf@process{\pgfpoint@intersect@end@b}}% +} + +\def\pgf@intersect@curve@and@line{% + \pgf@intersectionofcurveandline% + {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@firstsupport@a}}% + {\pgf@process{\pgfpoint@intersect@secondsupport@a}}{\pgf@process{\pgfpoint@intersect@end@a}}% + {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@end@b}}% +} + +\def\pgf@intersect@curve@and@curve{% + \pgf@intersectionofcurves% + {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@firstsupport@a}}% + {\pgf@process{\pgfpoint@intersect@secondsupport@a}}{\pgf@process{\pgfpoint@intersect@end@a}}% + {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@firstsupport@b}}% + {\pgf@process{\pgfpoint@intersect@secondsupport@b}}{\pgf@process{\pgfpoint@intersect@end@b}}% +} + + +\def\pgfintersectionoflines#1#2#3#4{% + \pgf@intersect@solutions=0\relax% + \pgf@intersectionoflines{#1}{#2}{#3}{#4}% +} + +\def\pgf@intersectionoflines#1#2#3#4{% + \pgf@iflinesintersect{#1}{#2}{#3}{#4}% + {% + \pgfextract@process\pgf@intersect@solution@candidate{% + \pgfpointintersectionoflines{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}% + {\pgfpoint@intersect@start@b}{\pgfpoint@intersect@end@b}% + }% + \pgf@ifsolution@duplicate{\pgf@intersect@solution@candidate}{% + % ah - we a duplicate. Apparently, we have a hit on an + % endpoint. + }{% + \global\advance\pgf@intersect@solutions by1\relax% + \expandafter\global\expandafter\let\csname pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions\endcsname=\pgf@intersect@solution@candidate + \ifpgf@intersect@sort% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgf@process{\pgfpointdiff{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}}% + \edef\pgf@marshal{% + \noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@ya}}% + }% + \pgf@marshal% + \let\pgf@intersect@length@a=\pgfmathresult% + \pgf@process{\pgfpointdiff{\pgfpoint@intersect@start@a}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}% + \edef\pgf@marshal{% + \noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}% + }% + \pgf@marshal% + \pgfmathdivide@{\pgfmathresult}{\pgf@intersect@length@a}% + \pgf@x=\pgfmathresult pt\relax% + \advance\pgf@x by\pgf@intersect@time@offset pt\relax% + \edef\pgf@intersect@time@a{\pgfmath@tonumber{\pgf@x}}% + \expandafter\global\expandafter\let\csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname= + \pgf@intersect@time@a + \else + \let\pgf@intersect@time@a=\pgfutil@empty + \fi% + \let\pgf@intersect@time@b=\pgfutil@empty + \pgf@intersection@store@properties{pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions}% + }% + % + }{}% +} + +% Test if two lines L1 and L2 intersect. +% +% #1 - first point P1 on L1. +% #2 - second point P2 on L1. +% #3 - first point P3 on L2. +% #2 - second point P4 on L2. +% #5 - code executed if intersection occurs. +% #6 - code executed if intersection does no occur. +% +% Let L1 be represented by P1+(P2-P1)s where 0<=s<=1 +% Let L2 be represented by P3+(P4-P3)t where 0<=t<=1 +% +% Then L1 and L2 intersect at +% +% s = |x2-x1 x3-x1| / |x4-x3 x2-x1| +% |y2-y1 y3-y1| |y4-y3 y2-y1| +% +% t = |x4-x3 x3-x1| / |x4-x3 x2-x1| +% |y4-y3 y3-y1| |y4-y3 y2-y1| +% +% with 0<=s,t<=1 +% +% s and t do not need to be calculated: +% +% Let s = A / C and t = B / C +% +% Then 0<=s<=1 if !(C=0) && ((A=0) || ((A>0) && !(CA))) +% 0<=t<=1 if !(C=0) && ((B=0) || ((B>0) && !(CB))) +% +\newif\ifpgf@s +\newif\ifpgf@t +\def\pgfiflinesintersect#1#2#3#4{% + \begingroup% + \pgf@iflinesintersect{\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}% + {\aftergroup\pgfutil@firstoftwo}{\aftergroup\pgfutil@secondoftwo}% + \endgroup% +} + +\def\pgf@iflinesintersect#1#2#3#4{% + #4\relax% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + #3\relax% + \advance\pgf@xc by-\pgf@x% + \advance\pgf@yc by-\pgf@y% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + #2\relax% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + #1\relax% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + \advance\pgf@xb by-\pgf@x% + \advance\pgf@yb by-\pgf@y% + % + % xc = x4-x3; yc=y4-y3; + % xb = x3-x1; yb=y3-y1; + % xa = x2-x1; ya=y2-y1; + % + % + % Normalise a little. 16384 may not be a robust choice. + % + \c@pgf@counta=\pgf@xa\divide\c@pgf@counta by16384\relax% + \c@pgf@countb=\pgf@xb\divide\c@pgf@countb by16384\relax% + \c@pgf@countc=\pgf@ya\divide\c@pgf@countc by16384\relax% + \c@pgf@countd=\pgf@yb\divide\c@pgf@countd by16384\relax% + \multiply\c@pgf@counta by\c@pgf@countd% + \multiply\c@pgf@countc by\c@pgf@countb% + \advance\c@pgf@counta by-\c@pgf@countc% + \pgfutil@tempcnta=\c@pgf@counta% + % + \c@pgf@counta=\pgf@xc\divide\c@pgf@counta by16384\relax% + \c@pgf@countc=\pgf@yc\divide\c@pgf@countc by16384\relax% + \multiply\c@pgf@countd by\c@pgf@counta% + \multiply\c@pgf@countb by\c@pgf@countc% + \advance\c@pgf@countd by-\c@pgf@countb% + \pgfutil@tempcntb=\c@pgf@countd% + % + \c@pgf@countb=\pgf@xa\divide\c@pgf@countb by16384\relax% + \c@pgf@countd=\pgf@ya\divide\c@pgf@countd by16384\relax% + \multiply\c@pgf@counta by\c@pgf@countd% + \multiply\c@pgf@countc by\c@pgf@countb% + \advance\c@pgf@counta by-\c@pgf@countc% + % + \pgf@sfalse% + \pgf@tfalse% + \ifnum\c@pgf@counta=0\relax% + \else% + \ifnum\pgfutil@tempcnta=0\relax% + \pgf@strue% + \else% + \ifnum\pgfutil@tempcnta>0\relax% + \ifnum\c@pgf@counta<\pgfutil@tempcnta% + \else% + \pgf@strue% + \fi% + \else% + \ifnum\c@pgf@counta>\pgfutil@tempcnta% + \else% + \pgf@strue% + \fi% + \fi% + \fi% + \ifnum\pgfutil@tempcntb=0\relax% + \pgf@ttrue% + \else% + \ifnum\pgfutil@tempcntb>0\relax% + \ifnum\c@pgf@counta<\pgfutil@tempcntb% + \else% + \pgf@ttrue% + \fi% + \else% + \ifnum\c@pgf@counta>\pgfutil@tempcntb% + \else% + \pgf@ttrue% + \fi% + \fi% + \fi% + \fi% + \let\pgf@intersect@next=\pgfutil@secondoftwo% + \ifpgf@s% + \ifpgf@t% + \let\pgf@intersect@next=\pgfutil@firstoftwo% + \fi% + \fi% + \pgf@intersect@next% +} + + + + +\def\pgfintersectionoflineandcurve#1#2#3#4#5#6{% + \pgf@intersect@solutions=0\relax% + \pgf@intersectionoflineandcurve{#1}{#2}{#3}{#4}{#5}{#6}% +} + +\def\pgf@intersectionoflineandcurve#1#2#3#4#5#6{% + \pgf@intersectionofcurves% + {\pgf@process{#1}}% + {% + \pgf@process{% + \pgfpointadd{#1\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}% + {#2\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}% + }% + }% + {% + \pgf@process{% + \pgfpointadd{#1\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}% + {#2\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}% + }% + }% + {\pgf@process{#2}}% + {\pgf@process{#3}}% + {\pgf@process{#4}}% + {\pgf@process{#5}}% + {\pgf@process{#6}}% +}% + +\def\pgf@intersectionofcurveandline#1#2#3#4#5#6{% + \pgf@intersectionofcurves% + {\pgf@process{#1}}% + {\pgf@process{#2}}% + {\pgf@process{#3}}% + {\pgf@process{#4}}% + {\pgf@process{#5}}% + {% + \pgf@process{% + \pgfpointadd{#5\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}% + {#6\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}% + }% + }% + {% + \pgf@process{% + \pgfpointadd{#5\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}% + {#6\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}% + }% + }% + {\pgf@process{#6}}% +}% + + + + +\def\pgfintersectiontolerance{0.1pt} +\def\pgfintersectiontolerancefactor{0.1} + + + +% Find the intersections of two bezier curves. +% +% #1 - #4 = curve 1. +% #5 - #8 = curve 2. +% #9 = the solution number. +% +% There is no guarantee of ordering of solutions. If there are +% no solutions, the origin is returned. +% +\def\pgfpointintersectionofcurves#1#2#3#4#5#6#7#8#9{% + \pgf@intersect@solutions=0\relax% + \pgf@intersectionofcurves% + {\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}% + {\pgf@process{#5}}{\pgf@process{#6}}{\pgf@process{#7}}{\pgf@process{#8}}% + \pgfpointintersectionsolution{#9}% +} + +% Return any intersection points of two curves C1 and C2. +% No order can be guaranteed for the solutions. +% +% #1, #2, #3, #4 - the points on C1 +% #5, #6, #7, #8 - the points on C2 +% +% Returns: +% +% \pgf@intersect@solutions - the number of solutions. +% \pgfpointintersectionsolution{} - the point for soultion S. +% +% (Sort of) use: +% +% intersection(C1,C2) +% S = {}; +% intersection'(C1,C2); +% return S; +% +% intersection'(C1,C2) +% B1 = boundingbox(C1); +% B2 = boundingbox(C2); +% if intersect(B1,B2) +% if (B1.width < q) and (B1.height < q) and +% (B2.width < q) and (B2.height < q) +% S = S + {average_of_all_points(B1,B2)}; \\ is there a better choice? +% else +% Q = subdivideLeft(C1); +% R = subdivideRight(C1); +% intersection'(C2,Q); +% intersection'(C2,R); +% +% where q is a small value (tolerance). +% +\def\pgfintersectionofcurves#1#2#3#4#5#6#7#8{% + \pgf@intersect@solutions=0\relax% + \pgf@intersectionofcurves% + {\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}% + {\pgf@process{#5}}{\pgf@process{#6}}{\pgf@process{#7}}{\pgf@process{#8}}% +}% +\def\pgf@intersectionofcurves#1#2#3#4#5#6#7#8{% + \begingroup% + \dimendef\pgf@time@a=2\relax% + \dimendef\pgf@time@aa=4\relax% + \dimendef\pgf@time@b=6\relax% + \dimendef\pgf@time@bb=8\relax% + \pgf@time@a=0pt\relax% + \pgf@time@aa=1pt\relax% + \pgf@time@b=0pt\relax% + \pgf@time@bb=1pt\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b% + \let\pgf@curve@subdivde@after=\pgf@@intersectionofcurves% + \pgf@@intersectionofcurves{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}% + \endgroup% +} + +\def\pgf@@intersectionofcurves#1#2#3#4#5#6#7#8{% + \pgf@intersect@boundingbox@reset% + \pgf@intersect@boundingbox@update{#1}% + \pgf@intersect@boundingbox@update{#2}% + \pgf@intersect@boundingbox@update{#3}% + \pgf@intersect@boundingbox@update{#4}% + % (\pgf@xa, \pgf@ya) is lower-left + % (\pgf@xb, \pgf@yb) is upper-right + \edef\pgf@intersect@boundingbox@b{% + \noexpand\pgf@x=\the\pgf@xa% + \noexpand\pgf@y=\the\pgf@ya% + \noexpand\pgf@xa=\the\pgf@xb% + \noexpand\pgf@ya=\the\pgf@yb% + }% + \pgf@intersect@boundingbox@reset% + \pgf@intersect@boundingbox@update{#5}% + \pgf@intersect@boundingbox@update{#6}% + \pgf@intersect@boundingbox@update{#7}% + \pgf@intersect@boundingbox@update{#8}% + \edef\pgf@intersect@boundingbox@a{% + \noexpand\pgf@xb=\the\pgf@xa% + \noexpand\pgf@yb=\the\pgf@ya% + \noexpand\pgf@xc=\the\pgf@xb% + \noexpand\pgf@yc=\the\pgf@yb% + }% + \pgf@intersect@boundingbox@a% + \pgf@intersect@boundingbox@b% + % check if the two bounding boxes overlap: + \ifdim\pgf@xa<\pgf@xb% + \else% + \ifdim\pgf@x>\pgf@xc% + \else% + \ifdim\pgf@ya<\pgf@yb% + \else% + \ifdim\pgf@y>\pgf@yc% + \else% + % compute DIFFERENCE vectors: + \advance\pgf@xc by-\pgf@xb% + \advance\pgf@yc by-\pgf@yb% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + \let\pgf@intersect@subdivde=\relax% + % check if both difference vectors are point wise + % less than tolerance (i.e. |v|_infty < eps ). + % That means that both bounding boxes are "small enough" + \ifdim\pgf@xc<\pgfintersectiontolerance\relax% + \ifdim\pgf@xa<\pgfintersectiontolerance\relax% + \ifdim\pgf@yc<\pgfintersectiontolerance\relax% + \ifdim\pgf@ya<\pgfintersectiontolerance\relax% + \pgfextract@process\pgf@intersect@solution@candidate{% + % set (x,y) = mean(the 4 points of the two bounding boxes): + \pgf@intersect@boundingbox@a% + \pgf@intersect@boundingbox@b% + \pgf@x=0.25\pgf@x% + \advance\pgf@x by0.25\pgf@xa% + \advance\pgf@x by0.25\pgf@xb% + \advance\pgf@x by0.25\pgf@xc% + \pgf@y=0.25\pgf@y% + \advance\pgf@y by0.25\pgf@ya% + \advance\pgf@y by0.25\pgf@yb% + \advance\pgf@y by0.25\pgf@yc% + }% + % We must avoid duplicate solutions. + \let\pgf@intersect@subdivde=\pgf@stop% + \pgf@ifsolution@duplicate\pgf@intersect@solution@candidate{}% + {% + \global\advance\pgf@intersect@solutions by1\relax% + \begingroup + \advance\pgf@time@a by\pgf@time@aa% + \divide\pgf@time@a by2\relax% + \advance\pgf@time@a by\pgf@intersect@time@offset pt\relax% + \edef\pgf@intersect@time@a{\pgfmath@tonumber{\pgf@time@a}}% + % + \advance\pgf@time@b by\pgf@time@bb% + \divide\pgf@time@b by2\relax% + \advance\pgf@time@b by\pgf@intersect@time@offset@b pt\relax% + \edef\pgf@intersect@time@b{\pgfmath@tonumber{\pgf@time@b}}% + % + \pgf@intersection@store@properties{pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions}% + \expandafter\global\expandafter\let% + \csname pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions\endcsname=% + \pgf@intersect@solution@candidate% + \ifpgf@intersect@sort% + \expandafter\xdef% + \csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname% + {\pgf@intersect@time@a}% + \fi% + \endgroup + }% + \fi% + \fi% + \fi% + \fi% + \ifx\pgf@intersect@subdivde\pgf@stop% + \else% + \pgf@intersect@subdivide@curve{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}% + \fi% + \fi% + \fi% + \fi% + \fi% +} + +\def\pgf@intersect@subdivide@curve@b#1#2#3#4#5#6#7#8{% + \begingroup% + \advance\pgf@time@bb by\pgf@time@b\relax% + \divide\pgf@time@bb by2\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@a% + \pgf@curve@subdivide@left{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}% + \endgroup% + \begingroup% + \advance\pgf@time@b by\pgf@time@bb\relax% + \divide\pgf@time@b by2\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@a% + \pgf@curve@subdivide@right{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}% + \endgroup% +} + +\def\pgf@intersect@subdivide@curve@a#1#2#3#4#5#6#7#8{% + \begingroup% + \advance\pgf@time@aa by\pgf@time@a\relax% + \divide\pgf@time@aa by2\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b% + \pgf@curve@subdivide@left{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}% + \endgroup% + \begingroup% + \advance\pgf@time@a by\pgf@time@aa\relax% + \divide\pgf@time@a by2\relax% + \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b% + \pgf@curve@subdivide@right{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}% + \endgroup% +} + +\def\pgf@intersect@boundingbox@reset{% + \pgf@xa=16000pt\relax% + \pgf@ya=16000pt\relax% + \pgf@xb=-16000pt\relax% + \pgf@yb=-16000pt\relax% +} + +\def\pgf@intersect@boundingbox@update#1{% + #1\relax% + \ifdim\pgf@x<\pgf@xa\pgf@xa=\pgf@x\fi% + \ifdim\pgf@y<\pgf@ya\pgf@ya=\pgf@y\fi% + \ifdim\pgf@x>\pgf@xb\pgf@xb=\pgf@x\fi% + \ifdim\pgf@y>\pgf@yb\pgf@yb=\pgf@y\fi% +} + +% The following subroutines are part of a conversion from pgfbasic +% math to FPU. This transition is necessary due to the restricted +% accuracy of pgfbasic. In order to limit the error rate of the +% transition pgfbasic -> FPU, I chose to +% keep the old "pattern" of sorts \advance\pgf@xa by0.5\pgf@y etc and +% simply adapt to some FPU call. +% +% The following routines constitute the "adapter": + +\def\pgf@float@adapter@setxy{% + \pgfmathfloatparsenumber{\pgf@sys@tonumber\pgf@x}\let\pgf@fpu@x=\pgfmathresult + \pgfmathfloatparsenumber{\pgf@sys@tonumber\pgf@y}\let\pgf@fpu@y=\pgfmathresult +}% +\def\pgf@float@adapter@mult#1=#2*#3{% + \pgfmathfloatmultiplyfixed@{#3}{#2}% + \let#1=\pgfmathresult +}% +\def\pgf@float@adapter@advance#1by#2*#3{% + \pgfmathfloatmultiplyfixed@{#3}{#2}% + \let\pgfutil@temp=\pgfmathresult + \pgfmathfloatadd@{#1}{\pgfutil@temp}% + \let#1=\pgfmathresult +}% + +\def\pgf@float@adapter@tostring#1{% + \pgfmathfloattofixed{#1}\edef#1{\pgfmathresult pt }% +}% + +\def\pgf@curve@subdivide@left#1#2#3#4{% + % + % The left curve (from t=0 to t=.5) + % + \begingroup + #1\relax% + \pgfutil@tempdima=\pgf@x% + \pgfutil@tempdimb=\pgf@y% + \pgf@float@adapter@setxy + \pgf@float@adapter@mult\pgf@fpu@xa=.5*\pgf@fpu@x \pgf@float@adapter@mult\pgf@fpu@ya=.5*\pgf@fpu@y% + \pgf@float@adapter@mult\pgf@fpu@xb=.25*\pgf@fpu@x \pgf@float@adapter@mult\pgf@fpu@yb=.25*\pgf@fpu@y% + \pgf@float@adapter@mult\pgf@fpu@xc=.125*\pgf@fpu@x\pgf@float@adapter@mult\pgf@fpu@yc=.125*\pgf@fpu@y% + #2\relax% + \pgf@float@adapter@setxy + \pgf@float@adapter@advance\pgf@fpu@xa by.5*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@ya by.5*\pgf@fpu@y% + \pgf@float@adapter@advance\pgf@fpu@xb by.5*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yb by.5*\pgf@fpu@y% + \pgf@float@adapter@advance\pgf@fpu@xc by.375*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yc by.375*\pgf@fpu@y% + #3\relax% + \pgf@float@adapter@setxy + \pgf@float@adapter@advance\pgf@fpu@xb by.25*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yb by.25*\pgf@fpu@y% + \pgf@float@adapter@advance\pgf@fpu@xc by.375*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yc by.375*\pgf@fpu@y% + #4\relax% + \pgf@float@adapter@setxy + \pgf@float@adapter@advance\pgf@fpu@xc by.125*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yc by.125*\pgf@fpu@y% + % + \pgf@float@adapter@tostring\pgf@fpu@xa + \pgf@float@adapter@tostring\pgf@fpu@ya + \pgf@float@adapter@tostring\pgf@fpu@xb + \pgf@float@adapter@tostring\pgf@fpu@yb + \pgf@float@adapter@tostring\pgf@fpu@xc + \pgf@float@adapter@tostring\pgf@fpu@yc + \edef\pgf@marshal{% + \noexpand\pgf@curve@subdivde@after% + {\noexpand\pgf@x=\the\pgfutil@tempdima\noexpand\pgf@y=\the\pgfutil@tempdimb}% + {\noexpand\pgf@x=\pgf@fpu@xa\noexpand\pgf@y=\pgf@fpu@ya}% + {\noexpand\pgf@x=\pgf@fpu@xb\noexpand\pgf@y=\pgf@fpu@yb} + {\noexpand\pgf@x=\pgf@fpu@xc\noexpand\pgf@y=\pgf@fpu@yc}% + }% + \expandafter + \endgroup + \pgf@marshal% +} + +\def\pgf@curve@subdivide@right#1#2#3#4{% + % + % The right curve (from t=0.5 to t=1) + % + \begingroup + #1\relax% + \pgf@float@adapter@setxy + \pgf@float@adapter@mult\pgf@float@tmpa=.125*\pgf@fpu@x\pgf@float@adapter@mult\pgf@float@tmpb=.125*\pgf@fpu@y% + #2\relax% + \pgf@float@adapter@setxy + \pgf@float@adapter@advance\pgf@float@tmpa by.375*\pgf@fpu@x\pgf@float@adapter@advance\pgf@float@tmpb by.375*\pgf@fpu@y% + \pgf@float@adapter@mult\pgf@fpu@xa=.25*\pgf@fpu@x\pgf@float@adapter@mult\pgf@fpu@ya=.25*\pgf@fpu@y% + #3\relax% + \pgf@float@adapter@setxy + \pgf@float@adapter@advance\pgf@float@tmpa by.375*\pgf@fpu@x\pgf@float@adapter@advance\pgf@float@tmpb by.375*\pgf@fpu@y% + \pgf@float@adapter@advance\pgf@fpu@xa by.5*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@ya by.5*\pgf@fpu@y% + \pgf@float@adapter@mult\pgf@fpu@xb=.5*\pgf@fpu@x\pgf@float@adapter@mult\pgf@fpu@yb=.5*\pgf@fpu@y% + #4\relax% + \pgf@float@adapter@setxy + \pgf@float@adapter@advance\pgf@float@tmpa by.125*\pgf@fpu@x\pgf@float@adapter@advance\pgf@float@tmpb by.125*\pgf@fpu@y% + \pgf@float@adapter@advance\pgf@fpu@xa by.25*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@ya by.25*\pgf@fpu@y% + \pgf@float@adapter@advance\pgf@fpu@xb by.5*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yb by.5*\pgf@fpu@y% + \let\pgf@fpu@xc=\pgf@fpu@x\let\pgf@fpu@yc=\pgf@fpu@y% + % + \pgf@float@adapter@tostring\pgf@float@tmpa + \pgf@float@adapter@tostring\pgf@float@tmpb + \pgf@float@adapter@tostring\pgf@fpu@xa + \pgf@float@adapter@tostring\pgf@fpu@ya + \pgf@float@adapter@tostring\pgf@fpu@xb + \pgf@float@adapter@tostring\pgf@fpu@yb + \pgf@float@adapter@tostring\pgf@fpu@xc + \pgf@float@adapter@tostring\pgf@fpu@yc + \edef\pgf@marshal{% + \noexpand\pgf@curve@subdivde@after% + {\noexpand\pgf@x=\pgf@float@tmpa\noexpand\pgf@y=\pgf@float@tmpb}% + {\noexpand\pgf@x=\pgf@fpu@xa\noexpand\pgf@y=\pgf@fpu@ya} + {\noexpand\pgf@x=\pgf@fpu@xb\noexpand\pgf@y=\pgf@fpu@yb} + {\noexpand\pgf@x=\pgf@fpu@xc\noexpand\pgf@y=\pgf@fpu@yc}% + }% + \expandafter + \endgroup + \pgf@marshal% +} + + +% A solution S1 is considered a duplicate of S2, if +% +% |x1 - x2|f < q and |y1 - y2|f < q +% +% where q is a small value (tolerance). +% +% #1 - the solution. +% +\def\pgf@ifsolution@duplicate#1{% + #1% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \let\pgf@intersect@next=\pgfutil@secondoftwo% + \pgfmathloop% + \ifnum\pgfmathcounter>\pgf@intersect@solutions\relax% + \else% + \pgf@ifsolution@duplicate@{\pgfmathcounter}% + \repeatpgfmathloop% + \pgf@intersect@next% +} + +\def\pgf@ifsolution@duplicate@#1{% + \pgf@process{\csname pgfpoint@g@intersect@solution@#1\endcsname}% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@y by-\pgf@ya% + \ifdim\pgf@x<0pt\relax\pgf@x=-\pgf@x\fi% + \ifdim\pgf@y<0pt\relax\pgf@y=-\pgf@y\fi% + % + \pgf@x=\pgfintersectiontolerancefactor\pgf@x% + \pgf@y=\pgfintersectiontolerancefactor\pgf@y% + \ifdim\pgf@x<\pgfintersectiontolerance\relax% + \ifdim\pgf@y<\pgfintersectiontolerance\relax% + \let\pgf@intersect@next=\pgfutil@firstoftwo% + \fi% + \fi% +}% + +\newif\ifpgf@intersect@solutions@sortfinish + +% Sort solutions according to their time index. +% +\def\pgfintersectionsolutionsortbytime{% + \pgf@intersect@solutions@sortfinishtrue% + \pgfmathloop% + \ifnum\pgfmathcounter=\pgfintersectionsolutions\relax% + \else% + \pgfutil@tempcnta=\pgfmathcounter% + \advance\pgfutil@tempcnta by1\relax% + \ifdim\csname pgf@intersect@solution@\pgfmathcounter @time@a\endcsname pt>% + \csname pgf@intersect@solution@\the\pgfutil@tempcnta @time@a\endcsname pt\relax% + \pgf@intersect@solutions@sortfinishfalse% + % + \pgfintersectionsolutionsortbytime@swap{pgfpoint@intersect@solution@\pgfmathcounter}% + {pgfpoint@intersect@solution@\the\pgfutil@tempcnta}% + % + \pgfintersectionsolutionsortbytime@swap{pgf@intersect@solution@\pgfmathcounter @time@a}% + {pgf@intersect@solution@\the\pgfutil@tempcnta @time@a}% + % + \pgfintersectionsolutionsortbytime@swap{pgf@intersect@solution@props@\pgfmathcounter}% + {pgf@intersect@solution@props@\the\pgfutil@tempcnta}% + \fi% + \repeatpgfmathloop% + \ifpgf@intersect@solutions@sortfinish% + \else% + \expandafter\pgfintersectionsolutionsortbytime% + \fi% +} + +\def\pgfintersectionsolutionsortbytime@swap#1#2{% + \pgfutil@namelet{pgf@intersect@temp}{#1}% + \pgfutil@namelet{#1}{#2}% + \pgfutil@namelet{#2}{pgf@intersect@temp}% +}% + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryluamath.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryluamath.code.tex new file mode 100644 index 0000000..28de060 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryluamath.code.tex @@ -0,0 +1,540 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Do 1. Jan 22:31:46 CET 2015 %%% + + + +% Copyright 2011 by Christophe Jorssen and Mark Wibrow +% Copyright 2014 by Christian Feuersänger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. +% +% $Id: pgflibraryluamath.code.tex,v 1.19 2014/12/27 14:11:49 cfeuersaenger Exp $ +% +% !!! Warning: this library does not work with fpu!!! +% +% +% This is a library for a LUA math parser and LUA math operations. +% Advantage compared to its TeX pendant: it is FASTER and has HIGHER +% ACCURACY. +% Disadvantage: any function declared by means of +% \pgfmathdeclarefunction is NOT automatically transported to the LUA +% side (at the time of this writing). +% LUA functions need to be defined by means of LUA code +% +% function pgfluamathfunctions.myoperation(a,b) +% return a*2*b +% end +% +% this will automatically set up 'myoperation' for use in +% \pgfluamathparse{myoperation(4,2)} +% +% The library has TWO use-cases which are more or less distinct: one +% is to use LUA for all math function, but not for math expression +% parsing -- this was still under control of the TeX math parser. +% This approach works like the 'fpu' library. +% +% The second approach is to use LUA to parse all math expressions - +% but if someone calls \pgfmathadd@{1}{2}, it would use the TeX +% command. This approach is relatively lightweight because it does not +% need to substitute all \pgfmath* macros. +% +% One can mix both modes. + +% ******************************************************************* +% Some luatex stuff. Should be put elsewhere (e.g. in +% pgfutil-luatex-engine). + +\edef\pgfliblua@oldcatcodedoublequote{\the\catcode`\"}% +\catcode`\"=12 + +% We assume luatex version > 0.39: +% - \directlua will work +% - \directlua is the only luatex primitive that we can assume +% accessible without being prefixed by the format via +% tex.enableprimitives. +% Ideas taken from the ifluatex package (Heiko Oberdiek) +\let\pgfutil@ifluatex\iffalse +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname directlua\endcsname\relax +\else + \expandafter\let\csname pgfutil@ifluatex\expandafter\endcsname + \csname iftrue\endcsname +\fi + +\pgfutil@ifluatex + \let\pgfutil@directlua\directlua + \pgfutil@directlua{% + tex.enableprimitives('pgfutil@',{'luaescapestring'})} +\else + \def\pgfutil@directlua#1{} + \def\pgfutil@luaescapestring#1{} +\fi + +\pgfutil@directlua{% + pgfluamathfunctions = require("pgfplotsoldpgfsupp.luamath.functions") + pgfluamathparser = require("pgfplotsoldpgfsupp.luamath.parser")} + + +% Patch some configuration macros such that the modifications are +% available in LUA as well: +\pgfkeys{ + /pgf/trig format/deg/.add code={}{\directlua{pgfluamathfunctions.setTrigFormat("deg")}\aftergroup\pgfmath@settrigformat}, + /pgf/trig format/rad/.add code={}{\directlua{pgfluamathfunctions.setTrigFormat("rad")}\aftergroup\pgfmath@settrigformat}, +} +% ... and reactivate the key: +\pgfmathiftrigonometricusesdeg{% + \pgfkeys{/pgf/trig format/deg}% +}{% + \pgfkeys{/pgf/trig format/rad}% +}% + +% re-activates the current trig format. This is important after a TeX +% group has been closed. +\def\pgfmath@settrigformat{% + \pgfmathiftrigonometricusesdeg{% + \directlua{pgfluamathfunctions.setTrigFormat("deg")}% + }{% + \directlua{pgfluamathfunctions.setTrigFormat("rad")}% + }% +}% + +\let\pgfmathsetseed@pgfbasic = \pgfmathsetseed +\def\pgfmathsetseed#1{% + \pgfmathsetseed@pgfbasic{#1}% + \directlua{pgfluamathfunctions.setRandomSeed(pgfluamathfunctions.tonumber("\pgfmathresult"))}% +}% + +% Patch 'declare function' such that it communicates the function +% directly to LUA. +\let\pgfmathnotifynewdeclarefunction@orig=\pgfmathnotifynewdeclarefunction +\def\pgfmathnotifynewdeclarefunction#1#2#3{% + \pgfmathnotifynewdeclarefunction@orig{#1}{#2}{#3}% + \directlua{pgfluamathparser.pushLocalExpressionFunction(% + "\pgfutil@luaescapestring{#1}",% + #2,% + "\pgfutil@luaescapestring{#3}")}% + % + % ensure that the local function is removed at the end of the + % scope. To this end, we maintain a stack on the LUA side. + \aftergroup\pgfluamathparse@pop@local@function +}% + +\def\pgfluamathparse@pop@local@function{% + \directlua{pgfluamathparser.popLocalExpressionFunction()}% +}% + +% End of luatex stuff +% ******************************************************************* + +% Loading part: based on fpu library + + +% if LUA failed to evaluate the expression, it will be evaluated in +% TeX as fallback. This boolean defines if the error message shall be +% shown or suppressed. The default is to suppress it and show any +% resulting TeX errors. +% +% If LUA fails \pgfmathresult will be empty. +% +% This is actually only for debugging; it will be set implicitly when +% activating/deactivating TeX fallback. +\newif\ifpgfluamathshowerrormessage + +% Defines what happens if LUA failed to evaluate the expression: if +% this is true, the TeX parser will be invoked as fallback. +% +% This happens +% - for \chardef'ed boxes for which LUA lacks evaluation capabilities +% - if the expression includes some function which is unavailable in +% LUA (defined only in TeX) +% - some special cases which simply haven't been added to the LUA +% parser (yet). +% At the time of this writing, this includes +% -- arrays created via '{}' and indexed with '[]' +% -- strings with "" +% -- 'scalar' function +% -- hex/octal/binary input +\newif\ifpgfluamathenableTeXfallback + +\newif\ifpgfluamathcomputationactive +\newif\ifpgfluamathparseractive + +\def\pgfluamath@makecomputationactive{% + \ifpgfluamathcomputationactive + \else + \pgfluamath@checkuninstallcmd% + \pgfluamath@install% + \pgfluamathcomputationactivetrue + \fi} + +\def\pgfluamath@makecomputationinactive{% + \ifpgfluamathcomputationactive + \pgfluamath@uninstall% + \pgfluamathcomputationactivefalse + \fi} + +\let\pgfluamath@pgfmathparse\pgfmathparse +\def\pgfluamath@makeparseractive{% + \ifpgfluamathparseractive + \else + \let\pgfluamath@pgfmathparse\pgfmathparse + \let\pgfmathparse\pgfluamathparse + \pgfluamathparseractivetrue + \fi} + +\def\pgfluamath@makeparserinactive{% + \ifpgfluamathparseractive + \let\pgfmathparse\pgfluamath@pgfmathparse + \pgfluamathparseractivefalse + \fi} + +\pgfqkeys{/pgf}{% + % Enable lua-side computation of \pgfmathresult + % (will be deactivated after the current TeX group) + luamath/.is choice, + luamath/only computation/.code={% + \pgfutil@ifluatex + \pgfluamath@makecomputationactive + \pgfluamath@makeparserinactive + \else + \pgfmath@error{Sorry, you need the luaTeX engine to use the + luamath library}% + \fi}, + luamath/parser and computation/.code={% + \pgfutil@ifluatex + \pgfluamath@makecomputationactive + \pgfluamath@makeparseractive + \else + \pgfmath@error{Sorry, you need the luaTeX engine to use the + luamath library}% + \fi}, + luamath/off/.code={% + \pgfluamath@makecomputationinactive + \pgfluamath@makeparserinactive}, + luamath/.default=only computation, + % + % activates ONLY the parser. This is fast and does not replace the + % \pgfmath* functions. + % @see |parser and computation| which also allows to write + % \pgfmathadd{1}{2} to call LUA + luamath/parser/.code={% + \pgfutil@ifluatex + \pgfluamath@makeparseractive + \else + \pgfmath@error{Sorry, you need the luaTeX engine to use the + luamath library}% + \fi + }, + luamath/output format/.is choice, + luamath/output format/fixed/.code= {\def\pgfluamath@outputformat@choice{0}}, + % returns results for use in the FPU + luamath/output format/float/.code= {\def\pgfluamath@outputformat@choice{1}}, + luamath/output format/fixed, + % this is merely useful for debugging purposes, I guess. + luamath/show error message/.is if=pgfluamathshowerrormessage, + luamath/enable TeX fallback/.is choice, + luamath/enable TeX fallback/true/.code={\pgfluamathenableTeXfallbacktrue\pgfluamathshowerrormessagefalse}, + luamath/enable TeX fallback/false/.code={\pgfluamathenableTeXfallbackfalse\pgfluamathshowerrormessagetrue}, + luamath/enable TeX fallback/.default=true, + luamath/enable TeX fallback=true, +} + +\def\pgfluamath@uninstall@appendcmd#1{% + \expandafter\gdef\expandafter\pgfluamath@uninstall\expandafter{% + \pgfluamath@uninstall #1}} + +% If the uninstall command is already assembled, it will skip the +% uninstall assemblation. +\def\pgfluamath@checkuninstallcmd{% + \pgfutil@ifundefined{pgfluamath@uninstall}{% + \global\let\pgfluamath@uninstall=\pgfutil@empty + }{% + % We already HAVE an uninstall command (prepared globally). + % So: don't waste time assembling one! + \def\pgfluamath@uninstall@appendcmd##1{}% + \def\pgfluamath@prepareuninstallcmd##1{}% + }% +} + +% This assembles an uninstall command globally ON FIRST USAGE. +% See \pgfmathfloat@plots@checkuninstallcmd +\def\pgfluamath@prepareuninstallcmd#1{% + \expandafter\global\expandafter\let + \csname pgfluamath@backup@\string#1\endcsname=#1% + \expandafter\gdef\expandafter\pgfluamath@uninstall\expandafter{% + \pgfluamath@uninstall + \expandafter\let\expandafter#1\csname pgfluamath@backup@\string#1\endcsname}% +} + +\def\pgfluamath@install@function#1=#2{% + \pgfluamath@prepareuninstallcmd{#1}% + \let#1=#2% +} + +\def\pgfluamath@install{% + \pgfluamath@install@function\pgfmathadd@=\pgfluamathadd@% + \pgfluamath@install@function\pgfmathsubtract@=\pgfluamathsubtract@% + \pgfluamath@install@function\pgfmathneg@=\pgfluamathneg@% + \pgfluamath@install@function\pgfmathmultiply@=\pgfluamathmultiply@% + \pgfluamath@install@function\pgfmathdivide@=\pgfluamathdivide@% + % \pgfluamath@install@function\pgfmathdiv@=\pgfluamathdiv@% + \pgfluamath@install@function\pgfmathfactorial@=\pgfluamathfactorial@% + \pgfluamath@install@function\pgfmathsqrt@=\pgfluamathsqrt@% + % \pgfluamath@install@function\pgfmathpow@=\pgfluamathpow@% + \pgfluamath@install@function\pgfmathe@=\pgfluamathe@% + \pgfluamath@install@function\pgfmathexp@=\pgfluamathexp@% + \pgfluamath@install@function\pgfmathln@=\pgfluamathln@% + \pgfluamath@install@function\pgfmathlogten@=\pgfluamathlogten@% + % \pgfluamath@install@function\pgfmathlogtwo@=\pgfluamathlogtwo@% + \pgfluamath@install@function\pgfmathabs@=\pgfluamathabs@% + \pgfluamath@install@function\pgfmathmod@=\pgfluamathmod@% + \pgfluamath@install@function\pgfmathMod@=\pgfluamathMod@% + \pgfluamath@install@function\pgfmathround@=\pgfluamathround@% + \pgfluamath@install@function\pgfmathfloor@=\pgfluamathfloor@% + \pgfluamath@install@function\pgfmathceil@=\pgfluamathceil@% + % \pgfluamath@install@function\pgfmathint@=\pgfluamathint@% + % \pgfluamath@install@function\pgfmathfrac@=\pgfluamathfrac@% + % \pgfluamath@install@function\pgfmathreal@=\pgfluamathreal@% + \pgfluamath@install@function\pgfmathgcd@=\pgfluamathgcd@% + \pgfluamath@install@function\pgfmathisprime@=\pgfluamathisprime@% + \pgfluamath@install@function\pgfmathpi@=\pgfluamathpi@% + \pgfluamath@install@function\pgfmathrad@=\pgfluamathrad@% + \pgfluamath@install@function\pgfmathdeg@=\pgfluamathdeg@% + \pgfluamath@install@function\pgfmathsin@=\pgfluamathsin@% + \pgfluamath@install@function\pgfmathcos@=\pgfluamathcos@% + \pgfluamath@install@function\pgfmathtan@=\pgfluamathtan@% + \pgfluamath@install@function\pgfmathsec@=\pgfluamathsec@% + \pgfluamath@install@function\pgfmathcosec@=\pgfluamathcosec@% + \pgfluamath@install@function\pgfmathcot@=\pgfluamathcot@% + \pgfluamath@install@function\pgfmathasin@=\pgfluamathasin@% + \pgfluamath@install@function\pgfmathacos@=\pgfluamathacos@% + \pgfluamath@install@function\pgfmathatan@=\pgfluamathatan@% + \pgfluamath@install@function\pgfmathatantwo@=\pgfluamathatantwo@% + \pgfluamath@install@function\pgfmathmax@=\pgfluamathmax@% + \pgfluamath@install@function\pgfmathmin@=\pgfluamathmin@% + % \pgfluamath@install@function\pgfmath@pi=\pgfluamathpi@% + % \pgfluamath@install@function\pgfmathpi=\pgfluamathpi@% + % \pgfluamath@install@function\pgfmathe@=\pgfluamathe@% + % \pgfluamath@install@function\pgfmathe=\pgfluamathe@% + % \pgfluamath@install@function\pgfmathlessthan@=\pgfluamathlessthan@% + % \pgfluamath@install@function\pgfmathless@=\pgfluamathlessthan@% + % \pgfluamath@install@function\pgfmathgreaterthan@=\pgfluamathgreaterthan@% + % \pgfluamath@install@function\pgfmathgreater@=\pgfluamathgreaterthan@% + % \pgfluamath@install@function\pgfmathpow@=\pgfluamathpow@ + \pgfluamath@install@function\pgfmathrand@=\pgfluamathrand@ + \pgfluamath@install@function\pgfmathrand=\pgfluamathrand@ + \pgfluamath@install@function\pgfmathrnd@=\pgfluamathrnd@ + \pgfluamath@install@function\pgfmathrnd=\pgfluamathrnd@ + % \pgfluamath@install@function\pgfmathtrue@=\pgfluamathtrue@ + % \pgfluamath@install@function\pgfmathfalse@=\pgfluamathfalse@ + % \pgfluamath@install@function\pgfmathnot@=\pgfluamathnot@ + % \pgfluamath@install@function\pgfmathhex@=\pgfluamathhex@ + % \pgfluamath@install@function\pgfmathHex@=\pgfluamathHex@ + % \pgfluamath@install@function\pgfmathoct@=\pgfluamathoct@ + % \pgfluamath@install@function\pgfmathbin@=\pgfluamathbin@ + % \pgfluamath@install@function\pgfmathand@=\pgfluamathand@ + % \pgfluamath@install@function\pgfmathor@=\pgfluamathor@ + % \pgfluamath@install@function\pgfmathfactorial@=\pgfluamathfactorial@ + % \pgfluamath@install@function\pgfmathveclen@=\pgfluamathveclen@ + % \pgfluamath@install@function\pgfmathcosh@=\pgfluamathcosh@ + % \pgfluamath@install@function\pgfmathsinh@=\pgfluamathsinh@ + % \pgfluamath@install@function\pgfmathtanh@=\pgfluamathtanh@ + % \pgfluamath@install@function@unimplemented{ceil}% + % \pgfluamath@install@function@unimplemented{frac}% + % \pgfluamath@install@function@unimplemented{log2}% + % \pgfluamath@install@function@unimplemented{log10}% + % \pgfluamath@install@function@unimplemented{equalto}% + % \pgfluamath@install@function@unimplemented{random}% + % \pgfluamath@install@function@unimplemented{setseed}% + % \pgfluamath@install@function@unimplemented{Mod}% + % \pgfluamath@install@function@unimplemented{real}% + % \pgfluamath@install@function@unimplemented{notequal}% + \pgfluamath@install@function\pgfmathreciprocal=\pgfluamathreciprocal% + \pgfluamath@install@function\pgfpointnormalised=\pgfluamathpointnormalised +} + +\def\pgfluamathgetresult#1{% + \edef\pgfmathresult{\pgfutil@directlua{tex.print(-1,#1)}}} + +\def\pgfluamathpi@{% + \pgfluamathgetresult{pgfluamathfunctions.pi()}} +\def\pgfluamathe@{% + \pgfluamathgetresult{pgfluamathfunctions.e()}} +\def\pgfluamathadd@#1#2{% + \pgfluamathgetresult{pgfluamathfunctions.add(#1,#2)}} +\def\pgfluamathsubtract@#1#2{% + \pgfluamathgetresult{pgfluamathfunctions.substract(#1,#2)}} +\def\pgfluamathneg@#1{% + \pgfluamathgetresult{pgfluamathfunctions.neg(#1)}} +\def\pgfluamathmultiply@#1#2{% + \pgfluamathgetresult{pgfluamathfunctions.multiply(#1,#2)}} +\def\pgfluamathdivide@#1#2{% + \pgfluamathgetresult{pgfluamathfunctions.divide(#1,#2)}} +\def\pgfluamathabs@#1{% + \pgfluamathgetresult{pgfluamathfunctions.abs(#1)}} +\def\pgfluamathround@#1{% + \pgfluamathgetresult{pgfluamathfunctions.round(#1)}} +\def\pgfluamathfloor@#1{% + \pgfluamathgetresult{pgfluamathfunctions.floor(#1)}} +\def\pgfluamathceil@#1{% + \pgfluamathgetresult{pgfluamathfunctions.ceil(#1)}} +\def\pgfluamathgcd@#1#2{% + \pgfluamathgetresult{pgfluamathfunctions.gcd(#1,#2)}} +\def\pgfluamathisprime@#1{% + \pgfluamathgetresult{pgfluamathfunctions.isprime(#1)}} +\def\pgfluamathmax@#1{% + \pgfluamathgetresult{% + math.max(pgfluamathfunctions.split_braces_to_explist("#1"))}} +\def\pgfluamathmin@#1{% + \pgfluamathgetresult{% + math.min(pgfluamathfunctions.split_braces_to_explist("#1"))}} +\def\pgfluamathsin@#1{% + \pgfluamathgetresult{pgfluamathfunctions.Sin(#1)}} +\def\pgfluamathcos@#1{% + \pgfluamathgetresult{pgfluamathfunctions.Cos(#1)}} +\def\pgfluamathtan@#1{% + \pgfluamathgetresult{pgfluamathfunctions.Tan(#1)}} +\def\pgfluamathmod@#1#2{% + \pgfluamathgetresult{pgfluamathfunctions.mod(#1,#2)}} +\def\pgfluamathMod@#1#2{% + \pgfluamathgetresult{pgfluamathfunctions.Mod(#1,#2)}} +\def\pgfluamathrad@#1{% + \pgfluamathgetresult{pgfluamathfunctions.rad(#1)}} +\def\pgfluamathdeg@#1{% + \pgfluamathgetresult{pgfluamathfunctions.deg(#1)}} +\def\pgfluamathatan@#1{% + \pgfluamathgetresult{pgfluamathfunctions.aTan(#1)}} +\def\pgfluamathatantwo@#1#2{% + \pgfluamathgetresult{pgfluamathfunctions.aTan2(#1,#2)}} +\def\pgfluamathasin@#1{% + \pgfluamathgetresult{pgfluamathfunctions.aSin(#1)}} +\def\pgfluamathacos@#1{% + \pgfluamathgetresult{pgfluamathfunctions.aCos(#1)}} +\def\pgfluamathcot@#1{% + \pgfluamathgetresult{1/pgfluamathfunctions.Tan(#1)}} +\def\pgfluamathsec@#1{% + \pgfluamathgetresult{1/pgfluamathfunctions.Cos(#1)}} +\def\pgfluamathcosec@#1{% + \pgfluamathgetresult{1/pgfluamathfunctions.Sin(#1)}} +\def\pgfluamathexp@#1{% + \pgfluamathgetresult{pgfluamathfunctions.exp(#1)}} +\def\pgfluamathln@#1{% + \pgfluamathgetresult{pgfluamathfunctions.log(#1)}} +\def\pgfluamathlogten@#1{% + \pgfluamathgetresult{pgfluamathfunctions.log10(#1)}} +\def\pgfluamathsqrt@#1{% + \pgfluamathgetresult{pgfluamathfunctions.sqrt(#1)}} +\def\pgfluamathrnd@{% + \pgfluamathgetresult{pgfluamathfunctions.rnd()}} +\def\pgfluamathrand@{% + \pgfluamathgetresult{pgfluamathfunctions.rand(-1,1)}} +\def\pgfluamathfactorial@#1{% + \pgfluamathgetresult{pgfluamathfunctions.factorial(#1)}} +\def\pgfluamathreciprocal#1{% + \pgfluamathgetresult{1/#1}} +% \pgfluamath@install@function\pgfmath@pi=\pgfluamathpi@% +% \pgfluamath@install@function\pgfmathpi=\pgfluamathpi@% +% \pgfluamath@install@function\pgfmathe@=\pgfluamathe@% +% \pgfluamath@install@function\pgfmathe=\pgfluamathe@% +% \pgfluamath@install@function\pgfmathlessthan@=\pgfluamathlessthan@% +% \pgfluamath@install@function\pgfmathless@=\pgfluamathlessthan@% +% \pgfluamath@install@function\pgfmathgreaterthan@=\pgfluamathgreaterthan@% +% \pgfluamath@install@function\pgfmathgreater@=\pgfluamathgreaterthan@% +% \pgfluamath@install@function\pgfmathpow@=\pgfluamathpow@ +% \pgfluamath@install@function\pgfmathrand@=\pgfluamathrand@ +% \pgfluamath@install@function\pgfmathrand=\pgfluamathrand@ +% \pgfluamath@install@function\pgfmathrnd@=\pgfluamathrnd@ +% \pgfluamath@install@function\pgfmathrnd=\pgfluamathrnd@ +% \pgfluamath@install@function\pgfmathtrue@=\pgfluamathtrue@ +% \pgfluamath@install@function\pgfmathfalse@=\pgfluamathfalse@ +% \pgfluamath@install@function\pgfmathnot@=\pgfluamathnot@ +% \pgfluamath@install@function\pgfmathhex@=\pgfluamathhex@ +% \pgfluamath@install@function\pgfmathHex@=\pgfluamathHex@ +% \pgfluamath@install@function\pgfmathoct@=\pgfluamathoct@ +% \pgfluamath@install@function\pgfmathbin@=\pgfluamathbin@ +% \pgfluamath@install@function\pgfmathand@=\pgfluamathand@ +% \pgfluamath@install@function\pgfmathor@=\pgfluamathor@ +% \pgfluamath@install@function\pgfmathfactorial@=\pgfluamathfactorial@ +% \pgfluamath@install@function\pgfmathveclen@=\pgfluamathveclen@ +% \pgfluamath@install@function\pgfmathcosh@=\pgfluamathcosh@ +% \pgfluamath@install@function\pgfmathsinh@=\pgfluamathsinh@ +% \pgfluamath@install@function\pgfmathtanh@=\pgfluamathtanh@ + +\def\pgfluamathpointnormalised#1{% + \pgf@process{#1}% + \pgfutil@directlua{% + pgfluamathfunctions.pointnormalised(% + \pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})}% + \ignorespaces} + +% Parser + +\newif\ifpgfluamathunitsdeclared + +% true if and only if LUA failed to evaluate the expression and the +% expression was evaluated by means of the TeX parser as fallback. +% +% This happens +% - for \chardef'ed boxes for which LUA lacks evaluation capabilities +% - if the expression includes some function which is unavailable in +% LUA (defined only in TeX) +% - some special cases which simply haven't been added to the LUA +% parser (yet). +% At the time of this writing, this includes +% -- arrays created via '{}' and indexed with '[]' +% -- strings with "" +% -- 'scalar' function +% -- hex/octal/binary input +\newif\ifpgfluamathusedTeXfallback + +% Parses the math expression and defines \pgfmathresult and +% \ifpgfmathunitsdeclared to contain the result. +% +% If \ifpgfluamathparseractive then the result is also assigned to +% \pgfmathresult. Furthermore, if the expression cannot be evaluated (because LUA does not support +% it), it will be evaluated by mean of TeX as fallback. +% +% @see \ifpgfluamathusedTeXfallback +% @see \ifpgfluamathshowerrormessage +\def\pgfluamathparse#1{% + \pgfluamathusedTeXfallbackfalse + \pgfutil@directlua{pgfluamathparser.texCallParser( + "\pgfutil@luaescapestring{#1}", + \pgfluamath@outputformat@choice, + \ifpgfluamathshowerrormessage true\else false\fi)% + }% + \ifx\pgfmathresult\pgfutil@empty + \ifpgfluamathenableTeXfallback + \pgfluamathusedTeXfallbacktrue + \pgfluamath@pgfmathparse{#1}% + \fi + \fi +} + +\catcode`\"=\pgfliblua@oldcatcodedoublequote +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex new file mode 100644 index 0000000..aa3c0e8 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex @@ -0,0 +1,1141 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%% + + + +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplothandlers.code.tex,v 1.17 2012/09/11 20:03:46 ludewich Exp $ + +\newif\ifpgf@plot@started + + +% This handler converts each plot stream command into a curveto +% command, except for the first, which is converted to the previously +% specified action. +% +% Example: +% +% \pgfpathmoveto{\pgfpointorigin} +% \pgfsetlinetofirstplotpoint +% \pgfplothandlercurveto +% \pgfplotxyfile{mytable} + +\def\pgfplothandlercurveto{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@initial% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgf@plot@curveto@handler@finish% + \global\pgf@plot@startedfalse% + }% +} + +\def\pgf@plot@curveto@handler@initial#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@plot@first@action{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@curveto@first{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \global\let\pgf@plot@curveto@first@support=\pgf@plot@curveto@first% + \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@second% +} + +\def\pgf@plot@curveto@handler@second#1{% + \pgf@process{#1}% + \xdef\pgf@plot@curveto@second{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@third% + \global\pgf@plot@startedtrue% +} + +\def\pgf@plot@curveto@handler@third#1{% + \pgf@process{#1}% + \xdef\pgf@plot@curveto@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@curveto@first} + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@curveto@second}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@curveto@first@support}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@curveto@second}}% + {\pgf@marshal}% + % Prepare next: + \global\let\pgf@plot@curveto@first=\pgf@plot@curveto@second% + \global\let\pgf@plot@curveto@second=\pgf@plot@curveto@current% + \xdef\pgf@plot@curveto@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% +} + +\def\pgf@plot@curveto@handler@finish{% + \ifpgf@plot@started% + \pgfpathcurveto{\pgf@plot@curveto@first@support}{\pgf@plot@curveto@second}{\pgf@plot@curveto@second}% + \fi% +} + + +% This commands sets the tension for smoothing of plots. +% +% #1 = tension of curves. A value of 1 will yield a circle when the +% control points are at quarters of a circle. A smaller value +% will result in a tighter curve. Default is 0.5. +% +% Example: +% +% \pgfsetplottension{0.2} + +\def\pgfsetplottension#1{% + \pgf@x=#1pt\relax% + \pgf@x=0.2775\pgf@x\relax% + \edef\pgf@plottension{\pgf@sys@tonumber\pgf@x}} +\pgfsetplottension{0.5} + + +% This handler converts the plot stream command into a curveto +% command that is closed using a closepath. +% +% Example: +% +% \pgfpathmoveto{\pgfpointorigin} +% \pgfplothandlerclosedcurve +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerclosedcurve{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@initial% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgf@plot@closedcurve@handler@finish% + }% +} + +\def\pgf@plot@closedcurve@handler@initial#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@closedcurve@initial{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@second% + \global\pgf@plot@startedfalse% +} + +\def\pgf@plot@closedcurve@handler@second#1{% + \pgf@process{#1}% + \xdef\pgf@plot@closedcurve@after@initial{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + {\pgfpathmoveto{}}% + \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@third% +} + +\def\pgf@plot@closedcurve@handler@third#1{% + \global\pgf@plot@startedtrue% + \pgf@process{#1}% + \xdef\pgf@plot@closedcurve@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@closedcurve@initial} + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@closedcurve@after@initial}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@after@initial% + \global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current% + \xdef\pgf@plot@closedcurve@after@initial@presupport{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@fourth% +} + +\def\pgf@plot@closedcurve@handler@fourth#1{% + \pgf@process{#1}% + \xdef\pgf@plot@closedcurve@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@closedcurve@first} + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@closedcurve@second}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}% + {\pgf@marshal}% + % Prepare next: + \global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@second% + \global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current% + \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% +} + +\def\pgf@plot@closedcurve@handler@finish{% + \ifpgf@plot@started + % + % first, draw line from 2nd last to last: + % + \pgf@process{\pgf@plot@closedcurve@initial}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@closedcurve@first}% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@closedcurve@second}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}% + {\pgf@marshal}% + \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + % + % second, draw line from last point to start: + % + \pgf@process{\pgf@plot@closedcurve@after@initial}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@closedcurve@second}% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@closedcurve@initial}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@initial}}% + {\pgf@marshal}% + % + % third, draw line from first to second point: + % + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + {\noexpand\pgf@plot@closedcurve@after@initial@presupport}{\noexpand\pgf@plot@closedcurve@after@initial}}% + {\pgf@marshal}% + \pgfpathclose% + \fi% +} + + + + + +% This handler converts each point in a stream into a line from the +% $y$-axis to the given points coordinate, resulting in a +% ``comb.'' +% +% Example: +% +% \pgfplothandlerxcomb +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerxcomb{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@xcomb@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfplotxzerolevelstreamstart + }% +} + +\def\pgf@plot@xcomb@handler#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% +} + + +% This handler converts each point in a stream into a line from the +% $x$-axis straight up to the given points coordinate, resulting in a +% ``comb.'' +% +% Example: +% +% \pgfplothandlerycomb +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerycomb{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@ycomb@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfplotyzerolevelstreamstart + }% +} + +\def\pgf@plot@ycomb@handler#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% +} + +% PGF Bar or comb plots usually draw something from zero to the current plot's coordinate. +% +% The 'zero' offset can be changed using an input stream. +% +% There are two such streams which can be configured independently. +% The first one returns "zeros" for coordinate x, the second one +% returns "zeros" for coordinate y. +% +% \pgfplotxzerolevelstreamstart +% \pgfplotxzerolevelstreamnext % assigns \pgf@x globally +% \pgfplotxzerolevelstreamnext +% \pgfplotxzerolevelstreamnext +% \pgfplotxzerolevelstreamend +% +% and +% \pgfplotyzerolevelstreamstart +% \pgfplotyzerolevelstreamnext % assigns \pgf@x globally +% \pgfplotyzerolevelstreamend +% +\def\pgfplotxzerolevelstreamstart{\pgf@plotxzerolevelstreamstart}% +\def\pgfplotxzerolevelstreamend{\pgf@plotxzerolevelstreamend}% +\def\pgfplotxzerolevelstreamnext{\pgf@plotxzerolevelstreamnext} +\def\pgfplotyzerolevelstreamstart{\pgf@plotyzerolevelstreamstart}% +\def\pgfplotyzerolevelstreamend{\pgf@plotyzerolevelstreamend}% +\def\pgfplotyzerolevelstreamnext{\pgf@plotyzerolevelstreamnext} + +% This zero level stream always returns '#1' (a dimension). +\def\pgfplotxzerolevelstreamconstant#1{% + \edef\pgfplotxzerolevelstreamconstant@val{#1}% + \def\pgf@plotxzerolevelstreamstart{% + \global\let\pgf@plotxzerolevelstreamend=\relax + \gdef\pgf@plotxzerolevelstreamnext{\global\pgf@x=\pgfplotxzerolevelstreamconstant@val\relax}% + }% +}% +\pgfplotxzerolevelstreamconstant{0pt}% + +% This zero level stream always returns '#1'. +\def\pgfplotyzerolevelstreamconstant#1{% + \edef\pgfplotyzerolevelstreamconstant@val{#1}% + \def\pgf@plotyzerolevelstreamstart{% + \global\let\pgf@plotyzerolevelstreamend=\relax + \gdef\pgf@plotyzerolevelstreamnext{\global\pgf@x=\pgfplotyzerolevelstreamconstant@val\relax}% + }% +}% +\pgfplotyzerolevelstreamconstant{0pt}% + +\def\pgfplotbarwidth{\pgfkeysvalueof{/pgf/bar width}} +\def\pgfplotbarshift{\pgfkeysvalueof{/pgf/bar shift}} + +\pgfqkeys{/pgf}{% + bar width/.initial=10pt, + bar shift/.initial=0pt, + bar interval width/.initial=1, + bar interval shift/.initial=0.5, + % + % hook which is executed right before a new bar is begun. + at begin bar/.initial=, + % hook which is executed right after a bar path has been finished. + % In this context, the bar's path has not been used. + at end bar/.initial=, +} + +% This handler places a rectangle at each point in the plot stream, a +% rectangle which touches the x-axis at one end and the current point +% at the other end: +% --(X)-- +% | | +% | | +% | | +% --(0)-- +% Example: +% +% \pgfplothandlerybar +% \pgfplotxyfile{mytable} +\def\pgfplothandlerybar{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@ybar@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfmathparse{\pgfplotbarwidth}% + \xdef\pgfplotbarwidth@{\pgfmathresult pt}% + \pgfmathparse{\pgfplotbarshift}% + \xdef\pgfplotbarshift@{\pgfmathresult pt}% + \pgfplotyzerolevelstreamstart + }% +} + +\def\pgf@plot@ybar@handler#1{% + \pgfkeysvalueof{/pgf/at begin bar}% + \pgf@process{#1}% + \pgf@ya=\pgf@y + \expandafter\pgf@xb\pgfplotbarwidth@\relax + \pgf@xc=\pgf@x + \advance\pgf@xc by-.5\pgf@xb + \advance\pgf@xc by\pgfplotbarshift@\relax + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@xc}{\pgf@yb}}% + {\pgfqpoint{\pgf@xb}{\pgf@ya}}% + \pgfkeysvalueof{/pgf/at end bar}% +} + +% This handler places a rectangle at each point in the plot stream, a +% rectangle which touches the y-axis at one end and the current point +% at the other end: +% --------- +% | | +% (0) (X) +% | | +% --------- +% Example: +% +% \pgfplothandlerxbar +% \pgfplotxyfile{mytable} +\def\pgfplothandlerxbar{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@xbar@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfmathparse{\pgfplotbarwidth}% + \xdef\pgfplotbarwidth@{\pgfmathresult pt}% + \pgfmathparse{\pgfplotbarshift}% + \xdef\pgfplotbarshift@{\pgfmathresult pt}% + \pgfplotxzerolevelstreamstart + }% +} + +\def\pgf@plot@xbar@handler#1{% + \pgfkeysvalueof{/pgf/at begin bar}% + \pgf@process{#1}% + \pgf@ya=\pgf@x + \expandafter\pgf@xb\pgfplotbarwidth@\relax + \pgf@xc=\pgf@y + \advance\pgf@xc by-.5\pgf@xb + \advance\pgf@xc by\pgfplotbarshift@\relax + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@yb}{\pgf@xc}}% + {\pgfqpoint{\pgf@ya}{\pgf@xb}}% + \pgfkeysvalueof{/pgf/at end bar}% +} + +% This handler is a variant of \pgfplothandlerybar which works with +% intervals instead of points. +% +% Bars are drawn between successive input coordinates and the width is +% determined relatively to the interval length. +% +% It looks like this: +% +% |---| |-----| +% | | | | +% | | | | +% | | | | +% (X)------(X)-----------(X) +% +% where (X) denotes the x-axis offsets of input coordinates. +% +% In more detail, if (x_i,y_i) and (x_{i+1},y_{i+1}) denote successive +% input coordinates, the bar will be placed above the +% interval [x_i,x_{i+1}], centered at +% +% x_i + \pgfkeysvalueof{/pgf/bar interval shift} * (x_{i+1} - x_i) +% +% with width +% +% \pgfkeysvalueof{/pgf/bar interval width} * (x_{i+1} - x_i). +% +% If you have N+1 input points, you will get N bars (one for each +% interval). The y_i value of the last bar will be ignored. +% +% Example: +% +% \pgfplothandlerybarinterval +% \pgfplotxyfile{mytable} +\def\pgfplothandlerybarinterval{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler@first% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}% + \xdef\pgfplotbarintervalwidth@{\pgfmathresult}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}% + \xdef\pgfplotbarintervalshift@{\pgfmathresult}% + \pgfplotyzerolevelstreamstart + }% +} + +\def\pgf@plot@ybarinterval@handler@first#1{% + \pgf@process{#1}% + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}% + \xdef\pgf@plot@barinterval@bar{\the\pgf@y}% + \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler% +} +\def\pgf@plot@ybarinterval@handler#1{% + \pgfkeysvalueof{/pgf/at begin bar}% + \pgf@process{#1}% + \pgf@ya=\pgf@plot@barinterval@bar + \xdef\pgf@plot@barinterval@bar{\the\pgf@y}% + \pgf@xc=\pgf@plot@barinterval@intervalstart\relax + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}% + \pgf@xb=\pgf@x + \advance\pgf@xb by-\pgf@xc + \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb + \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb + \advance\pgf@xc by-.5\pgf@xb% center + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@xc}{\pgf@yb}}% + {\pgfqpoint{\pgf@xb}{\pgf@ya}}% + \pgfkeysvalueof{/pgf/at end bar}% +} + +% Like \pgfplothandlerybarinterval but for xbar. +\def\pgfplothandlerxbarinterval{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler@first% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}% + \xdef\pgfplotbarintervalwidth@{\pgfmathresult}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}% + \xdef\pgfplotbarintervalshift@{\pgfmathresult}% + \pgfplotxzerolevelstreamstart + }% +} + +\def\pgf@plot@xbarinterval@handler@first#1{% + \pgf@process{#1}% + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}% + \xdef\pgf@plot@barinterval@bar{\the\pgf@x}% + \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler% +} +\def\pgf@plot@xbarinterval@handler#1{% + \pgfkeysvalueof{/pgf/at begin bar}% + \pgf@process{#1}% + \pgf@ya=\pgf@plot@barinterval@bar + \xdef\pgf@plot@barinterval@bar{\the\pgf@x}% + \pgf@xc=\pgf@plot@barinterval@intervalstart\relax + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}% + \pgf@xb=\pgf@y + \advance\pgf@xb by-\pgf@xc + \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb + \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb + \advance\pgf@xc by-.5\pgf@xb% center + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@yb}{\pgf@xc}}% + {\pgfqpoint{\pgf@ya}{\pgf@xb}}% + \pgfkeysvalueof{/pgf/at end bar}% +} + + +% This handler is very similar to \pgfplothandlerlineto, but it +% produces CONSTANT connected pieces of the form +% +% x +% | +% x--- | +% | x---- +% x-| +% +% Example: +% +% \pgfplothandlerconstantlineto +% \pgfplotxyfile{mytable} +\def\pgfplothandlerconstantlineto{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@const@line@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler@@% +} +\def\pgf@plot@const@line@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@yb\pgf@plot@const@line@handler@last\relax + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}% +} + +% A variant of \pgfplothandlerconstantlineto which places its mark on +% the right line ends. +% +% |---x +% ---x | +% |--x +% x +% +% Example: +% +% \pgfplothandlerconstantlinetomarkright +% \pgfplotxyfile{mytable} +\def\pgfplothandlerconstantlinetomarkright{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@const@line@mark@right@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler@@% +} +\def\pgf@plot@const@line@mark@right@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@yb\pgf@plot@const@line@handler@last\relax + \pgfpathlineto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}% +} + +% A variant of \pgfplothandlerconstantlineto which places its mark on +% the middle of the line segment. +% +% ----x +% | +% --x--- | +% | |--x---- +% x-- +% +% Example: +% +% \pgfplothandlerconstantlinetomarkmid +% \pgfplotxyfile{mytable} +\def\pgfplothandlerconstantlinetomarkmid{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@mid@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@const@line@mark@mid@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@mid@handler@@% +} +\def\pgf@plot@const@line@mark@mid@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@plot@const@line@handler@last + \pgf@xc=.5\pgf@xa + \advance\pgf@xc by.5\pgf@x + \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@y}}% + \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% +} + +% This handler is in fact a variant of \pgfplothandlerconstantlineto, +% but it does not draw vertical lines. It produces a sequence of +% line-to and move-to operations such that plot marks are placed at +% each right end: +% +% ---x +% ---x +% ---x +% --x +% +% Example: +% +% \pgfplothandlerjumpmarkright +% \pgfplotxyfile{mytable} +\def\pgfplothandlerjumpmarkright{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@jumpmarkright@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler@@% +} +\def\pgf@plot@jumpmarkright@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@yb\pgf@plot@const@line@handler@last\relax + \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}% +} + +% This handler is in fact a variant of \pgfplothandlerconstantlineto, +% but it does not draw vertical lines. It produces a sequence of +% line-to and move-to operations such that plot marks are placed at +% each left end: +% +% x--- +% x--- +% x--- +% x-- +% +% Example: +% +% \pgfplothandlerjumpmarkleft +% \pgfplotxyfile{mytable} +\def\pgfplothandlerjumpmarkleft{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@jumpmarkleft@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler@@% +} +\def\pgf@plot@jumpmarkleft@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@yb\pgf@plot@const@line@handler@last\relax + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}% +} + +% This handler is in fact a variant of +% \pgfplothandlerconstantlinetomarkmid, +% but it does not draw vertical lines. It produces a sequence of +% line-to and move-to operations such that plot marks are placed like +% +% ----x +% +% --x-- +% --x---- +% x-- +% +% Example: +% +% \pgfplothandlerjumpmarkmid +% \pgfplotxyfile{mytable} +\def\pgfplothandlerjumpmarkmid{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@jump@mark@mid@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@jump@mark@mid@handler#1{% + \pgf@process{#1}% + \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + \pgf@plot@first@action{}% + \global\let\pgf@plotstreampoint=\pgf@plot@jump@mark@mid@handler@@% +} +\def\pgf@plot@jump@mark@mid@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@plot@const@line@handler@last + \pgf@xc=.5\pgf@xa + \advance\pgf@xc by.5\pgf@x + \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@y}}% + \pgfpathmoveto{\pgfqpoint{\pgf@xc}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% +} + + +% This handler converts each point in a stream into a line from the +% origin to the point's coordinate, resulting in a ``star''. +% +% Example: +% +% \pgfplothandlerpolarcomb +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerpolarcomb{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@polarcomb@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} + +\def\pgf@plot@polarcomb@handler#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgfpathmoveto{\pgfpointorigin}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% +} + + + + +% This handler draws a given mark at each point. +% +% #1 = some code to be executed at each point (with the coordinate +% system translated to that point). +% Typically, this code will be \pgfuseplotmark{whatever}. +% +% Example: +% +% \pgfplothandlermark{\pgfuseplotmark{*}} +% \pgfplotxyfile{mytable} + +\def\pgfplothandlermark#1{% + \pgf@plothandlermark{% + \ifnum\pgf@plot@mark@count<\pgf@plot@mark@repeat\relax% + \else% + \global\pgf@plot@mark@count=0\relax% + #1% + \fi% + }% +} + +\newcount\pgf@plot@mark@count +\def\pgf@plot@mark@phase{0} + +\def\pgf@plothandlermark#1{% + \def\pgf@plot@mark{#1}% + \def\pgf@plotstreamstart{% + \global\pgf@plot@mark@count=\pgf@plot@mark@repeat\relax% + \global\advance\pgf@plot@mark@count by-\pgf@plot@mark@phase\relax% + \global\let\pgf@plotstreampoint=\pgf@plot@mark@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} + +\def\pgf@plot@mark@handler#1{% + \global\advance\pgf@plot@mark@count by1\relax% + {\pgftransformshift{#1}\pgf@plot@mark}% +} + + +% Set the repeat count for marks. For example, if 3 is given as a +% value, only every third point will get a mark. +% +% #1 = repeat count +% +% Example: +% +% \pgfsetplotmarkrepeat{2} + +\def\pgfsetplotmarkrepeat#1{\def\pgf@plot@mark@repeat{#1}} +\pgfsetplotmarkrepeat{1} + + +% Set the phase for marks. For example, if 3 is the repeat and 3 is +% the phase, already the first point will be marked. +% +% #1 = the index of the first point that should be marked. +% +% Example: +% +% \pgfsetplotmarkphase{3} + +\def\pgfsetplotmarkphase#1{\def\pgf@plot@mark@phase{#1}} +\pgfsetplotmarkphase{1} + + + +% This handler draws a given mark at those points whose number is +% given in the (pgffor-like) list. +% +% #1 = some code to be executed at each point (with the coordinate +% system translated to that point). +% Typically, this code will be \pgfuseplotmark{whatever}. +% #2 = list of positions like "1,2,4,...,9,10" +% +% Example: +% +% \pgfplothandlermarklisted{\pgfuseplotmark{*}}{1,2,4,...,9} +% \pgfplotxyfile{mytable} + +\def\pgfplothandlermarklisted#1#2{% + \let\pgf@plot@mark@list=\pgfutil@empty% + \edef\pgf@marshal{\noexpand\foreach\noexpand\pgf@temp in{#2}} + \pgf@marshal{\xdef\pgf@plot@mark@list{\pgf@plot@mark@list(\pgf@temp)}}% + \pgf@plothandlermark{% + \edef\pgf@marshal{\noexpand\pgfutil@in@{(\the\pgf@plot@mark@count)}{\pgf@plot@mark@list}}% + \pgf@marshal% + \ifpgfutil@in@#1\fi}% +} + + +% Define a new plot mark for use with \pgfplotmark. +% +% #1 = a plot mark mnemonic +% #2 = code for drawing the mark +% +% Example: +% +% \pgfdeclareplotmark{*}{\pgfpathcircle{\pgfpointorigin}{2pt}\pgfusepathqfill} + +\def\pgfdeclareplotmark#1#2{\expandafter\def\csname pgf@plot@mark@#1\endcsname{#2}} + + +% Set the size of plot marks. For circles, this will be the radius, +% for other shapes it should be about half the width/height. +% +% Example: +% +% \pgfsetplotmarksize{1pt} + +\def\pgfsetplotmarksize#1{\pgfmathsetlength\pgfplotmarksize{#1}} + +\newdimen\pgfplotmarksize +\pgfplotmarksize=2pt + + +% Insert a plot mark's code at the origin. +% +% #1 = plot mark mnemonic +% +% Example: +% +% \pgfuseplotmark{*} + +\def\pgfuseplotmark#1{\csname pgf@plot@mark@#1\endcsname} + + +% A stroke-filled circle mark + +\pgfdeclareplotmark{*} +{% + \pgfpathcircle{\pgfpointorigin}{\pgfplotmarksize} + \pgfusepathqfillstroke +} + + +% A plus-sign like mark + +\pgfdeclareplotmark{+} +{% + \pgfpathmoveto{\pgfqpoint{-\pgfplotmarksize}{0pt}} + \pgfpathlineto{\pgfqpoint{\pgfplotmarksize}{0pt}} + \pgfpathmoveto{\pgfqpoint{0pt}{\pgfplotmarksize}} + \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}} + \pgfusepathqstroke +} + + +% An x-shaped mark + +\pgfdeclareplotmark{x} +{% + \pgfpathmoveto{\pgfqpoint{-.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}} + \pgfpathlineto{\pgfqpoint{.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}} + \pgfpathmoveto{\pgfqpoint{-.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}} + \pgfpathlineto{\pgfqpoint{.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}} + \pgfusepathqstroke +} + +% See pgflibraryplotmarks for more plot marks + + + + +% This handler turns creates a series of straight line segements +% between consecutive points, but leaving /pgf/gap around stream point +% space. +% +% Example: +% +% \pgfplothandlergaplineto +% \pgfplotxyfile{mytable} + +\pgfkeys{/pgf/gap around stream point/.initial=1.5pt} + +\def\pgfplothandlergaplineto{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@gap@lineto@handler@initial% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} + +\def\pgf@plot@gap@lineto@handler@initial#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@gap@lineto@last{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \global\let\pgf@plotstreampoint=\pgf@plot@gap@lineto@handler% +} + +\def\pgf@plot@gap@lineto@handler#1{% + % Ok, compute normalized line vector + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@gap@lineto@next{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@plot@gap@lineto@last}{\pgf@plot@gap@lineto@next}}}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgfpathmoveto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap + around stream point}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgf@plot@gap@lineto@last}}% + \pgfpathlineto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap + around stream point}}{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}}{\pgf@plot@gap@lineto@next}}% + \global\let\pgf@plot@gap@lineto@last=\pgf@plot@gap@lineto@next% +} + + + + +% This handler works like \pgfplothandlergaplineto, only the last +% point is connected to the first point, creating a closed curve +% space. +% +% Example: +% +% \pgfplothandlergapcycle +% \pgfplotxyfile{mytable} + +\def\pgfplothandlergapcycle{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@gap@cycle@handler@initial% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgf@plot@gap@cycle@handler@finish% + \global\let\pgf@plot@gap@cycle@first=\relax% + }% +} + +\def\pgf@plot@gap@cycle@handler@initial#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@gap@cycle@last{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \global\let\pgf@plot@gap@cycle@first=\pgf@plot@gap@cycle@last% + \global\let\pgf@plotstreampoint=\pgf@plot@gap@cycle@handler% +} + +\def\pgf@plot@gap@cycle@handler#1{% + % Ok, compute normalized line vector + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@gap@cycle@next{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@plot@gap@cycle@last}{\pgf@plot@gap@cycle@next}}}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgfpathmoveto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap + around stream point}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgf@plot@gap@cycle@last}}% + \pgfpathlineto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap + around stream point}}{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}}{\pgf@plot@gap@cycle@next}}% + \global\let\pgf@plot@gap@cycle@last=\pgf@plot@gap@cycle@next% +} + +\def\pgf@plot@gap@cycle@handler@finish{% + \ifx\pgf@plot@gap@cycle@first\relax% + \else + \pgf@plot@gap@cycle@handler{\pgf@plot@gap@cycle@first}% + \fi +} + + + +\endinput diff --git a/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex new file mode 100644 index 0000000..8a3f322 --- /dev/null +++ b/tex/.texmf/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex @@ -0,0 +1,90 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +% +% Support for the contents of this file will NOT be done by the PGF/TikZ team. +% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction +% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: +% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Sa 7. Dez 20:58:23 CET 2013 %%% + + + +% Copyright 2009 by Till Tantau and Christian Feuersänger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\input pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex +\input pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex + +% TODO for auto xrefs: +% 1. check the already identified labels, preferrably using +% /pdflinks/show labels=true +% and the image externalization debug mode (see pgfmanual-en-main.tex) +% (to strip almost all images away) +% +% 2. Insert '\declareandlabel' in the document whenever something has been +% defined in the text, so it should get a pdf anchor (see +% pgfmanual.pdflinks.code.tex ) +% +% 2.1 perhaps insert \pgfmanualpdflabel{