25 #ifndef LSST_AFW_MATH_LeastSquares_h_INCLUDED
26 #define LSST_AFW_MATH_LeastSquares_h_INCLUDED
31 namespace lsst {
namespace afw {
namespace math {
98 template <
typename T1,
typename T2,
int C1,
int C2>
104 LeastSquares r(factorization, design.template getSize<1>());
110 template <
typename D1,
typename D2>
112 Eigen::MatrixBase<D1>
const & design,
113 Eigen::MatrixBase<D2>
const & data,
122 template <
typename T1,
typename T2,
int C1,
int C2>
137 template <
typename D1,
typename D2>
139 Eigen::MatrixBase<D1>
const & design,
140 Eigen::MatrixBase<D2>
const & data
148 template <
typename T1,
int C1>
155 template <
typename D1,
typename D2>
162 template <
typename T1,
typename T2,
int C1,
int C2>
168 LeastSquares r(factorization, fisher.template getSize<0>());
174 template <
typename D1,
typename D2>
176 Eigen::MatrixBase<D1>
const & fisher,
177 Eigen::MatrixBase<D2>
const & rhs,
186 template <
typename T1,
typename T2,
int C1,
int C2>
191 if ((C1 > 0) ==
bool(Eigen::MatrixXd::IsRowMajor)) {
201 template <
typename D1,
typename D2>
203 Eigen::MatrixBase<D1>
const & fisher,
204 Eigen::MatrixBase<D2>
const & rhs
206 if (
bool(Eigen::MatrixBase<D1>::IsRowMajor) ==
bool(Eigen::MatrixXd::IsRowMajor)) {
351 void _factor(
bool haveNormalEquations);
358 #endif // !LSST_AFW_MATH_LeastSquares_h_INCLUDED
Eigen matrix objects that present a view into an ndarray::Array.
static LeastSquares fromNormalEquations(ndarray::Array< T1, 2, C1 > const &fisher, ndarray::Array< T2, 1, C2 > const &rhs, Factorization factorization=NORMAL_EIGENSYSTEM)
Initialize from the terms in the normal equations, given as ndarrays.
void _factor(bool haveNormalEquations)
double getThreshold() const
Get the threshold used to determine when to truncate Eigenvalues.
void setThreshold(double threshold)
Set the threshold used to determine when to truncate Eigenvalues.
Eigen::VectorXd & _getDataVector()
EigenView< Element, ND::value, RMC::value, XprKind, Rows, Cols > asEigen() const
Solver for linear least-squares problems.
void setDesignMatrix(ndarray::Array< T1, 2, C1 > const &design)
Reset the design matrix given as an ndarray; dimension and data are not changed.
LeastSquares(Factorization factorization, int dimension)
Construct a least-squares object for the given factorization and dimensionality.
static LeastSquares fromDesignMatrix(ndarray::Array< T1, 2, C1 > const &design, ndarray::Array< T2, 1, C2 > const &data, Factorization factorization=NORMAL_EIGENSYSTEM)
Initialize from the design matrix and data vector given as ndarrays.
Use a thin singular value decomposition of the design matrix.
void setNormalEquations(ndarray::Array< T1, 2, C1 > const &fisher, ndarray::Array< T2, 1, C2 > const &rhs)
Reset the terms in the normal equations given as ndarrays; dimension must not change.
Use the normal equations with a Cholesky decomposition.
int getRank() const
Return the rank of the problem (number of nonzero Eigenvalues).
Use the normal equations with a symmetric Eigensystem decomposition.
ndarray::Array< double const, 1, 1 > getDiagnostic(Factorization factorization)
Return a factorization-dependent vector that can be used to characterize the stability of the solutio...
void setDesignMatrix(Eigen::MatrixBase< D1 > const &design, Eigen::MatrixBase< D2 > const &data)
Reset the design matrix and data vector given as Eigen objects; dimension must not change...
void setDesignMatrix(ndarray::Array< T1, 2, C1 > const &design, ndarray::Array< T2, 1, C2 > const &data)
Reset the design matrix and data vector given as ndarrays; dimension must not change.
boost::shared_ptr< Impl > _impl
void setDesignMatrix(Eigen::MatrixBase< D1 > const &design)
Reset the design matrix given as an Eigen object; dimension and data are not changed.
ndarray::Array< double const, 2, 2 > getCovariance()
Return the covariance matrix of the least squares problem.
A multidimensional strided array.
static LeastSquares fromDesignMatrix(Eigen::MatrixBase< D1 > const &design, Eigen::MatrixBase< D2 > const &data, Factorization factorization=NORMAL_EIGENSYSTEM)
Initialize from the design matrix and data vector given as an Eigen objects.
Factorization
Private implementation; forward-declared publicly so we can inherit from it in .cc.
void setNormalEquations(Eigen::MatrixBase< D1 > const &fisher, Eigen::MatrixBase< D2 > const &rhs)
Reset the terms in the normal equations given as Eigen objects; dimension must not change...
Factorization getFactorization() const
Retun the type of factorization used by the solver.
ndarray::Array< double const, 1, 1 > getSolution()
Return the vector solution to the least squares problem.
Eigen::MatrixXd & _getFisherMatrix()
static LeastSquares fromNormalEquations(Eigen::MatrixBase< D1 > const &fisher, Eigen::MatrixBase< D2 > const &rhs, Factorization factorization=NORMAL_EIGENSYSTEM)
Initialize from the terms in the normal equations, given as Eigen objects.
Eigen::MatrixXd & _getDesignMatrix()
int getDimension() const
Return the number of parameters.
ndarray::Array< double const, 2, 2 > getFisherMatrix()
Return the Fisher matrix (inverse of the covariance) of the parameters.
Eigen::VectorXd & _getRhsVector()