From 0cadc70ecce6939b7d9d54cfb39faecab2a9c0a1 Mon Sep 17 00:00:00 2001 From: Francesco Iannelli <54247008+frjnn@users.noreply.github.com> Date: Sat, 18 Jun 2022 09:07:32 +0200 Subject: [PATCH 1/3] Move prints behind `iprint` check --- src/linesearch.c | 4 +++- src/subalgorithms.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/linesearch.c b/src/linesearch.c index 7c94c72..c47f333 100644 --- a/src/linesearch.c +++ b/src/linesearch.c @@ -125,7 +125,9 @@ static integer c__1 = 1; if (*gd >= 0.) { /* the directional derivative >=0. */ /* Line search is impossible. */ - printf("ascend direction in projection gd = %.2e\n", *gd ); + if (*iprint >= 0) { + printf("ascend direction in projection gd = %.2e\n", *gd ); + } *info = -4; return 0; } diff --git a/src/subalgorithms.c b/src/subalgorithms.c index e71d32f..fa120eb 100644 --- a/src/subalgorithms.c +++ b/src/subalgorithms.c @@ -2161,8 +2161,10 @@ static integer c__11 = 11; } if (dd_p__ > 0.) { dcopy(n, &xp[1], &c__1, &x[1], &c__1); - printf("Positive dir derivative in projection \n"); - printf("Using the backtracking step\n"); + if (*iprint >= 0) { + printf("Positive dir derivative in projection \n"); + printf("Using the backtracking step\n"); + } } else { goto L911; } From a17dac13269172e2a14be7f9645a289f0c1e8834 Mon Sep 17 00:00:00 2001 From: frjnn Date: Sat, 18 Jun 2022 21:04:03 +0200 Subject: [PATCH 2/3] Pass `iprint` to `lnsrlb` and change verbosity to 99 in `subsm` --- src/lbfgsb.c | 2 +- src/lbfgsb.h | 2 +- src/linesearch.c | 2 +- src/subalgorithms.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lbfgsb.c b/src/lbfgsb.c index 046847c..fe9374c 100644 --- a/src/lbfgsb.c +++ b/src/lbfgsb.c @@ -876,7 +876,7 @@ static double c_b7 = 0.; 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]); /* (ftnlen)60, (ftnlen)60); */ + csave, &isave[22], iprint, &dsave[17]); /* (ftnlen)60, (ftnlen)60); */ if (info != 0 || iback >= 20) { /* restore the previous iterate. */ dcopy(n, &t[1], &c__1, &x[1], &c__1); diff --git a/src/lbfgsb.h b/src/lbfgsb.h index 750b5bc..a0d95d0 100644 --- a/src/lbfgsb.h +++ b/src/lbfgsb.h @@ -325,7 +325,7 @@ extern int lnsrlb(integer *n, double *l, double *u, double *dnorm, double *dtd, double *xstep, double * stpmx, integer *iter, integer *ifun, integer *iback, integer *nfgv, integer *info, integer *task, logical *boxed, logical *cnstnd, integer * - csave, integer *isave, double *dsave); /* ftnlen task_len, ftnlen + csave, integer *isave, integer* iprint, double *dsave); /* ftnlen task_len, ftnlen csave_len); */ #define projgr FORTRAN_WRAPPER(projgr) extern int projgr(integer *, double *, double *, diff --git a/src/linesearch.c b/src/linesearch.c index c47f333..641d058 100644 --- a/src/linesearch.c +++ b/src/linesearch.c @@ -9,7 +9,7 @@ static integer c__1 = 1; double *dnorm, double *dtd, double *xstep, double * stpmx, integer *iter, integer *ifun, integer *iback, integer *nfgv, integer *info, integer *task, logical *boxed, logical *cnstnd, integer * - csave, integer *isave, double *dsave) /* ftnlen task_len, ftnlen + csave, integer *isave, integer* iprint, double *dsave) /* ftnlen task_len, ftnlen csave_len) */ { /* diff --git a/src/subalgorithms.c b/src/subalgorithms.c index fa120eb..e16f884 100644 --- a/src/subalgorithms.c +++ b/src/subalgorithms.c @@ -2161,7 +2161,7 @@ static integer c__11 = 11; } if (dd_p__ > 0.) { dcopy(n, &xp[1], &c__1, &x[1], &c__1); - if (*iprint >= 0) { + if (*iprint >= 99) { printf("Positive dir derivative in projection \n"); printf("Using the backtracking step\n"); } From 57578ad8ca9ed3638ad7a6f64dcf74cd4c568e98 Mon Sep 17 00:00:00 2001 From: frjnn Date: Sat, 18 Jun 2022 21:19:50 +0200 Subject: [PATCH 3/3] Fix pointer placements --- src/lbfgsb.h | 2 +- src/linesearch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lbfgsb.h b/src/lbfgsb.h index a0d95d0..85cd2ae 100644 --- a/src/lbfgsb.h +++ b/src/lbfgsb.h @@ -325,7 +325,7 @@ extern int lnsrlb(integer *n, double *l, double *u, double *dnorm, double *dtd, double *xstep, double * stpmx, integer *iter, integer *ifun, integer *iback, integer *nfgv, integer *info, integer *task, logical *boxed, logical *cnstnd, integer * - csave, integer *isave, integer* iprint, double *dsave); /* ftnlen task_len, ftnlen + csave, integer *isave, integer *iprint, double *dsave); /* ftnlen task_len, ftnlen csave_len); */ #define projgr FORTRAN_WRAPPER(projgr) extern int projgr(integer *, double *, double *, diff --git a/src/linesearch.c b/src/linesearch.c index 641d058..ed73293 100644 --- a/src/linesearch.c +++ b/src/linesearch.c @@ -9,7 +9,7 @@ static integer c__1 = 1; double *dnorm, double *dtd, double *xstep, double * stpmx, integer *iter, integer *ifun, integer *iback, integer *nfgv, integer *info, integer *task, logical *boxed, logical *cnstnd, integer * - csave, integer *isave, integer* iprint, double *dsave) /* ftnlen task_len, ftnlen + csave, integer *isave, integer *iprint, double *dsave) /* ftnlen task_len, ftnlen csave_len) */ { /*