C Configuration Space and Tuning Library (CCS)
Loading...
Searching...
No Matches
Functions
rng.h File Reference

CCS rng define random number generators. More...

#include <gsl/gsl_rng.h>
Include dependency graph for rng.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ccs_result_t ccs_create_rng (ccs_rng_t *rng_ret)
 Create a new random number generator using the gsl default type (see gsl_rng_default).
 
ccs_result_t ccs_create_rng_with_type (const gsl_rng_type *rng_type, ccs_rng_t *rng_ret)
 Create a new random number generator using the provided gsl type (see gsl_rng_type).
 
ccs_result_t ccs_rng_get_type (ccs_rng_t rng, const gsl_rng_type **rng_type_ret)
 Get the gsl type of a random number generator.
 
ccs_result_t ccs_rng_set_seed (ccs_rng_t rng, unsigned long int seed)
 Set the seed of a random number generator.
 
ccs_result_t ccs_rng_get (ccs_rng_t rng, unsigned long int *value_ret)
 Get a random integer from a random number generator.
 
ccs_result_t ccs_rng_uniform (ccs_rng_t rng, ccs_float_t *value_ret)
 Get a random floating point value uniformly sampled in the interval [0.0, 1.0).
 
ccs_result_t ccs_rng_min (ccs_rng_t rng, unsigned long int *value_ret)
 Get the minimum value that can be returned by ccs_rng_get.
 
ccs_result_t ccs_rng_max (ccs_rng_t rng, unsigned long int *value_ret)
 Get the maximum value that can be returned by ccs_rng_get.
 

Detailed Description

CCS rng define random number generators.

For now they are wrappers over gsl random number generators.

Function Documentation

◆ ccs_create_rng()

ccs_result_t ccs_create_rng ( ccs_rng_t rng_ret)
extern

Create a new random number generator using the gsl default type (see gsl_rng_default).

Parameters
[out]rng_reta pointer to the variable that will contain the returned random number generator
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_VALUE if rng_ret is NULL
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to allocate the new random number generator
Remarks
This function is thread-safe

◆ ccs_create_rng_with_type()

ccs_result_t ccs_create_rng_with_type ( const gsl_rng_type *  rng_type,
ccs_rng_t rng_ret 
)
extern

Create a new random number generator using the provided gsl type (see gsl_rng_type).

Parameters
[in]rng_typea pointer to the type of gsl random number generator to use.
[out]rng_reta pointer to the variable that will contain the returned random number generator
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_VALUE if rng_ret or rng_type are NULL
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to allocate the new random number generator
Remarks
This function is thread-safe

◆ ccs_rng_get()

ccs_result_t ccs_rng_get ( ccs_rng_t  rng,
unsigned long int *  value_ret 
)
extern

Get a random integer from a random number generator.

Integer is contained between the value returned by ccs_rng_min and ccs_rng_max, both included.

Parameters
[in]rng
[out]value_reta pointer to the variable that will contain the returned value
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if rng is not a valid CCS random number generator
CCS_RESULT_ERROR_INVALID_VALUE if value_ret is NULL
Remarks
This function is thread-safe

◆ ccs_rng_get_type()

ccs_result_t ccs_rng_get_type ( ccs_rng_t  rng,
const gsl_rng_type **  rng_type_ret 
)
extern

Get the gsl type of a random number generator.

Parameters
[in]rng
[out]rng_type_reta pointer that will contained a pointer to the returned gsl random number generator type.
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if rng is not a valid CCS random number generator
CCS_RESULT_ERROR_INVALID_VALUE if rng_type_ret is NULL
Remarks
This function is thread-safe

◆ ccs_rng_max()

ccs_result_t ccs_rng_max ( ccs_rng_t  rng,
unsigned long int *  value_ret 
)
extern

Get the maximum value that can be returned by ccs_rng_get.

Parameters
[in]rng
[out]value_reta pointer to the variable that will contain the returned value
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if rng is not a valid CCS random number generator
CCS_RESULT_ERROR_INVALID_VALUE if value_ret is NULL
Remarks
This function is thread-safe

◆ ccs_rng_min()

ccs_result_t ccs_rng_min ( ccs_rng_t  rng,
unsigned long int *  value_ret 
)
extern

Get the minimum value that can be returned by ccs_rng_get.

Parameters
[in]rng
[out]value_reta pointer to the variable that will contain the returned value
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if rng is not a valid CCS random number generator
CCS_RESULT_ERROR_INVALID_VALUE if value_ret is NULL
Remarks
This function is thread-safe

◆ ccs_rng_set_seed()

ccs_result_t ccs_rng_set_seed ( ccs_rng_t  rng,
unsigned long int  seed 
)
extern

Set the seed of a random number generator.

Parameters
[in]rng
[in]seedthe seed to use with the random number generator
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if rng is not a valid CCS random number generator
Remarks
This function is thread-safe

◆ ccs_rng_uniform()

ccs_result_t ccs_rng_uniform ( ccs_rng_t  rng,
ccs_float_t value_ret 
)
extern

Get a random floating point value uniformly sampled in the interval [0.0, 1.0).

Parameters
[in]rng
[out]value_reta pointer to the variable that will contain the returned value
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if rng is not a valid CCS random number generator
CCS_RESULT_ERROR_INVALID_VALUE if value_ret is NULL
Remarks
This function is thread-safe