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