# iNewAbstractStream

Creates and initializes an abstract random stream for integer arrays.

## Syntax

Fortran:

status = vslinewabstractstream( stream, n, ibuf, icallback )

C:

status = vsliNewAbstractStream( &stream, n, ibuf, icallback );

## Description

This function creates a new abstract stream and associates it with an integer array ibuf and user's callback function icallback that is intended for updating of ibuf content.

## Input Parameters

Name | Type | Description
--- | --- | ---
n | FORTRAN: INTEGER, INTENT(IN) C: int | Size of the array ibuf
ibuf | FORTRAN: INTEGER, INTENT(IN) C: unsigned int* | Array of n 32-bit integers
icallback | FORTRAN: See Note below C: See Note below | FORTRAN: Address of the callback function used for ibuf update C: Pointer to the callback function used for ibuf update

## Output Parameters

Name | Type | Description
--- | --- | ---
stream | FORTRAN: TYPE(VSL_STREAM_STATE), TINTENT(OUT) C: VSLStreamStatePtr* | Descriptor of the stream state structure

### Note

Format of the callback function in Fortran:
`INTEGER FUNCTION IUPDATEFUNC[C]( stream, n, ibuf, nmin, nmax, idx )`
`TYPE(VSL_STREAM_STATE),POINTER :: stream[reference]`
`INTEGER(KIND=4),INTENT(IN) :: n[reference]`
`INTEGER(KIND=4),INTENT(OUT) :: ibuf[reference](0:n-1)`
`INTEGER(KIND=4),INTENT(IN) :: nmin[reference]`
`INTEGER(KIND=4),INTENT(IN) :: nmax[reference]`
`INTEGER(KIND=4),INTENT(IN) :: idx[reference]`

Format of the callback function in C:
`int iUpdateFunc( VSLStreamStatePtrstream, int* n, unsigned int ibuf[], int* nmin, int* nmax, int* idx );`

The callback function returns the number of elements in the array actually updated by the function. Tableicallback Callback Function Parameters gives the description of the callback function parameters.

icallback Callback Function Parameters
Parameters | Short Description
--- | ---
stream | Abstract stream descriptor
n | Size of ibuf
ibuf | Array of random numbers associated with the stream stream
nmin | Minimal quantity of numbers to update
nmax | Maximal quantity of numbers that can be updated
idx | Position in cyclic buffer ibuf to start update `0 ≤ idx < n`.

## Return Values

VSL_ERROR_OK, VSL_STATUS_OK
  Indicates no error, execution is successful.
VSL_ERROR_BAD_ARG
  Parameter n is not positive.
VSL_ERROR_MEM_FAILURE

  System cannot allocate memory for stream.

VSL_ERROR_NULL_PTR

  Either buffer or callback function parameter is a NULL pointer.

Parent topic: Service Routines