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_newrand, CNET_nextrand - generate pseudo-random numbers

SYNOPSIS
#include <cnet.h>

CnetRandom CNET_newrand(unsigned int seed);

long CNET_nextrand(CnetRandom stream);

DESCRIPTION
Each node may employ multiple independent pseudo-random sequences. CNET_newrand returns an opaque stream identifier for a new random sequence, and CNET_nextrand accepts the stream identifier to generate the next independent random number in that sequence on [0..MAXLONG]. A typical use is:

    CnetRandom  stream1, stream2;
    int         firstlink, alternatelink;

    stream1 = CNET_newrand(123);
    stream2 = CNET_newrand(456);

    .....

    firstlink   = CNET_nextrand(stream1) % nodeinfo.nlinks + 1;
    do {
        alternatelink   = CNET_nextrand(stream2) % nodeinfo.nlinks + 1;
    } while (alternatelink == firstlink);

The independent random sequences may be generated at different rates without interfering with one another.

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

RETURN VALUE
CNET_newrand returns a new random stream identifier.
CNET_nextrand returns the next long integer in the random sequence on [0..MAXLONG].

SEE ALSO
CNET_srand and CNET_rand
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.