function r8ge_np_trm_test ( )

%*****************************************************************************80
%
%% R8GE_NP_TRM_TEST tests R8GE_NP_TRM.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  m = 10;
  n = m;
  nrhs = 1;

  seed = 123456789;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8GE_NP_TRM_TEST\n' );
  fprintf ( 1, '  R8GE_NP_TRM computes A*x after A has been factored by R8GE_NP_TRF.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Matrix rows M =    %d\n', m );
  fprintf ( 1, '  Matrix columns N = %d\n', n );
%
%  Set the matrix.
%
  [ a, seed ] = r8ge_random ( m, n, seed );
%
%  Set the desired solution.
%
  x(1:n) = 1.0;
%
%  Compute the corresponding right hand side.
%
  b = r8ge_mv ( m, n, a, x );
%
%  Factor the matrix.
%
  [ a_lu, info ] = r8ge_np_trf ( m, n, a );

  if ( info ~= 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'R8GE_NP_TRM_TEST - Fatal error!\n' );
    fprintf ( 1, '  R8GE_NP_TRF declares the matrix is singular!\n' );
    fprintf ( 1, '  The value of INFO is %d\n', info );
    return
  end
%
%  Solve the linear system.
%
  b_mat = r8vec_to_r8ge ( n, nrhs, b );
  [ x_mat, info ] = r8ge_np_trs ( n, nrhs, 'N', a_lu, b_mat );
  x = r8ge_to_r8vec ( n, nrhs, x_mat );
   
  if ( info ~= 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'R8GE_NP_TRM_TEST - Fatal error!\n' );
    fprintf ( 1, '  R8GE_TRS returned an error condition!\n' );
    fprintf ( 1, '  The value of INFO is %d\n', info );
    return
  end

  r8vec_print ( n, x, '  Solution:' );
%
%  Set the desired solution.
%
  x = r8vec_indicator1 ( n );
%
%  Compute the corresponding right hand side.
%
  job = 0;
  b = r8ge_np_trm ( m, n, a_lu, x, job );
%
%  Solve the system
%
  b_mat = r8vec_to_r8ge ( n, nrhs, b );
  [ x_mat, info ] = r8ge_np_trs ( n, nrhs, 'N', a_lu, b_mat );
  x = r8ge_to_r8vec ( n, nrhs, x_mat );

  if ( info ~= 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'R8GE_NP_TRM_TEST - Fatal error!\n' );
    fprintf ( 1, '  R8GE_TRS returned an error condition!\n' );
    fprintf ( 1, '  The value of INFO is %d\n', info );
    return
  end

  r8vec_print ( n, x, '  Solution:' );
%
%  Set the desired solution.
%
  x = r8vec_indicator1 ( n );
%
%  Compute the corresponding right hand side.
%
  job = 1;
  b = r8ge_np_trm ( m, n, a_lu, x, job );
%
%  Solve the system.
%
  b_mat = r8vec_to_r8ge ( n, nrhs, b );
  [ x_mat, info ] = r8ge_np_trs ( n, nrhs, 'T', a_lu, b_mat );
  x = r8ge_to_r8vec ( n, nrhs, x_mat );

  if ( info ~= 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'R8GE_NP_TRM_TEST - Fatal error!\n' );
    fprintf ( 1, '  R8GE_TRS returned an error condition!\n' );
    fprintf ( 1, '  The value of INFO is %d\n', info );
    return
  end

  r8vec_print ( n, x, '  Solution of transposed system:' );

  return
end
