# dNewAbstractStream

Creates and initializes an abstract random stream for double precision floating-point arrays.

## Syntax

Fortran:

status = vsldnewabstractstream( stream, n, dbuf, a, b, dcallback )

C:

status = vsldNewAbstractStream( &stream, n, dbuf, a, b, dcallback );

## Description

This function creates a new abstract stream for double precision floating-point arrays with random numbers of the uniform distribution over interval (a,b). The function associates the stream with a double precision array dbuf and user's callback function dcallback that is intended for updating of dbuf content.

## Input Parameters

Name | Type | Description
--- | --- | ---
n | FORTRAN: INTEGER, INTENT(IN) C: int | Size of the array dbuf
dbuf | FORTRAN: DOUBLE PRECISION, INTENT(IN) C: double* | Array of n double precision floating-point random numbers with uniform distribution over interval (a,b)
a | FORTRAN: DOUBLE PRECISION, INTENT(IN) C: double | Left boundary a
b | FORTRAN: DOUBLE PRECISION, INTENT(IN) C: double | Right boundary b
dcallback | FORTRAN: See Note below C: See Note below | FORTRAN: Address of the callback function used for update of the array dbuf C: Pointer to the callback function used for update of the array dbuf

## Output Parameters

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

### Note

Format of the callback function in Fortran:
`INTEGER FUNCTION DUPDATEFUNC[C]( stream, n, dbuf, nmin, nmax, idx )`
`TYPE(VSL_STREAM_STATE),POINTER :: stream[reference]`
`INTEGER(KIND=4),INTENT(IN) :: n[reference]`
`REAL(KIND=8), INTENT(OUT) :: dbuf[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 dUpdateFunc( VSLStreamStatePtr stream, int* n, double dbuf[], int* nmin, int* nmax, int* idx );`

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

dcallback Callback Function Parameters
Parameters | Short Description
--- | ---
stream | Abstract stream descriptor
n | Size of dbuf
dbuf | 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 dbuf 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