aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/llrand.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmath/llrand.h')
-rw-r--r--linden/indra/llmath/llrand.h132
1 files changed, 0 insertions, 132 deletions
diff --git a/linden/indra/llmath/llrand.h b/linden/indra/llmath/llrand.h
deleted file mode 100644
index 0a28213..0000000
--- a/linden/indra/llmath/llrand.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/**
2 * @file llrand.h
3 * @brief Information, functions, and typedefs for randomness.
4 *
5 * $LicenseInfo:firstyear=2000&license=viewergpl$
6 *
7 * Copyright (c) 2000-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_LLRAND_H
33#define LL_LLRAND_H
34
35#include <boost/random/lagged_fibonacci.hpp>
36#include <boost/random/mersenne_twister.hpp>
37
38/**
39 * Use the boost random number generators if you want a stateful
40 * random numbers. If you want more random numbers, use the
41 * c-functions since they will generate faster/better randomness
42 * across the process.
43 *
44 * I tested some of the boost random engines, and picked a good double
45 * generator and a good integer generator. I also took some timings
46 * for them on linux using gcc 3.3.5. The harness also did some other
47 * fairly trivial operations to try to limit compiler optimizations,
48 * so these numbers are only good for relative comparisons.
49 *
50 * usec/inter algorithm
51 * 0.21 boost::minstd_rand0
52 * 0.039 boost:lagged_fibonacci19937
53 * 0.036 boost:lagged_fibonacci607
54 * 0.44 boost::hellekalek1995
55 * 0.44 boost::ecuyer1988
56 * 0.042 boost::rand48
57 * 0.043 boost::mt11213b
58 * 0.028 stdlib random()
59 * 0.05 stdlib lrand48()
60 * 0.034 stdlib rand()
61 * 0.020 the old & lame LLRand
62 */
63
64/**
65 *@brief Generate a float from [0, RAND_MAX).
66 */
67S32 ll_rand();
68
69/**
70 *@brief Generate a float from [0, val) or (val, 0].
71 */
72S32 ll_rand(S32 val);
73
74/**
75 *@brief Generate a float from [0, 1.0).
76 */
77F32 ll_frand();
78
79/**
80 *@brief Generate a float from [0, val) or (val, 0].
81 */
82F32 ll_frand(F32 val);
83
84/**
85 *@brief Generate a double from [0, 1.0).
86 */
87F64 ll_drand();
88
89/**
90 *@brief Generate a double from [0, val) or (val, 0].
91 */
92F64 ll_drand(F64 val);
93
94/**
95 * @brief typedefs for good boost lagged fibonacci.
96 * @see boost::lagged_fibonacci
97 *
98 * These generators will quickly generate doubles. Note the memory
99 * requirements, because they are somewhat high. I chose the smallest
100 * one, and one comparable in speed but higher periodicity without
101 * outrageous memory requirements.
102 * To use:
103 * LLRandLagFib607 foo((U32)time(NULL));
104 * double bar = foo();
105 */
106
107typedef boost::lagged_fibonacci607 LLRandLagFib607;
108/**<
109 * lengh of cycle: 2^32,000
110 * memory: 607*sizeof(double) (about 5K)
111 */
112
113typedef boost::lagged_fibonacci2281 LLRandLagFib2281;
114/**<
115 * lengh of cycle: 2^120,000
116 * memory: 2281*sizeof(double) (about 17K)
117 */
118
119/**
120 * @breif typedefs for a good boost mersenne twister implementation.
121 * @see boost::mersenne_twister
122 *
123 * This fairly quickly generates U32 values
124 * To use:
125 * LLRandMT19937 foo((U32)time(NULL));
126 * U32 bar = foo();
127 *
128 * lengh of cycle: 2^19,937-1
129 * memory: about 2496 bytes
130 */
131typedef boost::mt11213b LLRandMT19937;
132#endif