source: trunk/src/Interpolator1D.h@ 3066

Last change on this file since 3066 was 2878, checked in by Takeshi Nakazato, 11 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: test_sdcal2

Put in Release Notes: No

Module(s): sd

Description: Describe your changes here...

Bug fix on Interpolator class.


File size: 2.2 KB
Line 
1//
2// C++ Interface: Interpolator1D
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_INTERPOLATOR_1D_H
13#define ASAP_INTERPOLATOR_1D_H
14
15#include "Locator.h"
16
17namespace asap {
18
19/**
20 * Base class for interpolation operation
21 * @author TakeshiNakazato
22 */
23template <class T, class U> class Interpolator1D {
24public:
25 // Default constructor.
26 Interpolator1D();
27
28 // Destructor.
29 virtual ~Interpolator1D();
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 virtual void setData(T *x, U *y, unsigned int n);
36
37 // Set horizontal data (x).
38 // @param[in] x pointer to horizontal data.
39 // @param[in] n number of data.
40 virtual void setX(T *x, unsigned int n);
41
42 // Set vertical data (y).
43 // @param[in] y pointer to vertical data.
44 // @param[in] n number of data.
45 virtual void setY(U *y, unsigned int n);
46
47 // Reset object.
48 void reset();
49
50 // Set order for polynomial interpolation.
51 // @param order order of the polynomial.
52 //
53 // This method is effective only for polynomial interpolation.
54 void setOrder(unsigned int order) {order_ = order;}
55
56 // Perform interpolation.
57 // @param[in] x horizontal location where the value is evaluated
58 // by interpolation.
59 // @return interpolated value at x.
60 virtual U interpolate(T x) = 0;
61
62protected:
63 // Locate x.
64 // @param[in] x horizontal location.
65 // @return location as an index.
66 // @see Locator::locate()
67 unsigned int locate(T x);
68
69 // Query function whether the object is ready to interpolate.
70 // @return true if object is ready else false.
71 bool isready();
72
73 // Fuctory method to create appropriate Locator object.
74 void createLocator();
75
76 // Order of the polynomial (only effective for polynomial interpolation).
77 unsigned int order_;
78
79 // Number of data points.
80 unsigned int n_;
81
82 // Horizontal data.
83 T *x_;
84
85 // Vertical data.
86 U *y_;
87
88 // Pointer to the Locator object.
89 Locator<T> *locator_;
90};
91
92}
93
94#include "Interpolator1D.tcc"
95
96#endif
Note: See TracBrowser for help on using the repository browser.