lsst.afw  13.0-73-gb2a4e38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
minimize.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 
23 #include <pybind11/pybind11.h>
24 //#include <pybind11/operators.h>
25 #include <pybind11/stl.h>
26 
27 #include "lsst/afw/math/minimize.h"
28 
29 namespace py = pybind11;
30 
31 using namespace lsst::afw::math;
32 
33 template <typename ReturnT>
34 void declareMinimize(py::module &mod) {
35  mod.def("minimize", (FitResults(*)(lsst::afw::math::Function1<ReturnT> const &,
36  std::vector<double> const &, std::vector<double> const &,
37  std::vector<double> const &, std::vector<double> const &,
38  std::vector<double> const &, double))minimize<ReturnT>);
39  mod.def("minimize",
40  (FitResults(*)(lsst::afw::math::Function2<ReturnT> const &, std::vector<double> const &,
41  std::vector<double> const &, std::vector<double> const &,
42  std::vector<double> const &, std::vector<double> const &,
43  std::vector<double> const &, double))minimize<ReturnT>);
44 };
45 
46 PYBIND11_PLUGIN(_minimize) {
47  py::module mod("_minimize", "Python wrapper for afw _minimize library");
48 
49  /* Module level */
50 
51  /* Member types and enums */
52 
53  /* Constructors */
54 
55  /* Operators */
56 
57  /* Members */
58  py::class_<FitResults> clsFitResults(mod, "FitResults");
59  clsFitResults.def_readwrite("isValid", &FitResults::isValid);
60  clsFitResults.def_readwrite("chiSq", &FitResults::chiSq);
61  clsFitResults.def_readwrite("parameterList", &FitResults::parameterList);
62  clsFitResults.def_readwrite("parameterErrorList", &FitResults::parameterErrorList);
63 
64  declareMinimize<double>(mod);
65  declareMinimize<float>(mod);
66 
67  return mod.ptr();
68 }
std::vector< double > parameterList
fit parameters
Definition: minimize.h:49
std::vector< std::pair< double, double > > parameterErrorList
negative,positive (1 sigma?) error for each parameter
Definition: minimize.h:51
A Function taking two arguments.
Definition: Function.h:266
Results from minimizing a function.
Definition: minimize.h:45
double chiSq
chi squared; may be nan or infinite, but only if isValid false
Definition: minimize.h:48
A Function taking one argument.
Definition: Function.h:207
bool isValid
true if the fit converged; false otherwise
Definition: minimize.h:47
void declareMinimize(py::module &mod)
Definition: minimize.cc:34
PYBIND11_PLUGIN(_approximate)
Definition: approximate.cc:56