--- ray/src/common/urand.c 1991/05/17 12:55:27 1.1 +++ ray/src/common/urand.c 1997/12/01 09:55:00 2.3 @@ -1,11 +1,11 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1997 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" @@ -14,16 +14,19 @@ static char SCCSid[] = "$SunId$ LBL"; extern char *malloc(); -short *urperm; /* urand() permutation */ +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++) ; @@ -44,4 +47,20 @@ int size; else urperm[i+offset]++; } + return(1< 0) + hval += *d++ * tab[n&7]; + return(hval); }