# NewStream

Creates and initializes a random stream.

## Syntax

Fortran:

status = vslnewstream( stream, brng, seed )

C:

status = vslNewStream( &stream, brng, seed );

## Description

For a basic generator with number brng, this function creates a new stream and initializes it with a 32-bit seed. The seed is an initial value used to select a particular sequence generated by the basic generator brng. The function is also applicable for generators with multiple initial conditions. See VSL Notes for a more detailed description of stream initialization for different basic generators.

### Note

This function is not applicable for abstract basic random number generators. Please use `vsl` iNewAbstractStream, `vsl` sNewAbstractStream or `vsl` dNewAbstractStream to utilize integer, single-precision or double-precision external random data respectively.

## Input Parameters

Name | Type | Description
--- | --- | ---
brng | FORTRAN: INTEGER, INTENT(IN) C: int | Index of the basic generator to initialize the stream. See Table Values of brng parameter for specific value.
seed | FORTRAN: INTEGER, INTENT(IN) C: unsigned int | Initial condition of the stream. In the case of a quasi-random number generator seed parameter is used to set the dimension. If the dimension is greater than the dimension that brng can support or is less than 1, then the dimension is assumed to be equal to 1.

## Output Parameters

Name | Type | Description
--- | --- | ---
stream | FORTRAN: TYPE(VSL_STREAM_STATE), INTENT(OUT) C: VSLStreamStatePtr* | Stream state descriptor

## Return Values

VSL_ERROR_OK, VSL_STATUS_OK
  Indicates no error, execution is successful.
VSL_ERROR_INVALID_BRNG_INDEX
  BRNG index is invalid.
VSL_ERROR_MEM_FAILURE

  System cannot allocate memory for stream.

Parent topic: Service Routines