55 assert(g_0.size() == vec::Index(
n()));
56 assert(r_0.size() == vec::Index(
n()));
58 rₗₐₛₜ = std::move(r_0);
68 throw std::logic_error(
"AndersonAccel::compute() called before "
69 "AndersonAccel::initialize()");
78 throw std::logic_error(
"AndersonAccel::compute() called before "
79 "AndersonAccel::initialize()");
83 rₗₐₛₜ = std::move(rₖ);
90 if (newest_g_idx != 0)
91 G.col(0) =
G.col(newest_g_idx);
AndersonAccel(Params params, length_t n)
length_t current_history() const
Get the number of columns currently stored in the buffer.
length_t n() const
Get the problem dimension.
void compute(crvec gₖ, crvec rₖ, rvec xₖ_aa)
Compute the accelerated iterate , given the function value at the current iterate and the correspond...
void initialize(crvec g_0, vec r_0)
Call this function on the first iteration to initialize the accelerator.
const Params & get_params() const
Get the parameters.
length_t history() const
Get the maximum number of stored columns.
AndersonAccel(Params params)
void resize(length_t n)
Change the problem dimension.
void reset()
Reset the accelerator (but keep the last function value and residual, so calling initialize is not ne...
void compute(crvec gₖ, vec &&rₖ, rvec xₖ_aa)
Compute the accelerated iterate , given the function value at the current iterate and the correspond...
Incremental QR factorization using modified Gram-Schmidt with reorthogonalization.
length_t current_history() const
Get the number of columns currently stored in the buffer.
index_t ring_tail() const
Get the tail index of the circular buffer (points to one past the most recent element).
void resize(length_t n, length_t m)
Re-allocate storage for a problem with a different size.
void reset()
Reset all indices, clearing the Q and R matrices.
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
length_t memory
Length of the history to keep (the number of columns in the QR factorization).
realmat mat
Default type for matrices.
index_t length_t
Default type for vector sizes.
void minimize_update_anderson(LimitedMemoryQR &qr, rmat G, crvec rₖ, crvec rₗₐₛₜ, crvec gₖ, rvec γ_LS, rvec xₖ_aa)
Solve one step of Anderson acceleration to find a fixed point of a function g(x):
realvec vec
Default type for vectors.
Eigen::Index index_t
Default type for vector indices.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Parameters for the AndersonAccel class.