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

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
 

Function Documentation

◆ test_anderson()

def test_anderson ( )

Definition at line 35 of file test_anderson.py.

Variable Documentation

◆ n

int n = 10

Definition at line 9 of file test_anderson.py.

◆ ε

int ε = 1e-12

Definition at line 10 of file test_anderson.py.

◆ rng

rng = nprand.default_rng(seed=123)

Definition at line 13 of file test_anderson.py.

◆ A

A = rng.random(size=(n, n))

Definition at line 14 of file test_anderson.py.

◆ Q

Q

Definition at line 15 of file test_anderson.py.

◆ D

D = np.diag(rng.normal(scale=4, size=(n, )))

Definition at line 16 of file test_anderson.py.

◆ q

q = rng.normal(scale=1, size=(n, ))

Definition at line 18 of file test_anderson.py.

◆ x_

x_ = cs.SX.sym('x', n)

Definition at line 20 of file test_anderson.py.

◆ px

float px = x_ + 0.2 * cs.sin(x_[::-1])

Definition at line 21 of file test_anderson.py.

◆ f_

float f_ = 0.5 * (x_.T @ A @ px) + cs.dot(q, x_)

Definition at line 22 of file test_anderson.py.

◆ f

f = cs.Function("f", [x_], [f_])

Definition at line 23 of file test_anderson.py.

◆ grad_f_

grad_f_ = cs.gradient(f_, x_)

Definition at line 24 of file test_anderson.py.

◆ grad_f

grad_f = cs.Function("grad_f", [x_], [grad_f_])

Definition at line 25 of file test_anderson.py.

◆ hess_f_

hess_f_ = cs.jacobian(grad_f_, x_)

Definition at line 26 of file test_anderson.py.

◆ hess_f

hess_f = cs.Function("hess_f", [x_], [hess_f_])

Definition at line 27 of file test_anderson.py.

◆ L

int L = la.norm(D)**2

Definition at line 28 of file test_anderson.py.