summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-11-22 22:50:16 +0000
committerKarl Berry <karl@freefriends.org>2016-11-22 22:50:16 +0000
commitf476e2547d6f421f3f59e812adb855596f668eb5 (patch)
tree859e615afe313dc934f3ca679cd4ea760e356f98 /Master/texmf-dist/source/latex/l3kernel
parent4061b69b7a85fc322821dbfc8beb83b498542e45 (diff)
l3 (22nov16)
git-svn-id: svn://tug.org/texlive/trunk@42556 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/expl3.dtx4
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3.ins1
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3format.ins1
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx39
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx70
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx64
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx266
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx23
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp.dtx76
9 files changed, 532 insertions, 12 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/expl3.dtx b/Master/texmf-dist/source/latex/l3kernel/expl3.dtx
index 4a37d2c3c4e..0c1b6727074 100644
--- a/Master/texmf-dist/source/latex/l3kernel/expl3.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/expl3.dtx
@@ -36,8 +36,8 @@
%<*driver|generic|package>
\def\ExplFileName{expl3}%
\def\ExplFileDescription{L3 programming layer}%
-\def\ExplFileDate{2016/10/19}%
-\def\ExplFileVersion{6730}%
+\def\ExplFileDate{2016/11/21}%
+\def\ExplFileVersion{6760}%
%</driver|generic|package>
%<*driver>
\documentclass[full]{l3doc}
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3.ins b/Master/texmf-dist/source/latex/l3kernel/l3.ins
index c1d041943b0..a60eb19398c 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3.ins
+++ b/Master/texmf-dist/source/latex/l3kernel/l3.ins
@@ -71,6 +71,7 @@ Do not distribute a modified version of this file.
\from{l3fp-expo.dtx} {package}
\from{l3fp-trig.dtx} {package}
\from{l3fp-convert.dtx} {package}
+ \from{l3fp-random.dtx} {package}
\from{l3fp-assign.dtx} {package}
\from{l3box.dtx} {package}
\from{l3coffins.dtx} {package}
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3format.ins b/Master/texmf-dist/source/latex/l3kernel/l3format.ins
index 30bfd609096..1e38ca555f3 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3format.ins
+++ b/Master/texmf-dist/source/latex/l3kernel/l3format.ins
@@ -71,6 +71,7 @@ Do not distribute a modified version of this file.
\from{l3fp-expo.dtx} {initex}
\from{l3fp-trig.dtx} {initex}
\from{l3fp-convert.dtx} {initex}
+ \from{l3fp-random.dtx} {initex}
\from{l3fp-assign.dtx} {initex}
\from{l3box.dtx} {initex}
\from{l3coffins.dtx} {initex}
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx
index ce51a27a8d5..519a63fd6d9 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx
@@ -36,7 +36,7 @@
%
%<*driver>
\documentclass[full]{l3doc}
-\GetIdInfo$Id: l3fp-aux.dtx 6685 2016-08-19 16:26:52Z bruno $
+\GetIdInfo$Id: l3fp-aux.dtx 6750 2016-11-21 01:24:26Z bruno $
{L3 Floating-point support functions}
\documentclass[full]{l3doc}
\begin{document}
@@ -939,6 +939,43 @@
% \end{macrocode}
% \end{macro}
%
+% \subsection{Integer floating points}
+%
+% \begin{macro}[int, EXP, pTF]{\@@_int:w}
+% \begin{macro}[aux, EXP]{\@@_int_normal:nnnnn, \@@_int_test:Nw}
+% Tests if the floating point argument is an integer. This holds if
+% the rounding digit resulting from \cs{@@_decimate:nNnnnn} is~$0$.
+% \begin{macrocode}
+\prg_new_conditional:Npnn \@@_int:w \s_@@ \@@_chk:w #1 #2 #3; { TF , T , F , p }
+ {
+ \if_case:w #1 \exp_stop_f:
+ \prg_return_true:
+ \or: \@@_int_normal:nnnnn #3
+ \else: \prg_return_false:
+ \fi:
+ }
+\cs_new:Npn \@@_int_normal:nnnnn #1 #2#3#4#5
+ {
+ \if_int_compare:w #1 > \c_zero
+ \@@_decimate:nNnnnn { \c_sixteen - #1 }
+ \@@_int_test:Nw
+ {#2} {#3} {#4} {#5}
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+\cs_new:Npn \@@_int_test:Nw #1#2;
+ {
+ \if_meaning:w 0 #1
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Small integer floating points}
%
% \begin{macro}[int, EXP]{\@@_small_int:wTF}
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx
index 40691eeeff3..68282396cce 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx
@@ -36,7 +36,7 @@
%
%<*driver>
\documentclass[full]{l3doc}
-\GetIdInfo$Id: l3fp-logic.dtx 6659 2016-08-15 15:37:48Z bruno $
+\GetIdInfo$Id: l3fp-logic.dtx 6759 2016-11-21 17:04:08Z joseph $
{L3 Floating-point conditionals}
\begin{document}
\DocInput{\jobname.dtx}
@@ -316,6 +316,74 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[EXP]{\fp_step_function:nnnN, \fp_step_function:nnnc}
+% \begin{macro}[EXP, aux]{\@@_step:wwwN}
+% \begin{macro}[EXP, aux]{\@@_step:NnnnN, \@@_step:NfnnN}
+% The approach here is much the same as \cs{int_step_function:nnnN} except we
+% do not have a convenient low-level way to evaluation each argument to give
+% a pure number. Instead, the internal parser is used to leave values in the
+% internal format (and avoid a more expensive \texttt{f}-type expansion of
+% multiple uses of \texttt{fp_eval:n}).
+% \begin{macrocode}
+\cs_new:Npn \fp_step_function:nnnN #1#2#3
+ {
+ \exp_after:wN \@@_step:wwwN
+ \exp:w \exp_end_continue_f:w \@@_parse_o:n {#1} :
+ \exp:w \exp_end_continue_f:w \@@_parse_o:n {#2} :
+ \exp:w \exp_end_continue_f:w \@@_parse:n {#3} :
+ }
+\cs_generate_variant:Nn \fp_step_function:nnnN { nnnc }
+% \end{macrocode}
+% Here, |#1| will be passed to the output on the first pass of the loop.
+% To avoid this being in internal form, an \texttt{f}-type expansion is used
+% here on that value only. The second and third arguments will be converted
+% during the loop itself.
+% \begin{macrocode}
+\cs_new:Npn \@@_step:wwwN #1 : #2 : #3 : #4
+ {
+ \fp_compare:nNnTF {#2} > 0
+ { \@@_step:NfnnN > }
+ {
+ \fp_compare:nNnTF {#2} = 0
+ {
+ \__msg_kernel_expandable_error:nnn { kernel } { zero-step } {#4}
+ \use_none:nnnn
+ }
+ { \@@_step:NfnnN < }
+ }
+ { \fp_eval:n {#1} } {#2} {#3} #4
+ }
+
+\cs_new:Npn \@@_step:NnnnN #1#2#3#4#5
+ {
+ \fp_compare:nNnF {#2} #1 {#4}
+ {
+ #5 {#2}
+ \@@_step:NfnnN
+ #1 { \fp_eval:n { #2 + #3 } } {#3} {#4} #5
+ }
+ }
+\cs_generate_variant:Nn \@@_step:NnnnN { Nf }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\fp_step_inline:nnnn}
+% As for \cs{int_step_inline:nnnn}, create a global function and apply it,
+% following up with a break point.
+% \begin{macrocode}
+\cs_new_protected:Npn \fp_step_inline:nnnn #1#2#3#4
+ {
+ \int_gincr:N \g__prg_map_int
+ \cs_gset_protected:cpn { __prg_map_ \int_use:N \g__prg_map_int :w }
+ ##1 {#4}
+ \fp_step_function:nnnc {#1} {#2} {#3}
+ { __prg_map_ \int_use:N \g__prg_map_int :w }
+ \__prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__prg_map_int }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Extrema}
%
% \begin{macro}[int, EXP]{\@@_minmax_o:Nw}
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx
index d3dbf085569..339595c6d2e 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx
@@ -36,7 +36,7 @@
%
%<*driver>
\documentclass[full]{l3doc}
-\GetIdInfo$Id: l3fp-parse.dtx 6685 2016-08-19 16:26:52Z bruno $
+\GetIdInfo$Id: l3fp-parse.dtx 6750 2016-11-21 01:24:26Z bruno $
{L3 Floating-point expression parsing}
\begin{document}
\DocInput{\jobname.dtx}
@@ -91,6 +91,8 @@
% in the input stream as an internal floating point number. This
% function forms the basis of almost all public \pkg{l3fp} functions.
% During evaluation, each token is fully \texttt{f}-expanded.
+%
+% \cs{@@_parse_o:n} does the same but expands once after its result.
% \begin{texnote}
% Registers (integers, toks, etc.) are automatically unpacked,
% without requiring a function such as \cs{int_use:N}. Invalid
@@ -821,7 +823,7 @@
% integer registers from dimensions/skips from muskips, according to
% the presence of a period and/or of |pt|. For integers, simply
% convert \meta{value}|e|\meta{exponent} to a floating point number
-% with \cs{fp_parse:n} (this is somewhat wasteful). For other
+% with \cs{@@_parse:n} (this is somewhat wasteful). For other
% registers, the decimal rounding provided by \TeX{} does not
% accurately represent the binary value that it manipulates, so we
% extract this binary value as a number of scaled points with
@@ -1783,8 +1785,8 @@
% {\@@_parse_prefix_(:Nw, \@@_parse_lparen_after:NwN}
% The left parenthesis is treated as a unary prefix operator because
% it appears in exactly the same settings. Commas will be allowed if
-% the previous precedence is $16$ (function with multiple arguments)
-% or $13$ (unary boolean \enquote{not}). In this case, find an
+% the previous precedence is $16$ (function with multiple arguments).
+% In this case, find an
% operand using the precedence~$1$; otherwise the precedence~$0$.
% Once the operand is found, the \texttt{lparen_after} auxiliary makes
% sure that there was a closing parenthesis (otherwise it complains),
@@ -1825,6 +1827,42 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[aux, EXP, verb]{\@@_parse_prefix_,:Nw}
+% \begin{macro}[aux, EXP]{\@@_parse_prefix_):Nw}
+% The right parenthesis and the comma can appear as unary prefixes
+% when an argument of a multi-argument function is missing (for
+% instance the first and last ones in |max(,1,2,)| or in |rand()|).
+% In single-argument functions (precedence~$0$ rather than~$1$) forbid
+% this.
+% \begin{macrocode}
+\cs_new:cpn { @@_parse_prefix_,:Nw } #1
+ {
+ \if_int_compare:w #1 = \c_one
+ \exp_after:wN \@@_parse_one:Nw
+ \exp_after:wN #1
+ \else:
+ \__msg_kernel_expandable_error:nnn
+ { kernel } { fp-missing-number } { , }
+ \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w
+ \exp_after:wN \@@_parse_infix:NN
+ \exp_after:wN #1
+ \exp_after:wN ,
+ \fi:
+ }
+\cs_new:cpn { @@_parse_prefix_):Nw } #1
+ {
+ \if_int_compare:w #1 = \c_one
+ \else:
+ \__msg_kernel_expandable_error:nnn
+ { kernel } { fp-missing-number } { ) }
+ \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w
+ \fi:
+ \@@_parse_infix:NN #1 )
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsubsection{Constants}
%
% \begin{macro}[aux, EXP]
@@ -1939,9 +1977,11 @@
% \@@_parse_word_acot:N , \@@_parse_word_acotd:N,
% \@@_parse_word_atan:N , \@@_parse_word_atand:N,
% \@@_parse_word_max:N , \@@_parse_word_min:N ,
+% \@@_parse_word_rand:N , \@@_parse_word_randint:N,
% }
% Those functions are also unary (not binary), but may receive a
% variable number of arguments.
+% For |randint| we don't use the first argument~|?|.
% \begin{macrocode}
\cs_new:Npn \@@_parse_word_acot:N
{ \@@_parse_function:NNN \@@_acot_o:Nw \use_i:nn }
@@ -1955,6 +1995,10 @@
{ \@@_parse_function:NNN \@@_minmax_o:Nw 2 }
\cs_new:Npn \@@_parse_word_min:N
{ \@@_parse_function:NNN \@@_minmax_o:Nw 0 }
+\cs_new:Npn \@@_parse_word_rand:N
+ { \@@_parse_function:NNN \@@_rand_o:Nw ? }
+\cs_new:Npn \@@_parse_word_randint:N
+ { \@@_parse_function:NNN \@@_randint_o:Nw ? }
% \end{macrocode}
% \end{macro}
%
@@ -2088,6 +2132,18 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}[int, EXP]{\@@_parse_o:n}
+% ^^A todo: optimize, comment, make it work for arrays.
+% \begin{macrocode}
+\cs_new:Npn \@@_parse_o:n #1
+ {
+ \exp_after:wN \exp_after:wN
+ \exp_after:wN \@@_exp_after_o:w
+ \@@_parse:n {#1}
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}[aux, EXP]{\@@_parse_operand:Nw}
% \begin{macro}[aux, EXP]{\@@_parse_continue:NwN}
% The \cs{@@_parse_operand}
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx
new file mode 100644
index 00000000000..e2708e193fc
--- /dev/null
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx
@@ -0,0 +1,266 @@
+% \iffalse meta-comment
+%
+%% File: l3fp-random.dtx Copyright (C) 2016 The LaTeX3 Project
+%%
+%% It may be distributed and/or modified under the conditions of the
+%% LaTeX Project Public License (LPPL), either version 1.3c of this
+%% license or (at your option) any later version. The latest version
+%% of this license is in the file
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% This file is part of the "l3kernel bundle" (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%%
+%% The released version of this bundle is available from CTAN.
+%%
+%% -----------------------------------------------------------------------
+%%
+%% The development version of the bundle can be found at
+%%
+%% http://www.latex-project.org/svnroot/experimental/trunk/
+%%
+%% for those people who are interested.
+%%
+%%%%%%%%%%%
+%% NOTE: %%
+%%%%%%%%%%%
+%%
+%% Snapshots taken from the repository represent work in progress and may
+%% not work or may contain conflicting material! We therefore ask
+%% people _not_ to put them into distributions, archives, etc. without
+%% prior consultation with the LaTeX Project Team.
+%%
+%% -----------------------------------------------------------------------
+%%
+%
+%<*driver>
+\documentclass[full]{l3doc}
+\GetIdInfo$Id: l3fp-random.dtx 6750 2016-11-21 01:24:26Z bruno $
+ {L3 Floating-point random numbers}
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \title{The \textsf{l3fp-random} package\thanks{This file
+% has version number \ExplFileVersion, last
+% revised \ExplFileDate.}\\
+% Floating point random numbers}
+% \author{^^A
+% The \LaTeX3 Project\thanks
+% {^^A
+% E-mail:
+% \href{mailto:latex-team@latex-project.org}
+% {latex-team@latex-project.org}^^A
+% }^^A
+% }
+% \date{Released \ExplFileDate}
+%
+% \maketitle
+%
+% \begin{documentation}
+%
+% \end{documentation}
+%
+% \begin{implementation}
+%
+% \section{\pkg{l3fp-random} Implementation}
+%
+% \begin{macrocode}
+%<*initex|package>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<@@=fp>
+% \end{macrocode}
+%
+% \subsection{Random floating point}
+%
+% \begin{macro}[EXP, int]{\@@_rand_o:Nw}
+% \begin{macro}[EXP, aux]{\@@_rand_o:}
+% Check that |random| was called without argument. Random numbers are
+% only available if the engine defines a primitive equivalent to
+% \pdfTeX{}'s \tn{pdfuniformdeviate}. A random floating point number
+% in $[0,1)$, uniformly distributed with equal-spaced steps of
+% $10^{-16}$ is obtained by combining two integers in $[0,10^8-1]$.
+% \begin{macrocode}
+\cs_new:Npn \@@_rand_o:Nw ? #1 @
+ {
+ \tl_if_empty:nTF {#1}
+ { \@@_rand_o: }
+ {
+ \__msg_kernel_expandable_error:nnnnn
+ { kernel } { fp-num-args } { rand() } { 0 } { 0 }
+ \exp_after:wN \c_nan_fp
+ }
+ }
+\cs_if_exist:NTF \pdftex_uniformdeviate:D
+ {
+ \cs_new:Npn \@@_rand_o:
+ {
+ \@@_parse_o:n
+ {
+ .
+ \exp_after:wN \use_none:n
+ \__int_value:w \__int_eval:w 1 0000 0000 +
+ \pdftex_uniformdeviate:D 1 0000 0000 \__int_eval_end:
+ \exp_after:wN \use_none:n
+ \__int_value:w \__int_eval:w 1 0000 0000 +
+ \pdftex_uniformdeviate:D 1 0000 0000 \__int_eval_end:
+ }
+ }
+ }
+ {
+ \cs_new:Npn \@@_rand_o:
+ {
+ \__msg_kernel_expandable_error:nn { kernel } { fp-no-random }
+ \exp_after:wN \c_nan_fp
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Random integer}
+%
+% \begin{macro}[EXP, int]{\@@_randint_o:Nw}
+% \begin{macro}[EXP, aux]
+% {
+% \@@_randint_badarg:w,
+% \@@_randint_e:w,
+% \@@_randint_narrow_e:nn,
+% \@@_randint_wide_e:nn,
+% \@@_randint_wide_e:nnn,
+% \@@_randint_wide_e:nnnn,
+% }
+% Enforce that there is one argument (then add first argument~$1$)
+% or two arguments. Enforce that they are integers in
+% $(-10^{16},10^{16})$ and ordered.
+%
+% When the range is narrow (less than $2\times 10^9$) we can
+% directly use the primitive. Otherwise we use the primitive twice.
+% To ensure a uniform distribution we combine two uniformly
+% distributed integers into a total range greater or equal to our
+% target range and try again if the random number ended up being too
+% big.
+%
+% The strange |+\c_six| ensures that the first argument of
+% \cs{@@_randint_wide_e:nnn} is larger than $10^{-8}$ times the
+% difference between the end-points even if these are near
+% $-10^{16}$ and $+10^{16}$ (their difference is rounded to sixteen
+% digits). Note that we cannot just concatenate the two random
+% numbers provided by the engine as that may give an integer up to
+% (almost) $2\times 10^{16}$ which incurs rounding.
+% \begin{macrocode}
+\cs_new:Npn \@@_randint_o:Nw ? #1 @
+ {
+ \if_case:w
+ \__int_eval:w \@@_array_count:n {#1} - \c_one \__int_eval_end:
+ \exp_after:wN \@@_randint_e:w \c_one_fp #1
+ \or: \@@_randint_e:w #1
+ \else:
+ \__msg_kernel_expandable_error:nnnnn
+ { kernel } { fp-num-args } { randint() } { 1 } { 2 }
+ \exp_after:wN \c_nan_fp \exp:w
+ \fi:
+ \exp_after:wN \exp_end:
+ }
+\cs_new:Npn \@@_randint_badarg:w \s_@@ \@@_chk:w #1#2#3;
+ {
+ \@@_int:wTF \s_@@ \@@_chk:w #1#2#3;
+ {
+ \if_meaning:w 1 #1
+ \if_int_compare:w
+ \use_i_delimit_by_q_stop:nw #3 \q_stop > \c_sixteen
+ \exp_after:wN \c_one
+ \fi:
+ \fi:
+ }
+ { \c_one }
+ }
+\cs_new:Npn \@@_randint_e:w #1; #2;
+ {
+ \if_case:w
+ \@@_randint_badarg:w #1;
+ \@@_randint_badarg:w #2;
+ \fp_compare:nNnTF { #1; } > { #2; } { \c_one } { \c_zero }
+ \fp_compare:nNnTF { #1; + 2e9 } < { #2; }
+ { \@@_randint_wide_e:nn }
+ { \@@_randint_narrow_e:nn }
+ { #1; } { #2; }
+ \or:
+ \@@_invalid_operation_tl_o:ff
+ { randint } { \@@_array_to_clist:n { #1; #2; } }
+ \exp:w
+ \fi:
+ }
+\cs_if_exist:NTF \pdftex_uniformdeviate:D
+ {
+ \cs_new:Npn \@@_randint_narrow_e:nn #1#2
+ {
+ \@@_parse_o:n
+ {
+ #1 +
+ \pdftex_uniformdeviate:D
+ \int_eval:n { \fp_to_int:n { #2 - #1 } + \c_one }
+ }
+ \exp:w
+ }
+ \cs_new:Npn \@@_randint_wide_e:nn #1 #2
+ {
+ \exp_args:Nf \@@_randint_wide_e:nnn
+ { \fp_to_int:n { ceil ( ( #2 - #1 + \c_six ) * 1e-8 ) } }
+ {#1} {#2}
+ }
+ \cs_new:Npn \@@_randint_wide_e:nnn #1#2#3
+ {
+ \exp_args:Nf \@@_randint_wide_e:nnnn
+ {
+ \@@_parse:n
+ {
+ #2 +
+ \pdftex_uniformdeviate:D #1 e 8 +
+ \pdftex_uniformdeviate:D 1 0000 0000
+ }
+ }
+ {#1} {#2} {#3}
+ }
+ \cs_new:Npn \@@_randint_wide_e:nnnn #1#2#3#4
+ {
+ \fp_compare:nNnTF {#1} > {#4}
+ { \@@_randint_wide_e:nnn {#2} {#3} {#4} }
+ { \@@_exp_after_o:w #1 \exp:w }
+ }
+ }
+ {
+ \cs_new:Npn \@@_randint_narrow_e:nn #1#2
+ {
+ \__msg_kernel_expandable_error:nn { kernel } { fp-no-random }
+ \exp_after:wN \c_nan_fp \exp:w
+ }
+ \cs_new:Npn \@@_randint_wide_e:nn #1#2
+ {
+ \__msg_kernel_expandable_error:nn { kernel } { fp-no-random }
+ \exp_after:wN \c_nan_fp \exp:w
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macrocode}
+\__msg_kernel_new:nnn { kernel } { fp-no-random }
+ { Random~numbers~unavailable }
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</initex|package>
+% \end{macrocode}
+%
+% \end{implementation}
+%
+% \PrintChanges
+%
+% \PrintIndex
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx
index cc6299b8dfd..899c1a3bd6b 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx
@@ -36,7 +36,7 @@
%
%<*driver>
\documentclass[full]{l3doc}
-\GetIdInfo$Id: l3fp-round.dtx 6441 2016-03-24 10:11:59Z joseph $
+\GetIdInfo$Id: l3fp-round.dtx 6750 2016-11-21 01:24:26Z bruno $
{L3 Floating-point rounding}
\begin{document}
\DocInput{\jobname.dtx}
@@ -350,6 +350,7 @@
%
% ^^A todo: This macro is intermingled with l3fp-parse.
% ^^A todo: Add explanations.
+% ^^A todo: This macro f-expands rather than o-expands after itself, is that an issue?
% \begin{macro}[aux,EXP]{\@@_round_o:Nw}
% The |trunc|, |ceil| and |floor| functions expect one or two
% arguments (the second is $0$ by default), and the |round| function
@@ -360,8 +361,9 @@
\cs_new:Npn \@@_round_o:Nw #1#2 @
{
\if_case:w
- \__int_eval:w \@@_array_count:n {#2} - \c_one \__int_eval_end:
- \@@_round:Nwn #1 #2 {0} \exp:w
+ \__int_eval:w \@@_array_count:n {#2} \__int_eval_end:
+ \@@_round_no_arg_o:Nw #1 \exp:w
+ \or: \@@_round:Nwn #1 #2 {0} \exp:w
\or: \@@_round:Nww #1 #2 \exp:w
\else: \@@_round:Nwww #1 #2 @ \exp:w
\fi:
@@ -370,6 +372,21 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[aux, EXP]{\@@_round_no_arg_o:Nw}
+% \begin{macrocode}
+\cs_new:Npn \@@_round_no_arg_o:Nw #1
+ {
+ \cs_if_eq:NNTF #1 \@@_round_to_nearest:NNN
+ { \@@_error:nnnn { num-args } { round () } { 1 } { 3 } }
+ {
+ \@@_error:nffn { num-args }
+ { \@@_round_name_from_cs:N #1 () } { 1 } { 2 }
+ }
+ \exp_after:wN \c_nan_fp
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}[aux, EXP]{\@@_round:Nwww}
% Having three arguments is only allowed for |round|, not |trunc|,
% |ceil|, |floor|, so check for that case. If all is well, construct
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx
index 3b1843e9b43..2cbbe3e2cb6 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx
@@ -38,7 +38,7 @@
\documentclass[full]{l3doc}
%</driver>
%<*driver|package>
-\GetIdInfo$Id: l3fp.dtx 6685 2016-08-19 16:26:52Z bruno $
+\GetIdInfo$Id: l3fp.dtx 6761 2016-11-21 21:48:43Z joseph $
{L3 Floating points}
%</driver|package>
%<*driver>
@@ -91,6 +91,7 @@
% \item Boolean logic: negation $\mathop{!}x$, conjunction
% $x\mathop{\&\&}y$, disjunction $x\mathop{\vert\vert}y$, ternary
% operator $x\mathop{?}y\mathop{:}z$.
+% \item Random numbers: $\mathop{rand}()$, $\mathop{randint}(m,n)$.
% \item Exponentials: $\exp x$, $\ln x$, $x^y$.
% \item Trigonometry: $\sin x$, $\cos x$, $\tan x$, $\cot x$, $\sec
% x$, $\csc x$ expecting their arguments in radians, and
@@ -540,6 +541,50 @@
% \texttt{false}.
% \end{function}
%
+% \begin{function}[added = 2016-11-21, rEXP]
+% {\fp_step_function:nnnN}
+% \begin{syntax}
+% \cs{fp_step_function:nnnN} \Arg{initial value} \Arg{step} \Arg{final value} \meta{function}
+% \end{syntax}
+% This function first evaluates the \meta{initial value}, \meta{step}
+% and \meta{final value}, all of which should be floating point expressions.
+% The \meta{function} is then placed in front of each \meta{value}
+% from the \meta{initial value} to the \meta{final value} in turn
+% (using \meta{step} between each \meta{value}). The \meta{step} must
+% be non-zero. If the \meta{step} is positive, the loop stops when
+% the \meta{value} becomes larger than the \meta{final value}. If the
+% \meta{step} is negative, the loop stops when the \meta{value}
+% becomes smaller than the \meta{final value}. The \meta{function}
+% should absorb one numerical argument. For example
+% \begin{verbatim}
+% \cs_set:Npn \my_func:n #1 { [I~saw~#1] \quad }
+% \fp_step_function:nnnN { 1.0 } { 0.1 } { 1.5 } \my_func:n
+% \end{verbatim}
+% would print
+% \begin{quote}
+% [I saw 1.0] \quad
+% [I saw 1.1] \quad
+% [I saw 1.2] \quad
+% [I saw 1.3] \quad
+% [I saw 1.4] \quad
+% [I saw 1.5] \quad
+% \end{quote}
+% \end{function}
+%
+% \begin{function}[added = 2016-11-21]
+% {\fp_step_inline:nnnn}
+% \begin{syntax}
+% \cs{fp_step_inline:nnnn} \Arg{initial value} \Arg{step} \Arg{final value} \Arg{code}
+% \end{syntax}
+% This function first evaluates the \meta{initial value}, \meta{step}
+% and \meta{final value}, all of which should be floating point expressions.
+% Then for each \meta{value} from the \meta{initial value} to the
+% \meta{final value} in turn (using \meta{step} between each
+% \meta{value}), the \meta{code} is inserted into the input stream
+% with |#1| replaced by the current \meta{value}. Thus the
+% \meta{code} should define a function of one argument~(|#1|).
+% \end{function}
+%
% \section{Some useful constants, and scratch variables}
%
% \begin{variable}[added = 2012-05-08]{\c_zero_fp, \c_minus_zero_fp}
@@ -1135,6 +1180,35 @@
% $\sqrt{\text{\nan{}}}=\text{\nan{}}$.
% \end{function}
%
+% \begin{function}[added = 2016-11-20]{rand}
+% \begin{syntax}
+% \cs{fp_eval:n} \{ |rand()| \}
+% \end{syntax}
+% Produces a pseudo-random floating-point number (multiple of
+% $10^{-16}$) between $0$~included and $1$~excluded.
+% \begin{texnote}
+% This is a wrapper around \tn{pdfuniformdeviate}. The random seed
+% can be queried using \tn{pdfrandomseed} and set using
+% \tn{pdfsetrandomseed}.
+% \end{texnote}
+% \end{function}
+%
+% \begin{function}[added = 2016-11-20]{randint}
+% \begin{syntax}
+% \cs{fp_eval:n} \{ |randint(| \meta{fpexpr} |)| \}
+% \cs{fp_eval:n} \{ |randint(| \meta{fpexpr_1} , \meta{fpexpr_2} |)| \}
+% \end{syntax}
+% Produces a pseudo-random integer between $1$~and \meta{fpexpr} or
+% between \meta{fpexpr_1} and \meta{fpexpr_2} inclusive. The bounds
+% must be integers in the range $(-10^{16},10^{16})$ and the first
+% must be smaller or equal to the second.
+% \begin{texnote}
+% This is a wrapper around \tn{pdfuniformdeviate}. The random seed
+% can be queried using \tn{pdfrandomseed} and set using
+% \tn{pdfsetrandomseed}.
+% \end{texnote}
+% \end{function}
+%
% \begin{variable}[tested = m3fp-parse001]{inf, nan}
% The special values $+\infty$, $-\infty$, and \nan{} are represented
% as \texttt{inf}, \texttt{-inf} and \texttt{nan} (see \cs{c_inf_fp},