function [ nz_num, ist, jst, Ast ] = ge_to_st ( Age )

%*****************************************************************************80
%
%% ge_to_st() converts a GE matrix to Sparse Triplet (ST) format.
%
%  Discussion:
%
%    ge is the general matrix format for an m x n matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 March 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 ist(nz_num), jst(nz_num), the row and column indices
%    of the nonzero elements.
%
%    real Ast(nz_num), the values of the nonzero elements.
%
  [ m, n ] = size ( Age );

  nz_num = nnz ( Age );
  ist = zeros ( nz_num );
  jst = zeros ( nz_num );
  Ast = zeros ( nz_num );
  
  k = 0;
  for j = 1 : n
    for i = 1 : m
      if ( Age(i,j) ~= 0.0 )
        k = k + 1;
        ist(k) = i;
        jst(k) = j;
        Ast(k) = Age(i,j);
      end
    end
  end

  return
end
