Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
417 jrf 1
#include "CGLA.h"
2
 
3
namespace
4
{
5
  unsigned int seed = 1;
6
  unsigned int current_rand = 1;
7
}
8
 
9
namespace CGLA
10
{
11
  void gel_srand(unsigned int s)
12
  {
13
    seed = current_rand = s;
14
  }
15
 
16
  unsigned int gel_rand(unsigned int k)
17
  {
18
    unsigned int b = 3125;
19
    unsigned int c = 49;
20
    unsigned int result = seed;
21
 
22
    for (;k > 0;k>>=1)
23
    {
24
      if (k & 1) result = result * b + c;
25
      c += b * c;
26
      b *= b;
27
    }
28
    return result;
29
  }
30
 
31
  unsigned int gel_rand()
32
  {
33
    unsigned int b = 3125;
34
    unsigned int c = 49;
35
 
36
    current_rand = current_rand*b + c;
37
    return current_rand;
38
  }
39
}