#ifndef RND_H_INCLUDED
#define RND_H_INCLUDED 1

// Copyright (C) 2005 Zbynek Winkler, zw at robotika cz
// Licensed to the public under the terms of the GNU GPL 2

#include <stdint.h>

class rnd
{
public:
	uint32_t m_seed;
public:
	rnd(uint32_t in_seed=1) : m_seed(in_seed) {}
	uint32_t rand() { return (((m_seed = m_seed * 214013L + 2531011L) >> 16) & 0x7fff); }
	double operator () () { return uniform(); }
	double uniform()
	{
		return 2.0*rand() / ((double)0x7fff+1) - 1;
	}
	void srand(uint32_t a_seed)
	{
		m_seed = a_seed;
	}
};


#endif

