function acc = st_to_ccs_values ( nst, ist, jst, ast, ncc, n, icc, ccc )

%*****************************************************************************80
%
%% st_to_ccs_values() creates CCS values from ST data.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    14 July 2014
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer NST, the number of ST elements.
%
%    integer IST(NST), JST(NST), the ST rows and columns.
%
%    real AST(NST), the ST values.
%
%    integer NCC, the number of CCS elements.
%
%    integer N, the number of columns.
%
%    integer ICC(NCC), the CCS rows.
%
%    integer CCC(N+1), the CCS compressed columns.
%
%  Output:
%
%    real ACC(NCC), the CCS values.
%
  acc = zeros ( ncc, 1 );

  for kst = 1 : nst

    i = ist(kst);
    j = jst(kst);

    clo = ccc(j);
    chi = ccc(j+1);

    fail = 1;

    for kcc = clo : chi - 1
      if ( icc(kcc) == i )
        acc(kcc) = acc(kcc) + ast(kst);
        fail = 0;
        break
      end                 
    end

    if ( fail )
      fprintf ( 1, '\n' );
      fprintf ( 1, 'ST_TO_CCS_VALUES - Fatal error!\n' );
      fprintf ( 1, '  ST entry cannot be located in CCS array.\n' );
      fprintf ( 1, '  ST index KST    = %d\n', kst );
      fprintf ( 1, '  ST row IST(KST) = %d\n', ist(kst) );
      fprintf ( 1, '  ST col JST(KST) = %d\n', jst(kst) );
      fprintf ( 1, '  ST val AST(KST) = %g\n', ast(kst) );
      error ( 'ST_TO_CCS_VALUES - Fatal error!' );
    end

  end

  return
end
