Mercurial > hg > octave-terminal
changeset 7535:bda16af4fd2f
oct-rand.cc (get_dist_id): initialize retval
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2008 18:45:57 -0500 |
parents | ef755c763b62 |
children | 4dda6fbc8ba6 |
files | liboctave/ChangeLog liboctave/oct-rand.cc |
diffstat | 2 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,5 +1,10 @@ 2008-02-26 John W. Eaton <jwe@octave.org> + * oct-rand.cc (unknown_dist): New dist type. + (uniform_dist, normal_dist, expon_dist, poisson_dist, gamma_dist): + Use static const int instead of #define. + (get_dist_id): Default retval is unknown_dist. + * oct-rand.cc (rand_states): New static variable. (initialize_rand_states, get_dist_id, get_internal_state, set_internal_state, switch_to_generator, save_state): New functions.
--- a/liboctave/oct-rand.cc +++ b/liboctave/oct-rand.cc @@ -39,13 +39,12 @@ #include "randgamma.h" #include "mach-info.h" -// Possible distributions of random numbers. This was handled with an -// enum, but unwind_protecting that doesn't work so well. -#define uniform_dist 1 -#define normal_dist 2 -#define expon_dist 3 -#define poisson_dist 4 -#define gamma_dist 5 +static const int unknown_dist = 0; +static const int uniform_dist = 1; +static const int normal_dist = 2; +static const int expon_dist = 3; +static const int poisson_dist = 4; +static const int gamma_dist = 5; // Current distribution of random numbers. static int current_distribution = uniform_dist; @@ -188,7 +187,7 @@ static int get_dist_id (const std::string& d) { - int retval; + int retval = unknown_dist; if (d == "uniform" || d == "rand") retval = uniform_dist;