?RCS: $Id: randfunc.U,v 3.0 1993/08/18 12:09:39 ram Exp $
?RCS:
?RCS: Copyright (c) 1991-1993, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 3.0.
?RCS:
?RCS: $Log: randfunc.U,v $
?RCS: Revision 3.0  1993/08/18  12:09:39  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?X:
?X:	This is the new unit that should be used when random
?X:	functions are to be used. It thus makes randbits.U obsolete.
?X:
?X:	This unit gives a simple #define for Drand01, which produces
?X:	doubles in the range [0,1) using the "best" random number
?X:	generator available.  The source should just call Drand01
?X:	and not worry about the underlying implementation.
?X:	    Andy Dougherty  July 1998
?X:
?MAKE:randfunc drand01 seedfunc randbits randseedtype: \
	Compile Myread Csym ccflags
?MAKE:	-pick add $@ %<
?S:randfunc:
?S:	Indicates the name of the random number function to use.
?S:	Values include drand48, random, and rand. In C programs,
?S:	the 'Drand01' macro is defined to generate uniformly distributed
?S:	random numbers over the range [0., 1.[ (see drand01 and nrand).
?S:.
?S:drand01:
?S:	Indicates the macro to be used to generate normalized
?S:	random numbers.  Uses randfunc, often divided by
?S:	(double) (((unsigned long) 1 << randbits)) in order to
?S:	normalize the result.
?S:	In C programs, the macro 'Drand01' is mapped to drand01.
?S:.
?S:randseedtype:
?S:	Indicates the type of the argument of the seedfunc.
?S:.
?S:seedfunc:
?S:	Indicates the random number generating seed function.
?S:	Values include srand48, srandom, and srand.
?S:.
?S:randbits:
?S:	Indicates how many bits are produced by the function used to
?S:	generate normalized random numbers.
?S:.
?C:RANDFUNC:
?C:	This symbol defines the random function used to define Drand01().
?C:.
?C:Drand01:
?C:	This macro is to be used to generate uniformly distributed
?C:	random numbers over the range [0., 1.[.  You may have to supply
?C:	an 'extern double drand48();' in your program since SunOS 4.1.3
?C:	doesn't provide you with anything relevant in its headers.
?C:	See HAS_DRAND48_PROTO.
?C:.
?C:Rand_seed_t:
?C:	This symbol defines the type of the argument of the
?C:	random seed function.
?C:.
?C:seedDrand01:
?C:	This symbol defines the macro to be used in seeding the
?C:	random number generator (see Drand01).
?C:.
?C:RANDBITS:
?C:	This symbol indicates how many bits are produced by the
?C:	function used to generate normalized random numbers.
?C:	Values include 15, 16, 31, and 48.
?C:.
?H:#define RANDFUNC		$randfunc		/**/
?H:#define Drand01()		$drand01		/**/
?H:#define Rand_seed_t		$randseedtype		/**/
?H:#define seedDrand01(x)	$seedfunc((Rand_seed_t)x)	/**/
?H:#define RANDBITS		$randbits		/**/
?H:.
?LINT:change ccflags
?LINT:unclosed $randbits))"
: How can we generate normalized random numbers ?
echo " "
echo "Using our internal random number implementation..." >&4

case "$ccflags" in
*-Dmy_rand=*|*-Dmy_srand=*)
	echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
	ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
	ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
	ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
	;;
esac

randfunc=Perl_drand48
drand01="Perl_drand48()"
seedfunc="Perl_drand48_init"
randbits=48
randseedtype=U32

