# Service Routines

Stream handling comprises routines for creating, deleting, or copying the streams and getting the index of a basic generator. A random stream can also be saved to and then read from a binary file. Table “Service Routines” lists all available service routines

Service Routines
Routine | Short Description
--- | ---
NewStream | Creates and initializes a random stream.
NewStreamEx | Creates and initializes a random stream for the generators with multiple initial conditions.
iNewAbstractStream | Creates and initializes an abstract random stream for integer arrays.
dNewAbstractStream | Creates and initializes an abstract random stream for double precision floating-point arrays.
sNewAbstractStream | Creates and initializes an abstract random stream for single precision floating-point arrays.
DeleteStream | Deletes previously created stream.
CopyStream | Copies a stream to another stream.
CopyStreamState | Creates a copy of a random stream state.
SaveStreamF | Writes a stream to a binary file.
LoadStreamF | Reads a stream from a binary file.
LeapfrogStream | Initializes the stream by the leapfrog method to generate a subsequence of the original sequence.
SkipAheadStream | Initializes the stream by the skip-ahead method.
GetStreamStateBrng | Obtains the index of the basic generator responsible for the generation of a given random stream.
GetNumRegBrngs | Obtains the number of currently registered basic generators.

### Note

In the above table, the vsl prefix in the function names is omitted. In the function reference this prefix is always used in function prototypes and code examples.

Most of the generator-based work comprises three basic steps:

1. Creating and initializing a stream (NewStream, NewStreamEx, CopyStream, CopyStreamState, LeapfrogStream, SkipAheadStream).

2. Generating random numbers with given distribution, see Distribution Generators.

3. Deleting the stream (DeleteStream).

Note that you can concurrently create multiple streams and obtain random data from one or several generators by using the stream state. You must use the DeleteStream function to delete all the streams afterwards.