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
Interpolate.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #if !defined(LSST_AFW_MATH_INTERPOLATE_H)
3 #define LSST_AFW_MATH_INTERPOLATE_H
4 
5 /*
6  * LSST Data Management System
7  * Copyright 2008, 2009, 2010 LSST Corporation.
8  *
9  * This product includes software developed by the
10  * LSST Project (http://www.lsst.org/).
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the LSST License Statement and
23  * the GNU General Public License along with this program. If not,
24  * see <http://www.lsstcorp.org/LegalNotices/>.
25  */
26 #include "lsst/base.h"
27 
28 namespace lsst {
29 namespace afw {
30 namespace math {
31 
37 class Interpolate {
38 public:
39  enum Style {
40  UNKNOWN = -1,
41  CONSTANT = 0,
42  LINEAR = 1,
49  };
50 
51  friend PTR(Interpolate) makeInterpolate(std::vector<double> const &x, std::vector<double> const &y,
52  Interpolate::Style const style);
53 
54  virtual ~Interpolate() {}
55  virtual double interpolate(double const x) const = 0;
56 protected:
60  Interpolate(std::vector<double> const &x,
61  std::vector<double> const &y,
62  Interpolate::Style const style=UNKNOWN
63  ) : _x(x), _y(y), _style(style) {}
64  Interpolate(std::pair<std::vector<double>, std::vector<double> > const xy,
65  Interpolate::Style const style=UNKNOWN);
66 
67  std::vector<double> const _x;
68  std::vector<double> const _y;
70 private:
71  Interpolate(Interpolate const&);
73 };
74 
75 PTR(Interpolate) makeInterpolate(std::vector<double> const &x, std::vector<double> const &y,
76  Interpolate::Style const style=Interpolate::AKIMA_SPLINE);
77 
78 Interpolate::Style stringToInterpStyle(std::string const &style);
79 Interpolate::Style lookupMaxInterpStyle(int const n);
80 int lookupMinInterpPoints(Interpolate::Style const style);
81 
82 }}}
83 
84 #endif // LSST_AFW_MATH_INTERPOLATE_H
int y
friend boost::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style)
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Definition: Interpolate.cc:262
Interpolate values for a set of x,y vector&lt;&gt;s.
Definition: Interpolate.h:37
#define PTR(...)
Definition: base.h:41
std::vector< double > const _y
Definition: Interpolate.h:68
boost::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
Definition: Interpolate.cc:353
std::vector< double > const _x
Definition: Interpolate.h:67
Interpolate::Style lookupMaxInterpStyle(int const n)
Get the highest order Interpolation::Style available for &#39;n&#39; points.
Definition: Interpolate.cc:285
int x
Interpolate & operator=(Interpolate const &)
int lookupMinInterpPoints(Interpolate::Style const style)
Get the minimum number of points needed to use the requested interpolation style. ...
Definition: Interpolate.cc:309
Interpolate::Style const _style
Definition: Interpolate.h:69
virtual double interpolate(double const x) const =0
Interpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=UNKNOWN)
Definition: Interpolate.h:60