?? prng.h
字號(hào):
/*8:*/#line 208 "./prng.w"#if !defined(_PRNG_H_)#define _PRNG_H_extern const char*prng_rcs_id;#if !defined(HAVE_NRAND48)#define HAVE_NRAND48 0#endif/*14:*/#line 320 "./prng.w"#include "error.h"/*:14*//*28:*/#line 539 "./prng.w"#include "gb_flip.h"/*:28*//*38:*/#line 647 "./prng.w"#if HAVE_NRAND48#include <stdlib.h>#define FIXINCLUDES_NEED_NRAND48#include "fixincludes.h"#undef FIXINCLUDES_NEED_NRAND48#endif/*:38*/#line 215 "./prng.w"/*11:*/#line 254 "./prng.w"typedef enum{/*27:*/#line 533 "./prng.w"PRNG_GB_FLIP,/*:27*//*33:*/#line 585 "./prng.w"PRNG_NRAND48,/*:33*//*42:*/#line 696 "./prng.w"PRNG_NUM_KINDS,PRNG_DEFAULT= PRNG_GB_FLIP/*:42*/#line 255 "./prng.w"}prng_kind_t;typedef struct{prng_kind_t kind;int seed;/*20:*/#line 423 "./prng.w"int have_saved_normal;double saved_normal;/*:20*/#line 259 "./prng.w"union{/*29:*/#line 543 "./prng.w"gb_prng_t*gb_flipper;/*:29*//*34:*/#line 590 "./prng.w"#if SIZEOF_SHORT==2unsigned short nrand48_state[3];#else#error "short int is not 16 bits"#endif/*:34*/#line 261 "./prng.w"}gen;}prng_t;/*:11*/#line 216 "./prng.w"/*9:*/#line 237 "./prng.w"prng_t*prng_new(prng_kind_t kind,int seed);double prng_normal(prng_t*g,double mean,double stddev);void prng_free(prng_t*g);int prng_kind_from_name(char*name);const char*prng_name_from_kind(int kind);int prng_kind(prng_t*g);/*:9*/#line 217 "./prng.w"#include "prngconfig.h"#if PRNG_DESIRE_INLINING && COMPILER_SUPPORTS_INLINE#define inline_proto inline extern#define inline_def inline extern#include <math.h> /*10:*/#line 246 "./prng.w"inline_proto int prng_unif_int(prng_t*g,long m);inline_proto double prng_unif_double_01(prng_t*g);inline_proto double prng_unif_double_range(prng_t*g,double a,double b);/*:10*/#line 224 "./prng.w"/*13:*/#line 307 "./prng.w"inline_def intprng_unif_int(prng_t*g,long m){switch(g->kind){/*32:*/#line 561 "./prng.w"case PRNG_GB_FLIP:return gb_prng_unif_rand(g->gen.gb_flipper,m);/*:32*//*37:*/#line 629 "./prng.w"case PRNG_NRAND48:#if HAVE_NRAND48{unsigned long t= 0x80000000UL-(0x80000000UL%m);long r;do{r= nrand48(g->gen.nrand48_state);}while(t<=(unsigned long)r);return r%m;}#elseerrorif(1,"Sorry, nrand48 is not available on this system.");return 0;#endifbreak;/*:37*/#line 312 "./prng.w"default:errorif(1,"No such kind of random number generator: %d",g->kind);return 0;}}/*:13*//*17:*/#line 353 "./prng.w"inline_def doubleprng_unif_double_01(prng_t*g){#if FLT_RADIX==2double i= prng_unif_int(g,1<<30);double j= prng_unif_int(g,1<<(DBL_MANT_DIG-30));return ldexp(ldexp(i,-30)+j,-(DBL_MANT_DIG-30));#else double x= 0.0,full= 0.0;while(full<1.0){x= ldexp(x+prng_unif_int(g,2),-1);full= ldexp(1.0+full,-1);}return x;#endif}/*:17*//*19:*/#line 400 "./prng.w"inline_def doubleprng_unif_double_range(prng_t*g,double a,double b){const double t= prng_unif_double_01(g);return a+t*(b-a);}/*:19*/#line 225 "./prng.w"#undef inline_proto#undef inline_def#else#define inline_proto/*10:*/#line 246 "./prng.w"inline_proto int prng_unif_int(prng_t*g,long m);inline_proto double prng_unif_double_01(prng_t*g);inline_proto double prng_unif_double_range(prng_t*g,double a,double b);/*:10*/#line 230 "./prng.w"#undef inline_proto#endif#endif /*:8*/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -