summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/polexpr/polexpr.sty135
1 files changed, 68 insertions, 67 deletions
diff --git a/Master/texmf-dist/tex/latex/polexpr/polexpr.sty b/Master/texmf-dist/tex/latex/polexpr/polexpr.sty
index 601446cf671..9bc286115d8 100644
--- a/Master/texmf-dist/tex/latex/polexpr/polexpr.sty
+++ b/Master/texmf-dist/tex/latex/polexpr/polexpr.sty
@@ -1,7 +1,7 @@
% author: Jean-François Burnol
% License: LPPL 1.3c (author-maintained)
\ProvidesPackage{polexpr}%
- [2018/12/08 v0.7 Polynomial expressions with rational coefficients (JFB)]%
+ [2018/12/09 v0.7.2 Polynomial expressions with rational coefficients (JFB)]%
\RequirePackage{xintexpr}[2018/06/17]% xint 1.3c for \ifxintglobaldefs boolean
\edef\POL@restorecatcodes
{\catcode`\noexpand\_ \the\catcode`\_ %
@@ -914,12 +914,13 @@
{\let\POL@findrat@E\POL@findrat@Dexp} % aussi ok pour 1[0]
{\edef\POL@findrat@E{\the\numexpr\xintLen{\POL@findrat@Dint}%
+\POL@findrat@Dexp}}%
+% ATTENTION QUE LA CONVENTION DE SIGNE POUR \POL@findrat@E EST OPPOSÉE À CELLE
+% POUR LE CODE PLUS ANCIEN FAISANT "REFINE"
\POL@initarray\POL@IfMultIsKnown\xint_secondoftwo
\let\POL@findrat@nbofirrroots\POL@isolz@NbOfRoots
% find all rational roots, and their multiplicities,
% factor them out in passing from original (Sturm root) polynomial
\ifnum\POL@findrat@E<7
- \PolEnsureIntervalLength{\POL@sturmname}{1}{-\POL@findrat@E}%
\def\POL@findrat@index{1}%
\POL@findrat@loop@secondpass@direct
\else
@@ -928,7 +929,6 @@
\POL@findrat@loop@firstpass
% and now we do the final pass finding them all
\def\POL@findrat@index{1}%
- \PolEnsureIntervalLength{\POL@sturmname}{1}{-\POL@findrat@E}%
\POL@findrat@loop@secondpass
\fi
% declare the new polynomials
@@ -947,7 +947,7 @@
{}%
\ifnum\xintiloopindex<\POL@isolz@NbOfRoots\space
\repeat }%
- \begingroup\globaldefs1
+ \begingroup\globaldefs\@ne
% attention de ne surtout pas faire un \expandafter ici, car en cas d'un
% seul item, \xintAssignArray l'unbraces...
\xintAssignArray\POL@temp\to#1%
@@ -956,36 +956,20 @@
\def\POL@findrat@loop@firstpass{%
\PolSturmIfZeroExactlyKnown{\POL@sturmname}{\POL@findrat@index}%
\POL@findrat@loop@decimal% get its multiplicity
- \POL@findrat@loop@a
+ \POL@findrat@loop@aa % refine interval and check
\edef\POL@findrat@index{\the\numexpr\POL@findrat@index+\@ne}%
\ifnum\POL@findrat@index>\POL@isolz@NbOfRoots
\else
\expandafter\POL@findrat@loop@firstpass
\fi
}%
-\def\POL@findrat@loop@secondpass{%
+\def\POL@findrat@loop@aa{%
+ % we do a first pass to identify roots with denominators < 1000
+ \PolEnsureIntervalLength{\POL@sturmname}{\POL@findrat@index}{-6}%
+ % attention that perhaps now the root is known!
\PolSturmIfZeroExactlyKnown{\POL@sturmname}{\POL@findrat@index}%
- {}% nothing more to be done, already stored
- \POL@findrat@loop@b
- \edef\POL@findrat@index{\the\numexpr\POL@findrat@index+\@ne}%
- \ifnum\POL@findrat@index>\POL@isolz@NbOfRoots
- \else
- \PolEnsureIntervalLength
- {\POL@sturmname}{\POL@findrat@index}{-\POL@findrat@E}% dynamic
- \expandafter\POL@findrat@loop@secondpass
- \fi
-}%
-\def\POL@findrat@loop@secondpass@direct{%
- \PolSturmIfZeroExactlyKnown{\POL@sturmname}{\POL@findrat@index}%
- \POL@findrat@loop@decimal
- \POL@findrat@loop@b
- \edef\POL@findrat@index{\the\numexpr\POL@findrat@index+\@ne}%
- \ifnum\POL@findrat@index>\POL@isolz@NbOfRoots
- \else
- \PolEnsureIntervalLength
- {\POL@sturmname}{\POL@findrat@index}{-\POL@findrat@E}% dynamic
- \expandafter\POL@findrat@loop@secondpass@direct
- \fi
+ \POL@findrat@loop@decimal
+ \POL@findrat@loop@a
}%
\def\POL@findrat@loop@decimal{% we have an already found decimal root
% we do not go via @storeit, as it is already stored
@@ -1002,6 +986,7 @@
\edef\POLuserpol@_findrat@oneterm{1.\noexpand\empty
{\xintiiOpp\POL@findrat@xN/1[0]}{\POL@findrat@xD/1[0]}}%
\POL@divide{\POL@sturmname\POL@sqfnorr}{_findrat@oneterm}% the one without mult.
+ %\expandafter\POL@split\POL@R;\POL@degR\POL@polR
\POL@findrat@loop@updatequotients
\POL@findrat@loop@getmultiplicity
}%
@@ -1018,10 +1003,7 @@
\def\POL@findrat@getE #1/1[#2]{#2}% /1 as it should be there.
% so an error will arise if not but cf \POL@refine@getE where I did not put it
\def\POL@findrat@loop@a{%
- % we do a first pass to identify roots with denominators < 1000
- \PolEnsureIntervalLength{\POL@sturmname}{\POL@findrat@index}{-6}%
% attention that the width may have been already smaller than 10^{-6}
- % also attention that one of the bound may be zero
\POL@get@IsoLeft@rawin
\POL@get@IsoRight@rawin
\edef\POL@findrat@localW
@@ -1046,28 +1028,20 @@
\fi
}%
\def\POL@findrat@gcdloop{%
- % we must be careful with sign (attention one of the bounds may be zero)
- \let\POL@findrat@IfNeg\xint_secondoftwo
+ % we must be careful with sign
+ % but we are certain no extremity is a root
+ \let\POL@findrat@ifnegative\xint_secondoftwo
\xintiiifSgn\POL@IsoLeft@Int
\POL@findrat@gcdloop@n
- \POL@findrat@gcdloop@zero
+ \POL@error@thisisimpossible
\POL@findrat@gcdloop@p
}%
\def\POL@findrat@gcdloop@n{%
- \let\POL@findrat@IfNeg\xint_firstoftwo
+ \let\POL@findrat@ifnegative\xint_firstoftwo
\let\POL@temp\POL@IsoRight@Int
\edef\POL@IsoRight@Int{\xintiiOpp{\POL@IsoLeft@Int}}%
\edef\POL@IsoLeft@Int{\xintiiOpp{\POL@temp}}%
- \xintiiifSgn\POL@IsoLeft@Int
- \POL@error % impossible branch
- \POL@findrat@gcdloop@zero
- \POL@findrat@gcdloop@p
-}%
-\def\POL@findrat@gcdloop@zero{%
- % the continued fraction would be the one of 1/2, so only 1/2 to test...
- \edef\POL@findrat@x
- {1/2\romannumeral\xintreplicate{\POL@findrat@localW}{0}[0]}%
- \POL@findrat@gcdloop@testit
+ \POL@findrat@gcdloop@p
}%
\def\POL@findrat@gcdloop@p{%
\edef\POL@findrat@gcdloop@Ap{\xintDec{\xintDouble\POL@IsoRight@Int}}%
@@ -1140,7 +1114,7 @@
}%
\def\POL@findrat@gcdloop@testit{%
% zero should never occur here
- \POL@findrat@IfNeg{\edef\POL@findrat@x{-\POL@findrat@x}}{}%
+ \POL@findrat@ifnegative{\edef\POL@findrat@x{-\POL@findrat@x}}{}%
\POL@xintfrac@getNDE\POL@findrat@x\POL@findrat@xN\POL@findrat@xD\POL@_
\edef\POLuserpol@_findrat@oneterm{1.\noexpand\empty
{\xintiiOpp{\POL@findrat@xN}/1[0]}{\POL@findrat@xD/1[0]}}%
@@ -1151,10 +1125,36 @@
\POL@findrat@loop@updatequotients
\POL@findrat@loop@getmultiplicity % will continue updating the mult. one
\def\POL@findrat@gcdloop@done{1}%
- \else
\fi
}%
% This is second phase
+\def\POL@findrat@loop@secondpass{%
+ \PolSturmIfZeroExactlyKnown{\POL@sturmname}{\POL@findrat@index}%
+ {}% nothing more to be done, already stored
+ \POL@findrat@loop@bb % refine interval and check
+ \edef\POL@findrat@index{\the\numexpr\POL@findrat@index+\@ne}%
+ \ifnum\POL@findrat@index>\POL@isolz@NbOfRoots
+ \else
+ \expandafter\POL@findrat@loop@secondpass
+ \fi
+}%
+\def\POL@findrat@loop@secondpass@direct{%
+ \PolSturmIfZeroExactlyKnown{\POL@sturmname}{\POL@findrat@index}%
+ \POL@findrat@loop@decimal
+ \POL@findrat@loop@bb
+ \edef\POL@findrat@index{\the\numexpr\POL@findrat@index+\@ne}%
+ \ifnum\POL@findrat@index>\POL@isolz@NbOfRoots
+ \else
+ \expandafter\POL@findrat@loop@secondpass@direct
+ \fi
+}%
+\def\POL@findrat@loop@bb{%
+ \PolEnsureIntervalLength{\POL@sturmname}{\POL@findrat@index}{-\POL@findrat@E}%
+ % ATTENTION THAT PERHAPS NOW THE ROOT IS KNOWN!
+ \PolSturmIfZeroExactlyKnown{\POL@sturmname}{\POL@findrat@index}%
+ \POL@findrat@loop@decimal
+ \POL@findrat@loop@b
+}%
\def\POL@findrat@loop@b{%
\edef\POL@findrat@Lscaled{\xintMul{\POL@findrat@D}%
{\POL@xintexprGetVar{\POL@sturmname L_\POL@findrat@index}}}%
@@ -1206,11 +1206,13 @@
\let\csname POL_ZeroIsKnown\POL@sturmname\POL@findrat@index\endcsname
\xint_stop_atfirstoftwo
\begingroup\xintglobaldefstrue
- \xintdefvar
- \POL@sturmname L_\POL@findrat@index,%
- \POL@sturmname R_\POL@findrat@index,%
- \POL@sturmname Z_\POL@findrat@index _isknown
- := qfrac(\POL@findrat@x),qfrac(\POL@findrat@x),1;%
+ % skip some overhead of \xintdefvar...
+ \XINT_expr_defvar_one{\POL@sturmname L_\POL@findrat@index}%
+ {\csname .=\POL@findrat@x\endcsname}%
+ \XINT_expr_defvar_one{\POL@sturmname R_\POL@findrat@index}%
+ {\csname .=\POL@findrat@x\endcsname}%
+ \XINT_expr_defvar_one{\POL@sturmname Z_\POL@findrat@index _isknown}%
+ {\csname .=1\endcsname}%
\endgroup
}%
\def\POL@findrat@loop@updatequotients{%
@@ -1320,8 +1322,9 @@
% added at 0.7
\let\x\POL@isolz@NbOfRoots
\xintloop
- \xintdefvar \POL@sturmname M_\x
- := \csname POL_ZeroMult\POL@sturmname\x\endcsname ;%
+ % skip some overhead of \xintdefvar...
+ \XINT_expr_defvar_one{\POL@sturmname M_\x}%
+ {\csname .=\csname POL_ZeroMult\POL@sturmname\x\endcsname\endcsname}%
\edef\x{\the\numexpr\x-\@ne}%
\ifnum\x>\z@
\repeat
@@ -1694,11 +1697,11 @@
\repeat
}%
\def\POL@isolz@check{% \POL@IsoRightSign must be ready for use here
-% \ifxintverbose
-% \xintMessage{polexpr}{Info}%
-% {\the\numexpr\POL@IsoLeftSV-\POL@IsoRightSV\relax\space roots
-% in (\POL@IsoLeft@raw,\POL@IsoRight@raw] (E = \POL@isolz@E)}%
-% \fi
+\ifxintverbose
+ \xintMessage{polexpr}{Info}%
+ {\the\numexpr\POL@IsoLeftSV-\POL@IsoRightSV\relax\space roots
+ in (\POL@IsoLeft@raw,\POL@IsoRight@raw] (E = \POL@isolz@E)}%
+\fi
\ifcase\numexpr\POL@IsoLeftSV-\POL@IsoRightSV\relax
% no root in ]left, right]
\global\POL@isolz@nextwillneedrefinefalse
@@ -1896,18 +1899,16 @@
\xint_stop_atfirstoftwo
\fi
\begingroup\xintglobaldefstrue
- \xintdefvar
- \POL@sturmname L_\POL@isolz@IntervalIndex,%
- \POL@sturmname R_\POL@isolz@IntervalIndex,%
+ % skip some overhead of \xintdefvar...
+ \XINT_expr_defvar_one{\POL@sturmname L_\POL@isolz@IntervalIndex}%
+ {\csname .=\POL@IsoLeft@rawout\endcsname}%
+ \XINT_expr_defvar_one{\POL@sturmname R_\POL@isolz@IntervalIndex}%
+ {\csname .=\POL@IsoRight@rawout\endcsname}%
% added at 0.7
- \POL@sturmname Z_\POL@isolz@IntervalIndex _isknown
- := qfrac(\POL@IsoLeft@rawout),%
- qfrac(\POL@IsoRight@rawout),%
- \ifnum\POL@IsoRightSign=\z@ 1\else 0\fi;%
+ \XINT_expr_defvar_one{\POL@sturmname Z_\POL@isolz@IntervalIndex _isknown}%
+ {\csname .=\ifnum\POL@IsoRightSign=\z@ 1\else 0\fi\endcsname}%
\endgroup
}%
-
-
%% \PolRefineInterval
\def\POL@xintexprGetVar#1{\expandafter\expandafter\expandafter
\XINT_expr_unlock\csname XINT_expr_var_#1\endcsname}%