texlive[53633] Master/texmf-dist: polexpr (1feb20)

commits+karl at tug.org commits+karl at tug.org
Sat Feb 1 23:17:01 CET 2020


Revision: 53633
          http://tug.org/svn/texlive?view=revision&revision=53633
Author:   karl
Date:     2020-02-01 23:17:01 +0100 (Sat, 01 Feb 2020)
Log Message:
-----------
polexpr (1feb20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/polexpr/README.md
    trunk/Master/texmf-dist/doc/latex/polexpr/polexpr.html
    trunk/Master/texmf-dist/doc/latex/polexpr/polexpr.txt
    trunk/Master/texmf-dist/tex/latex/polexpr/polexpr.sty

Modified: trunk/Master/texmf-dist/doc/latex/polexpr/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/polexpr/README.md	2020-02-01 22:15:59 UTC (rev 53632)
+++ trunk/Master/texmf-dist/doc/latex/polexpr/README.md	2020-02-01 22:17:01 UTC (rev 53633)
@@ -4,7 +4,7 @@
 License
 -------
 
-Copyright (C) 2018-2019 Jean-François Burnol
+Copyright (C) 2018-2020 Jean-François Burnol
 
 See documentation of package [xint](http://www.ctan.org/pkg/xint) for
 contact information.
@@ -81,8 +81,10 @@
 - 0.7.4 (2019/02/12)
   Bugfix: 20000000000 is too big for \numexpr, shouldn't I know that?
   Thanks to Jürgen Gilg for report.
+- 0.7.5 (2020/01/31)
+  Synced with xint 1.4. Requires it.
 
-Files of 0.7.4 release:
+Files of 0.7.5 release:
 
 - README.md,
 - polexpr.sty (package file),

Modified: trunk/Master/texmf-dist/doc/latex/polexpr/polexpr.html
===================================================================
--- trunk/Master/texmf-dist/doc/latex/polexpr/polexpr.html	2020-02-01 22:15:59 UTC (rev 53632)
+++ trunk/Master/texmf-dist/doc/latex/polexpr/polexpr.html	2020-02-01 22:17:01 UTC (rev 53633)
@@ -362,7 +362,7 @@
 <body>
 <div class="document" id="package-polexpr-documentation">
 <h1 class="title">Package polexpr documentation</h1>
-<h2 class="subtitle" id="id1">0.7.4 (2019/02/12)</h2>
+<h2 class="subtitle" id="id1">0.7.5 (2020/01/31)</h2>
 
 <!-- comment: -*- fill-column: 72; mode: rst; -*- -->
 <div class="contents topic" id="contents">
@@ -2891,6 +2891,9 @@
 </li>
 </ul>
 </li>
+<li><p class="first">v0.7.5 (2020/01/31)</p>
+<p>Synced with xint 1.4. Requires it.</p>
+</li>
 </ul>
 </div>
 <div class="section" id="acknowledgments">

Modified: trunk/Master/texmf-dist/doc/latex/polexpr/polexpr.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/polexpr/polexpr.txt	2020-02-01 22:15:59 UTC (rev 53632)
+++ trunk/Master/texmf-dist/doc/latex/polexpr/polexpr.txt	2020-02-01 22:17:01 UTC (rev 53633)
@@ -4,7 +4,7 @@
  Package polexpr documentation
 ===============================
 
-0.7.4 (2019/02/12)
+0.7.5 (2020/01/31)
 ==================
 
 .. contents::
@@ -2567,6 +2567,11 @@
     - 20000000000 is too big for ``\numexpr``, shouldn't I know that?
       Thanks to Jürgen Gilg for report.
 
+- v0.7.5 (2020/01/31)
+
+  Synced with xint 1.4. Requires it.
+
+
 Acknowledgments
 ---------------
 

Modified: trunk/Master/texmf-dist/tex/latex/polexpr/polexpr.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polexpr/polexpr.sty	2020-02-01 22:15:59 UTC (rev 53632)
+++ trunk/Master/texmf-dist/tex/latex/polexpr/polexpr.sty	2020-02-01 22:17:01 UTC (rev 53633)
@@ -1,33 +1,178 @@
 % author: Jean-François Burnol
 % License: LPPL 1.3c (author-maintained)
 \ProvidesPackage{polexpr}%
-  [2019/02/12 v0.7.4 Polynomial expressions with rational coefficients (JFB)]%
-\RequirePackage{xintexpr}[2018/06/17]% xint 1.3c for \ifxintglobaldefs boolean
-\edef\POL at restorecatcodes
+  [2020/01/31 v0.7.5 Polynomial expressions with rational coefficients (JFB)]%
+\RequirePackage{xintexpr}[2020/01/31]% xint 1.4
+\edef\POL at restorecatcodes % TODO: think better about what is reasonable here
     {\catcode`\noexpand\_ \the\catcode`\_ %
      \catcode`\noexpand\! \the\catcode`\! %
      \catcode`\noexpand\* \the\catcode`\* %
+     \catcode`\noexpand\~ \the\catcode`\~ %
+     \catcode`\noexpand\: \the\catcode`\: %
      \catcode0 \the\catcode0\relax}%
 \catcode`\_ 11 \catcode0 12 \catcode`\* 12
 \long\def\xint_stop_atfirstoftwo  #1#2{ #1}% not yet in xint 1.3c
 \long\def\xint_stop_atsecondoftwo #1#2{ #2}%
 
-%% PATCH xintexpr TO AUTHORIZE ' IN NAMES (0.5.1)
-\catcode`\! 11
+%% 0.7.5 VERY SERIOUS TROUBLES TO GET polexpr TO WORK WITH xintexpr 1.4
+
+%% I hesitated about incorporating it directly into xint 1.4
+%% Don't do this at home, only xint gurus are allowed.
+\let\POL at originalXINT_expr_redefinemacros\XINT_expr_redefinemacros
+\def\XINT_expr_redefinemacros
+{%
+    \POL at originalXINT_expr_redefinemacros
+    \POL at activateNEhook
+}%
+%% Using \def's and not \let's to get better readable trace
+%% in case I need to debug but this never happens
+\def\POL at activateNEhook@xint % done in a group
+{%
+    \def\POL at NEhook@polfunc{\POL at NE@polfunc}%
+}%
+\def\POL at activateNEhook@pol
+{%
+    \def\POL at NEhook@polfunc{\POL at NP@polfunc}%
+}%
+\def\POL at activateNEhook{\POL at activateNEhook@xint}%
+%
+%
+\catcode`~ 12
+\catcode`! 11
+\catcode`: 11
+% We drop consideration of \XINT_global matters
+% because we have other more urgent and arduous problems
+\def\POL at defpolfunc #1#2%
+{%
+  \expandafter\POL at defpolfunc_a
+  \csname XINT_#2_func_#1\expandafter\endcsname
+  \csname XINT_#2_polfunc_#1\endcsname {#1}{#2}%
+}%
+\def\POL at defpolfunc_a #1#2#3#4%
+{%
+  \protected % xintexpr 1.4 does things such as \expandafter\xintAdd\expanded 
+  \expandafter\def\expandafter#2\expandafter##\expandafter1\expandafter
+  {%
+      #2{##1}%
+  }%
+  \def#1##1##2##3%
+  {%
+  % put it directly at the correct level of bracing
+  % don't worry for now about minimizing how many times ##3 is grabbed 
+     \expandafter##1\expandafter##2\expandafter{\expandafter
+     {\romannumeral`^^@\POL at NEhook@polfunc{XINT_#4_polfunc_#3}#2{##3}}}%
+  }%
+}%
+%
+\def\POL at polfunc@go #1#2#3{#2#3}% brace stripping intentional
+\def\POL at NEhook@polfunc{\POL at polfunc@go}% default for pure numerics
+%
+% Hook for expansion in \poldef
+\def\POL at NP@polfunc #1{%
+\def\POL at NP@polfunc ##1##2##3%
+{%
+    \if0\expandafter\XINT:NE:hastilde\detokenize{##3}~!\relax
+        \expandafter\XINT:NE:hashash\detokenize{##3}#1!\relax 0%
+      \expandafter\POL at polfunc@go
+    \else
+      \expandafter\POL:NP:polfunc:p
+    \fi {##1}{##2}{##3}%
+}}\expandafter\POL at NP@polfunc\string#%
+\def\POL:NP:polfunc:p #1#2#3%
+{%
+    ~romannumeral~POL:usepolfunc:pol{#1}{#3}%
+}%
+\def\POL:usepolfunc:pol #1%#2%
+{%
+% Here we are in the core of \poldef and we really
+% need to get rid of some \expanded tokens so
+% we accept being exposed to \expanded but arrange to
+% remain invariant. Then we will try to speed up
+% polynomial composition (at this time the \#1
+% is a nested Horner type macro) by «pre-expanding»
+% the argument, but this means using the \POL at get
+% methods inside an \hbox
+%
+% \POL at applypolfunc will be defined \protected
+%
+    \expandafter\xint_c_\expandafter\POL at applypolfunc
+% This will be \protected
+    \csname#1\endcsname
+%    #2% brace stripping is deliberate
+}%
+%
+% Hook for expansion in \xintexpr
+\def\POL at NE@polfunc #1{%
+\def\POL at NE@polfunc ##1##2##3%
+{%
+    \if0\expandafter\XINT:NE:hastilde\detokenize{##3}~!\relax
+        \expandafter\XINT:NE:hashash\detokenize{##3}#1!\relax 0%
+      \expandafter\POL at polfunc@go
+    \else
+      \expandafter\POL:NE:polfunc:p
+    \fi {##1}{##2}{##3}%
+}}\expandafter\POL at NE@polfunc\string#%
+\def\POL:NE:polfunc:p #1#2#3%
+{%
+    ~romannumeral~POL:usepolfunc:xint{#1}{#3}%
+}%
+\def\POL:usepolfunc:xint #1%
+{%
+% This is done to overcome \protected and is useful
+% in case the polynomial function ends up nested
+% in some non-polynomial user declared function
+% as the latter (and other things) tries to pre-expand
+% its arguments (as they may be used multiple time)
+% using \expanded, but \#1 is protected.
+% And this works recursively. We are inside braces.
+% However we have a very big problem with constant
+% polynomial functions. We have to handle them
+% in a special way.
+    -`0\csname#1\expandafter\endcsname\expanded
+}%
+\catcode`~ 13
+\catcode`: 12
+
+
+%% Start defining some \protected ones here
+\protected\def\POL at empty{}%
+\newif\ifPOL at pol
+\protected\def\POL at polglobaltrue {\global\let\ifPOL at pol\iftrue}%
+\protected\def\POL at polglobalfalse{\global\let\ifPOL at pol\iffalse}%
+
+
+%% Patch xintexpr to authorize ' in names (0.5.1)
+%% Adapted 0.7.5 to follow-up on xintexpr 1.4 internal changes
+%% (much simpler than previous stuff...)
+%% This allows ' as a character in a polynomial name (not initial one)
 \def\POL at XINT_expr_scanfunc_b #1%
 {%
-  \ifx !#1\xint_dothis{(_}\fi
-  \ifcat \relax#1\xint_dothis{(_}\fi
-  \if (#1\xint_dothis{\xint_firstoftwo{(`}}\fi
-  \if '#1\xint_dothis \XINT_expr_scanfunc_a \fi
-  \if @#1\xint_dothis \XINT_expr_scanfunc_a \fi
-  \if _#1\xint_dothis \XINT_expr_scanfunc_a \fi
-  \ifnum \xint_c_ix<1\string#1 \xint_dothis \XINT_expr_scanfunc_a \fi
-  \ifcat a#1\xint_dothis \XINT_expr_scanfunc_a \fi
-  \xint_orthat {(_}%
-    #1%
+  \ifcat \relax#1\xint_dothis{\iffalse{\fi}(_#1}\fi
+  \if (#1\xint_dothis{\iffalse{\fi}(`}\fi
+  \if 1\ifcat a#10\fi
+       \ifnum\xint_c_ix<1\string#1 0\fi
+       \if @#10\fi
+       \if _#10\fi
+       \if '#10\fi
+      1%
+      \xint_dothis{\iffalse{\fi}(_#1}\fi
+  \xint_orthat {#1\XINT_expr_scanfunc_a}%
 }%
 
+
+%% Activate polexp's modified xintexpr (only during definitions
+%% of polynomials)
+\def\POL at hackxintexpr {%
+    \let\POL at originalXINT_expr_scanfunc_b\XINT_expr_scanfunc_b
+    \let\XINT_expr_scanfunc_b\POL at XINT_expr_scanfunc_b
+    \def\POL at activateNEhook{\POL at activateNEhook@pol}%
+}%
+\def\POL at restorexintexpr {%
+    \let\XINT_expr_scanfunc_b\POL at originalXINT_expr_scanfunc_b
+    \def\POL at activateNEhook{\POL at activateNEhook@xint}%
+}%
+
+
 %% AUXILIARIES
 \catcode`! 3
 %% added at 0.7
@@ -46,7 +191,6 @@
 \polexprsetup{norr=_norr, sqfnorr=_sqf_norr}
 
 \newcount\POL at count
-\newif\ifPOL at pol
 \newif\ifxintveryverbose
 \newif\ifpoltypesetall
 \newif\ifPOL at tosturm@makefirstprimitive
@@ -54,7 +198,7 @@
 \newif\ifPOL at isolz@nextwillneedrefine
 \newif\ifpoltoexprall
 %% the main exchange structure (stored in macros \POLuserpol@<name>)
-%% is: degree.\empty{coeff0}{coeff1}....{coeffN}
+%% is: degree.\POL at empty{coeff0}{coeff1}....{coeffN}
 %% (degree=N except zero polynomial recognized from degree set to -1
 %%  but it has always the {0/1[0]} coeff0.)
 \def\POL at ifZero#1{\expandafter\POL at ifZero@aux#1;}%
@@ -67,13 +211,17 @@
 %
 \def\POL at resultfromarray #1{% ATTENTION, **MUST** be executed with
 % \count@ set to 1 + degree (\count@ = 0 for zero polynomial)
-    \edef\POL at result{\ifnum\count@>\z@
-      \the\numexpr\count at -\@ne.\noexpand\empty
+% Attention to the \protected here at 0.7.5
+% They are many all over the place
+    \protected\edef\POL at result{\ifnum\count@>\z@
+      \the\numexpr\count at -\@ne.\POL at empty
       \xintiloop [1+1]%
       \expandafter\POL at braceit\csname POL at array#1\xintiloopindex\endcsname
       \ifnum\xintiloopindex<\count@
       \repeat
-      \else-1.\noexpand\empty{0/1[0]}\fi}%
+% Attention to this \protected\POL at empty
+% They are many all over the place
+      \else-1.\POL at empty{0/1[0]}\fi}%
 }%
 \def\POL at braceit#1{{#1}}% needed as \xintiloopindex can not "see" through braces
 
@@ -85,12 +233,11 @@
    \POL at restoresemicolon
    \edef\POL at tmp{\ifxintverbose1\else0\fi}%
    \unless\ifxintveryverbose\xintverbosefalse\fi
-   \let\POL at originalXINT_expr_scanfunc_b\XINT_expr_scanfunc_b
-   \let\XINT_expr_scanfunc_b\POL at XINT_expr_scanfunc_b
+   \POL at hackxintexpr
    \xintdeffunc __pol(#2):=0+(#4);% force conversion to raw if a constant
+   \POL at restorexintexpr
    \if1\POL at tmp\xintverbosetrue\fi
    \edef\POL at polname{\xint_zapspaces #1 \xint_gobble_i}%
-   \let\XINT_expr_scanfunc_b\POL at originalXINT_expr_scanfunc_b
    \begingroup
      \setbox0\hbox{%
      \let\xintScalarAdd\xintAdd
@@ -107,9 +254,10 @@
      \def\xintSub ##1##2{\xintAdd{##1}{\xintOpp{##2}}}%
      % \xintAdd{0} to get \POL at result defined even if numerical only expression
      % I could also test \ifPOL at pol, but this is anyhow small overhead
-     \xintAdd{0}%
-       {\csname XINT_expr_userfunc___pol\endcsname
-        {\global\POL at poltrue\def\POL at result{1.\empty{0/1[0]}{1/1[0]}}}}%
+% Attention that xintexpr 1.4 has braces all over the place
+     \expandafter\xintAdd\expandafter{\expandafter0\expandafter}%
+       \romannumeral0\csname XINT_expr_userfunc___pol\endcsname
+        {\POL at polglobaltrue\protected\def\POL at result{1.\POL at empty{0/1[0]}{1/1[0]}}}%
      \expandafter}\expandafter
    \endgroup\expandafter
    \def\csname POLuserpol@\POL at polname\expandafter\endcsname
@@ -116,39 +264,69 @@
         \expandafter{\POL at result}%
    \expandafter\POL at newpol\expandafter{\POL at polname}%
 }%
-%%
+%
+
+
 \def\POL at newpol#1{%
-   \expandafter\POL at ifZero\csname POLuserpol@#1\endcsname
-      {\@namedef{XINT_expr_userfunc_#1}##1{0/1[0]}}%
-      {\POL at newpolhorner{#1}}%
-   \expandafter\XINT_expr_defuserfunc
-     \csname XINT_expr_func_#1\endcsname{#1}{expr}%
+%% We must handle specially constant polynomials because they must
+%% be made to work expandably in \poldef of other polynomials due
+%% to complicated matters having to do with the \POL at ifpol conditional
+   \ifnum\PolDegree{#1}<\@ne
+      % non-zero constant
+      % I am defining this one only for the Info message, no time now
+      \expandafter\edef\csname XINT_expr_polfunc_#1\endcsname
+          ##1{\PolNthCoeff{#1}{0}}%
+      % No hooks here!
+      \expandafter\edef\csname XINT_expr_func_#1\endcsname ##1##2##3%
+          {##1##2{{\PolNthCoeff{#1}{0}}}}%
+   \else
+      % polynomial of degree at least 1. This means that mechanism
+      % to get \POL at result will get activated and we must be very careful
+      % to never \edef when the Horner macro will be converted to
+      % a polynomial
+      \POL at newpolhorner{#1}%
+      \POL at defpolfunc{#1}{expr}%
+   \fi
    \expandafter\let\csname XINT_flexpr_func_#1\endcsname\@undefined
    \ifxintverbose\POL at info{#1}\fi
 }%
 \def\POL at newfloatpol#1{%
-   \expandafter\POL at ifZero\csname POLuserpol@#1\endcsname
-      {\@namedef{XINT_flexpr_userfunc_#1}##1{0[0]}}%
-      {\POL at newfloatpolhorner{#1}}%
-   \expandafter\XINT_expr_defuserfunc
-     \csname XINT_flexpr_func_#1\endcsname{#1}{flexpr}%
+%% We must handle specially constant polynomials because they must
+%% be made to work expandably in \poldef of other polynomials due
+%% to complicated matters having to do with the \POL at ifpol conditional
+   \ifnum\PolDegree{#1}<\@ne
+      % non-zero constant
+      % I am defining this one only for the Info message, no time now
+      \expandafter\edef\csname XINT_flexpr_polfunc_#1\endcsname
+          ##1{\PolNthCoeff{#1}{0}}%
+      % No hooks here!
+      \expandafter\edef\csname XINT_flexpr_func_#1\endcsname ##1##2##3%
+          {##1##2{{\PolNthCoeff{#1}{0}}}}%
+   \else
+      % polynomial of degree at least 1. This means that mechanism
+      % to get \POL at result will get activated and we must be very careful
+      % to never \edef when the Horner macro will be converted to
+      % a polynomial
+      \POL at newfloatpolhorner{#1}%
+      \POL at defpolfunc{#1}{flexpr}%
+   \fi
    \ifxintverbose\POL at floatinfo{#1}\fi
 }%
 \def\POL at info #1{%
    \xintMessage {polexpr}{Info}%
         {Function #1 for the \string\xintexpr\space parser is
-         associated to \string\XINT_expr_userfunc_#1\space
+         associated to \string\XINT_expr_polfunc_#1\space
          whose meaning uses Horner scheme:
          \expandafter\meaning
-         \csname XINT_expr_userfunc_#1\endcsname}%
+         \csname XINT_expr_polfunc_#1\endcsname}%
 }%
 \def\POL at floatinfo #1{%
    \xintMessage {polexpr}{Info}%
         {Function #1 for the \string\xintfloatexpr\space parser is
-         associated to \string\XINT_flexpr_userfunc_#1\space
+         associated to \string\XINT_flexpr_polfunc_#1\space
          whose meaning uses Horner scheme:
          \expandafter\meaning
-         \csname XINT_flexpr_userfunc_#1\endcsname}%
+         \csname XINT_flexpr_polfunc_#1\endcsname}%
 }%
 %
 \def\POL at newpolhorner#1{%
@@ -162,7 +340,7 @@
       \expandafter\POL at newpol@horner\POL at var@coeffs\relax
    \expandafter
    \endgroup
-   \expandafter\def\csname XINT_expr_userfunc_#1\expandafter\endcsname
+   \expandafter\def\csname XINT_expr_polfunc_#1\expandafter\endcsname
       \expandafter##\expandafter1\expandafter{\POL at tmp{##1}}%
 }%
 \def\POL at newfloatpolhorner#1{%
@@ -176,7 +354,7 @@
       \expandafter\POL at newpol@floathorner\POL at var@coeffs\relax
    \expandafter
    \endgroup
-   \expandafter\def\csname XINT_flexpr_userfunc_#1\expandafter\endcsname
+   \expandafter\def\csname XINT_flexpr_polfunc_#1\expandafter\endcsname
       \expandafter##\expandafter1\expandafter{\POL at tmp{##1}}%
 }%
 \def\POL at newpol@horner#1{\let\xintAdd\relax\let\xintMul\relax
@@ -211,10 +389,9 @@
 \def\POL at let#1#2{%
     \expandafter\let\csname POLuserpol@#1\expandafter\endcsname
                     \csname POLuserpol@#2\endcsname
-    \expandafter\let\csname XINT_expr_userfunc_#1\expandafter\endcsname
-                    \csname XINT_expr_userfunc_#2\endcsname
-    \expandafter\XINT_expr_defuserfunc
-       \csname XINT_expr_func_#1\endcsname{#1}{expr}%
+    \expandafter\let\csname XINT_expr_polfunc_#1\expandafter\endcsname
+                    \csname XINT_expr_polfunc_#2\endcsname
+    \POL at defpolfunc{#1}{expr}%
     \ifxintverbose\POL at info{#1}\fi
 }%
 \newcommand\PolGlobalLet[2]{\begingroup
@@ -259,7 +436,7 @@
 \def\POL at getfromarray#1#2{%
         \count@=#2{0} %<- intentional space
   \ifnum\count@=\z@
-     \def\POL at result{-1.\empty{0/1[0]}}% 0.5 fix for empty array
+     \protected\def\POL at result{-1.\POL at empty{0/1[0]}}% 0.5 fix for empty array
   \else
         \xintloop
           \edef\POL at tmp{#2{\count@}}%
@@ -283,7 +460,7 @@
         \repeat
         \count@\count\tw@          
         \def\POL at tmp##1.{{\csname POL at tmparray##1\endcsname}}%
-        \edef\POL at result{\the\numexpr\count at -\@ne.\noexpand\empty
+        \protected\edef\POL at result{\the\numexpr\count at -\@ne.\POL at empty
                          \xintiloop[1+1]%
                          \expandafter\POL at tmp\xintiloopindex.%
                          \ifnum\xintiloopindex<\count@
@@ -480,7 +657,7 @@
         {\ifnum\POL at degB<\z@
           \expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo
         \fi
-          {\def\POL at result{-1.\empty{0/1[0]}}}%
+          {\protected\def\POL at result{-1.\POL at empty{0/1[0]}}}%
           {\xintAssignArray\POL at polB\to\POL at arrayB
            \POL at normalize{B}%
            \POL at gcd@exit BA}}%
@@ -606,11 +783,11 @@
    \expandafter\expandafter\expandafter\POL at split
       \csname POLuserpol@#1\endcsname;\POL at var@deg\POL at var@coeffs
    \ifnum\POL at var@deg<\@ne
-      \@namedef{POLuserpol@#2}{-1.\empty{0/1[0]}}%
+      \@namedef{POLuserpol@#2}{-1.\POL at empty{0/1[0]}}%
    \else
      \edef\POL at var@coeffs{\expandafter\POL at diff\POL at var@coeffs\relax}%
      \expandafter\edef\csname POLuserpol@#2\endcsname
-        {\the\numexpr\POL at var@deg-\@ne.\noexpand\empty\POL at var@coeffs}%
+        {\the\numexpr\POL at var@deg-\@ne.\POL at empty\POL at var@coeffs}%
    \fi
 }%
 % lazy way but allows to share with AntiDiff
@@ -666,11 +843,11 @@
    \expandafter\expandafter\expandafter\POL at split
       \csname POLuserpol@#1\endcsname;\POL at var@deg\POL at var@coeffs
    \ifnum\POL at var@deg<\z@
-      \@namedef{POLuserpol@#2}{-1.\empty{0/1[0]}}%
+      \@namedef{POLuserpol@#2}{-1.\POL at empty{0/1[0]}}%
    \else
      \edef\POL at var@coeffs{\expandafter\POL at antidiff\POL at var@coeffs\relax}%
      \expandafter\edef\csname POLuserpol@#2\endcsname
-         {\the\numexpr\POL at var@deg+\@ne.\noexpand\empty{0/1[0]}\POL at var@coeffs}%
+         {\the\numexpr\POL at var@deg+\@ne.\POL at empty{0/1[0]}\POL at var@coeffs}%
    \fi
 }%
 
@@ -737,7 +914,7 @@
      \POL at count\z@
      % if I applied the same as for positive degree, I should make it -1
      % if constant is negative. I also don't worry if polynomial is zero.
-     \@namedef{POLuserpol@\POL at sturmname _0}{0.\empty{1/1[0]}}%
+     \@namedef{POLuserpol@\POL at sturmname _0}{0.\POL at empty{1/1[0]}}%
   \else
      \ifPOL at tosturm@makefirstprimitive\POL at makeprimitive{\POL at sturmname _0_}\fi
      \POL at tosturm@dosturm
@@ -793,7 +970,7 @@
       \POL at mapcoeffs\POL at aux@toint{\POL at sturmname _\the\POL at count}%    
     \ifnum\POL at count>\z@
     \repeat
-    \@namedef{POLuserpol@\POL at sturmname _\POL at sturm@N}{0.\empty{1/1[0]}}%
+    \@namedef{POLuserpol@\POL at sturmname _\POL at sturm@N}{0.\POL at empty{1/1[0]}}%
   \else % they are already normalized
     \advance\POL at count\@ne % attention to include last one also
     \xintloop
@@ -984,7 +1161,7 @@
     \POL at findrat@xN\POL at findrat@xD\POl at _
   % we can't move this to updatequotients because other branch will
   % need to do the division first anyhow
-  \edef\POLuserpol at _findrat@oneterm{1.\noexpand\empty
+  \edef\POLuserpol at _findrat@oneterm{1.\POL at empty
         {\xintiiOpp\POL at findrat@xN/1[0]}{\POL at findrat@xD/1[0]}}%
   \POL at divide{\POL at sturmname\POL at sqfnorr}{_findrat at oneterm}% the one without mult.
   %\expandafter\POL at split\POL at R;\POL at degR\POL at polR
@@ -1118,7 +1295,7 @@
   % zero should never occur here
   \POL at findrat@ifnegative{\edef\POL at findrat@x{-\POL at findrat@x}}{}%
   \POL at xintfrac@getNDE\POL at findrat@x\POL at findrat@xN\POL at findrat@xD\POL at _
-  \edef\POLuserpol at _findrat@oneterm{1.\noexpand\empty
+  \edef\POLuserpol at _findrat@oneterm{1.\POL at empty
       {\xintiiOpp{\POL at findrat@xN}/1[0]}{\POL at findrat@xD/1[0]}}%
   \POL at divide{\POL at sturmname\POL at sqfnorr}{_findrat at oneterm}% the one without mult.
   \expandafter\POL at split\POL at R;\POL at degR\POL at polR
@@ -1185,7 +1362,7 @@
   % safer to do the edef as \POL at findrat@x used later in storeit
   \edef\POL at findrat@x{\xintIrr{\xintDiv\POL at findrat@Num\POL at findrat@D}[0]}%
   \POL at xintfrac@getNDE\POL at findrat@x\POL at findrat@xN\POL at findrat@xD\POL at _
-  \edef\POLuserpol at _findrat@oneterm{1.\noexpand\empty
+  \edef\POLuserpol at _findrat@oneterm{1.\POL at empty
       {\xintiiOpp{\POL at findrat@xN}/1[0]}{\POL at findrat@xD/1[0]}}%
   \POL at divide{\POL at sturmname\POL at sqfnorr}{_findrat at oneterm}% the one without mult.
   \expandafter\POL at split\POL at R;\POL at degR\POL at polR
@@ -1210,11 +1387,11 @@
   \begingroup\xintglobaldefstrue
     % skip some overhead of \xintdefvar...
     \XINT_expr_defvar_one{\POL at sturmname L_\POL at findrat@index}%
-       {\csname .=\POL at findrat@x\endcsname}%
+       {\POL at findrat@x}%
     \XINT_expr_defvar_one{\POL at sturmname R_\POL at findrat@index}%
-       {\csname .=\POL at findrat@x\endcsname}%
+       {\POL at findrat@x}%
     \XINT_expr_defvar_one{\POL at sturmname Z_\POL at findrat@index _isknown}%
-       {\csname .=1\endcsname}%
+       {1}%
   \endgroup
 }%
 \def\POL at findrat@loop at updatequotients{%
@@ -1326,7 +1503,7 @@
     \xintloop
     % skip some overhead of \xintdefvar...
       \XINT_expr_defvar_one{\POL at sturmname M_\x}%
-         {\csname .=\csname POL_ZM\POL at sturmname*\x\endcsname\endcsname}%
+         {\csname POL_ZM\POL at sturmname*\x\endcsname}%
     \edef\x{\the\numexpr\x-\@ne}%
     \ifnum\x>\z@
     \repeat
@@ -1901,17 +2078,16 @@
     \begingroup\xintglobaldefstrue
     % skip some overhead of \xintdefvar...
       \XINT_expr_defvar_one{\POL at sturmname L_\POL at isolz@IntervalIndex}%
-         {\csname .=\POL at IsoLeft@rawout\endcsname}%
+         {\POL at IsoLeft@rawout}%
       \XINT_expr_defvar_one{\POL at sturmname R_\POL at isolz@IntervalIndex}%
-         {\csname .=\POL at IsoRight@rawout\endcsname}%
+         {\POL at IsoRight@rawout}%
       % added at 0.7
       \XINT_expr_defvar_one{\POL at sturmname Z_\POL at isolz@IntervalIndex _isknown}%
-         {\csname .=\ifnum\POL at IsoRightSign=\z@ 1\else 0\fi\endcsname}%
+         {\ifnum\POL at IsoRightSign=\z@ 1\else 0\fi}%
     \endgroup
 }%
 %% \PolRefineInterval
-\def\POL at xintexprGetVar#1{\expandafter\expandafter\expandafter
-    \XINT_expr_unlock\csname XINT_expr_var_#1\endcsname}%
+\def\POL at xintexprGetVar#1{\csname XINT_expr_varvalue_#1\endcsname}%
 % attention, also used by \POL at findrat@loop at a
 \def\POL at get@IsoLeft at rawin{%
     \edef\POL at IsoLeft@rawin
@@ -2277,10 +2453,14 @@
 %% The idea is to execute it with another meaning given to \xintAdd etc..,
 %% so that it operates on "polynomials". This is a mixture of expandable
 %% and non-expandable techniques.
+%%
+%% And it was complicated to let it work with xintexpr 1.4
+%%
 \def\POL at get#1#2#3{%
-    \global\POL at polfalse
+    \relax %!! part de la tambouille pour fonctionner en xint 1.4
+    \POL at polglobalfalse
     \begingroup
-        \def\POL at result{#3}%
+        \protected\def\POL at result{#3}%
         #3%
         \expandafter
     \endgroup
@@ -2287,18 +2467,56 @@
     \expandafter\def\expandafter#1\expandafter{\POL at result}%
     \unless\ifPOL at pol
         % avoid expanding more than twice #3
+        % #3 must be purely numerical or at least compatible with \edef
+        % this is why at 0.7.5 I had to handle especially constant
+        % polynomial functions to remove any protection from them
+        % (because the protection triggers the COMPOSITION when
+        %  the polynomial is found as argument of another one and
+        %  this is not expandable) 
         \edef#1{#3}%
         \xintiiifZero{#1}%
-            {\def#1{-1.\empty{0/1[0]}}}%
-            {\edef#1{0.\noexpand\empty{#1}}}%
+            {\def#1{-1.\POL at empty{0/1[0]}}}%
+            {\edef#1{0.\POL at empty{#1}}}%
     \fi
     #2%
 }%
+
+%% COMPOSITION
+%% This did not exist before 0.7.5 and is part of its adaptation to xint 1.4
+%% We thus took up this opportunity to speed up substantially composition.
+%% Very serious difficulties with constant polynomials. Had to handle them
+%% especially.
+%% OK, that was really tough, but advantage now is that composition
+%% at 0.7.5 should be more efficient than before. However when polynomials
+%% become big via composition, coefficients also are big and the time
+%% taken by arithmetic dominates.  No time to test really, though, relieved
+%% I can release xint 1.4 at last.  My basic polexpr test suite passes,
+%% but it goes back already to old releases.
+\protected\def\POL at applypolfunc#1#2%
+{%
+% This #2 may be also invoing \POL at applypolfunc...
+   \POL at get\POL at A\POL at applypolfunc@b#2#1%
+}%
+\def\POL at applypolfunc@b #1%
+{%
+% and now the have our Horner scheme nested macro
+% which hopefully will do its job with \POL at add, \POL at mul etc...
+    \POL at polglobalfalse
+    \expandafter#1\expanded
+    {{\POL at polglobaltrue\protected\def\noexpand\POL at result{\POL at A}}}%
+    \unless\ifPOL at pol
+        \odef\POL at result{#1{0}}%
+        \xintiiifZero{\POL at result}%
+            {\protected\def\POL at result{-1.\POL at empty{0/1[0]}}}%
+            {\protected\edef\POL at result{0.\POL at empty{\POL at result}}}%
+    \fi
+}%
+
 %% ADDITION
 \def\POL at add  {\POL at get\POL at A\POL at add@b}%
 \def\POL at add@b{\POL at get\POL at B\POL at add@c}%
 \def\POL at add@c{%
-    \global\POL at poltrue
+    \POL at polglobaltrue
     \POL at ifZero\POL at A
         {\let\POL at result\POL at B}%
         {\POL at ifZero\POL at B
@@ -2341,11 +2559,11 @@
 \def\POL at mul  {\POL at get\POL at A\POL at mul@b}%
 \def\POL at mul@b{\POL at get\POL at B\POL at mul@c}%
 \def\POL at mul@c{%
-    \global\POL at poltrue
+    \POL at polglobaltrue
     \POL at ifZero\POL at A
-        {\def\POL at result{-1.\empty{0/1[0]}}}%
+        {\protected\def\POL at result{-1.\POL at empty{0/1[0]}}}%
         {\POL at ifZero\POL at B
-             {\def\POL at result{-1.\empty{0/1[0]}}}%
+             {\protected\def\POL at result{-1.\POL at empty{0/1[0]}}}%
              {\POL@@mul}}%
 }%
 \def\POL@@mul{%
@@ -2436,9 +2654,9 @@
 
 %% POWERS (SCALAR EXPONENT...)
 \def\POL at pow #1#2{%
-    \global\POL at polfalse
+    \POL at polglobalfalse
     \begingroup
-        \def\POL at result{#1}%
+        \protected\def\POL at result{#1}%
         #1%
         \expandafter
     \endgroup
@@ -2446,12 +2664,12 @@
     \unless\ifPOL at pol
         \edef\POL at A{\xintScalarPow{#1}{#2}}% no error check
         \xintiiifZero{\POL at A}%
-            {\def\POL at result{-1.\empty{0/1[0]}}}%
-            {\edef\POL at result{0.\noexpand\empty{\POL at A}}}%
+            {\protected\def\POL at result{-1.\POL at empty{0/1[0]}}}%
+            {\protected\edef\POL at result{0.\POL at empty{\POL at A}}}%
     \else
       \edef\POL at B{\numexpr\xintNum{#2}\relax}% no check on exponent >= 0
       \ifcase\POL at B
-        \def\POL at result{0.\empty{1/1[0]}}%
+        \protected\def\POL at result{0.\POL at empty{1/1[0]}}%
       \or
         \let\POL at result\POL at A
       \else
@@ -2458,18 +2676,18 @@
         \POL@@pow at check
       \fi
     \fi
-    \global\POL at poltrue
+    \POL at polglobaltrue
 }%
 \def\POL@@pow at check {%
 % no problem here with leftover tokens!
 % should I have used that I-don't-care technique more elsewhere?
     \ifnum\@ne>\POL at A
-    % polynomial is a constant, must get rid of dot and \empty
+    % polynomial is a constant, must get rid of dot and \empty (\POL at empty)
         \edef\POL at A{\expandafter\xintScalarPow\romannumeral`^^@%
                     \expandafter\xint_gob_til_dot\POL at A{\POL at B}}%
         \xintiiifZero{\POL at A}%
-            {\def\POL at result{-1.\empty{0/1[0]}}}%
-            {\edef\POL at result{0.\noexpand\empty{\POL at A}}}%
+            {\protected\def\POL at result{-1.\POL at empty{0/1[0]}}}%
+            {\protected\edef\POL at result{0.\POL at empty{\POL at A}}}%
     \else
     \ifnum\@ne=\POL at A
     % perhaps a constant times X, check constant term
@@ -2476,9 +2694,9 @@
         \xintiiifZero
         {\expandafter\xint_firstoftwo\romannumeral`^^@%
          \expandafter\xint_gob_til_dot\POL at A}
-        {\edef\POL at result
+        {\protected\edef\POL at result
           {\the\POL at B.% here at least 2.
-           \noexpand\empty
+           \POL at empty
            \romannumeral\xintreplicate{\POL at B}{{0/1[0]}}%
            {\xintScalarPow
              {\expandafter\xint_secondoftwo\romannumeral`^^@%
@@ -2531,8 +2749,8 @@
        {#2}%
     \expandafter\POL at mul\expandafter
         {\expandafter\def\expandafter\POL at result\expandafter
-         {\POL at result}\global\POL at poltrue}%
-        {\def\POL at result{#1}\global\POL at poltrue}%
+         {\POL at result}\POL at polglobaltrue}%
+        {\protected\def\POL at result{#1}\POL at polglobaltrue}%
 }%
 
 %% DIVISION
@@ -2540,7 +2758,7 @@
 \def\POL at div  {\POL at get\POL at A\POL at div@b}%
 \def\POL at div@b{\POL at get\POL at B\POL at div@c}%
 \def\POL at div@c{%
-    \global\POL at poltrue
+    \POL at polglobaltrue
     \expandafter\POL at split\POL at A;\POL at degA\POL at polA
     \expandafter\POL at split\POL at B;\POL at degB\POL at polB
     \ifnum\POL at degA<\POL at degB\space
@@ -2599,9 +2817,9 @@
 
 %% MINUS SIGN AS UNARY OPERATOR
 \def\POL at opp #1{%
-    \global\POL at polfalse
+    \POL at polglobalfalse
     \begingroup
-        \def\POL at result{#1}%
+        \protected\def\POL at result{#1}%
         #1%
         \expandafter
     \endgroup
@@ -2609,13 +2827,13 @@
     \unless\ifPOL at pol
         \edef\POL at A{\xintScalarOpp{#1}}%
         \xintiiifZero{\POL at A}%
-            {\def\POL at result{-1.\empty{0/1[0]}}}%
-            {\edef\POL at result{0.\noexpand\empty{\POL at A}}}%
+            {\protected\def\POL at result{-1.\POL at empty{0/1[0]}}}%
+            {\protected\edef\POL at result{0.\POL at empty{\POL at A}}}%
     \else
-      \edef\POL at B{0.\noexpand\empty{-1/1[0]}}%
+      \edef\POL at B{0.\POL at empty{-1/1[0]}}%
       \POL@@mul
     \fi
-    \global\POL at poltrue
+    \POL at polglobaltrue
 }%
 
 
@@ -2626,9 +2844,9 @@
      \At\PolEvalAtExpr\krof {#1}{#3}%
 }%
 \newcommand\PolEvalAt[2]
-    {\xintpraw{\csname XINT_expr_userfunc_#1\endcsname{#2}}}%
+    {\xintpraw{\csname XINT_expr_polfunc_#1\endcsname{#2}}}%
 \newcommand\POL at eval[2]
-    {\csname XINT_expr_userfunc_#1\endcsname{#2}}%
+    {\csname XINT_expr_polfunc_#1\endcsname{#2}}%
 \newcommand\PolEvalAtExpr[2]{\xinttheexpr #1(#2)\relax}%
 %
 \newcommand\PolEvalReduced[3]{\romannumeral`^^@\POL at eval@fork
@@ -2637,11 +2855,11 @@
 }%
 \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_polfunc_#1\endcsname{#2}}[0]}%
 }%
 \newcommand\PolEvalReducedAtExpr[2]{%
     \xintpraw
-    {\xintIrr{\romannumeral`^^@\xintthebareeval#1(#2)\relax}[0]}%
+    {\expandafter\xintIrr\romannumeral`^^@\xintthebareeval#1(#2)\relax[0]}%
 }%
 %
 \newcommand\PolFloatEval[3]{\romannumeral`^^@\POL at eval@fork
@@ -2649,7 +2867,7 @@
      \At\PolFloatEvalAtExpr\krof {#1}{#3}%
 }%
 \newcommand\PolFloatEvalAt[2]
-    {\xintpfloat{\csname XINT_flexpr_userfunc_#1\endcsname{#2}}}%
+    {\xintpfloat{\csname XINT_flexpr_polfunc_#1\endcsname{#2}}}%
 \newcommand\PolFloatEvalAtExpr[2]{\xintthefloatexpr #1(#2)\relax}%
 
 
@@ -2898,12 +3116,12 @@
        \expandafter#1%
     \fi {#3}#2}%
 %
-\def\POL at toexprA #1#2\empty#3{%
+\def\POL at toexprA #1#2\POL at empty#3{%
     \ifpoltoexprall\expandafter\POL at toexprall@b
               \else\expandafter\POL at toexpr@b
     \fi {#3}#2{0}1.%
 }%
-\def\POL at toexprD #1#2#3\relax{% #3 has \empty to prevent brace removal
+\def\POL at toexprD #1#2#3\relax{% #3 has \empty (\POL at empty) to prevent brace removal
     \expandafter\POL at toexprD@a\expandafter#2%
     \the\numexpr #1\expandafter.\romannumeral0\xintrevwithbraces{#3}\relax
 }%



More information about the tex-live-commits mailing list.