LSST Applications g0fba68d861+5616995c1c,g1ebb85f214+2420ccdea7,g1fd858c14a+44c57a1f81,g21d47ad084+8e51fce9ac,g262e1987ae+1a7d68eb3b,g2cef7863aa+3bd8df3d95,g35bb328faa+fcb1d3bbc8,g36ff55ed5b+2420ccdea7,g47891489e3+5c6313fe9a,g53246c7159+fcb1d3bbc8,g646c943bdb+dbb9921566,g67b6fd64d1+5c6313fe9a,g6bd32b75b5+2420ccdea7,g74acd417e5+37fc0c974d,g786e29fd12+cf7ec2a62a,g86c591e316+6e13bcb9e9,g87389fa792+1e0a283bba,g89139ef638+5c6313fe9a,g90f42f885a+fce05a46d3,g9125e01d80+fcb1d3bbc8,g93e38de9ac+5345a64125,g95a1e89356+47d08a1cc6,g97be763408+bba861c665,ga9e4eb89a6+85210110a1,gb0b61e0e8e+1f27f70249,gb58c049af0+f03b321e39,gb89ab40317+5c6313fe9a,gc4e39d7843+4e09c98c3d,gd16ba4ae74+5402bcf54a,gd8ff7fe66e+2420ccdea7,gd9a9a58781+fcb1d3bbc8,gdab6d2f7ff+37fc0c974d,gde280f09ee+604b327636,ge278dab8ac+50e2446c94,ge410e46f29+5c6313fe9a,gef3c2e6661+6b480e0fb7,gf67bdafdda+5c6313fe9a,gffca2db377+fcb1d3bbc8,v29.2.0.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
_functionLibrary.cc
Go to the documentation of this file.
1/*
2 * LSST Data Management System
3 * Copyright 2008-2016 AURA/LSST.
4 *
5 * This product includes software developed by the
6 * LSST Project (http://www.lsst.org/).
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the LSST License Statement and
19 * the GNU General Public License along with this program. If not,
20 * see <https://www.lsstcorp.org/LegalNotices/>.
21 */
22#include <memory>
23
24#include <pybind11/pybind11.h>
26
27#include <pybind11/stl.h>
28
29#include "lsst/geom/Box.h"
30#include "lsst/geom/Point.h"
31
34
35namespace py = pybind11;
36using namespace pybind11::literals;
37
38namespace lsst {
39namespace afw {
40namespace math {
41
42template <typename ReturnT>
44 /* PolynomialFunction1 */
45
46 wrappers.wrapType(
48 Function1<ReturnT>>(wrappers.module, ("PolynomialFunction1" + suffix).c_str()),
49 [](auto &mod, auto &cls) {
50 cls.def(py::init<std::vector<double> const &>(), "params"_a);
51 cls.def(py::init<unsigned int>(), "order"_a);
52
53 cls.def("__call__", &PolynomialFunction1<ReturnT>::operator(), "x"_a);
54 cls.def("clone", &PolynomialFunction1<ReturnT>::clone);
55 cls.def("isLinearCombination", &PolynomialFunction1<ReturnT>::isLinearCombination);
56 cls.def("getOrder", &PolynomialFunction1<ReturnT>::getOrder);
57 cls.def("toString", &PolynomialFunction1<ReturnT>::toString, "prefix"_a = "");
58 });
59 /* PolynomialFunction2 */
60 wrappers.wrapType(py::classh<PolynomialFunction2<ReturnT>,
62 ("PolynomialFunction2" + suffix).c_str()),
63 [](auto &mod, auto &cls) {
64 cls.def(py::init<std::vector<double> const &>(), "params"_a);
65 cls.def(py::init<unsigned int>(), "order"_a);
66
67 cls.def("__call__", &PolynomialFunction2<ReturnT>::operator(), "x"_a, "y"_a);
68 cls.def("clone", &PolynomialFunction2<ReturnT>::clone);
69 cls.def("getOrder", &PolynomialFunction2<ReturnT>::getOrder);
70 cls.def("getDFuncDParameters", &PolynomialFunction2<ReturnT>::getDFuncDParameters);
71 cls.def("toString", &PolynomialFunction2<ReturnT>::toString, "prefix"_a = "");
72 cls.def("isPersistable", &PolynomialFunction2<ReturnT>::isPersistable);
73 });
74};
75
76template <typename ReturnT>
78 /* Chebyshev1Function1 */
79
80 wrappers.wrapType(
82 Function1<ReturnT>>(wrappers.module, ("Chebyshev1Function1" + suffix).c_str()),
83 [](auto &mod, auto &cls) {
84 cls.def(py::init<std::vector<double>, double, double>(), "params"_a, "minX"_a = -1,
85 "maxX"_a = 1);
86 cls.def(py::init<unsigned int, double, double>(), "order"_a, "minX"_a = -1, "maxX"_a = 1);
87
88 cls.def("__call__", &Chebyshev1Function1<ReturnT>::operator(), "x"_a);
89 cls.def("clone", &Chebyshev1Function1<ReturnT>::clone);
90 cls.def("getMinX", &Chebyshev1Function1<ReturnT>::getMinX);
91 cls.def("getMaxX", &Chebyshev1Function1<ReturnT>::getMaxX);
92 cls.def("getOrder", &Chebyshev1Function1<ReturnT>::getOrder);
93 cls.def("isLinearCombination", &Chebyshev1Function1<ReturnT>::isLinearCombination);
94 cls.def("toString", &Chebyshev1Function1<ReturnT>::toString, "prefix"_a = "");
95
96 /* Chebyshev1Function2 */
97 });
98 wrappers.wrapType(py::classh<Chebyshev1Function2<ReturnT>,
100 ("Chebyshev1Function2" + suffix).c_str()),
101 [](auto &mod, auto &cls) {
102 cls.def(py::init<std::vector<double>, lsst::geom::Box2D const &>(), "params"_a,
103 "xyRange"_a = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, -1.0),
104 lsst::geom::Point2D(1.0, 1.0)));
105 cls.def(py::init<unsigned int, lsst::geom::Box2D const &>(), "order"_a,
106 "xyRange"_a = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, -1.0),
107 lsst::geom::Point2D(1.0, 1.0)));
108
109 cls.def("__call__", &Chebyshev1Function2<ReturnT>::operator(), "x"_a, "y"_a);
110 cls.def("clone", &Chebyshev1Function2<ReturnT>::clone);
111 cls.def("getXYRange", &Chebyshev1Function2<ReturnT>::getXYRange);
112 cls.def("truncate", &Chebyshev1Function2<ReturnT>::truncate, "order"_a);
113 cls.def("toString", &Chebyshev1Function2<ReturnT>::toString, "prefix"_a = "");
114 cls.def("isPersistable", &Chebyshev1Function2<ReturnT>::isPersistable);
115 });
116};
117
118template <typename ReturnT>
120 /* GaussianFunction1 */
121 wrappers.wrapType(py::classh<GaussianFunction1<ReturnT>,
122 Function1<ReturnT>>(wrappers.module, ("GaussianFunction1" + suffix).c_str()),
123 [](auto &mod, auto &cls) {
124 cls.def(py::init<double>(), "sigma"_a);
125
126 cls.def("__call__", &GaussianFunction1<ReturnT>::operator(), "x"_a);
127 cls.def("clone", &GaussianFunction1<ReturnT>::clone);
128 cls.def("toString", &GaussianFunction1<ReturnT>::toString, "prefix"_a = "");
129 });
130
131 wrappers.wrapType(py::classh<GaussianFunction2<ReturnT>,
132 Function2<ReturnT>>(wrappers.module, ("GaussianFunction2" + suffix).c_str()),
133 [](auto &mod, auto &cls) {
134 /* GaussianFunction2 */
135
136 cls.def(py::init<double, double, double>(), "sigma1"_a, "sigma2"_a,
137 "angle"_a = 0.0);
138
139 cls.def("__call__", &GaussianFunction2<ReturnT>::operator(), "x"_a, "y"_a);
140 cls.def("clone", &GaussianFunction2<ReturnT>::clone);
141 cls.def("toString", &GaussianFunction2<ReturnT>::toString, "prefix"_a = "");
142 cls.def("isPersistable", &GaussianFunction2<ReturnT>::isPersistable);
143 });
144 /* DoubleGaussianFunction2 */
145
146 wrappers.wrapType(
148 Function2<ReturnT>>(wrappers.module, ("DoubleGaussianFunction2" + suffix).c_str()),
149 [](auto &mod, auto &cls) {
150 cls.def(py::init<double, double, double>(), "sigma1"_a, "sigma2"_a = 0, "ampl"_a = 0);
151
152 cls.def("__call__", &DoubleGaussianFunction2<ReturnT>::operator(), "x"_a, "y"_a);
153 cls.def("clone", &DoubleGaussianFunction2<ReturnT>::clone);
154 cls.def("toString", &DoubleGaussianFunction2<ReturnT>::toString, "prefix"_a = "");
155 cls.def("isPersistable", &DoubleGaussianFunction2<ReturnT>::isPersistable);
156 });
157};
158
159template <typename ReturnT>
161 const std::string &suffix) {
162 /* IntegerDeltaFunction1 */
163
164 wrappers.wrapType(
166 Function1<ReturnT>>(wrappers.module, ("IntegerDeltaFunction1" + suffix).c_str()),
167 [](auto &mod, auto &cls) {
168 cls.def(py::init<double>(), "xo"_a);
169
170 cls.def("__call__", &IntegerDeltaFunction1<ReturnT>::operator(), "x"_a);
171 cls.def("clone", &IntegerDeltaFunction1<ReturnT>::clone);
172 cls.def("toString", &IntegerDeltaFunction1<ReturnT>::toString, "prefix"_a = "");
173 });
174 /* IntegerDeltaFunction2 */
175
176 wrappers.wrapType(
178 Function2<ReturnT>>(wrappers.module, ("IntegerDeltaFunction2" + suffix).c_str()),
179 [](auto &mod, auto &cls) {
180 cls.def(py::init<double, double>(), "xo"_a, "yo"_a);
181
182 cls.def("__call__", &IntegerDeltaFunction2<ReturnT>::operator(), "x"_a, "y"_a);
183 cls.def("clone", &IntegerDeltaFunction2<ReturnT>::clone);
184 cls.def("toString", &IntegerDeltaFunction2<ReturnT>::toString, "prefix"_a = "");
185 });
186};
187
188template <typename ReturnT>
190 /* LanczosFunction1 */
191
192 wrappers.wrapType(py::classh<LanczosFunction1<ReturnT>,
193 Function1<ReturnT>>(wrappers.module, ("LanczosFunction1" + suffix).c_str()),
194 [](auto &mod, auto &cls) {
195 cls.def(py::init<unsigned int, double>(), "n"_a, "xOffset"_a = 0.0);
196
197 cls.def("__call__", &LanczosFunction1<ReturnT>::operator(), "x"_a);
198 cls.def("clone", &LanczosFunction1<ReturnT>::clone);
199 cls.def("getOrder", &LanczosFunction1<ReturnT>::getOrder);
200 cls.def("toString", &LanczosFunction1<ReturnT>::toString, "prefix"_a = "");
201 });
202 /* LanczosFunction2 */
203
204 wrappers.wrapType(py::classh<LanczosFunction2<ReturnT>,
205 Function2<ReturnT>>(wrappers.module, ("LanczosFunction2" + suffix).c_str()),
206 [](auto &mod, auto &cls) {
207 /* LanczosFunction2 */
208 cls.def(py::init<unsigned int, double, double>(), "n"_a, "xOffset"_a = 0.0,
209 "yOffset"_a = 0.0);
210
211 cls.def("__call__", &LanczosFunction2<ReturnT>::operator(), "x"_a, "y"_a);
212 cls.def("clone", &LanczosFunction2<ReturnT>::clone);
213 cls.def("getOrder", &LanczosFunction2<ReturnT>::getOrder);
214 cls.def("toString", &LanczosFunction2<ReturnT>::toString, "prefix"_a = "");
215 });
216};
217
232
233} // namespace math
234} // namespace afw
235} // namespace lsst
Base class for 2-dimensional polynomials of the form:
Definition Function.h:326
1-dimensional weighted sum of Chebyshev polynomials of the first kind.
2-dimensional weighted sum of Chebyshev polynomials of the first kind.
double Guassian (sum of two Gaussians)
A Function taking one argument.
Definition Function.h:202
A Function taking two arguments.
Definition Function.h:259
1-dimensional integer delta function.
2-dimensional integer delta function.
1-dimensional Lanczos function
2-dimensional separable Lanczos function
1-dimensional polynomial function.
2-dimensional polynomial function with cross terms
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
void addInheritanceDependency(std::string const &name)
Indicate an external module that provides a base class for a subsequent addType call.
Definition python.h:343
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
Definition python.h:391
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
Definition python.h:448
void declareChebyshevFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void declareGaussianFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void declareLanczosFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void declareIntegerDeltaFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void declarePolynomialFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void wrapFunctionLibrary(lsst::cpputils::python::WrapperCollection &wrappers)