aboutsummaryrefslogtreecommitdiff
path: root/src/stable/randombasic.h
blob: 8fd96b1324fa061cca811ded1cc8b14981059fc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (C) 2007-2023 Xagasoft, All rights reserved.
 *
 * This file is part of the libbu++ library and is released under the
 * terms of the license contained in the file LICENSE.
 */
#ifndef BU_RANDOM_BASIC_H
#define BU_RANDOM_BASIC_H

#include "bu/randombase.h"

namespace Bu
{
    /**
     * Basic Linear Congruential Generator.  This is one of the simplest and
     * most common pseudo-random number generators out there.  It's simple,
     * fast, and does a decent job if you don't have any stastistical
     * requirements other than "random looking."  This is the algorithm included
     * as the default random number generator in most standard libraries,
     * although this one uses larger numbers internally, has a longer period,
     * and more even distrubition of randomness accross it's bits than most
     * implementations.
     *
     * The base values were published by Donald Knuth.
     */
    class RandomBasic : public RandomBase
    {
    public:
        RandomBasic( int32_t iSeed=0 );
        virtual ~RandomBasic();

        virtual void seed( int32_t iSeed );

        virtual int32_t rand();

    private:
        int64_t x;
    };
};

#endif