23 #include <pybind11/pybind11.h>
27 #include "numpy/arrayobject.h"
28 #include "ndarray/pybind11.h"
29 #include "ndarray/converter.h"
34 namespace py = pybind11;
35 using namespace pybind11::literals;
37 using namespace lsst::afw::math;
39 template <
typename T1,
typename T2,
int C1,
int C2>
41 py::class_<LeastSquares>
cls(mod,
"LeastSquares");
42 py::enum_<LeastSquares::Factorization>(
cls,
"Factorization")
43 .value(
"NORMAL_EIGENSYSTEM", LeastSquares::Factorization::NORMAL_EIGENSYSTEM)
44 .value(
"NORMAL_CHOLESKY", LeastSquares::Factorization::NORMAL_CHOLESKY)
45 .value(
"DIRECT_SVD", LeastSquares::Factorization::DIRECT_SVD)
47 cls.def_static(
"fromDesignMatrix",
48 (
LeastSquares(*)(ndarray::Array<T1, 2, C1>
const &, ndarray::Array<T2, 1, C2>
const &,
50 LeastSquares::fromDesignMatrix<T1, T2, C1, C2>,
51 "design"_a,
"data"_a,
"factorization"_a = LeastSquares::NORMAL_EIGENSYSTEM);
52 cls.def_static(
"fromNormalEquations",
53 (
LeastSquares(*)(ndarray::Array<T1, 2, C1>
const &, ndarray::Array<T2, 1, C2>
const &,
55 LeastSquares::fromNormalEquations<T1, T2, C1, C2>,
56 "fisher"_a,
"rhs"_a,
"factorization"_a = LeastSquares::NORMAL_EIGENSYSTEM);
57 cls.def(
"getRank", &LeastSquares::getRank);
58 cls.def(
"setDesignMatrix",
59 (
void (
LeastSquares::*)(ndarray::Array<T1, 2, C1>
const &, ndarray::Array<T2, 1, C2>
const &)) &
60 LeastSquares::setDesignMatrix<T1, T2, C1, C2>);
61 cls.def(
"getDimension", &LeastSquares::getDimension);
62 cls.def(
"setNormalEquations",
63 (
void (
LeastSquares::*)(ndarray::Array<T1, 2, C1>
const &, ndarray::Array<T2, 1, C2>
const &)) &
64 LeastSquares::setNormalEquations<T1, T2, C1, C2>);
65 cls.def(
"getSolution", &LeastSquares::getSolution);
66 cls.def(
"getFisherMatrix", &LeastSquares::getFisherMatrix);
67 cls.def(
"getCovariance", &LeastSquares::getCovariance);
68 cls.def(
"getFactorization", &LeastSquares::getFactorization);
69 cls.def(
"getDiagnostic", &LeastSquares::getDiagnostic);
70 cls.def(
"getThreshold", &LeastSquares::getThreshold);
71 cls.def(
"setThreshold", &LeastSquares::setThreshold);
75 py::module mod(
"_leastSquares",
"Python wrapper for afw _leastSquares library");
77 if (_import_array() < 0) {
78 PyErr_SetString(PyExc_ImportError,
"numpy.core.multiarray failed to import");
82 declareLeastSquares<double, double, 0, 0>(mod);
Solver for linear least-squares problems.
PYBIND11_PLUGIN(_cameraPoint)
void declareLeastSquares(py::module &mod)
Factorization
Private implementation; forward-declared publicly so we can inherit from it in .cc.