Function for Allocating a Random Number Stream
Allocate a random number stream.
Interface Definition
int vslLeapfrogStream(VSLStreamStatePtr stream, const SizeType k, const SizeType nstreams);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
stream |
Pointer of the VSLStreamStatePtr type |
Pointer to the random number stream structure. |
Input/Output |
k |
SizeType |
Node subscript. |
Input |
nstreams |
SizeType |
Maximum number of nodes. |
Input |
Dependencies
#include "krng.h"
Examples
#include <stdio.h>
#include <stdlib.h>
#include "krng.h"
int main()
{
/* initialize stream with given BRNG type and seed */
VSLStreamStatePtr stream;
unsigned seed = 42;
int errcode = vslNewStream(&stream, VSL_BRNG_MCG59, seed);
if (errcode != VSL_STATUS_OK) {
fprintf(stderr, "Failure in newstream\n");
return 0;
}
int n = 10;
int nstreams = 10;
if (vslLeapfrogStream(stream, n, nstreams)) {
fprintf(stderr, "Failure in vslLeapfrogStream, skip = %d\n", forward_skip);
return 0;
}
/* deinitialize the stream */
errcode = vslDeleteStream(&stream);
if (errcode != VSL_STATUS_OK) {
fprintf(stderr, "Failure in deleting stream\n");
return 0;
}
return 0;
}
Parent topic: High-performance Functions