function y = r8crs_mv ( n, nz, row, col, val, x )

%*****************************************************************************80
%
%% r8crs_mv() multiplies an R8CRS matrix times a vector.
%
%  Discussion:
%
%    The R8CRS storage format stores the nonzero entries of row I in 
%    entries ROW(I) through ROW(I+1)-1 of VAL.  
%    COL(J) records the column index of the entry in VAL(J).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the order of the matrix.
%
%    integer NZ: the number of nonzero elements.
%
%    integer ROW(N+1): the nonzero offdiagonal elements 
%    of row I of A are contained in A(ROW(I)) through A(ROW(I+1)-1).
%
%    integer COL(NZ): the column indices of the nonzero elements of A.
%
%    real VAL(NZ): the nonzero elements of A.
%
%    real X(N): the vector to be multiplied by A.
%
%  Output:
%
%    real Y(N): the product A * X.
%  
  y = zeros ( n, 1 );

  for i = 1 : n
    for k = row(i) : row(i+1)-1
      j = col(k);
      y(i) = y(i) + val(k) * x(j);
    end
  end

  return
end
