Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Random.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Alexander Dietz, Jolien Creighton
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20#ifndef _LAL_RANDOM_H
21#define _LAL_RANDOM_H
22
23#include <lal/LALDatatypes.h>
24#include <lal/AVFactories.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30
31/**
32 * \defgroup Random_h Header Random.h
33 * \ingroup lal_utilities
34 * \author Creighton, J. D. E. and Tibbits, M. M.
35 *
36 * \brief Generates random numbers.
37 *
38 * ### Synopsis ###
39 *
40 * \code
41 * #include <lal/Random.h>
42 * \endcode
43 *
44 * This header covers the routines for generating random numbers.
45 *
46 */
47/** @{ */
48
49/**\name Error Codes */
50/** @{ */
51#define RANDOMH_ENULL 1 /**< Null pointer */
52#define RANDOMH_ENNUL 2 /**< Non-null pointer */
53#define RANDOMH_ESIZE 4 /**< Invalid size */
54#define RANDOMH_ELNTH 8 /**< Must have more than one data point */
55#define RANDOMH_ESEGZ 16 /**< Invalid number of segments */
56#define RANDOMH_ENUMZ 32 /**< Invalid number of points in segment */
57#define RANDOMH_EALOC 64 /**< Memory Allocation Error */
58#define RANDOMH_EINIT 128 /**< Params must be initialized with CreateParams first */
59#define RANDOMH_EZERO 256 /**< Output Vector length must be greater than zero */
60#define RANDOMH_ESEED 512 /**< Improper seed value */
61/** @} */
62
63/** @} */
64
65/** \cond DONT_DOXYGEN */
66#define RANDOMH_MSGENULL "Null pointer"
67#define RANDOMH_MSGENNUL "Non-null pointer"
68#define RANDOMH_MSGESIZE "Invalid size"
69#define RANDOMH_MSGELNTH "Must have more than one data point"
70#define RANDOMH_MSGESEGZ "Invalid number of segments"
71#define RANDOMH_MSGENUMZ "Invalid number of points in segment"
72#define RANDOMH_MSGEALOC "Memory Allocation Error"
73#define RANDOMH_MSGEINIT "Params must be initialized with CreateParams first"
74#define RANDOMH_MSGEZERO "Output Vector length must be greater than zero"
75#define RANDOMH_MSGESEED "Improper seed value"
76/** \endcond */
77
78/**
79 * \ingroup Random_h
80 * \brief This structure contains the parameters necessary for generating the current
81 * sequence of random numbers (based on the initial seed).
82 * \note The contents should not be manually adjusted.
83 */
84typedef struct
85tagRandomParams
86{
89 INT4 v[32];
90}
92
93typedef struct tagMTRandomParams MTRandomParams;
94
95
98void XLALResetRandomParams( RandomParams *params, INT4 seed );
101int XLALNormalDeviates( REAL4Vector *deviates, RandomParams *params );
103
104void
107 RandomParams **params,
108 INT4 seed
109 );
110
111void
114 RandomParams **params
115 );
116
117void
120 REAL4 *deviate,
121 RandomParams *params
122 );
123
124void
127 REAL4Vector *deviates,
128 RandomParams *params
129 );
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* _LAL_RANDOM_H */
struct tagMTRandomParams MTRandomParams
Definition: Random.h:93
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
REAL4 XLALNormalDeviate(RandomParams *params)
Definition: Random.c:234
INT4 XLALBasicRandom(INT4 i)
Definition: Random.c:92
RandomParams * XLALCreateRandomParams(INT4 seed)
Definition: Random.c:102
void LALCreateRandomParams(LALStatus *status, RandomParams **params, INT4 seed)
Definition: Random.c:266
REAL4 XLALUniformDeviate(RandomParams *params)
Definition: Random.c:146
void XLALDestroyRandomParams(RandomParams *params)
Definition: Random.c:140
void LALNormalDeviates(LALStatus *status, REAL4Vector *deviates, RandomParams *params)
Definition: Random.c:333
int XLALNormalDeviates(REAL4Vector *deviates, RandomParams *params)
Definition: Random.c:171
void LALUniformDeviate(LALStatus *status, REAL4 *deviate, RandomParams *params)
Definition: Random.c:309
void LALDestroyRandomParams(LALStatus *status, RandomParams **params)
Definition: Random.c:290
void XLALResetRandomParams(RandomParams *params, INT4 seed)
Definition: Random.c:122
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
Vector of type REAL4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:145
This structure contains the parameters necessary for generating the current sequence of random number...
Definition: Random.h:86
INT4 y
Definition: Random.h:88
INT4 i
Definition: Random.h:87