function b = r8ge_to_r8po ( n, a )

%*****************************************************************************80
%
%% r8ge_to_r8po() copies an R8GE matrix to an R8PO matrix.
%
%  Discussion:
%
%    The R8PO format assumes the matrix is square and symmetric; it is also 
%    typically assumed that the matrix is positive definite.  These are not
%    required here.  The copied R8PO matrix simply zeros out the lower triangle
%    of the R8GE matrix.
%
%    The R8GE storage format is used for a general M by N matrix.  A storage 
%    space is made for each entry.  The two dimensional logical
%    array can be thought of as a vector of M*N entries, starting with
%    the M entries in the column 1, then the M entries in column 2
%    and so on.  Considered as a vector, the entry A(I,J) is then stored
%    in vector location I+(J-1)*M.
%
%    The R8PO storage format is used for a symmetric positive definite 
%    matrix and its inverse.  (The Cholesky factor of an R8PO matrix is an
%    upper triangular matrix, so it will be in R8GE storage format.)
%
%    Only the diagonal and upper triangle of the square array are used.
%    This same storage scheme is used when the matrix is factored by
%    R8PO_FA, or inverted by R8PO_INVERSE.  For clarity, the lower triangle
%    is set to zero.
%
%    R8PO storage is used by LINPACK and LAPACK.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 August 2015
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the order of the matrix.
%
%    real A(N,N), the R8GE matrix.
%
%  Output:
%
%    real B(N,N), the R8PO matrix.
%
  b = zeros ( n, n );

  for i = 1 : n
    for j = 1 : n
      if ( i <= j )
        b(i,j) = a(i,j);
      end
    end
  end

  return
end
