function [ nz_num, colptr, rowind, Accs ] = ge_to_ccs ( Age )

%*****************************************************************************80
%
%% ge_to_ccs() converts a ge matrix to a ccs matrix.
%
%  Discussion:
%
%    ge is the general matrix format for an m x n matrix.
%
%    ccs is a sparse compressed column format.  The matrix is
%    assumed to have 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 ccs 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:
%
%    19 February 2026
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Iain Duff, Roger Grimes, John Lewis,
%    User's Guide for the Harwell-Boeing Sparse Matrix Collection,
%    October 1992
%
%  Input:
%
%    real Age(M,N): the GE format matrix.
%
%  Output:
%
%    integer nz_num, the number of nonzero elements.
%
%    integer colptr(n+1), points to the first element in Acc
%    of each column.
%
%    integer rowind(nz_num), contains the row indices of the elements.
%
%    real Accs(nz_num), the values of the matrix.
%
  [ m, n ] = size ( Age );

  nz_num = 0;
  colptr = zeros ( n + 1, 1 );
  rowind = zeros ( nnz ( Age ), 1 );
  Accs = zeros ( nnz ( Age ), 1 );
  
  k = 0;
  colptr(1) = 1;
  for j = 1 : n
    colptr(j+1) = colptr(j);
    for i = 1 : m
      if ( Age(i,j) ~= 0.0 )
        k = k + 1;
        Accs(k) = Age(i,j);
        rowind(k) = i;
        colptr(j+1) = colptr(j+1) + 1;
      end
    end
  end

  nz_num = k;

  return
end
