# rng.cu File Reference

Uniform and Normal RNG Implemented in CUDA as device functions. More...

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <limits.h>`
`#include <math.h>`
`#include <unistd.h>`
`#include <fcntl.h>`
`#include <float.h>`
`#include <sys/time.h>`

## Defines
#define | BLOCK_X 16
#define | BLOCK_Y 16
## Functions
__device__ float | d_randu (int *seed, int index)
__device__ float | d_randn (int *seed, int index)
int | main ()

## Detailed Description

Uniform and Normal RNG Implemented in CUDA as device functions.

Author:
  Michael Trotter & Matt Goodrum

## Function Documentation

__device__ float d_randn | ( | int * | seed,
|  | int | index |
| ) |  |  |

Generates a normally (Gaussian) distributed number using the Box-Muller transformation

Parameters:

  | seed | The provided seed array.
  | index | The index within the seed array that will be modified as a result of this function

Returns:
  A float in the range of FLOAT_MIN to FLOAT_MAX. This float is based on the modified seed value at index in the seed array.

See also:
  http://en.wikipedia.org/wiki/Box-Muller_transform

__device__ float d_randu | ( | int * | seed,
|  | int | index |
| ) |  |  |

Generates a uniformly distributed number in the range of [0, 1) using the Linear Congruential Generator (LCG)

Parameters:

  | seed | The provided seed array.
  | index | The index within the seed array that will be modified by this function.

Returns:
  A float in the range of [0,1). This float is based on the modified seed value at index in the seed array.

See also:
  http://en.wikipedia.org/wiki/Linear_congruential_generator

Note:
  GCC's values (M, A, C) for the LCG are used

int main | ( |  | ) |

A simple main that demonstrates how to setup the seed array for use

All Files Functions