Exemplo n.º 1
0
void get_rand_32(void)
{
	x = WELLRNG19937a() * bin32m;
	if (x == 0) {
		x = bin33m;
	}
}
Exemplo n.º 2
0
void	well_random_engine_test()
{
	unsigned int init[1391] = { 0, };
	for( int i = 0; i < sizeof( init )/sizeof( init[0] ); ++i )
	{
		init[i] = rand();
	}
	
	#define MASK32  0xffffffffU
	#define JMAX 16

	init[0] = 123456789;
	for( int i = 1; i < JMAX; ++i )
		init[i] = (663608941 * init[i - 1]) & MASK32;



	InitWELLRNG512a( init );
	InitWELLRNG1024a( init );
	InitWELLRNG19937a( init );
	InitWELLRNG44497a( init );
	g_rand();

	{
		DWORD start = GetTickCount();
		for( int i = 0; i < total_rand_count; ++i )
		{
			double r = g_rand.gen();
			r;
		}
		DWORD runing = GetTickCount() - start;
		std::wcout << L"g_rand run time: " << runing << std::endl;
	}

	{
		DWORD start = GetTickCount();
		for( int i = 0; i < total_rand_count; ++i )
		{
			double r = WELLRNG512a();
			r;
		}
		DWORD runing = GetTickCount() - start;
		std::wcout << L"WELL512 run time: " << runing << std::endl;
	}

	{
		DWORD start = GetTickCount();
		for( int i = 0; i < total_rand_count; ++i )
		{
			double r = WELLRNG1024a();
			r;
		}
		DWORD runing = GetTickCount() - start;
		std::wcout << L"WELL1024 run time: " << runing << std::endl;
	}

	{
		DWORD start = GetTickCount();
		for( int i = 0; i < total_rand_count; ++i )
		{
			double r = WELLRNG19937a();
			r;
		}
		DWORD runing = GetTickCount() - start;
		std::wcout << L"WELL19937 run time: " << runing << std::endl;
	}

	{
		DWORD start = GetTickCount();
		for( int i = 0; i < total_rand_count; ++i )
		{
			double r = WELLRNG44497a();
			r;
		}
		DWORD runing = GetTickCount() - start;
		std::wcout << L"WELL44497 run time: " << runing << std::endl;
	}

}