Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

PosGen Class Reference

#include <newran.h>

Inheritance diagram for PosGen:

Inheritance graph
[legend]
Collaboration diagram for PosGen:

Collaboration graph
[legend]

Public Member Functions

char * Name ()
 PosGen ()
virtual ~PosGen ()
Real Next ()
ExtReal Mean () const
ExtReal Variance () const

Protected Member Functions

void Build (bool)

Protected Attributes

Real xi
Realsx
Realsfx
bool NotReady

Private Member Functions

void operator= (const PosGen &)

Constructor & Destructor Documentation

PosGen::PosGen  ) 
 

Definition at line 184 of file newran.cpp.

References NotReady, and tron.

00185 {
00186    #ifdef MONITOR
00187       tron << "constructing PosGen\n";
00188    #endif
00189    NotReady=true;
00190 }

PosGen::~PosGen  )  [virtual]
 

Definition at line 192 of file newran.cpp.

References NotReady, sfx, sx, and tron.

00193 {
00194    if (!NotReady)
00195    {
00196       #ifdef MONITOR
00197          tron << "freeing PosGen arrays\n";
00198       #endif
00199       delete [] sx; delete [] sfx;
00200    }
00201    #ifdef MONITOR
00202       tron << "destructing PosGen\n";
00203    #endif
00204 }


Member Function Documentation

void PosGen::Build bool   )  [protected]
 

Definition at line 206 of file newran.cpp.

References Random::Density(), ErrorNoSpace(), NotReady, Real, sfx, sx, tron, and xi.

Referenced by SymGen::Next(), Next(), and Normal::Normal().

00207 {
00208    #ifdef MONITOR
00209       tron << "building PosGen arrays\n";
00210    #endif
00211    int i;
00212    NotReady=false;
00213    sx=new Real[60]; sfx=new Real[60];
00214    if (!sx || !sfx) ErrorNoSpace();
00215    Real sxi=0.0; Real inc = sym ? 0.01 : 0.02;
00216    for (i=0; i<60; i++)
00217    {
00218       sx[i]=sxi; Real f1=Density(sxi); sfx[i]=f1;
00219       if (f1<=0.0) goto L20;
00220       sxi+=inc/f1;
00221    }
00222    Throw(Runtime_error("Newran: area too large"));
00223 L20:
00224    if (i<50) Throw(Runtime_error("Newran: area too small"));
00225    xi = sym ? 2*i : i;
00226    return;
00227 }

ExtReal PosGen::Mean  )  const [inline, virtual]
 

Reimplemented from Random.

Reimplemented in ChiSq1, Gamma1, Normal, Cauchy, and Exponential.

Definition at line 109 of file newran.h.

References Missing.

00109 { return (ExtReal)Missing; }

char * PosGen::Name  )  [virtual]
 

Reimplemented from Random.

Reimplemented in SymGen, Normal, Cauchy, Exponential, PosGenX, and SymGenX.

Definition at line 905 of file newran.cpp.

00905 { return "PosGen";           }

Real PosGen::Next  )  [virtual]
 

Reimplemented from Random.

Reimplemented in ChiSq1, Gamma1, and SymGen.

Definition at line 229 of file newran.cpp.

References Build(), Random::Density(), Random::Next(), NotReady, Real, sfx, sx, and xi.

Referenced by Gamma1::Next().

00230 {
00231    Real ak,y; int ir;
00232    if (NotReady) Build(false);
00233    do
00234    {
00235       Real r1=Random::Next();
00236       ir = (int)(r1*xi); Real sxi=sx[ir];
00237       ak=sxi+(sx[ir+1]-sxi)*Random::Next();
00238       y=sfx[ir]*Random::Next();
00239    }
00240    while ( y>=sfx[ir+1] && y>=Density(ak) );
00241    return ak;
00242 }

void PosGen::operator= const PosGen  )  [inline, private]
 

Definition at line 97 of file newran.h.

00097 {}       // private so can't access

ExtReal PosGen::Variance  )  const [inline, virtual]
 

Reimplemented from Random.

Reimplemented in ChiSq1, Gamma1, Normal, Cauchy, and Exponential.

Definition at line 110 of file newran.h.

References Missing.

00110 { return (ExtReal)Missing; }


Field Documentation

bool PosGen::NotReady [protected]
 

Definition at line 101 of file newran.h.

Referenced by Build(), SymGen::Next(), Next(), Normal::Normal(), PosGen(), Normal::~Normal(), and ~PosGen().

Real * PosGen::sfx [protected]
 

Definition at line 100 of file newran.h.

Referenced by Build(), SymGen::Next(), Next(), Normal::Normal(), and ~PosGen().

Real * PosGen::sx [protected]
 

Definition at line 100 of file newran.h.

Referenced by Build(), SymGen::Next(), Next(), Normal::Normal(), and ~PosGen().

Real PosGen::xi [protected]
 

Definition at line 100 of file newran.h.

Referenced by Build(), SymGen::Next(), Next(), and Normal::Normal().


The documentation for this class was generated from the following files:
Generated on Fri Dec 5 04:06:32 2003 for Borqueror by doxygen 1.3.3