Ignore:
Timestamp:
12/08/06 17:10:14 (18 years ago)
Author:
bittner
Message:

merge, global lines, rss sampling updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h

    r860 r1867  
    77namespace GtpVisibilityPreprocessor { 
    88 
    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; 
     9inline float halton(float baseRec, float prev) { 
     10  float r = 1 - prev - 1e-10f; 
     11  if (baseRec < r) 
     12        return prev + baseRec; 
    1713        float h = baseRec; 
    1814        float hh; 
     
    2218        } while (h >= r); 
    2319        return prev + hh + h - 1; 
     20} 
     21 
     22template<int T> 
     23class Halton { 
     24  float _invBases[T]; 
     25  float _prev[T]; 
     26   
     27public: 
     28   
     29  void Reset() { 
     30        for (int i=0; i < T; i++)  
     31          _prev[i] = 0; 
    2432  } 
     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 
     54class Halton2 { 
     55  static float _invBases[2]; 
     56  float _prev[2]; 
    2557   
    2658public: 
     
    69101 */ 
    70102inline 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 
    75112  int prime = 1; 
    76113  int found = 1; 
     
    115152        int copyOfIndex = index; 
    116153        if((base >= 2) && (index >= 1)) { 
    117         // changed by matt 
    118         //if(base >= 2 & index >= 1) { 
    119154          while(copyOfIndex > 0) { 
    120155                N1 = (copyOfIndex / base); 
Note: See TracChangeset for help on using the changeset viewer.