A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
randomEngine
ArrayFire Functions | ArrayFire Functions by Category » Functions to create and modify Arrays » Functions to create arrays. » Random Number Generation

Functions to create, modify, use, and destroy randomEngine objects. More...

## Functions
AFAPI af_err | af_create_random_engine (af_random_engine *engine, af_random_engine_type rtype, unsigned long long seed)
| C Interface to create a random engine.
AFAPI af_err | af_retain_random_engine (af_random_engine *out, const af_random_engine engine)
| C Interface to retain a random engine.
AFAPI af_err | af_random_engine_set_type (af_random_engine *engine, const af_random_engine_type rtype)
| C Interface to change random engine type.
AFAPI af_err | af_random_engine_get_type (af_random_engine_type *rtype, const af_random_engine engine)
| C Interface to get random engine type.
AFAPI af_err | af_random_engine_set_seed (af_random_engine *engine, const unsigned long long seed)
| C Interface to set the seed of a random engine.
AFAPI af_err | af_random_engine_get_seed (unsigned long long *const seed, af_random_engine engine)
| C Interface to get the seed of a random engine.
AFAPI af_err | af_release_random_engine (af_random_engine engine)
| C Interface to release a random engine.

## Detailed Description

Functions to create, modify, use, and destroy randomEngine objects.

A af::randomEngine object can be used to generate psuedo random numbers using various types of random number generation algorithms defined by af::randomEngineType.

## Function Documentation

## ◆ af_create_random_engine()

AFAPI af_err af_create_random_engine | ( | af_random_engine * | engine,
|  | af_random_engine_type | rtype,
|  | unsigned long long | seed )

C Interface to create a random engine.

Parameters

  [out] | engine | pointer to the returned random engine object
  [in] | rtype | type of the random number generator
  [in] | seed | initializing seed of the random number generator

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ af_random_engine_get_seed()

AFAPI af_err af_random_engine_get_seed | ( | unsigned long long *const | seed,
|  | af_random_engine | engine )

C Interface to get the seed of a random engine.

Parameters

  [out] | seed | pointer to the returned seed
  [in] | engine | random engine object

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ af_random_engine_get_type()

AFAPI af_err af_random_engine_get_type | ( | af_random_engine_type * | rtype,
|  | const af_random_engine | engine )

C Interface to get random engine type.

Parameters

  [out] | rtype | type of the random number generator
  [in] | engine | random engine object

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ af_random_engine_set_seed()

AFAPI af_err af_random_engine_set_seed | ( | af_random_engine * | engine,
|  | const unsigned long long | seed )

C Interface to set the seed of a random engine.

Parameters

  [out] | engine | pointer to the returned random engine object
  [in] | seed | initializing seed of the random number generator

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ af_random_engine_set_type()

AFAPI af_err af_random_engine_set_type | ( | af_random_engine * | engine,
|  | const af_random_engine_type | rtype )

C Interface to change random engine type.

Parameters

  [in] | engine | random engine object
  [in] | rtype | type of the random number generator

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ af_release_random_engine()

AFAPI af_err af_release_random_engine | ( | af_random_engine | engine | ) |

C Interface to release a random engine.

Parameters

  [in] | engine | random engine object

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ af_retain_random_engine()

AFAPI af_err af_retain_random_engine | ( | af_random_engine * | out,
|  | const af_random_engine | engine )

C Interface to retain a random engine.

Parameters

  [out] | out | pointer to the returned random engine object
  [in] | engine | random engine object

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given