13 lines
210 B
Mathematica
13 lines
210 B
Mathematica
|
function pk = cauchy(B, g, deltak)
|
||
|
gbg = (g' * B * g);
|
||
|
|
||
|
if gbg <= 0
|
||
|
tau = 1;
|
||
|
else
|
||
|
tau = min(norm(g, 2)^3 / (deltak * gbg), 1);
|
||
|
end
|
||
|
|
||
|
pk = -tau * deltak / norm(g, 2) * g;
|
||
|
end
|
||
|
|