[355] | 1 | #include "Halton.h"
|
---|
[2076] | 2 | #include "PerfTimer.h"
|
---|
[355] | 3 |
|
---|
[2105] | 4 | #define PREGENERATE_HALTON 0
|
---|
| 5 |
|
---|
[863] | 6 | namespace GtpVisibilityPreprocessor {
|
---|
[860] | 7 |
|
---|
[2076] | 8 | PerfTimer haltonTimer;
|
---|
| 9 |
|
---|
[355] | 10 | // global halton generator
|
---|
| 11 |
|
---|
[2076] | 12 | Halton2 halton2;
|
---|
| 13 | float Halton2::_invBases[2];
|
---|
[860] | 14 |
|
---|
[2076] | 15 | float Halton<1>::_invBases[1];
|
---|
| 16 | float Halton<2>::_invBases[2];
|
---|
| 17 | float Halton<3>::_invBases[3];
|
---|
| 18 | float Halton<4>::_invBases[4];
|
---|
| 19 | float Halton<5>::_invBases[5];
|
---|
| 20 | float Halton<6>::_invBases[6];
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | Halton<1> dummmyHalton1(true);
|
---|
| 24 | Halton<2> dummmyHalton2(true);
|
---|
| 25 | Halton<3> dummmyHalton3(true);
|
---|
| 26 | Halton<4> dummmyHalton4(true);
|
---|
| 27 | Halton<5> dummmyHalton5(true);
|
---|
| 28 | Halton<6> dummmyHalton6(true);
|
---|
[2105] | 29 |
|
---|
| 30 |
|
---|
| 31 | int HaltonSequence::sPregeneratedDim = 0;
|
---|
| 32 | int HaltonSequence::sPregeneratedNumber = 0;
|
---|
| 33 | float *HaltonSequence::sPregeneratedValues = NULL;
|
---|
[2076] | 34 |
|
---|
[2105] | 35 | #if PREGENERATE_HALTON
|
---|
| 36 | // pregenerate first 100k numbers for 6 dimensions
|
---|
| 37 | static HaltonSequence staticHalton(6, 200000);
|
---|
| 38 | #endif
|
---|
| 39 |
|
---|
| 40 | // special construtor for pregenerating static halton sequences
|
---|
| 41 | HaltonSequence::HaltonSequence(const int dim,
|
---|
| 42 | const int number) {
|
---|
| 43 |
|
---|
| 44 | sPregeneratedDim = 0;
|
---|
| 45 | sPregeneratedNumber = 0;
|
---|
| 46 | sPregeneratedValues = new float[number*dim];
|
---|
| 47 |
|
---|
| 48 | float *p = sPregeneratedValues;
|
---|
| 49 | int i;
|
---|
| 50 | for (i=0; i < number; i++, p+=dim) {
|
---|
| 51 | GetNext(dim, p);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | sPregeneratedDim = dim;
|
---|
| 55 | sPregeneratedNumber = number;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[2076] | 58 | void
|
---|
| 59 | HaltonSequence::GetNext(const int dimensions, float *p)
|
---|
| 60 | {
|
---|
[2105] | 61 | // haltonTimer.Entry();
|
---|
| 62 | #if PREGENERATE_HALTON
|
---|
| 63 | if (index <= sPregeneratedNumber && dimensions <= sPregeneratedDim) {
|
---|
| 64 | float *pp = sPregeneratedValues + (sPregeneratedDim*(index-1));
|
---|
| 65 | for (int i=0; i < dimensions; i++)
|
---|
| 66 | p[i] = pp[i];
|
---|
| 67 | } else
|
---|
| 68 | #endif
|
---|
| 69 | {
|
---|
| 70 | for (int i=0; i < dimensions; i++)
|
---|
| 71 | p[i] = (float)GetNumber(i+1);
|
---|
| 72 | }
|
---|
[2076] | 73 | GenerateNext();
|
---|
[2105] | 74 | // haltonTimer.Exit();
|
---|
[2076] | 75 | }
|
---|
| 76 |
|
---|
| 77 | }
|
---|