| 1 | //
 | 
|---|
| 2 | // C++ Interface: BufferedLinearInterpolator1D
 | 
|---|
| 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_BUFFERED_LINEAR_INTERPOLATOR_1D_H
 | 
|---|
| 13 | #define ASAP_BUFFERED_LINEAR_INTERPOLATOR_1D_H
 | 
|---|
| 14 | 
 | 
|---|
| 15 | #include "Interpolator1D.h"
 | 
|---|
| 16 | 
 | 
|---|
| 17 | namespace asap {
 | 
|---|
| 18 | 
 | 
|---|
| 19 | /**
 | 
|---|
| 20 |  * Linear interpolation with some buffers for acceleration.
 | 
|---|
| 21 |  * @author TakeshiNakazato
 | 
|---|
| 22 |  */
 | 
|---|
| 23 | class BufferedLinearInterpolator1D : public Interpolator1D {
 | 
|---|
| 24 | public:
 | 
|---|
| 25 |   // Default constructor.
 | 
|---|
| 26 |   BufferedLinearInterpolator1D();
 | 
|---|
| 27 | 
 | 
|---|
| 28 |   // Destructor.
 | 
|---|
| 29 |   virtual ~BufferedLinearInterpolator1D();
 | 
|---|
| 30 | 
 | 
|---|
| 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.
 | 
|---|
| 35 |   // @see Interpolator1D::setData()
 | 
|---|
| 36 |   void setData(double *x, float *y, unsigned int n);
 | 
|---|
| 37 | 
 | 
|---|
| 38 |   // Set horizontal data (x).
 | 
|---|
| 39 |   // @param[in] x pointer to horizontal data.
 | 
|---|
| 40 |   // @param[in] n number of data.
 | 
|---|
| 41 |   // @see Interpolator1D::setX()
 | 
|---|
| 42 |   void setX(double *x, unsigned int n);
 | 
|---|
| 43 | 
 | 
|---|
| 44 |   // Perform interpolation.
 | 
|---|
| 45 |   // @param[in] x horizontal location where the value is evaluated 
 | 
|---|
| 46 |   //              by interpolation.
 | 
|---|
| 47 |   // @return interpolated value at x.
 | 
|---|
| 48 |   // @see Interpolator1D::interpolate()
 | 
|---|
| 49 |   float interpolate(double x);
 | 
|---|
| 50 | 
 | 
|---|
| 51 | private:
 | 
|---|
| 52 |   // Numerical factor for linear interpolation.
 | 
|---|
| 53 |   double factor_;
 | 
|---|
| 54 | 
 | 
|---|
| 55 |   // Previous location.
 | 
|---|
| 56 |   double xold_;
 | 
|---|
| 57 | 
 | 
|---|
| 58 |   // Previous location as an index 
 | 
|---|
| 59 |   unsigned int prev_;
 | 
|---|
| 60 | 
 | 
|---|
| 61 |   // Boolean parameter whether buffered values are effective or not.
 | 
|---|
| 62 |   bool reusable_;
 | 
|---|
| 63 | };
 | 
|---|
| 64 | 
 | 
|---|
| 65 | }
 | 
|---|
| 66 | #endif
 | 
|---|