📄 unuran_config.h
字号:
/* Define the possible compiler switches. */#define UNUR_URNG_FVOID 1 /* use type `double urng(void)' */#define UNUR_URNG_PRNG 2 /* use prng-3.x */#define UNUR_URNG_RNGSTREAM 3 /* use RngStream */#define UNUR_URNG_GSL 4 /* use GNU Scientific Library */#define UNUR_URNG_GENERIC 99 /* use a generic interface (see below) *//*---------------------------------------------------------------------------*//* Set type of uniform random number generator. */#define UNUR_URNG_TYPE UNUR_URNG_FVOID/* #define UNUR_URNG_TYPE UNUR_URNG_PRNG *//* #define UNUR_URNG_TYPE UNUR_URNG_RNGSTREAM *//* #define UNUR_URNG_TYPE UNUR_URNG_GSL *//* #define UNUR_URNG_TYPE UNUR_URNG_GENERIC *//*---------------------------------------------------------------------------*/#if UNUR_URNG_TYPE == UNUR_URNG_FVOID/*---------------------------------------------------------------------------*//* Type of uniform random number generator. (Don't touch this line!) */typedef double (UNUR_URNG)(void);/* Default name of uniform random number generator. *//* Valid name of a C routine of type `double urng(void)'. */#define UNUR_URNG_DEFAULT unur_urng_MRG31k3p#define UNUR_URNG_AUX_DEFAULT unur_urng_fish/* Function call to uniform RNG. (Don't touch this line!) */#define _unur_call_urng(urng) ((*(urng))())/* Function call to reset uniform RNG. (For test suite only.) *//* The routine must reset the the default uniform RNG (UNUR_URNG_DEFAULT). *//* Comment out the macro definition if a reset routine is not available. */#define unur_urng_reset(urng) (unur_urng_MRG31k3p_reset());/*---------------------------------------------------------------------------*/#elif UNUR_URNG_TYPE == UNUR_URNG_PRNG/*---------------------------------------------------------------------------*//* Header file from prng library. (Don't remove this line!) *//* Make sure that this header file and the prng library is installed. */#include <prng.h>/* Type of uniform random number generator. (Don't touch this line!) */typedef struct prng UNUR_URNG;/* Default uniform random number generators. *//* These functions must return a pointer to a valid generator object of *//* type `struct prng *' (see prng-3.x manual). */#define UNUR_URNG_DEFAULT (prng_new("mt19937(19863)"))#define UNUR_URNG_AUX_DEFAULT (prng_new("LCG(2147483647,16807,0,1)"))/* Function call to uniform RNG. (Don't touch this line!) */#define _unur_call_urng(urng) (prng_get_next(urng))/* Function call to reset uniform RNG. (For test suite only) *//* (Don't touch this line!) */#define unur_urng_reset(urng) (prng_reset(urng))/*---------------------------------------------------------------------------*/#elif UNUR_URNG_TYPE == UNUR_URNG_RNGSTREAM/*---------------------------------------------------------------------------*//* Header file from RngStream library. (Don't remove this line!) *//* Make sure that this header file and the RngStream library is installed. */#include <RngStream.h>/* Type of uniform random number generator. (Don't touch this line!) */typedef struct RngStream_InfoState UNUR_URNG;/* Default uniform random number generators. *//* These functions must return a pointer to a valid generator object of type *//* `struct RngStream_InfoState *' (see RngStream manual and RngStream.h). */#define UNUR_URNG_DEFAULT (RngStream_CreateStream("URNG_main"))#define UNUR_URNG_AUX_DEFAULT (RngStream_CreateStream("URNG_aux"))/* Function call to uniform RNG. (Don't touch this line!) */#define _unur_call_urng(urng) (RngStream_RandU01(urng))/* Function call to reset uniform RNG. (For test suite only) *//* (Don't touch this line!) */#define unur_urng_reset(urng) (RngStream_ResetStartStream(urng))/*---------------------------------------------------------------------------*/#elif UNUR_URNG_TYPE == UNUR_URNG_GSL/*---------------------------------------------------------------------------*//* Header file from GNU Scientific Library. (Don't remove this line!) *//* Make sure that this header file and the GSL is installed. */#include <gsl/gsl_rng.h>/* Type of uniform random number generator. (Don't touch this line!) */typedef gsl_rng UNUR_URNG;/* Default uniform random number generators. *//* These functions must return a pointer to a valid generator object of type *//* `struct RngStream_InfoState *' (see RngStream manual and RngStream.h). */#define UNUR_URNG_DEFAULT (gsl_rng_alloc(gsl_rng_mt19937))#define UNUR_URNG_AUX_DEFAULT (gsl_rng_alloc(gsl_rng_cmrg))/* Function call to uniform RNG. (Don't touch this line!) */#define _unur_call_urng(urng) (gsl_rng_uniform_pos(urng))/* Function call to reset uniform RNG. (For test suite only) *//* No such routine for gsl uniform RNGs. *//* #define unur_urng_reset(urng) (exit(EXIT_FAILSURE)) *//*---------------------------------------------------------------------------*/#elif UNUR_URNG_TYPE == UNUR_URNG_GENERIC/*---------------------------------------------------------------------------*//* This a generic interface with limited support. *//* *//* IMPORTANT! *//* All functions and parameters should be set at run time: *//* *//* 1. Allocate variable of type `struct unur_urng_generic' *//* (or of type `UNUR_URNG', which is the same): *//* UNUR_URNG *urng; *//* urng = malloc(sizeof(UNUR_URNG)); *//* 2. Set function of type `double (*rand)(void *)' for sampling from *//* uniform RNG: *//* urng->getrand = my_uniform_rng; *//* 3. Set pointer to parameters of for this function *//* (or NULL if no parameters are required): *//* urng->params = my_parameters; *//* 4. Use this uniform RNG: *//* unur_urng_set_default(urng); (set default generator) *//* unur_urng_set_default_aux(urng); (set default aux. generator) *//* Notice that this must be done before UNURAN generator object *//* are created. Of course urng can also used just for a particular *//* generator object. Use the following and similar calls: */ /* unur_set_urng(par,urng); *//* unur_chg_urng(gen,urng); *//* *//* To avoid a possible segmentation fault when this URNG type is set, *//* we use the build-in uniform RNGs as defaults. *//* Be carefull when you change any macro definition!! *//* Indead, there is no need to change these definitions (except *//* (un)commenting the below macro for reseting the uniform RNG), since all *//* pointers are set at run time! *//* Structure for storing function pointer and parameterlist. *//* (Don't touch this line!) */struct unur_urng_generic { double (*getrand)(void *params); /* function for generating uniform RNG */ void *params; /* list of parameters */};/* Type of uniform random number generator. (Don't touch this line!) */typedef struct unur_urng_generic UNUR_URNG;/* Default uniform random number generators. *//* (Very ugly hack! Don't do this yourself unless you understand the code!) */typedef double (_unur_urng_voidptr)(void*); /* cast function pointer */#define UNUR_URNG_DEFAULT \ malloc(sizeof(UNUR_URNG)); \ urng_default->getrand = (_unur_urng_voidptr*)(unur_urng_MRG31k3p); \ urng_default->params = NULL#define UNUR_URNG_AUX_DEFAULT \ malloc(sizeof(UNUR_URNG)); \ urng_aux_default->getrand = (_unur_urng_voidptr*)(unur_urng_fish); \ urng_aux_default->params = NULL/* Function call to uniform RNG. (Don't touch this line!) */#define _unur_call_urng(urng) ((urng)->getrand((urng)->params))/* Function call to reset uniform RNG. (For test suite only) *//* The routine must reset the the default uniform RNG (UNUR_URNG_DEFAULT). *//* Comment out the macro definition if a reset routine is not available. *//* (But don't change macro definition!) */#define unur_urng_reset(urng) (unur_urng_MRG31k3p_reset());/*---------------------------------------------------------------------------*/#else/*---------------------------------------------------------------------------*/#error UNUR_URNG_TYPE not valid !!/*---------------------------------------------------------------------------*/#endif /* UNUR_URNG_TYPE *//*---------------------------------------------------------------------------*//*---------------------------------------------------------------------------*/#endif /* UNURAN_CONFIG_H_SEEN *//*---------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -