function x = r8mat_ut_solve ( n, a, b )

%*****************************************************************************80
%
%% R8MAT_UT_SOLVE solves a transposed upper triangular linear system.
%
%  Discussion:
%
%    An R8MAT is an MxN array of R8's, stored by (I,J) -> [I+J*M].
%
%    Given the upper triangular matrix A, the linear system to be solved is:
%
%      A' * x = b
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    28 July 2015
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the number of rows and columns
%    of the matrix.
%
%    Input, real A(N,N), the N by N upper triangular matrix.
%
%    Input, real B(N,1), the right hand side of the linear system.
%
%    Output, real X(N,1), the solution of the linear system.
%
  b = b(:);
%
%  Solve U' * x = b.
%
  x = zeros ( n, 1 );

  for i = 1 : n
    x(i,1) = b(i,1);
    for j = 1 : i - 1
      x(i,1) = x(i,1) - a(j,i) * x(j,1);
    end
    x(i,1) = x(i,1) / a(i,i);
  end

  return
end
