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 | template <class T, class U>
|
---|
24 | class BufferedLinearInterpolator1D : public Interpolator1D<T, U> {
|
---|
25 | public:
|
---|
26 | // Default constructor.
|
---|
27 | BufferedLinearInterpolator1D();
|
---|
28 |
|
---|
29 | // Destructor.
|
---|
30 | virtual ~BufferedLinearInterpolator1D();
|
---|
31 |
|
---|
32 | // Set horizontal (x) and vertical (y) data.
|
---|
33 | // @param[in] x pointer to horizontal data.
|
---|
34 | // @param[in] y pointer to vertical data.
|
---|
35 | // @param[in] n number of data.
|
---|
36 | // @see Interpolator1D::setData()
|
---|
37 | void setData(T *x, U *y, unsigned int n);
|
---|
38 |
|
---|
39 | // Set horizontal data (x).
|
---|
40 | // @param[in] x pointer to horizontal data.
|
---|
41 | // @param[in] n number of data.
|
---|
42 | // @see Interpolator1D::setX()
|
---|
43 | void setX(T *x, unsigned int n);
|
---|
44 |
|
---|
45 | // Perform interpolation.
|
---|
46 | // @param[in] x horizontal location where the value is evaluated
|
---|
47 | // by interpolation.
|
---|
48 | // @return interpolated value at x.
|
---|
49 | // @see Interpolator1D::interpolate()
|
---|
50 | U interpolate(T x);
|
---|
51 |
|
---|
52 | private:
|
---|
53 | // Numerical factor for linear interpolation.
|
---|
54 | T factor_;
|
---|
55 |
|
---|
56 | // Previous location.
|
---|
57 | T xold_;
|
---|
58 |
|
---|
59 | // Previous location as an index
|
---|
60 | unsigned int prev_;
|
---|
61 |
|
---|
62 | // Boolean parameter whether buffered values are effective or not.
|
---|
63 | bool reusable_;
|
---|
64 | };
|
---|
65 |
|
---|
66 | }
|
---|
67 |
|
---|
68 | #include "BufferedLinearInterpolator1D.tcc"
|
---|
69 |
|
---|
70 | #endif
|
---|