CLHEP/Random/JamesRandom.h

// $Id: JamesRandom.h,v 1.13 2000/05/05 15:32:06 mf Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
//                             HEP Random
//                        --- HepJamesRandom ---
//                          class header file
// -----------------------------------------------------------------------
// This file is part of Geant4 (simulation toolkit for HEP).
//
// HepJamesRandom implements the algorithm by Marsaglia-Zaman RANMAR
// described in "F.James, Comp. Phys. Comm. 60 (1990) 329" and implemented
// in FORTRAN77 as part of the MATHLIB HEP library for pseudo-random
// numbers generation.
// This is the default random engine invoked by each distribution unless
// the user sets a different one.

// =======================================================================
// Gabriele Cosmo - Created: 5th September 1995
//                - Minor corrections: 31st October 1996
//                - Added methods for engine status: 19th November 1996
//                - setSeed(), setSeeds() now have default dummy argument
//                  set to zero: 11th July 1997
// J.Marraffino   - Added stream operators and related constructor.
//                  Added automatic seed selection from seed table and
//                  engine counter: 16th Feb 1998
// Ken Smith      - Added conversion operators:  6th Aug 1998
// V. Innocente   - changed pointers to indices     3 may 2000
// =======================================================================

#ifndef HepJamesRandom_h
#define HepJamesRandom_h 1

#include "CLHEP/Random/RandomEngine.h"

class HepJamesRandom: public HepRandomEngine {

public:

  HepJamesRandom(HepStd::istream& is);
  HepJamesRandom();
  HepJamesRandom(long seed);
  HepJamesRandom(HepInt rowIndex, HepInt colIndex);
  virtual ~HepJamesRandom();
  // Constructor and destructor.

  HepJamesRandom(const HepJamesRandom &p);
  // Copy constructor

  HepJamesRandom & operator = (const HepJamesRandom &p);
  // Overloaded assignment operator, to retrieve the engine status.

  HepDouble flat();
  // Returns a pseudo random number between 0 and 1 
  // (excluding the end points)

  void flatArray (const HepInt size, HepDouble* vect);
  // Fills the array "vect" of specified size with flat random values.

  void setSeed(long seed, HepInt dum=0);
  // Sets the state of the algorithm according to seed.

  void setSeeds(const long * seeds, HepInt dum=0);
  // Sets the state of the algorithm according to the zero terminated
  // array of seeds. Only the first seed is used.

  void saveStatus( const char filename[] = "JamesRand.conf" ) const;
  // Saves on file JamesRand.conf the current engine status.

  void restoreStatus( const char filename[] = "JamesRand.conf" );
  // Reads from file JamesRand.conf the last saved engine status
  // and restores it.

  void showStatus() const;
  // Dumps the engine status on the screen.

  operator unsigned int();
  // 32-bit flat, but slower than double or float.

  friend HepStd::ostream& operator<< (HepStd::ostream& os, const HepJamesRandom& e);
  friend HepStd::istream& operator>> (HepStd::istream& is,       HepJamesRandom& e);

private:

  // Members defining the current status of the generator.
  HepDouble u[97];
  HepDouble c, cd, cm;
  HepInt i97, j97;
  static HepInt numEngines;
  static HepInt maxIndex;
};

#endif

Generated by GNU enscript 1.6.1.