summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mplibdir/mp.w
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/mplibdir/mp.w')
-rw-r--r--Build/source/texk/web2c/mplibdir/mp.w24
1 files changed, 18 insertions, 6 deletions
diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w
index d40a45fda8c..a5b6a619cc4 100644
--- a/Build/source/texk/web2c/mplibdir/mp.w
+++ b/Build/source/texk/web2c/mplibdir/mp.w
@@ -1,4 +1,4 @@
-% $Id: mp.w 2060 2015-05-07 11:01:39Z luigi $
+% $Id: mp.w 2070 2015-10-06 10:35:23Z luigi $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -331,6 +331,7 @@ typedef struct mp_number_data mp_number;
typedef void (*convert_func) (mp_number *r);
typedef void (*m_log_func) (MP mp, mp_number *r, mp_number a);
typedef void (*m_exp_func) (MP mp, mp_number *r, mp_number a);
+typedef void (*m_unif_rand_func) (MP mp, mp_number *ret, mp_number x_orig);
typedef void (*m_norm_rand_func) (MP mp, mp_number *ret);
typedef void (*pyth_add_func) (MP mp, mp_number *r, mp_number a, mp_number b);
typedef void (*pyth_sub_func) (MP mp, mp_number *r, mp_number a, mp_number b);
@@ -475,6 +476,7 @@ typedef struct math_data {
n_arg_func n_arg;
m_log_func m_log;
m_exp_func m_exp;
+ m_unif_rand_func m_unif_rand;
m_norm_rand_func m_norm_rand;
pyth_add_func pyth_add;
pyth_sub_func pyth_sub;
@@ -2566,9 +2568,12 @@ void mp_new_randoms (MP mp) {
mp->j_random = 54;
}
-@ To consume a random fraction, the program below will say `|next_random|'.
+@ To consume a random fraction, the program below will say `|next_random|'.
+Now each number system has its own implementation,
+true to the original as much as possibile.
@c
+/* Unused.
static void mp_next_random (MP mp, mp_number *ret) {
if ( mp->j_random==0 )
mp_new_randoms(mp);
@@ -2576,7 +2581,7 @@ static void mp_next_random (MP mp, mp_number *ret) {
decr(mp->j_random);
number_clone (*ret, mp->randoms[mp->j_random]);
}
-
+*/
@ To produce a uniform random number in the range |0<=u<x| or |0>=u>x|
or |0=u=x|, given a |scaled| value~|x|, we proceed as shown here.
@@ -2584,10 +2589,15 @@ or |0=u=x|, given a |scaled| value~|x|, we proceed as shown here.
Note that the call of |take_fraction| will produce the values 0 and~|x|
with about half the probability that it will produce any other particular
values between 0 and~|x|, because it rounds its answers.
+This is the original one,
+that stays as reference:
+As said before, now each number system has its own implementation.
+
@c
+/*Unused.
static void mp_unif_rand (MP mp, mp_number *ret, mp_number x_orig) {
- mp_number y; /* trial value */
+ mp_number y; // trial value
mp_number x, abs_x;
mp_number u;
new_fraction (y);
@@ -2612,7 +2622,7 @@ static void mp_unif_rand (MP mp, mp_number *ret, mp_number x_orig) {
free_number (x);
free_number (y);
}
-
+*/
@ Finally, a normal deviate with mean zero and unit standard deviation
can readily be obtained with the ratio method (Algorithm 3.4.1R in
@@ -10965,6 +10975,7 @@ This first set goes into the header
@d n_arg(R,A,B) (((math_data *)(mp->math))->n_arg)(mp,&(R),A,B)
@d m_log(R,A) (((math_data *)(mp->math))->m_log)(mp,&(R),A)
@d m_exp(R,A) (((math_data *)(mp->math))->m_exp)(mp,&(R),A)
+@d m_unif_rand(R,A) (((math_data *)(mp->math))->m_unif_rand)(mp,&(R),A)
@d m_norm_rand(R) (((math_data *)(mp->math))->m_norm_rand)(mp,&(R))
@d velocity(R,A,B,C,D,E) (((math_data *)(mp->math))->velocity)(mp,&(R),A,B,C,D,E)
@d ab_vs_cd(R,A,B,C,D) (((math_data *)(mp->math))->ab_vs_cd)(mp,&(R),A,B,C,D)
@@ -24861,7 +24872,8 @@ static void mp_do_unary (MP mp, quarterword c) {
{
mp_number vvx;
new_number (vvx);
- mp_unif_rand (mp, &vvx, cur_exp_value_number ());
+ /*mp_unif_rand (mp, &vvx, cur_exp_value_number ());*/
+ m_unif_rand (vvx, cur_exp_value_number ());
set_cur_exp_value_number (vvx);
free_number (vvx);
}