LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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 #include "ndarray_fwd.h"
28 
29 namespace lsst {
30 namespace afw {
31 namespace math {
32 
38 class Interpolate {
39 public:
40  enum Style {
41  UNKNOWN = -1,
42  CONSTANT = 0,
43  LINEAR = 1,
50  };
51 
52  friend PTR(Interpolate) makeInterpolate(std::vector<double> const &x, std::vector<double> const &y,
53  Interpolate::Style const style);
54 
55  virtual ~Interpolate() {}
56  virtual double interpolate(double const x) const = 0;
57  std::vector<double> interpolate(std::vector<double> const& x) const;
58  ndarray::Array<double, 1> interpolate(ndarray::Array<double const, 1> const& x) const;
59 protected:
63  Interpolate(std::vector<double> const &x,
64  std::vector<double> const &y,
65  Interpolate::Style const style=UNKNOWN
66  ) : _x(x), _y(y), _style(style) {}
67  Interpolate(std::pair<std::vector<double>, std::vector<double> > const xy,
68  Interpolate::Style const style=UNKNOWN);
69 
70  std::vector<double> const _x;
71  std::vector<double> const _y;
73 private:
74  Interpolate(Interpolate const&);
76 };
77 
78 PTR(Interpolate) makeInterpolate(std::vector<double> const &x, std::vector<double> const &y,
79  Interpolate::Style const style=Interpolate::AKIMA_SPLINE);
80 PTR(Interpolate) makeInterpolate(ndarray::Array<double const, 1> const &x,
81  ndarray::Array<double const, 1> const &y,
82  Interpolate::Style const style=Interpolate::AKIMA_SPLINE);
83 Interpolate::Style stringToInterpStyle(std::string const &style);
84 Interpolate::Style lookupMaxInterpStyle(int const n);
85 int lookupMinInterpPoints(Interpolate::Style const style);
86 
87 }}}
88 
89 #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)
A factory function to make Interpolate objects.
Definition: Interpolate.cc:375
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Definition: Interpolate.cc:263
Interpolate values for a set of x,y vector&lt;&gt;s.
Definition: Interpolate.h:38
virtual double interpolate(double const x) const =0
Interpolate & operator=(Interpolate const &)
boost::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style)
A factory function to make Interpolate objects.
Definition: Interpolate.cc:375
metadata import lsst afw display as afwDisplay n
double x
std::vector< double > const _x
Definition: Interpolate.h:70
Interpolate::Style lookupMaxInterpStyle(int const n)
Get the highest order Interpolation::Style available for &#39;n&#39; points.
Definition: Interpolate.cc:286
int lookupMinInterpPoints(Interpolate::Style const style)
Get the minimum number of points needed to use the requested interpolation style. ...
Definition: Interpolate.cc:331
Interpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=UNKNOWN)
Base class ctor.
Definition: Interpolate.h:63
#define PTR(...)
Definition: base.h:41
std::vector< double > const _y
Definition: Interpolate.h:71
Interpolate::Style const _style
Definition: Interpolate.h:72
Basic LSST definitions.