Skip to content

Commit

Permalink
Call printf directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnoel committed Nov 27, 2023
1 parent dfd6a49 commit 37257e8
Show file tree
Hide file tree
Showing 16 changed files with 213 additions and 216 deletions.
30 changes: 15 additions & 15 deletions src/linad99/boundfun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ double dftinv(double x, double fmin, double fmax)
{
if (x <= fmin)
{
ad_printf("variable out of bounds in dftinv\nvariable = %lg", x);
ad_printf("lower bound = %lg", fmin);
ad_printf("upper bound = %lg\n", fmax);
printf("variable out of bounds in dftinv\nvariable = %lg", x);
printf("lower bound = %lg", fmin);
printf("upper bound = %lg\n", fmax);

x=dmin(fmin+.001,fmin+.01*(fmax-fmin));
}
Expand Down Expand Up @@ -392,17 +392,17 @@ double boundpin(double x, double fmin, double fmax)
{
if (x < fmin)
{
ad_printf("variable out of bounds in boundpin: variable = %lg", x);
ad_printf("; min = %lg", fmin);
ad_printf("; max = %lg\n", fmax);
printf("variable out of bounds in boundpin: variable = %lg", x);
printf("; min = %lg", fmin);
printf("; max = %lg\n", fmax);
x=dmin(fmin+.001,fmin+.01*(fmax-fmin));
}

if (x > fmax)
{
ad_printf("variable out of bounds in boundpin: variable = %lg", x);
ad_printf("; min = %lg", fmin);
ad_printf("; max = %lg\n", fmax);
printf("variable out of bounds in boundpin: variable = %lg", x);
printf("; min = %lg", fmin);
printf("; max = %lg\n", fmax);

x=dmax(fmax-.001,fmax-.01*(fmax-fmin));
}
Expand Down Expand Up @@ -451,18 +451,18 @@ double boundpin(const prevariable& xx, double fmin, double fmax)

if (x < fmin)
{
ad_printf("variable out of bounds in boundpin: variable = %lg", x);
ad_printf("; min = %lg", fmin);
ad_printf("; max = %lg\n", fmax);
printf("variable out of bounds in boundpin: variable = %lg", x);
printf("; min = %lg", fmin);
printf("; max = %lg\n", fmax);

x=dmin(fmin+.001,fmin+.01*(fmax-fmin));
}

if (x > fmax)
{
ad_printf("variable out of bounds in boundpin: variable = %lg", x);
ad_printf("; min = %lg", fmin);
ad_printf("; max = %lg\n", fmax);
printf("variable out of bounds in boundpin: variable = %lg", x);
printf("; min = %lg", fmin);
printf("; max = %lg\n", fmax);

x=dmax(fmax-.001,fmax-.01*(fmax-fmin));
}
Expand Down
38 changes: 19 additions & 19 deletions src/linad99/conjprod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ void fmmc::fmin(const double& fret, const dvector& _p, const dvector& _gg)
{
if (iprint>0)
{
ad_printf("Gradient magnitude criterion satisfied\n");
ad_printf("%d variables; iteration %ld; function evaluation %ld\n",
printf("Gradient magnitude criterion satisfied\n");
printf("%d variables; iteration %ld; function evaluation %ld\n",
n, iter, ifn);
ad_printf("Function value %le; maximum gradient component mag %le\n",
printf("Function value %le; maximum gradient component mag %le\n",
fret, max(fabs(gg)) );
fmmdisp(p, gg, n, this->scroll_flag); //fmc);
}
Expand Down Expand Up @@ -254,10 +254,10 @@ void fmmc::fmin(const double& fret, const dvector& _p, const dvector& _gg)
#if !defined (__WAT32__) && !defined (_MSC_VER)
if (!scroll_flag) clrscr();
#endif
ad_printf("Initial statistics: ");
ad_printf("%d variables; iteration %ld; function evaluation %ld\n",
printf("Initial statistics: ");
printf("%d variables; iteration %ld; function evaluation %ld\n",
n, iter, ifn);
ad_printf("Function value %le; maximum gradient component mag %le\n",
printf("Function value %le; maximum gradient component mag %le\n",
fbest, max(fabs(*gbest)) );
fmmdisp(*xbest, *gbest, n, this->scroll_flag); //fmc);
}
Expand Down Expand Up @@ -303,11 +303,11 @@ void fmmc::fmin(const double& fret, const dvector& _p, const dvector& _gg)
{
if (iprint>0)
{
ad_printf("User initiated interrupt\n");
ad_printf(" - final statistics:\n");
ad_printf("%d variables; iteration %ld; function evaluation %ld\n",
printf("User initiated interrupt\n");
printf(" - final statistics:\n");
printf("%d variables; iteration %ld; function evaluation %ld\n",
n, iter, ifn);
ad_printf("Function value %le; maximum gradient component mag %le\n",
printf("Function value %le; maximum gradient component mag %le\n",
fbest, max(fabs(*gbest)) );
fmmdisp(*xbest, *gbest, n, this->scroll_flag); //fmc);
}
Expand Down Expand Up @@ -359,9 +359,9 @@ void fmmc::fmin(const double& fret, const dvector& _p, const dvector& _gg)
{
if (iprint>0)
{
ad_printf("%d variables; iteration %ld; function evaluation %ld\n",
printf("%d variables; iteration %ld; function evaluation %ld\n",
n, iter, ifn);
ad_printf("Function value %le; maximum gradient component mag %le\n",
printf("Function value %le; maximum gradient component mag %le\n",
fbest, max(fabs(*gbest)) );
fmmdisp(*xbest, *gbest, n, this->scroll_flag); //fmc);
}
Expand Down Expand Up @@ -411,10 +411,10 @@ void fmmc::fmin(const double& fret, const dvector& _p, const dvector& _gg)
{
if (iprint>0)
{
ad_printf("Maximum number of function evaluations exceeded\n");
ad_printf("%d variables; iteration %ld; function evaluation %ld\n",
printf("Maximum number of function evaluations exceeded\n");
printf("%d variables; iteration %ld; function evaluation %ld\n",
n, iter, ifn);
ad_printf("Function value %le; maximum gradient component mag %le\n",
printf("Function value %le; maximum gradient component mag %le\n",
fbest, max(fabs(*gbest)) );
fmmdisp(*xbest, *gbest, n, this->scroll_flag); //fmc);
}
Expand All @@ -431,10 +431,10 @@ void fmmc::fmin(const double& fret, const dvector& _p, const dvector& _gg)
#if !defined (__WAT32__) && !defined (_MSC_VER)
if (!scroll_flag) clrscr();
#endif
ad_printf("Intermediate statistics: ");
ad_printf("%d variables; iteration %ld; function evaluation %ld\n",
printf("Intermediate statistics: ");
printf("%d variables; iteration %ld; function evaluation %ld\n",
n, iter, ifn);
ad_printf("Function value %le; maximum gradient component mag %le\n",
printf("Function value %le; maximum gradient component mag %le\n",
fbest, max(fabs(*gbest)) );
fmmdisp(*xbest, *gbest, n, this->scroll_flag); //fmc);
}
Expand Down Expand Up @@ -1067,7 +1067,7 @@ void derch(const double& _f, const dvector& _x, const dvector& _gg, int n,
f = fsave;
x(i)=xsave;
g2=(f1-f2)/(2.*s);
ad_printf(" %12.5e %12.5e %12.5e %12.5e ; %5d \n",
printf(" %12.5e %12.5e %12.5e %12.5e ; %5d \n",
x(i), f, g(i), g2, i);
} // for loop
} // while (j > 0)
Expand Down
2 changes: 1 addition & 1 deletion src/linad99/derch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void derch(const double& _f, const independent_variables & _x,
<< " " << setw(12) << perr
<< endl;
}
ad_printf(" %12.5e %12.5e %12.5e %12.5e ; %5d \n",
printf(" %12.5e %12.5e %12.5e %12.5e ; %5d \n",
x(i), f, g(i), g2, i);
fflush(stdout);
}
Expand Down
2 changes: 1 addition & 1 deletion src/linad99/df_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ DF_FILE::DF_FILE(const size_t nbytes, const unsigned int id)
#endif
if (file_ptr == -1)
{
ad_printf("Error opening temporary gradient"
printf("Error opening temporary gradient"
" file %s\n", cmpdif_file_name );
ad_exit(1);
}
Expand Down
28 changes: 14 additions & 14 deletions src/linad99/fmmtr1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ void fmmt1::fmin(const double& _f, const dvector & _x, const dvector& _g)
label7003:
if (iprint!=0)
{
ad_printf("%d variables; iteration %ld; function evaluation %ld\n",
printf("%d variables; iteration %ld; function evaluation %ld\n",
n, itn, ifn);
ad_printf("Function value %12.4le; maximum gradient component mag %12.4le\n",
printf("Function value %12.4le; maximum gradient component mag %12.4le\n",
f, gmax);
}
/*label7002:*/
Expand Down Expand Up @@ -365,7 +365,7 @@ label21 :
{
if (iprint>0)
{
ad_printf(" ic > imax in fminim is answer attained ?\n" );
printf(" ic > imax in fminim is answer attained ?\n" );
fmmdisp(x, g, n, this->scroll_flag,noprintx);
}
ihflag=1;
Expand Down Expand Up @@ -475,13 +475,13 @@ label21 :
if (iprint>0)
{
if (ihang == 1)
ad_printf("Function minimizer not making progress ... is minimum attained?\n");
printf("Function minimizer not making progress ... is minimum attained?\n");
}
if(iexit == 2)
{
if (iprint>0)
{
ad_printf("*** grad transpose times delta x greater >= 0\n"
printf("*** grad transpose times delta x greater >= 0\n"
" --- convergence critera may be too strict\n");
ireturn=-1;
}
Expand All @@ -493,21 +493,21 @@ label21 :
{
if (iprint>0)
{
ad_printf("Maximum number of function evaluations exceeded");
printf("Maximum number of function evaluations exceeded");
}
}
if (iprint>0)
{
if (quit_flag == 'Q' && use_control_c)
ad_printf("User initiated interrupt");
printf("User initiated interrupt");
}
if(iprint == 0) goto label777;
ad_printf(" - final statistics:\n");
ad_printf("%d variables; iteration %ld; function evaluation %ld\n",
printf(" - final statistics:\n");
printf("%d variables; iteration %ld; function evaluation %ld\n",
n, itn, ifn);
ad_printf("Function value %12.4le; maximum gradient component mag %12.4le\n",
printf("Function value %12.4le; maximum gradient component mag %12.4le\n",
f, gmax);
ad_printf("Exit code = %ld; converg criter %12.4le\n",iexit,crit);
printf("Exit code = %ld; converg criter %12.4le\n",iexit,crit);

fmmdisp(x, g, n, this->scroll_flag,noprintx);
label777:
Expand All @@ -528,7 +528,7 @@ label21 :
# if defined (_MSC_VER) && !defined (__WAT32__)
if (!scroll_flag) clrscr();
#endif
ad_printf("Initial statistics: ");
printf("Initial statistics: ");
}
goto label7003;
label7010:
Expand All @@ -537,14 +537,14 @@ label21 :
# if defined (_MSC_VER) && !defined (__WAT32__)
if (!scroll_flag) clrscr();
#endif
ad_printf("Intermediate statistics: ");
printf("Intermediate statistics: ");
}
llog=0;
goto label7003;
label7020:
if (iprint>0)
{
ad_printf("*** hessian not positive definite\n");
printf("*** hessian not positive definite\n");
}
#ifdef __ZTC__
if (ireturn <= 0)
Expand Down
7 changes: 2 additions & 5 deletions src/linad99/fvar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9488,6 +9488,7 @@ dmatrix make_dmatrix(dcompressed_triplet & M);
int norm2(const ivector &);
int sumsq(const ivector & v);

/*
template <class ... Args>
int ad_printf( FILE* stream, const char* format, Args ... args )
{
Expand All @@ -9496,13 +9497,9 @@ int ad_printf( FILE* stream, const char* format, Args ... args )
template <class ... Args>
int ad_printf( const char* format, Args ... args )
{
/*
int result = printf(format, args...);
fflush(stdout);
return result;
*/
return printf(format, args...);
}
*/
std::ostream& get_output_stream();

dvariable dtweedie(const double y, dvariable& mu, dvariable& phi, dvariable& p, const bool use_log);
Expand Down
8 changes: 4 additions & 4 deletions src/linad99/fvar_arr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ void gradient_structure::make_indvar_list(const dvar_vector& t)
unsigned int size = (unsigned int)(max - min + 1);
if (size > gradient_structure::MAX_NVAR_OFFSET)
{
ad_printf("Current maximum number of independent variables is %d\n",
printf("Current maximum number of independent variables is %d\n",
gradient_structure::MAX_NVAR_OFFSET);
ad_printf(" You need to increase the global variable "
printf(" You need to increase the global variable "
"MAX_NVAR_OFFSET to %d\n", size);
ad_printf(" This can be done by putting the line\n"
printf(" This can be done by putting the line\n"
" gradient_structure::set_MAX_NVAR_OFFSET(%d);\n", size);
ad_printf(" before the declaration of the gradient_structure object.\n"
printf(" before the declaration of the gradient_structure object.\n"
" or the command line option -mno %d\n", size);
/*
cerr << "Current maximum number of independent variables is "
Expand Down
2 changes: 1 addition & 1 deletion src/linad99/gradstak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ void grad_stack::create_gradfile()

if (_GRADFILE_PTR1 == -1)
{
ad_printf("Error opening temporary gradient file"
printf("Error opening temporary gradient file"
" %s\n",gradfile_name1);
ad_exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions src/linad99/gradstrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ extern "C"{

void spdll_exit(int ierr)
{
ad_printf(" Exception -- error code %d\n",ierr);
ad_printf(" Pause");
printf(" Exception -- error code %d\n",ierr);
printf(" Pause");
//adwait(4.0);
#if defined(USE_EXCEPTIONS)
throw spdll_exception(ierr);
Expand Down
Loading

0 comments on commit 37257e8

Please sign in to comment.