ext/lbfgsb/src/lbfgsb.c in lbfgsb-0.4.1 vs ext/lbfgsb/src/lbfgsb.c in lbfgsb-0.5.0

- old
+ new

@@ -41,18 +41,18 @@ * Instituto Tecnologico Autonomo de Mexico * Mexico D.F. Mexico. * * March 2011 */ - -#include "lbfgsb.h" #include "blas.h" #include "linpack.h" +#include "lbfgsb.h" + static double c_b9 = 0.; -static long c__1 = 1; -static long c__11 = 11; +static F77_int c__1 = 1; +static F77_int c__11 = 11; static double c_b280 = .001; static double c_b281 = .9; static double c_b282 = .1; /** @@ -61,15 +61,15 @@ * This subroutine partitions the working arrays wa and iwa, and * then uses the limited memory BFGS method to solve the bound * constrained optimization problem by calling mainlb. * (The direct method will be used in the subspace minimization.) * - * n is an long variable. + * n is an integer variable. * On entry n is the dimension of the problem. * On exit n is unchanged. * - * m is an long variable. + * m is an integer variable. * On entry m is the maximum number of variable metric corrections * used to define the limited memory matrix. * On exit m is unchanged. * * x is a double precision array of dimension n. @@ -82,11 +82,11 @@ * * u is a double precision array of dimension n. * On entry u is the upper bound on x. * On exit u is unchanged. * - * nbd is an long array of dimension n. + * nbd is an integer array of dimension n. * On entry nbd represents the type of bounds imposed on the * variables, and must be specified as follows: * nbd(i)=0 if x(i) is unbounded, * 1 if x(i) has only a lower bound, * 2 if x(i) has both lower and upper bounds, and @@ -124,16 +124,16 @@ * On exit pgtol is unchanged. * * wa is a double precision working array of length * (2mmax + 5)nmax + 12mmax^2 + 12mmax. * - * iwa is an long working array of length 3nmax. + * iwa is an integer working array of length 3nmax. * * task is a working string of characters of length 60 indicating * the current job when entering and quitting this subroutine. * - * iprint is an long variable that must be set by the user. + * iprint is an integer variable that must be set by the user. * It controls the frequency and type of output generated: * iprint<0 no output is generated; * iprint=0 print only one line at the last iteration; * 0<iprint<99 print also f and |proj g| every iprint iterations; * iprint=99 print details of every iteration except n-vectors; @@ -151,11 +151,11 @@ * its projection in the feasible set; * If lsave(2) = .true. then the problem is constrained; * If lsave(3) = .true. then each variable has upper and lower * bounds; * - * isave is an long working array of dimension 44. + * isave is an integer working array of dimension 44. * On exit with 'task' = NEW_X, the following information is * available: * isave(22) = the total number of intervals explored in the * search of Cauchy points; * isave(26) = the total number of skipped BFGS updates before @@ -230,15 +230,15 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double* f, double* g, double* factr, double* pgtol, - double* wa, long* iwa, char* task, long* iprint, char* csave, long* lsave, long* isave, double* dsave) { - long i__1; +void setulb_(F77_int* n, F77_int* m, double* x, double* l, double* u, F77_int* nbd, double* f, double* g, double* factr, double* pgtol, + double* wa, F77_int* iwa, char* task, F77_int* iprint, char* csave, F77_int* lsave, F77_int* isave, double* dsave) { + F77_int i__1; - static long ld, lr, lt, lz, lwa, lwn, lss, lxp, lws, lwt, lsy, lwy, lsnd; + static F77_int ld, lr, lt, lz, lwa, lwn, lss, lxp, lws, lwt, lsy, lwy, lsnd; /* jlm-jn */ --iwa; --g; --nbd; @@ -284,24 +284,23 @@ lxp = isave[15]; lwa = isave[16]; mainlb_(n, m, &x[1], &l[1], &u[1], &nbd[1], f, &g[1], factr, pgtol, &wa[lws], &wa[lwy], &wa[lsy], &wa[lss], &wa[lwt], &wa[lwn], &wa[lsnd], &wa[lz], &wa[lr], &wa[ld], &wa[lt], &wa[lxp], &wa[lwa], &iwa[1], &iwa[*n + 1], &iwa[(*n << 1) + 1], task, iprint, csave, &lsave[1], &isave[22], &dsave[1]); - return 0; } /** * Subroutine mainlb * * This subroutine solves bound constrained optimization problems by * using the compact formula of the limited memory BFGS updates. * - * n is an long variable. + * n is an integer variable. * On entry n is the number of variables. * On exit n is unchanged. * - * m is an long variable. + * m is an integer variable. * On entry m is the maximum number of variable metric * corrections allowed in the limited memory matrix. * On exit m is unchanged. * * x is a double precision array of dimension n. @@ -314,11 +313,11 @@ * * u is a double precision array of dimension n. * On entry u is the upper bound of x. * On exit u is unchanged. * - * nbd is an long array of dimension n. + * nbd is an integer array of dimension n. * On entry nbd represents the type of bounds imposed on the * variables, and must be specified as follows: * nbd(i)=0 if x(i) is unbounded, * 1 if x(i) has only a lower bound, * 2 if x(i) has both lower and upper bounds, @@ -382,32 +381,32 @@ * the Newton point. * xp is used to safeguard the projected Newton direction * * sg(m),sgo(m),yg(m),ygo(m) are double precision working arrays. * - * index is an long working array of dimension n. + * index is an integer working array of dimension n. * In subroutine freev, index is used to store the free and fixed * variables at the Generalized Cauchy Point (GCP). * - * iwhere is an long working array of dimension n used to record + * iwhere is an integer working array of dimension n used to record * the status of the vector x for GCP computation. * iwhere(i)=0 or -3 if x(i) is free and has bounds, * 1 if x(i) is fixed at l(i), and l(i) .ne. u(i) * 2 if x(i) is fixed at u(i), and u(i) .ne. l(i) * 3 if x(i) is always fixed, i.e., u(i)=x(i)=l(i) * -1 if x(i) is always free, i.e., no bounds on it. * - * indx2 is an long working array of dimension n. + * indx2 is an integer working array of dimension n. * Within subroutine cauchy, indx2 corresponds to the array iorder. * In subroutine freev, a list of variables entering and leaving * the free set is stored in indx2, and it is passed on to * subroutine formk with this information. * * task is a working string of characters of length 60 indicating * the current job when entering and leaving this subroutine. * - * iprint is an long variable that must be set by the user. + * iprint is an integer variable that must be set by the user. * It controls the frequency and type of output generated: * iprint<0 no output is generated; * iprint=0 print only one line at the last iteration; * 0<iprint<99 print also f and |proj g| every iprint iterations; * iprint=99 print details of every iteration except n-vectors; @@ -418,11 +417,11 @@ * * csave is a working string of characters of length 60. * * lsave is a logical working array of dimension 4. * - * isave is an long working array of dimension 23. + * isave is an integer working array of dimension 23. * * dsave is a double precision working array of dimension 29. * * * Subprograms called @@ -463,55 +462,55 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int mainlb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double* f, double* g, double* factr, double* pgtol, +void mainlb_(F77_int* n, F77_int* m, double* x, double* l, double* u, F77_int* nbd, double* f, double* g, double* factr, double* pgtol, double* ws, double* wy, double* sy, double* ss, double* wt, double* wn, double* snd, double* z__, double* r__, - double* d__, double* t, double* xp, double* wa, long* index, long* iwhere, long* indx2, char* task, long* iprint, - char* csave, long* lsave, long* isave, double* dsave) { - long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, wt_dim1, wt_offset, wn_dim1, wn_offset, + double* d__, double* t, double* xp, double* wa, F77_int* index, F77_int* iwhere, F77_int* indx2, char* task, F77_int* iprint, + char* csave, F77_int* lsave, F77_int* isave, double* dsave) { + F77_int ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, wt_dim1, wt_offset, wn_dim1, wn_offset, snd_dim1, snd_offset, i__1; double d__1, d__2; FILE* itfptr; - static long i__, k; + static F77_int i__, k; static double gd, dr, rr, dtd; - static long col; + static F77_int col; static double tol; - static long wrk; + static F77_int wrk; static double stp, cpu1, cpu2; - static long head; + static F77_int head; static double fold; - static long nact; + static F77_int nact; static double ddum; - static long info, nseg; + static F77_int info, nseg; static double time; - static long nfgv, ifun, iter; + static F77_int nfgv, ifun, iter; static char word[4]; static double time1, time2; - static long iback; + static F77_int iback; static double gdold; - static long nfree; - static long boxed; - static long itail; + static F77_int nfree; + static F77_int boxed; + static F77_int itail; static double theta; static double dnorm; - static long nskip, iword; + static F77_int nskip, iword; static double xstep, stpmx; - static long ileave; + static F77_int ileave; static double cachyt; - static long itfile; + static F77_int itfile; static double epsmch; - static long updatd; + static F77_int updatd; static double sbtime; - static long prjctd; - static long iupdat; + static F77_int prjctd; + static F77_int iupdat; static double sbgnrm; - static long cnstnd; - static long nenter; + static F77_int cnstnd; + static F77_int nenter; static double lnscht; - static long nintol; + static F77_int nintol; --indx2; --iwhere; --index; --xp; @@ -598,11 +597,11 @@ /* Check the input arguments for errors. */ errclb_(n, m, factr, &l[1], &u[1], &nbd[1], task, &info, &k); if (strncmp(task, "ERROR", 5) == 0) { prn3lb_(n, &x[1], f, task, iprint, &info, &itfile, &iter, &nfgv, &nintol, &nskip, &nact, &sbgnrm, &c_b9, &nseg, word, &iback, &stp, &xstep, &k, &cachyt, &sbtime, &lnscht); - return 0; + return; } prn1lb_(n, m, &l[1], &u[1], &x[1], iprint, &itfile, &epsmch); /* Initialize iwhere & project x onto the feasible set. */ active_(n, &l[1], &u[1], &nbd[1], &x[1], &iwhere[1], iprint, &prjctd, &cnstnd, &boxed); /* The end of the initialization. */ @@ -658,12 +657,12 @@ goto L111; } if (strncmp(task, "STOP", 4) == 0) { if (strncmp(task + 6, "CPU", 3) == 0) { /* restore the previous iterate. */ - lbfgsb_rb_dcopy_(n, &t[1], &c__1, &x[1], &c__1); - lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &g[1], &c__1); + dcopy_(n, &t[1], &c__1, &x[1], &c__1); + dcopy_(n, &r__[1], &c__1, &g[1], &c__1); *f = fold; } goto L999; } } @@ -674,13 +673,13 @@ L111: nfgv = 1; /* Compute the infinity norm of the (-) projected gradient. */ projgr_(n, &l[1], &u[1], &nbd[1], &x[1], &g[1], &sbgnrm); if (*iprint >= 1) { - fprintf(stdout, "\nAt iterate%5ld f= %12.5E |proj g|= %12.5E\n", iter, *f, sbgnrm); + fprintf(stdout, "\nAt iterate%5" PRIdF77INT " f= %12.5E |proj g|= %12.5E\n", iter, *f, sbgnrm); itfptr = fopen("iterate.dat", "a"); - fprintf(itfptr, " %4ld %4ld - - - - - - %10.3E %10.3E\n", iter, nfgv, sbgnrm, *f); + fprintf(itfptr, " %4" PRIdF77INT " %4" PRIdF77INT " - - - - - - %10.3E %10.3E\n", iter, nfgv, sbgnrm, *f); fclose(itfptr); } if (sbgnrm <= *pgtol) { /* terminate the algorithm. */ strcpy(task, "CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL"); @@ -688,17 +687,17 @@ } /* ----------------- the beginning of the loop -------------------------- */ L222: if (*iprint >= 99) { i__1 = iter + 1; - fprintf(stdout, "\n\nITERATION %5ld\n", i__1); + fprintf(stdout, "\n\nITERATION %5" PRIdF77INT "\n", i__1); } iword = -1; if (!cnstnd && col > 0) { /* skip the search for GCP. */ - lbfgsb_rb_dcopy_(n, &x[1], &c__1, &z__[1], &c__1); + dcopy_(n, &x[1], &c__1, &z__[1], &c__1); wrk = updatd; nseg = 0; goto L333; } /** @@ -813,12 +812,12 @@ L666: lnsrlb_(n, &l[1], &u[1], &nbd[1], &x[1], f, &fold, &gd, &gdold, &g[1], &d__[1], &r__[1], &t[1], &z__[1], &stp, &dnorm, &dtd, &xstep, &stpmx, &iter, &ifun, &iback, &nfgv, &info, task, &boxed, &cnstnd, csave, &isave[22], &dsave[17]); if (info != 0 || iback >= 20) { /* restore the previous iterate. */ - lbfgsb_rb_dcopy_(n, &t[1], &c__1, &x[1], &c__1); - lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &g[1], &c__1); + dcopy_(n, &t[1], &c__1, &x[1], &c__1); + dcopy_(n, &r__[1], &c__1, &g[1], &c__1); *f = fold; if (col == 0) { /* abnormal termination. */ if (info == 0) { info = -9; @@ -888,17 +887,17 @@ /* Compute d=newx-oldx, r=newg-oldg, rr=y'y and dr=y's. */ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { r__[i__] = g[i__] - r__[i__]; } - rr = lbfgsb_rb_ddot_(n, &r__[1], &c__1, &r__[1], &c__1); + rr = ddot_(n, &r__[1], &c__1, &r__[1], &c__1); if (stp == 1.) { dr = gd - gdold; ddum = -gdold; } else { dr = (gd - gdold) * stp; - lbfgsb_rb_dscal_(n, &stp, &d__[1], &c__1); + dscal_(n, &stp, &d__[1], &c__1); ddum = -gdold * stp; } if (dr <= epsmch * ddum) { /* skip the L-BFGS update. */ ++nskip; @@ -986,20 +985,19 @@ dsave[12] = stpmx; dsave[13] = sbgnrm; dsave[14] = stp; dsave[15] = gdold; dsave[16] = dtd; - return 0; } /** * Subroutine active * * This subroutine initializes iwhere and projects the initial x to * the feasible set if necessary. * - * iwhere is an long array of dimension n. + * iwhere is an integer array of dimension n. * On entry iwhere is unspecified. * On exit iwhere(i)=-1 if x(i) has no bounds * 3 if l(i)=u(i) * 0 otherwise. * In cauchy, iwhere is given finer gradations. @@ -1011,14 +1009,14 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int active_(long* n, double* l, double* u, long* nbd, double* x, long* iwhere, long* iprint, long* prjctd, long* cnstnd, - long* boxed) { - long i__1; - static long i__, nbdd; +void active_(F77_int* n, double* l, double* u, F77_int* nbd, double* x, F77_int* iwhere, F77_int* iprint, F77_int* prjctd, F77_int* cnstnd, + F77_int* boxed) { + F77_int i__1; + static F77_int i__, nbdd; --iwhere; --x; --nbd; --u; --l; @@ -1075,23 +1073,22 @@ fprintf(stdout, " This problem is unconstrained.\n"); } } if (*iprint > 0) { fprintf(stdout, "\n"); - fprintf(stdout, "At X0 %9ld variables are exactly at the bounds\n", nbdd); + fprintf(stdout, "At X0 %9" PRIdF77INT " variables are exactly at the bounds\n", nbdd); } - return 0; } /** * Subroutine bmv * * This subroutine computes the product of the 2m x 2m middle matrix * in the compact L-BFGS formula of B and a 2m vector v; * it returns the product in p. * - * m is an long variable. + * m is an integer variable. * On entry m is the maximum number of variable metric corrections * used to define the limited memory matrix. * On exit m is unchanged. * * sy is a double precision array of dimension m x m. @@ -1101,11 +1098,11 @@ * wt is a double precision array of dimension m x m. * On entry wt specifies the upper triangular matrix J' which is * the Cholesky factor of (thetaS'S+LD^(-1)L'). * On exit wt is unchanged. * - * col is an long variable. + * col is an integer variable. * On entry col specifies the number of s-vectors (or y-vectors) * stored in the compact L-BFGS formula. * On exit col is unchanged. * * v is a double precision array of dimension 2col. @@ -1114,11 +1111,11 @@ * * p is a double precision array of dimension 2col. * On entry p is unspecified. * On exit p is the product Mv. * - * info is an long variable. + * info is an integer variable. * On entry info is unspecified. * On exit info = 0 for normal return, * = nonzero for abnormal return when the system * to be solved by dtrsl is singular. * @@ -1133,13 +1130,13 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long* info) { - long sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2; - static long i__, k, i2; +void bmv_(F77_int* m, double* sy, double* wt, F77_int* col, double* v, double* p, F77_int* info) { + F77_int sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2; + static F77_int i__, k, i2; static double sum; wt_dim1 = *m; wt_offset = 1 + wt_dim1; wt -= wt_offset; @@ -1148,11 +1145,11 @@ sy -= sy_offset; --p; --v; if (*col == 0) { - return 0; + return; } /* PART I: solve [ D^(1/2) O ] [ p1 ] = [ v1 ] */ /* [ -L*D^(-1/2) J ] [ p2 ] [ v2 ]. */ /* solve Jp2=v2+LD^(-1)v1. */ p[*col + 1] = v[*col + 1]; @@ -1165,25 +1162,25 @@ sum += sy[i__ + k * sy_dim1] * v[k] / sy[k + k * sy_dim1]; } p[i2] = v[i2] + sum; } /* Solve the triangular system */ - lbfgsb_rb_dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__11, info); + dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__11, info); if (*info != 0) { - return 0; + return; } /* solve D^(1/2)p1=v1. */ i__1 = *col; for (i__ = 1; i__ <= i__1; ++i__) { p[i__] = v[i__] / sqrt(sy[i__ + i__ * sy_dim1]); } /* PART II: solve [ -D^(1/2) D^(-1/2)*L' ] [ p1 ] = [ p1 ] */ /* [ 0 J' ] [ p2 ] [ p2 ]. */ /* solve J^Tp2=p2. */ - lbfgsb_rb_dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__1, info); + dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__1, info); if (*info != 0) { - return 0; + return; } /* compute p1=-D^(-1/2)(p1-D^(-1/2)L'p2) */ /* =-D^(-1/2)p1+D^(-1)L'p2. */ i__1 = *col; for (i__ = 1; i__ <= i__1; ++i__) { @@ -1196,11 +1193,10 @@ for (k = i__ + 1; k <= i__2; ++k) { sum += sy[k + i__ * sy_dim1] * p[*col + k] / sy[i__ + i__ * sy_dim1]; } p[i__] += sum; } - return 0; } /** * Subroutine cauchy * @@ -1210,14 +1206,14 @@ * generalized Cauchy point (GCP), defined as the first local * minimizer of the quadratic * * Q(x + s) = g's + 1/2 s'Bs * - * along the projected gradient direction P(x-tg,l,u). + * aF77_int the projected gradient direction P(x-tg,l,u). * The routine returns the GCP in xcp. * - * n is an long variable. + * n is an integer variable. * On entry n is the dimension of the problem. * On exit n is unchanged. * * x is a double precision array of dimension n. * On entry x is the starting point for the GCP computation. @@ -1229,11 +1225,11 @@ * * u is a double precision array of dimension n. * On entry u is the upper bound of x. * On exit u is unchanged. * - * nbd is an long array of dimension n. + * nbd is an integer array of dimension n. * On entry nbd represents the type of bounds imposed on the * variables, and must be specified as follows: * nbd(i)=0 if x(i) is unbounded, * 1 if x(i) has only a lower bound, * 2 if x(i) has both lower and upper bounds, and @@ -1242,21 +1238,21 @@ * * g is a double precision array of dimension n. * On entry g is the gradient of f(x). g must be a nonzero vector. * On exit g is unchanged. * - * iorder is an long working array of dimension n. + * iorder is an integer working array of dimension n. * iorder will be used to store the breakpoints in the piecewise * linear path and free variables encountered. On exit, * iorder(1),...,iorder(nleft) are indices of breakpoints * which have not been encountered; * iorder(nleft+1),...,iorder(nbreak) are indices of * encountered breakpoints; and * iorder(nfree),...,iorder(n) are indices of variables which - * have no bound constraits along the search direction. + * have no bound constraits aF77_int the search direction. * - * iwhere is an long array of dimension n. + * iwhere is an integer array of dimension n. * On entry iwhere indicates only the permanently fixed (iwhere=3) * or free (iwhere= -1) components of x. * On exit iwhere records the status of the current x variables. * iwhere(i)=-3 if x(i) is free and has bounds, but is not moved * 0 if x(i) is free and has bounds, and is moved @@ -1272,11 +1268,11 @@ * the Cauchy direction P(x-tg)-x. * * xcp is a double precision array of dimension n used to return the * GCP on exit. * - * m is an long variable. + * m is an integer variable. * On entry m is the maximum number of variable metric corrections * used to define the limited memory matrix. * On exit m is unchanged. * * ws, wy, sy, and wt are double precision arrays. @@ -1291,16 +1287,16 @@ * * theta is a double precision variable. * On entry theta is the scaling factor specifying B_0 = theta I. * On exit theta is unchanged. * - * col is an long variable. + * col is an integer variable. * On entry col is the actual number of variable metric * corrections stored so far. * On exit col is unchanged. * - * head is an long variable. + * head is an integer variable. * On entry head is the location of the first s-vector (or y-vector) * in S (or Y). * On exit col is unchanged. * * p is a double precision working array of dimension 2m. @@ -1313,19 +1309,19 @@ * wbp will be used to store the row of W corresponding * to a breakpoint. * * v is a double precision working array of dimension 2m. * - * nseg is an long variable. + * nseg is an integer variable. * On exit nseg records the number of quadratic segments explored * in searching for the GCP. * * sg and yg are double precision arrays of dimension m. * On entry sg and yg store S'g and Y'g correspondingly. * On exit they are unchanged. * - * iprint is an long variable that must be set by the user. + * iprint is an integer variable that must be set by the user. * It controls the frequency and type of output generated: * iprint<0 no output is generated; * iprint=0 print only one line at the last iteration; * 0<iprint<99 print also f and |proj g| every iprint iterations; * iprint=99 print details of every iteration except n-vectors; @@ -1336,11 +1332,11 @@ * * sbgnrm is a double precision variable. * On entry sbgnrm is the norm of the projected gradient at x. * On exit sbgnrm is unchanged. * - * info is an long variable. + * info is an integer variable. * On entry info is 0. * On exit info = 0 for normal return, * = nonzero for abnormal return when the the system * used in routine bmv is singular. * @@ -1372,34 +1368,34 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int cauchy_(long* n, double* x, double* l, double* u, long* nbd, double* g, long* iorder, long* iwhere, double* t, double* d__, - double* xcp, long* m, double* wy, double* ws, double* sy, double* wt, double* theta, long* col, long* head, - double* p, double* c__, double* wbp, double* v, long* nseg, long* iprint, double* sbgnrm, long* info, +void cauchy_(F77_int* n, double* x, double* l, double* u, F77_int* nbd, double* g, F77_int* iorder, F77_int* iwhere, double* t, double* d__, + double* xcp, F77_int* m, double* wy, double* ws, double* sy, double* wt, double* theta, F77_int* col, F77_int* head, + double* p, double* c__, double* wbp, double* v, F77_int* nseg, F77_int* iprint, double* sbgnrm, F77_int* info, double* epsmch) { - long wy_dim1, wy_offset, ws_dim1, ws_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2; + F77_int wy_dim1, wy_offset, ws_dim1, ws_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2; double d__1; - static long i__, j; + static F77_int i__, j; static double f1, f2, dt, tj, tl, tu, tj0; - static long ibp; + static F77_int ibp; static double dtm; static double wmc, wmp, wmw; - static long col2; + static F77_int col2; static double dibp; - static long iter; + static F77_int iter; static double zibp, tsum, dibp2; - static long bnded; + static F77_int bnded; static double neggi; - static long nfree; + static F77_int nfree; static double bkmin; - static long nleft; + static F77_int nleft; static double f2_org__; - static long nbreak, ibkmin; - static long pointr; - static long xlower, xupper; + static F77_int nbreak, ibkmin; + static F77_int pointr; + static F77_int xlower, xupper; --xcp; --d__; --t; --iwhere; @@ -1431,12 +1427,12 @@ /* the derivative f1 and the vector p = W'd (for theta = 1). */ if (*sbgnrm <= 0.) { if (*iprint >= 0) { fprintf(stdout, " Subgnorm = 0. GCP = X.\n"); } - lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xcp[1], &c__1); - return 0; + dcopy_(n, &x[1], &c__1, &xcp[1], &c__1); + return; } bnded = TRUE_; nfree = *n + 1; nbreak = 0; ibkmin = 0; @@ -1530,14 +1526,14 @@ /* The indices of the nonzero components of d are now stored */ /* in iorder(1),...,iorder(nbreak) and iorder(nfree),...,iorder(n). */ /* The smallest of the nbreak breakpoints is in t(ibkmin)=bkmin. */ if (*theta != 1.) { /* complete the initialization of p for theta not= one. */ - lbfgsb_rb_dscal_(col, theta, &p[*col + 1], &c__1); + dscal_(col, theta, &p[*col + 1], &c__1); } /* Initialize GCP xcp = x. */ - lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xcp[1], &c__1); + dcopy_(n, &x[1], &c__1, &xcp[1], &c__1); if (nbreak == 0 && nfree == *n + 1) { /* is a zero vector, return with the initial xcp as GCP. */ if (*iprint > 100) { fprintf(stdout, "Cauchy X = \n"); fprintf(stdout, " "); @@ -1549,11 +1545,11 @@ fprintf(stdout, " "); } } fprintf(stdout, "\n"); } - return 0; + return; } /* Initialize c = W'(xcp - x) = 0. */ i__1 = col2; for (j = 1; j <= i__1; ++j) { c__[j] = 0.; @@ -1562,19 +1558,19 @@ f2 = -(*theta) * f1; f2_org__ = f2; if (*col > 0) { bmv_(m, &sy[sy_offset], &wt[wt_offset], col, &p[1], &v[1], info); if (*info != 0) { - return 0; + return; } - f2 -= lbfgsb_rb_ddot_(&col2, &v[1], &c__1, &p[1], &c__1); + f2 -= ddot_(&col2, &v[1], &c__1, &p[1], &c__1); } dtm = -f1 / f2; tsum = 0.; *nseg = 1; if (*iprint >= 99) { - fprintf(stdout, " There are %3ld breakpoints \n", nbreak); + fprintf(stdout, " There are %3" PRIdF77INT " breakpoints \n", nbreak); } /* If there are no breakpoints, locate the GCP and return. */ if (nbreak == 0) { goto L888; } @@ -1609,11 +1605,11 @@ ibp = iorder[nleft]; } dt = tj - tj0; if (dt != 0. && *iprint >= 100) { fprintf(stdout, "\n"); - fprintf(stdout, "Piece %3ld --f1, f2 at start point %11.4E %11.4E\n", *nseg, f1, f2); + fprintf(stdout, "Piece %3" PRIdF77INT " --f1, f2 at start point %11.4E %11.4E\n", *nseg, f1, f2); fprintf(stdout, "Distance to the next break point = %11.4E\n", dt); fprintf(stdout, "Distance to the stationary point = %11.4E\n", dtm); } /* If a minimizer is within this interval, locate the GCP and return. */ if (dtm < dt) { @@ -1634,11 +1630,11 @@ zibp = l[ibp] - x[ibp]; xcp[ibp] = l[ibp]; iwhere[ibp] = 1; } if (*iprint >= 100) { - fprintf(stdout, " Variable %ld is fixed.\n", ibp); + fprintf(stdout, " Variable %" PRIdF77INT " is fixed.\n", ibp); } if (nleft == 0 && nbreak == *n) { /* all n variables are fixed, */ /* return with xcp as GCP. */ dtm = dt; @@ -1653,11 +1649,11 @@ /* temporarily set f1 and f2 for col=0. */ f1 = f1 + dt * f2 + dibp2 - *theta * dibp * zibp; f2 -= *theta * dibp2; if (*col > 0) { /* update c = c + dt*p. */ - lbfgsb_rb_daxpy_(&col2, &dt, &p[1], &c__1, &c__[1], &c__1); + daxpy_(&col2, &dt, &p[1], &c__1, &c__[1], &c__1); /* choose wbp, */ /* the row of W corresponding to the breakpoint encountered. */ pointr = *head; i__1 = *col; for (j = 1; j <= i__1; ++j) { @@ -1666,18 +1662,18 @@ pointr = pointr % *m + 1; } /* compute (wbp)Mc, (wbp)Mp, and (wbp)M(wbp)'. */ bmv_(m, &sy[sy_offset], &wt[wt_offset], col, &wbp[1], &v[1], info); if (*info != 0) { - return 0; + return; } - wmc = lbfgsb_rb_ddot_(&col2, &c__[1], &c__1, &v[1], &c__1); - wmp = lbfgsb_rb_ddot_(&col2, &p[1], &c__1, &v[1], &c__1); - wmw = lbfgsb_rb_ddot_(&col2, &wbp[1], &c__1, &v[1], &c__1); + wmc = ddot_(&col2, &c__[1], &c__1, &v[1], &c__1); + wmp = ddot_(&col2, &p[1], &c__1, &v[1], &c__1); + wmw = ddot_(&col2, &wbp[1], &c__1, &v[1], &c__1); /* update p = p - dibp*wbp. */ d__1 = -dibp; - lbfgsb_rb_daxpy_(&col2, &d__1, &wbp[1], &c__1, &p[1], &c__1); + daxpy_(&col2, &d__1, &wbp[1], &c__1, &p[1], &c__1); /* complete updating f1 and f2 while col > 0. */ f1 += dibp * wmc; f2 = f2 + dibp * 2. * wmp - dibp2 * wmw; } d__1 = *epsmch * f2_org__; @@ -1696,25 +1692,25 @@ /* ------------------- the end of the loop ------------------------------- */ L888: if (*iprint >= 99) { fprintf(stdout, "\n"); fprintf(stdout, " GCP found in this segment\n"); - fprintf(stdout, "Piece %3ld --f1, f2 at start point %11.4E %11.4E\n", *nseg, f1, f2); + fprintf(stdout, "Piece %3" PRIdF77INT " --f1, f2 at start point %11.4E %11.4E\n", *nseg, f1, f2); fprintf(stdout, "Distance to the stationary point = %11.4E\n", dtm); } if (dtm <= 0.) { dtm = 0.; } tsum += dtm; /* Move free variables (i.e., the ones w/o breakpoints) and */ /* the variables whose breakpoints haven't been reached. */ - lbfgsb_rb_daxpy_(n, &tsum, &d__[1], &c__1, &xcp[1], &c__1); + daxpy_(n, &tsum, &d__[1], &c__1, &xcp[1], &c__1); L999: /* Update c = c + dtm*p = W'(x^c - x) */ /* which will be used in computing r = Z'(B(x^c - x) + g). */ if (*col > 0) { - lbfgsb_rb_daxpy_(&col2, &dtm, &p[1], &c__1, &c__[1], &c__1); + daxpy_(&col2, &dtm, &p[1], &c__1, &c__[1], &c__1); } if (*iprint > 100) { fprintf(stdout, "Cauchy X = \n"); fprintf(stdout, " "); i__1 = *n; @@ -1728,11 +1724,10 @@ fprintf(stdout, "\n"); } if (*iprint >= 99) { fprintf(stdout, "\n---------------- exit CAUCHY----------------------\n\n"); } - return 0; } /** * Subroutine cmprlb * @@ -1750,16 +1745,16 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int cmprlb_(long* n, long* m, double* x, double* g, double* ws, double* wy, double* sy, double* wt, double* z__, double* r__, - double* wa, long* index, double* theta, long* col, long* head, long* nfree, long* cnstnd, long* info) { - long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2; - static long i__, j, k; +void cmprlb_(F77_int* n, F77_int* m, double* x, double* g, double* ws, double* wy, double* sy, double* wt, double* z__, double* r__, + double* wa, F77_int* index, double* theta, F77_int* col, F77_int* head, F77_int* nfree, F77_int* cnstnd, F77_int* info) { + F77_int ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2; + static F77_int i__, j, k; static double a1, a2; - static long pointr; + static F77_int pointr; --index; --r__; --z__; --g; @@ -1790,11 +1785,11 @@ r__[i__] = -(*theta) * (z__[k] - x[k]) - g[k]; } bmv_(m, &sy[sy_offset], &wt[wt_offset], col, &wa[(*m << 1) + 1], &wa[1], info); if (*info != 0) { *info = -8; - return 0; + return; } pointr = *head; i__1 = *col; for (j = 1; j <= i__1; ++j) { a1 = wa[j]; @@ -1805,11 +1800,10 @@ r__[i__] = r__[i__] + wy[k + pointr * wy_dim1] * a1 + ws[k + pointr * ws_dim1] * a2; } pointr = pointr % *m + 1; } } - return 0; } /** * Subroutine errclb * @@ -1822,13 +1816,13 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int errclb_(long* n, long* m, double* factr, double* l, double* u, long* nbd, char* task, long* info, long* k) { - long i__1; - static long i__; +void errclb_(F77_int* n, F77_int* m, double* factr, double* l, double* u, F77_int* nbd, char* task, F77_int* info, F77_int* k) { + F77_int i__1; + static F77_int i__; --nbd; --u; --l; /* Check the input arguments for errors. */ @@ -1857,11 +1851,10 @@ *info = -7; *k = i__; } } } - return 0; } /** * Subroutine formk * @@ -1873,39 +1866,39 @@ * [ 0 I] * The matrix K can be shown to be equal to the matrix M^[-1]N * occurring in section 5.1 of [1], as well as to the matrix * Mbar^[-1] Nbar in section 5.3. * - * n is an long variable. + * n is an integer variable. * On entry n is the dimension of the problem. * On exit n is unchanged. * - * nsub is an long variable + * nsub is an integer variable * On entry nsub is the number of subspace variables in free set. * On exit nsub is not changed. * - * ind is an long array of dimension nsub. + * ind is an integer array of dimension nsub. * On entry ind specifies the indices of subspace variables. * On exit ind is unchanged. * - * nenter is an long variable. + * nenter is an integer variable. * On entry nenter is the number of variables entering the * free set. * On exit nenter is unchanged. * - * ileave is an long variable. + * ileave is an integer variable. * On entry indx2(ileave),...,indx2(n) are the variables leaving * the free set. * On exit ileave is unchanged. * - * indx2 is an long array of dimension n. + * indx2 is an integer array of dimension n. * On entry indx2(1),...,indx2(nenter) are the variables entering * the free set, while indx2(ileave),...,indx2(n) are the * variables leaving the free set. * On exit indx2 is unchanged. * - * iupdat is an long variable. + * iupdat is an integer variable. * On entry iupdat is the total number of BFGS updates made so far. * On exit iupdat is unchanged. * * updatd is a logical variable. * On entry 'updatd' is true if the L-BFGS matrix is updatd. @@ -1925,19 +1918,19 @@ * in the previous iteration. * On exit wn1 stores the corresponding updated matrices. * The purpose of wn1 is just to store these inner products * so they can be easily updated and inserted into wn. * - * m is an long variable. + * m is an integer variable. * On entry m is the maximum number of variable metric corrections * used to define the limited memory matrix. * On exit m is unchanged. * * ws, wy, sy, and wtyy are double precision arrays; * theta is a double precision variable; - * col is an long variable; - * head is an long variable. + * col is an integer variable; + * head is an integer variable. * On entry they store the information defining the * limited memory BFGS matrix: * ws(n,m) stores S, a set of s-vectors; * wy(n,m) stores Y, a set of y-vectors; * sy(m,m) stores S'Y; @@ -1946,11 +1939,11 @@ * theta is the scaling factor specifying B_0 = theta I; * col is the number of variable metric corrections stored; * head is the location of the 1st s- (or y-) vector in S (or Y). * On exit they are unchanged. * - * info is an long variable. + * info is an integer variable. * On entry info is unspecified. * On exit info = 0 for normal return; * = -1 when the 1st Cholesky factorization failed; * = -2 when the 2st Cholesky factorization failed. * @@ -1979,17 +1972,17 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int formk_(long* n, long* nsub, long* ind, long* nenter, long* ileave, long* indx2, long* iupdat, long* updatd, double* wn, - double* wn1, long* m, double* ws, double* wy, double* sy, double* theta, long* col, long* head, long* info) { - long wn_dim1, wn_offset, wn1_dim1, wn1_offset, ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, i__1, i__2, i__3; - static long i__, k, k1, m2, is, js, iy, jy, is1, js1, col2, dend, pend; - static long upcl; +void formk_(F77_int* n, F77_int* nsub, F77_int* ind, F77_int* nenter, F77_int* ileave, F77_int* indx2, F77_int* iupdat, F77_int* updatd, double* wn, + double* wn1, F77_int* m, double* ws, double* wy, double* sy, double* theta, F77_int* col, F77_int* head, F77_int* info) { + F77_int wn_dim1, wn_offset, wn1_dim1, wn1_offset, ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, i__1, i__2, i__3; + static F77_int i__, k, k1, m2, is, js, iy, jy, is1, js1, col2, dend, pend; + static F77_int upcl; static double temp1, temp2, temp3, temp4; - static long ipntr, jpntr, dbegin, pbegin; + static F77_int ipntr, jpntr, dbegin, pbegin; --indx2; --ind; sy_dim1 = *m; sy_offset = 1 + sy_dim1; @@ -2017,15 +2010,15 @@ /* shift old part of WN1. */ i__1 = *m - 1; for (jy = 1; jy <= i__1; ++jy) { js = *m + jy; i__2 = *m - jy; - lbfgsb_rb_dcopy_(&i__2, &wn1[jy + 1 + (jy + 1) * wn1_dim1], &c__1, &wn1[jy + jy * wn1_dim1], &c__1); + dcopy_(&i__2, &wn1[jy + 1 + (jy + 1) * wn1_dim1], &c__1, &wn1[jy + jy * wn1_dim1], &c__1); i__2 = *m - jy; - lbfgsb_rb_dcopy_(&i__2, &wn1[js + 1 + (js + 1) * wn1_dim1], &c__1, &wn1[js + js * wn1_dim1], &c__1); + dcopy_(&i__2, &wn1[js + 1 + (js + 1) * wn1_dim1], &c__1, &wn1[js + js * wn1_dim1], &c__1); i__2 = *m - 1; - lbfgsb_rb_dcopy_(&i__2, &wn1[*m + 2 + (jy + 1) * wn1_dim1], &c__1, &wn1[*m + 1 + jy * wn1_dim1], &c__1); + dcopy_(&i__2, &wn1[*m + 2 + (jy + 1) * wn1_dim1], &c__1, &wn1[*m + 1 + jy * wn1_dim1], &c__1); } } /* put new rows in blocks (1,1), (2,1) and (2,2). */ pbegin = 1; pend = *nsub; @@ -2172,37 +2165,35 @@ } /* Form the upper triangle of WN= [ LL' L^-1(-L_a'+R_z')] */ /* [(-L_a +R_z)L'^-1 S'AA'S*theta ] */ /* first Cholesky factor (1,1) block of wn to get LL' */ /* with L' stored in the upper triangle of wn. */ - lbfgsb_rb_dpofa_(&wn[wn_offset], &m2, col, info); + dpofa_(&wn[wn_offset], &m2, col, info); if (*info != 0) { *info = -1; - return 0; + return; } /* then form L^-1(-L_a'+R_z') in the (1,2) block. */ col2 = *col << 1; i__1 = col2; for (js = *col + 1; js <= i__1; ++js) { - lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, col, &wn[js * wn_dim1 + 1], &c__11, info); + dtrsl_(&wn[wn_offset], &m2, col, &wn[js * wn_dim1 + 1], &c__11, info); } /* Form S'AA'S*theta + (L^-1(-L_a'+R_z'))'L^-1(-L_a'+R_z') in the */ /* upper triangle of (2,2) block of wn. */ i__1 = col2; for (is = *col + 1; is <= i__1; ++is) { i__2 = col2; for (js = is; js <= i__2; ++js) { - wn[is + js * wn_dim1] += lbfgsb_rb_ddot_(col, &wn[is * wn_dim1 + 1], &c__1, &wn[js * wn_dim1 + 1], &c__1); + wn[is + js * wn_dim1] += ddot_(col, &wn[is * wn_dim1 + 1], &c__1, &wn[js * wn_dim1 + 1], &c__1); } } /* Cholesky factorization of (2,2) block of wn. */ - lbfgsb_rb_dpofa_(&wn[*col + 1 + (*col + 1) * wn_dim1], &m2, col, info); + dpofa_(&wn[*col + 1 + (*col + 1) * wn_dim1], &m2, col, info); if (*info != 0) { *info = -2; - return 0; } - return 0; } /** * Subroutine formt * @@ -2222,13 +2213,13 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int formt_(long* m, double* wt, double* sy, double* ss, long* col, double* theta, long* info) { - long wt_dim1, wt_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2, i__3; - static long i__, j, k, k1; +void formt_(F77_int* m, double* wt, double* sy, double* ss, F77_int* col, double* theta, F77_int* info) { + F77_int wt_dim1, wt_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2, i__3; + static F77_int i__, j, k, k1; static double ddum; ss_dim1 = *m; ss_offset = 1 + ss_dim1; ss -= ss_offset; @@ -2258,15 +2249,14 @@ wt[i__ + j * wt_dim1] = ddum + *theta * ss[i__ + j * ss_dim1]; } } /* Cholesky factorize T to J*J' with */ /* J' stored in the upper triangle of wt. */ - lbfgsb_rb_dpofa_(&wt[wt_offset], m, col, info); + dpofa_(&wt[wt_offset], m, col, info); if (*info != 0) { *info = -3; } - return 0; } /** * Subroutine freev * @@ -2274,19 +2264,19 @@ * iter > 0, and finds the index set of free and active variables * at the GCP. * * cnstnd is a logical variable indicating whether bounds are present * - * index is an long array of dimension n + * index is an integer array of dimension n * for i=1,...,nfree, index(i) are the indices of free variables * for i=nfree+1,...,n, index(i) are the indices of bound variables * On entry after the first iteration, index gives * the free variables at the previous iteration. * On exit it gives the free variables based on the determination * in cauchy using the array iwhere. * - * indx2 is an long array of dimension n + * indx2 is an integer array of dimension n * On entry indx2 is unspecified. * On exit with iter>0, indx2 indicates which variables * have changed status since the previous iteration. * For i= 1,...,nenter, indx2(i) have changed from bound to free. * For i= ileave+1,...,n, indx2(i) have changed from free to bound. @@ -2298,14 +2288,14 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long* indx2, long* iwhere, long* wrk, long* updatd, - long* cnstnd, long* iprint, long* iter) { - long i__1; - static long i__, k, iact; +void freev_(F77_int* n, F77_int* nfree, F77_int* index, F77_int* nenter, F77_int* ileave, F77_int* indx2, F77_int* iwhere, F77_int* wrk, F77_int* updatd, + F77_int* cnstnd, F77_int* iprint, F77_int* iter) { + F77_int i__1; + static F77_int i__, k, iact; --iwhere; --indx2; --index; @@ -2320,28 +2310,28 @@ /* write(6,*) ' index = ', i */ if (iwhere[k] > 0) { --(*ileave); indx2[*ileave] = k; if (*iprint >= 100) { - fprintf(stdout, " Variable %2ld leaves the set of free variables\n", k); + fprintf(stdout, " Variable %2" PRIdF77INT " leaves the set of free variables\n", k); } } } i__1 = *n; for (i__ = *nfree + 1; i__ <= i__1; ++i__) { k = index[i__]; if (iwhere[k] <= 0) { ++(*nenter); indx2[*nenter] = k; if (*iprint >= 100) { - fprintf(stdout, " Variable %2ld enters the set of free variables\n", k); + fprintf(stdout, " Variable %2" PRIdF77INT " enters the set of free variables\n", k); } } } if (*iprint >= 99) { i__1 = *n + 1 - *ileave; - fprintf(stdout, " %2ld variables leave; %2ld variables enter\n", i__1, *nenter); + fprintf(stdout, " %2" PRIdF77INT " variables leave; %2" PRIdF77INT " variables enter\n", i__1, *nenter); } } *wrk = *ileave < *n + 1 || *nenter > 0 || *updatd; /* Find the index set of free and active variables at the GCP. */ *nfree = 0; @@ -2356,36 +2346,35 @@ index[iact] = i__; } } if (*iprint >= 99) { i__1 = *iter + 1; - fprintf(stdout, " %2ld variables are free at GCP %3ld\n", *nfree, i__1); + fprintf(stdout, " %2" PRIdF77INT " variables are free at GCP %3" PRIdF77INT "\n", *nfree, i__1); } - return 0; } /** * Subroutine hpsolb * * This subroutine sorts out the least element of t, and puts the * remaining elements of t in a heap. * - * n is an long variable. + * n is an integer variable. * On entry n is the dimension of the arrays t and iorder. * On exit n is unchanged. * * t is a double precision array of dimension n. * On entry t stores the elements to be sorted, * On exit t(n) stores the least elements of t, and t(1) to t(n-1) * stores the remaining elements in the form of a heap. * - * iorder is an long array of dimension n. + * iorder is an integer array of dimension n. * On entry iorder(i) is the index of t(i). * On exit iorder(i) is still the index of t(i), but iorder may be * permuted in accordance with t. * - * iheap is an long variable specifying the task. + * iheap is an integer variable specifying the task. * On entry iheap should be set as follows: * iheap .eq. 0 if t(1) to t(n) is not in the form of a heap, * iheap .ne. 0 if otherwise. * On exit iheap is unchanged. * @@ -2400,15 +2389,15 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int hpsolb_(long* n, double* t, long* iorder, long* iheap) { - long i__1; - static long i__, j, k; +void hpsolb_(F77_int* n, double* t, F77_int* iorder, F77_int* iheap) { + F77_int i__1; + static F77_int i__, j, k; static double out, ddum; - static long indxin, indxou; + static F77_int indxin, indxou; --iorder; --t; if (*iheap == 0) { @@ -2460,11 +2449,10 @@ iorder[i__] = indxin; /* Put the least member in t(n). */ t[*n] = out; iorder[*n] = indxou; } - return 0; } /** * Subroutine lnsrlb * @@ -2485,17 +2473,17 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int lnsrlb_(long* n, double* l, double* u, long* nbd, double* x, double* f, double* fold, double* gd, double* gdold, double* g, +void lnsrlb_(F77_int* n, double* l, double* u, F77_int* nbd, double* x, double* f, double* fold, double* gd, double* gdold, double* g, double* d__, double* r__, double* t, double* z__, double* stp, double* dnorm, double* dtd, double* xstep, - double* stpmx, long* iter, long* ifun, long* iback, long* nfgv, long* info, char* task, long* boxed, long* cnstnd, - char* csave, long* isave, double* dsave) { - long i__1; + double* stpmx, F77_int* iter, F77_int* ifun, F77_int* iback, F77_int* nfgv, F77_int* info, char* task, F77_int* boxed, F77_int* cnstnd, + char* csave, F77_int* isave, double* dsave) { + F77_int i__1; double d__1; - static long i__; + static F77_int i__; static double a1, a2; --z__; --t; --r__; @@ -2509,11 +2497,11 @@ --dsave; if (strncmp(task, "FG_LN", 5) == 0) { goto L556; } - *dtd = lbfgsb_rb_ddot_(n, &d__[1], &c__1, &d__[1], &c__1); + *dtd = ddot_(n, &d__[1], &c__1, &d__[1], &c__1); *dnorm = sqrt(*dtd); /* Determine the maximum step length. */ *stpmx = 1e10; if (*cnstnd) { if (*iter == 0) { @@ -2546,47 +2534,46 @@ d__1 = 1. / *dnorm; *stp = d__1 <= *stpmx ? d__1 : *stpmx; } else { *stp = 1.; } - lbfgsb_rb_dcopy_(n, &x[1], &c__1, &t[1], &c__1); - lbfgsb_rb_dcopy_(n, &g[1], &c__1, &r__[1], &c__1); + dcopy_(n, &x[1], &c__1, &t[1], &c__1); + dcopy_(n, &g[1], &c__1, &r__[1], &c__1); *fold = *f; *ifun = 0; *iback = 0; strcpy(csave, "START"); L556: - *gd = lbfgsb_rb_ddot_(n, &g[1], &c__1, &d__[1], &c__1); + *gd = ddot_(n, &g[1], &c__1, &d__[1], &c__1); if (*ifun == 0) { *gdold = *gd; if (*gd >= 0.) { /* the directional derivative >=0. */ /* Line search is impossible. */ fprintf(stdout, " ascent direction in projection gd = %.8E\n", *gd); *info = -4; - return 0; + return; } } dcsrch_(f, gd, stp, &c_b280, &c_b281, &c_b282, &c_b9, stpmx, csave, &isave[1], &dsave[1]); *xstep = *stp * *dnorm; if (strncmp(csave, "CONV", 4) != 0 && strncmp(csave, "WARN", 4) != 0) { strcpy(task, "FG_LNSRCH"); ++(*ifun); ++(*nfgv); *iback = *ifun - 1; if (*stp == 1.) { - lbfgsb_rb_dcopy_(n, &z__[1], &c__1, &x[1], &c__1); + dcopy_(n, &z__[1], &c__1, &x[1], &c__1); } else { i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { x[i__] = *stp * d__[i__] + t[i__]; } } } else { strcpy(task, "NEW_X"); } - return 0; } /** * Subroutine matupd * @@ -2604,15 +2591,15 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int matupd_(long* n, long* m, double* ws, double* wy, double* sy, double* ss, double* d__, double* r__, long* itail, - long* iupdat, long* col, long* head, double* theta, double* rr, double* dr, double* stp, double* dtd) { - long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2; - static long j; - static long pointr; +void matupd_(F77_int* n, F77_int* m, double* ws, double* wy, double* sy, double* ss, double* d__, double* r__, F77_int* itail, + F77_int* iupdat, F77_int* col, F77_int* head, double* theta, double* rr, double* dr, double* stp, double* dtd) { + F77_int ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2; + static F77_int j; + static F77_int pointr; --r__; --d__; ss_dim1 = *m; @@ -2635,42 +2622,41 @@ } else { *itail = *itail % *m + 1; *head = *head % *m + 1; } /* Update matrices WS and WY. */ - lbfgsb_rb_dcopy_(n, &d__[1], &c__1, &ws[*itail * ws_dim1 + 1], &c__1); - lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &wy[*itail * wy_dim1 + 1], &c__1); + dcopy_(n, &d__[1], &c__1, &ws[*itail * ws_dim1 + 1], &c__1); + dcopy_(n, &r__[1], &c__1, &wy[*itail * wy_dim1 + 1], &c__1); /* Set theta=yy/ys. */ *theta = *rr / *dr; /* Form the middle matrix in B. */ /* update the upper triangle of SS, */ /* and the lower triangle of SY: */ if (*iupdat > *m) { /* move old information */ i__1 = *col - 1; for (j = 1; j <= i__1; ++j) { - lbfgsb_rb_dcopy_(&j, &ss[(j + 1) * ss_dim1 + 2], &c__1, &ss[j * ss_dim1 + 1], &c__1); + dcopy_(&j, &ss[(j + 1) * ss_dim1 + 2], &c__1, &ss[j * ss_dim1 + 1], &c__1); i__2 = *col - j; - lbfgsb_rb_dcopy_(&i__2, &sy[j + 1 + (j + 1) * sy_dim1], &c__1, &sy[j + j * sy_dim1], &c__1); + dcopy_(&i__2, &sy[j + 1 + (j + 1) * sy_dim1], &c__1, &sy[j + j * sy_dim1], &c__1); } } /* add new information: the last row of SY */ /* and the last column of SS: */ pointr = *head; i__1 = *col - 1; for (j = 1; j <= i__1; ++j) { - sy[*col + j * sy_dim1] = lbfgsb_rb_ddot_(n, &d__[1], &c__1, &wy[pointr * wy_dim1 + 1], &c__1); - ss[j + *col * ss_dim1] = lbfgsb_rb_ddot_(n, &ws[pointr * ws_dim1 + 1], &c__1, &d__[1], &c__1); + sy[*col + j * sy_dim1] = ddot_(n, &d__[1], &c__1, &wy[pointr * wy_dim1 + 1], &c__1); + ss[j + *col * ss_dim1] = ddot_(n, &ws[pointr * ws_dim1 + 1], &c__1, &d__[1], &c__1); pointr = pointr % *m + 1; } if (*stp == 1.) { ss[*col + *col * ss_dim1] = *dtd; } else { ss[*col + *col * ss_dim1] = *stp * *stp * *dtd; } sy[*col + *col * sy_dim1] = *dr; - return 0; } /** * Subroutine prn1lb * @@ -2685,24 +2671,24 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int prn1lb_(long* n, long* m, double* l, double* u, double* x, long* iprint, long* itfile, double* epsmch) { - long i__1; +void prn1lb_(F77_int* n, F77_int* m, double* l, double* u, double* x, F77_int* iprint, F77_int* itfile, double* epsmch) { + F77_int i__1; FILE* itfptr; - static long i__; + static F77_int i__; --x; --u; --l; if (*iprint >= 0) { fprintf(stdout, "RUNNING THE L-BFGS-B CODE\n\n"); fprintf(stdout, " * * *\n\n"); fprintf(stdout, "Machine precision = %.3E\n", *epsmch); - fprintf(stdout, " N = %3ld M = %2ld\n", *n, *m); + fprintf(stdout, " N = %3" PRIdF77INT " M = %2" PRIdF77INT "\n", *n, *m); if (*iprint >= 1) { itfptr = fopen("iterate.dat", "w"); fprintf(itfptr, "RUNNING THE L-BFGS-B CODE\n"); fprintf(itfptr, "\n"); fprintf(itfptr, "it = iteration number\n"); @@ -2717,11 +2703,11 @@ fprintf(itfptr, "projg = norm of the projected gradient\n"); fprintf(itfptr, "f = function value\n"); fprintf(itfptr, "\n"); fprintf(itfptr, " * * *\n\n"); fprintf(itfptr, "Machine precision = %.3E\n", *epsmch); - fprintf(itfptr, " N = %3ld M = %2ld\n", *n, *m); + fprintf(itfptr, " N = %3" PRIdF77INT " M = %2" PRIdF77INT "\n", *n, *m); fprintf(itfptr, "\n"); fprintf(itfptr, " it nf nseg nact sub itls stepl tstep projg f\n"); fclose(itfptr); if (*iprint > 100) { @@ -2761,11 +2747,10 @@ } fprintf(stdout, "\n"); } } } - return 0; } /** * Subroutine prn2lb * @@ -2779,14 +2764,14 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int prn2lb_(long* n, double* x, double* f, double* g, long* iprint, long* itfile, long* iter, long* nfgv, long* nact, - double* sbgnrm, long* nseg, char* word, long* iword, long* iback, double* stp, double* xstep) { - long i__1; - static long i__, imod; +void prn2lb_(F77_int* n, double* x, double* f, double* g, F77_int* iprint, F77_int* itfile, F77_int* iter, F77_int* nfgv, F77_int* nact, + double* sbgnrm, F77_int* nseg, char* word, F77_int* iword, F77_int* iback, double* stp, double* xstep) { + F77_int i__1; + static F77_int i__, imod; FILE* itfptr; --g; --x; /* 'word' records the status of subspace solutions. */ @@ -2801,12 +2786,12 @@ strcpy(word, "TNT"); } else { strcpy(word, "---"); } if (*iprint >= 99) { - fprintf(stdout, "LINE SEARCH %ld times; norm of step = %E\n", *iback, *xstep); - fprintf(stdout, "\nAt iterate%5ld f= %12.5E |proj g|= %12.5E\n", *iter, *f, *sbgnrm); + fprintf(stdout, "LINE SEARCH %" PRIdF77INT " times; norm of step = %E\n", *iback, *xstep); + fprintf(stdout, "\nAt iterate%5" PRIdF77INT" f= %12.5E |proj g|= %12.5E\n", *iter, *f, *sbgnrm); if (*iprint > 100) { fprintf(stdout, "X ="); i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { @@ -2821,20 +2806,19 @@ fprintf(stdout, "\n"); } } else if (*iprint > 0) { imod = *iter % *iprint; if (imod == 0) { - fprintf(stdout, "\nAt iterate%5ld f= %12.5E |proj g|= %12.5E\n", *iter, *f, *sbgnrm); + fprintf(stdout, "\nAt iterate%5" PRIdF77INT " f= %12.5E |proj g|= %12.5E\n", *iter, *f, *sbgnrm); } } if (*iprint >= 1) { itfptr = fopen("iterate.dat", "a"); - fprintf(itfptr, " %4ld %4ld %5ld %5ld %3s %4ld %7.1E %7.1E %10.3E %10.3E\n", *iter, *nfgv, *nseg, *nact, word, *iback, - *stp, *xstep, *sbgnrm, *f); + fprintf(itfptr, " %4" PRIdF77INT " %4" PRIdF77INT " %5" PRIdF77INT " %5" PRIdF77INT " %3s %4" PRIdF77INT " %7.1E %7.1E %10.3E %10.3E\n", + *iter, *nfgv, *nseg, *nact, word, *iback, *stp, *xstep, *sbgnrm, *f); fclose(itfptr); } - return 0; } /** * Subroutine prn3lb * @@ -2849,16 +2833,16 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int prn3lb_(long* n, double* x, double* f, char* task, long* iprint, long* info, long* itfile, long* iter, long* nfgv, - long* nintol, long* nskip, long* nact, double* sbgnrm, double* time, long* nseg, char* word, long* iback, - double* stp, double* xstep, long* k, double* cachyt, double* sbtime, double* lnscht) { - long i__1; +void prn3lb_(F77_int* n, double* x, double* f, char* task, F77_int* iprint, F77_int* info, F77_int* itfile, F77_int* iter, F77_int* nfgv, + F77_int* nintol, F77_int* nskip, F77_int* nact, double* sbgnrm, double* time, F77_int* nseg, char* word, F77_int* iback, + double* stp, double* xstep, F77_int* k, double* cachyt, double* sbtime, double* lnscht) { + F77_int i__1; FILE* itfptr; - static long i__; + static F77_int i__; --x; if (strncmp(task, "ERROR", 5) == 0) { goto L999; @@ -2876,11 +2860,12 @@ fprintf(stdout, "F = final function value\n"); fprintf(stdout, "\n"); fprintf(stdout, " * * *\n"); fprintf(stdout, "\n"); fprintf(stdout, " N Tit Tnf Tnint Skip Nact Projg F\n"); - fprintf(stdout, "%5ld %6ld %6ld %6ld %5ld %5ld %10.3E %10.3E\n", *n, *iter, *nfgv, *nintol, *nskip, *nact, *sbgnrm, *f); + fprintf(stdout, "%5" PRIdF77INT " %6" PRIdF77INT " %6" PRIdF77INT " %6" PRIdF77INT " %5" PRIdF77INT " %5" PRIdF77INT " %10.3E %10.3E\n", + *n, *iter, *nfgv, *nintol, *nskip, *nact, *sbgnrm, *f); if (*iprint >= 100) { fprintf(stdout, "\n"); fprintf(stdout, " X ="); i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { @@ -2925,14 +2910,14 @@ fprintf(stdout, " Warning: more than 10 function and gradient\n"); fprintf(stdout, " evaluations in the last line search. Termination\n"); fprintf(stdout, " may possibly be caused by a bad search direction.\n"); } if (*info == -6) { - fprintf(stdout, " Input nbd(%2ld) is invalid.\n", *k); + fprintf(stdout, " Input nbd(%2" PRIdF77INT ") is invalid.\n", *k); } if (*info == -7) { - fprintf(stdout, " l(%2ld) > u(%2ld). No feasible solution.\n", *k, *k); + fprintf(stdout, " l(%2" PRIdF77INT ") > u(%2" PRIdF77INT "). No feasible solution.\n", *k, *k); } if (*info == -8) { fprintf(stdout, "\n"); fprintf(stdout, " The triangular system is singular.\n"); } @@ -2955,12 +2940,12 @@ fprintf(stdout, "\n"); if (*iprint >= 1) { itfptr = fopen("iterate.dat", "a"); if (*info == -4 || *info == -9) { - fprintf(itfptr, " %4ld %4ld %5ld %5ld %3s %4ld %7.1E %7.1E - -\n", *iter, *nfgv, *nseg, *nact, word, - *iback, *stp, *xstep); + fprintf(itfptr, " %4" PRIdF77INT " %4" PRIdF77INT " %5" PRIdF77INT " %5" PRIdF77INT " %3s %4" PRIdF77INT " %7.1E %7.1E - -\n", + *iter, *nfgv, *nseg, *nact, word, *iback, *stp, *xstep); } fprintf(itfptr, "\n"); fprintf(itfptr, "%s\n", task); if (*info != 0) { if (*info == -1) { @@ -3004,11 +2989,10 @@ fprintf(itfptr, " Total User time %1.3E seconds.\n", *time); fprintf(itfptr, "\n"); fclose(itfptr); } } - return 0; } /** * Subroutine projgr * @@ -3022,14 +3006,14 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal. */ -int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, double* sbgnrm) { - long i__1; +void projgr_(F77_int* n, double* l, double* u, F77_int* nbd, double* x, double* g, double* sbgnrm) { + F77_int i__1; double d__1, d__2; - static long i__; + static F77_int i__; static double gi; --g; --x; --nbd; @@ -3054,11 +3038,10 @@ } } d__1 = *sbgnrm, d__2 = fabs(gi); *sbgnrm = d__1 >= d__2 ? d__1 : d__2; } - return 0; } /* ********************************************************************** * * This routine contains the major changes in the updated version. @@ -3091,11 +3074,11 @@ * (P) min Q(x) = r'(x-xcp) + 1/2 (x-xcp)' B (x-xcp) * * subject to l<=x<=u * x_i=xcp_i for all i in A(xcp) * - * along the subspace unconstrained Newton direction + * aF77_int the subspace unconstrained Newton direction * * d = -(Z'BZ)^(-1) r. * * The formula for the Newton direction, given the L-BFGS matrix * and the Sherman-Morrison formula, is @@ -3108,24 +3091,24 @@ * * Note that this procedure for computing d differs * from that described in [1]. One can show that the matrix K is * equal to the matrix M^[-1]N in that paper. * - * n is an long variable. + * n is an integer variable. * On entry n is the dimension of the problem. * On exit n is unchanged. * - * m is an long variable. + * m is an integer variable. * On entry m is the maximum number of variable metric corrections * used to define the limited memory matrix. * On exit m is unchanged. * - * nsub is an long variable. + * nsub is an integer variable. * On entry nsub is the number of free variables. * On exit nsub is unchanged. * - * ind is an long array of dimension nsub. + * ind is an integer array of dimension nsub. * On entry ind specifies the coordinate indices of free variables. * On exit ind is unchanged. * * l is a double precision array of dimension n. * On entry l is the lower bound of x. @@ -3133,11 +3116,11 @@ * * u is a double precision array of dimension n. * On entry u is the upper bound of x. * On exit u is unchanged. * - * nbd is a long array of dimension n. + * nbd is a integer array of dimension n. * On entry nbd represents the type of bounds imposed on the * variables, and must be specified as follows: * nbd(i)=0 if x(i) is unbounded, * 1 if x(i) has only a lower bound, * 2 if x(i) has both lower and upper bounds, and @@ -3163,22 +3146,22 @@ * On entry it holds the gradient at the current iterate * On output it is unchanged * * ws and wy are double precision arrays; * theta is a double precision variable; - * col is an long variable; - * head is an long variable. + * col is an integer variable; + * head is an integer variable. * On entry they store the information defining the * limited memory BFGS matrix: * ws(n,m) stores S, a set of s-vectors; * wy(n,m) stores Y, a set of y-vectors; * theta is the scaling factor specifying B_0 = theta I; * col is the number of variable metric corrections stored; * head is the location of the 1st s- (or y-) vector in S (or Y). * On exit they are unchanged. * - * iword is an long variable. + * iword is an integer variable. * On entry iword is unspecified. * On exit iword specifies the status of the subspace solution. * iword = 0 if the solution is in the box, * 1 if some bound is encountered. * @@ -3192,22 +3175,22 @@ * [L_a -R_z theta*S'AA'S ] * where E = [-I 0] * [ 0 I] * On exit wn is unchanged. * - * iprint is an long variable that must be set by the user. + * iprint is an integer variable that must be set by the user. * It controls the frequency and type of output generated: * iprint<0 no output is generated; * iprint=0 print only one line at the last iteration; * 0<iprint<99 print also f and |proj g| every iprint iterations; * iprint=99 print details of every iteration except n-vectors; * iprint=100 print also the changes of active set and final x; * iprint>100 print details of every iteration including x and g; * When iprint > 0, the file iterate.dat will be created to * summarize the iteration. * - * info is an long variable. + * info is an integer variable. * On entry info is unspecified. * On exit info = 0 for normal return, * = nonzero for abnormal return * when the matrix K is ill-conditioned. * @@ -3229,22 +3212,22 @@ * Argonne National Laboratory and Northwestern University. * Written by * Ciyou Zhu * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal */ -int subsm_(long* n, long* m, long* nsub, long* ind, double* l, double* u, long* nbd, double* x, double* d__, double* xp, - double* ws, double* wy, double* theta, double* xx, double* gg, long* col, long* head, long* iword, double* wv, - double* wn, long* iprint, long* info) { - long ws_dim1, ws_offset, wy_dim1, wy_offset, wn_dim1, wn_offset, i__1, i__2; +void subsm_(F77_int* n, F77_int* m, F77_int* nsub, F77_int* ind, double* l, double* u, F77_int* nbd, double* x, double* d__, double* xp, + double* ws, double* wy, double* theta, double* xx, double* gg, F77_int* col, F77_int* head, F77_int* iword, double* wv, + double* wn, F77_int* iprint, F77_int* info) { + F77_int ws_dim1, ws_offset, wy_dim1, wy_offset, wn_dim1, wn_offset, i__1, i__2; double d__1, d__2; - static long i__, j, k, m2; + static F77_int i__, j, k, m2; static double dk; - static long js, jy; + static F77_int js, jy; static double xk; - static long ibd, col2; + static F77_int ibd, col2; static double dd_p__, temp1, temp2, alpha; - static long pointr; + static F77_int pointr; --gg; --xx; --xp; --d__; @@ -3263,11 +3246,11 @@ ws_offset = 1 + ws_dim1; ws -= ws_offset; --ind; if (*nsub <= 0) { - return 0; + return; } if (*iprint >= 99) { fprintf(stdout, "\n----------------SUBSM entered-----------------\n\n"); } /* Compute wv = W'Zd. */ @@ -3287,21 +3270,21 @@ pointr = pointr % *m + 1; } /* Compute wv:=K^(-1)wv. */ m2 = *m << 1; col2 = *col << 1; - lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__11, info); + dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__11, info); if (*info != 0) { - return 0; + return; } i__1 = *col; for (i__ = 1; i__ <= i__1; ++i__) { wv[i__] = -wv[i__]; } - lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__1, info); + dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__1, info); if (*info != 0) { - return 0; + return; } /* Compute d = (1/theta)d + (1/theta**2)Z'W wv. */ pointr = *head; i__1 = *col; for (jy = 1; jy <= i__1; ++jy) { @@ -3312,16 +3295,16 @@ d__[i__] = d__[i__] + wy[k + pointr * wy_dim1] * wv[jy] / *theta + ws[k + pointr * ws_dim1] * wv[js]; } pointr = pointr % *m + 1; } d__1 = 1. / *theta; - lbfgsb_rb_dscal_(nsub, &d__1, &d__[1], &c__1); + dscal_(nsub, &d__1, &d__[1], &c__1); /* ----------------------------------------------------------------- */ /* Let us try the projection, d is the Newton direction */ *iword = 0; - lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xp[1], &c__1); + dcopy_(n, &x[1], &c__1, &xp[1], &c__1); i__1 = *nsub; for (i__ = 1; i__ <= i__1; ++i__) { k = ind[i__]; dk = d__[i__]; @@ -3370,11 +3353,11 @@ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { dd_p__ += (x[i__] - xx[i__]) * gg[i__]; } if (dd_p__ > 0.) { - lbfgsb_rb_dcopy_(n, &xp[1], &c__1, &x[1], &c__1); + dcopy_(n, &xp[1], &c__1, &x[1], &c__1); fprintf(stderr, " Positive dir derivative in projection\n"); fprintf(stderr, " Using the backtracking step\n"); } else { goto L911; } @@ -3429,11 +3412,10 @@ /* ccccc */ L911: if (*iprint >= 99) { fprintf(stdout, "\n----------------exit SUBSM --------------------\n\n"); } - return 0; } /** * Subroutine dcsrch * @@ -3546,11 +3528,11 @@ * input arguments. * * On exit with convergence, a warning or an error, the * variable task contains additional information. * - * isave is an long work array of dimension 2. + * isave is an integer work array of dimension 2. * * dsave is a double precision work array of dimension 13. * * Subprograms called * @@ -3562,18 +3544,18 @@ * * MINPACK-2 Project. October 1993. * Argonne National Laboratory and University of Minnesota. * Brett M. Averick, Richard G. Carter, and Jorge J. More'. */ -int dcsrch_(double* f, double* g, double* stp, double* ftol, double* gtol, double* xtol, double* stpmin, double* stpmax, - char* task, long* isave, double* dsave) { +void dcsrch_(double* f, double* g, double* stp, double* ftol, double* gtol, double* xtol, double* stpmin, double* stpmax, + char* task, F77_int* isave, double* dsave) { double d__1; static double fm, gm, fx, fy, gx, gy, fxm, fym, gxm, gym, stx, sty; - static long stage; + static F77_int stage; static double finit, ginit, width, ftest, gtest, stmin, stmax, width1; - static long brackt; + static F77_int brackt; --dsave; --isave; if (strncmp(task, "START", 5) == 0) { @@ -3602,11 +3584,11 @@ if (*stpmax < *stpmin) { strcpy(task, "ERROR: STPMAX .LT. STPMIN"); } /* Exit if there are errors on input. */ if (strncmp(task, "ERROR", 5) == 0) { - return 0; + return; } /* Initialize local variables. */ brackt = FALSE_; stage = 1; finit = *f; @@ -3746,11 +3728,10 @@ dsave[9] = sty; dsave[10] = stmin; dsave[11] = stmax; dsave[12] = width; dsave[13] = width1; - return 0; } /** * Subroutine dcstep * @@ -3839,12 +3820,12 @@ * * MINPACK-2 Project. October 1993. * Argonne National Laboratory and University of Minnesota. * Brett M. Averick and Jorge J. More'. */ -int dcstep_(double* stx, double* fx, double* dx, double* sty, double* fy, double* dy, double* stp, double* fp, double* dp, - long* brackt, double* stpmin, double* stpmax) { +void dcstep_(double* stx, double* fx, double* dx, double* sty, double* fy, double* dy, double* stp, double* fp, double* dp, + F77_int* brackt, double* stpmin, double* stpmax) { double d__1, d__2, d__3; static double p, q, r__, s, sgnd, stpc, stpf, stpq, gamma, theta; sgnd = *dp * (*dx / fabs(*dx)); /* First case: A higher function value. The minimum is bracketed. */ @@ -4005,12 +3986,10 @@ *fx = *fp; *dx = *dp; } /* Compute the new step. */ *stp = stpf; - return 0; } -int timer_(double* ttime) { +void timer_(double* ttime) { *ttime = (double)clock() / CLOCKS_PER_SEC; - return 0; }