Subversion Repositories gelsvn

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include "CGLA.h"

namespace
{
  unsigned int seed = 1;
  unsigned int current_rand = 1;
}

namespace CGLA
{
  void gel_srand(unsigned int s)
  {
    seed = current_rand = s;
  }

  unsigned int gel_rand(unsigned int k)
  {
    unsigned int b = 3125;
    unsigned int c = 49;
    unsigned int result = seed;

    for (;k > 0;k>>=1)
    {
      if (k & 1) result = result * b + c;
      c += b * c;
      b *= b;
    }
    return result;
  }

  unsigned int gel_rand()
  {
    unsigned int b = 3125;
    unsigned int c = 49;

    current_rand = current_rand*b + c;
    return current_rand;
  }
}

Generated by GNU Enscript 1.6.6.