1 /* === S Y N F I G ========================================================= */
3 ** \brief Template Header
5 ** $Id: guid.h 335 2007-03-16 00:39:09Z dooglus $
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === S T A R T =========================================================== */
26 #ifndef __SYNFIG_QUICK_RNG_H
27 #define __SYNFIG_QUICK_RNG_H
29 /* === H E A D E R S ======================================================= */
33 /* === M A C R O S ========================================================= */
35 /* === T Y P E D E F S ===================================================== */
37 /* === C L A S S E S & S T R U C T S ======================================= */
39 // A fast 32-bit linear congruential random number generator
44 quick_rng(uint32_t seed=0):next(seed) { }
46 void set_seed(uint32_t x)
53 static const uint32_t a(1664525);
54 static const uint32_t c(1013904223);
66 static const float m(int(65535));
68 return float(i16())/m;
71 uint32_t operator()(const uint32_t& m)
83 /* === E N D =============================================================== */