LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
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
std::vector< std::vector< double > > _coeffs
Definition: Spline.h:33
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)
Definition: Spline.cc:710
std::vector< double > roots(double const value, double const x0, double const x1) const
Definition: Spline.cc:1472
void interpolate(std::vector< double > const &x, std::vector< double > &y) const
Definition: Spline.cc:38
int const x0
Definition: saturated.cc:45
void derivative(std::vector< double > const &x, std::vector< double > &dydx) const
Definition: Spline.cc:73
TautSpline(std::vector< double > const &x, std::vector< double > const &y, double const gamma=0, Symmetry type=Unknown)
Definition: Spline.cc:178
std::vector< double > _knots
Definition: Spline.h:32
int x
double chisq
void _allocateSpline(int const nknot)
Definition: Spline.cc:25
void calculateTautSpline(std::vector< double > const &x, std::vector< double > const &y, double const gamma0)
Definition: Spline.cc:213
void calculateTautSplineEvenOdd(std::vector< double > const &x, std::vector< double > const &y, double const gamma0, bool even)
Definition: Spline.cc:1199