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 | /**
|
---|
20 | * Implementation of (natural) cubic spline interpolation.
|
---|
21 | * @author TakeshiNakazato
|
---|
22 | */
|
---|
23 | class CubicSplineInterpolator1D : public Interpolator1D {
|
---|
24 | public:
|
---|
25 | // Default constructor.
|
---|
26 | CubicSplineInterpolator1D();
|
---|
27 |
|
---|
28 | // Destructor.
|
---|
29 | virtual ~CubicSplineInterpolator1D();
|
---|
30 |
|
---|
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()
|
---|
37 | void setY(float *y, unsigned int n);
|
---|
38 |
|
---|
39 | // Perform interpolation.
|
---|
40 | // @param[in] x horizontal location where the value is evaluated
|
---|
41 | // by interpolation.
|
---|
42 | // @return interpolated value at x.
|
---|
43 | float interpolate(double x);
|
---|
44 | private:
|
---|
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();
|
---|
49 |
|
---|
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);
|
---|
56 |
|
---|
57 | // Array to store second derivatives on the data points.
|
---|
58 | float *y2_;
|
---|
59 |
|
---|
60 | // number of data points for second derivatives
|
---|
61 | unsigned int ny2_;
|
---|
62 |
|
---|
63 | // Boolean parameter whether buffered values are effective or not.
|
---|
64 | bool reusable_;
|
---|
65 | };
|
---|
66 |
|
---|
67 | }
|
---|
68 | #endif
|
---|