zigrandom.h
Go to the documentation of this file.00001 #ifndef INCLUDED_ZIGRANDOM_H
00002 #define INCLUDED_ZIGRANDOM_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024
00025 #ifdef __LP64__
00026 typedef unsigned long UINT64;
00027 typedef long INT64;
00028 #define LIT_UINT64(c) (c##ul)
00029 #define LIT_INT64(c) (c##l)
00030 #elif defined(_MSC_VER)
00031 typedef unsigned __int64 UINT64;
00032 typedef __int64 INT64;
00033 #define LIT_UINT64(c) (c##ui64)
00034 #define LIT_INT64(c) (c##i64)
00035 #else
00036 typedef unsigned long long UINT64;
00037 typedef long long INT64;
00038 #define LIT_UINT64(c) (c##ull)
00039 #define LIT_INT64(c) (c##ll)
00040 #endif
00041
00042 #define M_RAN_INVM30 9.31322574615478515625e-010
00043 #define M_RAN_INVM32 2.32830643653869628906e-010
00044 #define M_RAN_INVM48 3.55271367880050092936e-015
00045 #define M_RAN_INVM52 2.22044604925031308085e-016
00046 #define M_RAN_INVM64 5.42101086242752217004e-020
00047
00048 #define RANDBL_32old(iRan1) \
00049 ((unsigned int)(iRan1) * M_RAN_INVM32)
00050 #define RANDBL_48old(iRan1, iRan2) \
00051 ((unsigned int)(iRan1) + (unsigned int)((iRan2) << 16) \
00052 * M_RAN_INVM32) * M_RAN_INVM32
00053 #define RANDBL_52old(iRan1, iRan2) \
00054 ((unsigned int)(iRan1) + (unsigned int)((iRan2) << 12) \
00055 * M_RAN_INVM32) * M_RAN_INVM32
00056
00057 #define RANDBL_32new(iRan1) \
00058 ((int)(iRan1) * M_RAN_INVM32 + (0.5 + M_RAN_INVM32 / 2))
00059 #define RANDBL_48new(iRan1, iRan2) \
00060 ((int)(iRan1) * M_RAN_INVM32 + (0.5 + M_RAN_INVM48 / 2) + \
00061 (int)((iRan2) & 0x0000FFFF) * M_RAN_INVM48)
00062 #define RANDBL_52new(iRan1, iRan2) \
00063 ((int)(iRan1) * M_RAN_INVM32 + (0.5 + M_RAN_INVM52 / 2) + \
00064 (int)((iRan2) & 0x000FFFFF) * M_RAN_INVM52)
00065
00066 void GetInitialSeeds(unsigned int auiSeed[], int cSeed,
00067 unsigned int uiSeed, unsigned int uiMin);
00068
00069
00070 void RanSetSeed_MWC8222(int *piSeed, int cSeed);
00071 unsigned int IRan_MWC8222(void);
00072 double DRan_MWC8222(void);
00073 void VecIRan_MWC8222(unsigned int *auiRan, int cRan);
00074 void VecDRan_MWC8222(double *adRan, int cRan);
00075
00076
00077 typedef double ( * DRANFUN)(void);
00078 typedef unsigned int( * IRANFUN)(void);
00079 typedef void ( * IVECRANFUN)(unsigned int *, int);
00080 typedef void ( * DVECRANFUN)(double *, int);
00081 typedef void ( * RANSETSEEDFUN)(int *, int);
00082
00083 void RanSetRan(const char *sRan);
00084 void RanSetRanExt(DRANFUN DRanFun, IRANFUN IRanFun, IVECRANFUN IVecRanFun,
00085 DVECRANFUN DVecRanFun, RANSETSEEDFUN RanSetSeedFun);
00086 double DRanU(void);
00087 unsigned int IRanU(void);
00088 void RanVecIntU(unsigned int *auiRan, int cRan);
00089 void RanVecU(double *adRan, int cRan);
00090 void RanSetSeed(int *piSeed, int cSeed);
00091
00092
00093 double DProbNormal(double x);
00094
00095
00096 double FRanNormalPolar(void);
00097 double DRanNormalPolar(void);
00098 double FRanQuanNormal(void);
00099 double DRanQuanNormal(void);
00100
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104
00105 #endif