source: trunk/src/CubicSplineInterpolator1D.h @ 2730

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

New Development: No

JIRA Issue: Yes CAS-4770

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Rewrite implementations for locator and interpolator.
Documentation (doxygen format) is added to header files.


File size: 1.7 KB
Line 
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
17namespace asap {
18
19/**
20 * Implementation of (natural) cubic spline interpolation.
21 * @author TakeshiNakazato
22 */
23class CubicSplineInterpolator1D : public Interpolator1D {
24public:
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);
44private:
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
Note: See TracBrowser for help on using the repository browser.