# HG changeset patch # User John W. Eaton # Date 1204069574 18000 # Node ID 3f5a67e8215c761b269dc217d8318a9e5bea9586 # Parent a4d0680f4ddad764bfaefc22ccd5a7d7b2e800a0 oct-rand.cc (get_dist_id): initialize retval diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,5 +1,10 @@ 2008-02-26 John W. Eaton + * 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. diff --git a/liboctave/oct-rand.cc b/liboctave/oct-rand.cc --- 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;