LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
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 {
7 namespace afw {
8 namespace math {
9 namespace detail {
10 
11 /*
12  * Splines
13  */
14 class Spline {
15 public:
16  virtual ~Spline() = default;
17 
18  Spline(Spline const&) = default;
19  Spline(Spline&&) = default;
20  Spline& operator=(Spline const&) = default;
21  Spline& operator=(Spline&&) = default;
22 
36  void derivative(std::vector<double> const& x, std::vector<double>& dydx) const;
37 
46  std::vector<double> roots(double const value, double const x0, double const x1) const;
47 
48 protected:
49  Spline() = default;
53  void _allocateSpline(int const nknot);
54 
55  std::vector<double> _knots; // positions of knots
56  std::vector<std::vector<double> > _coeffs; // and associated coefficients
57 };
58 
59 class TautSpline : public Spline {
60 public:
61  enum Symmetry { Unknown, Odd, Even };
62 
133  TautSpline(std::vector<double> const& x, std::vector<double> const& y, double const gamma = 0,
134  Symmetry type = Unknown);
135 
136 private:
144  void calculateTautSpline(std::vector<double> const& x, std::vector<double> const& y, double const gamma0);
155  void calculateTautSplineEvenOdd(std::vector<double> const& x, std::vector<double> const& y,
156  double const gamma0, bool even);
157 };
158 
159 class SmoothedSpline : public Spline {
160 public:
229  double s, double* chisq = nullptr, std::vector<double>* errs = nullptr);
230 };
231 } // namespace detail
232 } // namespace math
233 } // namespace afw
234 } // namespace lsst
235 #endif
double x
table::Key< int > type
Definition: Detector.cc:163
int y
Definition: SpanSet.cc:48
SmoothedSpline(std::vector< double > const &x, std::vector< double > const &y, std::vector< double > const &dy, double s, double *chisq=nullptr, std::vector< double > *errs=nullptr)
Cubic spline data smoother.
Definition: Spline.cc:534
std::vector< double > _knots
Definition: Spline.h:55
std::vector< double > roots(double const value, double const x0, double const x1) const
Find the roots of Spline - val = 0 in the range [x0, x1).
Definition: Spline.cc:1226
void derivative(std::vector< double > const &x, std::vector< double > &dydx) const
Find the derivative of a Spline.
Definition: Spline.cc:57
Spline & operator=(Spline const &)=default
Spline(Spline const &)=default
void _allocateSpline(int const nknot)
Allocate the storage a Spline needs.
Definition: Spline.cc:21
void interpolate(std::vector< double > const &x, std::vector< double > &y) const
Interpolate a Spline.
Definition: Spline.cc:29
Spline & operator=(Spline &&)=default
std::vector< std::vector< double > > _coeffs
Definition: Spline.h:56
TautSpline(std::vector< double > const &x, std::vector< double > const &y, double const gamma=0, Symmetry type=Unknown)
Construct cubic spline interpolant to given data.
Definition: Spline.cc:86
A base class for image defects.