function [ i, j ] = r8ccs_kij ( m, n, nz_num, colptr, rowind, k )

%*****************************************************************************80
%
%% r8ccs_kij() seeks (I,J), the full index of K, the sparse index of an r8ccs matrix.
%
%  Discussion:
%
%    The r8ccs format is the double precision sparse compressed column
%    format.  Associated with this format, we have an M by N matrix
%    with NZ_NUM nonzero entries.  We construct the column pointer
%    vector COL of length N+1, such that entries of column J will be
%    stored in positions COL(J) through COL(J+1)-1.  This indexing
%    refers to both the ROW and A vectors, which store the row indices
%    and the values of the nonzero entries.  The entries of the
%    ROW vector corresponding to each column are assumed to be
%    ascending sorted.
%
%    The r8ccs format is equivalent to the MATLAB "sparse" format,
%    and the Harwell Boeing "real unsymmetric assembled" (RUA) format.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 September 2006
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Iain Duff, Roger Grimes, John Lewis,
%    User's Guide for the Harwell-Boeing Sparse Matrix Collection,
%    October 1992
%
%  Input:
%
%    integer M, the number of rows of the matrix.
%
%    integer N, the number of columns of the matrix.
%
%    integer NZ_NUM, the number of nonzero entries.
%
%    integer COLPTR(N+1), indicate where each column's data begins.
%
%    integer ROWIND(NZ_NUM), the row indices.
%
%    integer K, the sparse index of an entry of the matrix.
%    1 <= K <= NZ_NUM.
%
%  Output:
%
%    integer I, J, the full indices corresponding to the sparse
%    index K.
%
  i = -1;
  j = -1;

  if ( k < 1 | nz_num < k )
    return
  end
%
%  The row index is easy.
%
  i = rowind(k);
%
%  Determine the column by bracketing in COLPTR.
%
  for jj = 1 : n
    k1 = colptr(jj);
    k2 = colptr(jj+1) - 1;
    if ( k1 <= k & k <= k2 )
      j = jj;
      break
    end
  end

  if ( j == -1 )
    return;
  end

  return
end
