--- ray/src/common/urand.c 1991/05/17 12:55:27 1.1 +++ ray/src/common/urand.c 1991/05/17 13:51:14 1.2 @@ -16,6 +16,7 @@ extern char *malloc(); short *urperm; /* urand() permutation */ int urmask; /* bits used in permutation */ +static int urorder; /* number of bits */ initurand(size) /* initialize urand() for size entries */ @@ -44,4 +45,19 @@ int size; else urperm[i+offset]++; } +} + + +int +urhash(d, n) /* hash a set of integer values */ +register int *d; +register int n; +{ + static int tab[8] = {13623,353,1637,5831,2314,3887,5832,8737}; + register unsigned hval; + + hval = 0; + while (n-- > 0) + hval += *d++ * tab[n&7]; + return(hval & urmask); }