COIN-OR::LEMON - Graph Library

source: glpk-cmake/src/glprng.h @ 1:c445c931472f

Last change on this file since 1:c445c931472f was 1:c445c931472f, checked in by Alpar Juttner <alpar@…>, 14 years ago

Import glpk-4.45

  • Generated files and doc/notes are removed
File size: 2.2 KB
Line 
1/* glprng.h (pseudo-random number generator) */
2
3/***********************************************************************
4*  This code is part of GLPK (GNU Linear Programming Kit).
5*
6*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7*  2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9*  E-mail: <mao@gnu.org>.
10*
11*  GLPK is free software: you can redistribute it and/or modify it
12*  under the terms of the GNU General Public License as published by
13*  the Free Software Foundation, either version 3 of the License, or
14*  (at your option) any later version.
15*
16*  GLPK is distributed in the hope that it will be useful, but WITHOUT
17*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19*  License for more details.
20*
21*  You should have received a copy of the GNU General Public License
22*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23***********************************************************************/
24
25#ifndef GLPRNG_H
26#define GLPRNG_H
27
28typedef struct RNG RNG;
29
30struct RNG
31{     /* Knuth's portable pseudo-random number generator */
32      int A[56];
33      /* pseudo-random values */
34      int *fptr;
35      /* the next A value to be exported */
36};
37
38#define rng_create_rand _glp_rng_create_rand
39RNG *rng_create_rand(void);
40/* create pseudo-random number generator */
41
42#define rng_init_rand _glp_rng_init_rand
43void rng_init_rand(RNG *rand, int seed);
44/* initialize pseudo-random number generator */
45
46#define rng_next_rand _glp_rng_next_rand
47int rng_next_rand(RNG *rand);
48/* obtain pseudo-random integer in the range [0, 2^31-1] */
49
50#define rng_unif_rand _glp_rng_unif_rand
51int rng_unif_rand(RNG *rand, int m);
52/* obtain pseudo-random integer in the range [0, m-1] */
53
54#define rng_delete_rand _glp_rng_delete_rand
55void rng_delete_rand(RNG *rand);
56/* delete pseudo-random number generator */
57
58#define rng_unif_01 _glp_rng_unif_01
59double rng_unif_01(RNG *rand);
60/* obtain pseudo-random number in the range [0, 1] */
61
62#define rng_uniform _glp_rng_uniform
63double rng_uniform(RNG *rand, double a, double b);
64/* obtain pseudo-random number in the range [a, b] */
65
66#endif
67
68/* eof */
Note: See TracBrowser for help on using the repository browser.