


% [x,v,nev,h,args] = d2_min(f,d2f,args,ctl,code) - Newton-like minimization
%
% Minimize f(x) using 1st and 2nd derivatives. Any function w/ second
% derivatives can be minimized, as in Newton. f(x) decreases at each
% iteration, as in Levenberg-Marquardt. This function is inspired from the
% Levenberg-Marquardt algorithm found in the book 'Numerical Recipes'.
%
% ARGUMENTS :
% f : string : Cost function's name
%
% d2f : string : Name of function returning the cost (1x1), its
% differential (1xN) and its second differential or it's
% pseudo-inverse (NxN) (see ctl(5) below) :
%
% [v,dv,d2v] = d2f (x).
%
% args : list : f and d2f's arguments. By default, minimize the 1st
% or matrix : argument.
%
% ctl : vector : Control arguments (see below)
% or struct
%
% code : string : code will be evaluated after each outer loop that
% produced some (any) improvement. Variables visible from
% 'code' include 'x', the best parameter found, 'v' the
% best value and 'args', the list of all arguments. All can
% be modified. This option can be used to re-parameterize
% the argument space during optimization
%
% CONTROL VARIABLE ctl : (optional). May be a struct or a vector of length
% ---------------------- 5 or less where NaNs are ignored. Default values
% are written <value>.
% FIELD VECTOR
% NAME POS
%
% ftol, f N/A : Stop search when value doesn't improve, as tested by
%
% f > Deltaf/max(|f(x)|,1)
%
% where Deltaf is the decrease in f observed in the last
% iteration. <10*sqrt(eps)>
%
% utol, u N/A : Stop search when updates are small, as tested by
%
% u > max { dx(i)/max(|x(i)|,1) | i in 1..N }
%
% where dx is the change in the x that occured in the last
% iteration. <NaN>
%
% dtol, d N/A : Stop search when derivative is small, as tested by
%
% d > norm (dv) <eps>
%
% crit, c ctl(1) : Set one stopping criterion, 'ftol' (c=1), 'utol' (c=2)
% or 'dtol' (c=3) to the value of by the 'tol' option. <1>
%
% tol, t ctl(2) : Threshold in termination test chosen by 'crit' <10*eps>
%
% narg, n ctl(3) : Position of the minimized argument in args <1>
% maxev,m ctl(4) : Maximum number of function evaluations <inf>
% maxout,m : Maximum number of outer loops <inf>
% id2f, i ctl(5) : 0 if d2f returns the 2nd derivatives, 1 if <0>
% it returns its pseudo-inverse.
%
% verbose, v N/A : Be more or less verbose (quiet=0) <0>