~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/include/optimizer/geqo_random.h

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * geqo_random.h
 
4
 *        random number generator
 
5
 *
 
6
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
7
 * Portions Copyright (c) 1994, Regents of the University of California
 
8
 *
 
9
 * $PostgreSQL: pgsql/src/include/optimizer/geqo_random.h,v 1.16 2004-12-31 22:03:36 pgsql Exp $
 
10
 *
 
11
 *-------------------------------------------------------------------------
 
12
 */
 
13
 
 
14
/* contributed by:
 
15
   =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
 
16
   *  Martin Utesch                              * Institute of Automatic Control          *
 
17
   =                                                     = University of Mining and Technology =
 
18
   *  utesch@aut.tu-freiberg.de  * Freiberg, Germany                               *
 
19
   =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
 
20
 */
 
21
 
 
22
/* -- parts of this are adapted from D. Whitley's Genitor algorithm -- */
 
23
 
 
24
#ifndef GEQO_RANDOM_H
 
25
#define GEQO_RANDOM_H
 
26
 
 
27
#include <math.h>
 
28
 
 
29
/* geqo_rand returns a random float value between 0 and 1 inclusive */
 
30
 
 
31
#define geqo_rand() (((double) random()) / ((double) MAX_RANDOM_VALUE))
 
32
 
 
33
/* geqo_randint returns integer value between lower and upper inclusive */
 
34
 
 
35
#define geqo_randint(upper,lower) \
 
36
        ( (int) floor( geqo_rand()*(((upper)-(lower))+0.999999) ) + (lower) )
 
37
 
 
38
#endif   /* GEQO_RANDOM_H */