lbfgsb 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,14 +43,14 @@
43
43
  *
44
44
  * March 2011
45
45
  */
46
-
47
- #include "lbfgsb.h"
48
46
  #include "blas.h"
49
47
  #include "linpack.h"
50
48
 
49
+ #include "lbfgsb.h"
50
+
51
51
  static double c_b9 = 0.;
52
- static long c__1 = 1;
53
- static long c__11 = 11;
52
+ static F77_int c__1 = 1;
53
+ static F77_int c__11 = 11;
54
54
  static double c_b280 = .001;
55
55
  static double c_b281 = .9;
56
56
  static double c_b282 = .1;
@@ -63,11 +63,11 @@ static double c_b282 = .1;
63
63
  * constrained optimization problem by calling mainlb.
64
64
  * (The direct method will be used in the subspace minimization.)
65
65
  *
66
- * n is an long variable.
66
+ * n is an integer variable.
67
67
  * On entry n is the dimension of the problem.
68
68
  * On exit n is unchanged.
69
69
  *
70
- * m is an long variable.
70
+ * m is an integer variable.
71
71
  * On entry m is the maximum number of variable metric corrections
72
72
  * used to define the limited memory matrix.
73
73
  * On exit m is unchanged.
@@ -84,7 +84,7 @@ static double c_b282 = .1;
84
84
  * On entry u is the upper bound on x.
85
85
  * On exit u is unchanged.
86
86
  *
87
- * nbd is an long array of dimension n.
87
+ * nbd is an integer array of dimension n.
88
88
  * On entry nbd represents the type of bounds imposed on the
89
89
  * variables, and must be specified as follows:
90
90
  * nbd(i)=0 if x(i) is unbounded,
@@ -126,12 +126,12 @@ static double c_b282 = .1;
126
126
  * wa is a double precision working array of length
127
127
  * (2mmax + 5)nmax + 12mmax^2 + 12mmax.
128
128
  *
129
- * iwa is an long working array of length 3nmax.
129
+ * iwa is an integer working array of length 3nmax.
130
130
  *
131
131
  * task is a working string of characters of length 60 indicating
132
132
  * the current job when entering and quitting this subroutine.
133
133
  *
134
- * iprint is an long variable that must be set by the user.
134
+ * iprint is an integer variable that must be set by the user.
135
135
  * It controls the frequency and type of output generated:
136
136
  * iprint<0 no output is generated;
137
137
  * iprint=0 print only one line at the last iteration;
@@ -153,7 +153,7 @@ static double c_b282 = .1;
153
153
  * If lsave(3) = .true. then each variable has upper and lower
154
154
  * bounds;
155
155
  *
156
- * isave is an long working array of dimension 44.
156
+ * isave is an integer working array of dimension 44.
157
157
  * On exit with 'task' = NEW_X, the following information is
158
158
  * available:
159
159
  * isave(22) = the total number of intervals explored in the
@@ -232,11 +232,11 @@ static double c_b282 = .1;
232
232
  * Ciyou Zhu
233
233
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
234
234
  */
235
- int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double* f, double* g, double* factr, double* pgtol,
236
- double* wa, long* iwa, char* task, long* iprint, char* csave, long* lsave, long* isave, double* dsave) {
237
- long i__1;
235
+ 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,
236
+ double* wa, F77_int* iwa, char* task, F77_int* iprint, char* csave, F77_int* lsave, F77_int* isave, double* dsave) {
237
+ F77_int i__1;
238
238
 
239
- static long ld, lr, lt, lz, lwa, lwn, lss, lxp, lws, lwt, lsy, lwy, lsnd;
239
+ static F77_int ld, lr, lt, lz, lwa, lwn, lss, lxp, lws, lwt, lsy, lwy, lsnd;
240
240
 
241
241
  /* jlm-jn */
242
242
  --iwa;
@@ -286,7 +286,6 @@ int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
286
286
  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],
287
287
  &wa[lwn], &wa[lsnd], &wa[lz], &wa[lr], &wa[ld], &wa[lt], &wa[lxp], &wa[lwa], &iwa[1], &iwa[*n + 1],
288
288
  &iwa[(*n << 1) + 1], task, iprint, csave, &lsave[1], &isave[22], &dsave[1]);
289
- return 0;
290
289
  }
291
290
 
292
291
  /**
@@ -295,11 +294,11 @@ int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
295
294
  * This subroutine solves bound constrained optimization problems by
296
295
  * using the compact formula of the limited memory BFGS updates.
297
296
  *
298
- * n is an long variable.
297
+ * n is an integer variable.
299
298
  * On entry n is the number of variables.
300
299
  * On exit n is unchanged.
301
300
  *
302
- * m is an long variable.
301
+ * m is an integer variable.
303
302
  * On entry m is the maximum number of variable metric
304
303
  * corrections allowed in the limited memory matrix.
305
304
  * On exit m is unchanged.
@@ -316,7 +315,7 @@ int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
316
315
  * On entry u is the upper bound of x.
317
316
  * On exit u is unchanged.
318
317
  *
319
- * nbd is an long array of dimension n.
318
+ * nbd is an integer array of dimension n.
320
319
  * On entry nbd represents the type of bounds imposed on the
321
320
  * variables, and must be specified as follows:
322
321
  * nbd(i)=0 if x(i) is unbounded,
@@ -384,11 +383,11 @@ int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
384
383
  *
385
384
  * sg(m),sgo(m),yg(m),ygo(m) are double precision working arrays.
386
385
  *
387
- * index is an long working array of dimension n.
386
+ * index is an integer working array of dimension n.
388
387
  * In subroutine freev, index is used to store the free and fixed
389
388
  * variables at the Generalized Cauchy Point (GCP).
390
389
  *
391
- * iwhere is an long working array of dimension n used to record
390
+ * iwhere is an integer working array of dimension n used to record
392
391
  * the status of the vector x for GCP computation.
393
392
  * iwhere(i)=0 or -3 if x(i) is free and has bounds,
394
393
  * 1 if x(i) is fixed at l(i), and l(i) .ne. u(i)
@@ -396,7 +395,7 @@ int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
396
395
  * 3 if x(i) is always fixed, i.e., u(i)=x(i)=l(i)
397
396
  * -1 if x(i) is always free, i.e., no bounds on it.
398
397
  *
399
- * indx2 is an long working array of dimension n.
398
+ * indx2 is an integer working array of dimension n.
400
399
  * Within subroutine cauchy, indx2 corresponds to the array iorder.
401
400
  * In subroutine freev, a list of variables entering and leaving
402
401
  * the free set is stored in indx2, and it is passed on to
@@ -405,7 +404,7 @@ int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
405
404
  * task is a working string of characters of length 60 indicating
406
405
  * the current job when entering and leaving this subroutine.
407
406
  *
408
- * iprint is an long variable that must be set by the user.
407
+ * iprint is an integer variable that must be set by the user.
409
408
  * It controls the frequency and type of output generated:
410
409
  * iprint<0 no output is generated;
411
410
  * iprint=0 print only one line at the last iteration;
@@ -420,7 +419,7 @@ int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
420
419
  *
421
420
  * lsave is a logical working array of dimension 4.
422
421
  *
423
- * isave is an long working array of dimension 23.
422
+ * isave is an integer working array of dimension 23.
424
423
  *
425
424
  * dsave is a double precision working array of dimension 29.
426
425
  *
@@ -465,51 +464,51 @@ int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
465
464
  * Ciyou Zhu
466
465
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
467
466
  */
468
- int mainlb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double* f, double* g, double* factr, double* pgtol,
467
+ 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,
469
468
  double* ws, double* wy, double* sy, double* ss, double* wt, double* wn, double* snd, double* z__, double* r__,
470
- double* d__, double* t, double* xp, double* wa, long* index, long* iwhere, long* indx2, char* task, long* iprint,
471
- char* csave, long* lsave, long* isave, double* dsave) {
472
- 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,
469
+ double* d__, double* t, double* xp, double* wa, F77_int* index, F77_int* iwhere, F77_int* indx2, char* task, F77_int* iprint,
470
+ char* csave, F77_int* lsave, F77_int* isave, double* dsave) {
471
+ 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,
473
472
  snd_dim1, snd_offset, i__1;
474
473
  double d__1, d__2;
475
474
  FILE* itfptr;
476
- static long i__, k;
475
+ static F77_int i__, k;
477
476
  static double gd, dr, rr, dtd;
478
- static long col;
477
+ static F77_int col;
479
478
  static double tol;
480
- static long wrk;
479
+ static F77_int wrk;
481
480
  static double stp, cpu1, cpu2;
482
- static long head;
481
+ static F77_int head;
483
482
  static double fold;
484
- static long nact;
483
+ static F77_int nact;
485
484
  static double ddum;
486
- static long info, nseg;
485
+ static F77_int info, nseg;
487
486
  static double time;
488
- static long nfgv, ifun, iter;
487
+ static F77_int nfgv, ifun, iter;
489
488
  static char word[4];
490
489
  static double time1, time2;
491
- static long iback;
490
+ static F77_int iback;
492
491
  static double gdold;
493
- static long nfree;
494
- static long boxed;
495
- static long itail;
492
+ static F77_int nfree;
493
+ static F77_int boxed;
494
+ static F77_int itail;
496
495
  static double theta;
497
496
  static double dnorm;
498
- static long nskip, iword;
497
+ static F77_int nskip, iword;
499
498
  static double xstep, stpmx;
500
- static long ileave;
499
+ static F77_int ileave;
501
500
  static double cachyt;
502
- static long itfile;
501
+ static F77_int itfile;
503
502
  static double epsmch;
504
- static long updatd;
503
+ static F77_int updatd;
505
504
  static double sbtime;
506
- static long prjctd;
507
- static long iupdat;
505
+ static F77_int prjctd;
506
+ static F77_int iupdat;
508
507
  static double sbgnrm;
509
- static long cnstnd;
510
- static long nenter;
508
+ static F77_int cnstnd;
509
+ static F77_int nenter;
511
510
  static double lnscht;
512
- static long nintol;
511
+ static F77_int nintol;
513
512
 
514
513
  --indx2;
515
514
  --iwhere;
@@ -600,7 +599,7 @@ int mainlb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
600
599
  if (strncmp(task, "ERROR", 5) == 0) {
601
600
  prn3lb_(n, &x[1], f, task, iprint, &info, &itfile, &iter, &nfgv, &nintol, &nskip, &nact, &sbgnrm, &c_b9, &nseg, word,
602
601
  &iback, &stp, &xstep, &k, &cachyt, &sbtime, &lnscht);
603
- return 0;
602
+ return;
604
603
  }
605
604
  prn1lb_(n, m, &l[1], &u[1], &x[1], iprint, &itfile, &epsmch);
606
605
  /* Initialize iwhere & project x onto the feasible set. */
@@ -660,8 +659,8 @@ int mainlb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double
660
659
  if (strncmp(task, "STOP", 4) == 0) {
661
660
  if (strncmp(task + 6, "CPU", 3) == 0) {
662
661
  /* restore the previous iterate. */
663
- lbfgsb_rb_dcopy_(n, &t[1], &c__1, &x[1], &c__1);
664
- lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &g[1], &c__1);
662
+ dcopy_(n, &t[1], &c__1, &x[1], &c__1);
663
+ dcopy_(n, &r__[1], &c__1, &g[1], &c__1);
665
664
  *f = fold;
666
665
  }
667
666
  goto L999;
@@ -676,9 +675,9 @@ L111:
676
675
  /* Compute the infinity norm of the (-) projected gradient. */
677
676
  projgr_(n, &l[1], &u[1], &nbd[1], &x[1], &g[1], &sbgnrm);
678
677
  if (*iprint >= 1) {
679
- fprintf(stdout, "\nAt iterate%5ld f= %12.5E |proj g|= %12.5E\n", iter, *f, sbgnrm);
678
+ fprintf(stdout, "\nAt iterate%5" PRIdF77INT " f= %12.5E |proj g|= %12.5E\n", iter, *f, sbgnrm);
680
679
  itfptr = fopen("iterate.dat", "a");
681
- fprintf(itfptr, " %4ld %4ld - - - - - - %10.3E %10.3E\n", iter, nfgv, sbgnrm, *f);
680
+ fprintf(itfptr, " %4" PRIdF77INT " %4" PRIdF77INT " - - - - - - %10.3E %10.3E\n", iter, nfgv, sbgnrm, *f);
682
681
  fclose(itfptr);
683
682
  }
684
683
  if (sbgnrm <= *pgtol) {
@@ -690,13 +689,13 @@ L111:
690
689
  L222:
691
690
  if (*iprint >= 99) {
692
691
  i__1 = iter + 1;
693
- fprintf(stdout, "\n\nITERATION %5ld\n", i__1);
692
+ fprintf(stdout, "\n\nITERATION %5" PRIdF77INT "\n", i__1);
694
693
  }
695
694
  iword = -1;
696
695
 
697
696
  if (!cnstnd && col > 0) {
698
697
  /* skip the search for GCP. */
699
- lbfgsb_rb_dcopy_(n, &x[1], &c__1, &z__[1], &c__1);
698
+ dcopy_(n, &x[1], &c__1, &z__[1], &c__1);
700
699
  wrk = updatd;
701
700
  nseg = 0;
702
701
  goto L333;
@@ -815,8 +814,8 @@ L666:
815
814
  &xstep, &stpmx, &iter, &ifun, &iback, &nfgv, &info, task, &boxed, &cnstnd, csave, &isave[22], &dsave[17]);
816
815
  if (info != 0 || iback >= 20) {
817
816
  /* restore the previous iterate. */
818
- lbfgsb_rb_dcopy_(n, &t[1], &c__1, &x[1], &c__1);
819
- lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &g[1], &c__1);
817
+ dcopy_(n, &t[1], &c__1, &x[1], &c__1);
818
+ dcopy_(n, &r__[1], &c__1, &g[1], &c__1);
820
819
  *f = fold;
821
820
  if (col == 0) {
822
821
  /* abnormal termination. */
@@ -890,13 +889,13 @@ L777:
890
889
  for (i__ = 1; i__ <= i__1; ++i__) {
891
890
  r__[i__] = g[i__] - r__[i__];
892
891
  }
893
- rr = lbfgsb_rb_ddot_(n, &r__[1], &c__1, &r__[1], &c__1);
892
+ rr = ddot_(n, &r__[1], &c__1, &r__[1], &c__1);
894
893
  if (stp == 1.) {
895
894
  dr = gd - gdold;
896
895
  ddum = -gdold;
897
896
  } else {
898
897
  dr = (gd - gdold) * stp;
899
- lbfgsb_rb_dscal_(n, &stp, &d__[1], &c__1);
898
+ dscal_(n, &stp, &d__[1], &c__1);
900
899
  ddum = -gdold * stp;
901
900
  }
902
901
  if (dr <= epsmch * ddum) {
@@ -988,7 +987,6 @@ L1000:
988
987
  dsave[14] = stp;
989
988
  dsave[15] = gdold;
990
989
  dsave[16] = dtd;
991
- return 0;
992
990
  }
993
991
 
994
992
  /**
@@ -997,7 +995,7 @@ L1000:
997
995
  * This subroutine initializes iwhere and projects the initial x to
998
996
  * the feasible set if necessary.
999
997
  *
1000
- * iwhere is an long array of dimension n.
998
+ * iwhere is an integer array of dimension n.
1001
999
  * On entry iwhere is unspecified.
1002
1000
  * On exit iwhere(i)=-1 if x(i) has no bounds
1003
1001
  * 3 if l(i)=u(i)
@@ -1013,10 +1011,10 @@ L1000:
1013
1011
  * Ciyou Zhu
1014
1012
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
1015
1013
  */
1016
- int active_(long* n, double* l, double* u, long* nbd, double* x, long* iwhere, long* iprint, long* prjctd, long* cnstnd,
1017
- long* boxed) {
1018
- long i__1;
1019
- static long i__, nbdd;
1014
+ 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,
1015
+ F77_int* boxed) {
1016
+ F77_int i__1;
1017
+ static F77_int i__, nbdd;
1020
1018
  --iwhere;
1021
1019
  --x;
1022
1020
  --nbd;
@@ -1077,9 +1075,8 @@ int active_(long* n, double* l, double* u, long* nbd, double* x, long* iwhere, l
1077
1075
  }
1078
1076
  if (*iprint > 0) {
1079
1077
  fprintf(stdout, "\n");
1080
- fprintf(stdout, "At X0 %9ld variables are exactly at the bounds\n", nbdd);
1078
+ fprintf(stdout, "At X0 %9" PRIdF77INT " variables are exactly at the bounds\n", nbdd);
1081
1079
  }
1082
- return 0;
1083
1080
  }
1084
1081
 
1085
1082
  /**
@@ -1089,7 +1086,7 @@ int active_(long* n, double* l, double* u, long* nbd, double* x, long* iwhere, l
1089
1086
  * in the compact L-BFGS formula of B and a 2m vector v;
1090
1087
  * it returns the product in p.
1091
1088
  *
1092
- * m is an long variable.
1089
+ * m is an integer variable.
1093
1090
  * On entry m is the maximum number of variable metric corrections
1094
1091
  * used to define the limited memory matrix.
1095
1092
  * On exit m is unchanged.
@@ -1103,7 +1100,7 @@ int active_(long* n, double* l, double* u, long* nbd, double* x, long* iwhere, l
1103
1100
  * the Cholesky factor of (thetaS'S+LD^(-1)L').
1104
1101
  * On exit wt is unchanged.
1105
1102
  *
1106
- * col is an long variable.
1103
+ * col is an integer variable.
1107
1104
  * On entry col specifies the number of s-vectors (or y-vectors)
1108
1105
  * stored in the compact L-BFGS formula.
1109
1106
  * On exit col is unchanged.
@@ -1116,7 +1113,7 @@ int active_(long* n, double* l, double* u, long* nbd, double* x, long* iwhere, l
1116
1113
  * On entry p is unspecified.
1117
1114
  * On exit p is the product Mv.
1118
1115
  *
1119
- * info is an long variable.
1116
+ * info is an integer variable.
1120
1117
  * On entry info is unspecified.
1121
1118
  * On exit info = 0 for normal return,
1122
1119
  * = nonzero for abnormal return when the system
@@ -1135,9 +1132,9 @@ int active_(long* n, double* l, double* u, long* nbd, double* x, long* iwhere, l
1135
1132
  * Ciyou Zhu
1136
1133
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
1137
1134
  */
1138
- int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long* info) {
1139
- long sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
1140
- static long i__, k, i2;
1135
+ void bmv_(F77_int* m, double* sy, double* wt, F77_int* col, double* v, double* p, F77_int* info) {
1136
+ F77_int sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
1137
+ static F77_int i__, k, i2;
1141
1138
  static double sum;
1142
1139
 
1143
1140
  wt_dim1 = *m;
@@ -1150,7 +1147,7 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1150
1147
  --v;
1151
1148
 
1152
1149
  if (*col == 0) {
1153
- return 0;
1150
+ return;
1154
1151
  }
1155
1152
  /* PART I: solve [ D^(1/2) O ] [ p1 ] = [ v1 ] */
1156
1153
  /* [ -L*D^(-1/2) J ] [ p2 ] [ v2 ]. */
@@ -1167,9 +1164,9 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1167
1164
  p[i2] = v[i2] + sum;
1168
1165
  }
1169
1166
  /* Solve the triangular system */
1170
- lbfgsb_rb_dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__11, info);
1167
+ dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__11, info);
1171
1168
  if (*info != 0) {
1172
- return 0;
1169
+ return;
1173
1170
  }
1174
1171
  /* solve D^(1/2)p1=v1. */
1175
1172
  i__1 = *col;
@@ -1179,9 +1176,9 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1179
1176
  /* PART II: solve [ -D^(1/2) D^(-1/2)*L' ] [ p1 ] = [ p1 ] */
1180
1177
  /* [ 0 J' ] [ p2 ] [ p2 ]. */
1181
1178
  /* solve J^Tp2=p2. */
1182
- lbfgsb_rb_dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__1, info);
1179
+ dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__1, info);
1183
1180
  if (*info != 0) {
1184
- return 0;
1181
+ return;
1185
1182
  }
1186
1183
  /* compute p1=-D^(-1/2)(p1-D^(-1/2)L'p2) */
1187
1184
  /* =-D^(-1/2)p1+D^(-1)L'p2. */
@@ -1198,7 +1195,6 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1198
1195
  }
1199
1196
  p[i__] += sum;
1200
1197
  }
1201
- return 0;
1202
1198
  }
1203
1199
 
1204
1200
  /**
@@ -1212,10 +1208,10 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1212
1208
  *
1213
1209
  * Q(x + s) = g's + 1/2 s'Bs
1214
1210
  *
1215
- * along the projected gradient direction P(x-tg,l,u).
1211
+ * aF77_int the projected gradient direction P(x-tg,l,u).
1216
1212
  * The routine returns the GCP in xcp.
1217
1213
  *
1218
- * n is an long variable.
1214
+ * n is an integer variable.
1219
1215
  * On entry n is the dimension of the problem.
1220
1216
  * On exit n is unchanged.
1221
1217
  *
@@ -1231,7 +1227,7 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1231
1227
  * On entry u is the upper bound of x.
1232
1228
  * On exit u is unchanged.
1233
1229
  *
1234
- * nbd is an long array of dimension n.
1230
+ * nbd is an integer array of dimension n.
1235
1231
  * On entry nbd represents the type of bounds imposed on the
1236
1232
  * variables, and must be specified as follows:
1237
1233
  * nbd(i)=0 if x(i) is unbounded,
@@ -1244,7 +1240,7 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1244
1240
  * On entry g is the gradient of f(x). g must be a nonzero vector.
1245
1241
  * On exit g is unchanged.
1246
1242
  *
1247
- * iorder is an long working array of dimension n.
1243
+ * iorder is an integer working array of dimension n.
1248
1244
  * iorder will be used to store the breakpoints in the piecewise
1249
1245
  * linear path and free variables encountered. On exit,
1250
1246
  * iorder(1),...,iorder(nleft) are indices of breakpoints
@@ -1252,9 +1248,9 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1252
1248
  * iorder(nleft+1),...,iorder(nbreak) are indices of
1253
1249
  * encountered breakpoints; and
1254
1250
  * iorder(nfree),...,iorder(n) are indices of variables which
1255
- * have no bound constraits along the search direction.
1251
+ * have no bound constraits aF77_int the search direction.
1256
1252
  *
1257
- * iwhere is an long array of dimension n.
1253
+ * iwhere is an integer array of dimension n.
1258
1254
  * On entry iwhere indicates only the permanently fixed (iwhere=3)
1259
1255
  * or free (iwhere= -1) components of x.
1260
1256
  * On exit iwhere records the status of the current x variables.
@@ -1274,7 +1270,7 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1274
1270
  * xcp is a double precision array of dimension n used to return the
1275
1271
  * GCP on exit.
1276
1272
  *
1277
- * m is an long variable.
1273
+ * m is an integer variable.
1278
1274
  * On entry m is the maximum number of variable metric corrections
1279
1275
  * used to define the limited memory matrix.
1280
1276
  * On exit m is unchanged.
@@ -1293,12 +1289,12 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1293
1289
  * On entry theta is the scaling factor specifying B_0 = theta I.
1294
1290
  * On exit theta is unchanged.
1295
1291
  *
1296
- * col is an long variable.
1292
+ * col is an integer variable.
1297
1293
  * On entry col is the actual number of variable metric
1298
1294
  * corrections stored so far.
1299
1295
  * On exit col is unchanged.
1300
1296
  *
1301
- * head is an long variable.
1297
+ * head is an integer variable.
1302
1298
  * On entry head is the location of the first s-vector (or y-vector)
1303
1299
  * in S (or Y).
1304
1300
  * On exit col is unchanged.
@@ -1315,7 +1311,7 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1315
1311
  *
1316
1312
  * v is a double precision working array of dimension 2m.
1317
1313
  *
1318
- * nseg is an long variable.
1314
+ * nseg is an integer variable.
1319
1315
  * On exit nseg records the number of quadratic segments explored
1320
1316
  * in searching for the GCP.
1321
1317
  *
@@ -1323,7 +1319,7 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1323
1319
  * On entry sg and yg store S'g and Y'g correspondingly.
1324
1320
  * On exit they are unchanged.
1325
1321
  *
1326
- * iprint is an long variable that must be set by the user.
1322
+ * iprint is an integer variable that must be set by the user.
1327
1323
  * It controls the frequency and type of output generated:
1328
1324
  * iprint<0 no output is generated;
1329
1325
  * iprint=0 print only one line at the last iteration;
@@ -1338,7 +1334,7 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1338
1334
  * On entry sbgnrm is the norm of the projected gradient at x.
1339
1335
  * On exit sbgnrm is unchanged.
1340
1336
  *
1341
- * info is an long variable.
1337
+ * info is an integer variable.
1342
1338
  * On entry info is 0.
1343
1339
  * On exit info = 0 for normal return,
1344
1340
  * = nonzero for abnormal return when the the system
@@ -1374,30 +1370,30 @@ int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long*
1374
1370
  * Ciyou Zhu
1375
1371
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
1376
1372
  */
1377
- int cauchy_(long* n, double* x, double* l, double* u, long* nbd, double* g, long* iorder, long* iwhere, double* t, double* d__,
1378
- double* xcp, long* m, double* wy, double* ws, double* sy, double* wt, double* theta, long* col, long* head,
1379
- double* p, double* c__, double* wbp, double* v, long* nseg, long* iprint, double* sbgnrm, long* info,
1373
+ 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__,
1374
+ double* xcp, F77_int* m, double* wy, double* ws, double* sy, double* wt, double* theta, F77_int* col, F77_int* head,
1375
+ double* p, double* c__, double* wbp, double* v, F77_int* nseg, F77_int* iprint, double* sbgnrm, F77_int* info,
1380
1376
  double* epsmch) {
1381
- long wy_dim1, wy_offset, ws_dim1, ws_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
1377
+ F77_int wy_dim1, wy_offset, ws_dim1, ws_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
1382
1378
  double d__1;
1383
- static long i__, j;
1379
+ static F77_int i__, j;
1384
1380
  static double f1, f2, dt, tj, tl, tu, tj0;
1385
- static long ibp;
1381
+ static F77_int ibp;
1386
1382
  static double dtm;
1387
1383
  static double wmc, wmp, wmw;
1388
- static long col2;
1384
+ static F77_int col2;
1389
1385
  static double dibp;
1390
- static long iter;
1386
+ static F77_int iter;
1391
1387
  static double zibp, tsum, dibp2;
1392
- static long bnded;
1388
+ static F77_int bnded;
1393
1389
  static double neggi;
1394
- static long nfree;
1390
+ static F77_int nfree;
1395
1391
  static double bkmin;
1396
- static long nleft;
1392
+ static F77_int nleft;
1397
1393
  static double f2_org__;
1398
- static long nbreak, ibkmin;
1399
- static long pointr;
1400
- static long xlower, xupper;
1394
+ static F77_int nbreak, ibkmin;
1395
+ static F77_int pointr;
1396
+ static F77_int xlower, xupper;
1401
1397
 
1402
1398
  --xcp;
1403
1399
  --d__;
@@ -1433,8 +1429,8 @@ int cauchy_(long* n, double* x, double* l, double* u, long* nbd, double* g, long
1433
1429
  if (*iprint >= 0) {
1434
1430
  fprintf(stdout, " Subgnorm = 0. GCP = X.\n");
1435
1431
  }
1436
- lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xcp[1], &c__1);
1437
- return 0;
1432
+ dcopy_(n, &x[1], &c__1, &xcp[1], &c__1);
1433
+ return;
1438
1434
  }
1439
1435
  bnded = TRUE_;
1440
1436
  nfree = *n + 1;
@@ -1532,10 +1528,10 @@ int cauchy_(long* n, double* x, double* l, double* u, long* nbd, double* g, long
1532
1528
  /* The smallest of the nbreak breakpoints is in t(ibkmin)=bkmin. */
1533
1529
  if (*theta != 1.) {
1534
1530
  /* complete the initialization of p for theta not= one. */
1535
- lbfgsb_rb_dscal_(col, theta, &p[*col + 1], &c__1);
1531
+ dscal_(col, theta, &p[*col + 1], &c__1);
1536
1532
  }
1537
1533
  /* Initialize GCP xcp = x. */
1538
- lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xcp[1], &c__1);
1534
+ dcopy_(n, &x[1], &c__1, &xcp[1], &c__1);
1539
1535
  if (nbreak == 0 && nfree == *n + 1) {
1540
1536
  /* is a zero vector, return with the initial xcp as GCP. */
1541
1537
  if (*iprint > 100) {
@@ -1551,7 +1547,7 @@ int cauchy_(long* n, double* x, double* l, double* u, long* nbd, double* g, long
1551
1547
  }
1552
1548
  fprintf(stdout, "\n");
1553
1549
  }
1554
- return 0;
1550
+ return;
1555
1551
  }
1556
1552
  /* Initialize c = W'(xcp - x) = 0. */
1557
1553
  i__1 = col2;
@@ -1564,15 +1560,15 @@ int cauchy_(long* n, double* x, double* l, double* u, long* nbd, double* g, long
1564
1560
  if (*col > 0) {
1565
1561
  bmv_(m, &sy[sy_offset], &wt[wt_offset], col, &p[1], &v[1], info);
1566
1562
  if (*info != 0) {
1567
- return 0;
1563
+ return;
1568
1564
  }
1569
- f2 -= lbfgsb_rb_ddot_(&col2, &v[1], &c__1, &p[1], &c__1);
1565
+ f2 -= ddot_(&col2, &v[1], &c__1, &p[1], &c__1);
1570
1566
  }
1571
1567
  dtm = -f1 / f2;
1572
1568
  tsum = 0.;
1573
1569
  *nseg = 1;
1574
1570
  if (*iprint >= 99) {
1575
- fprintf(stdout, " There are %3ld breakpoints \n", nbreak);
1571
+ fprintf(stdout, " There are %3" PRIdF77INT " breakpoints \n", nbreak);
1576
1572
  }
1577
1573
  /* If there are no breakpoints, locate the GCP and return. */
1578
1574
  if (nbreak == 0) {
@@ -1611,7 +1607,7 @@ L777:
1611
1607
  dt = tj - tj0;
1612
1608
  if (dt != 0. && *iprint >= 100) {
1613
1609
  fprintf(stdout, "\n");
1614
- fprintf(stdout, "Piece %3ld --f1, f2 at start point %11.4E %11.4E\n", *nseg, f1, f2);
1610
+ fprintf(stdout, "Piece %3" PRIdF77INT " --f1, f2 at start point %11.4E %11.4E\n", *nseg, f1, f2);
1615
1611
  fprintf(stdout, "Distance to the next break point = %11.4E\n", dt);
1616
1612
  fprintf(stdout, "Distance to the stationary point = %11.4E\n", dtm);
1617
1613
  }
@@ -1636,7 +1632,7 @@ L777:
1636
1632
  iwhere[ibp] = 1;
1637
1633
  }
1638
1634
  if (*iprint >= 100) {
1639
- fprintf(stdout, " Variable %ld is fixed.\n", ibp);
1635
+ fprintf(stdout, " Variable %" PRIdF77INT " is fixed.\n", ibp);
1640
1636
  }
1641
1637
  if (nleft == 0 && nbreak == *n) {
1642
1638
  /* all n variables are fixed, */
@@ -1655,7 +1651,7 @@ L777:
1655
1651
  f2 -= *theta * dibp2;
1656
1652
  if (*col > 0) {
1657
1653
  /* update c = c + dt*p. */
1658
- lbfgsb_rb_daxpy_(&col2, &dt, &p[1], &c__1, &c__[1], &c__1);
1654
+ daxpy_(&col2, &dt, &p[1], &c__1, &c__[1], &c__1);
1659
1655
  /* choose wbp, */
1660
1656
  /* the row of W corresponding to the breakpoint encountered. */
1661
1657
  pointr = *head;
@@ -1668,14 +1664,14 @@ L777:
1668
1664
  /* compute (wbp)Mc, (wbp)Mp, and (wbp)M(wbp)'. */
1669
1665
  bmv_(m, &sy[sy_offset], &wt[wt_offset], col, &wbp[1], &v[1], info);
1670
1666
  if (*info != 0) {
1671
- return 0;
1667
+ return;
1672
1668
  }
1673
- wmc = lbfgsb_rb_ddot_(&col2, &c__[1], &c__1, &v[1], &c__1);
1674
- wmp = lbfgsb_rb_ddot_(&col2, &p[1], &c__1, &v[1], &c__1);
1675
- wmw = lbfgsb_rb_ddot_(&col2, &wbp[1], &c__1, &v[1], &c__1);
1669
+ wmc = ddot_(&col2, &c__[1], &c__1, &v[1], &c__1);
1670
+ wmp = ddot_(&col2, &p[1], &c__1, &v[1], &c__1);
1671
+ wmw = ddot_(&col2, &wbp[1], &c__1, &v[1], &c__1);
1676
1672
  /* update p = p - dibp*wbp. */
1677
1673
  d__1 = -dibp;
1678
- lbfgsb_rb_daxpy_(&col2, &d__1, &wbp[1], &c__1, &p[1], &c__1);
1674
+ daxpy_(&col2, &d__1, &wbp[1], &c__1, &p[1], &c__1);
1679
1675
  /* complete updating f1 and f2 while col > 0. */
1680
1676
  f1 += dibp * wmc;
1681
1677
  f2 = f2 + dibp * 2. * wmp - dibp2 * wmw;
@@ -1698,7 +1694,7 @@ L888:
1698
1694
  if (*iprint >= 99) {
1699
1695
  fprintf(stdout, "\n");
1700
1696
  fprintf(stdout, " GCP found in this segment\n");
1701
- fprintf(stdout, "Piece %3ld --f1, f2 at start point %11.4E %11.4E\n", *nseg, f1, f2);
1697
+ fprintf(stdout, "Piece %3" PRIdF77INT " --f1, f2 at start point %11.4E %11.4E\n", *nseg, f1, f2);
1702
1698
  fprintf(stdout, "Distance to the stationary point = %11.4E\n", dtm);
1703
1699
  }
1704
1700
  if (dtm <= 0.) {
@@ -1707,12 +1703,12 @@ L888:
1707
1703
  tsum += dtm;
1708
1704
  /* Move free variables (i.e., the ones w/o breakpoints) and */
1709
1705
  /* the variables whose breakpoints haven't been reached. */
1710
- lbfgsb_rb_daxpy_(n, &tsum, &d__[1], &c__1, &xcp[1], &c__1);
1706
+ daxpy_(n, &tsum, &d__[1], &c__1, &xcp[1], &c__1);
1711
1707
  L999:
1712
1708
  /* Update c = c + dtm*p = W'(x^c - x) */
1713
1709
  /* which will be used in computing r = Z'(B(x^c - x) + g). */
1714
1710
  if (*col > 0) {
1715
- lbfgsb_rb_daxpy_(&col2, &dtm, &p[1], &c__1, &c__[1], &c__1);
1711
+ daxpy_(&col2, &dtm, &p[1], &c__1, &c__[1], &c__1);
1716
1712
  }
1717
1713
  if (*iprint > 100) {
1718
1714
  fprintf(stdout, "Cauchy X = \n");
@@ -1730,7 +1726,6 @@ L999:
1730
1726
  if (*iprint >= 99) {
1731
1727
  fprintf(stdout, "\n---------------- exit CAUCHY----------------------\n\n");
1732
1728
  }
1733
- return 0;
1734
1729
  }
1735
1730
 
1736
1731
  /**
@@ -1752,12 +1747,12 @@ L999:
1752
1747
  * Ciyou Zhu
1753
1748
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
1754
1749
  */
1755
- int cmprlb_(long* n, long* m, double* x, double* g, double* ws, double* wy, double* sy, double* wt, double* z__, double* r__,
1756
- double* wa, long* index, double* theta, long* col, long* head, long* nfree, long* cnstnd, long* info) {
1757
- long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
1758
- static long i__, j, k;
1750
+ void cmprlb_(F77_int* n, F77_int* m, double* x, double* g, double* ws, double* wy, double* sy, double* wt, double* z__, double* r__,
1751
+ double* wa, F77_int* index, double* theta, F77_int* col, F77_int* head, F77_int* nfree, F77_int* cnstnd, F77_int* info) {
1752
+ F77_int ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
1753
+ static F77_int i__, j, k;
1759
1754
  static double a1, a2;
1760
- static long pointr;
1755
+ static F77_int pointr;
1761
1756
 
1762
1757
  --index;
1763
1758
  --r__;
@@ -1792,7 +1787,7 @@ int cmprlb_(long* n, long* m, double* x, double* g, double* ws, double* wy, doub
1792
1787
  bmv_(m, &sy[sy_offset], &wt[wt_offset], col, &wa[(*m << 1) + 1], &wa[1], info);
1793
1788
  if (*info != 0) {
1794
1789
  *info = -8;
1795
- return 0;
1790
+ return;
1796
1791
  }
1797
1792
  pointr = *head;
1798
1793
  i__1 = *col;
@@ -1807,7 +1802,6 @@ int cmprlb_(long* n, long* m, double* x, double* g, double* ws, double* wy, doub
1807
1802
  pointr = pointr % *m + 1;
1808
1803
  }
1809
1804
  }
1810
- return 0;
1811
1805
  }
1812
1806
 
1813
1807
  /**
@@ -1824,9 +1818,9 @@ int cmprlb_(long* n, long* m, double* x, double* g, double* ws, double* wy, doub
1824
1818
  * Ciyou Zhu
1825
1819
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
1826
1820
  */
1827
- int errclb_(long* n, long* m, double* factr, double* l, double* u, long* nbd, char* task, long* info, long* k) {
1828
- long i__1;
1829
- static long i__;
1821
+ 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) {
1822
+ F77_int i__1;
1823
+ static F77_int i__;
1830
1824
  --nbd;
1831
1825
  --u;
1832
1826
  --l;
@@ -1859,7 +1853,6 @@ int errclb_(long* n, long* m, double* factr, double* l, double* u, long* nbd, ch
1859
1853
  }
1860
1854
  }
1861
1855
  }
1862
- return 0;
1863
1856
  }
1864
1857
 
1865
1858
  /**
@@ -1875,35 +1868,35 @@ int errclb_(long* n, long* m, double* factr, double* l, double* u, long* nbd, ch
1875
1868
  * occurring in section 5.1 of [1], as well as to the matrix
1876
1869
  * Mbar^[-1] Nbar in section 5.3.
1877
1870
  *
1878
- * n is an long variable.
1871
+ * n is an integer variable.
1879
1872
  * On entry n is the dimension of the problem.
1880
1873
  * On exit n is unchanged.
1881
1874
  *
1882
- * nsub is an long variable
1875
+ * nsub is an integer variable
1883
1876
  * On entry nsub is the number of subspace variables in free set.
1884
1877
  * On exit nsub is not changed.
1885
1878
  *
1886
- * ind is an long array of dimension nsub.
1879
+ * ind is an integer array of dimension nsub.
1887
1880
  * On entry ind specifies the indices of subspace variables.
1888
1881
  * On exit ind is unchanged.
1889
1882
  *
1890
- * nenter is an long variable.
1883
+ * nenter is an integer variable.
1891
1884
  * On entry nenter is the number of variables entering the
1892
1885
  * free set.
1893
1886
  * On exit nenter is unchanged.
1894
1887
  *
1895
- * ileave is an long variable.
1888
+ * ileave is an integer variable.
1896
1889
  * On entry indx2(ileave),...,indx2(n) are the variables leaving
1897
1890
  * the free set.
1898
1891
  * On exit ileave is unchanged.
1899
1892
  *
1900
- * indx2 is an long array of dimension n.
1893
+ * indx2 is an integer array of dimension n.
1901
1894
  * On entry indx2(1),...,indx2(nenter) are the variables entering
1902
1895
  * the free set, while indx2(ileave),...,indx2(n) are the
1903
1896
  * variables leaving the free set.
1904
1897
  * On exit indx2 is unchanged.
1905
1898
  *
1906
- * iupdat is an long variable.
1899
+ * iupdat is an integer variable.
1907
1900
  * On entry iupdat is the total number of BFGS updates made so far.
1908
1901
  * On exit iupdat is unchanged.
1909
1902
  *
@@ -1927,15 +1920,15 @@ int errclb_(long* n, long* m, double* factr, double* l, double* u, long* nbd, ch
1927
1920
  * The purpose of wn1 is just to store these inner products
1928
1921
  * so they can be easily updated and inserted into wn.
1929
1922
  *
1930
- * m is an long variable.
1923
+ * m is an integer variable.
1931
1924
  * On entry m is the maximum number of variable metric corrections
1932
1925
  * used to define the limited memory matrix.
1933
1926
  * On exit m is unchanged.
1934
1927
  *
1935
1928
  * ws, wy, sy, and wtyy are double precision arrays;
1936
1929
  * theta is a double precision variable;
1937
- * col is an long variable;
1938
- * head is an long variable.
1930
+ * col is an integer variable;
1931
+ * head is an integer variable.
1939
1932
  * On entry they store the information defining the
1940
1933
  * limited memory BFGS matrix:
1941
1934
  * ws(n,m) stores S, a set of s-vectors;
@@ -1948,7 +1941,7 @@ int errclb_(long* n, long* m, double* factr, double* l, double* u, long* nbd, ch
1948
1941
  * head is the location of the 1st s- (or y-) vector in S (or Y).
1949
1942
  * On exit they are unchanged.
1950
1943
  *
1951
- * info is an long variable.
1944
+ * info is an integer variable.
1952
1945
  * On entry info is unspecified.
1953
1946
  * On exit info = 0 for normal return;
1954
1947
  * = -1 when the 1st Cholesky factorization failed;
@@ -1981,13 +1974,13 @@ int errclb_(long* n, long* m, double* factr, double* l, double* u, long* nbd, ch
1981
1974
  * Ciyou Zhu
1982
1975
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
1983
1976
  */
1984
- int formk_(long* n, long* nsub, long* ind, long* nenter, long* ileave, long* indx2, long* iupdat, long* updatd, double* wn,
1985
- double* wn1, long* m, double* ws, double* wy, double* sy, double* theta, long* col, long* head, long* info) {
1986
- 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;
1987
- static long i__, k, k1, m2, is, js, iy, jy, is1, js1, col2, dend, pend;
1988
- static long upcl;
1977
+ 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,
1978
+ double* wn1, F77_int* m, double* ws, double* wy, double* sy, double* theta, F77_int* col, F77_int* head, F77_int* info) {
1979
+ 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;
1980
+ static F77_int i__, k, k1, m2, is, js, iy, jy, is1, js1, col2, dend, pend;
1981
+ static F77_int upcl;
1989
1982
  static double temp1, temp2, temp3, temp4;
1990
- static long ipntr, jpntr, dbegin, pbegin;
1983
+ static F77_int ipntr, jpntr, dbegin, pbegin;
1991
1984
 
1992
1985
  --indx2;
1993
1986
  --ind;
@@ -2019,11 +2012,11 @@ int formk_(long* n, long* nsub, long* ind, long* nenter, long* ileave, long* ind
2019
2012
  for (jy = 1; jy <= i__1; ++jy) {
2020
2013
  js = *m + jy;
2021
2014
  i__2 = *m - jy;
2022
- lbfgsb_rb_dcopy_(&i__2, &wn1[jy + 1 + (jy + 1) * wn1_dim1], &c__1, &wn1[jy + jy * wn1_dim1], &c__1);
2015
+ dcopy_(&i__2, &wn1[jy + 1 + (jy + 1) * wn1_dim1], &c__1, &wn1[jy + jy * wn1_dim1], &c__1);
2023
2016
  i__2 = *m - jy;
2024
- lbfgsb_rb_dcopy_(&i__2, &wn1[js + 1 + (js + 1) * wn1_dim1], &c__1, &wn1[js + js * wn1_dim1], &c__1);
2017
+ dcopy_(&i__2, &wn1[js + 1 + (js + 1) * wn1_dim1], &c__1, &wn1[js + js * wn1_dim1], &c__1);
2025
2018
  i__2 = *m - 1;
2026
- lbfgsb_rb_dcopy_(&i__2, &wn1[*m + 2 + (jy + 1) * wn1_dim1], &c__1, &wn1[*m + 1 + jy * wn1_dim1], &c__1);
2019
+ dcopy_(&i__2, &wn1[*m + 2 + (jy + 1) * wn1_dim1], &c__1, &wn1[*m + 1 + jy * wn1_dim1], &c__1);
2027
2020
  }
2028
2021
  }
2029
2022
  /* put new rows in blocks (1,1), (2,1) and (2,2). */
@@ -2174,16 +2167,16 @@ int formk_(long* n, long* nsub, long* ind, long* nenter, long* ileave, long* ind
2174
2167
  /* [(-L_a +R_z)L'^-1 S'AA'S*theta ] */
2175
2168
  /* first Cholesky factor (1,1) block of wn to get LL' */
2176
2169
  /* with L' stored in the upper triangle of wn. */
2177
- lbfgsb_rb_dpofa_(&wn[wn_offset], &m2, col, info);
2170
+ dpofa_(&wn[wn_offset], &m2, col, info);
2178
2171
  if (*info != 0) {
2179
2172
  *info = -1;
2180
- return 0;
2173
+ return;
2181
2174
  }
2182
2175
  /* then form L^-1(-L_a'+R_z') in the (1,2) block. */
2183
2176
  col2 = *col << 1;
2184
2177
  i__1 = col2;
2185
2178
  for (js = *col + 1; js <= i__1; ++js) {
2186
- lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, col, &wn[js * wn_dim1 + 1], &c__11, info);
2179
+ dtrsl_(&wn[wn_offset], &m2, col, &wn[js * wn_dim1 + 1], &c__11, info);
2187
2180
  }
2188
2181
  /* Form S'AA'S*theta + (L^-1(-L_a'+R_z'))'L^-1(-L_a'+R_z') in the */
2189
2182
  /* upper triangle of (2,2) block of wn. */
@@ -2191,16 +2184,14 @@ int formk_(long* n, long* nsub, long* ind, long* nenter, long* ileave, long* ind
2191
2184
  for (is = *col + 1; is <= i__1; ++is) {
2192
2185
  i__2 = col2;
2193
2186
  for (js = is; js <= i__2; ++js) {
2194
- wn[is + js * wn_dim1] += lbfgsb_rb_ddot_(col, &wn[is * wn_dim1 + 1], &c__1, &wn[js * wn_dim1 + 1], &c__1);
2187
+ wn[is + js * wn_dim1] += ddot_(col, &wn[is * wn_dim1 + 1], &c__1, &wn[js * wn_dim1 + 1], &c__1);
2195
2188
  }
2196
2189
  }
2197
2190
  /* Cholesky factorization of (2,2) block of wn. */
2198
- lbfgsb_rb_dpofa_(&wn[*col + 1 + (*col + 1) * wn_dim1], &m2, col, info);
2191
+ dpofa_(&wn[*col + 1 + (*col + 1) * wn_dim1], &m2, col, info);
2199
2192
  if (*info != 0) {
2200
2193
  *info = -2;
2201
- return 0;
2202
2194
  }
2203
- return 0;
2204
2195
  }
2205
2196
 
2206
2197
  /**
@@ -2224,9 +2215,9 @@ int formk_(long* n, long* nsub, long* ind, long* nenter, long* ileave, long* ind
2224
2215
  * Ciyou Zhu
2225
2216
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
2226
2217
  */
2227
- int formt_(long* m, double* wt, double* sy, double* ss, long* col, double* theta, long* info) {
2228
- long wt_dim1, wt_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2, i__3;
2229
- static long i__, j, k, k1;
2218
+ void formt_(F77_int* m, double* wt, double* sy, double* ss, F77_int* col, double* theta, F77_int* info) {
2219
+ F77_int wt_dim1, wt_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2, i__3;
2220
+ static F77_int i__, j, k, k1;
2230
2221
  static double ddum;
2231
2222
 
2232
2223
  ss_dim1 = *m;
@@ -2260,11 +2251,10 @@ int formt_(long* m, double* wt, double* sy, double* ss, long* col, double* theta
2260
2251
  }
2261
2252
  /* Cholesky factorize T to J*J' with */
2262
2253
  /* J' stored in the upper triangle of wt. */
2263
- lbfgsb_rb_dpofa_(&wt[wt_offset], m, col, info);
2254
+ dpofa_(&wt[wt_offset], m, col, info);
2264
2255
  if (*info != 0) {
2265
2256
  *info = -3;
2266
2257
  }
2267
- return 0;
2268
2258
  }
2269
2259
 
2270
2260
  /**
@@ -2276,7 +2266,7 @@ int formt_(long* m, double* wt, double* sy, double* ss, long* col, double* theta
2276
2266
  *
2277
2267
  * cnstnd is a logical variable indicating whether bounds are present
2278
2268
  *
2279
- * index is an long array of dimension n
2269
+ * index is an integer array of dimension n
2280
2270
  * for i=1,...,nfree, index(i) are the indices of free variables
2281
2271
  * for i=nfree+1,...,n, index(i) are the indices of bound variables
2282
2272
  * On entry after the first iteration, index gives
@@ -2284,7 +2274,7 @@ int formt_(long* m, double* wt, double* sy, double* ss, long* col, double* theta
2284
2274
  * On exit it gives the free variables based on the determination
2285
2275
  * in cauchy using the array iwhere.
2286
2276
  *
2287
- * indx2 is an long array of dimension n
2277
+ * indx2 is an integer array of dimension n
2288
2278
  * On entry indx2 is unspecified.
2289
2279
  * On exit with iter>0, indx2 indicates which variables
2290
2280
  * have changed status since the previous iteration.
@@ -2300,10 +2290,10 @@ int formt_(long* m, double* wt, double* sy, double* ss, long* col, double* theta
2300
2290
  * Ciyou Zhu
2301
2291
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
2302
2292
  */
2303
- int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long* indx2, long* iwhere, long* wrk, long* updatd,
2304
- long* cnstnd, long* iprint, long* iter) {
2305
- long i__1;
2306
- static long i__, k, iact;
2293
+ 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,
2294
+ F77_int* cnstnd, F77_int* iprint, F77_int* iter) {
2295
+ F77_int i__1;
2296
+ static F77_int i__, k, iact;
2307
2297
 
2308
2298
  --iwhere;
2309
2299
  --indx2;
@@ -2322,7 +2312,7 @@ int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long*
2322
2312
  --(*ileave);
2323
2313
  indx2[*ileave] = k;
2324
2314
  if (*iprint >= 100) {
2325
- fprintf(stdout, " Variable %2ld leaves the set of free variables\n", k);
2315
+ fprintf(stdout, " Variable %2" PRIdF77INT " leaves the set of free variables\n", k);
2326
2316
  }
2327
2317
  }
2328
2318
  }
@@ -2333,13 +2323,13 @@ int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long*
2333
2323
  ++(*nenter);
2334
2324
  indx2[*nenter] = k;
2335
2325
  if (*iprint >= 100) {
2336
- fprintf(stdout, " Variable %2ld enters the set of free variables\n", k);
2326
+ fprintf(stdout, " Variable %2" PRIdF77INT " enters the set of free variables\n", k);
2337
2327
  }
2338
2328
  }
2339
2329
  }
2340
2330
  if (*iprint >= 99) {
2341
2331
  i__1 = *n + 1 - *ileave;
2342
- fprintf(stdout, " %2ld variables leave; %2ld variables enter\n", i__1, *nenter);
2332
+ fprintf(stdout, " %2" PRIdF77INT " variables leave; %2" PRIdF77INT " variables enter\n", i__1, *nenter);
2343
2333
  }
2344
2334
  }
2345
2335
  *wrk = *ileave < *n + 1 || *nenter > 0 || *updatd;
@@ -2358,9 +2348,8 @@ int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long*
2358
2348
  }
2359
2349
  if (*iprint >= 99) {
2360
2350
  i__1 = *iter + 1;
2361
- fprintf(stdout, " %2ld variables are free at GCP %3ld\n", *nfree, i__1);
2351
+ fprintf(stdout, " %2" PRIdF77INT " variables are free at GCP %3" PRIdF77INT "\n", *nfree, i__1);
2362
2352
  }
2363
- return 0;
2364
2353
  }
2365
2354
 
2366
2355
  /**
@@ -2369,7 +2358,7 @@ int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long*
2369
2358
  * This subroutine sorts out the least element of t, and puts the
2370
2359
  * remaining elements of t in a heap.
2371
2360
  *
2372
- * n is an long variable.
2361
+ * n is an integer variable.
2373
2362
  * On entry n is the dimension of the arrays t and iorder.
2374
2363
  * On exit n is unchanged.
2375
2364
  *
@@ -2378,12 +2367,12 @@ int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long*
2378
2367
  * On exit t(n) stores the least elements of t, and t(1) to t(n-1)
2379
2368
  * stores the remaining elements in the form of a heap.
2380
2369
  *
2381
- * iorder is an long array of dimension n.
2370
+ * iorder is an integer array of dimension n.
2382
2371
  * On entry iorder(i) is the index of t(i).
2383
2372
  * On exit iorder(i) is still the index of t(i), but iorder may be
2384
2373
  * permuted in accordance with t.
2385
2374
  *
2386
- * iheap is an long variable specifying the task.
2375
+ * iheap is an integer variable specifying the task.
2387
2376
  * On entry iheap should be set as follows:
2388
2377
  * iheap .eq. 0 if t(1) to t(n) is not in the form of a heap,
2389
2378
  * iheap .ne. 0 if otherwise.
@@ -2402,11 +2391,11 @@ int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long*
2402
2391
  * Ciyou Zhu
2403
2392
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
2404
2393
  */
2405
- int hpsolb_(long* n, double* t, long* iorder, long* iheap) {
2406
- long i__1;
2407
- static long i__, j, k;
2394
+ void hpsolb_(F77_int* n, double* t, F77_int* iorder, F77_int* iheap) {
2395
+ F77_int i__1;
2396
+ static F77_int i__, j, k;
2408
2397
  static double out, ddum;
2409
- static long indxin, indxou;
2398
+ static F77_int indxin, indxou;
2410
2399
 
2411
2400
  --iorder;
2412
2401
  --t;
@@ -2462,7 +2451,6 @@ int hpsolb_(long* n, double* t, long* iorder, long* iheap) {
2462
2451
  t[*n] = out;
2463
2452
  iorder[*n] = indxou;
2464
2453
  }
2465
- return 0;
2466
2454
  }
2467
2455
 
2468
2456
  /**
@@ -2487,13 +2475,13 @@ int hpsolb_(long* n, double* t, long* iorder, long* iheap) {
2487
2475
  * Ciyou Zhu
2488
2476
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
2489
2477
  */
2490
- int lnsrlb_(long* n, double* l, double* u, long* nbd, double* x, double* f, double* fold, double* gd, double* gdold, double* g,
2478
+ void lnsrlb_(F77_int* n, double* l, double* u, F77_int* nbd, double* x, double* f, double* fold, double* gd, double* gdold, double* g,
2491
2479
  double* d__, double* r__, double* t, double* z__, double* stp, double* dnorm, double* dtd, double* xstep,
2492
- double* stpmx, long* iter, long* ifun, long* iback, long* nfgv, long* info, char* task, long* boxed, long* cnstnd,
2493
- char* csave, long* isave, double* dsave) {
2494
- long i__1;
2480
+ 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,
2481
+ char* csave, F77_int* isave, double* dsave) {
2482
+ F77_int i__1;
2495
2483
  double d__1;
2496
- static long i__;
2484
+ static F77_int i__;
2497
2485
  static double a1, a2;
2498
2486
 
2499
2487
  --z__;
@@ -2511,7 +2499,7 @@ int lnsrlb_(long* n, double* l, double* u, long* nbd, double* x, double* f, doub
2511
2499
  if (strncmp(task, "FG_LN", 5) == 0) {
2512
2500
  goto L556;
2513
2501
  }
2514
- *dtd = lbfgsb_rb_ddot_(n, &d__[1], &c__1, &d__[1], &c__1);
2502
+ *dtd = ddot_(n, &d__[1], &c__1, &d__[1], &c__1);
2515
2503
  *dnorm = sqrt(*dtd);
2516
2504
  /* Determine the maximum step length. */
2517
2505
  *stpmx = 1e10;
@@ -2548,14 +2536,14 @@ int lnsrlb_(long* n, double* l, double* u, long* nbd, double* x, double* f, doub
2548
2536
  } else {
2549
2537
  *stp = 1.;
2550
2538
  }
2551
- lbfgsb_rb_dcopy_(n, &x[1], &c__1, &t[1], &c__1);
2552
- lbfgsb_rb_dcopy_(n, &g[1], &c__1, &r__[1], &c__1);
2539
+ dcopy_(n, &x[1], &c__1, &t[1], &c__1);
2540
+ dcopy_(n, &g[1], &c__1, &r__[1], &c__1);
2553
2541
  *fold = *f;
2554
2542
  *ifun = 0;
2555
2543
  *iback = 0;
2556
2544
  strcpy(csave, "START");
2557
2545
  L556:
2558
- *gd = lbfgsb_rb_ddot_(n, &g[1], &c__1, &d__[1], &c__1);
2546
+ *gd = ddot_(n, &g[1], &c__1, &d__[1], &c__1);
2559
2547
  if (*ifun == 0) {
2560
2548
  *gdold = *gd;
2561
2549
  if (*gd >= 0.) {
@@ -2563,7 +2551,7 @@ L556:
2563
2551
  /* Line search is impossible. */
2564
2552
  fprintf(stdout, " ascent direction in projection gd = %.8E\n", *gd);
2565
2553
  *info = -4;
2566
- return 0;
2554
+ return;
2567
2555
  }
2568
2556
  }
2569
2557
  dcsrch_(f, gd, stp, &c_b280, &c_b281, &c_b282, &c_b9, stpmx, csave, &isave[1], &dsave[1]);
@@ -2574,7 +2562,7 @@ L556:
2574
2562
  ++(*nfgv);
2575
2563
  *iback = *ifun - 1;
2576
2564
  if (*stp == 1.) {
2577
- lbfgsb_rb_dcopy_(n, &z__[1], &c__1, &x[1], &c__1);
2565
+ dcopy_(n, &z__[1], &c__1, &x[1], &c__1);
2578
2566
  } else {
2579
2567
  i__1 = *n;
2580
2568
  for (i__ = 1; i__ <= i__1; ++i__) {
@@ -2584,7 +2572,6 @@ L556:
2584
2572
  } else {
2585
2573
  strcpy(task, "NEW_X");
2586
2574
  }
2587
- return 0;
2588
2575
  }
2589
2576
 
2590
2577
  /**
@@ -2606,11 +2593,11 @@ L556:
2606
2593
  * Ciyou Zhu
2607
2594
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
2608
2595
  */
2609
- int matupd_(long* n, long* m, double* ws, double* wy, double* sy, double* ss, double* d__, double* r__, long* itail,
2610
- long* iupdat, long* col, long* head, double* theta, double* rr, double* dr, double* stp, double* dtd) {
2611
- long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2;
2612
- static long j;
2613
- static long pointr;
2596
+ void matupd_(F77_int* n, F77_int* m, double* ws, double* wy, double* sy, double* ss, double* d__, double* r__, F77_int* itail,
2597
+ F77_int* iupdat, F77_int* col, F77_int* head, double* theta, double* rr, double* dr, double* stp, double* dtd) {
2598
+ F77_int ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2;
2599
+ static F77_int j;
2600
+ static F77_int pointr;
2614
2601
 
2615
2602
  --r__;
2616
2603
  --d__;
@@ -2637,8 +2624,8 @@ int matupd_(long* n, long* m, double* ws, double* wy, double* sy, double* ss, do
2637
2624
  *head = *head % *m + 1;
2638
2625
  }
2639
2626
  /* Update matrices WS and WY. */
2640
- lbfgsb_rb_dcopy_(n, &d__[1], &c__1, &ws[*itail * ws_dim1 + 1], &c__1);
2641
- lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &wy[*itail * wy_dim1 + 1], &c__1);
2627
+ dcopy_(n, &d__[1], &c__1, &ws[*itail * ws_dim1 + 1], &c__1);
2628
+ dcopy_(n, &r__[1], &c__1, &wy[*itail * wy_dim1 + 1], &c__1);
2642
2629
  /* Set theta=yy/ys. */
2643
2630
  *theta = *rr / *dr;
2644
2631
  /* Form the middle matrix in B. */
@@ -2648,9 +2635,9 @@ int matupd_(long* n, long* m, double* ws, double* wy, double* sy, double* ss, do
2648
2635
  /* move old information */
2649
2636
  i__1 = *col - 1;
2650
2637
  for (j = 1; j <= i__1; ++j) {
2651
- lbfgsb_rb_dcopy_(&j, &ss[(j + 1) * ss_dim1 + 2], &c__1, &ss[j * ss_dim1 + 1], &c__1);
2638
+ dcopy_(&j, &ss[(j + 1) * ss_dim1 + 2], &c__1, &ss[j * ss_dim1 + 1], &c__1);
2652
2639
  i__2 = *col - j;
2653
- lbfgsb_rb_dcopy_(&i__2, &sy[j + 1 + (j + 1) * sy_dim1], &c__1, &sy[j + j * sy_dim1], &c__1);
2640
+ dcopy_(&i__2, &sy[j + 1 + (j + 1) * sy_dim1], &c__1, &sy[j + j * sy_dim1], &c__1);
2654
2641
  }
2655
2642
  }
2656
2643
  /* add new information: the last row of SY */
@@ -2658,8 +2645,8 @@ int matupd_(long* n, long* m, double* ws, double* wy, double* sy, double* ss, do
2658
2645
  pointr = *head;
2659
2646
  i__1 = *col - 1;
2660
2647
  for (j = 1; j <= i__1; ++j) {
2661
- sy[*col + j * sy_dim1] = lbfgsb_rb_ddot_(n, &d__[1], &c__1, &wy[pointr * wy_dim1 + 1], &c__1);
2662
- ss[j + *col * ss_dim1] = lbfgsb_rb_ddot_(n, &ws[pointr * ws_dim1 + 1], &c__1, &d__[1], &c__1);
2648
+ sy[*col + j * sy_dim1] = ddot_(n, &d__[1], &c__1, &wy[pointr * wy_dim1 + 1], &c__1);
2649
+ ss[j + *col * ss_dim1] = ddot_(n, &ws[pointr * ws_dim1 + 1], &c__1, &d__[1], &c__1);
2663
2650
  pointr = pointr % *m + 1;
2664
2651
  }
2665
2652
  if (*stp == 1.) {
@@ -2668,7 +2655,6 @@ int matupd_(long* n, long* m, double* ws, double* wy, double* sy, double* ss, do
2668
2655
  ss[*col + *col * ss_dim1] = *stp * *stp * *dtd;
2669
2656
  }
2670
2657
  sy[*col + *col * sy_dim1] = *dr;
2671
- return 0;
2672
2658
  }
2673
2659
 
2674
2660
  /**
@@ -2687,10 +2673,10 @@ int matupd_(long* n, long* m, double* ws, double* wy, double* sy, double* ss, do
2687
2673
  * Ciyou Zhu
2688
2674
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
2689
2675
  */
2690
- int prn1lb_(long* n, long* m, double* l, double* u, double* x, long* iprint, long* itfile, double* epsmch) {
2691
- long i__1;
2676
+ void prn1lb_(F77_int* n, F77_int* m, double* l, double* u, double* x, F77_int* iprint, F77_int* itfile, double* epsmch) {
2677
+ F77_int i__1;
2692
2678
  FILE* itfptr;
2693
- static long i__;
2679
+ static F77_int i__;
2694
2680
 
2695
2681
  --x;
2696
2682
  --u;
@@ -2700,7 +2686,7 @@ int prn1lb_(long* n, long* m, double* l, double* u, double* x, long* iprint, lon
2700
2686
  fprintf(stdout, "RUNNING THE L-BFGS-B CODE\n\n");
2701
2687
  fprintf(stdout, " * * *\n\n");
2702
2688
  fprintf(stdout, "Machine precision = %.3E\n", *epsmch);
2703
- fprintf(stdout, " N = %3ld M = %2ld\n", *n, *m);
2689
+ fprintf(stdout, " N = %3" PRIdF77INT " M = %2" PRIdF77INT "\n", *n, *m);
2704
2690
  if (*iprint >= 1) {
2705
2691
  itfptr = fopen("iterate.dat", "w");
2706
2692
  fprintf(itfptr, "RUNNING THE L-BFGS-B CODE\n");
@@ -2719,7 +2705,7 @@ int prn1lb_(long* n, long* m, double* l, double* u, double* x, long* iprint, lon
2719
2705
  fprintf(itfptr, "\n");
2720
2706
  fprintf(itfptr, " * * *\n\n");
2721
2707
  fprintf(itfptr, "Machine precision = %.3E\n", *epsmch);
2722
- fprintf(itfptr, " N = %3ld M = %2ld\n", *n, *m);
2708
+ fprintf(itfptr, " N = %3" PRIdF77INT " M = %2" PRIdF77INT "\n", *n, *m);
2723
2709
  fprintf(itfptr, "\n");
2724
2710
  fprintf(itfptr, " it nf nseg nact sub itls stepl tstep projg f\n");
2725
2711
  fclose(itfptr);
@@ -2763,7 +2749,6 @@ int prn1lb_(long* n, long* m, double* l, double* u, double* x, long* iprint, lon
2763
2749
  }
2764
2750
  }
2765
2751
  }
2766
- return 0;
2767
2752
  }
2768
2753
 
2769
2754
  /**
@@ -2781,10 +2766,10 @@ int prn1lb_(long* n, long* m, double* l, double* u, double* x, long* iprint, lon
2781
2766
  * Ciyou Zhu
2782
2767
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
2783
2768
  */
2784
- int prn2lb_(long* n, double* x, double* f, double* g, long* iprint, long* itfile, long* iter, long* nfgv, long* nact,
2785
- double* sbgnrm, long* nseg, char* word, long* iword, long* iback, double* stp, double* xstep) {
2786
- long i__1;
2787
- static long i__, imod;
2769
+ 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,
2770
+ double* sbgnrm, F77_int* nseg, char* word, F77_int* iword, F77_int* iback, double* stp, double* xstep) {
2771
+ F77_int i__1;
2772
+ static F77_int i__, imod;
2788
2773
  FILE* itfptr;
2789
2774
  --g;
2790
2775
  --x;
@@ -2803,8 +2788,8 @@ int prn2lb_(long* n, double* x, double* f, double* g, long* iprint, long* itfile
2803
2788
  strcpy(word, "---");
2804
2789
  }
2805
2790
  if (*iprint >= 99) {
2806
- fprintf(stdout, "LINE SEARCH %ld times; norm of step = %E\n", *iback, *xstep);
2807
- fprintf(stdout, "\nAt iterate%5ld f= %12.5E |proj g|= %12.5E\n", *iter, *f, *sbgnrm);
2791
+ fprintf(stdout, "LINE SEARCH %" PRIdF77INT " times; norm of step = %E\n", *iback, *xstep);
2792
+ fprintf(stdout, "\nAt iterate%5" PRIdF77INT" f= %12.5E |proj g|= %12.5E\n", *iter, *f, *sbgnrm);
2808
2793
 
2809
2794
  if (*iprint > 100) {
2810
2795
  fprintf(stdout, "X =");
@@ -2823,16 +2808,15 @@ int prn2lb_(long* n, double* x, double* f, double* g, long* iprint, long* itfile
2823
2808
  } else if (*iprint > 0) {
2824
2809
  imod = *iter % *iprint;
2825
2810
  if (imod == 0) {
2826
- fprintf(stdout, "\nAt iterate%5ld f= %12.5E |proj g|= %12.5E\n", *iter, *f, *sbgnrm);
2811
+ fprintf(stdout, "\nAt iterate%5" PRIdF77INT " f= %12.5E |proj g|= %12.5E\n", *iter, *f, *sbgnrm);
2827
2812
  }
2828
2813
  }
2829
2814
  if (*iprint >= 1) {
2830
2815
  itfptr = fopen("iterate.dat", "a");
2831
- fprintf(itfptr, " %4ld %4ld %5ld %5ld %3s %4ld %7.1E %7.1E %10.3E %10.3E\n", *iter, *nfgv, *nseg, *nact, word, *iback,
2832
- *stp, *xstep, *sbgnrm, *f);
2816
+ fprintf(itfptr, " %4" PRIdF77INT " %4" PRIdF77INT " %5" PRIdF77INT " %5" PRIdF77INT " %3s %4" PRIdF77INT " %7.1E %7.1E %10.3E %10.3E\n",
2817
+ *iter, *nfgv, *nseg, *nact, word, *iback, *stp, *xstep, *sbgnrm, *f);
2833
2818
  fclose(itfptr);
2834
2819
  }
2835
- return 0;
2836
2820
  }
2837
2821
 
2838
2822
  /**
@@ -2851,12 +2835,12 @@ int prn2lb_(long* n, double* x, double* f, double* g, long* iprint, long* itfile
2851
2835
  * Ciyou Zhu
2852
2836
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
2853
2837
  */
2854
- int prn3lb_(long* n, double* x, double* f, char* task, long* iprint, long* info, long* itfile, long* iter, long* nfgv,
2855
- long* nintol, long* nskip, long* nact, double* sbgnrm, double* time, long* nseg, char* word, long* iback,
2856
- double* stp, double* xstep, long* k, double* cachyt, double* sbtime, double* lnscht) {
2857
- long i__1;
2838
+ 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,
2839
+ F77_int* nintol, F77_int* nskip, F77_int* nact, double* sbgnrm, double* time, F77_int* nseg, char* word, F77_int* iback,
2840
+ double* stp, double* xstep, F77_int* k, double* cachyt, double* sbtime, double* lnscht) {
2841
+ F77_int i__1;
2858
2842
  FILE* itfptr;
2859
- static long i__;
2843
+ static F77_int i__;
2860
2844
 
2861
2845
  --x;
2862
2846
 
@@ -2878,7 +2862,8 @@ int prn3lb_(long* n, double* x, double* f, char* task, long* iprint, long* info,
2878
2862
  fprintf(stdout, " * * *\n");
2879
2863
  fprintf(stdout, "\n");
2880
2864
  fprintf(stdout, " N Tit Tnf Tnint Skip Nact Projg F\n");
2881
- fprintf(stdout, "%5ld %6ld %6ld %6ld %5ld %5ld %10.3E %10.3E\n", *n, *iter, *nfgv, *nintol, *nskip, *nact, *sbgnrm, *f);
2865
+ fprintf(stdout, "%5" PRIdF77INT " %6" PRIdF77INT " %6" PRIdF77INT " %6" PRIdF77INT " %5" PRIdF77INT " %5" PRIdF77INT " %10.3E %10.3E\n",
2866
+ *n, *iter, *nfgv, *nintol, *nskip, *nact, *sbgnrm, *f);
2882
2867
  if (*iprint >= 100) {
2883
2868
  fprintf(stdout, "\n");
2884
2869
  fprintf(stdout, " X =");
@@ -2927,10 +2912,10 @@ L999:
2927
2912
  fprintf(stdout, " may possibly be caused by a bad search direction.\n");
2928
2913
  }
2929
2914
  if (*info == -6) {
2930
- fprintf(stdout, " Input nbd(%2ld) is invalid.\n", *k);
2915
+ fprintf(stdout, " Input nbd(%2" PRIdF77INT ") is invalid.\n", *k);
2931
2916
  }
2932
2917
  if (*info == -7) {
2933
- fprintf(stdout, " l(%2ld) > u(%2ld). No feasible solution.\n", *k, *k);
2918
+ fprintf(stdout, " l(%2" PRIdF77INT ") > u(%2" PRIdF77INT "). No feasible solution.\n", *k, *k);
2934
2919
  }
2935
2920
  if (*info == -8) {
2936
2921
  fprintf(stdout, "\n");
@@ -2957,8 +2942,8 @@ L999:
2957
2942
  if (*iprint >= 1) {
2958
2943
  itfptr = fopen("iterate.dat", "a");
2959
2944
  if (*info == -4 || *info == -9) {
2960
- fprintf(itfptr, " %4ld %4ld %5ld %5ld %3s %4ld %7.1E %7.1E - -\n", *iter, *nfgv, *nseg, *nact, word,
2961
- *iback, *stp, *xstep);
2945
+ fprintf(itfptr, " %4" PRIdF77INT " %4" PRIdF77INT " %5" PRIdF77INT " %5" PRIdF77INT " %3s %4" PRIdF77INT " %7.1E %7.1E - -\n",
2946
+ *iter, *nfgv, *nseg, *nact, word, *iback, *stp, *xstep);
2962
2947
  }
2963
2948
  fprintf(itfptr, "\n");
2964
2949
  fprintf(itfptr, "%s\n", task);
@@ -3006,7 +2991,6 @@ L999:
3006
2991
  fclose(itfptr);
3007
2992
  }
3008
2993
  }
3009
- return 0;
3010
2994
  }
3011
2995
 
3012
2996
  /**
@@ -3024,10 +3008,10 @@ L999:
3024
3008
  * Ciyou Zhu
3025
3009
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
3026
3010
  */
3027
- int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, double* sbgnrm) {
3028
- long i__1;
3011
+ void projgr_(F77_int* n, double* l, double* u, F77_int* nbd, double* x, double* g, double* sbgnrm) {
3012
+ F77_int i__1;
3029
3013
  double d__1, d__2;
3030
- static long i__;
3014
+ static F77_int i__;
3031
3015
  static double gi;
3032
3016
 
3033
3017
  --g;
@@ -3056,7 +3040,6 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3056
3040
  d__1 = *sbgnrm, d__2 = fabs(gi);
3057
3041
  *sbgnrm = d__1 >= d__2 ? d__1 : d__2;
3058
3042
  }
3059
- return 0;
3060
3043
  }
3061
3044
 
3062
3045
  /* **********************************************************************
@@ -3093,7 +3076,7 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3093
3076
  * subject to l<=x<=u
3094
3077
  * x_i=xcp_i for all i in A(xcp)
3095
3078
  *
3096
- * along the subspace unconstrained Newton direction
3079
+ * aF77_int the subspace unconstrained Newton direction
3097
3080
  *
3098
3081
  * d = -(Z'BZ)^(-1) r.
3099
3082
  *
@@ -3110,20 +3093,20 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3110
3093
  * from that described in [1]. One can show that the matrix K is
3111
3094
  * equal to the matrix M^[-1]N in that paper.
3112
3095
  *
3113
- * n is an long variable.
3096
+ * n is an integer variable.
3114
3097
  * On entry n is the dimension of the problem.
3115
3098
  * On exit n is unchanged.
3116
3099
  *
3117
- * m is an long variable.
3100
+ * m is an integer variable.
3118
3101
  * On entry m is the maximum number of variable metric corrections
3119
3102
  * used to define the limited memory matrix.
3120
3103
  * On exit m is unchanged.
3121
3104
  *
3122
- * nsub is an long variable.
3105
+ * nsub is an integer variable.
3123
3106
  * On entry nsub is the number of free variables.
3124
3107
  * On exit nsub is unchanged.
3125
3108
  *
3126
- * ind is an long array of dimension nsub.
3109
+ * ind is an integer array of dimension nsub.
3127
3110
  * On entry ind specifies the coordinate indices of free variables.
3128
3111
  * On exit ind is unchanged.
3129
3112
  *
@@ -3135,7 +3118,7 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3135
3118
  * On entry u is the upper bound of x.
3136
3119
  * On exit u is unchanged.
3137
3120
  *
3138
- * nbd is a long array of dimension n.
3121
+ * nbd is a integer array of dimension n.
3139
3122
  * On entry nbd represents the type of bounds imposed on the
3140
3123
  * variables, and must be specified as follows:
3141
3124
  * nbd(i)=0 if x(i) is unbounded,
@@ -3165,8 +3148,8 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3165
3148
  *
3166
3149
  * ws and wy are double precision arrays;
3167
3150
  * theta is a double precision variable;
3168
- * col is an long variable;
3169
- * head is an long variable.
3151
+ * col is an integer variable;
3152
+ * head is an integer variable.
3170
3153
  * On entry they store the information defining the
3171
3154
  * limited memory BFGS matrix:
3172
3155
  * ws(n,m) stores S, a set of s-vectors;
@@ -3176,7 +3159,7 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3176
3159
  * head is the location of the 1st s- (or y-) vector in S (or Y).
3177
3160
  * On exit they are unchanged.
3178
3161
  *
3179
- * iword is an long variable.
3162
+ * iword is an integer variable.
3180
3163
  * On entry iword is unspecified.
3181
3164
  * On exit iword specifies the status of the subspace solution.
3182
3165
  * iword = 0 if the solution is in the box,
@@ -3194,7 +3177,7 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3194
3177
  * [ 0 I]
3195
3178
  * On exit wn is unchanged.
3196
3179
  *
3197
- * iprint is an long variable that must be set by the user.
3180
+ * iprint is an integer variable that must be set by the user.
3198
3181
  * It controls the frequency and type of output generated:
3199
3182
  * iprint<0 no output is generated;
3200
3183
  * iprint=0 print only one line at the last iteration;
@@ -3205,7 +3188,7 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3205
3188
  * When iprint > 0, the file iterate.dat will be created to
3206
3189
  * summarize the iteration.
3207
3190
  *
3208
- * info is an long variable.
3191
+ * info is an integer variable.
3209
3192
  * On entry info is unspecified.
3210
3193
  * On exit info = 0 for normal return,
3211
3194
  * = nonzero for abnormal return
@@ -3231,18 +3214,18 @@ int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, doub
3231
3214
  * Ciyou Zhu
3232
3215
  * in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal
3233
3216
  */
3234
- int subsm_(long* n, long* m, long* nsub, long* ind, double* l, double* u, long* nbd, double* x, double* d__, double* xp,
3235
- double* ws, double* wy, double* theta, double* xx, double* gg, long* col, long* head, long* iword, double* wv,
3236
- double* wn, long* iprint, long* info) {
3237
- long ws_dim1, ws_offset, wy_dim1, wy_offset, wn_dim1, wn_offset, i__1, i__2;
3217
+ 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,
3218
+ double* ws, double* wy, double* theta, double* xx, double* gg, F77_int* col, F77_int* head, F77_int* iword, double* wv,
3219
+ double* wn, F77_int* iprint, F77_int* info) {
3220
+ F77_int ws_dim1, ws_offset, wy_dim1, wy_offset, wn_dim1, wn_offset, i__1, i__2;
3238
3221
  double d__1, d__2;
3239
- static long i__, j, k, m2;
3222
+ static F77_int i__, j, k, m2;
3240
3223
  static double dk;
3241
- static long js, jy;
3224
+ static F77_int js, jy;
3242
3225
  static double xk;
3243
- static long ibd, col2;
3226
+ static F77_int ibd, col2;
3244
3227
  static double dd_p__, temp1, temp2, alpha;
3245
- static long pointr;
3228
+ static F77_int pointr;
3246
3229
 
3247
3230
  --gg;
3248
3231
  --xx;
@@ -3265,7 +3248,7 @@ int subsm_(long* n, long* m, long* nsub, long* ind, double* l, double* u, long*
3265
3248
  --ind;
3266
3249
 
3267
3250
  if (*nsub <= 0) {
3268
- return 0;
3251
+ return;
3269
3252
  }
3270
3253
  if (*iprint >= 99) {
3271
3254
  fprintf(stdout, "\n----------------SUBSM entered-----------------\n\n");
@@ -3289,17 +3272,17 @@ int subsm_(long* n, long* m, long* nsub, long* ind, double* l, double* u, long*
3289
3272
  /* Compute wv:=K^(-1)wv. */
3290
3273
  m2 = *m << 1;
3291
3274
  col2 = *col << 1;
3292
- lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__11, info);
3275
+ dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__11, info);
3293
3276
  if (*info != 0) {
3294
- return 0;
3277
+ return;
3295
3278
  }
3296
3279
  i__1 = *col;
3297
3280
  for (i__ = 1; i__ <= i__1; ++i__) {
3298
3281
  wv[i__] = -wv[i__];
3299
3282
  }
3300
- lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__1, info);
3283
+ dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__1, info);
3301
3284
  if (*info != 0) {
3302
- return 0;
3285
+ return;
3303
3286
  }
3304
3287
  /* Compute d = (1/theta)d + (1/theta**2)Z'W wv. */
3305
3288
  pointr = *head;
@@ -3314,12 +3297,12 @@ int subsm_(long* n, long* m, long* nsub, long* ind, double* l, double* u, long*
3314
3297
  pointr = pointr % *m + 1;
3315
3298
  }
3316
3299
  d__1 = 1. / *theta;
3317
- lbfgsb_rb_dscal_(nsub, &d__1, &d__[1], &c__1);
3300
+ dscal_(nsub, &d__1, &d__[1], &c__1);
3318
3301
 
3319
3302
  /* ----------------------------------------------------------------- */
3320
3303
  /* Let us try the projection, d is the Newton direction */
3321
3304
  *iword = 0;
3322
- lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xp[1], &c__1);
3305
+ dcopy_(n, &x[1], &c__1, &xp[1], &c__1);
3323
3306
 
3324
3307
  i__1 = *nsub;
3325
3308
  for (i__ = 1; i__ <= i__1; ++i__) {
@@ -3372,7 +3355,7 @@ int subsm_(long* n, long* m, long* nsub, long* ind, double* l, double* u, long*
3372
3355
  dd_p__ += (x[i__] - xx[i__]) * gg[i__];
3373
3356
  }
3374
3357
  if (dd_p__ > 0.) {
3375
- lbfgsb_rb_dcopy_(n, &xp[1], &c__1, &x[1], &c__1);
3358
+ dcopy_(n, &xp[1], &c__1, &x[1], &c__1);
3376
3359
  fprintf(stderr, " Positive dir derivative in projection\n");
3377
3360
  fprintf(stderr, " Using the backtracking step\n");
3378
3361
  } else {
@@ -3431,7 +3414,6 @@ L911:
3431
3414
  if (*iprint >= 99) {
3432
3415
  fprintf(stdout, "\n----------------exit SUBSM --------------------\n\n");
3433
3416
  }
3434
- return 0;
3435
3417
  }
3436
3418
 
3437
3419
  /**
@@ -3548,7 +3530,7 @@ L911:
3548
3530
  * On exit with convergence, a warning or an error, the
3549
3531
  * variable task contains additional information.
3550
3532
  *
3551
- * isave is an long work array of dimension 2.
3533
+ * isave is an integer work array of dimension 2.
3552
3534
  *
3553
3535
  * dsave is a double precision work array of dimension 13.
3554
3536
  *
@@ -3564,14 +3546,14 @@ L911:
3564
3546
  * Argonne National Laboratory and University of Minnesota.
3565
3547
  * Brett M. Averick, Richard G. Carter, and Jorge J. More'.
3566
3548
  */
3567
- int dcsrch_(double* f, double* g, double* stp, double* ftol, double* gtol, double* xtol, double* stpmin, double* stpmax,
3568
- char* task, long* isave, double* dsave) {
3549
+ void dcsrch_(double* f, double* g, double* stp, double* ftol, double* gtol, double* xtol, double* stpmin, double* stpmax,
3550
+ char* task, F77_int* isave, double* dsave) {
3569
3551
 
3570
3552
  double d__1;
3571
3553
  static double fm, gm, fx, fy, gx, gy, fxm, fym, gxm, gym, stx, sty;
3572
- static long stage;
3554
+ static F77_int stage;
3573
3555
  static double finit, ginit, width, ftest, gtest, stmin, stmax, width1;
3574
- static long brackt;
3556
+ static F77_int brackt;
3575
3557
 
3576
3558
  --dsave;
3577
3559
  --isave;
@@ -3604,7 +3586,7 @@ int dcsrch_(double* f, double* g, double* stp, double* ftol, double* gtol, doubl
3604
3586
  }
3605
3587
  /* Exit if there are errors on input. */
3606
3588
  if (strncmp(task, "ERROR", 5) == 0) {
3607
- return 0;
3589
+ return;
3608
3590
  }
3609
3591
  /* Initialize local variables. */
3610
3592
  brackt = FALSE_;
@@ -3748,7 +3730,6 @@ L1000:
3748
3730
  dsave[11] = stmax;
3749
3731
  dsave[12] = width;
3750
3732
  dsave[13] = width1;
3751
- return 0;
3752
3733
  }
3753
3734
 
3754
3735
  /**
@@ -3841,8 +3822,8 @@ L1000:
3841
3822
  * Argonne National Laboratory and University of Minnesota.
3842
3823
  * Brett M. Averick and Jorge J. More'.
3843
3824
  */
3844
- int dcstep_(double* stx, double* fx, double* dx, double* sty, double* fy, double* dy, double* stp, double* fp, double* dp,
3845
- long* brackt, double* stpmin, double* stpmax) {
3825
+ void dcstep_(double* stx, double* fx, double* dx, double* sty, double* fy, double* dy, double* stp, double* fp, double* dp,
3826
+ F77_int* brackt, double* stpmin, double* stpmax) {
3846
3827
  double d__1, d__2, d__3;
3847
3828
  static double p, q, r__, s, sgnd, stpc, stpf, stpq, gamma, theta;
3848
3829
 
@@ -4007,10 +3988,8 @@ int dcstep_(double* stx, double* fx, double* dx, double* sty, double* fy, double
4007
3988
  }
4008
3989
  /* Compute the new step. */
4009
3990
  *stp = stpf;
4010
- return 0;
4011
3991
  }
4012
3992
 
4013
- int timer_(double* ttime) {
3993
+ void timer_(double* ttime) {
4014
3994
  *ttime = (double)clock() / CLOCKS_PER_SEC;
4015
- return 0;
4016
3995
  }