function p00_gdif_test ( )

%*****************************************************************************80
%
%% p00_gdif_test() compares the exact and approximate gradient vectors.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    17 October 2011
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'p00_gdif_test():\n' );
  fprintf ( 1, '  p00_gdif() estimates the gradient vector G\n' );
  fprintf ( 1, '  with a finite difference estimate GDIF\n' );
%
%  Get the number of problems.
%
  problem_num = p00_problem_num ( );

  for problem = 1 : problem_num

    if ( problem == 25 )
      p = 0.0;
      p25_p_set ( p );
    end

    if ( problem == 36 )
      p36_p_init ( );
    end

    title = p00_title ( problem );

    n = p00_n ( problem );

    n_min = n;

    if ( n < 0 )
      n_min = abs ( n_min );
      n = max ( n_min, 4 );
    end

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Problem %d:  "%s"\n', problem, title );

    if ( true )

      x = rand ( n, 1 );

    else

      x = p00_start ( problem, n );

    end

    g = p00_g ( problem, n, x );

    g_dif = p00_gdif ( problem, n, x );

    r8vec_transpose_print ( n, x, '  X:' );
    r8vec_transpose_print ( n, g, '  G:' );
    r8vec_transpose_print ( n, g_dif, '  GDIF:' );

    if ( problem == 25 )

      p = 1.0;
      p25_p_set ( p );

      fprintf ( 1, '\n' );
      fprintf ( 1, '  Repeat problem with P = %f\n', p );

      x = p00_start ( problem, n );

      g = p00_g ( problem, n, x );

      g_dif = p00_gdif ( problem, n, x );

      r8vec_transpose_print ( n, x, '  X:' );
      r8vec_transpose_print ( n, g, '  G:' );
      r8vec_transpose_print ( n, g_dif, '  GDIF:' );

    end

  end

  return
end
