Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!fluke!ssc-vax!bcsaic!clevea
From: clevea@bcsaic.UUCP (Cleve Ashcraft)
Newsgroups: comp.lang.c
Subject: Re: C vs. FORTRAN
Message-ID: <14080@bcsaic.UUCP>
Date: 16 Aug 89 14:11:30 GMT
References: <3288@ohstpy.mps.ohio-state.edu> <225800204@uxe.cso.uiuc.edu> <517@chem.ucsd.EDU> <14017@lanl.gov>
Reply-To: clevea@bcsaic.UUCP (Cleve Ashcraft)
Organization: Boeing Computer Services AI Center, Seattle
Lines: 52

In article <14017@lanl.gov> jlg@lanl.gov (Jim Giles) writes:
>
>From article <517@chem.ucsd.EDU>, by tps@chem.ucsd.edu (Tom Stockfisch):
>
>> Sparse matrices are also easier in C.
>
>I've heard this claim before, but I've never seen any advantage of either
>language for this.  In either case, the programmer must code a lot of index
>calculations - the only difference is whether the calculated index is
>added to a pointer or used as a subscript - big deal.
>

as someone who works with sparse matrices, i will agree with the
first statement, with the following qualification. just about
any numerical work on sparse matrices uses the following kernels,
quoted in C syntax.

daxpy :
for ( i = 0 ; i < size ; i++ )
   x[i] += alpha * y[i] ;

daxpyi :
for ( i = 0 ; i < size ; i++ )
   x[indices[i]] += alpha * y[i] ;

ddot :
for ( i = 0, sum = 0. ; i < size ; i++ )
   sum += x[i] * y[i] ;
return sum ;

ddoti :
for ( i = 0, sum = 0. ; i < size ; i++ )
   sum += x[i] * y[indices[i]] ;
return sum ;

in general, these kernels do not have their vector arguments
overlapped, and thus can be vectorized. some type of compiler
directive should be made available to generate good code on
vector machines. however, C has no advantage over Fortran for
these kernels.

where C does have an advantage is found in the ordering of
sparse matrices, the setting up of higher level graph structures,
and the dynamic storage allocation. sparse matrix algorithms
have gone a long way past the simple general sparse algorithm.
references on request.

i switched over to C about 18 months ago, and the productivity
benefits have made it worth it.

cleve ashcraft
clevea@atc.boeing.com