function print2 ( n, x, prin, fx, nf, nl )

%*****************************************************************************80
%
%% PRINT2 prints certain data about the progress of the iteration.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    31 July 2016
%
%  Author:
%
%    Original FORTRAN77 version by Richard Brent.
%    MATLAB version by John Burkardt.
%
%  Reference:
%
%    Richard Brent,
%    Algorithms for Minimization with Derivatives,
%    Prentice Hall, 1973,
%    Reprinted by Dover, 2002.
%
%  Parameters:
%
%    Input, integer N, the number of variables.
%
%    Input, real X(N), the current estimate of the minimizer.
%
%    Input, integer PRIN, the user-specifed print level.
%    0, nothing is printed.
%    1, F is printed after every n+1 or n+2 linear minimizations.
%       final X is printed, but intermediate X is printed only
%       if N is at most 4.
%    2, the scale factors and the principal values of the approximating
%       quadratic form are also printed.
%    3, X is also printed after every few linear minimizations.
%    4, the principal vectors of the approximating quadratic form are
%       also printed.
%
%    Input, real FX, the smallest value of F(X) found so far.
%
%    Input, integer NF, the number of function evaluations.
%
%    Input, integer NL, the number of linear searches.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Linear searches      %d\n', nl );
  fprintf ( 1, '  Function evaluations %d\n', nf );
  fprintf ( 1, '  The function value FX = %g\n', fx );

  if ( n <= 4 || 2 < prin )
    r8vec_print ( n, x, '  X:' );
  end

  return
end
