23 #include <pybind11/pybind11.h>
26 #include "ndarray/pybind11.h"
31 using namespace pybind11::literals;
38 template <
typename T1,
typename T2,
int C1,
int C2>
40 auto clsLeastSquares = wrappers.
wrapType(
41 py::class_<LeastSquares>(wrappers.
module,
"LeastSquares"), [](
auto &mod,
auto &cls) {
44 (LeastSquares(*)(ndarray::Array<T1, 2, C1> const &, ndarray::Array<T2, 1, C2> const &,
45 LeastSquares::Factorization)) &
46 LeastSquares::fromDesignMatrix<T1, T2, C1, C2>,
47 "design"_a,
"data"_a,
"factorization"_a = LeastSquares::NORMAL_EIGENSYSTEM);
49 "fromNormalEquations",
50 (LeastSquares(*)(ndarray::Array<T1, 2, C1> const &, ndarray::Array<T2, 1, C2> const &,
51 LeastSquares::Factorization)) &
52 LeastSquares::fromNormalEquations<T1, T2, C1, C2>,
53 "fisher"_a,
"rhs"_a,
"factorization"_a = LeastSquares::NORMAL_EIGENSYSTEM);
54 cls.def(
"getRank", &LeastSquares::getRank);
55 cls.def(
"setDesignMatrix", (void (LeastSquares::*)(ndarray::Array<T1, 2, C1> const &,
56 ndarray::Array<T2, 1, C2> const &)) &
57 LeastSquares::setDesignMatrix<T1, T2, C1, C2>);
58 cls.def(
"getDimension", &LeastSquares::getDimension);
59 cls.def(
"setNormalEquations", (void (LeastSquares::*)(ndarray::Array<T1, 2, C1> const &,
60 ndarray::Array<T2, 1, C2> const &)) &
61 LeastSquares::setNormalEquations<T1, T2, C1, C2>);
62 cls.def(
"getSolution", &LeastSquares::getSolution);
63 cls.def(
"getFisherMatrix", &LeastSquares::getFisherMatrix);
64 cls.def(
"getCovariance", &LeastSquares::getCovariance);
65 cls.def(
"getFactorization", &LeastSquares::getFactorization);
66 cls.def(
"getDiagnostic", &LeastSquares::getDiagnostic);
67 cls.def(
"getThreshold", &LeastSquares::getThreshold);
68 cls.def(
"setThreshold", &LeastSquares::setThreshold);
70 wrappers.
wrapType(py::enum_<LeastSquares::Factorization>(clsLeastSquares,
"Factorization"),
71 [](
auto &mod,
auto &enm) {
72 enm.value(
"NORMAL_EIGENSYSTEM", LeastSquares::Factorization::NORMAL_EIGENSYSTEM);
73 enm.value(
"NORMAL_CHOLESKY", LeastSquares::Factorization::NORMAL_CHOLESKY);
74 enm.value(
"DIRECT_SVD", LeastSquares::Factorization::DIRECT_SVD);
81 declareLeastSquares<double, double, 0, 0>(wrappers);
A helper class for subdividing pybind11 module across multiple translation units (i....
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
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...
void wrapLeastSquares(lsst::utils::python::WrapperCollection &wrappers)
A base class for image defects.