function r = r8sd_resid ( m, n, ndiag, offset, a, x, b )

%*****************************************************************************80
%
%% r8sd_resid() computes the residual R = B-A*X for R8SD matrices.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    02 June 2014
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the number of rows of the matrix.
%    M must be positive.
%
%    integer N, the number of columns of the matrix.
%    N must be positive.
%
%    integer NDIAG, the number of diagonals that are stored.
%    NDIAG must be at least 1 and no more than N.
%
%    integer OFFSET(NDIAG), the offsets for the diagonal
%    storage.
%
%    real A(N,NDIAG), the R8SD matrix.
%
%    real X(N), the vector to be multiplied by A.
%
%    real B(M), the desired result A * x.
%
%  Output:
%
%    real R(M), the residual R = B - A * X.
%
  r = r8sd_mv ( m, n, ndiag, offset, a, x );

  r(1:m,1) = b(1:m,1) - r(1:m,1);

  return
end

