ERKALE
ERKALE - DFT from Hel
 All Classes Functions Variables Friends Pages
lbfgs.h
1 /*
2  * This source code is part of
3  *
4  * E R K A L E
5  * -
6  * HF/DFT from Hel
7  *
8  * Copyright © 2015 The Regents of the University of California
9  * All Rights Reserved
10  *
11  * Written by Susi Lehtola, Lawrence Berkeley National Laboratory
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  */
18 
19 #ifndef ERKALE_LBFGS
20 #define ERKALE_LBFGS
21 
22 #include "global.h"
23 #include <armadillo>
24 
25 class LBFGS {
26  protected:
28  size_t nmax;
29 
31  std::vector<arma::vec> xk;
33  std::vector<arma::vec> gk;
34 
36  virtual arma::vec diagonal_hessian(const arma::vec & q) const;
37 
38  public:
40  LBFGS(size_t nmax=10);
42  virtual ~LBFGS();
43 
45  void update(const arma::vec & x, const arma::vec & g);
47  arma::vec solve() const;
49  void clear();
50 };
51 
52 #endif
std::vector< arma::vec > gk
Gradients g_k.
Definition: lbfgs.h:33
virtual ~LBFGS()
Destructor.
Definition: lbfgs.cpp:24
void update(const arma::vec &x, const arma::vec &g)
Update.
Definition: lbfgs.cpp:27
std::vector< arma::vec > xk
Coordinates x_k.
Definition: lbfgs.h:31
virtual arma::vec diagonal_hessian(const arma::vec &q) const
Apply diagonal Hessian: r = H_0 q.
Definition: lbfgs.cpp:37
Definition: lbfgs.h:25
arma::vec solve() const
Solve for new search direction.
Definition: lbfgs.cpp:49
size_t nmax
Maximum number of matrices.
Definition: lbfgs.h:28
void clear()
Clear stack.
Definition: lbfgs.cpp:86
LBFGS(size_t nmax=10)
Constructor.
Definition: lbfgs.cpp:21