LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Approximate.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #if !defined(LSST_AFW_MATH_APPROXIMATE_H)
3 #define LSST_AFW_MATH_APPROXIMATE_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 geom {
31  class Box2I;
32 }
33 namespace image {
34 template<typename PixelT> class Image;
35 template<typename PixelT, typename U, typename V> class MaskedImage;
36 }
37 namespace math {
38 template<typename T> class Approximate;
39 
48 public:
50  enum Style {
51  UNKNOWN = -1,
54  };
55 
56  ApproximateControl(Style style, int orderX, int orderY=-1, bool weighting=true);
58  Style getStyle() const { return _style; }
60  int getOrderX() const { return _orderX; }
62  int getOrderY() const { return _orderY; }
64  bool getWeighting() const { return _weighting; }
65 private:
66  Style const _style;
67  int const _orderX;
68  int const _orderY;
69  bool const _weighting;
70 };
71 
75 template<typename PixelT>
77 makeApproximate(std::vector<double> const &x, std::vector<double> const &y,
78  image::MaskedImage<PixelT> const& im, geom::Box2I const& bbox,
79  ApproximateControl const& ctrl);
80 
85 template<typename PixelT>
86 class Approximate {
87 public:
88  typedef float OutPixelT;
89 
90  friend PTR(Approximate<PixelT>)
91  makeApproximate<>(std::vector<double> const &x, std::vector<double> const &y,
92  image::MaskedImage<PixelT> const& im, geom::Box2I const& bbox,
93  ApproximateControl const& ctrl);
95  virtual ~Approximate() {}
97  PTR(image::Image<OutPixelT>) getImage(int orderX=-1, int orderY=-1) const {
98  return doGetImage(orderX, orderY);
99  }
101  PTR(image::MaskedImage<OutPixelT>) getMaskedImage(int orderX=-1, int orderY=-1) const {
102  return doGetMaskedImage(orderX, orderY);
103  }
104 protected:
108  Approximate(std::vector<double> const &x,
109  std::vector<double> const &y,
110  geom::Box2I const& bbox,
111  ApproximateControl const& ctrl
112  ) : _xVec(x), _yVec(y), _bbox(bbox), _ctrl(ctrl) {}
113 
114  std::vector<double> const _xVec;
115  std::vector<double> const _yVec;
118 private:
119  Approximate(Approximate const&);
120  Approximate& operator=(Approximate const&);
121  virtual PTR(image::Image<OutPixelT>) doGetImage(int orderX, int orderY) const = 0;
122  virtual PTR(image::MaskedImage<OutPixelT>) doGetMaskedImage(int orderX, int orderY) const = 0;
123 };
124 
125 }}}
126 
127 #endif // LSST_AFW_MATH_APPROXIMATE_H
int y
Style getStyle() const
Return the Style.
Definition: Approximate.h:58
std::vector< double > const _yVec
the y-values of points
Definition: Approximate.h:115
#define PTR(...)
Definition: base.h:41
Approximate values for a MaskedImage.
Definition: Approximate.h:38
int getOrderY() const
Return the order of approximation to use in the y-direction.
Definition: Approximate.h:62
An integer coordinate rectangle.
Definition: Box.h:53
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
Approximate(std::vector< double > const &x, std::vector< double > const &y, geom::Box2I const &bbox, ApproximateControl const &ctrl)
Base class ctor.
Definition: Approximate.h:108
ApproximateControl(Style style, int orderX, int orderY=-1, bool weighting=true)
ctor
Definition: Approximate.cc:48
Use a 2-D Chebyshev polynomial.
Definition: Approximate.h:52
Control how to make an approximation.
Definition: Approximate.h:47
geom::Box2I const & _bbox
Definition: fits_io_mpl.h:80
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:77
Style
Choose the type of approximation to use.
Definition: Approximate.h:50
float OutPixelT
The pixel type of returned images.
Definition: Approximate.h:88
int x
boost::shared_ptr< Approximate< PixelT > > makeApproximate(std::vector< double > const &x, std::vector< double > const &y, image::MaskedImage< PixelT > const &im, geom::Box2I const &bbox, ApproximateControl const &ctrl)
Construct a new Approximate object, inferring the type from the type of the given MaskedImage...
Definition: Approximate.cc:289
std::vector< double > const _xVec
the x-values of points
Definition: Approximate.h:114
geom::Box2I const _bbox
Domain for approximation.
Definition: Approximate.h:116
int getOrderX() const
Return the order of approximation to use in the x-direction.
Definition: Approximate.h:60
bool getWeighting() const
Return whether inverse variance weighting will be used in calculation.
Definition: Approximate.h:64
ApproximateControl const _ctrl
desired approximation algorithm
Definition: Approximate.h:117
A class to represent a 2-dimensional array of pixels.
Definition: PSF.h:43