Class for solving a constrained least squares problem. More...
#include <ptems/linearalgebra.hpp>
Public Member Functions | |
ConstrainedLeastSquares (std::size_t rows, std::size_t cols, std::size_t constraints) | |
Create the constrained least squares problem: find \(x\in T^n\) which minimises. More... | |
std::size_t | ColumnCount () const |
Gets the size of the linear system. More... | |
std::size_t | RowCount () const |
Gets the size of the linear system. More... | |
std::size_t | ConstraintCount () const |
Gets the size of the linear system. More... | |
T & | operator() (std::size_t i, std::size_t j) |
Gets mutable reference to the specified entry of the matrix \(A\). More... | |
T & | Constraint (std::size_t i, std::size_t j) |
Gets mutable reference to the specified entry of the constraint matrix \(C\). More... | |
std::vector< T > & | Solve (std::vector< T > &rhs, const std::vector< T > &constraintRHS) |
Solves the constrained least squares problem. More... | |
Class for solving a constrained least squares problem.
The constrained least squares problem is to find \(x\in T^n\) which minimises
\[\Vert Ax - b \Vert^2\]
subject to the constraints
\[Cx = d\]
where \(A\in T^{m\times n}\), \(C\in T^{p\times n}\), \(x\in T^m\) and \(d\in T^p\).
T | The type of the entries of the least squares system |
|
inline |
Create the constrained least squares problem: find \(x\in T^n\) which minimises.
\[\Vert Ax - b \Vert^2\]
subject to the constraints
\[Cx = d\]
where \(A\in T^{m\times n}\), \(C\in T^{p\times n}\), \(x\in T^m\) and \(d\in T^p\).
rows | Number of rows ( \(m\)) in the matrix |
cols | Number of columns ( \(n\)) in the matrix |
constraints | Number of constraints ( \(p\)) |
|
inline |
Gets the size of the linear system.
|
inline |
Gets mutable reference to the specified entry of the constraint matrix \(C\).
std::out_of_range | If the row or column index is greater or equal to the number or constraints or columns, respectively |
std::logic_error | If Solve() has been called already |
i | The row index of the entry to get |
j | The column index of the entry to get |
|
inline |
Gets the size of the linear system.
|
inline |
Gets mutable reference to the specified entry of the matrix \(A\).
std::out_of_range | If the row or column index is greater or equal to the number or rows or columns, respectively |
std::logic_error | If Solve() has been called already |
i | The row index of the entry to get |
j | The column index of the entry to get |
|
inline |
Gets the size of the linear system.
|
inline |
Solves the constrained least squares problem.
std::invalid_argument | If rhs.size() != number of columns, or constraintRHS.size() != number of constraints |
rhs | The mutable vector containing \(b\) which is updated with \(x\) on return |
constraintRHS | The right hand side vector \(d\) for the constraints |