[2727] | 1 | // |
---|
| 2 | // C++ Interface: CubicSplineInterpolator1D |
---|
| 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_CUBIC_SPLINE_INTERPOLATOR_1D_H |
---|
| 13 | #define ASAP_CUBIC_SPLINE_INTERPOLATOR_1D_H |
---|
| 14 | |
---|
| 15 | #include "Interpolator1D.h" |
---|
| 16 | |
---|
| 17 | namespace asap { |
---|
| 18 | |
---|
| 19 | /** |
---|
[2730] | 20 | * Implementation of (natural) cubic spline interpolation. |
---|
[2727] | 21 | * @author TakeshiNakazato |
---|
| 22 | */ |
---|
[2733] | 23 | template <class T, class U> |
---|
| 24 | class CubicSplineInterpolator1D : public Interpolator1D<T, U> { |
---|
[2727] | 25 | public: |
---|
[2730] | 26 | // Default constructor. |
---|
[2727] | 27 | CubicSplineInterpolator1D(); |
---|
| 28 | |
---|
[2730] | 29 | // Destructor. |
---|
[2727] | 30 | virtual ~CubicSplineInterpolator1D(); |
---|
| 31 | |
---|
[2730] | 32 | // Override Interpolator1D::setData. |
---|
| 33 | // @see Interpolator1D::setData |
---|
[2733] | 34 | void setData(T *x, U *y, unsigned int n); |
---|
[2730] | 35 | |
---|
| 36 | // Override Interpolator1D::setY. |
---|
| 37 | // @see Interpolator1D::setY() |
---|
[2733] | 38 | void setY(U *y, unsigned int n); |
---|
[2730] | 39 | |
---|
| 40 | // Perform interpolation. |
---|
| 41 | // @param[in] x horizontal location where the value is evaluated |
---|
| 42 | // by interpolation. |
---|
| 43 | // @return interpolated value at x. |
---|
[2733] | 44 | U interpolate(T x); |
---|
[2727] | 45 | private: |
---|
[2730] | 46 | // Determine second derivatives of each point based on |
---|
| 47 | // natural cubic spline condition (second derivative at each |
---|
| 48 | // end is zero). |
---|
| 49 | void evaly2(); |
---|
[2727] | 50 | |
---|
[2730] | 51 | // Do interpolation using second derivatives determined by evaly2(). |
---|
| 52 | // @param[in] x horizontal location where the value is evaluated |
---|
| 53 | // by interpolation. |
---|
| 54 | // @param[in] i location index for x. |
---|
| 55 | // @return interpolated value at x. |
---|
[2733] | 56 | U dospline(T x, unsigned int i); |
---|
[2727] | 57 | |
---|
[2730] | 58 | // Array to store second derivatives on the data points. |
---|
[2733] | 59 | U *y2_; |
---|
[2730] | 60 | |
---|
| 61 | // number of data points for second derivatives |
---|
[2727] | 62 | unsigned int ny2_; |
---|
[2730] | 63 | |
---|
| 64 | // Boolean parameter whether buffered values are effective or not. |
---|
[2727] | 65 | bool reusable_; |
---|
| 66 | }; |
---|
| 67 | |
---|
| 68 | } |
---|
[2733] | 69 | |
---|
| 70 | #include "CubicSplineInterpolator1D.tcc" |
---|
| 71 | |
---|
[2727] | 72 | #endif |
---|