src/glprng.h
changeset 1 c445c931472f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/glprng.h	Mon Dec 06 13:09:21 2010 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* glprng.h (pseudo-random number generator) */
     1.5 +
     1.6 +/***********************************************************************
     1.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
     1.8 +*
     1.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
    1.10 +*  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
    1.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
    1.12 +*  E-mail: <mao@gnu.org>.
    1.13 +*
    1.14 +*  GLPK is free software: you can redistribute it and/or modify it
    1.15 +*  under the terms of the GNU General Public License as published by
    1.16 +*  the Free Software Foundation, either version 3 of the License, or
    1.17 +*  (at your option) any later version.
    1.18 +*
    1.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
    1.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    1.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
    1.22 +*  License for more details.
    1.23 +*
    1.24 +*  You should have received a copy of the GNU General Public License
    1.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
    1.26 +***********************************************************************/
    1.27 +
    1.28 +#ifndef GLPRNG_H
    1.29 +#define GLPRNG_H
    1.30 +
    1.31 +typedef struct RNG RNG;
    1.32 +
    1.33 +struct RNG
    1.34 +{     /* Knuth's portable pseudo-random number generator */
    1.35 +      int A[56];
    1.36 +      /* pseudo-random values */
    1.37 +      int *fptr;
    1.38 +      /* the next A value to be exported */
    1.39 +};
    1.40 +
    1.41 +#define rng_create_rand _glp_rng_create_rand
    1.42 +RNG *rng_create_rand(void);
    1.43 +/* create pseudo-random number generator */
    1.44 +
    1.45 +#define rng_init_rand _glp_rng_init_rand
    1.46 +void rng_init_rand(RNG *rand, int seed);
    1.47 +/* initialize pseudo-random number generator */
    1.48 +
    1.49 +#define rng_next_rand _glp_rng_next_rand
    1.50 +int rng_next_rand(RNG *rand);
    1.51 +/* obtain pseudo-random integer in the range [0, 2^31-1] */
    1.52 +
    1.53 +#define rng_unif_rand _glp_rng_unif_rand
    1.54 +int rng_unif_rand(RNG *rand, int m);
    1.55 +/* obtain pseudo-random integer in the range [0, m-1] */
    1.56 +
    1.57 +#define rng_delete_rand _glp_rng_delete_rand
    1.58 +void rng_delete_rand(RNG *rand);
    1.59 +/* delete pseudo-random number generator */
    1.60 +
    1.61 +#define rng_unif_01 _glp_rng_unif_01
    1.62 +double rng_unif_01(RNG *rand);
    1.63 +/* obtain pseudo-random number in the range [0, 1] */
    1.64 +
    1.65 +#define rng_uniform _glp_rng_uniform
    1.66 +double rng_uniform(RNG *rand, double a, double b);
    1.67 +/* obtain pseudo-random number in the range [a, b] */
    1.68 +
    1.69 +#endif
    1.70 +
    1.71 +/* eof */