Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

zigrandom.cc File Reference

#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include "zigrandom.h"
Include dependency graph for zigrandom.cc:

Go to the source code of this file.

Defines

#define MWC_R   256
#define MWC_A   LIT_UINT64(809430660)
#define MWC_AI   809430660
#define MWC_C   362436
#define POLARBLOCK(u1, u2, d)
#define FPOLARBLOCK(u1, u2, d)

Functions

void GetInitialSeeds (unsigned int auiSeed[], int cSeed, unsigned int uiSeed, unsigned int uiMin)
void RanSetSeed_MWC8222 (int *piSeed, int cSeed)
unsigned int IRan_MWC8222 (void)
double DRan_MWC8222 (void)
void VecIRan_MWC8222 (unsigned int *auiRan, int cRan)
void VecDRan_MWC8222 (double *adRan, int cRan)
double DRanU (void)
unsigned int IRanU (void)
void RanVecIntU (unsigned int *auiRan, int cRan)
void RanVecU (double *adRan, int cRan)
void RanSetSeed (int *piSeed, int cSeed)
void RanSetRan (const char *sRan)
static unsigned int IRanUfromDRanU (void)
static double DRanUfromIRanU (void)
void RanSetRanExt (DRANFUN DRanFun, IRANFUN IRanFun, IVECRANFUN IVecRanFun, DVECRANFUN DVecRanFun, RANSETSEEDFUN RanSetSeedFun)
double DRanNormalPolar (void)
double FRanNormalPolar (void)
static double dProbN (double x, int fUpper)
double DProbNormal (double x)
double DRanQuanNormal (void)
double FRanQuanNormal (void)

Variables

static unsigned int s_uiStateMWC = MWC_R - 1
static unsigned int s_uiCarryMWC = MWC_C
static unsigned int s_auiStateMWC [MWC_R]
static int s_cNormalInStore = 0
static DRANFUN s_fnDRanu = DRan_MWC8222
static IRANFUN s_fnIRanu = IRan_MWC8222
static IVECRANFUN s_fnVecIRanu = VecIRan_MWC8222
static DVECRANFUN s_fnVecDRanu = VecDRan_MWC8222
static RANSETSEEDFUN s_fnRanSetSeed = RanSetSeed_MWC8222
static double s_dNormalInStore
static float s_fNormalInStore

Detailed Description

========================================================================== This code is Copyright (C) 2005, Jurgen A. Doornik. Permission to use this code for non-commercial purposes is hereby given, provided proper reference is made to: Doornik, J.A. (2005), "An Improved Ziggurat Method to Generate Normal Random Samples", mimeo, Nuffield College, University of Oxford, and www.doornik.com/research. or the published version when available. This reference is still required when using modified versions of the code. This notice should be maintained in modified versions of the code. No warranty is given regarding the correctness of this code. ==========================================================================

Author:
Jurgen A. Doornik (Creator)

Definition in file zigrandom.cc.


Define Documentation

#define FPOLARBLOCK ( u1,
u2,
 ) 
Value:
do                                        \
  {   u1 = (float)((*s_fnDRanu)());  u1 = 2 * u1 - 1;\
    u2 = (float)((*s_fnDRanu)());  u2 = 2 * u2 - 1;\
    d = u1 * u1 + u2 * u2;                \
  } while (d >= 1);                         \
  d = std::sqrt( (-2.f / d) * std::log(d) );          \
  u1 *= d;  u2 *= d

Definition at line 236 of file zigrandom.cc.

#define MWC_A   LIT_UINT64(809430660)

Definition at line 50 of file zigrandom.cc.

Referenced by DRan_MWC8222(), IRan_MWC8222(), VecDRan_MWC8222(), and VecIRan_MWC8222().

#define MWC_AI   809430660

Definition at line 51 of file zigrandom.cc.

#define MWC_C   362436

Definition at line 52 of file zigrandom.cc.

Referenced by RanSetSeed_MWC8222().

#define MWC_R   256
#define POLARBLOCK ( u1,
u2,
 ) 
Value:
do                                        \
  {   u1 = (decltype(u1))(*s_fnDRanu)();  u1 = 2 * u1 - 1;\
    u2 = (decltype(u2))(*s_fnDRanu)();  u2 = 2 * u2 - 1;\
    d = u1 * u1 + u2 * u2;                \
  } while (d >= 1);                         \
  d = std::sqrt( (-2.f / d) * std::log(d) );          \
  u1 *= d;  u2 *= d

Definition at line 210 of file zigrandom.cc.

Referenced by DRanNormalPolar(), and FRanNormalPolar().


Function Documentation

static double dProbN ( double  x,
int  fUpper 
) [static]

Definition at line 263 of file zigrandom.cc.

Referenced by DProbNormal().

double DProbNormal ( double  x  ) 
double DRan_MWC8222 ( void   ) 

Definition at line 85 of file zigrandom.cc.

Referenced by RanSetRan().

double DRanNormalPolar ( void   ) 

Definition at line 221 of file zigrandom.cc.

Referenced by DRanQuanNormal().

double DRanQuanNormal ( void   ) 

Definition at line 300 of file zigrandom.cc.

double DRanU ( void   ) 

Definition at line 138 of file zigrandom.cc.

Referenced by DRanNormalTail(), DRanNormalZig(), and DRanNormalZigVec().

static double DRanUfromIRanU ( void   )  [static]

Definition at line 193 of file zigrandom.cc.

Referenced by RanSetRanExt().

double FRanNormalPolar ( void   ) 

Definition at line 246 of file zigrandom.cc.

Referenced by FRanQuanNormal().

double FRanQuanNormal ( void   ) 

Definition at line 304 of file zigrandom.cc.

void GetInitialSeeds ( unsigned int  auiSeed[],
int  cSeed,
unsigned int  uiSeed,
unsigned int  uiMin 
)

Definition at line 30 of file zigrandom.cc.

Referenced by RanSetSeed_MWC8222().

unsigned int IRan_MWC8222 ( void   ) 

Definition at line 75 of file zigrandom.cc.

Referenced by RanSetRan().

unsigned int IRanU ( void   ) 

Definition at line 142 of file zigrandom.cc.

Referenced by DRanNormalZig(), DRanNormalZig32(), and DRanNormalZig32Vec().

static unsigned int IRanUfromDRanU ( void   )  [static]

Definition at line 189 of file zigrandom.cc.

Referenced by RanSetRanExt().

void RanSetRan ( const char *  sRan  ) 

Definition at line 171 of file zigrandom.cc.

void RanSetRanExt ( DRANFUN  DRanFun,
IRANFUN  IRanFun,
IVECRANFUN  IVecRanFun,
DVECRANFUN  DVecRanFun,
RANSETSEEDFUN  RanSetSeedFun 
)

Definition at line 197 of file zigrandom.cc.

void RanSetSeed ( int *  piSeed,
int  cSeed 
)

Definition at line 166 of file zigrandom.cc.

Referenced by RanNormalSetSeedZig(), and RanNormalSetSeedZig32().

void RanSetSeed_MWC8222 ( int *  piSeed,
int  cSeed 
)

Definition at line 57 of file zigrandom.cc.

Referenced by RanSetRan().

void RanVecIntU ( unsigned int *  auiRan,
int  cRan 
)

Definition at line 146 of file zigrandom.cc.

Referenced by DRanNormalZig32Vec(), and DRanNormalZigVec().

void RanVecU ( double *  adRan,
int  cRan 
)

Definition at line 150 of file zigrandom.cc.

Referenced by DRanNormalZigVec().

void VecDRan_MWC8222 ( double *  adRan,
int  cRan 
)

Definition at line 110 of file zigrandom.cc.

void VecIRan_MWC8222 ( unsigned int *  auiRan,
int  cRan 
)

Definition at line 95 of file zigrandom.cc.

Referenced by RanSetRan().


Variable Documentation

unsigned int s_auiStateMWC[MWC_R] [static]

Definition at line 55 of file zigrandom.cc.

int s_cNormalInStore = 0 [static]

Definition at line 130 of file zigrandom.cc.

double s_dNormalInStore [static]

Definition at line 219 of file zigrandom.cc.

DRANFUN s_fnDRanu = DRan_MWC8222 [static]

Definition at line 132 of file zigrandom.cc.

IRANFUN s_fnIRanu = IRan_MWC8222 [static]

Definition at line 133 of file zigrandom.cc.

Definition at line 245 of file zigrandom.cc.

RANSETSEEDFUN s_fnRanSetSeed = RanSetSeed_MWC8222 [static]

Definition at line 136 of file zigrandom.cc.

DVECRANFUN s_fnVecDRanu = VecDRan_MWC8222 [static]

Definition at line 135 of file zigrandom.cc.

IVECRANFUN s_fnVecIRanu = VecIRan_MWC8222 [static]

Definition at line 134 of file zigrandom.cc.

unsigned int s_uiCarryMWC = MWC_C [static]

Definition at line 54 of file zigrandom.cc.

unsigned int s_uiStateMWC = MWC_R - 1 [static]

Definition at line 53 of file zigrandom.cc.


Tekkotsu v5.1CVS
Generated Mon May 9 04:59:04 2016 by Doxygen 1.6.3