xref: /petsc/src/tao/unconstrained/impls/cg/taocg.h (revision 9dd11ecf0918283bb567d8b33a92f53ac4ea7840)
1 /*
2     Context for conjugate gradient method (unconstrained minimization)
3  */
4 
5 #pragma once
6 
7 #include <petsc/private/taoimpl.h>
8 
9 typedef struct {
10   Vec G_old;
11   Vec X_old;
12   Vec W; /*  work vector */
13 
14   PetscReal eta;       /*  Restart tolerance */
15   PetscReal delta_max; /*  Minimum value for scaling */
16   PetscReal delta_min; /*  Maximum value for scaling */
17 
18   /*  The algorithm restarts when the gradient at the current point g_k,
19        and the gradient of the previous point, g_{k-1}, satisfy the
20        following inequality:
21 
22             abs(inner(g_k, g_{k-1})) > eta * norm(g_k, 2)^2. */
23 
24   PetscInt ngradsteps;  /*  Number of gradient steps */
25   PetscInt nresetsteps; /*  Number of reset steps */
26 
27   PetscInt cg_type; /*  Formula to use */
28 } TAO_CG;
29