| Revision: | 2.5 | 
| Committed: | Sat Jun 7 12:50:20 2003 UTC (22 years, 5 months ago) by schorsch | 
| Content type: | text/plain | 
| Branch: | MAIN | 
| CVS Tags: | rad5R4, rad5R2, rad5R3, rad5R0, rad5R1, rad4R2, rad3R7P2, rad3R7P1, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1, rad4R2P2 | 
| Changes since 2.4: | +3 -1 lines | 
| Log Message: | Various small changes to reduce compile warnings/errors on Windows.  | 
| # | Content | 
|---|---|
| 1 | #ifndef lint | 
| 2 | static const char RCSid[] = "$Id: multisamp.c,v 2.4 2003/02/25 02:47:21 greg Exp $"; | 
| 3 | #endif | 
| 4 | /* | 
| 5 | * Binary space partitioning curve for multidimensional sampling. | 
| 6 | * | 
| 7 | * Written by Christophe Schlick | 
| 8 | */ | 
| 9 | |
| 10 | #include "copyright.h" | 
| 11 | |
| 12 | #include <stdlib.h> | 
| 13 | |
| 14 | #include "random.h" | 
| 15 | |
| 16 | void | 
| 17 | multisamp(t, n, r) /* convert 1-dimensional sample to N dimensions */ | 
| 18 | double t[]; /* returned N-dimensional vector */ | 
| 19 | register int n; /* number of dimensions */ | 
| 20 | double r; /* 1-dimensional sample [0,1) */ | 
| 21 | { | 
| 22 | int j; | 
| 23 | register int i, k; | 
| 24 | int ti[8]; | 
| 25 | double s; | 
| 26 | |
| 27 | i = n; | 
| 28 | while (i-- > 0) | 
| 29 | ti[i] = 0; | 
| 30 | j = 8; | 
| 31 | while (j--) { | 
| 32 | k = s = r*(1<<n); | 
| 33 | r = s - k; | 
| 34 | i = n; | 
| 35 | while (i-- > 0) | 
| 36 | ti[i] += ti[i] + ((k>>i) & 1); | 
| 37 | } | 
| 38 | i = n; | 
| 39 | while (i-- > 0) | 
| 40 | t[i] = 1./256. * (ti[i] + frandom()); | 
| 41 | } |