[2720] | 1 | // |
---|
| 2 | // C++ Interface: Interpolator1D |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // |
---|
| 6 | // |
---|
| 7 | // Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2012 |
---|
| 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
| 12 | #ifndef ASAP_INTERPOLATOR_1D_H |
---|
| 13 | #define ASAP_INTERPOLATOR_1D_H |
---|
| 14 | |
---|
| 15 | #include "Locator.h" |
---|
| 16 | |
---|
| 17 | namespace asap { |
---|
| 18 | |
---|
| 19 | /** |
---|
| 20 | * Base class for interpolation operation |
---|
| 21 | * @author TakeshiNakazato |
---|
| 22 | */ |
---|
[2733] | 23 | template <class T, class U> class Interpolator1D { |
---|
[2720] | 24 | public: |
---|
[2730] | 25 | // Default constructor. |
---|
[2720] | 26 | Interpolator1D(); |
---|
| 27 | |
---|
[2730] | 28 | // Destructor. |
---|
[2720] | 29 | virtual ~Interpolator1D(); |
---|
| 30 | |
---|
[2730] | 31 | // Set horizontal (x) and vertical (y) data. |
---|
| 32 | // @param[in] x pointer to horizontal data. |
---|
| 33 | // @param[in] y pointer to vertical data. |
---|
| 34 | // @param[in] n number of data. |
---|
[2733] | 35 | void setData(T *x, U *y, unsigned int n); |
---|
[2730] | 36 | |
---|
| 37 | // Set horizontal data (x). |
---|
| 38 | // @param[in] x pointer to horizontal data. |
---|
| 39 | // @param[in] n number of data. |
---|
[2733] | 40 | void setX(T *x, unsigned int n); |
---|
[2730] | 41 | |
---|
| 42 | // Set vertical data (y). |
---|
| 43 | // @param[in] y pointer to vertical data. |
---|
| 44 | // @param[in] n number of data. |
---|
[2733] | 45 | void setY(U *y, unsigned int n); |
---|
[2730] | 46 | |
---|
| 47 | // Reset object. |
---|
[2720] | 48 | void reset(); |
---|
[2727] | 49 | |
---|
[2730] | 50 | // Set order for polynomial interpolation. |
---|
| 51 | // @param order order of the polynomial. |
---|
| 52 | // |
---|
| 53 | // This method is effective only for polynomial interpolation. |
---|
[2720] | 54 | void setOrder(unsigned int order) {order_ = order;} |
---|
| 55 | |
---|
[2730] | 56 | // Perform interpolation. |
---|
| 57 | // @param[in] x horizontal location where the value is evaluated |
---|
| 58 | // by interpolation. |
---|
| 59 | // @return interpolated value at x. |
---|
[2733] | 60 | virtual U interpolate(T x) = 0; |
---|
[2720] | 61 | |
---|
| 62 | protected: |
---|
[2730] | 63 | // Locate x. |
---|
| 64 | // @param[in] x horizontal location. |
---|
| 65 | // @return location as an index. |
---|
| 66 | // @see Locator::locate() |
---|
[2733] | 67 | unsigned int locate(T x); |
---|
[2730] | 68 | |
---|
| 69 | // Query function whether the object is ready to interpolate. |
---|
| 70 | // @return true if object is ready else false. |
---|
[2720] | 71 | bool isready(); |
---|
[2730] | 72 | |
---|
| 73 | // Fuctory method to create appropriate Locator object. |
---|
[2727] | 74 | void createLocator(); |
---|
[2720] | 75 | |
---|
[2730] | 76 | // Order of the polynomial (only effective for polynomial interpolation). |
---|
[2720] | 77 | unsigned int order_; |
---|
[2730] | 78 | |
---|
| 79 | // Number of data points. |
---|
[2720] | 80 | unsigned int n_; |
---|
[2730] | 81 | |
---|
| 82 | // Horizontal data. |
---|
[2733] | 83 | T *x_; |
---|
[2730] | 84 | |
---|
| 85 | // Vertical data. |
---|
[2733] | 86 | U *y_; |
---|
[2730] | 87 | |
---|
| 88 | // Pointer to the Locator object. |
---|
[2733] | 89 | Locator<T> *locator_; |
---|
[2720] | 90 | }; |
---|
| 91 | |
---|
| 92 | } |
---|
[2733] | 93 | |
---|
| 94 | #include "Interpolator1D.tcc" |
---|
| 95 | |
---|
[2720] | 96 | #endif |
---|