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
int getDimension() const
Return the number of parameters.
ndarray::Array< double const, 2, 2 > getCovariance()
Return the covariance matrix of the least squares problem.
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...
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.
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.
Eigen matrix objects that present a view into an ndarray::Array.
Eigen::VectorXd & _getDataVector()
Eigen::VectorXd & _getRhsVector()
void setDesignMatrix(Eigen::MatrixBase< D1 > const &design)
Reset the design matrix given as an Eigen object; dimension and data are not changed.
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, ndarray::Array< T2, 1, C2 > const &data)
Reset the design matrix and data vector given as ndarrays; dimension must not change.
int getRank() const
Return the rank of the problem (number of nonzero Eigenvalues).
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.
Eigen::MatrixXd & _getDesignMatrix()
void setThreshold(double threshold)
Set the threshold used to determine when to truncate Eigenvalues.
Factorization getFactorization() const
Retun the type of factorization used by the solver.
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.
double getThreshold() const
Get the threshold used to determine when to truncate Eigenvalues.
A multidimensional strided array.
Factorization
Private implementation; forward-declared publicly so we can inherit from it in .cc.
void _factor(bool haveNormalEquations)
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.
Use the normal equations with a symmetric Eigensystem decomposition.
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...
ndarray::Array< double const, 2, 2 > getFisherMatrix()
Return the Fisher matrix (inverse of the covariance) of the parameters.
boost::shared_ptr< Impl > _impl
Eigen::MatrixXd & _getFisherMatrix()
ndarray::Array< double const, 1, 1 > getSolution()
Return the vector solution to the least squares problem.
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(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.