quala main
Quasi-Newton and other accelerators
Loading...
Searching...
No Matches
Namespaces | Functions | Variables
test_anderson.py File Reference

Go to the source code of this file.

Namespaces

namespace  test_anderson
 

Functions

def test_anderson ()
 

Variables

int n = 10
 
int ε = 1e-12
 
 rng = nprand.default_rng(seed=123)
 
 A = rng.random(size=(n, n))
 
 Q
 
 D = np.diag(rng.normal(scale=4, size=(n, )))
 
 q = rng.normal(scale=1, size=(n, ))
 
 x_ = cs.SX.sym('x', n)
 
float px = x_ + 0.2 * cs.sin(x_[::-1])
 
float f_ = 0.5 * (x_.T @ A @ px) + cs.dot(q, x_)
 
 f = cs.Function("f", [x_], [f_])
 
 grad_f_ = cs.gradient(f_, x_)
 
 grad_f = cs.Function("grad_f", [x_], [grad_f_])
 
 hess_f_ = cs.jacobian(grad_f_, x_)
 
 hess_f = cs.Function("hess_f", [x_], [hess_f_])
 
int L = la.norm(D)**2