1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
4 |
> |
static char SCCSid[] = "$SunId$ SGI"; |
5 |
|
#endif |
6 |
|
|
7 |
|
/* |
8 |
< |
* Uncorrelated (anticorrelated) random function |
8 |
> |
* Anticorrelated random function due to Christophe Schlick |
9 |
|
*/ |
10 |
|
|
11 |
|
#include "random.h" |
14 |
|
|
15 |
|
extern char *malloc(); |
16 |
|
|
17 |
< |
short *urperm; /* urand() permutation */ |
17 |
> |
short *urperm = NULL; /* urand() permutation */ |
18 |
|
int urmask; /* bits used in permutation */ |
19 |
|
|
20 |
|
|
21 |
+ |
int |
22 |
|
initurand(size) /* initialize urand() for size entries */ |
23 |
|
int size; |
24 |
|
{ |
25 |
|
int order, n; |
26 |
|
register int i, offset; |
27 |
|
|
28 |
+ |
if (urperm != NULL) |
29 |
+ |
free((char *)urperm); |
30 |
|
size--; |
31 |
|
for (i = 1; size >>= 1; i++) |
32 |
|
; |
47 |
|
else |
48 |
|
urperm[i+offset]++; |
49 |
|
} |
50 |
+ |
return(1<<order); |
51 |
+ |
} |
52 |
+ |
|
53 |
+ |
|
54 |
+ |
int |
55 |
+ |
ilhash(d, n) /* hash a set of integer values */ |
56 |
+ |
register int *d; |
57 |
+ |
register int n; |
58 |
+ |
{ |
59 |
+ |
static int tab[8] = {13623,353,1637,5831,2314,3887,5832,8737}; |
60 |
+ |
register int hval; |
61 |
+ |
|
62 |
+ |
hval = 0; |
63 |
+ |
while (n-- > 0) |
64 |
+ |
hval += *d++ * tab[n&7]; |
65 |
+ |
return(hval); |
66 |
|
} |