LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
Spline.h
Go to the documentation of this file.
1 #if !defined(LSST_AFW_MATH_DETAIL_SPLINE)
2 #define LSST_AFW_MATH_DETAIL_SPLINE 1
3 #include <cmath>
4 #include <vector>
5 
6 namespace lsst { namespace afw { namespace math { namespace detail {
7 
8 /*****************************************************************************/
9 /*
10  * Splines
11  */
12 class Spline {
13 public:
14  virtual ~Spline() {}
15 
16  void interpolate(std::vector<double> const& x,
17  std::vector<double> &y
18  ) const;
19  void derivative(std::vector<double> const& x,
20  std::vector<double> &dydx
21  ) const;
22 
23  std::vector<double> roots(double const value,
24  double const x0,
25  double const x1
26  ) const;
27 
28 protected:
29  Spline() {}
30  void _allocateSpline(int const nknot);
31 
32  std::vector<double> _knots; // positions of knots
33  std::vector<std::vector<double> > _coeffs; // and associated coefficients
34 };
35 
36 class TautSpline : public Spline {
37 public:
38  enum Symmetry { Unknown, Odd, Even };
39 
40  TautSpline(std::vector<double> const& x,
41  std::vector<double> const& y,
42  double const gamma=0,
43  Symmetry type=Unknown
44  );
45 private:
46  void calculateTautSpline(std::vector<double> const& x,
47  std::vector<double> const& y,
48  double const gamma0
49  );
50  void calculateTautSplineEvenOdd(std::vector<double> const& x,
51  std::vector<double> const& y,
52  double const gamma0,
53  bool even
54  );
55 };
56 
57 class SmoothedSpline : public Spline {
58 public:
59  SmoothedSpline(std::vector<double> const& x,
60  std::vector<double> const& y,
61  std::vector<double> const& dy,
62  double s,
63  double *chisq=NULL,
64  std::vector<double> *errs=NULL
65  );
66 };
67 }}}}
68 #endif
int y
void interpolate(std::vector< double > const &x, std::vector< double > &y) const
Interpolate a Spline.
Definition: Spline.cc:38
std::vector< double > roots(double const value, double const x0, double const x1) const
Definition: Spline.cc:1472
void derivative(std::vector< double > const &x, std::vector< double > &dydx) const
Find the derivative of a Spline.
Definition: Spline.cc:73
TautSpline(std::vector< double > const &x, std::vector< double > const &y, double const gamma=0, Symmetry type=Unknown)
Adapted from A Practical Guide to Splines by C.
Definition: Spline.cc:178
int const x0
Definition: saturated.cc:45
std::vector< double > _knots
Definition: Spline.h:32
void _allocateSpline(int const nknot)
Definition: Spline.cc:25
double x
std::vector< std::vector< double > > _coeffs
Definition: Spline.h:33
double chisq
void calculateTautSpline(std::vector< double > const &x, std::vector< double > const &y, double const gamma0)
Here&#39;s the worker routine for the TautSpline ctor.
Definition: Spline.cc:213
SmoothedSpline(std::vector< double > const &x, std::vector< double > const &y, std::vector< double > const &dy, double s, double *chisq=NULL, std::vector< double > *errs=NULL)
Algorithm 642 collected algorithms from ACM.
Definition: Spline.cc:710
void calculateTautSplineEvenOdd(std::vector< double > const &x, std::vector< double > const &y, double const gamma0, bool even)
Definition: Spline.cc:1199