/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: RELVALS -- computes RELB and RELGRAD, which are used in testing for convergence. call as: relb=relvals(b,db,g,vof,typb,typf,"relgrad"); INPUTS b -- vector of coefficient estimates db -- change in coefficient estimates: b-b0 g -- current gradient vector of objective function. vof -- current value of the objective function. typb -- a user-specified parameter which is a vector of the "typical" values of the parameters. If scalar 1, will convert to a kx1 vector of 1's. This value is used to do a fix-up when elements of b fall below typb. This fix-up is necessary if elements of b approach 0, and can be useful otherwise in controlling the convergence criteria. typf -- a user-specified parameter which is the "typical" value of the objective function at the optimum. It is like typb. OUTPUTS relb -- this is returned directly; it is the "relative" change in the parameters; see the code below. relgrad -- this is returned as a global with VARPUT; it is essentially the elasticity of the function with respect to the parameters; see the code below. ............................................................................*/ proc 1=relvals(b,db,g,vof,typb,typf,retvar1); /* returns relgrad directly -- returns retvar1 to memory */ local fb, fvof, relgrad, relb; if rows(typb) ne rows(b); /* If typb not right size, use 1's as default */ typb=ones(rows(b),1); endif; fb=maxc(abs(b)|typb); fvof=maxc(abs(vof)|typf); relgrad=abs(g).*(fb/fvof); /* Relative gradients (elasticities of ofn) */ relb=abs(db)./fb; /* Proportionate changes in parameters. */ call varput(relb,retvar1); retp(relgrad); endp;  .