function lsqnonlin_test ( )

%*****************************************************************************80
%
%% lsqnonlin_test() tests lsqnonlin() on the test problems.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    03 March 2026
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'lsqnonlin_test():\n' );
  fprintf ( 1, '  lsgnonlin() seeks an n-vector x* which minimizes\n' );
  fprintf ( 1, '  the L2 norm of m functions f(x*).\n' );
  fprintf ( 1, '  Use x0=p00_start(), fx0=p00_f(x0);\n' );
  fprintf ( 1, '  Compare norms of x0 and x*, fx0 and fx*.\n' );
%
%  Get the number of tests.
%
  test_num = p00_test_num ( );

  for test = 1 : test_num

    [ m, n ] = p00_mn ( test );

    if ( test == 11 )
      m = 31;
      n = 5;
    elseif ( 0 < m && 0 < n )
      
    elseif ( m < 0 )
      if ( 0 < n )
        m = n + 2;
      elseif ( -10 == n )
        m = 5;
        n = 5;
      else
        m = 5;
        n = 3;
      end
    end

    title = p00_title ( test );
    x0 = p00_start ( test, n );
    fx0 = p00_f ( test, m, n, x0 );
    x = lsqnonlin ( @(x)p00_f(test,m,n,x), x0 );
    fx = p00_f ( test, m, n, x );

    fprintf ( 1, '\n' );
    fprintf ( 1, '  %d "%s"\n', test, title );
    fprintf ( 1, '  m = %d, n = %d\n', m, n );
    fprintf ( 1, '  ||x0||  = %g, ||x*||  = %g\n', norm ( x0 ),  norm ( x ) );
    fprintf ( 1, '  ||fx0|| = %g, ||fx*|| = %g\n', norm ( fx0 ), norm ( fx ) );
    for i = 1 : n
      fprintf ( 1, '  %20.16g\n', x(i) );
    end

  end

  return
end

