Fortran vs. C for numerical work (SUMMARY)

Tony Warnock ttw at lanl.gov
Wed Nov 28 10:38:17 AEST 1990



Re:
>> 2. C has no conformant arrays, i.e. you can't do the equivalent of:
>  [ ... ]
>> In C you either have to do your own indexing *(a + j*m +i) or have
>> pointers to pointers *(*(a + i) + j).
 
Dan Bernstein writes:
 
>I agree that this is a problem. However, the double-pointer solution
>usually allows faster access than the standard method of storing arrays,
>doesn't waste much memory, allows more flexibility, gets around the
>memory management problems of some small architectures, and lets you use
>a[i][j] for *(*(a + i) + j), all within current C. It is extremely
>difficult to do this efficiently in Fortran, and it will continue to be.
 
    What is it that Dan thinks is difficult? He uses only "this"
    so it is not clear what he has in mind. Fortran has allowed
    one to write a(i,j,k,l,m,n,p) for years. If done inside a
    loop where one of the supscripts is varying, there is only a
    single addition (if that) to do indexing. If the subscripts
    are chosed at random, how does having a pointer help: the
    necessary offset must still be gotten somehow.
 



More information about the Comp.lang.c mailing list