function r8ri_print_some ( n, nz, ija, a, ilo, jlo, ihi, jhi, title )

%*****************************************************************************80
%
%% R8RI_PRINT_SOME prints some of an R8RI matrix.
%
%  Discussion:
%
%    An R8RI matrix is in row indexed sparse storage form, using an index
%    array IJA and a value array A.  The first N entries of A store the
%    diagonal elements in order.  The first N entries of IJA store the index
%    of the first off-diagonal element of the corresponding row; if there is
%    no off-diagonal element in that row, it is one greater than the index
%    in A of the most recently stored element in the previous row.
%    Location 1 of IJA is always equal to N+2; location N+1 of IJA is one
%    greater than the index in A of the last off-diagonal element of the
%    last row.  Location N+1 of A is not used.  Entries in A with index
%    N+2 or greater contain the off-diagonal values, ordered by row, and
%    then by column.  Entries in IJA with index N+2 or greater contain the
%    column number of the corresponding element in A.
%
%  Example:
%
%    A:
%      3 0 1 0 0
%      0 4 0 0 0
%      0 7 5 9 0
%      0 0 0 0 2
%      0 0 0 6 8
%
%    NZ = 11
%
%    IJA:
%      7  8  8 10 11 12  3  2  4  5  4
%
%    A:
%      3  4  5  0  8  *  1  7  9  2  6
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    08 July 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the order of the matrix.
%
%    Input, integer NZ, the size required for the RI
%    or "row indexed" sparse storage.
%
%    Input, integer IJA(NZ), the index vector.
%
%    Input, real A(NZ), the value vector.
%
%    Input, integer ILO, JLO, IHI, JHI, the first row and
%    column, and the last row and column to be printed.
%
%    Input, string TITLE, a title.
%
  incx = 5;

  fprintf ( 1, '\n' );
  fprintf ( 1, '%s\n', title );
%
%  Print the columns of the matrix, in strips of 5.
%
  for j2lo = jlo : incx : jhi

    j2hi = j2lo + incx - 1;
    j2hi = min ( j2hi, n );
    j2hi = min ( j2hi, jhi );

    inc = j2hi + 1 - j2lo;

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Col: ' );

    for j = j2lo : j2hi
      fprintf ( 1, '%7d       ', j );
    end

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Row\n' );
    fprintf ( 1, '  ---\n' );
%
%  Determine the range of the rows in this strip.
%
    i2lo = max ( ilo, 1 );
    i2hi = min ( ihi, n );

    for i = i2lo : i2hi
%
%  Print out (up to) 5 entries in row I, J2LO <= J <= J2HI.
%
%  1) Assume everything is zero.
%
      aij(j2lo:j2hi) = 0.0;
%
%  2) Diagonal entry.
%
      if ( j2lo <= i && i <= j2hi )
        aij(i) = a(i);
      end
%
%  3) Now examine all the offdiagonal entries.
%
      for k = ija(i) : ija(i+1) - 1
        j = ija(k);
        if ( j2lo <= j && j <= j2hi )
          aij(j) = a(k);
        end
      end
      fprintf ( 1, '%5d  ', i )

      for j = j2lo : j2hi
        fprintf ( 1, '%14.6g', aij(j) );
      end
      fprintf ( 1, '\n' );

    end

  end

  return
end
