diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xintgcd.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintgcd.sty | 165 |
1 files changed, 87 insertions, 78 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintgcd.sty b/Master/texmf-dist/tex/generic/xint/xintgcd.sty index 981520a4909..cc32e455e57 100644 --- a/Master/texmf-dist/tex/generic/xint/xintgcd.sty +++ b/Master/texmf-dist/tex/generic/xint/xintgcd.sty @@ -21,7 +21,7 @@ %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) %% --------------------------------------------------------------- -%% The xint bundle 1.2o 2017/08/29 +%% The xint bundle 1.2p 2017/12/05 %% Copyright (C) 2013-2017 by Jean-Francois Burnol %% xintgcd: Euclidean algorithm with xint package %% --------------------------------------------------------------- @@ -70,24 +70,17 @@ \XINTsetupcatcodes% defined in xintkernel.sty \XINT_providespackage \ProvidesPackage{xintgcd}% - [2017/08/29 1.2o Euclide algorithm with xint package (JFB)]% + [2017/12/05 1.2p Euclide algorithm with xint package (JFB)]% \def\xintGCD {\romannumeral0\xintgcd }% -\def\xintgcd #1% -{% - \expandafter\XINT_gcd\expandafter{\romannumeral0\xintiabs {#1}}% -}% -\def\XINT_gcd #1#2% -{% - \expandafter\XINT_gcd_fork\romannumeral0\xintiabs {#2}\Z #1\Z -}% +\def\xintgcd #1#2{\xintiigcd {\xintNum{#1}}{\xintNum{#2}}}% \def\xintiiGCD {\romannumeral0\xintiigcd }% \def\xintiigcd #1% {% - \expandafter\XINT_iigcd\expandafter{\romannumeral0\xintiiabs {#1}}% + \expandafter\XINT_iigcd\expandafter{\romannumeral0\xintiiabs{#1}}% }% \def\XINT_iigcd #1#2% {% - \expandafter\XINT_gcd_fork\romannumeral0\xintiiabs {#2}\Z #1\Z + \expandafter\XINT_gcd_fork\romannumeral0\xintiiabs{#2}\Z #1\Z }% \def\XINT_gcd_fork #1#2\Z #3#4\Z {% @@ -114,22 +107,15 @@ {#1}% }% \def\xintLCM {\romannumeral0\xintlcm}% -\def\xintlcm #1% -{% - \expandafter\XINT_lcm\expandafter{\romannumeral0\xintiabs {#1}}% -}% -\def\XINT_lcm #1#2% -{% - \expandafter\XINT_lcm_fork\romannumeral0\xintiabs {#2}\Z #1\Z -}% +\def\xintlcm #1#2{\xintiilcm{\xintNum{#1}}{\xintNum{#2}}}% \def\xintiiLCM {\romannumeral0\xintiilcm}% \def\xintiilcm #1% {% - \expandafter\XINT_iilcm\expandafter{\romannumeral0\xintiiabs {#1}}% + \expandafter\XINT_iilcm\expandafter{\romannumeral0\xintiiabs{#1}}% }% \def\XINT_iilcm #1#2% {% - \expandafter\XINT_lcm_fork\romannumeral0\xintiiabs {#2}\Z #1\Z + \expandafter\XINT_lcm_fork\romannumeral0\xintiiabs{#2}\Z #1\Z }% \def\XINT_lcm_fork #1#2\Z #3#4\Z {% @@ -166,113 +152,135 @@ #3-\XINT_bezout_plusminus % A < 0, B > 0 --\XINT_bezout_plusplus % A > 0, B > 0 \krof - {#2}{#4}#1#3{#3#4}{#1#2}% #1#2=B, #3#4=A + {#2}{#4}#1#3% #1#2=B, #3#4=A }% -\def\XINT_bezout_botharezero #1\krof#2#3#4#5#6#7% - {\XINT_signalcondition{InvalidOperation} - {No Bezout identity for 0 and 0}{}{{0}{0}{0}{0}{0}}}% -\def\XINT_bezout_firstiszero #1\krof#2#3#4#5#6#7% +\def\XINT_bezout_botharezero #1\krof#2#300{{0}{0}{0}}% +\def\XINT_bezout_firstiszero #1\krof#2#3#4#5% {% \xint_UDsignfork - #4{{0}{#7}{0}{1}{#2}}% - -{{0}{#7}{0}{-1}{#7}}% + #4{{0}{-1}{#2}}% + -{{0}{1}{#4#2}}% \krof }% -\def\XINT_bezout_secondiszero #1\krof#2#3#4#5#6#7% +\def\XINT_bezout_secondiszero #1\krof#2#3#4#5% {% \xint_UDsignfork - #5{{#6}{0}{-1}{0}{#3}}% - -{{#6}{0}{1}{0}{#6}}% + #5{{-1}{0}{#3}}% + -{{1}{0}{#5#3}}% \krof }% \def\XINT_bezout_minusminus #1#2#3#4% {% \expandafter\XINT_bezout_mm_post - \romannumeral0\XINT_bezout_loop_a 1{#1}{#2}1001% + \romannumeral0\expandafter\XINT_bezout_preloop_a + \romannumeral0\XINT_div_prepare {#1}{#2}{#1}% }% \def\XINT_bezout_mm_post #1#2% {% \expandafter\XINT_bezout_mm_postb\expandafter {\romannumeral0\xintiiopp{#2}}{\romannumeral0\xintiiopp{#1}}% }% -\def\XINT_bezout_mm_postb #1#2% -{% - \expandafter\XINT_bezout_mm_postc\expandafter {#2}{#1}% -}% -\def\XINT_bezout_mm_postc #1#2#3#4#5{{#4}{#5}{#1}{#2}{#3}}% +\def\XINT_bezout_mm_postb #1#2{\expandafter{#2}{#1}}% \def\XINT_bezout_minusplus #1#2#3#4% {% \expandafter\XINT_bezout_mp_post - \romannumeral0\XINT_bezout_loop_a 1{#1}{#4#2}1001% + \romannumeral0\expandafter\XINT_bezout_preloop_a + \romannumeral0\XINT_div_prepare {#1}{#4#2}{#1}% }% \def\XINT_bezout_mp_post #1#2% {% - \expandafter\XINT_bezout_mp_postb\expandafter - {\romannumeral0\xintiiopp {#2}}{#1}% + \expandafter\xint_exchangetwo_keepbraces\expandafter + {\romannumeral0\xintiiopp {#2}}{#1}% }% -\def\XINT_bezout_mp_postb #1#2#3#4#5{{#4}{#5}{#2}{#1}{#3}}% \def\XINT_bezout_plusminus #1#2#3#4% {% \expandafter\XINT_bezout_pm_post - \romannumeral0\XINT_bezout_loop_a 1{#3#1}{#2}1001% + \romannumeral0\expandafter\XINT_bezout_preloop_a + \romannumeral0\XINT_div_prepare {#3#1}{#2}{#3#1}% +}% +\def\XINT_bezout_pm_post #1{\expandafter{\romannumeral0\xintiiopp{#1}}}% +\def\XINT_bezout_plusplus #1#2#3#4% +{% + \expandafter\XINT_bezout_preloop_a + \romannumeral0\XINT_div_prepare {#3#1}{#4#2}{#3#1}% }% -\def\XINT_bezout_pm_post #1% +\def\XINT_bezout_preloop_a #1#2#3% {% - \expandafter \XINT_bezout_pm_postb \expandafter - {\romannumeral0\xintiiopp{#1}}% + \if0#1\xint_dothis\XINT_bezout_preloop_exchange\fi + \if0#2\xint_dothis\XINT_bezout_preloop_exit\fi + \xint_orthat{\expandafter\XINT_bezout_loop_B}% + \romannumeral0\XINT_div_prepare {#2}{#3}{#2}{#1}110% }% -\def\XINT_bezout_pm_postb #1#2#3#4#5{{#4}{#5}{#1}{#2}{#3}}% -\def\XINT_bezout_plusplus #1#2#3#4% +\def\XINT_bezout_preloop_exit + \romannumeral0\XINT_div_prepare #1#2#3#4#5#6#7% {% - \expandafter\XINT_bezout_pp_post - \romannumeral0\XINT_bezout_loop_a 1{#3#1}{#4#2}1001% + {0}{1}{#2}% }% -\def\XINT_bezout_pp_post #1#2#3#4#5{{#4}{#5}{#1}{#2}{#3}}% -\def\XINT_bezout_loop_a #1#2#3% +\def\XINT_bezout_preloop_exchange {% - \expandafter\XINT_bezout_loop_b\the\numexpr -#1\expandafter.% - \romannumeral0\XINT_div_prepare {#2}{#3}{#2}% + \expandafter\xint_exchangetwo_keepbraces + \romannumeral0\expandafter\XINT_bezout_preloop_A }% -\def\XINT_bezout_loop_b #1.#2#3#4#5#6#7#8% +\def\XINT_bezout_preloop_A #1#2#3#4% {% - \expandafter\XINT_bezout_loop_c\expandafter - {\romannumeral0\xintiiadd{\XINT_mul_fork #5\xint:#2\xint:}{#7}}% - {\romannumeral0\xintiiadd{\XINT_mul_fork #6\xint:#2\xint:}{#8}}% - {#1}{#3}{#4}{#5}{#6}% + \if0#2\xint_dothis\XINT_bezout_preloop_exit\fi + \xint_orthat{\expandafter\XINT_bezout_loop_B}% + \romannumeral0\XINT_div_prepare {#2}{#3}{#2}{#1}% }% -\def\XINT_bezout_loop_c #1#2% +\def\XINT_bezout_loop_B #1#2% {% - \expandafter\XINT_bezout_loop_d\expandafter{#2}{#1}% + \if0#2\expandafter\XINT_bezout_exitA + \else\expandafter\XINT_bezout_loop_C + \fi {#1}{#2}% }% -\def\XINT_bezout_loop_d #1#2#3#4#5% +\def\XINT_bezout_loop_C #1#2#3#4#5#6#7% {% - \XINT_bezout_loop_e #4\Z {#3}{#5}{#2}{#1}% + \expandafter\XINT_bezout_loop_D\expandafter + {\romannumeral0\xintiiadd{\XINT_mul_plusplus{}{}#1\xint:#4\xint:}{#6}}% + {\romannumeral0\xintiiadd{\XINT_mul_plusplus{}{}#1\xint:#5\xint:}{#7}}% + {#2}{#3}{#4}{#5}% }% -\def\XINT_bezout_loop_e #1#2\Z +\def\XINT_bezout_loop_D #1#2% {% - \xint_gob_til_zero #1\XINT_bezout_loop_exit0\XINT_bezout_loop_f {#1#2}% + \expandafter\XINT_bezout_loop_E\expandafter{#2}{#1}% }% -\def\XINT_bezout_loop_f #1#2% +\def\XINT_bezout_loop_E #1#2#3#4% {% - \XINT_bezout_loop_a {#2}{#1}% + \expandafter\XINT_bezout_loop_b + \romannumeral0\XINT_div_prepare {#3}{#4}{#3}{#2}{#1}% }% -\def\XINT_bezout_loop_exit0\XINT_bezout_loop_f #1#2% +\def\XINT_bezout_loop_b #1#2% {% - \ifcase #2 - \or \expandafter\XINT_bezout_exiteven - \else\expandafter\XINT_bezout_exitodd - \fi + \if0#2\expandafter\XINT_bezout_exita + \else\expandafter\XINT_bezout_loop_c + \fi {#1}{#2}% +}% +\def\XINT_bezout_loop_c #1#2#3#4#5#6#7% +{% + \expandafter\XINT_bezout_loop_d\expandafter + {\romannumeral0\xintiiadd{\XINT_mul_plusplus{}{}#1\xint:#4\xint:}{#6}}% + {\romannumeral0\xintiiadd{\XINT_mul_plusplus{}{}#1\xint:#5\xint:}{#7}}% + {#2}{#3}{#4}{#5}% +}% +\def\XINT_bezout_loop_d #1#2% +{% + \expandafter\XINT_bezout_loop_e\expandafter{#2}{#1}% +}% +\def\XINT_bezout_loop_e #1#2#3#4% +{% + \expandafter\XINT_bezout_loop_B + \romannumeral0\XINT_div_prepare {#3}{#4}{#3}{#2}{#1}% }% -\def\XINT_bezout_exiteven #1#2#3#4#5{{#5}{#4}{#1}}% -\def\XINT_bezout_exitodd #1#2#3#4#5{{-#5}{-#4}{#1}}% +\def\XINT_bezout_exita #1#2#3#4#5#6#7{{-#5}{#4}{#3}}% +\def\XINT_bezout_exitA #1#2#3#4#5#6#7{{#5}{-#4}{#3}}% \def\xintEuclideAlgorithm {\romannumeral0\xinteuclidealgorithm }% \def\xinteuclidealgorithm #1% {% - \expandafter\XINT_euc\expandafter{\romannumeral0\xintiabs {#1}}% + \expandafter\XINT_euc\expandafter{\romannumeral0\xintiiabs{\xintNum{#1}}}% }% \def\XINT_euc #1#2% {% - \expandafter\XINT_euc_fork\romannumeral0\xintiabs {#2}\Z #1\Z + \expandafter\XINT_euc_fork\romannumeral0\xintiiabs{\xintNum{#2}}\Z #1\Z }% \def\XINT_euc_fork #1#2\Z #3#4\Z {% @@ -312,11 +320,12 @@ \def\xintBezoutAlgorithm {\romannumeral0\xintbezoutalgorithm }% \def\xintbezoutalgorithm #1% {% - \expandafter \XINT_bezalg \expandafter{\romannumeral0\xintiabs {#1}}% + \expandafter \XINT_bezalg + \expandafter{\romannumeral0\xintiiabs{\xintNum{#1}}}% }% \def\XINT_bezalg #1#2% {% - \expandafter\XINT_bezalg_fork \romannumeral0\xintiabs {#2}\Z #1\Z + \expandafter\XINT_bezalg_fork\romannumeral0\xintiiabs{\xintNum{#2}}\Z #1\Z }% \def\XINT_bezalg_fork #1#2\Z #3#4\Z {% |