function [ m, n, nz, row, col, val ] = ge_to_crs ( A )

%*****************************************************************************80
%
%% ge_to_crs() copies a GE matrix to CRS format.
%
%  Discussion:
%
%    The CRS 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:
%
%    24 March 2026
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A(M,N): the matrix.
%
%  Output:
%
%    integer M, N: the order of the matrix.
%
%    integer NZ: the number of nonzero elements.
%
%    integer ROW(M+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.
%
  [ m, n ] = size ( A );
  nz = nnz ( A );
  row = zeros ( m + 1, 1 );
  col = zeros ( nz, 1 );
  val = zeros ( nz, 1 );

  row(1) = 1;
  k = 0;

  for i = 1 : m

    for j = 1 : n
      if ( A(i,j) ~= 0.0 )
        k = k + 1;
        col(k) = j;
        val(k) = A(i,j);
      end
    end

    row(i+1) = k + 1;

  end

  return
end

