--- ray/src/common/urand.c 1991/05/21 11:01:00 1.3 +++ ray/src/common/urand.c 1998/01/05 16:47:37 2.4 @@ -1,35 +1,40 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1998 Silicon Graphics, Inc. */ #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static char SCCSid[] = "$SunId$ SGI"; #endif /* - * Uncorrelated (anticorrelated) random function + * Anticorrelated random function due to Christophe Schlick */ #include "random.h" #define NULL 0 +#define MAXORDER (8*sizeof(unsigned short)) + extern char *malloc(); -short *urperm; /* urand() permutation */ +unsigned short *urperm = NULL; /* urand() permutation */ int urmask; /* bits used in permutation */ +int initurand(size) /* initialize urand() for size entries */ int size; { int order, n; register int i, offset; + if (urperm != NULL) + free((char *)urperm); size--; for (i = 1; size >>= 1; i++) ; - order = i; + order = i>MAXORDER ? MAXORDER : i; urmask = (1< 0)