function b = r83_mtv ( m, n, a, x )

%*****************************************************************************80
%
%% r83_mtv() multiplies a vector by an R83 matrix.
%
%  Discussion:
%
%    The R83 storage format is used for a tridiagonal matrix.
%    The superdiagonal is stored in entries (1,2:min(M+1,N)).
%    The diagonal in entries (2,1:min(M,N)).
%    The subdiagonal in (3,min(M-1,N)). 
%    R8GE A(I,J) = R83 A(I-J+2,J).  
%
%    The original matrix is "collapsed" vertically into the array.
%
%  Example:
%
%    An R83 matrix of order 3x5 would be stored:
%
%       *  A12 A23 A34  *
%      A11 A22 A33  *   *
%      A21 A32  *   *   *
%
%    An R83 matrix of order 5x5 would be stored:
%
%       *  A12 A23 A34 A45
%      A11 A22 A33 A44 A55
%      A21 A32 A43 A54  *
%
%    An R83 matrix of order 5x3 would be stored:
%
%       *  A12 A23
%      A11 A22 A33
%      A21 A32 A43
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    27 August 2015
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the order of the linear system.
%
%    real A(3,N), the R83 MxN matrix.
%
%    real X(M,1), the vector to be multiplied by A'.
%
%  Output:
%
%    real B(N,1), the product A' * x.
%
  b = zeros ( n, 1 );
%
%  Force X to be a column vector.
%
  x = x ( : );
%
%  Find each nonzero A(I,J), multiply by X(I), add to B(J).
%
  for j = 1 : n
    for i = max ( 1, j - 1 ) : min ( m, j + 1 )
      b(j) = b(j) + x(i) * a(i-j+2,j);
    end
  end

  return
end
