14template <Config Conf = DefaultConfig>
38template <Config Conf = DefaultConfig>
68 assert(g_0.size() ==
n());
69 assert(r_0.size() ==
n());
81 throw std::logic_error(
"AndersonAccel::compute() called before "
82 "AndersonAccel::initialize()");
91 throw std::logic_error(
"AndersonAccel::compute() called before "
92 "AndersonAccel::initialize()");
96 rₗₐₛₜ = std::move(rₖ);
103 if (newest_g_idx != 0)
104 G.col(0) =
G.col(newest_g_idx);
119 return "AndersonAccel<" + std::string(config_t::get_name()) +
'>';
std::string get_name() const
AndersonAccel(Params params, length_t n)
length_t current_history() const
Get the number of columns currently stored in the buffer.
LimitedMemoryQR< config_t > qr
void compute(crvec gₖ, crvec rₖ, rvec xₖ_aa)
Compute the accelerated iterate , given the function value at the current iterate and the correspond...
const Params & get_params() const
Get the parameters.
length_t history() const
Get the maximum number of stored columns.
void initialize(crvec g_0, crvec r_0)
Call this function on the first iteration to initialize the accelerator.
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...
AndersonAccelParams< config_t > Params
void scale_R(real_t scal)
Scale the factorization.
void compute(crvec gₖ, vec &&rₖ, rvec xₖ_aa)
Compute the accelerated iterate , given the function value at the current iterate and the correspond...
const LimitedMemoryQR< config_t > & get_QR() const
For testing purposes.
Incremental QR factorization using modified Gram-Schmidt with reorthogonalization.
#define USING_ALPAQA_CONFIG(Conf)
Parameters for the AndersonAccel class.
typename Conf::real_t real_t
typename Conf::index_t index_t
typename Conf::length_t length_t
typename Conf::crvec crvec
void minimize_update_anderson(LimitedMemoryQR< Conf > &qr, rmat< Conf > G̃, crvec< Conf > rₖ, crvec< Conf > rₗₐₛₜ, crvec< Conf > gₖ, real_t< Conf > min_div_fac, rvec< Conf > γ_LS, rvec< Conf > xₖ_aa)
Solve one step of Anderson acceleration to find a fixed point of a function g(x):