CXXR (C++ R)
Random.h
1 /*CXXR $Id: Random.h 1348 2013-02-25 17:49:03Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
17 /*
18  * R : A Computer Language for Statistical Data Analysis
19  * Copyright (C) 1998-2011 The R Core Team
20  *
21  * This program is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU Lesser General Public License as published by
23  * the Free Software Foundation; either version 2.1 of the License, or
24  * (at your option) any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  * GNU Lesser General Public License for more details.
30  *
31  * You should have received a copy of the GNU Lesser General Public License
32  * along with this program; if not, a copy is available at
33  * http://www.r-project.org/Licenses/
34  */
35 
36 #ifndef R_RANDOM_H
37 #define R_RANDOM_H
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include <R_ext/Boolean.h>
44 
45 typedef enum {
46  WICHMANN_HILL,
47  MARSAGLIA_MULTICARRY,
48  SUPER_DUPER,
49  MERSENNE_TWISTER,
50  KNUTH_TAOCP,
51  USER_UNIF,
52  KNUTH_TAOCP2,
53  LECUYER_CMRG
54 } RNGtype;
55 
56 /* Different kinds of "N(0,1)" generators :*/
57 typedef enum {
58  BUGGY_KINDERMAN_RAMAGE,
59  AHRENS_DIETER,
60  BOX_MULLER,
61  USER_NORM,
62  INVERSION,
63  KINDERMAN_RAMAGE
64 } N01type;
65 
66 
67 void GetRNGstate(void);
68 void PutRNGstate(void);
69 
70 double unif_rand(void);
71 /* These are also defined in Rmath.h */
72 double norm_rand(void);
73 double exp_rand(void);
74 
75 typedef unsigned int Int32;
76 double * user_unif_rand(void);
77 void user_unif_init(Int32);
78 int * user_unif_nseed(void);
79 int * user_unif_seedloc(void);
80 
81 double * user_norm_rand(void);
82 
83 void FixupProb(double *, int, int, Rboolean);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif /* R_RANDOM_H */