diff options
Diffstat (limited to 'Master/texmf-dist/source/latex-dev/l3kernel/l3fp-random.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex-dev/l3kernel/l3fp-random.dtx | 111 |
1 files changed, 57 insertions, 54 deletions
diff --git a/Master/texmf-dist/source/latex-dev/l3kernel/l3fp-random.dtx b/Master/texmf-dist/source/latex-dev/l3kernel/l3fp-random.dtx index 9180a1f2243..9ca2d3b3b2f 100644 --- a/Master/texmf-dist/source/latex-dev/l3kernel/l3fp-random.dtx +++ b/Master/texmf-dist/source/latex-dev/l3kernel/l3fp-random.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2025-01-14} +% \date{Released 2025-01-18} % % \maketitle % @@ -266,13 +266,13 @@ % \begin{macro}[EXP] % {\@@_rand_myriads:n, \@@_rand_myriads_loop:w, \@@_rand_myriads_get:w} % Used as \cs{@@_rand_myriads:n} |{XXX}| with one letter |X| -% (specifically) per block of four digit we want; it expands to |;| +% (specifically) per block of four digit we want; it expands to \cs{@@_sep:} % followed by the requested number of brace groups, each containing % four (pseudo-random) digits. Digits are produced as a random number % in $[10000,19999]$ for the usual reason of preserving leading zeros. % \begin{macrocode} \cs_new:Npn \@@_rand_myriads:n #1 - { \@@_rand_myriads_loop:w #1 \prg_break: X \prg_break_point: ; } + { \@@_rand_myriads_loop:w #1 \prg_break: X \prg_break_point: \@@_sep: } \cs_new:Npn \@@_rand_myriads_loop:w #1 X { #1 @@ -281,7 +281,7 @@ \__kernel_randint:n { 10000 } \@@_rand_myriads_loop:w } -\cs_new:Npn \@@_rand_myriads_get:w 1 #1 ; { ; {#1} } +\cs_new:Npn \@@_rand_myriads_get:w 1 #1 \@@_sep: { \@@_sep: {#1} } % \end{macrocode} % \end{macro} % @@ -301,7 +301,7 @@ { \exp_after:wN \@@_rand_o:w \exp:w \exp_end_continue_f:w - \@@_rand_myriads:n { XXXX } { 0000 } { 0000 } ; 0 + \@@_rand_myriads:n { XXXX } { 0000 } { 0000 } \@@_sep: 0 } { \msg_expandable_error:nnnnn @@ -309,7 +309,7 @@ \exp_after:wN \c_nan_fp } } -\cs_new:Npn \@@_rand_o:w ; +\cs_new:Npn \@@_rand_o:w \@@_sep: { \exp_after:wN \@@_sanitize:Nw \exp_after:wN 0 @@ -360,41 +360,41 @@ { \@@_randint_default:w \@@_randint_o:w } } \cs_new:Npn \@@_randint_default:w #1 { \exp_after:wN #1 \c_one_fp } -\cs_new:Npn \@@_randint_badarg:w \s_@@ \@@_chk:w #1#2#3; +\cs_new:Npn \@@_randint_badarg:w \s_@@ \@@_chk:w #1#2#3\@@_sep: { - \@@_int:wTF \s_@@ \@@_chk:w #1#2#3; + \@@_int:wTF \s_@@ \@@_chk:w #1#2#3\@@_sep: { \if_meaning:w 1 #1 \if_int_compare:w - \@@_use_i_until_s:nw #3 ; > \c_@@_prec_int + \@@_use_i_until_s:nw #3 \@@_sep: > \c_@@_prec_int \c_one_int \fi: \fi: } { \c_one_int } } -\cs_new:Npn \@@_randint_o:w #1; #2; @ +\cs_new:Npn \@@_randint_o:w #1\@@_sep: #2\@@_sep: @ { \if_case:w - \@@_randint_badarg:w #1; - \@@_randint_badarg:w #2; - \if:w 1 \@@_compare_back:ww #2; #1; \c_one_int \fi: + \@@_randint_badarg:w #1\@@_sep: + \@@_randint_badarg:w #2\@@_sep: + \if:w 1 \@@_compare_back:ww #2\@@_sep: #1\@@_sep: \c_one_int \fi: \c_zero_int - \@@_randint_auxi_o:ww #1; #2; + \@@_randint_auxi_o:ww #1\@@_sep: #2\@@_sep: \or: \@@_invalid_operation_tl_o:ff - { randint } { \@@_array_to_clist:n { #1; #2; } } + { randint } { \@@_array_to_clist:n { #1\@@_sep: #2\@@_sep: } } \exp:w \fi: \exp_after:wN \exp_end: } -\cs_new:Npn \@@_randint_auxi_o:ww #1 ; #2 ; #3 \exp_end: +\cs_new:Npn \@@_randint_auxi_o:ww #1 \@@_sep: #2 \@@_sep: #3 \exp_end: { \fi: - \@@_randint_auxii:wn #2 ; - { \@@_randint_auxii:wn #1 ; \@@_randint_auxiii_o:ww } + \@@_randint_auxii:wn #2 \@@_sep: + { \@@_randint_auxii:wn #1 \@@_sep: \@@_randint_auxiii_o:ww } } -\cs_new:Npn \@@_randint_auxii:wn \s_@@ \@@_chk:w #1#2#3#4 ; +\cs_new:Npn \@@_randint_auxii:wn \s_@@ \@@_chk:w #1#2#3#4 \@@_sep: { \if_meaning:w 0 #1 \exp_after:wN \use_i:nn @@ -405,7 +405,7 @@ { \exp_after:wN \@@_ep_to_fixed:wwn \int_value:w \@@_int_eval:w - #3 - \c_@@_prec_int , #4 {0000} {0000} ; + #3 - \c_@@_prec_int , #4 {0000} {0000} \@@_sep: { \if_meaning:w 0 #2 \exp_after:wN \use_i:nnnn @@ -416,22 +416,22 @@ \@@_fixed_continue:wn } } -\cs_new:Npn \@@_randint_auxiii_o:ww #1 ; #2 ; +\cs_new:Npn \@@_randint_auxiii_o:ww #1 \@@_sep: #2 \@@_sep: { - \@@_fixed_add:wwn #2 ; - {0000} {0000} {0000} {0001} {0000} {0000} ; - \@@_fixed_sub:wwn #1 ; + \@@_fixed_add:wwn #2 \@@_sep: + {0000} {0000} {0000} {0001} {0000} {0000} \@@_sep: + \@@_fixed_sub:wwn #1 \@@_sep: { \exp_after:wN \use_i:nn \exp_after:wN \@@_fixed_mul_add:wwwn - \exp:w \exp_end_continue_f:w \@@_rand_myriads:n { XXXXXX } ; + \exp:w \exp_end_continue_f:w \@@_rand_myriads:n { XXXXXX } \@@_sep: } - #1 ; + #1 \@@_sep: \@@_randint_auxiv_o:ww - #2 ; - \@@_randint_auxv_o:w #1 ; @ + #2 \@@_sep: + \@@_randint_auxv_o:w #1 \@@_sep: @ } -\cs_new:Npn \@@_randint_auxiv_o:ww #1#2#3#4#5 ; #6#7#8#9 +\cs_new:Npn \@@_randint_auxiv_o:ww #1#2#3#4#5 \@@_sep: #6#7#8#9 { \if_int_compare:w \if_int_compare:w #1#2 > #6#7 \exp_stop_f: 1 \else: @@ -441,7 +441,7 @@ \fi: \@@_randint_auxv_o:w {#1}{#2}{#3}{#4}#5 } -\cs_new:Npn \@@_randint_auxv_o:w #1#2#3#4#5 ; #6 @ +\cs_new:Npn \@@_randint_auxv_o:w #1#2#3#4#5 \@@_sep: #6 @ { \exp_after:wN \@@_sanitize:Nw \int_value:w @@ -453,7 +453,7 @@ \exp_after:wN \@@_reverse_args:Nww \fi: \exp_after:wN \@@_fixed_sub:wwn \c_@@_one_fixed_tl - {#1} {#2} {#3} {#4} {0000} {0000} ; + {#1} {#2} {#3} {#4} {0000} {0000} \@@_sep: { \exp_after:wN \exp_stop_f: \int_value:w \@@_int_eval:w \c_@@_prec_int @@ -480,16 +480,16 @@ \int_eval:n { \exp_after:wN \@@_randint:ww - \int_value:w \int_eval:n {#1} \exp_after:wN ; - \int_value:w \int_eval:n {#2} ; + \int_value:w \int_eval:n {#1} \exp_after:wN \@@_sep: + \int_value:w \int_eval:n {#2} \@@_sep: } } -\cs_new:Npn \@@_randint:ww #1; #2; +\cs_new:Npn \@@_randint:ww #1\@@_sep: #2\@@_sep: { \if_int_compare:w #1 > #2 \exp_stop_f: \msg_expandable_error:nnnn { kernel } { randint-backward-range } {#1} {#2} - \@@_randint:ww #2; #1; + \@@_randint:ww #2\@@_sep: #1\@@_sep: \else: \if_int_compare:w \@@_int_eval:w #2 \if_int_compare:w #1 > \c_zero_int @@ -517,15 +517,15 @@ % } % Any $n\in[-2^{31}+1,2^{31}-1]$ is uniquely written as % $2^{14}n_1+n_2$ with $n_1\in[-2^{17},2^{17}-1]$ and -% $n_2\in[0,2^{14}-1]$. Calling \cs{@@_randint_split_o:Nw} $n$ |;| -% gives $n_1$|;| $n_2$|;| and expands the next token once. We do this +% $n_2\in[0,2^{14}-1]$. Calling \cs{@@_randint_split_o:Nw} $n$ \cs{@@_sep:} +% gives $n_1$\cs{@@_sep:} $n_2$\cs{@@_sep:} and expands the next token once. We do this % for two random numbers and apply \cs{@@_randint_split_o:Nw} twice to % fully decompose the range~$R$. One subtlety is that we compute % $R-2^{31}=\meta{max}-\meta{min}-(2^{31}-1)\in[-2^{31}+1,2^{31}-1]$ % rather than $R$ to avoid overflow. % -% Then we have \cs{@@_randint_wide_aux:w} \meta{X_1}|;|\meta{X_0}|;| -% \meta{Y_1}|;|\meta{Y_0}|;| \meta{R_2}|;|\meta{R_1}|;|\meta{R_0}|;.| +% Then we have \cs{@@_randint_wide_aux:w} \meta{X_1}\cs{@@_sep:}\meta{X_0}\cs{@@_sep:} +% \meta{Y_1}\cs{@@_sep:}\meta{Y_0}\cs{@@_sep:} \meta{R_2}\cs{@@_sep:}\meta{R_1}\cs{@@_sep:}\meta{R_0}|;.| % and we apply the algorithm described earlier. % \begin{macrocode} \cs_new:Npn \__kernel_randint:nn #1#2 @@ -534,46 +534,49 @@ \exp_after:wN \@@_randint_wide_aux:w \int_value:w \exp_after:wN \@@_randint_split_o:Nw - \tex_uniformdeviate:D 268435456 ; + \tex_uniformdeviate:D 268435456 \@@_sep: \int_value:w \exp_after:wN \@@_randint_split_o:Nw - \tex_uniformdeviate:D 268435456 ; + \tex_uniformdeviate:D 268435456 \@@_sep: \int_value:w \exp_after:wN \@@_randint_split_o:Nw \int_value:w \@@_int_eval:w 131072 + \exp_after:wN \@@_randint_split_o:Nw \int_value:w - \__kernel_int_add:nnn {#2} { -#1 } { -\c_max_int } ; + \__kernel_int_add:nnn {#2} { -#1 } { -\c_max_int } \@@_sep: . } -\cs_new:Npn \@@_randint_split_o:Nw #1#2 ; +\cs_new:Npn \@@_randint_split_o:Nw #1#2 \@@_sep: { \if_meaning:w 0 #1 - 0 \exp_after:wN ; \int_value:w 0 + 0 \exp_after:wN \@@_sep: \int_value:w 0 \else: \exp_after:wN \@@_randint_split_aux:w - \int_value:w \@@_int_eval:w (#1#2 - 8192) / 16384 ; + \int_value:w \@@_int_eval:w (#1#2 - 8192) / 16384 \@@_sep: + #1#2 \fi: - \exp_after:wN ; + \exp_after:wN \@@_sep: } -\cs_new:Npn \@@_randint_split_aux:w #1 ; +\cs_new:Npn \@@_randint_split_aux:w #1 \@@_sep: { - #1 \exp_after:wN ; + #1 \exp_after:wN \@@_sep: \int_value:w \@@_int_eval:w - #1 * 16384 } -\cs_new:Npn \@@_randint_wide_aux:w #1;#2; #3;#4; #5;#6;#7; . +\cs_new:Npn \@@_randint_wide_aux:w + #1\@@_sep:#2\@@_sep: #3\@@_sep:#4\@@_sep: + #5\@@_sep:#6\@@_sep:#7\@@_sep: . { \exp_after:wN \@@_randint_wide_auxii:w \int_value:w \@@_int_eval:w #5 * #3 + #6 * #1 + (#5 * #4 + #6 * #3 + #7 * #1 + (#5 * #2 + #7 * #3 + (16384 * #6 + #7) * (16384 * #4 + #2) / 268435456) / 16384 - ) / 16384 \exp_after:wN ; - \int_value:w \@@_int_eval:w (#5 + #6) * 16384 + #7 ; - #1 ; #5 ; + ) / 16384 \exp_after:wN \@@_sep: + \int_value:w \@@_int_eval:w (#5 + #6) * 16384 + #7 \@@_sep: + #1 \@@_sep: #5 \@@_sep: } -\cs_new:Npn \@@_randint_wide_auxii:w #1; #2; #3; #4; +\cs_new:Npn \@@_randint_wide_auxii:w + #1\@@_sep: #2\@@_sep: #3\@@_sep: #4\@@_sep: { \if_int_odd:w 0 \if_int_compare:w #1 = #2 \else: \exp_stop_f: \fi: @@ -606,7 +609,7 @@ \if_int_compare:w #1 < \c_one_int \msg_expandable_error:nnnn { kernel } { randint-backward-range } { 1 } {#1} - \@@_randint:ww #1; 1; + \@@_randint:ww #1\@@_sep: 1\@@_sep: \else: \if_int_compare:w #1 > \c__kernel_randint_max_int \__kernel_randint:nn { 1 } {#1} |