Function for Copying a Random Number Stream
Copy a random number stream.
Interface Definition
int vslCopyStream(VSLStreamStatePtr *newStream, VSLStreamStatePtr stream);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
newStream |
VSLStreamStatePtr type |
New random number stream. |
Output |
stream |
Pointer of the VSLStreamStatePtr type |
Pointer to the random number stream structure to copy. |
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;
}
VSLStreamStatePtr stream2;
if (vslCopyStream(&stream2, stream)) {
fprintf(stderr, "Failure in vslCopyStream\n");
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