LSSTApplications  20.0.0
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 {
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 = NULL, std::vector<double>* errs = NULL);
230 };
231 } // namespace detail
232 } // namespace math
233 } // namespace afw
234 } // namespace lsst
235 #endif
lsst::afw::math::detail::Spline::operator=
Spline & operator=(Spline const &)=default
y
int y
Definition: SpanSet.cc:49
lsst::afw::math::detail::Spline::derivative
void derivative(std::vector< double > const &x, std::vector< double > &dydx) const
Find the derivative of a Spline.
Definition: Spline.cc:57
lsst::afw::math::detail::Spline::Spline
Spline(Spline &&)=default
lsst::afw::math::detail::Spline::~Spline
virtual ~Spline()=default
lsst::afw::math::detail::Spline::interpolate
void interpolate(std::vector< double > const &x, std::vector< double > &y) const
Interpolate a Spline.
Definition: Spline.cc:29
lsst::afw::math::detail::TautSpline::Odd
@ Odd
Definition: Spline.h:61
std::vector< double >
lsst::afw::math::detail::TautSpline::Even
@ Even
Definition: Spline.h:61
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::math::detail::SmoothedSpline::SmoothedSpline
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)
Cubic spline data smoother.
Definition: Spline.cc:534
lsst::afw::math::detail::Spline::Spline
Spline()=default
lsst::afw::math::detail::SmoothedSpline
Definition: Spline.h:159
lsst::afw::math::detail::Spline::operator=
Spline & operator=(Spline &&)=default
lsst::afw::math::detail::TautSpline
Definition: Spline.h:59
lsst::afw::math::detail::Spline::_knots
std::vector< double > _knots
Definition: Spline.h:55
x
double x
Definition: ChebyshevBoundedField.cc:277
lsst::afw::math::detail::TautSpline::TautSpline
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
lsst::afw::math::detail::Spline::roots
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
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::math::detail::Spline::_coeffs
std::vector< std::vector< double > > _coeffs
Definition: Spline.h:56
lsst::afw::math::detail::Spline
Definition: Spline.h:14
lsst::afw::math::detail::TautSpline::Symmetry
Symmetry
Definition: Spline.h:61
type
table::Key< int > type
Definition: Detector.cc:163
lsst::afw::math::detail::Spline::_allocateSpline
void _allocateSpline(int const nknot)
Allocate the storage a Spline needs.
Definition: Spline.cc:21
lsst::afw::math::detail::TautSpline::Unknown
@ Unknown
Definition: Spline.h:61
lsst::afw::math::detail::Spline::Spline
Spline(Spline const &)=default