#ifndef __AMSCU_RANDOM_HPP__ #define __AMSCU_RANDOM_HPP__ namespace amscuda { // Random Number Gerneators // faster floating point hash function used in fractal generators __device__ __host__ float fhash1d_su(float x); __device__ __host__ float fhash3d_su(float x, float y, float z); __device__ __host__ float fhash4d_su(float x, float y, float z, float w); ////////////////////////////////////////////////// // Deterministic Pseudorandom int32_t Generator // ////////////////////////////////////////////////// //Next seed in simple 32 bit integer deterministic psuedo-rand generator __host__ __device__ void dpr32_nextseed(int32_t *rseed_inout); //Simple 32 bit integer deterministic pseudo-random generator // *not* for cryptography // Frequency of generated floats should be uniform [0,1) __host__ __device__ float dpr32_randf(int32_t *rseed_inout); //box muller standard normal pseudorandom variable __host__ __device__ float dpr32_randnf(int32_t *rseed_inout); ////////////////////////////////////////////////// // Deterministic Pseudorandom int64_t Generator // ////////////////////////////////////////////////// //operates without side-effects on explicit seed for threaded use //deterministic pseudorandom number generator - takes seed and returns next seed __host__ __device__ void dpr64_nextseed(int64_t *seedinout); //deterministic pseudorandom number generator - takes seed and returns next seed //returns uniformly distributed double __host__ __device__ double dpr64_randd(int64_t *seedinout); __host__ __device__ float dpr64_randf(int64_t *seedinout); void test_dprg64(); void test_dprg32(); }; //end namespace amscuda #endif