LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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 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
std::vector< std::vector< double > > _coeffs
Definition: Spline.h:33
void derivative(std::vector< double > const &x, std::vector< double > &dydx) const
Definition: Spline.cc:73
std::vector< double > _knots
Definition: Spline.h:32
int const x0
Definition: saturated.cc:45
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
void interpolate(std::vector< double > const &x, std::vector< double > &y) const
Definition: Spline.cc:38
std::vector< double > roots(double const value, double const x0, double const x1) const
Definition: Spline.cc:1472
double x
void _allocateSpline(int const nknot)
Definition: Spline.cc:25
double chisq
TautSpline(std::vector< double > const &x, std::vector< double > const &y, double const gamma=0, Symmetry type=Unknown)
Definition: Spline.cc:178