function U = mgs1 ( A )

%*****************************************************************************80
%
%% mgs1() applies the modified Gram-Schmidt algorithm with no normalization.
%
%  Discussion:
%
%    The output of this function will be a set of orthogonal vectors,
%    such that U(:,i) dot U(:,j) is zero if i is not equal to j.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 December 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A(M,N), a matrix of N vectors.
%
%  Output:
%
%    real U(M,N), a matrix with orthogonal columns.
%
  [ m, n ] = size ( A );

  U = A;

  for j = 1 : n

    v = U(:,j);

    for j2 = j + 1 : n
      v2 = U(:,j2);
      p = v' * v2 / ( v' * v );
      v2 = v2 - p * v;
      U(:,j2) = v2;
    end
 
  end

  return
end
