Returns the residual vector for the lsqrsolve function.
r = uncprb_lsqrsolvefun ( x, m, nprob, n )
a n-by-1 matrix of doubles, the point where to compute f and g
a 1-by-1 matrix of doubles, integer value, the problem number
a 1-by-1 matrix of doubles, integer value, the number of variables, i.e. the size of x
a 1-by-1 matrix of doubles, integer value, the number of functions, i.e. the size of fvec
a m-by-1 matrix of doubles, the residual
This function is designed to be used to make the lsqrsolve solver optimize the problem #nprob. Indeed, the header of the uncprb_lsqrsolvefun function is the one required by the optim function.
// Check wrapper on problem #1 nprob = 1; [n,m,x0]=uncprb_getinitf(nprob); r = uncprb_lsqrsolvefun ( x0, m, nprob, n ) // r0 = [-4.4; 2.2] // Make lsqrsolve optimize the problem #1 nprob = 1; [n,m,x0]=uncprb_getinitf(nprob) [xopt, ropt,info]=lsqrsolve(x0,list(uncprb_lsqrsolvefun,nprob,n),m) // Make lsqrsolve optimize the problem #1 // Get the number of iterations, function and gradient evaluations nprob = 1; [n,m,x0]=uncprb_getinitf(nprob); uncprb_lsqrsolveinit(); objfun = list(uncprb_lsqrsolvefun,nprob,n); [xopt, ropt,info]=lsqrsolve(x0,objfun,m) [foptE,xoptE] = uncprb_getopt(nprob,n,m) goptE = uncprb_getgrdfcn(n,m,xoptE,nprob) [funeval,geval] = uncprb_lsqrsolveget() // 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_lsqrsolveinit(); objfun = list(uncprb_lsqrsolvefun,nprob,n); objjac = list(uncprb_lsqrsolvejac,nprob,n); [xopt, ropt,info]=lsqrsolve(x0,objfun,m,objjac) [foptE,xoptE] = uncprb_getopt(nprob,n,m) goptE = uncprb_getgrdfcn(n,m,xoptE,nprob) [funeval,geval] = uncprb_lsqrsolveget() | ![]() | ![]() |