cnet v3.1.4

home
FAQ

cmdline options
topology files
attributes

datatypes
data structures
core API
support API

download/install

cnet's Application Programming Interface

NAME
CNET_srand, CNET_rand - generate pseudo-random numbers

SYNOPSIS
#include <cnet.h>

void CNET_srand(unsigned int seed);

long CNET_rand(void);

DESCRIPTION
Each node has its own pseudo-random number generator so that the frequency of requests for random numbers in one node does not interfere with those of other nodes.

CNET_srand seeds the current node's random number generator. A typical use is:

CNET_srand(nodeinfo.time_of_day.sec + nodeinfo.nodenumber);

CNET_rand returns the next long integer in the random sequence on [0..MAXLONG]. A typical use is:

even = (CNET_rand() % 2) == 0;

cnet employs the Mersenne Twister (MT19937) random number generator.

RETURN VALUE
CNET_srand always succeeds.
CNET_rand returns the next long integer in the random sequence on [0..MAXLONG].

SEE ALSO
CNET_newrand and CNET_nextrand
The Mersenne Twister home page.

cnet was written and is maintained by Chris McDonald (chris@csse.uwa.edu.au).

cnet development has been supported by an ACM-SIGCSE Special Project Grant, and an Australian Apple University Consortium Scholarship.