function b = r8to_mv ( n, a, x )

%*****************************************************************************80
%
%% R8TO_MV multiplies a R8TO matrix times a vector.
%
%  Discussion:
%
%    The R8TO storage format is used for a Toeplitz matrix, which is constant
%    along diagonals.  Thus, in an N by N Toeplitz matrix, there are at most 
%    2*N-1 distinct entries.  The format stores the N elements of the first
%    row, followed by the N-1 elements of the first column (skipping the
%    entry in the first row).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 August 2015
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the order of the matrix.
%
%    Input, real A(2*N-1), the R8TO matrix.
%
%    Input, real X(N), the vector to be multiplied by A.
%
%    Output, real B(N), the product A * x.
%
  b = zeros ( n, 1 );

  for i = 1 : n
    b(1) = b(1) + a(i) * x(i);
  end

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

  return
end
