Changeset 1867 for GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h
- Timestamp:
- 12/08/06 17:10:14 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h
r860 r1867 7 7 namespace GtpVisibilityPreprocessor { 8 8 9 class Halton2 { 10 static float _invBases[2]; 11 float _prev[2]; 12 13 float halton(float baseRec, float prev) const { 14 float r = 1 - prev - 1e-10f; 15 if (baseRec < r) 16 return prev + baseRec; 9 inline float halton(float baseRec, float prev) { 10 float r = 1 - prev - 1e-10f; 11 if (baseRec < r) 12 return prev + baseRec; 17 13 float h = baseRec; 18 14 float hh; … … 22 18 } while (h >= r); 23 19 return prev + hh + h - 1; 20 } 21 22 template<int T> 23 class Halton { 24 float _invBases[T]; 25 float _prev[T]; 26 27 public: 28 29 void Reset() { 30 for (int i=0; i < T; i++) 31 _prev[i] = 0; 24 32 } 33 34 Halton() { 35 for (int i=0; i < T; i++) { 36 int base = FindPrime(i+1); 37 if (base == 1) 38 base++; 39 _invBases[i] = 1.0f/base; 40 } 41 Reset(); 42 } 43 44 void 45 GetNext(float *a) { 46 for (int i=0; i < T; i++) { 47 a[i] = halton(_invBases[i], _prev[i]); 48 _prev[i] = a[i]; 49 } 50 } 51 52 }; 53 54 class Halton2 { 55 static float _invBases[2]; 56 float _prev[2]; 25 57 26 58 public: … … 69 101 */ 70 102 inline int FindPrime(const int index) { 71 if(index < 1) { 72 cerr<<"FindPrime: The argument must be non-negative."<<endl; 73 return -1; 74 } 103 // if (index < 1) { 104 // cerr<<"FindPrime: The argument must be non-negative."<<endl; 105 // return -1; 106 // } 107 108 const int primes[] = {-1, 1, 3, 5, 7, 11, 13}; 109 if (index <= 6) 110 return primes[index]; 111 75 112 int prime = 1; 76 113 int found = 1; … … 115 152 int copyOfIndex = index; 116 153 if((base >= 2) && (index >= 1)) { 117 // changed by matt118 //if(base >= 2 & index >= 1) {119 154 while(copyOfIndex > 0) { 120 155 N1 = (copyOfIndex / base);
Note: See TracChangeset
for help on using the changeset viewer.