<< uncprb_computestatus Benchmark uncprb_leastsqget >>

Unconstrained Optimization Problems Toolbox >> Unconstrained Optimization Problems Toolbox > Benchmark > uncprb_leastsqfun

uncprb_leastsqfun

Returns the residual vector for the leastsq function.

Calling Sequence

r = uncprb_leastsqfun ( x, m, nprob, n )

Parameters

x:

a n-by-1 matrix of doubles, the point where to compute f and g

nprob:

a 1-by-1 matrix of doubles, integer value, the problem number

n:

a 1-by-1 matrix of doubles, integer value, the number of variables, i.e. the size of x

m:

a 1-by-1 matrix of doubles, integer value, the number of functions, i.e. the size of fvec

r:

a m-by-1 matrix of doubles, the residual

Description

This function is designed to be used to make the leastsq solver optimize the problem #nprob. Indeed, the header of the uncprb_leastsqfun function is the one required by the leastsq function.

Examples

// Check wrapper on problem #1
nprob = 1;
[n,m,x0]=uncprb_getinitf(nprob);
r = uncprb_leastsqfun ( x0, m, nprob, n )
// r0 = [-4.4; 2.2]

// Make leastsq optimize the problem #1
nprob = 1;
[n,m,x0]=uncprb_getinitf(nprob)
objfun = list(uncprb_leastsqfun, m, nprob, n);
[fopt,xopt,gopt]=leastsq(objfun,x0)

// Make leastsq optimize the problem #1
// Get the number of iterations, function and gradient evaluations
nprob = 1;
[n,m,x0]=uncprb_getinitf(nprob);
uncprb_leastsqinit();
objfun = list(uncprb_leastsqfun, m, nprob, n);
[fopt,xopt,gopt]=leastsq(objfun,x0)
[foptE,xoptE] = uncprb_getopt(nprob,n,m)
goptE = uncprb_getgrdfcn(n,m,xoptE,nprob)
[funeval,Jeval] = uncprb_leastsqget()

// Make lsqrsolve optimize the problem #1
// With Jacobian
// Get the number of iterations, function and gradient evaluations
nprob = 1;
[n,m,x0]=uncprb_getinitf(nprob);
uncprb_leastsqinit();
objfun = list(uncprb_leastsqfun, m, nprob, n);
[fopt,xopt,gopt]=leastsq(objfun,uncprb_leastsqjac,x0)
[foptE,xoptE] = uncprb_getopt(nprob,n,m)
goptE = uncprb_getgrdfcn(n,m,xoptE,nprob)
[funeval,Jeval] = uncprb_leastsqget()

Authors

<< uncprb_computestatus Benchmark uncprb_leastsqget >>