summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/xint/xintfrac.sty
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2021-04-04 02:31:47 +0000
committerNorbert Preining <preining@logic.at>2021-04-04 02:31:47 +0000
commitd1301f3e47b2340fd9ffbb7d1a0a4b361540e22e (patch)
tree4a851156d9d547008865e20d69b78626178c5828 /Master/texmf-dist/tex/generic/xint/xintfrac.sty
parent6aa284727262f1c7ac0ec6c67becc28d5a678a8c (diff)
xint (4apr21)
git-svn-id: svn://tug.org/texlive/trunk@58738 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xintfrac.sty')
-rw-r--r--Master/texmf-dist/tex/generic/xint/xintfrac.sty156
1 files changed, 111 insertions, 45 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintfrac.sty b/Master/texmf-dist/tex/generic/xint/xintfrac.sty
index 62c5d924cd9..a10aa57392a 100644
--- a/Master/texmf-dist/tex/generic/xint/xintfrac.sty
+++ b/Master/texmf-dist/tex/generic/xint/xintfrac.sty
@@ -21,8 +21,8 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.4c 2021/02/20
-%% Copyright (C) 2013-2020 by Jean-Francois Burnol
+%% The xint bundle 1.4d 2021/03/29
+%% Copyright (C) 2013-2021 by Jean-Francois Burnol
%% xintfrac: Expandable operations on fractions
%% ---------------------------------------------------------------
\begingroup\catcode61\catcode48\catcode32=10\relax%
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xintfrac}%
- [2021/02/20 v1.4c Expandable operations on fractions (JFB)]%
+ [2021/03/29 v1.4d Expandable operations on fractions (JFB)]%
\def\XINT_cntSgnFork #1%
{%
\ifcase #1\expandafter\xint_secondofthree
@@ -1955,81 +1955,147 @@
\def\xintSgn {\romannumeral0\xintsgn }%
\def\xintsgn #1{\expandafter\XINT_sgn\romannumeral0\xintraw {#1}\xint:}%
\def\xintGCD {\romannumeral0\xintgcd}%
-\def\xintgcd #1#2{\XINT_fgcdof{#1}{#2}^}%
-\def\xintLCM {\romannumeral0\xintlcm}%
-\def\xintlcm #1#2{\XINT_flcmof{#1}{#2}^}%
+\def\xintgcd #1%
+{%
+ \expandafter\XINT_fgcd_in
+ \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:
+}%
+\def\XINT_fgcd_in #1#2\xint:#3%
+{%
+ \expandafter\XINT_fgcd_out
+ \romannumeral0\expandafter\XINT_fgcd_chkzeros\expandafter#1%
+ \romannumeral0\xintrez{\xintPIrr{\xintAbs{#3}}}\xint:#1#2\xint:
+}%
+\def\XINT_fgcd_out#1[#2]{\xintirr{#1[#2]}[0]}%
+\def\XINT_fgcd_chkzeros #1#2%
+{%
+ \xint_UDzerofork
+ #1\XINT_fgcd_aiszero
+ #2\XINT_fgcd_biszero
+ 0\XINT_fgcd_main
+ \krof #2%
+}%
+\def\XINT_fgcd_aiszero #1\xint:#2\xint:{ #1}%
+\def\XINT_fgcd_biszero #1\xint:#2\xint:{ #2}%
+\def\XINT_fgcd_main #1/#2[#3]\xint:#4/#5[#6]\xint:
+{%
+ \expandafter\XINT_fgcd_a
+ \romannumeral0\XINT_gcd_loop #2\xint:#5\xint:\xint:
+ #2\xint:#5\xint:#1\xint:#4\xint:#3.#6.%
+}%
+\def\XINT_fgcd_a #1\xint:#2\xint:
+{%
+ \expandafter\XINT_fgcd_b
+ \romannumeral0\xintiiquo{#2}{#1}\xint:#1\xint:#2\xint:
+}%
+\def\XINT_fgcd_b #1\xint:#2\xint:#3\xint:#4\xint:#5\xint:#6\xint:#7.#8.%
+{%
+ \expanded{%
+ \xintiigcd{\xintiiE{\xintiiMul{#5}{\xintiiQuo{#4}{#2}}}{#7-#8}}%
+ {\xintiiE{\xintiiMul{#6}{#1}}{#8-#7}}%
+ /\xintiiMul{#1}{#4}%
+ [\ifnum#7>#8 #8\else #7\fi]%
+ }%
+}%
\def\xintGCDof {\romannumeral0\xintgcdof}%
\def\xintgcdof #1{\expandafter\XINT_fgcdof\romannumeral`&&@#1^}%
\def\XINT_GCDof{\romannumeral0\XINT_fgcdof}%
\def\XINT_fgcdof #1%
{%
- \xint_gob_til_^ #1\XINT_fgcdof_empty ^%
- \expandafter\XINT_fgcdof_loop\romannumeral0\xintiiabs#1\xint:
+ \expandafter\XINT_fgcdof_chkempty\romannumeral`&&@#1\xint:
+}%
+\def\XINT_fgcdof_chkempty #1%
+{%
+ \xint_gob_til_^#1\XINT_fgcdof_empty ^\XINT_fgcdof_in #1%
+}%
+\def\XINT_fgcdof_empty #1\xint:{ 1/1[0]}% hesitation, should it be infinity? O?
+\def\XINT_fgcdof_in #1\xint:
+{%
+ \expandafter\XINT_fgcd_out
+ \romannumeral0\expandafter\XINT_fgcdof_loop
+ \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:
}%
-\def\XINT_fgcdof_empty ^#1\xint:{ 1/1[0]}%
\def\XINT_fgcdof_loop #1\xint:#2%
{%
- \expandafter\XINT_fgcdof_loop_a\romannumeral0\xintiiabs#2\xint:#1\xint:
+ \expandafter\XINT_fgcdof_chkend\romannumeral`&&@#2\xint:#1\xint:\xint:
+}%
+\def\XINT_fgcdof_chkend #1%
+{%
+ \xint_gob_til_^#1\XINT_fgcdof_end ^\XINT_fgcdof_loop_pair #1%
+}%
+\def\XINT_fgcdof_end #1\xint:#2\xint:\xint:{ #2}%
+\def\XINT_fgcdof_loop_pair #1\xint:#2%
+{%
+ \expandafter\XINT_fgcdof_loop
+ \romannumeral0\expandafter\XINT_fgcd_chkzeros\expandafter#2%
+ \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:#2%
}%
-\def\XINT_fgcdof_loop_a#1#2\xint:#3\xint:
+\def\xintLCM {\romannumeral0\xintlcm}%
+\def\xintlcm #1%
{%
- \xint_gob_til_^ #1\XINT_fgcdof_end ^%
- \xint_gob_til_zero #1\XINT_fgcdof_skip 0%
- \expandafter\XINT_fgcdof_loop_b\romannumeral0\xintmod{#1#2}{#3}\xint:#3\xint:
+ \expandafter\XINT_flcm_in
+ \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:
}%
-\def\XINT_fgcdof_end ^#1\xint:#2\xint:{ #2}%
-\def\XINT_fgcdof_skip 0%
- \expandafter\XINT_fgcdof_loop_b\romannumeral0\xintmod#1\xint:
+\def\XINT_flcm_in #1#2\xint:#3%
{%
- \XINT_fgcdof_loop
+ \expandafter\XINT_fgcd_out
+ \romannumeral0\expandafter\XINT_flcm_chkzeros\expandafter#1%
+ \romannumeral0\xintrez{\xintPIrr{\xintAbs{#3}}}\xint:#1#2\xint:
}%
-\def\XINT_fgcdof_loop_b#1#2\xint:#3\xint:
+\def\XINT_flcm_chkzeros #1#2%
{%
- \xint_gob_til_zero #1\XINT_fgcdof_next 0%
- \expandafter\XINT_fgcdof_loop_b\romannumeral0\xintmod{#3}{#1#2}\xint:#1#2\xint:
+ \xint_UDzerofork
+ #1\XINT_flcm_zero
+ #2\XINT_flcm_zero
+ 0\XINT_flcm_main
+ \krof #2%
}%
-\def\XINT_fgcdof_next 0%
- \expandafter\XINT_fgcdof_loop_b\romannumeral0\xintmod#1#2\xint:#3\xint:#4%
+\def\XINT_flcm_zero #1\xint:#2\xint:{ 0/1[0]}%
+\def\XINT_flcm_main #1/#2[#3]\xint:#4/#5[#6]\xint:
{%
- \expandafter\XINT_fgcdof_loop_a\romannumeral0\xintiiabs#4\xint:#1\xint:
+ \xintinv
+ {%
+ \romannumeral0\XINT_fgcd_main #2/#1[-#3]\xint:#5/#4[-#6]\xint:
+ }%
}%
\def\xintLCMof {\romannumeral0\xintlcmof}%
\def\xintlcmof #1{\expandafter\XINT_flcmof\romannumeral`&&@#1^}%
\def\XINT_LCMof{\romannumeral0\XINT_flcmof}%
\def\XINT_flcmof #1%
{%
- \xint_gob_til_^ #1\XINT_flcmof_empty ^%
- \expandafter\XINT_flcmof_loop\romannumeral0\xintiiabs\xintRaw{#1}\xint:
+ \expandafter\XINT_flcmof_chkempty\romannumeral`&&@#1\xint:
+}%
+\def\XINT_flcmof_chkempty #1%
+{%
+ \xint_gob_til_^#1\XINT_flcmof_empty ^\XINT_flcmof_in #1%
}%
-\def\XINT_flcmof_empty ^#1\xint:{ 0/1[0]}%
-\def\XINT_flcmof_loop #1%
+\def\XINT_flcmof_empty #1\xint:{ 0/1[0]}% hesitation
+\def\XINT_flcmof_in #1\xint:
{%
- \xint_gob_til_zero #1\XINT_flcmof_zero 0%
- \expandafter\XINT_flcmof_d\romannumeral0\XINT_inv #1%
+ \expandafter\XINT_fgcd_out
+ \romannumeral0\expandafter\XINT_flcmof_loop
+ \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:
}%
-\def\XINT_flcmof_zero #1^{ 0/1[0]}%
-\def\XINT_flcmof_d #1\xint:#2%
+\def\XINT_flcmof_loop #1\xint:#2%
{%
- \expandafter\XINT_flcmof_loop_a\romannumeral0\xintiiabs#2\xint:#1\xint:
+ \expandafter\XINT_flcmof_chkend\romannumeral`&&@#2\xint:#1\xint:\xint:
}%
-\def\XINT_flcmof_loop_a #1#2\xint:%
+\def\XINT_flcmof_chkend #1%
{%
- \xint_gob_til_^ #1\XINT_flcmof_end ^%
- \xint_gob_til_zero #1\XINT_flcmof_zero 0%
- \expandafter\XINT_flcmof_loop_b\romannumeral0\expandafter\XINT_inv
- \romannumeral0\xintraw{#1#2}\xint:
+ \xint_gob_til_^#1\XINT_flcmof_end ^\XINT_flcmof_loop_pair #1%
}%
-\def\XINT_flcmof_end ^#1\xint:#2\xint:{\XINT_inv #2}%
-\def\XINT_flcmof_loop_b #1#2\xint:#3\xint:
+\def\XINT_flcmof_end #1\xint:#2\xint:\xint:{ #2}%
+\def\XINT_flcmof_loop_pair #1\xint:#2%
{%
- \xint_gob_til_zero #1\XINT_flcmof_next 0%
- \expandafter\XINT_flcmof_loop_b\romannumeral0\xintmod{#3}{#1#2}\xint:#1#2\xint:
+ \expandafter\XINT_flcmof_chkzero
+ \romannumeral0\expandafter\XINT_flcm_chkzeros\expandafter#2%
+ \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:#2%
}%
-\def\XINT_flcmof_next 0%
- \expandafter\XINT_flcmof_loop_b\romannumeral0\xintmod#1#2\xint:#3\xint:#4%
+\def\XINT_flcmof_chkzero #1%
{%
- \expandafter\XINT_flcmof_loop_a\romannumeral0\xintiiabs#4\xint:#1\xint:
+ \xint_gob_til_zero#1\XINT_flcmof_zero0\XINT_flcmof_loop#1%
}%
+\def\XINT_flcmof_zero#1^{ 0/1[0]}%
\mathchardef\XINTdigits 16
\def\xintDigits #1=%
{\afterassignment \xint_gobble_i \mathchardef\XINTdigits=}%