summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/xint/xintgcd.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xintgcd.sty')
-rw-r--r--Master/texmf-dist/tex/generic/xint/xintgcd.sty545
1 files changed, 545 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintgcd.sty b/Master/texmf-dist/tex/generic/xint/xintgcd.sty
new file mode 100644
index 00000000000..3c7cc44b183
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/xint/xintgcd.sty
@@ -0,0 +1,545 @@
+%%
+%% This is file `xintgcd.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% xint.dtx (with options: `gcd')
+%%
+%% IMPORTANT NOTICE:
+%%
+%% For the copyright see the source file.
+%%
+%% Any modified versions of this file must be renamed
+%% with new filenames distinct from xintgcd.sty.
+%%
+%% For distribution of the original source see the terms
+%% for copying and modification in the file xint.dtx.
+%%
+%% This generated file may be distributed as long as the
+%% original source files, as listed above, are part of the
+%% same distribution. (The sources need not necessarily be
+%% in the same archive or directory.)
+%%----------------------------------------------------------------
+%% xint: Expandable operations on long numbers
+%% xintgcd: Euclidean algorithm with xint package
+%% Copyright (C) 2013 by Jean-Francois Burnol
+%%----------------------------------------------------------------
+\begingroup\catcode61\catcode48\catcode32=10\relax%
+ \catcode13=5 % ^^M
+ \endlinechar=13 %
+ \catcode123=1 % {
+ \catcode125=2 % }
+ \catcode64=11 % @
+ \catcode35=6 % #
+ \catcode44=12 % ,
+ \catcode45=12 % -
+ \catcode46=12 % .
+ \catcode58=12 % :
+ \def\space { }%
+ \let\z\endgroup
+ \expandafter\let\expandafter\x\csname ver@xintgcd.sty\endcsname
+ \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname
+ \expandafter
+ \ifx\csname PackageInfo\endcsname\relax
+ \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}%
+ \else
+ \def\y#1#2{\PackageInfo{#1}{#2}}%
+ \fi
+ \expandafter
+ \ifx\csname numexpr\endcsname\relax
+ \y{xintgcd}{\numexpr not available, aborting input}%
+ \aftergroup\endinput
+ \else
+ \ifx\x\relax % plain-TeX, first loading of xintgcd.sty
+ \ifx\w\relax % but xint.sty not yet loaded.
+ \y{xintgcd}{Package xint is required}%
+ \y{xintgcd}{Will try \string\input\space xint.sty}%
+ \def\z{\endgroup\input xint.sty\relax}%
+ \fi
+ \else
+ \def\empty {}%
+ \ifx\x\empty % LaTeX, first loading,
+ % variable is initialized, but \ProvidesPackage not yet seen
+ \ifx\w\relax % xint.sty not yet loaded.
+ \y{xintgcd}{Package xint is required}%
+ \y{xintgcd}{Will try \string\RequirePackage{xint}}%
+ \def\z{\endgroup\RequirePackage{xint}}%
+ \fi
+ \else
+ \y{xintgcd}{I was already loaded, aborting input}%
+ \aftergroup\endinput
+ \fi
+ \fi
+ \fi
+\z%
+\begingroup\catcode61\catcode48\catcode32=10\relax%
+ \catcode13=5 % ^^M
+ \endlinechar=13 %
+ \catcode123=1 % {
+ \catcode125=2 % }
+ \catcode64=11 % @
+ \catcode35=6 % #
+ \catcode44=12 % ,
+ \catcode45=12 % -
+ \catcode46=12 % .
+ \catcode58=12 % :
+ \expandafter
+ \ifx\csname PackageInfo\endcsname\relax
+ \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}%
+ \else
+ \def\y#1#2{\PackageInfo{#1}{#2}}%
+ \fi
+ \def\empty {}%
+ \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname
+ \ifx\w\relax % Plain TeX, user gave a file name at the prompt
+ \y{xintgcd}{Loading of package xint failed, aborting input}%
+ \aftergroup\endinput
+ \fi
+ \ifx\w\empty % LaTeX, user gave a file name at the prompt
+ \y{xintgcd}{Loading of package xint failed, aborting input}%
+ \aftergroup\endinput
+ \fi
+\endgroup%
+\begingroup\catcode61\catcode48\catcode32=10\relax%
+ \catcode13=5 % ^^M
+ \endlinechar=13 %
+ \catcode123=1 % {
+ \catcode125=2 % }
+ \catcode64=11 % @
+ \def\x
+ {%
+ \endgroup
+ \edef\XINT@gcd@restorecatcodes@endinput
+ {%
+ \catcode36=\the\catcode36 % $
+ \catcode47=\the\catcode47 % /
+ \catcode41=\the\catcode41 % )
+ \catcode40=\the\catcode40 % (
+ \catcode42=\the\catcode42 % *
+ \catcode43=\the\catcode43 % +
+ \catcode62=\the\catcode62 % >
+ \catcode60=\the\catcode60 % <
+ \catcode58=\the\catcode58 % :
+ \catcode46=\the\catcode46 % .
+ \catcode45=\the\catcode45 % -
+ \catcode44=\the\catcode44 % ,
+ \catcode35=\the\catcode35 % #
+ \catcode64=\the\catcode64 % @
+ \catcode125=\the\catcode125 % }
+ \catcode123=\the\catcode123 % {
+ \endlinechar=\the\endlinechar
+ \catcode13=\the\catcode13 % ^^M
+ \catcode32=\the\catcode32 %
+ \catcode61=\the\catcode61 % =
+ \noexpand\endinput
+ }%
+ \XINT@setcatcodes
+ \catcode36=3 % $
+ }%
+\x
+\begingroup
+ \catcode91=12 % [
+ \catcode93=12 % ]
+ \catcode58=12 % :
+ \expandafter\ifx\csname ProvidesPackage\endcsname\relax
+ \def\x#1#2#3[#4]{\endgroup
+ \immediate\write-1{Package: #3 #4}%
+ \xdef#1{#4}%
+ }%
+ \else
+ \def\x#1#2[#3]{\endgroup
+ #2[{#3}]%
+ \ifx#1\@undefined
+ \xdef#1{#3}%
+ \fi
+ \ifx#1\relax
+ \xdef#1{#3}%
+ \fi
+ }%
+ \fi
+\expandafter\x\csname ver@xintgcd.sty\endcsname
+\ProvidesPackage{xintgcd}%
+ [2013/03/28 v1.0 Euclide algorithm with xint package (jfB)]%
+\def\xintGCD {\romannumeral0\xintgcd }%
+\def\xintgcd #1%
+{%
+ \expandafter
+ \XINT@gcd
+ \expandafter
+ {\romannumeral0\xintabs {#1}}%
+}%
+\def\XINT@gcd #1#2%
+{%
+ \expandafter
+ \XINT@gcd@fork
+ \romannumeral0\xintabs {#2}\Z #1\Z
+}%
+\def\XINT@gcd@fork #1#2\Z #3#4\Z
+{%
+ \xint@UDzerofork
+ #1\dummy \XINT@gcd@BisZero
+ #3\dummy \XINT@gcd@AisZero
+ 0\dummy \XINT@gcd@loop
+ \xint@UDforkzero
+ {#1#2}{#3#4}%
+}%
+\def\XINT@gcd@AisZero #1#2{ #1}%
+\def\XINT@gcd@BisZero #1#2{ #2}%
+\def\XINT@gcd@CheckRem #1#2\Z
+{%
+ \xint@zero #1\xint@gcd@end0\XINT@gcd@loop {#1#2}%
+}%
+\def\xint@gcd@end0\XINT@gcd@loop #1#2{ #2}%
+\def\XINT@gcd@loop #1#2%
+{%
+ \expandafter\expandafter\expandafter
+ \XINT@gcd@CheckRem
+ \expandafter\xint@secondoftwo
+ \romannumeral0\XINT@div@prepare {#1}{#2}\Z
+ {#1}%
+}%
+\def\xintBezout {\romannumeral0\xintbezout }%
+\def\xintbezout #1%
+{%
+ \expandafter\expandafter\expandafter
+ \xint@bezout
+ \expandafter\expandafter\expandafter
+ {#1}%
+}%
+\def\xint@bezout #1#2%
+{\expandafter\expandafter\expandafter
+ \XINT@bezout@fork #2\Z #1\Z
+}%
+\def\XINT@bezout@fork #1#2\Z #3#4\Z
+{%
+ \xint@UDzerosfork
+ #1#3\dummy \XINT@bezout@botharezero
+ #10\dummy \XINT@bezout@secondiszero
+ #30\dummy \XINT@bezout@firstiszero
+ 00\dummy
+ {\xint@UDsignsfork
+ #1#3\dummy \XINT@bezout@minusminus % A < 0, B < 0
+ #1-\dummy \XINT@bezout@minusplus % A > 0, B < 0
+ #3-\dummy \XINT@bezout@plusminus % A < 0, B > 0
+ --\dummy \XINT@bezout@plusplus % A > 0, B > 0
+ \xint@UDforksigns }%
+ \xint@UDforkzeros
+ {#2}{#4}#1#3{#3#4}{#1#2}% #1#2=B, #3#4=A
+}%
+\def\XINT@bezout@botharezero #1#2#3#4#5#6%
+{%
+ \xintError:NoBezoutForZeros
+ \space {0}{0}{0}{0}{0}%
+}%
+\def\XINT@bezout@firstiszero #1#2#3#4#5#6%
+{%
+ \xint@UDsignfork
+ #3\dummy { {0}{#3#1}{0}{1}{#1}}%
+ -\dummy { {0}{#3#1}{0}{-1}{#1}}%
+ \xint@UDforksign
+}%
+\def\XINT@bezout@secondiszero #1#2#3#4#5#6%
+{%
+ \xint@UDsignfork
+ #4\dummy{ {#4#2}{0}{-1}{0}{#2}}%
+ -\dummy{ {#4#2}{0}{1}{0}{#2}}%
+ \xint@UDforksign
+}%
+\def\XINT@bezout@minusminus #1#2#3#4%
+{%
+ \expandafter\XINT@bezout@mm@post
+ \romannumeral0\XINT@bezout@loop@a 1{#1}{#2}1001%
+}%
+\def\XINT@bezout@mm@post #1#2%
+{%
+ \expandafter
+ \XINT@bezout@mm@postb
+ \expandafter
+ {\romannumeral0\xintopp{#2}}{\romannumeral0\xintopp{#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%
+{%
+ \space {#4}{#5}{#1}{#2}{#3}%
+}%
+\def\XINT@bezout@minusplus #1#2#3#4%
+{%
+ \expandafter\XINT@bezout@mp@post
+ \romannumeral0\XINT@bezout@loop@a 1{#1}{#4#2}1001%
+}%
+\def\XINT@bezout@mp@post #1#2%
+{%
+ \expandafter
+ \XINT@bezout@mp@postb
+ \expandafter
+ {\romannumeral0\xintopp {#2}}{#1}%
+}%
+\def\XINT@bezout@mp@postb #1#2#3#4#5%
+{%
+ \space {#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%
+}%
+\def\XINT@bezout@pm@post #1%
+{%
+ \expandafter
+ \XINT@bezout@pm@postb
+ \expandafter
+ {\romannumeral0\xintopp{#1}}%
+}%
+\def\XINT@bezout@pm@postb #1#2#3#4#5%
+{%
+ \space {#4}{#5}{#1}{#2}{#3}%
+}%
+\def\XINT@bezout@plusplus #1#2#3#4%
+{%
+ \expandafter\XINT@bezout@pp@post
+ \romannumeral0\XINT@bezout@loop@a 1{#3#1}{#4#2}1001%
+}%
+\def\XINT@bezout@pp@post #1#2#3#4#5%
+{%
+ \space {#4}{#5}{#1}{#2}{#3}%
+}%
+\def\XINT@bezout@loop@a #1#2#3%
+{%
+ \expandafter\XINT@bezout@loop@b
+ \expandafter{\the\numexpr -#1\expandafter }%
+ \romannumeral0\XINT@div@prepare {#2}{#3}{#2}%
+}%
+\def\XINT@bezout@loop@b #1#2#3#4#5#6#7#8%
+{%
+ \expandafter
+ \XINT@bezout@loop@c
+ \expandafter
+ {\romannumeral0\xintadd{\XINT@Mul{#5}{#2}}{#7}}%
+ {\romannumeral0\xintadd{\XINT@Mul{#6}{#2}}{#8}}%
+ {#1}{#3}{#4}{#5}{#6}%
+}%
+\def\XINT@bezout@loop@c #1#2%
+{%
+ \expandafter
+ \XINT@bezout@loop@d
+ \expandafter
+ {#2}{#1}%
+}%
+\def\XINT@bezout@loop@d #1#2#3#4#5%
+{%
+ \XINT@bezout@loop@e #4\Z {#3}{#5}{#2}{#1}%
+}%
+\def\XINT@bezout@loop@e #1#2\Z
+{%
+ \xint@zero #1\xint@bezout@loop@exit0\XINT@bezout@loop@f
+ {#1#2}%
+}%
+\def\XINT@bezout@loop@f #1#2%
+{%
+ \XINT@bezout@loop@a {#2}{#1}%
+}%
+\def\xint@bezout@loop@exit0\XINT@bezout@loop@f #1#2%
+{%
+ \ifcase #2
+ \or \expandafter\XINT@bezout@exiteven
+ \else\expandafter\XINT@bezout@exitodd
+ \fi
+}%
+\def\XINT@bezout@exiteven #1#2#3#4#5%
+{%
+ \space {#5}{#4}{#1}%
+}%
+\def\XINT@bezout@exitodd #1#2#3#4#5%
+{%
+ \space {-#5}{-#4}{#1}%
+}%
+\def\xintEuclideAlgorithm {\romannumeral0\xinteuclidealgorithm }%
+\def\xinteuclidealgorithm #1%
+{%
+ \expandafter
+ \XINT@euc
+ \expandafter
+ {\romannumeral0\xintabs {#1}}%
+}%
+\def\XINT@euc #1#2%
+{%
+ \expandafter
+ \XINT@euc@fork
+ \romannumeral0\xintabs {#2}\Z #1\Z
+}%
+\def\XINT@euc@fork #1#2\Z #3#4\Z
+{%
+ \xint@UDzerofork
+ #1\dummy \XINT@euc@BisZero
+ #3\dummy \XINT@euc@AisZero
+ 0\dummy \XINT@euc@a
+ \xint@UDforkzero
+ {0}{#1#2}{#3#4}{{#3#4}{#1#2}}{}\Z
+}%
+\def\XINT@euc@AisZero #1#2#3#4#5#6{ {1}{0}{#2}{#2}{0}{0}}%
+\def\XINT@euc@BisZero #1#2#3#4#5#6{ {1}{0}{#3}{#3}{0}{0}}%
+\def\XINT@euc@a #1#2#3%
+{%
+ \expandafter
+ \XINT@euc@b
+ \expandafter {\the\numexpr #1+1\expandafter }%
+ \romannumeral0\XINT@div@prepare {#2}{#3}{#2}%
+}%
+\def\XINT@euc@b #1#2#3#4%
+{%
+ \XINT@euc@c #3\Z {#1}{#3}{#4}{{#2}{#3}}%
+}%
+\def\XINT@euc@c #1#2\Z
+{%
+ \xint@zero #1\xint@euc@end0\XINT@euc@a
+}%
+\def\xint@euc@end0\XINT@euc@a #1#2#3#4\Z%
+{%
+ \expandafter\xint@euc@end@
+ \romannumeral0%
+ \XINT@rord@main {}#4{{#1}{#3}}%
+ \xint@UNDEF
+ \xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@UNDEF
+}%
+\def\xint@euc@end@ #1#2#3%
+{%
+ \space {#1}{#3}{#2}%
+}%
+\def\xintBezoutAlgorithm {\romannumeral0\xintbezoutalgorithm }%
+\def\xintbezoutalgorithm #1%
+{%
+ \expandafter
+ \XINT@bezalg
+ \expandafter
+ {\romannumeral0\xintabs {#1}}%
+}%
+\def\XINT@bezalg #1#2%
+{%
+ \expandafter
+ \XINT@bezalg@fork
+ \romannumeral0\xintabs {#2}\Z #1\Z
+}%
+\def\XINT@bezalg@fork #1#2\Z #3#4\Z
+{%
+ \xint@UDzerofork
+ #1\dummy \XINT@bezalg@BisZero
+ #3\dummy \XINT@bezalg@AisZero
+ 0\dummy \XINT@bezalg@a
+ \xint@UDforkzero
+ 0{#1#2}{#3#4}1001{{#3#4}{#1#2}}{}\Z
+}%
+\def\XINT@bezalg@AisZero #1#2#3\Z{ {1}{0}{0}{1}{#2}{#2}{1}{0}{0}{0}{0}{1}}%
+\def\XINT@bezalg@BisZero #1#2#3#4\Z{ {1}{0}{0}{1}{#3}{#3}{1}{0}{0}{0}{0}{1}}%
+\def\XINT@bezalg@a #1#2#3%
+{%
+ \expandafter
+ \XINT@bezalg@b
+ \expandafter {\the\numexpr #1+1\expandafter }%
+ \romannumeral0\XINT@div@prepare {#2}{#3}{#2}%
+}%
+\def\XINT@bezalg@b #1#2#3#4#5#6#7#8%
+{%
+ \expandafter\XINT@bezalg@c\expandafter
+ {\romannumeral0\xintadd {\xintMul {#6}{#2}}{#8}}%
+ {\romannumeral0\xintadd {\xintMul {#5}{#2}}{#7}}%
+ {#1}{#2}{#3}{#4}{#5}{#6}%
+}%
+\def\XINT@bezalg@c #1#2#3#4#5#6%
+{%
+ \expandafter\XINT@bezalg@d\expandafter
+ {#2}{#3}{#4}{#5}{#6}{#1}%
+}%
+\def\XINT@bezalg@d #1#2#3#4#5#6#7#8%
+{%
+ \XINT@bezalg@e #4\Z {#2}{#4}{#5}{#1}{#6}{#7}{#8}{{#3}{#4}{#1}{#6}}%
+}%
+\def\XINT@bezalg@e #1#2\Z
+{%
+ \xint@zero #1\xint@bezalg@end0\XINT@bezalg@a
+}%
+\def\xint@bezalg@end0\XINT@bezalg@a #1#2#3#4#5#6#7#8\Z
+{%
+ \expandafter\xint@bezalg@end@
+ \romannumeral0%
+ \XINT@rord@main {}#8{{#1}{#3}}%
+ \xint@UNDEF
+ \xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@UNDEF
+}%
+\def\xint@bezalg@end@ #1#2#3#4%
+{%
+ \space {#1}{#3}{0}{1}{#2}{#4}{1}{0}%
+}%
+\def\xintTypesetEuclideAlgorithm #1#2%
+{% l'algo remplace #1 et #2 par |#1| et |#2|
+ \par
+ \begingroup
+ \xintAssignArray\xintEuclideAlgorithm {#1}{#2}\to\U
+ \edef\A{\U2}\edef\B{\U4}\edef\N{\U1}%
+ \setbox 0 \vbox{\halign {$##$\cr \A\cr \B \cr}}%
+ \noindent
+ \count 255 1
+ \loop
+ \hbox to \wd 0 {\hfil$\U{\the\numexpr 2*\count 255\relax}$}%
+ ${} = \U{\the\numexpr 2*\count 255 + 3\relax}
+ \times \U{\the\numexpr 2*\count 255 + 2\relax}
+ + \U{\the\numexpr 2*\count 255 + 4\relax}$%
+ \ifnum \count 255 < \N
+ \hfill\break
+ \advance \count 255 1
+ \repeat
+ \par
+ \endgroup
+}%
+\def\xintTypesetBezoutAlgorithm #1#2%
+{%
+ \par
+ \begingroup
+ \parindent0pt
+ \xintAssignArray\xintBezoutAlgorithm {#1}{#2}\to\BEZ
+ \edef\A{\BEZ2}\edef\B{\BEZ6}\edef\N{\BEZ1}% A = |#1|, B = |#2|
+ \setbox 0 \vbox{\halign {$##$\cr \A\cr \B \cr}}%
+ \count 255 1
+ \loop
+ \noindent
+ \hbox to \wd 0 {\hfil$\BEZ{\the\numexpr 4*\count 255 - 2\relax}$}%
+ ${} = \BEZ{\the\numexpr 4*\count 255 + 5\relax}
+ \times \BEZ{\the\numexpr 4*\count 255 + 2\relax}
+ + \BEZ{\the\numexpr 4*\count 255 + 6\relax}$\hfill\break
+ \hbox to \wd 0 {\hfil$\BEZ{\the\numexpr 4*\count 255 +7\relax}$}%
+ ${} = \BEZ{\the\numexpr 4*\count 255 + 5\relax}
+ \times \BEZ{\the\numexpr 4*\count 255 + 3\relax}
+ + \BEZ{\the\numexpr 4*\count 255 - 1\relax}$\hfill\break
+ \hbox to \wd 0 {\hfil$\BEZ{\the\numexpr 4*\count 255 +8\relax}$}%
+ ${} = \BEZ{\the\numexpr 4*\count 255 + 5\relax}
+ \times \BEZ{\the\numexpr 4*\count 255 + 4\relax}
+ + \BEZ{\the\numexpr 4*\count 255 \relax}$
+ \endgraf
+ \ifnum \count 255 < \N
+ \advance \count 255 1
+ \repeat
+ \par
+ \edef\U{\BEZ{\the\numexpr 4*\N + 4\relax}}%
+ \edef\V{\BEZ{\the\numexpr 4*\N + 3\relax}}%
+ \edef\D{\BEZ5}%
+ \ifodd\N\relax
+ $\U\times\A - \V\times \B = -\D$%
+ \else
+ $\U\times\A - \V\times\B = \D$%
+ \fi
+ \par
+ \endgroup
+}%
+\XINT@gcd@restorecatcodes@endinput%
+\endinput
+%%
+%% End of file `xintgcd.sty'.