Main Page Modules Class Hierarchy Compound List File List Compound Members

# random.h

    00001 //==========================================================================
    00002 //   RANDOM.H - header for
    00003 //                             OMNeT++
    00004 //            Discrete System Simulation in C++
    00005 //
    00006 //
    00007 //  Random number generator functions
    00008 //
    00009 //==========================================================================
    00010
    00011 /*--------------------------------------------------------------*
    00012   Copyright (C) 1992-2003 Andras Varga
    00013
    00014   This file is distributed WITHOUT ANY WARRANTY. See the file
    00015   `license' for details on this and other legal matters.
    00016 *--------------------------------------------------------------*/
    00017
    00018 #ifndef __RANDOM_H
    00019 #define __RANDOM_H
    00020
    00021 #include "defs.h"
    00022
    00023
    00027 #define NUM_RANDOM_GENERATORS    32
    00028
    00029 #define INTRAND_MAX  0x7ffffffeL  /* = 2**31-2 FIXME */
    00030
    00031
    00041
    00047 SIM_API int testrand();
    00048
    00054 SIM_API long opp_nextrand(long& seed);
    00055
    00059 SIM_API void opp_randomize();
    00060
    00064 SIM_API long randseed();
    00065
    00069 SIM_API long randseed(long seed);
    00070
    00074 SIM_API long intrand();
    00075
    00079 SIM_API long intrand(long r);
    00080
    00084 inline  double dblrand();
    00085
    00089 SIM_API void genk_opp_randomize(int gen_nr);
    00090
    00094 SIM_API long genk_randseed(int gen_nr);
    00095
    00099 SIM_API long genk_randseed(int gen_nr, long seed);
    00100
    00104 SIM_API long genk_intrand(int gen_nr);
    00105
    00109 SIM_API long genk_intrand(int gen_nr,long r);
    00110
    00114 inline  double genk_dblrand(int gen_nr);
    00116
    00117 //==========================================================================
    00118 //=== Implementation of utility functions:
    00119
    00120 inline double dblrand()
    00121 {
    00122    return (double)intrand() / (double)((unsigned long)INTRAND_MAX+1UL);
    00123 }
    00124
    00125 inline double genk_dblrand(int gen_nr)
    00126 {
    00127    return (double)genk_intrand(gen_nr) / (double)((unsigned long)INTRAND_MAX+1UL);
    00128 }
    00129
    00130 #endif
    00131
    00132