diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/pstricks/contrib/pst-math |
Initial commit
Diffstat (limited to 'graphics/pstricks/contrib/pst-math')
-rw-r--r-- | graphics/pstricks/contrib/pst-math/Changes | 15 | ||||
-rw-r--r-- | graphics/pstricks/contrib/pst-math/README | 8 | ||||
-rw-r--r-- | graphics/pstricks/contrib/pst-math/doc/pst-math-doc.bib | 150 | ||||
-rw-r--r-- | graphics/pstricks/contrib/pst-math/doc/pst-math-doc.pdf | bin | 0 -> 231813 bytes | |||
-rw-r--r-- | graphics/pstricks/contrib/pst-math/doc/pst-math-doc.tex | 571 | ||||
-rw-r--r-- | graphics/pstricks/contrib/pst-math/dvips/pst-math.pro | 247 | ||||
-rw-r--r-- | graphics/pstricks/contrib/pst-math/latex/pst-math.sty | 93 | ||||
-rw-r--r-- | graphics/pstricks/contrib/pst-math/tex/pst-math.tex | 32 |
8 files changed, 1116 insertions, 0 deletions
diff --git a/graphics/pstricks/contrib/pst-math/Changes b/graphics/pstricks/contrib/pst-math/Changes new file mode 100644 index 0000000000..6a228ba897 --- /dev/null +++ b/graphics/pstricks/contrib/pst-math/Changes @@ -0,0 +1,15 @@ +..... pst-math.sty/pro +0.65 2018-12-16 - allow lists with more than 100 numbers +0.64 2018-12-13 - added macros for creating lists of randoms +0.63 2014-07-30 - added the arc secans functions +0.61 2010-10-02 - moved vasicek into pst-func to make the + probability available as parameter +0.6 2010-09-29 - added the inverse normal function + - added the varicek density function +0.5 2009-08-27 modified SINC function (Patrice Megret) +0.4 2009-05-11 added SystemEqnSolver +0.3 2009-01-20 added SIMPSON for numeric integration (dr/hv) +0.2 2007-08-30 added GAMMA function (hv) +0.1 first CTAN version (cj) + + diff --git a/graphics/pstricks/contrib/pst-math/README b/graphics/pstricks/contrib/pst-math/README new file mode 100644 index 0000000000..2838a7bf4b --- /dev/null +++ b/graphics/pstricks/contrib/pst-math/README @@ -0,0 +1,8 @@ +pst-math: PostScript extension for mathematical functions: + +The macros for random numbers cannot be used with xelatex! + +hvoss@tug.org + + +%% $Id: README 864 2018-12-15 21:15:11Z herbert $ diff --git a/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.bib b/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.bib new file mode 100644 index 0000000000..5cb6f4cf4a --- /dev/null +++ b/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.bib @@ -0,0 +1,150 @@ +%% -*-bibtex-*- +@STRING{tugboat = {TUGboat} } +@STRING{beiprogramm = {{\TeX}-Beiprogramm} } +@STRING{bretter = {Bretter, die die Welt bedeuten} } +@STRING{dtk = {{D}ie {\TeX}nische {K}om{\"o}die} } +@STRING{editorial = {Editorial} } +@STRING{fremdebuehne = {Von fremden B{\"u}hnen} } +@STRING{fundus = {Aus dem Fundus} } +@STRING{hinterbuehne = {Hinter der B{\"u}hne} } +@STRING{leserbrief = {Leserbrief(e)} } +@STRING{magazin = {Magazin} } +@STRING{rezension = {Rezensionen} } +@STRING{schonimmer = {Was Sie schon immer {\"u}ber {\TeX} wissen wollten \dots} } +@STRING{theaterkasse = {Von der Theaterkasse} } +@STRING{theatertage = {{\TeX}-Theatertage} } + +@Article{ dtk02.2:jackson.voss:plot-funktionen, + author = {Laura E. Jackson and Herbert Vo{\ss}}, + title = {Die {P}lot-{F}unktionen von {\texttt{pst-plot}}}, + journal = dtk, + year = 2002, + volume = {2/02}, + altvolume = 2, + altnumber = 14, + month = jun, + pages = {27--34}, + annote = bretter, + keywords = {}, + abstract = { Im letzten Heft wurden die mathematischen Funktionen von + \PS~im Zusammenhang mit dem {\LaTeX}-Paket + \texttt{pst-plot} zum Zeichnen von Funktionen beschrieben + und durch Beispiele erl{\"a}utert. In diesem Teil werden + die bislang nur erw{\"a}hnten Plot-Funktionen f{\"u}r + externe Daten behandelt. } +} + +@Article{ dtk02.1:voss:mathematischen, + author = {Herbert Vo{\ss}}, + title = {Die mathematischen {F}unktionen von {P}ost{S}cript}, + journal = dtk, + year = 2002, + volume = {1/02}, + altvolume = 1, + altnumber = 14, + month = mar, + pages = {}, + annote = bretter, + keywords = {}, + abstract = { \PS, faktisch genauso alt wie {\TeX}, ist im + Verh{\"a}ltnis dazu allgemein noch weniger bekannt, wenn es + darum geht zu beurteilen, was es denn nun im eigentlichen + Sinne ist. Au{\ss}erdem wird h{\"a}ufig vergessen, dass + sich mit den \PS-Funktionen viele Dinge erledigen lassen, + bei denen sonst auf externe Programme zur{\"u}ckgegriffen + wird. Dies wird im Folgenden f{\"u}r die mathematischen + Funktionen im Zusammenhang mit dem Paket \texttt{pst-plot} + gezeigt. } +} + +@Book{tlgc2, + author = {Michel Goosens and Frank Mittelbach and Sebastian Rahtz and Denis Roegel and Herbert Vo{\ss}}, + title = {The {\LaTeX} {G}raphics {C}ompanion}, + publisher = {{Addison-Wesley Publishing Company}}, + edition = second, + year = {2007}, + address = {Reading, Mass.} +} + + +@Article{girou:01:, + author = {Denis Girou}, + title = {Pr\'esentation de {PST}ricks}, + journal = {Cahier {GUT}enberg}, + year = 1994, + volume = {16}, + month = apr, + pages = {21-70} +} + +@Article{girou:02:, + author = {{Timothy van} Zandt and Denis Girou}, + title = {Inside {PST}ricks}, + journal = TUGboat, + year = 1994, + volume = {15}, + month = sep, + pages = {239-246} +} + +@Book{PostScript, + Author = {Kollock, Nikolai G.}, + Title = {Post{S}cript richtig eingesetzt: vom {K}onzept zum + praktischen {E}insatz}, + Publisher = {IWT}, + Address = {Vaterstetten}, + year = 1989, +} + +@Manual{pstricks, + Title = {PSTricks - {\PS} macros for generic {\TeX}}, + Author = {{Timothy van} Zandt}, + Organization = {}, + Address = {\url{http://www.tug.org/application/PSTricks}}, + Note = {}, + year = 1993 +} + +@Manual{pst-plot, + Title = {\texttt{pst-plot}: Plotting two dimensional functions and data}, + Author = {{Timothy van} Zandt}, + Organization = {}, + Address = {\url{CTAN:graphics/pstricks/generic/pst-plot.tex}}, + Note = {}, + year = 1999 +} + +@Manual{multido, + Title = {\texttt{multido.tex} - a loop macro, that supports fixed-point addition}, + Author = {{Timothy van} Zandt}, + Organization = {}, + Address = {\url{CTAN:/graphics/pstricks/generic/multido.tex}}, + Note = {}, + year = 1997 +} + +@Book{PSTricks2, + author = {Herbert Vo\ss}, + title = {\texttt{PSTricks} -- {G}rafik f\"ur \TeX{} und \LaTeX}, + edition = {5.}, + publisher = {DANTE -- Lehmanns}, + year = {2008}, + address = {Heidelberg/Hamburg} +} + +@Book{voss:math, + author = {Herbert Vo\ss}, + title = {Mathematiksatz mit {\LaTeX}}, + publisher = {{DANTE/Lehmanns Media}}, + year = {2009}, + address = {Heidelberg/Berlin} +} + +@Manual{wolfram, + author = {Eric Weisstein}, + title = {Wolfram MathWorld}, + publisher = {{Wolfram}}, + year = {2007}, + address = {\url{http://mathworld.wolfram.com}} +} + diff --git a/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.pdf b/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.pdf Binary files differnew file mode 100644 index 0000000000..97b00889d7 --- /dev/null +++ b/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.pdf diff --git a/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.tex b/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.tex new file mode 100644 index 0000000000..d40e7eb2f8 --- /dev/null +++ b/graphics/pstricks/contrib/pst-math/doc/pst-math-doc.tex @@ -0,0 +1,571 @@ +%% $Id: pst-math-doc.tex 864 2018-12-15 21:15:11Z herbert $ +\documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false, + headings=small, headinclude=false,footinclude=false,oneside,abstract=on]{pst-doc} +\usepackage{pst-math} +\let\pstMathFV\fileversion +\usepackage{pstricks-add} +\lstset{pos=t,wide=true,language=PSTricks, + morekeywords={psGammaDist,psChiIIDist,psTDist,psFDist,psBetaDist,psPlotImpl},basicstyle=\footnotesize\ttfamily} +% +\def\pshlabel#1{\footnotesize#1} +\def\psvlabel#1{\footnotesize#1} +% +\makeatletter +\def\DefOfOperator{\@ifstar{\DefOfOperator@}{\DefOfOperator@@}} +\def\DefOfOperator@#1#2#3#4{{\operator@font#1}:\left\{\begin{array}{ccc} #2&\to\\ +x&\mapsto\end{array}\right.} +\def\DefOfOperator@@#1#2#3{{\operator@font#1}:\left\{\begin{array}{ccc} #2&\to\\ +x&\mapsto&{\operator@font#1}(x)\end{array}\right.} +\makeatother + +\addbibresource{\jobname.bib} + + +\begin{document} + +\title{\texttt{pst-math}} +\subtitle{Special mathematical PostScript functions; v.\pstMathFV} +\author{Christoph Jorssen\\Herbert Vo\ss} +\docauthor{Herbert Vo\ss} +\date{\today} +\maketitle + +\tableofcontents + +\clearpage + +\begin{abstract} +\noindent +\LPack{pst-math} is an extension to the \Index{PostScript} language. The files \LFile{pst-math.sty} +and \LFile{pst-math.tex} are only wrapper files for the \LFile{pst-math.pro} file, which +defines all the new mathematical functions for use with PostScript. + +\vfill\noindent +Thanks to: \\ +Denis Bitouzé; +Jacques L'helgoualc'h; +Patrice M\'egret; +Dominik Rodriguez +\end{abstract} + + +\clearpage + +\section{Introduction} +\nxLPack{pst-math} defines \Lcs{pstPi} on \TeX\ level which expects 1,2,3 or 4 as +parameter. It is not available on PostScript level. + +\begin{BDef} +\Lcs{pstPI}\Larg\# +\end{BDef} + +\Lcs{pstPI}1 $\Rightarrow$ $\pi$\\ +\Lcs{pstPI}2 $\Rightarrow$ $\dfrac{\pi}{2}$\\[2pt] +\Lcs{pstPI}3 $\Rightarrow$ $\dfrac{\pi}{3}$\\[2pt] +\Lcs{pstPI}4 $\Rightarrow$ $\dfrac{\pi}{4}$ + + +\section{Trigonometry} + +\LPack{pst-math} introduces natural trigonometric PostScript operators \Lps{COS}, \Lps{SIN} and \Lps{TAN} defined by +\[\DefOfOperator{cos}{\mathbb R}{[-1,1]}\] +\[\DefOfOperator{sin}{\mathbb R}{[-1,1]}\] +\[\DefOfOperator{tan}{\mathbb R\backslash\{k\dfrac{\pi}2,k\in\mathbb Z\}}{\mathbb R}\] +where $x$ is in \emph{radians}. \Lps{TAN} does \emph{not} produce a PS error\footnote{\nxLps{TAN} is defined with +Div, a special PSTricks operator rather than with div, the default PS operator.} when $x=k\dfrac{\pi}{2}$. + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num & \Lps{COS} & real & Return \Index{cosine} of \textsf{num} radians \\ +num & \Lps{SIN} & real & Return \Index{sine} of \textsf{num} radians \\ +num & \Lps{TAN} & real & Return \Index{tangent} of \textsf{num} radians\\\hline +\end{tabular} +\end{center} + +%\begin{LTXexample}[pos=t,wide=false] +\begin{pspicture}*(-5,-2)(5,2) +\SpecialCoor % For label positionning +\psaxes[labels=y,Dx=\pstPI2]{->}(0,0)(-5,-2)(5,2) +\uput[-90](!PI 0){$\pi$} \uput[-90](!PI neg 0){$-\pi$} +\uput[-90](!PI 2 div 0){$\frac{\pi}2$} +\uput[-90](!PI 2 div neg 0){$-\frac{\pi}2$} +\psplot[linewidth=1.5pt,linecolor=blue]{-5}{5}{x COS} +\psplot[linewidth=1.5pt,linecolor=red]{-5}{5}{x SIN} +\psplot[linewidth=1.5pt,linecolor=green]{-5}{5}{x TAN} +\end{pspicture} +%\end{LTXexample} + + +\begin{lstlisting} +\begin{pspicture}*(-5,-2)(5,2) +\SpecialCoor % For label positionning +\psaxes[labels=y,Dx=\pstPI2]{->}(0,0)(-5,-2)(5,2) +\uput[-90](!PI 0){$\pi$} \uput[-90](!PI neg 0){$-\pi$} +\uput[-90](!PI 2 div 0){$\frac{\pi}2$} +\uput[-90](!PI 2 div neg 0){$-\frac{\pi}2$} +\psplot[linewidth=1.5pt,linecolor=blue]{-5}{5}{x COS} +\psplot[linewidth=1.5pt,linecolor=red]{-5}{5}{x SIN} +\psplot[linewidth=1.5pt,linecolor=green]{-5}{5}{x TAN} +\end{pspicture} +\end{lstlisting} + + +\LPack{pst-math} introduces natural trigonometric postscript +operators \Lps{ACOS}, \Lps{ASIN} and \Lps{ATAN} defined by + +\[\DefOfOperator{acos}{[-1,1]}{[0,\pi]}\] +\[\DefOfOperator{asin}{[-1,1]}{[-\dfrac{\pi}2,\dfrac{\pi}2]}\] +\[\DefOfOperator{atan}{\mathbb R}{]-\dfrac{\pi}2,\dfrac{\pi}2[}\] + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num & \Lps{ACOS} & angle & Return \Index{arccosine} of \textsf{num} in radians \\ +num & \Lps{ASIN} & angle & Return \Index{arcsine} of \textsf{num} in radians \\ +num & \Lps{ATAN} & angle & Return \Index{arctangent} of \textsf{num} in radians \\ +num & \Lps{ASEC} & angle & Return \Index{arcsecans} of \textsf{num} in radians \\ +num & \Lps{ACSC} & angle & Return \Index{arccosecans} of \textsf{num} in radians \\\hline +\end{tabular} +\end{center} + +\medskip\noindent +\begin{tabularx}{\linewidth}{!{\vrule width3pt}X} +\Lps{ATAN} is \emph{not} defined as the already existing PS operator \Lps{atan}. \Lps{ATAN} needs only \emph{one} +argument on the stack. +\end{tabularx} + +\begin{LTXexample}[pos=t,wide=false] +\begin{pspicture}(-5,-2)(5,4) +\SpecialCoor % For label positionning +\psaxes[labels=x,Dy=\pstPI2]{->}(0,0)(-5,-2)(5,4) +\uput[0](!0 PI){$\pi$} \uput[0](!0 PI 2 div){$\frac{\pi}2$} +\uput[0](!0 PI 2 div neg){$-\frac{\pi}2$} +\psset{linewidth=1.5pt,yMaxValue=4} +\psplot[linecolor=blue]{-1}{1}{x ACOS} \psplot[linecolor=red]{-1}{1}{x ASIN} +\psplot[linecolor=green]{-5}{5}{x ATAN} +\psplot[linestyle=dashed,linecolor=cyan,arrows=-*]{-5}{-1}{x ASEC} +\psplot[linestyle=dashed,linecolor=cyan,arrows=*-]{1}{5}{x ASEC} +\psplot[linestyle=dashed,linecolor=magenta,arrows=-*]{-5}{-1}{x ACSC} +\psplot[linestyle=dashed,linecolor=magenta,arrows=*-]{1}{5}{x ACSC} +\end{pspicture} +\end{LTXexample} + +\clearpage +\section{Hyperbolic trigonometry} + +\LPack{pst-math} introduces hyperbolic trigonometric postscript operators +\Lps{COSH}, \Lps{SINH} and \Lps{TANH} defined by + +\[\DefOfOperator{cosh}{\mathbb R}{[1,+\infty[}\] +\[\DefOfOperator{sinh}{\mathbb R}{\mathbb R}\] +\[\DefOfOperator{tanh}{\mathbb R}{]-1,1[}\] + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num & \Lps{COSH} & real & Return \Index{hyperbolic cosine} of \textsf{num} \\ +num & \Lps{SINH} & real & Return \Index{hyperbolic sine} of \textsf{num} \\ +num & \Lps{TANH} & real & Return \Index{hyperbolic tangent} of \textsf{num}\\\hline +\end{tabular} +\end{center} + +\begin{LTXexample}[pos=t,wide=false] +\begin{pspicture}*(-5,-5)(5,5) +\psaxes{->}(0,0)(-5,-5)(5,5) +\psplot[linewidth=1.5pt,linecolor=blue]{-5}{5}{x COSH} +\psplot[linewidth=1.5pt,linecolor=red]{-5}{5}{x SINH} +\psplot[linewidth=1.5pt,linecolor=green]{-5}{5}{x TANH} +\end{pspicture} +\end{LTXexample} + +\LPack{pst-math} introduces reciprocal \Index{hyperbolic} trigonometric postscript operators \Lps{ACOSH}, \Lps{ASINH} and +\Lps{ATANH} defined by +\[\DefOfOperator{acosh}{[1,+\infty[}{\mathbb R}\] +\[\DefOfOperator{asinh}{\mathbb R}{\mathbb R}\] +\[\DefOfOperator{atanh}{]-1,1[}{\mathbb R}\] + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num & \Lps{ACOSH} & real & Return \Index{reciprocal hyperbolic cosine} of \textsf{num} \\ +num & \Lps{ASINH} & real & Return \Index{reciprocal hyperbolic sine} of \textsf{num} \\ +num & \Lps{ATANH} & real & Return \Index{reciprocal hyperbolic tangent} of \textsf{num}\\\hline +\end{tabular} +\end{center} + +\begin{LTXexample}[pos=t,wide=false] +\begin{pspicture}(-5,-4)(5,4) +\psaxes{->}(0,0)(-5,-4)(5,4) +\psplot[linewidth=1.5pt,linecolor=blue]{1}{5}{x ACOSH} +\psplot[linewidth=1.5pt,linecolor=red]{-5}{5}{x ASINH} +\psplot[linewidth=1.5pt,linecolor=green]{-.999}{.999}{x ATANH} +\end{pspicture} +\end{LTXexample} + +\section{Other operators} + +\LPack{pst-math} introduces postscript operator \Lps{EXP} defined by +\[\DefOfOperator{exp}{\mathbb R}{\mathbb R}\] + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num & \Lps{EXP} & real & Return \Index{exponential} of \textsf{num}\\\hline +\end{tabular} +\end{center} + +\begin{LTXexample}[pos=t,wide=false] +\begin{pspicture}*(-5,-1)(5,5) +\psaxes{->}(0,0)(-5,-0.5)(5,5) +\psplot[linecolor=blue,linewidth=1.5pt,plotpoints=1000]{-5}{5}{x EXP} +\end{pspicture} +\end{LTXexample} + +\LPack{pst-math} introduces postscript operator \Lps{GAUSS} defined by + +\[\DefOfOperator*{gauss}{\mathbb R}{\mathbb R}{\displaystyle\frac{1}{\sqrt{2\pi\sigma^2}}\exp-\frac{(x-\overline x)^2}{2\sigma^2}}\] + +\begin{center} +\begin{tabularx}{\linewidth}{@{} >{\sffamily}l l >{\sffamily}l X @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num1 num2 num3 & \Lps{GAUSS} & real & Return gaussian of \textsf{num1} with + mean \textsf{num2} and \Index{standard deviation} \textsf{num3}\\\hline +\end{tabularx} +\end{center} + +\begin{LTXexample}[pos=t,wide=false] +\psset{yunit=5} +\begin{pspicture}(-5,-.1)(5,1.1) +\psaxes{->}(0,0)(-5,-.1)(5,1.1) +\psplot[linecolor=blue,linewidth=1.5pt,plotpoints=1000]{-5}{5}{x 2 2 GAUSS} +\psplot[linecolor=red,linewidth=1.5pt,plotpoints=1000]{-5}{5}{x 0 .5 GAUSS} +\end{pspicture} +\end{LTXexample} + +\LPack{pst-math} introduces postscript operator \Index{SINC} defined by +\[\DefOfOperator*{sinc}{\mathbb R}{\mathbb R}{\displaystyle\frac{\sin x}x}\] + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num & \Lps{SINC} & real & Return \Index{cardinal sine} of \textsf{num} radians\\\hline +\end{tabular} +\end{center} + +\begin{LTXexample}[pos=t,wide=false] +\psset{xunit=.25,yunit=3} +\begin{pspicture}(-20,-.5)(20,1.5) +\SpecialCoor % For label positionning +\psaxes[labels=y,Dx=\pstPI1]{->}(0,0)(-20,-.5)(20,1.5) +\uput[-90](!PI 0){$\pi$} \uput[-90](!PI neg 0){$-\pi$} +\psplot[linecolor=blue,linewidth=1.5pt,plotpoints=1000]{-20}{20}{x SINC} +\end{pspicture} +\end{LTXexample} + +\LPack{pst-math} introduces postscript operator \Lps{GAMMA} and \Lps{GAMMALN} defined by + +\[\DefOfOperator*{\Gamma}{\mathbb{R} \backslash\mathbb{Z}}{\mathbb R}{\displaystyle\int_0^\infty t^{x-1}\mathrm e^{-t}\,\mathrm d t}\] +\[\DefOfOperator*{\ln\Gamma}{]0,+\infty[}{\mathbb R}{\ln\displaystyle\int_0^t t^{x-1}\mathrm e^{-t}\,\mathrm d t}\] + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num & \Lps{GAMMA} & real & Return $\Gamma$\index{Gamma func@$\Gamma$ function} function of \textsf{num}\\ +num & \Lps{GAMMALN} & real & Return \Index{logarithm} of $\Gamma$ function of \textsf{num}\\\hline +\end{tabular} +\end{center} + +\begin{LTXexample}[pos=t,wide=false] +\begin{pspicture*}(-.5,-.5)(6.2,6.2) +\psaxes{->}(0,0)(-.5,-.5)(6,6) +\psplot[linecolor=blue,linewidth=1.5pt,plotpoints=200]{.1}{6}{x GAMMA} +\psplot[linecolor=red,linewidth=1.5pt,plotpoints=200]{.1}{6}{x GAMMALN} +\end{pspicture*} +\end{LTXexample} + +\begin{LTXexample}[pos=t,wide=false] +\psset{xunit=.25,yunit=3} +\begin{pspicture}(-20,-.5)(20,1.5) +\psaxes[Dx=5,Dy=.5]{->}(0,0)(-20,-.5)(20,1.5) +\psplot[linecolor=blue,linewidth=1.5pt,plotpoints=1000]{-20}{20}{x BESSEL_J0} +\psplot[linecolor=red,linewidth=1.5pt,plotpoints=1000]{-20}{20}{x BESSEL_J1} +\end{pspicture} +\end{LTXexample} + +\begin{LTXexample}[pos=t,wide=false] +\psset{xunit=.5,yunit=3} +\begin{pspicture}*(-1.5,-.75)(19,1.5) +\psaxes[Dx=5,Dy=.5]{->}(0,0)(-1,-.75)(19,1.5) +\psplot[linecolor=blue,linewidth=1.5pt,plotpoints=1000]{0.0001}{20}{x BESSEL_Y0} +\psplot[linecolor=red,linewidth=1.5pt,plotpoints=1000]{0.0001}{20}{x BESSEL_Y1} +%\psplot[linecolor=green,plotpoints=1000]{0.0001}{20}{x 2 BESSEL_Yn} +\end{pspicture} +\end{LTXexample} + +\section{Numerical integration} + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num num /var $\lbrace$ function $\rbrace$ num & \Lps{SIMPSON} & real & Return $\displaystyle\int\limits_a^b f(t)\mathrm{d}t$\\ +num +\end{tabular} +\end{center} + +%a b var f Ierr + +the first two variables are the low and high boundary \Index{integral}, both can be values or +\PS\ expressions. \verb+/var+ is the definition of the integrated variable (not x!), which is +used in the following function description, which must be inside of braces. The last +number is the tolerance for the step adjustment. The function \Lps{SIMPSON} can be +nested. + +\begin{LTXexample}[pos=t,wide=false] +\psset{xunit=.75} +\begin{pspicture*}[showgrid=true](-0.4,-3.4)(10,3) + \psplot[linestyle=dashed,linewidth=1.5pt]{.1}{10}{1 x div} + \psplot[linecolor=red,linewidth=1.5pt]{.1}{10}{ + 1 % start + x % end + /t % variable + { 1 t div } % function + .001 % tolerance + SIMPSON } % + \psplot[linecolor=blue,linewidth=1.5pt]{.1}{10}{1 x /t { 1 t div } 1 SIMPSON } +\end{pspicture*} +\end{LTXexample} + + + +\begin{LTXexample}[pos=t,wide=false] +%%% Gaussian and relative integral from -x to x to its value sqrt{pi} +\psset{unit=2} +\begin{pspicture}[showgrid=true](-3,-1)(3,1) + \psplot[linecolor=red,linewidth=1.5pt]{-3}{3}{Euler x dup mul neg exp } + \psplot[linecolor=green,linewidth=1.5pt]{-3}{3} + { x neg x /t { Euler t dup mul neg exp } .001 SIMPSON Pi sqrt div} +\end{pspicture} +\end{LTXexample} + + +\psset{unit=1.75cm} +%%% successive polynomial developments of sine-cosine +\begin{pspicture}[showgrid=true](-3,-2)(3,2) +\psaxes{->}(0,0)(-3,-2)(3,2) +\psset{linewidth=1.5pt} +\psplot[linecolor=green, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{0 x /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } +\psplot[linecolor=blue, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{1 0 x /tata + {0 tata /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} +\psplot[linecolor=yellow, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{0 x /titi + {1 0 titi /tata + {0 tata /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + .01 SIMPSON } +\psplot[linecolor=red, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{1 0 x /tyty + {0 tyty /titi + {1 0 titi /tata + {0 tata /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} +\psplot[linecolor=magenta, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{0 x /tete + {1 0 tete /tyty + {0 tyty /titi + {1 0 titi /tata + {0 tata /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + .01 SIMPSON }%%% FIVE nested calls +\end{pspicture} +\psset{unit=1cm} + +\begin{lstlisting} +\psset{unit=1.75cm} +%%% successive polynomial developments of sine-cosine +\begin{pspicture}[showgrid=true](-3,-2)(3,2) +\psaxes{->}(0,0)(-3,-2)(3,2) + \psplot[linecolor=green, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{0 x /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + \psplot[linecolor=blue, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{1 0 x /tata + {0 tata /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + \psplot[linecolor=yellow, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{0 x /titi + {1 0 titi /tata + {0 tata /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + .01 SIMPSON } + \psplot[linecolor=red, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{1 0 x /tyty + {0 tyty /titi + {1 0 titi /tata + {0 tata /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + \psplot[linecolor=magenta, algebraic=false, plotpoints=61, showpoints=true] + {-3}{3}{0 x /tete + {1 0 tete /tyty + {0 tyty /titi + {1 0 titi /tata + {0 tata /tutu + {1 0 tutu /toto { toto } .1 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + .01 SIMPSON } + .01 SIMPSON sub} + .01 SIMPSON }%%% FIVE nested calls +\end{pspicture} +\end{lstlisting} + + +\iffalse + +\begin{LTXexample}[pos=t,wide=false] +% ce code definit la fonction [cos(2pix cos(t))-cos(2pix)]^2 / sin(t) avec x=h/lambda +\def\Func{ + 0.01 3.1 + /t + { TwoPi x mul t COS mul COS TwoPi x mul COS sub 2 exp t SIN div } def + .01 SIMPSON 60 mul } +% D = 2*(cos^2(2pix))/Func +\def\fD{TwoPi x mul COS dup mul 2 mul \Func\space div} +\psset{llx=-1.5cm,lly=-0.5cm,urx=0.2cm,ury=0.2cm, + xAxisLabel={$h/\lambda$},xAxisLabelPos={0.5,-45},yAxisLabel={$R_r$ en ohms}, + yAxisLabelPos={-0.1,150}} +\begin{psgraph}[Dy=50,Dx=0.1,xticksize=300 0,yticksize=1 0, + comma=true,axesstyle=frame](0,0)(1,300){10cm}{5cm} + \psplot{0}{1}{\Func} + \psplot[linecolor=red]{0.01}{.1}{\fD}% +\end{psgraph} +\end{LTXexample} + +\fi + +\section{Random numbers} +Package \LPack{pst-math} supports the creation of random number lists where a number will +appear only once. %But there is a different handling of the macros for Lua\LaTeX\ and the +%other \TeX\ engines. %With Lua\TeX\ all random numbers are build with the help of Lua which +%has the advantage that there will be no problem with \TeX's limited parameter stack size. + + +\begin{BDef} +\Lcs{defineRandIntervall}\Largr{min,max}{maxNo}\\ +\Lcs{makeSimpleRandomNumberList}\% multiple values possible\\ +\Lcs{makeRandomNumberList} \% no multiple values!\\ +\Lcs{getNumberFromList}\Largb{number} +\end{BDef} + +The list of the random numbers is \Lcs{RandomNumbers}, a comma separated list of the values. +It can be used for own purpuses. + + +\begin{LTXexample}[pos=t] +\defineRandIntervall(1,50){30} +\makeSimpleRandomNumberList +Random list: \RandomNumbers + +\psforeach{\iA}{1,2,..,30}{\getNumberFromList{\iA}~} +\end{LTXexample} + + +In the next example a random number appears only \emph{once} in the list. There are no multiple +numbers: + + +\begin{LTXexample}[pos=t] +\defineRandIntervall(1,30){30} +\makeRandomNumberList +\psforeach{\iA}{1,2,..,30}{\getNumberFromList{\iA}~} +\end{LTXexample} + + + + +\begin{LTXexample}[pos=t] +\newcounter{RandNo} +\def\n{5} \def\N{\the\numexpr\n*\n} +\defineRandIntervall(1,\N){\N} +\makeRandomNumberList \setcounter{RandNo}{1} +\begin{pspicture}(\n,\n) + \psgrid[subgriddiv=0,gridlabels=0pt] + \multido{\rRow=0.5+1.0}{\n}{\multido{\rCol=0.5+1.0}{\n}{% + \rput(\rCol,\rRow){\getNumberFromList{\theRandNo}}% + \stepcounter{RandNo}}} +\end{pspicture} +\setcounter{RandNo}{1} +\def\n{10} \def\N{\the\numexpr\n*\n} +\defineRandIntervall(1,\N){\N} +\makeRandomNumberList \setcounter{RandNo}{1} +\begin{pspicture}(\n,\n) + \psgrid[subgriddiv=0,gridlabels=0pt] + \multido{\rRow=0.5+1.0}{\n}{\multido{\rCol=0.5+1.0}{\n}{% + \rput(\rCol,\rRow){\getNumberFromList{\theRandNo}}% + \stepcounter{RandNo}}} +\end{pspicture} +\end{LTXexample} + + + + +\clearpage + +\section{Numerical functions} + +\begin{center} +\begin{tabular}{@{} >{\sffamily}l l >{\sffamily}l l @{} } +\emph{Stack} & \emph{Operator} & \emph{Result} & \emph{Description} \\\hline +num & \Lps{norminv} & real & Return $\mathop{norminv}(num)$\\ +\end{tabular} +\end{center} + + +\begin{LTXexample}[width=5cm,wide=false] +\psset{xunit=5} +\begin{pspicture}(-0.1,-3)(1.1,4) +\psaxes{->}(0,0)(0,-3)(1.1,4) +\psplot[plotpoints=200,algebraic,linecolor=red]{0}{0.9999}{norminv(x)} +\end{pspicture} +\end{LTXexample} + + + +These function returns the inverse normal. + +\bgroup +\raggedright +\nocite{*} +\printbibliography +\egroup + +\printindex + + +\end{document} diff --git a/graphics/pstricks/contrib/pst-math/dvips/pst-math.pro b/graphics/pstricks/contrib/pst-math/dvips/pst-math.pro new file mode 100644 index 0000000000..1d4f70369a --- /dev/null +++ b/graphics/pstricks/contrib/pst-math/dvips/pst-math.pro @@ -0,0 +1,247 @@ +% -*- Mode: Postscript -*- +% pst-math.pro --- PostScript header file pst-math.pro +% +% Author : Christophe JORSSEN +% Author : Herbert Voß <hvoss@tug.org> +% Last Mod : $Date: 2018/12/16 $ +% Version : 0.65 $ +% +/PI 3.14159265359 def +/ENeperian 2.71828182846 def +% +/DegToRad {PI mul 180 div} bind def +/RadToDeg {180 mul PI div} bind def +% +/COS {RadToDeg cos} bind def +/SIN {RadToDeg sin} bind def +/TAN {dup SIN exch COS Div} bind def +/tan {dup sin exch cos Div} bind def +/ATAN {neg -1 atan 180 sub DegToRad} bind def +/ACOS {dup dup mul neg 1 add sqrt exch atan DegToRad} bind def +/acos {dup dup mul neg 1 add sqrt exch atan} bind def +/ASEC {1 exch Div ACOS} bind def +/ASIN {neg dup dup mul neg 1 add sqrt neg atan 180 sub DegToRad} bind def +/asin {neg dup dup mul neg 1 add sqrt neg atan 180 sub} bind def +/ACSC {1 exch Div ASIN} bind def +% +/EXP {ENeperian exch exp} bind def +% +/COSH {dup EXP exch neg EXP add 2 div} bind def +/SINH {dup EXP exch neg EXP sub 2 div} bind def +/TANH {dup SINH exch COSH div} bind def +/ACOSH {dup dup mul 1 sub sqrt add ln} bind def +/ASINH {dup dup mul 1 add sqrt add ln} bind def +/ATANH {dup 1 add exch neg 1 add Div ln 2 div} bind def +% +%/SINC {dup SIN exch Div} bind def +/SINC { dup 0 eq { pop 1 } { dup SIN exch div } ifelse } bind def + +/GAUSS {dup mul 2 mul dup 4 -2 roll sub dup mul exch div neg EXP exch PI mul sqrt div} bind def +% +/GAMMA { 2 dict begin % hv 2007-08-30 + /z exch def + 1.000000000190015 % p(0) + 0 1 5 { % on stack is 0 1 2 3 4 5 + dup % n-1 n-1 + [ 76.18009172947146 + -86.50532032941677 + 24.0140982483091 + -1.231739572450155 + 0.1208650973866179E-2 + -0.5395239384953E-5 ] exch get exch % p(n) n-1 + 1 add z add div % p(n)/(z+n) + add % build the sum + } for + Pi 2 mul sqrt z div mul + z 5.5 add z 0.5 add exp mul ENeperian z 5.5 add neg exp mul + end } bind def +% +/GAMMALN {dup dup dup 5.5 add dup ln 3 -1 roll .5 add mul sub neg 1.000000000190015 + 0 1 5 { + [76.18009172947146 -86.50532032941677 24.0140982483091 -1.231739572450155 + .1208650973866179E-2 -.5395239384953E-5 2.5066282746310005] exch get + 4 -1 roll 1 add dup 5 1 roll div add} for + 4 -1 roll div 2.5066282746310005 mul ln add exch pop} bind def +/BETA {2 copy add GAMMALN neg exch GAMMALN 3 -1 roll GAMMALN EXP} bind def +% +/HORNER {aload length + dup 2 add -1 roll + exch 1 sub { + dup 4 1 roll + mul add exch + } repeat + pop +} bind def +% +/BESSEL_J0 {dup abs 8 lt { + dup mul dup [57568490574 -13362590354 651619640.7 -11214424.18 77392.33017 -184.9052456] HORNER + exch [57568490411 1029532985 9494680.718 59272.64853 267.8532712 1] HORNER + Div} + {abs dup .636619772 exch div sqrt exch dup .785398164 sub exch 8 exch div dup dup mul dup + [1 -1.098628627E-2 .2734510407E-4 -.2073370639E-5 .2093887211E-6] HORNER + 3 index COS mul + exch [-.1562499995E-1 .1430488765E-3 -.6911147651E-5 .7621095161E-6 -.934945152E-7] HORNER + 4 -1 roll SIN mul 3 -1 roll mul neg add mul} + ifelse} bind def +% +/BESSEL_Y0 {dup 8 lt { + dup dup mul dup [-2957821389 7062834065 -512359803.6 10879881.29 -86327.92757 228.4622733] HORNER + exch [40076544269 745249964.8 7189466.438 47447.26470 226.1030244 1] HORNER + Div exch dup ln exch BESSEL_J0 .636619772 mul mul add} + {dup .636619772 exch div sqrt exch dup .785398164 sub exch 8 exch div dup dup mul dup + [1 -.1098628627E-2 .2734510407E-4 -.2073370639E-5 .2093887211E-6] HORNER + 3 index SIN mul + exch [-.1562499995E-1 .1430488765E-3 -.6911147651E-5 .7621095161E-6 -.934945152E-7] HORNER + 4 -1 roll COS mul 3 -1 roll mul add mul} + ifelse} bind def +% +/BESSEL_J1 {dup abs 8 lt { + dup dup mul dup 3 -2 roll [72362614232 -7895059235 242396853.1 -2972611.439 15704.48260 -30.16036606] HORNER mul + exch [144725228442 2300535178 18583304.74 99447.43394 376.9991397 1] HORNER + Div} + {dup abs dup .636619772 exch div sqrt exch dup 2.356194491 sub exch 8 exch div dup dup mul dup + [1 .183105E-2 -.3516396496E-4 .2457520174E-5 -.240337019E-6] HORNER + 3 index COS mul + exch [.04687499995 6.2002690873E-3 .8449199096E-5 -.88228987E-6 .105787412E-6] HORNER + 4 -1 roll SIN mul 3 -1 roll mul neg add mul exch dup abs Div mul} + ifelse} bind def +% +/BESSEL_Y1 {dup 8 lt { + dup dup dup mul dup [-.4900604943E13 .1275274390E13 -.5153428139E11 .7349264551E9 -.4237922726E7 .8511937935E4] HORNER + exch [.2499580570E14 .4244419664E12 .3733650367E10 .2245904002E8 .1020426050E6 .3549632885E3 1] HORNER + Div mul exch dup dup ln exch BESSEL_J1 mul exch 1 exch div sub .636619772 mul add} + {dup .636619772 exch div sqrt exch dup 2.356194491 sub exch 8 exch div dup dup mul dup + [1 .183105E-2 -.3516396496E-4 .2457520174E-5 -.240337019E-6] HORNER + 3 index SIN mul + exch [.04687499995 -.2002690873E-3 .8449199096E-5 6.88228987E-6 .105787412E-6] HORNER + 4 -1 roll COS mul 3 -1 roll mul add mul} + ifelse} bind def +% +% En cours... +/BESSEL_Yn {dup 0 eq {pop BESSEL_Y0}{dup 1 eq {pop BESSEL_Y1}{ + exch dup BESSEL_Y0 exch dup BESSEL_Y1 exch 2 exch Div { + mul 3 -1 roll mul 2 index sub pstack} for + } ifelse } ifelse } bind def +% +/SIMPSON { 1 dict begin %% on stack a b var f ierr Dominik Rodriguez + 3 index 5 index sub % compute h + 1 % a b var f ierr h n + 4 index 7 index def 3 index exec % a b var f ierr h n f(a) + 5 index 7 index def 4 index exec add % a b var f ierr h n f(a)+f(b) + 5 index 8 index 4 index 2 div add def 4 index exec % a b var f ierr h n f(a)+f(b) f(a+h/2) + exch 1 index 4 mul add 0 % a b var f ierr h n old=f(a+h/2) Estim=f(a)+f(b)+4f(a+h/2) NbLoop + { % a b var f ierr h n old Estim NbLoop + 5 -1 roll 2 div dup 6 1 roll % h<-h/2 + 5 -1 roll 2 mul 5 1 roll % n<-2n + % a b var f ierr h n old Estim NbLoop h + 2 div 10 index add 0 % a b var f ierr h n old Estim NbLoop a+h/2 Cumul + 5 index { + 1 index 10 index exch def 8 index exec add exch 6 index add exch + } repeat % a b var f ierr h n old Estim NbLoop a+nh/2 Cumul + exch pop % a b var f ierr h n old Estim NbLoop New + 2 index 1 index 4 mul 6 -1 roll 2 mul sub sub % a b var f ierr h n Estim NbLoop New Diff + 4 -1 roll 2 mul 1 index sub 4 1 roll % a b var f ierr h n Estim NbLoop New Diff + exch 4 1 roll % a b var f ierr h n old Estim NbLoop Diff + 5 index 6 div mul abs 6 index lt { exit } if + 1 add dup 9 eq { exit } if + } loop % a b var f ierr h n old Estim NbLoop + exch 5 -1 roll 6 div mul mark 10 2 roll cleartomark +end +} def +% ------------------------------------ math stuff ---------------------------------- +% +% Matrix A in arrays of rows A[[row1][row2]...] +% with [row1]=[a11 a12 ... b1] +% returns on stack solution vector X=[x1 x2 ... xn] +/SolveLinEqSystem { % on stack matrix M=[A,b] (A*x=b) + 10 dict begin % hold all ocal + /A exch def + /Rows A length def % Rows = number of rows + /Cols A 0 get length def % Cols = number of columns + /Index [ 0 1 Rows 1 sub { } for ] def % Index = [0 1 2 ... Rows-1] + /col 0 def + /row 0 def + /PR Rows array def % PR[c] = pivot row for row row + { % starts the loop, find pivot entry in row r + col Cols ge row Rows ge or { exit } if % col < Cols and row < Rows else exit + /pRow row def % pRow = pivot row + /max A row get col get abs def % get A[row[col]], first A[0,0] + row 1 add 1 Rows 1 sub { % starts for loop 1 1 Rows-1 + /j exch def % index counter + /x A j get col get abs def % get A[j[r]] + x max gt { % x>max, then save position + /pRow j def + /max x def + } if + } for % now we have the row with biggest A[0,1] + % with pRow = the pivot row + max 0 gt { % swap entries pRow and row in i + /tmp Index row get def + Index row Index pRow get put + Index pRow tmp put % and columns pRow and row in A + /tmp A row get def + A row A pRow get put + A pRow tmp put % pivot + /row0 A row get def % the pivoting row + /p0 row0 col get def % the pivot value + row 1 add 1 Rows 1 sub { % start for loop + /j exch def + /c1 A j get def + /p c1 col get p0 div def + c1 col p put % subtract (p1/p0)*row[i] from row[j] + col 1 add 1 Cols 1 sub { % start for loop + /i exch def + c1 dup i exch % c1 i c1 + i get row0 i get p mul sub put + } for + } for + PR row col put + /col col 1 add def + /row row 1 add def + }{ % all zero entries + /row row 1 add def % continue loop with same row + } ifelse + } loop + /X A def % solution vector + A Rows 1 sub get dup + Cols 1 sub get exch + Cols 2 sub get div + X Rows 1 sub 3 -1 roll put % X[n] + Rows 2 sub -1 0 { % for loop to calculate X[i] + /xi exch def % current index + A xi get % i-th row + /Axi exch def + /sum 0 def + Cols 2 sub -1 xi 1 add { + /n exch def + /sum sum Axi n get X n get mul add def + } for + Axi Cols 1 sub get % b=Axi[Cols-1] + sum sub % b-sum + Axi xi get div % b-sum / Axi[xi] + X xi 3 -1 roll put % X[xi] + } for + X + end +} def +% +/c@_0 2.515517 def +/c@_1 0.802853 def +/c@_2 0.010328 def +/d@_1 1.432788 def +/d@_2 0.189269 def +/d@_3 0.001308 def +/norminv { + 5 dict begin + neg 1 add 1 exch div ln 2 mul sqrt + /t exch def + /t2 t dup mul def + /t3 t2 t mul def + c@_0 c@_1 t mul add c@_2 t2 mul add 1 d@_1 t mul add + d@_2 t2 mul add d@_3 t3 mul add div neg t add + end +} def +%end{norminv Michael Sharpe} +% +% +% END pst-math.pro diff --git a/graphics/pstricks/contrib/pst-math/latex/pst-math.sty b/graphics/pstricks/contrib/pst-math/latex/pst-math.sty new file mode 100644 index 0000000000..0c0f1aef40 --- /dev/null +++ b/graphics/pstricks/contrib/pst-math/latex/pst-math.sty @@ -0,0 +1,93 @@ +% $Id: pst-math.sty 864 2018-12-15 21:15:11Z herbert $ +%% +%% This is file `pst-math.sty'. +%% +%% IMPORTANT NOTICE: +%% +%% pst-math Copyright (C) 2019- Herbert Voss <hvoss@tug.org> +%% +%% This package may be distributed under the terms of the LaTeX Project +%% Public License, as described in lppl.txt in the base LaTeX distribution. +%% Either version 1.0 or, at your option, any later version. +%% + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{pst-math}[2018/12/16 v 0.65 package wrapper for PSTricks pst-math.tex] +\RequirePackage{pst-calculate} +\RequirePackage{ifluatex} +\RequirePackage{xstring} +\input pst-math.tex +\ProvidesFile{pst-math.tex} + [\filedate\space v\fileversion\space `PST-math' (hv)] +\IfFileExists{pst-math.pro}{\ProvidesFile{pst-math.pro}% + [2018/12/13 v. 0.65, PostScript prologue file (hv)] +\@addtofilelist{pst-math.pro}}{}% + +\newcounter{Rand@No}\newcounter{Random@Left}\newcounter{Random@Right}\newcounter{Random@No@max}% +\setcounter{Rand@No}{0}\setcounter{Random@Left}{1}\setcounter{Random@Right}{1000}% + +\def\defineRandIntervall(#1,#2)#3{% + \setcounter{Random@Left}{#1}% + \setcounter{Random@Right}{#2}% + \setcounter{Random@No@max}{#3}% + \setcounter{Rand@No}{0}% + \def\RandomNumbers{}% + \def\R@Control{}% + \multido{\iA=1+1}{\theRandom@No@max}{\xdef\R@Control{0\R@Control}}% +} + +\def\RandomNumbers{}%\pscalculate{randint(\theRandom@Left,\theRandom@Right)}} + +\def\makeSimpleRandomNumberList{% + \def\RandomNumbers{}% + \psforeach{\iA}{1,2,..,\theRandom@No@max}{% + \edef\@Number{\pscalculate{randint(\theRandom@Left,\theRandom@Right)}}% Zufallszahl + \ifnum\iA=1 + \xdef\RandomNumbers{\@Number}% + \else + \xdef\RandomNumbers{\RandomNumbers,\@Number}% + \fi + }% +} +% +\def\makeRandomNumberList{% + \edef\@Number{\pscalculate{randint(\theRandom@Left,\theRandom@Right)}}% Zufallszahl + \add@Number{\@Number}} + +\def\add@Number#1{% + \def\R@Left{}\def\R@Right{}\def\R@Value{}% + \StrChar{\R@Control}{#1}[\R@Value] + \ifnum\R@Value=0 + \stepcounter{Rand@No}% + \ifnum\theRand@No=1\relax + \gdef\RandomNumbers{#1}% + \else + \xdef\RandomNumbers{\RandomNumbers,#1}% + \fi + \StrLeft{\R@Control}{\the\numexpr#1-1}[\R@Left]% + \StrRight{\R@Control}{\the\numexpr\theRandom@No@max-#1}[\R@Right]% + \xdef\R@Control{\R@Left1\R@Right}% + \fi + \ifnum\theRand@No=\theRandom@No@max + \def\next{}% + \else + \def\next{\makeRandomNumberList}% + \fi + \next +} +\def\getNumberFromList#1{% + \global\count0 = 1 + \edef\x{\noexpand\get@Index#1;\RandomNumbers}\x,,\relax} +\def\get@Index#1;#2,#3,#4\relax{% + \ifnum\the\count0=#1 + \def\next{#2}% + \else + \global\advance\count0 by 1 + \def\next{\get@Index#1;#3,#4\relax}% + \fi + \next +} + +\endinput + + diff --git a/graphics/pstricks/contrib/pst-math/tex/pst-math.tex b/graphics/pstricks/contrib/pst-math/tex/pst-math.tex new file mode 100644 index 0000000000..5816202457 --- /dev/null +++ b/graphics/pstricks/contrib/pst-math/tex/pst-math.tex @@ -0,0 +1,32 @@ +%% +%% This is file `pst-math.tex', +%% +%% IMPORTANT NOTICE: +%% +%% Package `pst-math.tex' +%% +%% Christophe Jorssen +%% Herbert Voss <hvoss@tug.org> +%% +%% This program can be redistributed and/or modified under the terms +%% of the LaTeX Project Public License Distributed from CTAN archives +%% in directory CTAN:/macros/latex/base/lppl.txt. +%% +%% DESCRIPTION: +%% `pst-math' is a PSTricks package to enhance math in PSTricks +%% +%% +% +\csname PSTmathLoaded\endcsname +\let\PSTmathLoaded\endinput +\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi +\def\fileversion{0.64} +\def\filedate{2018/12/13} +\message{`pst-math' v\fileversion\space, (CJ,hv)} + +\pstheader{pst-math.pro} +% +\def\pstPI#1{\ifcase#1\or3.141593\or1.570796\or1.047198\or0.785398\fi} +% + +\endinput |