summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-03-02 22:42:11 +0000
committerKarl Berry <karl@freefriends.org>2018-03-02 22:42:11 +0000
commit15987abe3d0b65ba3cdd8310f3f383837c9a5c2b (patch)
treed3079c01af891485bc4bcfe80aacee99a80d2c6b /Master/texmf-dist/tex
parent59c0af634a8c722fcf21699c218479d08b902139 (diff)
polexpr (2mar18)
git-svn-id: svn://tug.org/texlive/trunk@46789 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/polexpr/polexpr.sty146
1 files changed, 27 insertions, 119 deletions
diff --git a/Master/texmf-dist/tex/latex/polexpr/polexpr.sty b/Master/texmf-dist/tex/latex/polexpr/polexpr.sty
index d4d45177744..fd295dfe687 100644
--- a/Master/texmf-dist/tex/latex/polexpr/polexpr.sty
+++ b/Master/texmf-dist/tex/latex/polexpr/polexpr.sty
@@ -1,8 +1,8 @@
% author: Jean-François Burnol
% License: LPPL 1.3c (author-maintained)
\ProvidesPackage{polexpr}%
- [2018/02/16 v0.4 Polynomial expressions with rational coefficients (JFB)]%
-\RequirePackage{xintexpr}[2016/03/19]% xint 1.2g (or 1.2c 2015/11/16 at least)
+ [2018/03/01 v0.4.1 Polynomial expressions with rational coefficients (JFB)]%
+\RequirePackage{xintexpr}[2018/03/01]% xint 1.3
\edef\POL@restorecatcodes
{\catcode`\noexpand\_ \the\catcode`\_ \catcode0 \the\catcode0\relax}%
\catcode`\_ 11 \catcode0 12
@@ -45,17 +45,14 @@
\catcode59 12 \POL@defpol}%
\def\POL@defpol #1(#2)#3=#4;{%
\POL@restoresemicolon
- \let\POL@original_redefinemacros\XINT_expr_redefinemacros
- \let\XINT_expr_redefinemacros\POL@redefinemacros
\edef\POL@tmp{\ifxintverbose1\else0\fi}%
\unless\ifxintveryverbose\xintverbosefalse\fi
- \xintdeffunc __pol(#2):=#4;\if1\POL@tmp\xintverbosetrue\fi
- \let\XINT_expr_redefinemacros\POL@original_redefinemacros
+ \xintdeffunc __pol(#2):=0+(#4);% force conversion to raw if a constant
+ \if1\POL@tmp\xintverbosetrue\fi
\edef\POL@polname{\xint_zapspaces #1 \xint_gobble_i}%
\begingroup
\setbox0\hbox{%
\let\xintScalarAdd\xintAdd
- \let\XINT_fadd_C\POL_fadd_C % patch Add to use l.c.m.
\let\xintScalarSub\xintSub
\let\xintScalarMul\xintMul
\let\xintScalarDiv\xintDiv
@@ -68,10 +65,10 @@
\let\xintOpp\POL@opp
\def\xintSub ##1##2{\xintAdd{##1}{\xintOpp{##2}}}%
% \xintAdd to get \POL@result defined even if numerical only expression
+ % I could also test \ifPOL@pol, but well, this is very small overhead
\xintAdd{0}%
{\csname XINT_expr_userfunc___pol\endcsname
-% comma delimited from xintexpr at 1.2p or earlier. Might change.
- {\global\POL@poltrue\def\POL@result{1.\empty{0/1[0]}{1/1[0]}}},}%
+ {\global\POL@poltrue\def\POL@result{1.\empty{0/1[0]}{1/1[0]}}}}%
\expandafter}\expandafter
\endgroup\expandafter
\def\csname POLuserpol@\POL@polname\expandafter\endcsname
@@ -81,22 +78,19 @@
%%
\def\POL@newpol#1{%
\expandafter\POL@ifZero\csname POLuserpol@#1\endcsname
- {\@namedef{XINT_expr_userfunc_#1}##1,{0/1[0]}}%
+ {\@namedef{XINT_expr_userfunc_#1}##1{0/1[0]}}%
{\POL@newpolhorner{#1}}%
- \unless\ifcsname XINT_expr_userfuncNE:#1\endcsname\POL@addtoextras{#1}\fi
\expandafter\XINT_expr_defuserfunc
- \csname XINT_expr_func_#1\expandafter\endcsname
- \csname XINT_expr_userfunc_#1\endcsname
+ \csname XINT_expr_func_#1\endcsname{#1}{expr}%
\expandafter\let\csname XINT_flexpr_func_#1\endcsname\@undefined
\ifxintverbose\POL@info{#1}\fi
}%
\def\POL@newfloatpol#1{%
\expandafter\POL@ifZero\csname POLuserpol@#1\endcsname
- {\@namedef{XINT_flexpr_userfunc_#1}##1,{0[0]}}%
+ {\@namedef{XINT_flexpr_userfunc_#1}##1{0[0]}}%
{\POL@newfloatpolhorner{#1}}%
\expandafter\XINT_expr_defuserfunc
- \csname XINT_flexpr_func_#1\expandafter\endcsname
- \csname XINT_flexpr_userfunc_#1\endcsname
+ \csname XINT_flexpr_func_#1\endcsname{#1}{flexpr}%
\ifxintverbose\POL@floatinfo{#1}\fi
}%
\def\POL@info #1{%
@@ -128,7 +122,7 @@
\expandafter
\endgroup
\expandafter\def\csname XINT_expr_userfunc_#1\expandafter\endcsname
- \expandafter##\expandafter1\expandafter,\expandafter{\POL@tmp{##1}}%
+ \expandafter##\expandafter1\expandafter{\POL@tmp{##1}}%
}%
\def\POL@newfloatpolhorner#1{%
%% redefine function to expand by Horner scheme. Is this useful?
@@ -142,7 +136,7 @@
\expandafter
\endgroup
\expandafter\def\csname XINT_flexpr_userfunc_#1\expandafter\endcsname
- \expandafter##\expandafter1\expandafter,\expandafter{\POL@tmp{##1}}%
+ \expandafter##\expandafter1\expandafter{\POL@tmp{##1}}%
}%
\def\POL@newpol@horner#1{\let\xintAdd\relax\let\xintMul\relax
\def\POL@tmp##1{#1}\POL@newpol@horner@loop.}%
@@ -164,42 +158,6 @@
{\xintMul{##1}{\POL@tmp{##1}}}}%
\POL@newpol@floathorner@loop.%
}%
-%% Customizes xintexpr.sty's \XINT_NewExpr (\POL@addtoextras{name})
-\begingroup
-\catcode`~ 12
-\catcode`$ 12 % $
-\catcode`! 11
-\gdef\POL@NEfork_one #1#2!#3#4{%
- \if ###1\xint_dothis {\POL__settopol{#4}}\fi
- \if ~#1\xint_dothis {\POL__userfunc{#4}}\fi
- \if $#1\xint_dothis {~xintApply::csv{~POL_userfunc{#4}}}\fi %$
- \xint_orthat {#3}#1#2\endcsname
-}%
-\gdef\POL@@redefineone #1#2#3{% #3 = name
- % Used for immediate f(numerical)
- \let#2#1%
- % \XINT_expr_userfunc_name
- \def#1##1\endcsname % key trick is to fetch up to \endcsname!
- {\expandafter\POL@NEfork_one\romannumeral`^^@##1!#2{#3}}%
-}%
- % Used when f(x) is encountered: great gain here!
-\gdef\POL__settopol#1#2,{~POL_settopol{#1}}%
-\gdef\POL_settopol#1{\global\POL@poltrue\expandafter\let\expandafter
- \POL@result\csname POLuserpol@#1\endcsname}%
- % Used when argument is neither numerical nor a macro parameter
- % Quite some magic here! (braces couldn't be used this way in \xintexpr)
-\gdef\POL__userfunc#1#2,\endcsname{~POL_userfunc{#1}{#2},\endcsname}%
-\gdef\POL_userfunc#1{\csname XINT_expr_userfunc_#1\endcsname}%
-\endgroup
-\def\POL@addtoextras#1{%
- \oodef\POL@redefineextras{\expandafter\POL@redefineextras
- \expandafter\POL@@redefineone
- \csname XINT_expr_userfunc_#1\expandafter\endcsname
- \csname XINT_expr_userfuncNE:#1\endcsname{#1}}%
-}%
-%\let\POL@original@redefinemacros\XINT_expr_redefinemacros % do locally
-\def\POL@redefinemacros{\POL@original_redefinemacros\POL@redefineextras}%
-\let\POL@redefineextras\@empty
\newcommand\PolGenFloatVariant[1]{\POL@newfloatpol{#1}}%
@@ -212,20 +170,17 @@
\def\POL@let#1#2{%
\expandafter\let\csname POLuserpol@#1\expandafter\endcsname
\csname POLuserpol@#2\endcsname
- \unless\ifcsname XINT_expr_userfuncNE:#1\endcsname\POL@addtoextras{#1}\fi
\expandafter\let\csname XINT_expr_userfunc_#1\expandafter\endcsname
\csname XINT_expr_userfunc_#2\endcsname
\expandafter\XINT_expr_defuserfunc
- \csname XINT_expr_func_#1\expandafter\endcsname
- \csname XINT_expr_userfunc_#1\endcsname
+ \csname XINT_expr_func_#1\endcsname{#1}{expr}%
\ifxintverbose\POL@info{#1}\fi
}%
\newcommand\PolGlobalLet[2]{\begingroup
\globaldefs\@ne
\if=\noexpand#2\expandafter\xint_firstoftwo
\else\expandafter\xint_secondoftwo\fi
-% There is a potential problem related to \POL@addtoextras, (the local set-up
-% will become the global one) but I will reconsider that another day
+% do I need to check something here relative to \xintNewExpr?
\POL@@globallet\POL@globallet {#1}{#2}}%
\def\POL@@globallet#1#2#3{\POL@globallet{#1}{#3}}%
\def\POL@globallet#1#2{\POL@let{#1}{#2}\endgroup}%
@@ -400,13 +355,9 @@
\edef\index{\the\numexpr\index+\@ne}%
\POL@map@loop.}%
\def\POL@xintIrr#1{\xintIrr{#1}[0]}%
-\def\POL@special@xintIrr#1{%
- \expandafter\POL@special@xintIrr@i\romannumeral0\xintraw{#1}}%
-\def\POL@special@xintIrr@i#1/#2[#3]{\xintIrr{#1/#2[0]}[#3]}%
\newcommand\PolReduceCoeffs{\@ifstar\POL@sreducecoeffs\POL@reducecoeffs}%
\def\POL@reducecoeffs#1{\PolMapCoeffs{\POL@xintIrr}{#1}}%
-\def\POL@sreducecoeffs#1{\PolMapCoeffs{\POL@special@xintIrr}{#1}}%
-\def\POL@special@xintIrr@skipraw#1{\POL@special@xintIrr@i#1}% used by ToSturm
+\def\POL@sreducecoeffs#1{\PolMapCoeffs{\xintPIrr}{#1}}%
%% EUCLIDEAN DIVISION
@@ -430,7 +381,7 @@
\newcommand\POL@divide[2]{%
\begingroup
\let\xintScalarSub\xintSub
- \let\XINT_fadd_C\POL_fadd_C
+ \let\xintScalarAdd\xintAdd
\let\xintScalarMul\xintMul
\let\xintScalarDiv\xintDiv
\expandafter\let\expandafter\POL@A\csname POLuserpol@#1\endcsname
@@ -462,7 +413,7 @@
\def\POL@GCD #1#2#3{%
\begingroup
\let\xintScalarSub\xintSub
- \let\XINT_fadd_C\POL_fadd_C
+ \let\xintScalarAdd\xintAdd
\let\xintScalarMul\xintMul
\let\xintScalarDiv\xintDiv
\expandafter\let\expandafter\POL@A\csname POLuserpol@#1\endcsname
@@ -678,7 +629,7 @@
\newcommand\POL@ToSturm[2]{%
\edef\POL@sturmname{#2}%
\POL@let{\POL@sturmname _0}{#1}%
- \POL@mapcoeffs{\POL@special@xintIrr}{\POL@sturmname _0}%
+ \POL@mapcoeffs{\xintPIrr}{\POL@sturmname _0}%
\POL@Diff@@one{\POL@sturmname _0}{\POL@sturmname _1}%
\POL@count\@ne
\xintloop
@@ -686,6 +637,7 @@
{\POL@sturmname _\the\POL@count}%
\expandafter\POL@split\POL@R;\POL@degR\POL@polR
\unless\ifnum\POL@degR=\m@ne
+ % suis-je sûr format raw certain?
\edef\POL@polR{\xintApply{\POL@dooppandirr}{\POL@polR}}%
\advance\POL@count\@ne
\expandafter\edef\csname POLuserpol@\POL@sturmname _\the\POL@count\endcsname
@@ -699,7 +651,8 @@
\POL@divide{\POL@sturmname _\the\POL@count}%
{\POL@sturmname _\POL@sturm@N}%
\expandafter\POL@split\POL@Q;\POL@degQ\POL@polQ
- \edef\POL@polQ{\xintApply{\POL@special@xintIrr@skipraw}{\POL@polQ}}%
+ \edef\POL@polQ % suis-je sûr format raw certain?
+ {\xintApply{\expandafter\XINT_pirr_start\xint_firstofone}{\POL@polQ}}%
\edef\POL@Q{\POL@degQ.\noexpand\empty\POL@polQ}%
\expandafter\edef\csname POLuserpol@\POL@sturmname _\the\POL@count\endcsname
{\POL@degQ.\noexpand\empty\POL@polQ}%
@@ -716,7 +669,7 @@
\repeat
\expandafter\let\csname PolSturmChainLength_\POL@sturmname \endcsname\POL@sturm@N
}%
-\def\POL@dooppandirr#1{\xintiiOpp{\POL@special@xintIrr@i#1}}%
+\def\POL@dooppandirr#1{\xintiiOpp{\XINT_pirr_start#1}}%
\newcommand\PolSturmChainLength[1]
{\romannumeral`^^@\csname PolSturmChainLength_#1\endcsname}%
\newcommand\PolSetToSturmChainSignChangesAt[4][\global]{%
@@ -1434,25 +1387,8 @@
\romannumeral`^^@\csname POL_ZeroInt#1L0\endcsname
}%
-%% \PolDecToString (should become an xintfrac macro at some point)
-\newcommand\PolDecToString[1]{\romannumeral0\expandafter
- \POL@dectostring\romannumeral0\xintraw{#1}}%
-\def\POL@dectostring #1/#2[#3]{\xintiiifZero {#1}%
- \POL@dectostring@z
- {\if1\XINT_isOne{#2}\expandafter\POL@dectostring@a
- \else\expandafter\POL@dectostring@b
- \fi}%
- #1/#2[#3]%
-}%
-\def\POL@dectostring@z#1[#2]{ 0}%
-\def\POL@dectostring@a#1/#2[#3]{%
- \ifnum#3<\z@\xint_dothis{\xinttrunc{-#3}{#1[#3]}}\fi
- \xint_orthat{\xintiie{#1}{#3}}%
-}%
-\def\POL@dectostring@b#1/#2[#3]{% just to handle this somehow
- \ifnum#3<\z@\xint_dothis{\xinttrunc{-#3}{#1[#3]}/#2}\fi
- \xint_orthat{\xintiie{#1}{#3}/#2}%
-}%
+
+\let\PolDecToString\xintDecToString
\newcommand\PolMakeMonic[1]{%
@@ -1817,7 +1753,7 @@
\At\PolEvalAtExpr\krof {#1}{#3}%
}%
\newcommand\PolEvalAt[2]
- {\xintpraw{\csname XINT_expr_userfunc_#1\endcsname{#2},}}%
+ {\xintpraw{\csname XINT_expr_userfunc_#1\endcsname{#2}}}%
\newcommand\PolEvalAtExpr[2]{\xinttheexpr #1(#2)\relax}%
%
\newcommand\PolEvalReduced[3]{\romannumeral`^^@\Pol@Eval@fork
@@ -1826,7 +1762,7 @@
}%
\newcommand\PolEvalReducedAt[2]{%
\xintpraw % in order not to print denominator if the latter equals 1
- {\xintIrr{\csname XINT_expr_userfunc_#1\endcsname{#2},}[0]}%
+ {\xintIrr{\csname XINT_expr_userfunc_#1\endcsname{#2}}[0]}%
}%
\newcommand\PolEvalReducedAtExpr[2]{%
\xintpraw
@@ -1838,7 +1774,7 @@
\At\PolFloatEvalAtExpr\krof {#1}{#3}%
}%
\newcommand\PolFloatEvalAt[2]
- {\xintpfloat{\csname XINT_flexpr_userfunc_#1\endcsname{#2},}}%
+ {\xintpfloat{\csname XINT_flexpr_userfunc_#1\endcsname{#2}}}%
\newcommand\PolFloatEvalAtExpr[2]{\xintthefloatexpr #1(#2)\relax}%
%
\newcommand\PolLeadingCoeff[1]{%
@@ -1987,33 +1923,5 @@
}%
-%% Patch of xintfrac.sty's \xintAdd: for a/b + c/d, use lcm(b,d)
-\RequirePackage{xintgcd}
-\def\POL_fadd_C #1#2#3%
-{%
- \expandafter\POL_fadd_D
- \romannumeral0\xintiigcd{#2}{#3}.%
- {#2}{#3}{#1}%
-}%
-\def\POL_fadd_D #1.#2#3%
-{%
- \expandafter\POL_fadd_E
- \romannumeral0\xintiiquo{#3}{#1}.%
- {\romannumeral0\xintiiquo{#2}{#1}}{#2}{#3}%
-}%
-\def\POL_fadd_E #1.#2#3#4#5%
-{%
- \expandafter\POL_fadd_F\romannumeral0\xintiimul{#1}{#3}.{#2}%
- {\xintiiMul{#1}{#5}}%
-}%
-\def\POL_fadd_F #1.#2#3#4%
-{%
- \expandafter\POL_fadd_G
- \romannumeral0\xintiiadd{#3}{\xintiiMul{#2}{#4}}/#1%
-}%
-\def\POL_fadd_G #1{%
-\def\POL_fadd_G ##1{\if0##1\expandafter\XINT_fadd_iszero\fi#1##1}%
-}\POL_fadd_G{ }%
-
\POL@restorecatcodes
\endinput