#include <alpaqa/inner/detail/limited-memory-qr.hpp>
Incremental QR factorization using modified Gram-Schmidt with reorthogonalization.
Computes A = QR while allowing efficient removal of the first column of A or adding new columns at the end of A.
Definition at line 14 of file limited-memory-qr.hpp.
Public Types | |
template<class Derived > | |
using | solve_ret_t = std::conditional_t< Eigen::internal::traits< Derived >::ColsAtCompileTime==1, vec, mat > |
Public Member Functions | |
LimitedMemoryQR ()=default | |
LimitedMemoryQR (size_t n, size_t m) | |
size_t | n () const |
size_t | m () const |
template<class VecV > | |
void | add_column (const VecV &v) |
Add the given column to the right. More... | |
void | remove_column () |
Remove the leftmost column. More... | |
template<class VecB , class VecX > | |
void | solve_col (const VecB &b, VecX &x) const |
Solve the least squares problem Ax = b. More... | |
template<class MatB , class MatX > | |
void | solve (const MatB &B, MatX &X) const |
Solve the least squares problem AX = B. More... | |
template<class Derived > | |
solve_ret_t< Derived > | solve (const Eigen::DenseBase< Derived > &B) |
Solve the least squares problem AX = B. More... | |
const mat & | get_raw_Q () const |
Get the full, raw storage for the orthogonal matrix Q. More... | |
const mat & | get_raw_R () const |
Get the full, raw storage for the upper triangular matrix R. More... | |
mat | get_full_R () const |
Get the full storage for the upper triangular matrix R but with the columns in the correct order. More... | |
mat | get_R () const |
Get the matrix R such that Q times R is the original matrix. More... | |
mat | get_Q () const |
Get the matrix Q such that Q times R is the original matrix. More... | |
void | scale_R (real_t scal) |
Multiply the matrix R by a scalar. More... | |
size_t | get_reorth_count () const |
Get the number of MGS reorthogonalizations. More... | |
void | clear_reorth_count () |
Reset the number of MGS reorthogonalizations. More... | |
void | reset () |
Reset all indices, clearing the Q and R matrices. More... | |
void | resize (size_t n, size_t m) |
Re-allocate storage for a problem with a different size. More... | |
size_t | num_columns () const |
Get the number of columns that are currently stored. More... | |
size_t | ring_head () const |
Get the head index of the circular buffer (points to the oldest element). More... | |
size_t | ring_tail () const |
Get the tail index of the circular buffer (points to one past the most recent element). More... | |
size_t | ring_next (size_t i) const |
Get the next index in the circular buffer. More... | |
size_t | ring_prev (size_t i) const |
Get the previous index in the circular buffer. More... | |
CircularRange< size_t > | ring_iter () const |
Get iterators in the circular buffer. More... | |
ReverseCircularRange< size_t > | ring_reverse_iter () const |
Get reverse iterators in the circular buffer. More... | |
Private Member Functions | |
size_t | r_succ (size_t i) const |
Get the next index in the circular storage for R. More... | |
size_t | r_pred (size_t i) const |
Get the previous index in the circular storage for R. More... | |
Private Attributes | |
mat | Q |
Storage for orthogonal factor Q. More... | |
mat | R |
Storage for upper triangular factor R. More... | |
size_t | q_idx = 0 |
Number of columns of Q being stored. More... | |
size_t | r_idx_start = 0 |
Index of the first column of R. More... | |
size_t | r_idx_end = 0 |
Index of the one-past-last column of R. More... | |
size_t | reorth_count = 0 |
Number of MGS reorthogonalizations. More... | |
using solve_ret_t = std::conditional_t< Eigen::internal::traits<Derived>::ColsAtCompileTime == 1, vec, mat> |
Definition at line 154 of file limited-memory-qr.hpp.
|
default |
|
inline |
n | The size of the vectors, the number of rows of A. |
m | The maximum number of columns of A. |
The maximum dimensions of Q are n×m and the maximum dimensions of R are m×m.
Definition at line 25 of file limited-memory-qr.hpp.
|
inline |
|
inline |
|
inline |
Add the given column to the right.
Definition at line 32 of file limited-memory-qr.hpp.
|
inline |
Remove the leftmost column.
Definition at line 75 of file limited-memory-qr.hpp.
|
inline |
Solve the least squares problem Ax = b.
Definition at line 114 of file limited-memory-qr.hpp.
|
inline |
Solve the least squares problem AX = B.
Definition at line 141 of file limited-memory-qr.hpp.
|
inline |
Solve the least squares problem AX = B.
Definition at line 159 of file limited-memory-qr.hpp.
|
inline |
Get the full, raw storage for the orthogonal matrix Q.
Definition at line 166 of file limited-memory-qr.hpp.
|
inline |
Get the full, raw storage for the upper triangular matrix R.
The columns of this matrix are permuted because it's stored as a circular buffer for efficiently appending columns to the end and popping columns from the front.
Definition at line 171 of file limited-memory-qr.hpp.
|
inline |
Get the full storage for the upper triangular matrix R but with the columns in the correct order.
Definition at line 176 of file limited-memory-qr.hpp.
|
inline |
Get the matrix R such that Q times R is the original matrix.
Definition at line 190 of file limited-memory-qr.hpp.
|
inline |
Get the matrix Q such that Q times R is the original matrix.
Definition at line 197 of file limited-memory-qr.hpp.
|
inline |
Multiply the matrix R by a scalar.
Definition at line 200 of file limited-memory-qr.hpp.
|
inline |
Get the number of MGS reorthogonalizations.
Definition at line 206 of file limited-memory-qr.hpp.
|
inline |
Reset the number of MGS reorthogonalizations.
Definition at line 208 of file limited-memory-qr.hpp.
|
inline |
Reset all indices, clearing the Q and R matrices.
Definition at line 211 of file limited-memory-qr.hpp.
|
inline |
Re-allocate storage for a problem with a different size.
Causes a reset.
Definition at line 220 of file limited-memory-qr.hpp.
|
inline |
Get the number of columns that are currently stored.
Definition at line 227 of file limited-memory-qr.hpp.
|
inline |
Get the head index of the circular buffer (points to the oldest element).
Definition at line 230 of file limited-memory-qr.hpp.
|
inline |
Get the tail index of the circular buffer (points to one past the most recent element).
Definition at line 233 of file limited-memory-qr.hpp.
|
inline |
Get the next index in the circular buffer.
Definition at line 235 of file limited-memory-qr.hpp.
|
inline |
Get the previous index in the circular buffer.
Definition at line 237 of file limited-memory-qr.hpp.
|
inline |
Get iterators in the circular buffer.
Definition at line 240 of file limited-memory-qr.hpp.
|
inline |
Get reverse iterators in the circular buffer.
Definition at line 244 of file limited-memory-qr.hpp.
|
inlineprivate |
Get the next index in the circular storage for R.
Definition at line 259 of file limited-memory-qr.hpp.
|
inlineprivate |
Get the previous index in the circular storage for R.
Definition at line 261 of file limited-memory-qr.hpp.
|
private |
Storage for orthogonal factor Q.
Definition at line 249 of file limited-memory-qr.hpp.
|
private |
Storage for upper triangular factor R.
Definition at line 250 of file limited-memory-qr.hpp.
|
private |
Number of columns of Q being stored.
Definition at line 252 of file limited-memory-qr.hpp.
|
private |
Index of the first column of R.
Definition at line 253 of file limited-memory-qr.hpp.
|
private |
Index of the one-past-last column of R.
Definition at line 254 of file limited-memory-qr.hpp.
|
private |
Number of MGS reorthogonalizations.
Definition at line 256 of file limited-memory-qr.hpp.