function a = r8mat_vand2 ( m, n, x )

%*****************************************************************************80
%
%% R8MAT_VAND2 returns the N by N row Vandermonde matrix A.
%
%  Discussion:
%
%    The row Vandermonde matrix returned by this routine reads "across"
%    rather than down.  In particular, each row begins with a 1, followed by
%    some value X, followed by successive powers of X.
%
%  Formula:
%
%    A(I,J) = X(I)^(J-1)
%
%  Properties:
%
%    A is nonsingular if, and only if, the X values are distinct.
%
%    The determinant of A is
%
%      det(A) = product ( 2 <= I <= N ) (
%        product ( 1 <= J <= I-1 ) ( ( X(I) - X(J) ) ) ).
%
%    The matrix A is generally ill-conditioned.
%
%  Example:
%
%    N = 5, X = (2, 3, 4, 5, 6)
%
%    1 2  4   8   16
%    1 3  9  27   81
%    1 4 16  64  256
%    1 5 25 125  625
%    1 6 36 216 1296
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 April 2005
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the order of the matrix desired.
%
%    real X(M), the values that define A.
%
%  Output:
%
%    real A(M,N), the M by N row Vandermonde matrix.
%
  a = zeros ( m, n );
  
  for i = 1 : m
    a(i,1) = 1.0;
    for j = 2 : n
      a(i,j) = a(i,j-1) * x(i);
    end
  end

  return
end
