init f 1.403e+07
iter 1 f 5.390e+06 |g| 6.197e+05 CG 2 step_size 1.00e+00
we indeed print
f(w_k) |g(w_{k-1})|
So |g| 6.197e+05 is the grad at f(0) = 1.403e+07.
The output is changed to
init f 1.403e+07 |g| 6.197e+05
iter 1 f 5.390e+06 |g| 2.118e+05 CG 2 step_size 1.00e+00
iter 2 f 1.925e+06 |g| 7.244e+04 CG 4 step_size 1.00e+00
Each line shows the new f and |g| after an iteration with
CG steps and line search step_size
- in pcg(), we calculate
alpha = zTr/ddot_(&n, d, &inc, Hd, &inc);
before the stopping condition based on quadratic approximations.
But after the previous CG step, the new zTr and dHd may both be zero
(or very close to zero). Then 0/0 may occur. In such a situation CG
should stop. Now a safeguard check is added: