Changeset 2731
- Timestamp:
- 01/16/13 16:45:43 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 4 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/BisectionLocator.h
r2730 r2731 21 21 * @author TakeshiNakazato 22 22 */ 23 class BisectionLocator : public Locator{23 template <class T> class BisectionLocator : public Locator<T> { 24 24 public: 25 25 // Default constructor. … … 31 31 // @param[in] copystorage whether allocate internal memory or not. 32 32 // @see Locator::set() 33 BisectionLocator( double*v, unsigned int n, bool copystorage=true);33 BisectionLocator(T *v, unsigned int n, bool copystorage=true); 34 34 35 35 // Destructor. … … 40 40 // @return location as an index j. 41 41 // @see Locator::locate() 42 unsigned int locate( doublex);42 unsigned int locate(T x); 43 43 }; 44 44 45 45 } 46 47 #include "BisectionLocator.tcc" 48 46 49 #endif -
trunk/src/BufferedBisectionLocator.h
r2730 r2731 22 22 * @author TakeshiNakazato 23 23 */ 24 class BufferedBisectionLocator : public Locator{24 template <class T> class BufferedBisectionLocator : public Locator<T> { 25 25 public: 26 26 // Default constructor. … … 32 32 // @param[in] copystorage whether allocate internal memory or not. 33 33 // @see Locator::set() 34 BufferedBisectionLocator( double*v, unsigned int n, bool copystorage=true);34 BufferedBisectionLocator(T *v, unsigned int n, bool copystorage=true); 35 35 36 36 // Destructor. … … 41 41 // @return location as an index j. 42 42 // @see Locator::locate() 43 unsigned int locate( doublex);43 unsigned int locate(T x); 44 44 private: 45 45 … … 49 49 50 50 } 51 52 #include "BufferedBisectionLocator.tcc" 53 51 54 #endif -
trunk/src/CMakeLists.txt
r2729 r2731 80 80 ${SRCDIR}/Calibrator.cpp 81 81 ${SRCDIR}/PSAlmaCalibrator.cpp 82 ${SRCDIR}/Locator.cpp83 ${SRCDIR}/BisectionLocator.cpp84 ${SRCDIR}/HuntLocator.cpp85 ${SRCDIR}/BufferedBisectionLocator.cpp86 82 ${SRCDIR}/Interpolator1D.cpp 87 83 ${SRCDIR}/NearestInterpolator1D.cpp -
trunk/src/HuntLocator.h
r2730 r2731 21 21 * @author TakeshiNakazato 22 22 */ 23 class HuntLocator : public Locator{23 template <class T> class HuntLocator : public Locator<T> { 24 24 public: 25 25 // Default constructor. … … 31 31 // @param[in] copystorage whether allocate internal memory or not. 32 32 // @see Locator::set() 33 HuntLocator( double*v, unsigned int n, bool copystorage=true);33 HuntLocator(T *v, unsigned int n, bool copystorage=true); 34 34 35 35 // Destructor. … … 41 41 // @return location as an index j. 42 42 // @see Locator::locate() 43 unsigned int locate( doublex);43 unsigned int locate(T x); 44 44 private: 45 // Hunt algorithm 46 // @param[in] x input value to be located. 47 // @param[in,out] left input: the starting point for hunt. 48 // output: the left index of hunted region. 49 // @param[out] right the right index of hunted region. 50 void hunt(T x, unsigned int &left, unsigned int &right); 51 45 52 // Storage for previous result. 46 53 unsigned int prev_; … … 48 55 49 56 } 57 58 #include "HuntLocator.tcc" 59 50 60 #endif -
trunk/src/Interpolator1D.cpp
r2730 r2731 16 16 17 17 #include "Interpolator1D.h" 18 #include "Locator.h" 18 19 #include "BisectionLocator.h" 19 20 #include "HuntLocator.h" … … 88 89 if (!locator_) { 89 90 if (n_ > 1000) 90 locator_ = new HuntLocator ();91 locator_ = new HuntLocator<double>(); 91 92 else 92 locator_ = new BisectionLocator ();93 locator_ = new BisectionLocator<double>(); 93 94 } 94 95 } -
trunk/src/Interpolator1D.h
r2730 r2731 87 87 88 88 // Pointer to the Locator object. 89 Locator *locator_;89 Locator<double> *locator_; 90 90 }; 91 91 -
trunk/src/Locator.h
r2730 r2731 19 19 * @author TakeshiNakazato 20 20 */ 21 class Locator {21 template <class T> class Locator { 22 22 public: 23 23 // Default constructor. … … 29 29 // @param[in] copystorage whether allocate internal memory or not. 30 30 // @see set() 31 Locator( double*v, unsigned int n, bool copystorage=true);32 31 Locator(T *v, unsigned int n, bool copystorage=true); 32 33 33 // Set data. The data must be sorted in either ascending or descending 34 34 // order, and must not have any duplicate elements. … … 42 42 // it will take a risk to allow to edit the data to be searched from 43 43 // outside the class. 44 void set( double*v, unsigned int n, bool copystorage=true);45 44 void set(T *v, unsigned int n, bool copystorage=true); 45 46 46 // Destructor. 47 47 virtual ~Locator(); 48 48 49 49 // Return right hand side index of location. 50 50 // @param[in] x input value to be located. … … 54 54 // case while x_[j-1] > x >= x_[j] for descending case. 55 55 // Returned value 0 or x.nelements() indicates out of range. 56 virtual unsigned int locate( doublex) = 0;57 56 virtual unsigned int locate(T x) = 0; 57 58 58 protected: 59 59 // Bisection search. … … 61 61 // @param[in] left the leftmost index to search. 62 62 // @param[in] right the rightmost index to search. 63 unsigned int bisection( doublex, unsigned int left, unsigned int right);63 unsigned int bisection(T x, unsigned int left, unsigned int right); 64 64 65 // Hunt algorithm66 // @param[in] x input value to be located.67 // @param[in,out] left input: the starting point for hunt.68 // output: the left index of hunted region.69 // @param[out] right the right index of hunted region.70 void hunt(double x, unsigned int &left, unsigned int &right);71 72 65 // Pointer to the data. 73 double*x_;66 T *x_; 74 67 75 68 // Length of the data. … … 84 77 85 78 } 79 80 #include "Locator.tcc" 81 86 82 #endif
Note:
See TracChangeset
for help on using the changeset viewer.