function rowcol = r8ncf_dif2_rowcol ( m, n, nz_num )

%*****************************************************************************80
%
%% R8NCF_DIF2_ROWCOL sets indexing for an R8NCF second difference matrix.
%
%  Discussion:
%
%    The R8NCF storage format stores NZ_NUM, the number of nonzeros, 
%    a real array containing the nonzero values, a 2 by NZ_NUM integer 
%    array storing the row and column of each nonzero entry.
%
%    The R8NCF format is used by NSPCG.  NSPCG requires that the information
%    for the diagonal entries of the matrix must come first.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    20 July 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M, N, the number of rows and columns in
%    the matrix.
%
%    Input, integer NZ_NUM, the number of nonzero entries.
%
%    Output, integer ROWCOL(2,NZ_NUM), the coordinates of 
%    the nonzero entries.
%
  rowcol = zeros ( 2, nz_num );

  k = 0;

  for i = 1 : m

    j = i - 1;
    if ( 1 <= j && j <= n )
      k = k + 1;
      rowcol(1,k) = i;
      rowcol(2,k) = j;
    end

    j = i;
    if ( j <= n )
      k = k + 1;
      rowcol(1,k) = i;
      rowcol(2,k) = j;
    end

    j = i + 1;
    if ( j <= n )
      k = k + 1;
      rowcol(1,k) = i;
      rowcol(2,k) = j;
    end

  end

  return
end

